| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_ | 5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_ |
| 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_ | 6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
| 11 #include "base/time/time.h" | 11 #include "base/time/time.h" |
| 12 #include "cc/output/compositor_frame_metadata.h" | 12 #include "cc/output/compositor_frame_metadata.h" |
| 13 #include "content/browser/devtools/protocol/devtools_protocol_handler.h" | 13 #include "content/browser/devtools/protocol/devtools_protocol_handler.h" |
| 14 #include "content/public/browser/notification_observer.h" |
| 15 #include "content/public/browser/notification_registrar.h" |
| 14 #include "content/public/browser/readback_types.h" | 16 #include "content/public/browser/readback_types.h" |
| 15 | 17 |
| 16 class SkBitmap; | 18 class SkBitmap; |
| 17 | 19 |
| 18 namespace content { | 20 namespace content { |
| 19 | 21 |
| 20 class RenderViewHostImpl; | 22 class RenderFrameHostImpl; |
| 23 class WebContentsImpl; |
| 21 | 24 |
| 22 namespace devtools { | 25 namespace devtools { |
| 23 namespace page { | 26 namespace page { |
| 24 | 27 |
| 25 class ColorPicker; | 28 class ColorPicker; |
| 26 | 29 |
| 27 class PageHandler { | 30 class PageHandler : public NotificationObserver { |
| 28 public: | 31 public: |
| 29 typedef DevToolsProtocolClient::Response Response; | 32 typedef DevToolsProtocolClient::Response Response; |
| 30 | 33 |
| 31 class ScreencastListener { | 34 class ScreencastListener { |
| 32 public: | 35 public: |
| 33 virtual ~ScreencastListener() { } | 36 virtual ~ScreencastListener() { } |
| 34 virtual void ScreencastEnabledChanged() = 0; | 37 virtual void ScreencastEnabledChanged() = 0; |
| 35 }; | 38 }; |
| 36 | 39 |
| 37 PageHandler(); | 40 PageHandler(); |
| 38 virtual ~PageHandler(); | 41 ~PageHandler() override; |
| 39 | 42 |
| 40 void SetRenderViewHost(RenderViewHostImpl* host); | 43 void SetRenderFrameHost(RenderFrameHostImpl* host); |
| 41 void SetClient(scoped_ptr<Client> client); | 44 void SetClient(scoped_ptr<Client> client); |
| 42 void Detached(); | 45 void Detached(); |
| 43 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); | 46 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata); |
| 44 void OnVisibilityChanged(bool visible); | |
| 45 void DidAttachInterstitialPage(); | 47 void DidAttachInterstitialPage(); |
| 46 void DidDetachInterstitialPage(); | 48 void DidDetachInterstitialPage(); |
| 47 void SetScreencastListener(ScreencastListener* listener); | 49 void SetScreencastListener(ScreencastListener* listener); |
| 48 bool screencast_enabled() const { return enabled_ && screencast_enabled_; } | 50 bool screencast_enabled() const { return enabled_ && screencast_enabled_; } |
| 49 | 51 |
| 50 Response Enable(); | 52 Response Enable(); |
| 51 Response Disable(); | 53 Response Disable(); |
| 52 | 54 |
| 53 Response Reload(const bool* ignoreCache, | 55 Response Reload(const bool* ignoreCache, |
| 54 const std::string* script_to_evaluate_on_load, | 56 const std::string* script_to_evaluate_on_load, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 73 Response ScreencastFrameAck(int frame_number); | 75 Response ScreencastFrameAck(int frame_number); |
| 74 | 76 |
| 75 Response HandleJavaScriptDialog(bool accept, const std::string* prompt_text); | 77 Response HandleJavaScriptDialog(bool accept, const std::string* prompt_text); |
| 76 | 78 |
| 77 Response QueryUsageAndQuota(DevToolsCommandId command_id, | 79 Response QueryUsageAndQuota(DevToolsCommandId command_id, |
| 78 const std::string& security_origin); | 80 const std::string& security_origin); |
| 79 | 81 |
| 80 Response SetColorPickerEnabled(bool enabled); | 82 Response SetColorPickerEnabled(bool enabled); |
| 81 | 83 |
| 82 private: | 84 private: |
| 85 WebContentsImpl* GetWebContents(); |
| 83 void NotifyScreencastVisibility(bool visible); | 86 void NotifyScreencastVisibility(bool visible); |
| 84 void InnerSwapCompositorFrame(); | 87 void InnerSwapCompositorFrame(); |
| 85 void ScreencastFrameCaptured(const cc::CompositorFrameMetadata& metadata, | 88 void ScreencastFrameCaptured(const cc::CompositorFrameMetadata& metadata, |
| 86 const SkBitmap& bitmap, | 89 const SkBitmap& bitmap, |
| 87 ReadbackResponse response); | 90 ReadbackResponse response); |
| 88 void ScreencastFrameEncoded(const cc::CompositorFrameMetadata& metadata, | 91 void ScreencastFrameEncoded(const cc::CompositorFrameMetadata& metadata, |
| 89 const base::Time& timestamp, | 92 const base::Time& timestamp, |
| 90 const std::string& data); | 93 const std::string& data); |
| 91 | 94 |
| 92 void ScreenshotCaptured( | 95 void ScreenshotCaptured( |
| 93 DevToolsCommandId command_id, | 96 DevToolsCommandId command_id, |
| 94 const unsigned char* png_data, | 97 const unsigned char* png_data, |
| 95 size_t png_size); | 98 size_t png_size); |
| 96 | 99 |
| 97 void OnColorPicked(int r, int g, int b, int a); | 100 void OnColorPicked(int r, int g, int b, int a); |
| 98 | 101 |
| 102 // NotificationObserver overrides. |
| 103 void Observe(int type, |
| 104 const NotificationSource& source, |
| 105 const NotificationDetails& details) override; |
| 106 |
| 99 bool enabled_; | 107 bool enabled_; |
| 100 | 108 |
| 101 bool screencast_enabled_; | 109 bool screencast_enabled_; |
| 102 std::string screencast_format_; | 110 std::string screencast_format_; |
| 103 int screencast_quality_; | 111 int screencast_quality_; |
| 104 int screencast_max_width_; | 112 int screencast_max_width_; |
| 105 int screencast_max_height_; | 113 int screencast_max_height_; |
| 106 int capture_retry_count_; | 114 int capture_retry_count_; |
| 107 bool has_compositor_frame_metadata_; | 115 bool has_compositor_frame_metadata_; |
| 108 cc::CompositorFrameMetadata next_compositor_frame_metadata_; | 116 cc::CompositorFrameMetadata next_compositor_frame_metadata_; |
| 109 cc::CompositorFrameMetadata last_compositor_frame_metadata_; | 117 cc::CompositorFrameMetadata last_compositor_frame_metadata_; |
| 110 int screencast_frame_sent_; | 118 int screencast_frame_sent_; |
| 111 int screencast_frame_acked_; | 119 int screencast_frame_acked_; |
| 112 bool processing_screencast_frame_; | 120 bool processing_screencast_frame_; |
| 113 | 121 |
| 114 scoped_ptr<ColorPicker> color_picker_; | 122 scoped_ptr<ColorPicker> color_picker_; |
| 115 | 123 |
| 116 RenderViewHostImpl* host_; | 124 RenderFrameHostImpl* host_; |
| 117 scoped_ptr<Client> client_; | 125 scoped_ptr<Client> client_; |
| 118 ScreencastListener* screencast_listener_; | 126 ScreencastListener* screencast_listener_; |
| 127 NotificationRegistrar registrar_; |
| 119 base::WeakPtrFactory<PageHandler> weak_factory_; | 128 base::WeakPtrFactory<PageHandler> weak_factory_; |
| 120 | 129 |
| 121 DISALLOW_COPY_AND_ASSIGN(PageHandler); | 130 DISALLOW_COPY_AND_ASSIGN(PageHandler); |
| 122 }; | 131 }; |
| 123 | 132 |
| 124 } // namespace page | 133 } // namespace page |
| 125 } // namespace devtools | 134 } // namespace devtools |
| 126 } // namespace content | 135 } // namespace content |
| 127 | 136 |
| 128 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_ | 137 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_ |
| OLD | NEW |