| 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 "extensions/browser/api/capture_web_contents_function.h" | 8 #include "extensions/browser/api/capture_web_contents_function.h" |
| 9 #include "extensions/browser/api/execute_code_function.h" | 9 #include "extensions/browser/api/execute_code_function.h" |
| 10 #include "extensions/browser/extension_function.h" | 10 #include "extensions/browser/extension_function.h" |
| 11 #include "extensions/browser/guest_view/web_view/web_ui/web_ui_url_fetcher.h" |
| 11 #include "extensions/browser/guest_view/web_view/web_view_guest.h" | 12 #include "extensions/browser/guest_view/web_view/web_view_guest.h" |
| 12 | 13 |
| 13 // WARNING: WebViewInternal could be loaded in an unblessed context, thus any | 14 // WARNING: WebViewInternal could be loaded in an unblessed context, thus any |
| 14 // new APIs must extend WebViewInternalExtensionFunction or | 15 // new APIs must extend WebViewInternalExtensionFunction or |
| 15 // WebViewInternalExecuteCodeFunction which do a process ID check to prevent | 16 // WebViewInternalExecuteCodeFunction which do a process ID check to prevent |
| 16 // abuse by normal renderer processes. | 17 // abuse by normal renderer processes. |
| 17 namespace extensions { | 18 namespace extensions { |
| 18 | 19 |
| 19 // An abstract base class for async webview APIs. It does a process ID check | 20 // An abstract base class for async webview APIs. It does a process ID check |
| 20 // in RunAsync, and then calls RunAsyncSafe which must be overriden by all | 21 // in RunAsync, and then calls RunAsyncSafe which must be overriden by all |
| (...skipping 26 matching lines...) Expand all Loading... |
| 47 // WebViewInternalExtensionFunction implementation. | 48 // WebViewInternalExtensionFunction implementation. |
| 48 bool RunAsyncSafe(WebViewGuest* guest) override; | 49 bool RunAsyncSafe(WebViewGuest* guest) override; |
| 49 | 50 |
| 50 DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction); | 51 DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction); |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 class WebViewInternalExecuteCodeFunction | 54 class WebViewInternalExecuteCodeFunction |
| 54 : public extensions::ExecuteCodeFunction { | 55 : public extensions::ExecuteCodeFunction { |
| 55 public: | 56 public: |
| 56 WebViewInternalExecuteCodeFunction(); | 57 WebViewInternalExecuteCodeFunction(); |
| 57 // Called when a file URL request is complete. | |
| 58 // Parameters: | |
| 59 // - whether the request is success. | |
| 60 // - If yes, the content of the file. | |
| 61 using WebUILoadFileCallback = base::Callback<void(bool, const std::string&)>; | |
| 62 | 58 |
| 63 protected: | 59 protected: |
| 64 ~WebViewInternalExecuteCodeFunction() override; | 60 ~WebViewInternalExecuteCodeFunction() override; |
| 65 | 61 |
| 66 // Initialize |details_| if it hasn't already been. | 62 // Initialize |details_| if it hasn't already been. |
| 67 bool Init() override; | 63 bool Init() override; |
| 68 bool ShouldInsertCSS() const override; | 64 bool ShouldInsertCSS() const override; |
| 69 bool CanExecuteScriptOnPage() override; | 65 bool CanExecuteScriptOnPage() override; |
| 70 // Guarded by a process ID check. | 66 // Guarded by a process ID check. |
| 71 extensions::ScriptExecutor* GetScriptExecutor() final; | 67 extensions::ScriptExecutor* GetScriptExecutor() final; |
| 72 bool IsWebView() const override; | 68 bool IsWebView() const override; |
| 73 const GURL& GetWebViewSrc() const override; | 69 const GURL& GetWebViewSrc() const override; |
| 74 bool LoadFile(const std::string& file) override; | 70 bool LoadFile(const std::string& file) override; |
| 75 | 71 |
| 76 private: | 72 private: |
| 77 class WebUIURLFetcher; | |
| 78 | |
| 79 // Loads a file url on WebUI. | 73 // Loads a file url on WebUI. |
| 80 bool LoadFileForWebUI(const std::string& file_src, | 74 bool LoadFileForWebUI(const std::string& file_src, |
| 81 const WebUILoadFileCallback& callback); | 75 const WebUIURLFetcher::WebUILoadFileCallback& callback); |
| 82 | 76 |
| 83 // Contains extension resource built from path of file which is | 77 // Contains extension resource built from path of file which is |
| 84 // specified in JSON arguments. | 78 // specified in JSON arguments. |
| 85 extensions::ExtensionResource resource_; | 79 extensions::ExtensionResource resource_; |
| 86 | 80 |
| 87 int guest_instance_id_; | 81 int guest_instance_id_; |
| 88 | 82 |
| 89 GURL guest_src_; | 83 GURL guest_src_; |
| 90 | 84 |
| 91 scoped_ptr<WebUIURLFetcher> url_fetcher_; | 85 scoped_ptr<WebUIURLFetcher> url_fetcher_; |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 459 uint32 remove_mask_; | 453 uint32 remove_mask_; |
| 460 // Tracks any data related or parse errors. | 454 // Tracks any data related or parse errors. |
| 461 bool bad_message_; | 455 bool bad_message_; |
| 462 | 456 |
| 463 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); | 457 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); |
| 464 }; | 458 }; |
| 465 | 459 |
| 466 } // namespace extensions | 460 } // namespace extensions |
| 467 | 461 |
| 468 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ | 462 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ |
| OLD | NEW |