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

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

Issue 1004253002: Enable <webview>.executeScript outside of Apps and Extensions [2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 9 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 "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"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // WebViewInternalExtensionFunction implementation. 47 // WebViewInternalExtensionFunction implementation.
48 bool RunAsyncSafe(WebViewGuest* guest) override; 48 bool RunAsyncSafe(WebViewGuest* guest) override;
49 49
50 DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction); 50 DISALLOW_COPY_AND_ASSIGN(WebViewInternalNavigateFunction);
51 }; 51 };
52 52
53 class WebViewInternalExecuteCodeFunction 53 class WebViewInternalExecuteCodeFunction
54 : public extensions::ExecuteCodeFunction { 54 : public extensions::ExecuteCodeFunction {
55 public: 55 public:
56 WebViewInternalExecuteCodeFunction(); 56 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&)>;
57 62
58 protected: 63 protected:
59 ~WebViewInternalExecuteCodeFunction() override; 64 ~WebViewInternalExecuteCodeFunction() override;
60 65
61 // Initialize |details_| if it hasn't already been. 66 // Initialize |details_| if it hasn't already been.
62 bool Init() override; 67 bool Init() override;
63 bool ShouldInsertCSS() const override; 68 bool ShouldInsertCSS() const override;
64 bool CanExecuteScriptOnPage() override; 69 bool CanExecuteScriptOnPage() override;
65 // Guarded by a process ID check. 70 // Guarded by a process ID check.
66 extensions::ScriptExecutor* GetScriptExecutor() final; 71 extensions::ScriptExecutor* GetScriptExecutor() final;
67 bool IsWebView() const override; 72 bool IsWebView() const override;
68 const GURL& GetWebViewSrc() const override; 73 const GURL& GetWebViewSrc() const override;
74 bool LoadFile(const std::string& file) override;
69 75
70 private: 76 private:
77 class WebUIURLFetcher;
78
79 // Loads a file url on WebUI.
80 bool LoadFileForWebUI(const std::string& file_src,
81 const WebUILoadFileCallback& callback);
82
71 // Contains extension resource built from path of file which is 83 // Contains extension resource built from path of file which is
72 // specified in JSON arguments. 84 // specified in JSON arguments.
73 extensions::ExtensionResource resource_; 85 extensions::ExtensionResource resource_;
74 86
75 int guest_instance_id_; 87 int guest_instance_id_;
76 88
77 GURL guest_src_; 89 GURL guest_src_;
78 90
91 scoped_ptr<WebUIURLFetcher> url_fetcher_;
92
79 DISALLOW_COPY_AND_ASSIGN(WebViewInternalExecuteCodeFunction); 93 DISALLOW_COPY_AND_ASSIGN(WebViewInternalExecuteCodeFunction);
80 }; 94 };
81 95
82 class WebViewInternalExecuteScriptFunction 96 class WebViewInternalExecuteScriptFunction
83 : public WebViewInternalExecuteCodeFunction { 97 : public WebViewInternalExecuteCodeFunction {
84 public: 98 public:
85 WebViewInternalExecuteScriptFunction(); 99 WebViewInternalExecuteScriptFunction();
86 100
87 protected: 101 protected:
88 ~WebViewInternalExecuteScriptFunction() override {} 102 ~WebViewInternalExecuteScriptFunction() override {}
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 uint32 remove_mask_; 391 uint32 remove_mask_;
378 // Tracks any data related or parse errors. 392 // Tracks any data related or parse errors.
379 bool bad_message_; 393 bool bad_message_;
380 394
381 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); 395 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction);
382 }; 396 };
383 397
384 } // namespace extensions 398 } // namespace extensions
385 399
386 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ 400 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/execute_code_function.cc ('k') | extensions/browser/api/guest_view/web_view/web_view_internal_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698