12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file. 42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_ 62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_ 72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/basictypes.h" 92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/compiler_specific.h" 10effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "base/memory/ref_counted_memory.h" 112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "base/memory/scoped_ptr.h" 12bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch#include "base/memory/weak_ptr.h" 1358537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles)#include "base/time/time.h" 14424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)#include "cc/output/compositor_frame_metadata.h" 152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include "content/browser/devtools/devtools_protocol.h" 164e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)#include "content/common/content_export.h" 1703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "content/public/browser/render_widget_host.h" 1803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)#include "third_party/skia/include/core/SkBitmap.h" 192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 20c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdochclass SkBitmap; 21c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch 22424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)namespace IPC { 23424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)class Message; 24424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles)} 25424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) 2603b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)namespace blink { 2703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)class WebMouseEvent; 2803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles)} 2903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) 302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace content { 312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 32ca12bfac764ba476d6cd062bf1dde12cc64c3f40Ben Murdochclass DevToolsTracingHandler; 336e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)class RenderViewHostImpl; 342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Overrides Inspector commands before they are sent to the renderer. 362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// May override the implementation completely, ignore it, or handle 372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// additional browser process implementation details. 384e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)class CONTENT_EXPORT RendererOverridesHandler 394e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) : public DevToolsProtocol::Handler { 402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public: 4103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) RendererOverridesHandler(); 422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) virtual ~RendererOverridesHandler(); 432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 443551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void OnClientDetached(); 45a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); 4668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) void OnVisibilityChanged(bool visible); 4703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void SetRenderViewHost(RenderViewHostImpl* host); 4803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void ClearRenderViewHost(); 491320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci void DidAttachInterstitialPage(); 501320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci void DidDetachInterstitialPage(); 513551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private: 53424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) void InnerSwapCompositorFrame(); 543551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 553551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // DOM domain. 56bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_refptr<DevToolsProtocol::Response> 57bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch GrantPermissionsForSetFileInputFiles( 58bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_refptr<DevToolsProtocol::Command> command); 593551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 605c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu // Network domain. 6103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> CanEmulateNetworkConditions( 6203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 635c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu scoped_refptr<DevToolsProtocol::Response> ClearBrowserCache( 645c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu scoped_refptr<DevToolsProtocol::Command> command); 655c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu scoped_refptr<DevToolsProtocol::Response> ClearBrowserCookies( 665c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu scoped_refptr<DevToolsProtocol::Command> command); 675c02ac1a9c1b504631c0a3d2b6e737b5d738bae1Bo Liu 683551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Page domain. 691320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci scoped_refptr<DevToolsProtocol::Response> PageEnable( 701320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci scoped_refptr<DevToolsProtocol::Command> command); 713551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageDisable( 723551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 73bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_refptr<DevToolsProtocol::Response> PageHandleJavaScriptDialog( 74bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_refptr<DevToolsProtocol::Command> command); 75bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_refptr<DevToolsProtocol::Response> PageNavigate( 76bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_refptr<DevToolsProtocol::Command> command); 7768043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageReload( 7868043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 7958537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageGetNavigationHistory( 8058537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 8158537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageNavigateToHistoryEntry( 8258537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 8303b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageSetTouchEmulationEnabled( 8403b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 85bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_refptr<DevToolsProtocol::Response> PageCaptureScreenshot( 86bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch scoped_refptr<DevToolsProtocol::Command> command); 871320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci scoped_refptr<DevToolsProtocol::Response> PageCanEmulate( 881320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci scoped_refptr<DevToolsProtocol::Command> command); 898bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageCanScreencast( 908bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 913551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageStartScreencast( 923551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 933551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageStopScreencast( 943551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 954e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageQueryUsageAndQuota( 964e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Command>); 9703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> PageSetColorPickerEnabled( 9803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command>); 99bb1529ce867d8845a77ec7cdf3e3003ef1771a40Ben Murdoch 100c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch void ScreenshotCaptured( 101c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch scoped_refptr<DevToolsProtocol::Command> command, 102116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const unsigned char* png_data, 103116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch size_t png_size); 104effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch 105effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch void ScreencastFrameCaptured( 106c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch const std::string& format, 107c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch int quality, 108424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) const cc::CompositorFrameMetadata& metadata, 109c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch bool success, 110c2db58bd994c04d98e4ee2cd7565b71548655fe3Ben Murdoch const SkBitmap& bitmap); 1112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1124e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) void PageQueryUsageAndQuotaCompleted( 1134e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Command>, 1144e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) scoped_ptr<base::DictionaryValue> response_data); 1154e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) 11668043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) void NotifyScreencastVisibility(bool visible); 11703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void SetColorPickerEnabled(bool enabled); 11803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void UpdateColorPickerFrame(); 11903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void ResetColorPickerFrame(); 12003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void ColorPickerFrameUpdated(bool succeeded, const SkBitmap& bitmap); 12103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) bool HandleMouseEvent(const blink::WebMouseEvent& event); 12203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void UpdateColorPickerCursor(); 12368043e1e95eeb07d5cae7aca370b26518b0867d6Torne (Richard Coles) 1243551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) // Input domain. 1255f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) scoped_refptr<DevToolsProtocol::Response> InputEmulateTouchFromMouseEvent( 1263551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> command); 1273551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 12803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) void UpdateTouchEventEmulationState(); 1296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles) 13003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) RenderViewHostImpl* host_; 1311320f92c476a1ad9d19dba2a48c72b75566198e9Primiano Tucci bool page_domain_enabled_; 1323551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<DevToolsProtocol::Command> screencast_command_; 1335f1c94371a64b3196d4be9466099bb892df9b88eTorne (Richard Coles) bool has_last_compositor_frame_metadata_; 134424c4d7b64af9d0d8fd9624f381f469654d5e3d2Torne (Richard Coles) cc::CompositorFrameMetadata last_compositor_frame_metadata_; 13558537e28ecd584eab876aee8be7156509866d23aTorne (Richard Coles) base::TimeTicks last_frame_time_; 1368bcbed890bc3ce4d7a057a8f32cab53fa534672eTorne (Richard Coles) int capture_retry_count_; 13703b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) bool touch_emulation_enabled_; 13803b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) bool color_picker_enabled_; 13903b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) SkBitmap color_picker_frame_; 14003b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) int last_cursor_x_; 14103b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) int last_cursor_y_; 14203b57e008b61dfcb1fbad3aea950ae0e001748b0Torne (Richard Coles) RenderWidgetHost::MouseEventCallback mouse_event_callback_; 1434e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles) base::WeakPtrFactory<RendererOverridesHandler> weak_factory_; 1442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) DISALLOW_COPY_AND_ASSIGN(RendererOverridesHandler); 1452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}; 1462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)} // namespace content 1482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) 1492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif // CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_ 150