Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: content/browser/devtools/protocol/page_handler.h

Issue 2592983002: [devtools] Support different encodings for Page.CaptureScreenshot. (Closed)
Patch Set: Return gfx::Image from ui snapshot methods instead. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 8 #include <stddef.h>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "cc/output/compositor_frame_metadata.h" 14 #include "cc/output/compositor_frame_metadata.h"
15 #include "content/browser/devtools/protocol/devtools_domain_handler.h" 15 #include "content/browser/devtools/protocol/devtools_domain_handler.h"
16 #include "content/browser/devtools/protocol/page.h" 16 #include "content/browser/devtools/protocol/page.h"
17 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 #include "content/public/browser/readback_types.h" 19 #include "content/public/browser/readback_types.h"
20 20
21 class SkBitmap; 21 class SkBitmap;
22 22
23 namespace gfx {
24 class Image;
25 } // namespace gfx
26
23 namespace content { 27 namespace content {
24 28
25 class DevToolsSession; 29 class DevToolsSession;
26 class NavigationHandle; 30 class NavigationHandle;
27 class PageNavigationThrottle; 31 class PageNavigationThrottle;
28 class RenderFrameHostImpl; 32 class RenderFrameHostImpl;
29 class WebContentsImpl; 33 class WebContentsImpl;
30 34
31 namespace protocol { 35 namespace protocol {
32 36
(...skipping 25 matching lines...) Expand all
58 Response Navigate(const std::string& url, Page::FrameId* frame_id) override; 62 Response Navigate(const std::string& url, Page::FrameId* frame_id) override;
59 Response StopLoading() override; 63 Response StopLoading() override;
60 64
61 using NavigationEntries = protocol::Array<Page::NavigationEntry>; 65 using NavigationEntries = protocol::Array<Page::NavigationEntry>;
62 Response GetNavigationHistory( 66 Response GetNavigationHistory(
63 int* current_index, 67 int* current_index,
64 std::unique_ptr<NavigationEntries>* entries) override; 68 std::unique_ptr<NavigationEntries>* entries) override;
65 Response NavigateToHistoryEntry(int entry_id) override; 69 Response NavigateToHistoryEntry(int entry_id) override;
66 70
67 void CaptureScreenshot( 71 void CaptureScreenshot(
72 Maybe<std::string> format,
73 Maybe<int> quality,
68 std::unique_ptr<CaptureScreenshotCallback> callback) override; 74 std::unique_ptr<CaptureScreenshotCallback> callback) override;
69 Response StartScreencast(Maybe<std::string> format, 75 Response StartScreencast(Maybe<std::string> format,
70 Maybe<int> quality, 76 Maybe<int> quality,
71 Maybe<int> max_width, 77 Maybe<int> max_width,
72 Maybe<int> max_height, 78 Maybe<int> max_height,
73 Maybe<int> every_nth_frame) override; 79 Maybe<int> every_nth_frame) override;
74 Response StopScreencast() override; 80 Response StopScreencast() override;
75 Response ScreencastFrameAck(int session_id) override; 81 Response ScreencastFrameAck(int session_id) override;
76 82
77 Response HandleJavaScriptDialog(bool accept, 83 Response HandleJavaScriptDialog(bool accept,
78 Maybe<std::string> prompt_text) override; 84 Maybe<std::string> prompt_text) override;
79 85
80 Response SetColorPickerEnabled(bool enabled) override; 86 Response SetColorPickerEnabled(bool enabled) override;
81 Response RequestAppBanner() override; 87 Response RequestAppBanner() override;
82 88
83 Response SetControlNavigations(bool enabled) override; 89 Response SetControlNavigations(bool enabled) override;
84 Response ProcessNavigation(const std::string& response, 90 Response ProcessNavigation(const std::string& response,
85 int navigation_id) override; 91 int navigation_id) override;
86 92
87 std::unique_ptr<PageNavigationThrottle> CreateThrottleForNavigation( 93 std::unique_ptr<PageNavigationThrottle> CreateThrottleForNavigation(
88 NavigationHandle* navigation_handle); 94 NavigationHandle* navigation_handle);
89 95
90 void OnPageNavigationThrottleDisposed(int navigation_id); 96 void OnPageNavigationThrottleDisposed(int navigation_id);
91 void NavigationRequested(const PageNavigationThrottle* throttle); 97 void NavigationRequested(const PageNavigationThrottle* throttle);
92 98
93 private: 99 private:
100 enum EncodingFormat { PNG, JPEG };
101
94 WebContentsImpl* GetWebContents(); 102 WebContentsImpl* GetWebContents();
95 void NotifyScreencastVisibility(bool visible); 103 void NotifyScreencastVisibility(bool visible);
96 void InnerSwapCompositorFrame(); 104 void InnerSwapCompositorFrame();
97 void ScreencastFrameCaptured(cc::CompositorFrameMetadata metadata, 105 void ScreencastFrameCaptured(cc::CompositorFrameMetadata metadata,
98 const SkBitmap& bitmap, 106 const SkBitmap& bitmap,
99 ReadbackResponse response); 107 ReadbackResponse response);
100 void ScreencastFrameEncoded(cc::CompositorFrameMetadata metadata, 108 void ScreencastFrameEncoded(cc::CompositorFrameMetadata metadata,
101 const base::Time& timestamp, 109 const base::Time& timestamp,
102 const std::string& data); 110 const std::string& data);
103 111
104 void ScreenshotCaptured( 112 void ScreenshotCaptured(std::unique_ptr<CaptureScreenshotCallback> callback,
105 std::unique_ptr<CaptureScreenshotCallback> callback, 113 const std::string& format,
106 const unsigned char* png_data, 114 int quality,
107 size_t png_size); 115 const gfx::Image& image);
116 void ScreenshotEncoded(std::unique_ptr<CaptureScreenshotCallback> callback,
117 const std::string& data);
108 118
109 void OnColorPicked(int r, int g, int b, int a); 119 void OnColorPicked(int r, int g, int b, int a);
110 120
111 // NotificationObserver overrides. 121 // NotificationObserver overrides.
112 void Observe(int type, 122 void Observe(int type,
113 const NotificationSource& source, 123 const NotificationSource& source,
114 const NotificationDetails& details) override; 124 const NotificationDetails& details) override;
115 125
116 bool enabled_; 126 bool enabled_;
117 127
(...skipping 22 matching lines...) Expand all
140 NotificationRegistrar registrar_; 150 NotificationRegistrar registrar_;
141 base::WeakPtrFactory<PageHandler> weak_factory_; 151 base::WeakPtrFactory<PageHandler> weak_factory_;
142 152
143 DISALLOW_COPY_AND_ASSIGN(PageHandler); 153 DISALLOW_COPY_AND_ASSIGN(PageHandler);
144 }; 154 };
145 155
146 } // namespace protocol 156 } // namespace protocol
147 } // namespace content 157 } // namespace content
148 158
149 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_ 159 #endif // CONTENT_BROWSER_DEVTOOLS_PROTOCOL_PAGE_HANDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698