| 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 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" |
| 11 #include "extensions/browser/api/execute_code_function.h" | 12 #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 | |
| 63 class WebViewInternalNavigateFunction | 40 class WebViewInternalNavigateFunction |
| 64 : public WebViewInternalExtensionFunction { | 41 : public WebViewInternalExtensionFunction { |
| 65 public: | 42 public: |
| 66 DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate", | 43 DECLARE_EXTENSION_FUNCTION("webViewInternal.navigate", |
| 67 WEBVIEWINTERNAL_NAVIGATE); | 44 WEBVIEWINTERNAL_NAVIGATE); |
| 68 WebViewInternalNavigateFunction() {} | 45 WebViewInternalNavigateFunction() {} |
| 69 | 46 |
| 70 protected: | 47 protected: |
| 71 ~WebViewInternalNavigateFunction() override {} | 48 ~WebViewInternalNavigateFunction() override {} |
| 72 | 49 |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 479 uint32_t remove_mask_; | 456 uint32_t remove_mask_; |
| 480 // Tracks any data related or parse errors. | 457 // Tracks any data related or parse errors. |
| 481 bool bad_message_; | 458 bool bad_message_; |
| 482 | 459 |
| 483 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); | 460 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); |
| 484 }; | 461 }; |
| 485 | 462 |
| 486 } // namespace extensions | 463 } // namespace extensions |
| 487 | 464 |
| 488 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ | 465 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ |
| OLD | NEW |