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

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: Devlin's comments. 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
83 // Called when the file is loaded for WebUI.
84 void DidLoadFileForWebUI(const std::string& file,
85 bool success,
86 const std::string& data);
87
71 // Contains extension resource built from path of file which is 88 // Contains extension resource built from path of file which is
72 // specified in JSON arguments. 89 // specified in JSON arguments.
73 extensions::ExtensionResource resource_; 90 extensions::ExtensionResource resource_;
74 91
75 int guest_instance_id_; 92 int guest_instance_id_;
76 93
77 GURL guest_src_; 94 GURL guest_src_;
78 95
96 scoped_ptr<WebUIURLFetcher> url_fetcher_;
97
79 DISALLOW_COPY_AND_ASSIGN(WebViewInternalExecuteCodeFunction); 98 DISALLOW_COPY_AND_ASSIGN(WebViewInternalExecuteCodeFunction);
80 }; 99 };
81 100
82 class WebViewInternalExecuteScriptFunction 101 class WebViewInternalExecuteScriptFunction
83 : public WebViewInternalExecuteCodeFunction { 102 : public WebViewInternalExecuteCodeFunction {
84 public: 103 public:
85 WebViewInternalExecuteScriptFunction(); 104 WebViewInternalExecuteScriptFunction();
86 105
87 protected: 106 protected:
88 ~WebViewInternalExecuteScriptFunction() override {} 107 ~WebViewInternalExecuteScriptFunction() override {}
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 uint32 remove_mask_; 396 uint32 remove_mask_;
378 // Tracks any data related or parse errors. 397 // Tracks any data related or parse errors.
379 bool bad_message_; 398 bool bad_message_;
380 399
381 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction); 400 DISALLOW_COPY_AND_ASSIGN(WebViewInternalClearDataFunction);
382 }; 401 };
383 402
384 } // namespace extensions 403 } // namespace extensions
385 404
386 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_ 405 #endif // CHROME_BROWSER_EXTENSIONS_API_WEB_VIEW_WEB_VIEW_INTERNAL_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698