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

Side by Side Diff: extensions/browser/api/guest_view/web_view/web_view_internal_api.h

Issue 1582053002: Implement webview.captureVisibleRegion() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix test so it waits for the first frame to be generated. Created 4 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 EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ 5 #ifndef EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
6 #define EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ 6 #define EXTENSIONS_BROWSER_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "extensions/browser/api/capture_web_contents_function.h"
12 #include "extensions/browser/api/execute_code_function.h" 11 #include "extensions/browser/api/execute_code_function.h"
12 #include "extensions/browser/api/web_contents_capture_client.h"
13 #include "extensions/browser/extension_function.h" 13 #include "extensions/browser/extension_function.h"
14 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" 14 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h"
15 #include "extensions/browser/guest_view/web_view/web_view_guest.h" 15 #include "extensions/browser/guest_view/web_view/web_view_guest.h"
16 16
17 // WARNING: WebViewInternal could be loaded in an unblessed context, thus any 17 // WARNING: WebViewInternal could be loaded in an unblessed context, thus any
18 // new APIs must extend WebViewInternalExtensionFunction or 18 // new APIs must extend WebViewInternalExtensionFunction or
19 // WebViewInternalExecuteCodeFunction which do a process ID check to prevent 19 // WebViewInternalExecuteCodeFunction which do a process ID check to prevent
20 // abuse by normal renderer processes. 20 // abuse by normal renderer processes.
21 namespace extensions { 21 namespace extensions {
22 22
23 // An abstract base class for async webview APIs. It does a process ID check 23 // An abstract base class for async webview APIs. It does a process ID check
24 // in RunAsync, and then calls RunAsyncSafe which must be overriden by all 24 // in RunAsync, and then calls RunAsyncSafe which must be overriden by all
25 // subclasses. 25 // subclasses.
26 class WebViewInternalExtensionFunction : public AsyncExtensionFunction { 26 class WebViewInternalExtensionFunction : public AsyncExtensionFunction {
27 public: 27 public:
28 WebViewInternalExtensionFunction() {} 28 WebViewInternalExtensionFunction() {}
29 29
30 protected: 30 protected:
31 ~WebViewInternalExtensionFunction() override {} 31 ~WebViewInternalExtensionFunction() override {}
32 32
33 // ExtensionFunction implementation. 33 // ExtensionFunction implementation.
34 bool RunAsync() final; 34 bool RunAsync() final;
35 35
36 private: 36 private:
37 virtual bool RunAsyncSafe(WebViewGuest* guest) = 0; 37 virtual bool RunAsyncSafe(WebViewGuest* guest) = 0;
38 }; 38 };
39 39
40 class WebViewInternalCaptureVisibleRegionFunction
41 : public WebViewInternalExtensionFunction,
42 public WebContentsCaptureClient {
43 public:
44 DECLARE_EXTENSION_FUNCTION("webViewInternal.captureVisibleRegion",
45 WEBVIEWINTERNAL_CAPTUREVISIBLEREGION);
46 WebViewInternalCaptureVisibleRegionFunction() {}
47
48 protected:
49 ~WebViewInternalCaptureVisibleRegionFunction() override {}
50
51 private:
52 // WebViewInternalExtensionFunction implementation.
53 bool RunAsyncSafe(WebViewGuest* guest) override;
54
55 // extensions::WebContentsCaptureClient:
56 bool IsScreenshotEnabled() override;
57 void OnCaptureSuccess(const SkBitmap& bitmap) override;
58 void OnCaptureFailure(FailureReason reason) override;
59
60 DISALLOW_COPY_AND_ASSIGN(WebViewInternalCaptureVisibleRegionFunction);
61 };
62
40 class WebViewInternalNavigateFunction 63 class WebViewInternalNavigateFunction
41 : public WebViewInternalExtensionFunction { 64 : public WebViewInternalExtensionFunction {
42 public: 65 public:
43 DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate", 66 DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate",
44 WEBVIEWINTERNAL_NAVIGATE); 67 WEBVIEWINTERNAL_NAVIGATE);
45 WebViewInternalNavigateFunction() {} 68 WebViewInternalNavigateFunction() {}
46 69
47 protected: 70 protected:
48 ~WebViewInternalNavigateFunction() override {} 71 ~WebViewInternalNavigateFunction() override {}
49 72
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 uint32_t remove_mask_; 479 uint32_t remove_mask_;
457 // Tracks any data related or parse errors. 480 // Tracks any data related or parse errors.
458 bool bad_message_; 481 bool bad_message_;
459 482
460 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); 483 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction);
461 }; 484 };
462 485
463 } // namespace extensions 486 } // namespace extensions
464 487
465 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ 488 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698