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

Side by Side Diff: extensions/browser/api/execute_code_function.h

Issue 942533003: Enable <webview>.executeScript outside of Apps and Extensions [1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_routingid_user_script_UserScriptSet_non_hostset_2
Patch Set: Add a test. 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_EXECUTE_CODE_FUNCTION_H_ 5 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ 6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
7 7
8 #include "extensions/browser/extension_function.h" 8 #include "extensions/browser/extension_function.h"
9 #include "extensions/browser/script_executor.h" 9 #include "extensions/browser/script_executor.h"
10 #include "extensions/common/api/extension_types.h" 10 #include "extensions/common/api/extension_types.h"
11 #include "extensions/common/host_id.h"
11 12
12 namespace extensions { 13 namespace extensions {
13 14
14 // Base class for javascript code injection. 15 // Base class for javascript code injection.
15 // This is used by both chrome.webview.executeScript and 16 // This is used by both chrome.webview.executeScript and
16 // chrome.tabs.executeScript. 17 // chrome.tabs.executeScript.
17 class ExecuteCodeFunction : public AsyncExtensionFunction { 18 class ExecuteCodeFunction : public AsyncExtensionFunction {
18 public: 19 public:
19 ExecuteCodeFunction(); 20 ExecuteCodeFunction();
20 21
(...skipping 11 matching lines...) Expand all
32 virtual ScriptExecutor* GetScriptExecutor() = 0; 33 virtual ScriptExecutor* GetScriptExecutor() = 0;
33 virtual bool IsWebView() const = 0; 34 virtual bool IsWebView() const = 0;
34 virtual const GURL& GetWebViewSrc() const = 0; 35 virtual const GURL& GetWebViewSrc() const = 0;
35 virtual void OnExecuteCodeFinished(const std::string& error, 36 virtual void OnExecuteCodeFinished(const std::string& error,
36 const GURL& on_url, 37 const GURL& on_url,
37 const base::ListValue& result); 38 const base::ListValue& result);
38 39
39 // The injection details. 40 // The injection details.
40 scoped_ptr<core_api::extension_types::InjectDetails> details_; 41 scoped_ptr<core_api::extension_types::InjectDetails> details_;
41 42
43 const HostID& host_id() const { return host_id_; }
44 void set_host_id(HostID host_id) {
45 host_id_ = host_id;
46 }
47
42 private: 48 private:
43 // Called when contents from the file whose path is specified in JSON 49 // Called when contents from the file whose path is specified in JSON
44 // arguments has been loaded. 50 // arguments has been loaded.
45 void DidLoadFile(bool success, const std::string& data); 51 void DidLoadFile(bool success, const std::string& data);
46 52
47 // Runs on FILE thread. Loads message bundles for the extension and 53 // Runs on FILE thread. Loads message bundles for the extension and
48 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. 54 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread.
49 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type, 55 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type,
50 const std::string& data, 56 const std::string& data,
51 const std::string& extension_id, 57 const std::string& extension_id,
52 const base::FilePath& extension_path, 58 const base::FilePath& extension_path,
53 const std::string& extension_default_locale); 59 const std::string& extension_default_locale);
54 60
55 // Called when contents from the loaded file have been localized. 61 // Called when contents from the loaded file have been localized.
56 void DidLoadAndLocalizeFile(bool success, const std::string& data); 62 void DidLoadAndLocalizeFile(bool success, const std::string& data);
57 63
58 // Run in UI thread. Code string contains the code to be executed. Returns 64 // Run in UI thread. Code string contains the code to be executed. Returns
59 // true on success. If true is returned, this does an AddRef. 65 // true on success. If true is returned, this does an AddRef.
60 bool Execute(const std::string& code_string); 66 bool Execute(const std::string& code_string);
61 67
62 // Contains extension resource built from path of file which is 68 // Contains extension resource built from path of file which is
63 // specified in JSON arguments. 69 // specified in JSON arguments.
64 ExtensionResource resource_; 70 ExtensionResource resource_;
65 71
66 // The URL of the file being injected into the page. 72 // The URL of the file being injected into the page.
67 GURL file_url_; 73 GURL file_url_;
74
75 // The ID of the injection host.
76 HostID host_id_;
68 }; 77 };
69 78
70 } // namespace extensions 79 } // namespace extensions
71 80
72 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ 81 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698