1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_ 6 #define CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/weak_ptr.h" 12 #include "base/time/time.h" 13 #include "cc/output/compositor_frame_metadata.h" 14 #include "content/browser/devtools/devtools_protocol.h" 15 #include "content/common/content_export.h" 16 17 class SkBitmap; 18 19 namespace IPC { 20 class Message; 21 } 22 23 namespace content { 24 25 class DevToolsAgentHost; 26 class DevToolsTracingHandler; 27 28 // Overrides Inspector commands before they are sent to the renderer. 29 // May override the implementation completely, ignore it, or handle 30 // additional browser process implementation details. 31 class CONTENT_EXPORT RendererOverridesHandler 32 : public DevToolsProtocol::Handler { 33 public: 34 explicit RendererOverridesHandler(DevToolsAgentHost* agent); 35 virtual ~RendererOverridesHandler(); 36 37 void OnClientDetached(); 38 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); 39 void OnVisibilityChanged(bool visible); 40 41 private: 42 void InnerSwapCompositorFrame(); 43 void ParseCaptureParameters(DevToolsProtocol::Command* command, 44 std::string* format, int* quality, 45 double* scale); 46 47 // DOM domain. 48 scoped_refptr<DevToolsProtocol::Response> 49 GrantPermissionsForSetFileInputFiles( 50 scoped_refptr<DevToolsProtocol::Command> command); 51 52 // Page domain. 53 scoped_refptr<DevToolsProtocol::Response> PageDisable( 54 scoped_refptr<DevToolsProtocol::Command> command); 55 scoped_refptr<DevToolsProtocol::Response> PageHandleJavaScriptDialog( 56 scoped_refptr<DevToolsProtocol::Command> command); 57 scoped_refptr<DevToolsProtocol::Response> PageNavigate( 58 scoped_refptr<DevToolsProtocol::Command> command); 59 scoped_refptr<DevToolsProtocol::Response> PageReload( 60 scoped_refptr<DevToolsProtocol::Command> command); 61 scoped_refptr<DevToolsProtocol::Response> PageGetNavigationHistory( 62 scoped_refptr<DevToolsProtocol::Command> command); 63 scoped_refptr<DevToolsProtocol::Response> PageNavigateToHistoryEntry( 64 scoped_refptr<DevToolsProtocol::Command> command); 65 scoped_refptr<DevToolsProtocol::Response> PageCaptureScreenshot( 66 scoped_refptr<DevToolsProtocol::Command> command); 67 scoped_refptr<DevToolsProtocol::Response> PageCanScreencast( 68 scoped_refptr<DevToolsProtocol::Command> command); 69 scoped_refptr<DevToolsProtocol::Response> PageStartScreencast( 70 scoped_refptr<DevToolsProtocol::Command> command); 71 scoped_refptr<DevToolsProtocol::Response> PageStopScreencast( 72 scoped_refptr<DevToolsProtocol::Command> command); 73 scoped_refptr<DevToolsProtocol::Response> PageQueryUsageAndQuota( 74 scoped_refptr<DevToolsProtocol::Command>); 75 76 void ScreenshotCaptured( 77 scoped_refptr<DevToolsProtocol::Command> command, 78 const std::string& format, 79 int quality, 80 const cc::CompositorFrameMetadata& metadata, 81 bool success, 82 const SkBitmap& bitmap); 83 84 void PageQueryUsageAndQuotaCompleted( 85 scoped_refptr<DevToolsProtocol::Command>, 86 scoped_ptr<base::DictionaryValue> response_data); 87 88 void NotifyScreencastVisibility(bool visible); 89 90 // Input domain. 91 scoped_refptr<DevToolsProtocol::Response> InputDispatchMouseEvent( 92 scoped_refptr<DevToolsProtocol::Command> command); 93 scoped_refptr<DevToolsProtocol::Response> InputDispatchGestureEvent( 94 scoped_refptr<DevToolsProtocol::Command> command); 95 96 DevToolsAgentHost* agent_; 97 scoped_refptr<DevToolsProtocol::Command> screencast_command_; 98 cc::CompositorFrameMetadata last_compositor_frame_metadata_; 99 base::TimeTicks last_frame_time_; 100 int capture_retry_count_; 101 base::WeakPtrFactory<RendererOverridesHandler> weak_factory_; 102 DISALLOW_COPY_AND_ASSIGN(RendererOverridesHandler); 103 }; 104 105 } // namespace content 106 107 #endif // CONTENT_BROWSER_DEVTOOLS_RENDERER_OVERRIDES_HANDLER_H_ 108