Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / devtools / protocol / page_handler.h
blobfff0cda58ecc00f371376fd8845a893e9e91218b
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_
6 #define CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/memory/weak_ptr.h"
11 #include "base/time/time.h"
12 #include "cc/output/compositor_frame_metadata.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"
16 #include "content/public/browser/readback_types.h"
18 class SkBitmap;
20 namespace content {
22 class RenderFrameHostImpl;
23 class WebContentsImpl;
25 namespace devtools {
26 namespace page {
28 class ColorPicker;
30 class PageHandler : public NotificationObserver {
31 public:
32 typedef DevToolsProtocolClient::Response Response;
34 class ScreencastListener {
35 public:
36 virtual ~ScreencastListener() { }
37 virtual void ScreencastEnabledChanged() = 0;
40 PageHandler();
41 ~PageHandler() override;
43 void SetRenderFrameHost(RenderFrameHostImpl* host);
44 void SetClient(scoped_ptr<Client> client);
45 void Detached();
46 void OnSwapCompositorFrame(const cc::CompositorFrameMetadata& frame_metadata);
47 void DidAttachInterstitialPage();
48 void DidDetachInterstitialPage();
49 void SetScreencastListener(ScreencastListener* listener);
50 bool screencast_enabled() const { return enabled_ && screencast_enabled_; }
52 Response Enable();
53 Response Disable();
55 Response Reload(const bool* ignoreCache,
56 const std::string* script_to_evaluate_on_load,
57 const std::string* script_preprocessor = NULL);
59 Response Navigate(const std::string& url, FrameId* frame_id);
61 using NavigationEntries = std::vector<scoped_refptr<NavigationEntry>>;
62 Response GetNavigationHistory(int* current_index,
63 NavigationEntries* entries);
65 Response NavigateToHistoryEntry(int entry_id);
67 Response CaptureScreenshot(DevToolsCommandId command_id);
69 Response CanScreencast(bool* result);
70 Response StartScreencast(const std::string* format,
71 const int* quality,
72 const int* max_width,
73 const int* max_height);
74 Response StopScreencast();
75 Response ScreencastFrameAck(int frame_number);
77 Response HandleJavaScriptDialog(bool accept, const std::string* prompt_text);
79 Response QueryUsageAndQuota(DevToolsCommandId command_id,
80 const std::string& security_origin);
82 Response SetColorPickerEnabled(bool enabled);
84 private:
85 WebContentsImpl* GetWebContents();
86 void NotifyScreencastVisibility(bool visible);
87 void InnerSwapCompositorFrame();
88 void ScreencastFrameCaptured(const cc::CompositorFrameMetadata& metadata,
89 const SkBitmap& bitmap,
90 ReadbackResponse response);
91 void ScreencastFrameEncoded(const cc::CompositorFrameMetadata& metadata,
92 const base::Time& timestamp,
93 const std::string& data);
95 void ScreenshotCaptured(
96 DevToolsCommandId command_id,
97 const unsigned char* png_data,
98 size_t png_size);
100 void OnColorPicked(int r, int g, int b, int a);
102 // NotificationObserver overrides.
103 void Observe(int type,
104 const NotificationSource& source,
105 const NotificationDetails& details) override;
107 bool enabled_;
109 bool screencast_enabled_;
110 std::string screencast_format_;
111 int screencast_quality_;
112 int screencast_max_width_;
113 int screencast_max_height_;
114 int capture_retry_count_;
115 bool has_compositor_frame_metadata_;
116 cc::CompositorFrameMetadata next_compositor_frame_metadata_;
117 cc::CompositorFrameMetadata last_compositor_frame_metadata_;
118 int screencast_frame_sent_;
119 int screencast_frame_acked_;
120 bool processing_screencast_frame_;
122 scoped_ptr<ColorPicker> color_picker_;
124 RenderFrameHostImpl* host_;
125 scoped_ptr<Client> client_;
126 ScreencastListener* screencast_listener_;
127 NotificationRegistrar registrar_;
128 base::WeakPtrFactory<PageHandler> weak_factory_;
130 DISALLOW_COPY_AND_ASSIGN(PageHandler);
133 } // namespace page
134 } // namespace devtools
135 } // namespace content
137 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_