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

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

Issue 538063003: Move execute_code_function to extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: gn build Created 6 years, 3 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 CHROME_BROWSER_EXTENSIONS_API_EXECUTE_CODE_FUNCTION_H_ 5 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
6 #define CHROME_BROWSER_EXTENSIONS_API_EXECUTE_CODE_FUNCTION_H_ 6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
7 7
8 #include "chrome/common/extensions/api/tabs.h"
9 #include "extensions/browser/extension_function.h" 8 #include "extensions/browser/extension_function.h"
10 #include "extensions/browser/script_executor.h" 9 #include "extensions/browser/script_executor.h"
10 #include "extensions/common/api/extension_types.h"
11 11
12 namespace extensions { 12 namespace extensions {
13 13
14 // Base class for javascript code injection. 14 // Base class for javascript code injection.
15 // This is used by both chrome.webview.executeScript and 15 // This is used by both chrome.webview.executeScript and
16 // chrome.tabs.executeScript. 16 // chrome.tabs.executeScript.
17 class ExecuteCodeFunction : public AsyncExtensionFunction { 17 class ExecuteCodeFunction : public AsyncExtensionFunction {
18 public: 18 public:
19 ExecuteCodeFunction(); 19 ExecuteCodeFunction();
20 20
21 protected: 21 protected:
22 virtual ~ExecuteCodeFunction(); 22 virtual ~ExecuteCodeFunction();
23 23
24 // ExtensionFunction implementation. 24 // ExtensionFunction implementation.
25 virtual bool HasPermission() OVERRIDE; 25 virtual bool HasPermission() OVERRIDE;
26 virtual bool RunAsync() OVERRIDE; 26 virtual bool RunAsync() OVERRIDE;
27 27
28 // Initialize |details_| if it hasn't already been. 28 // Initialize |details_| if it hasn't already been.
29 virtual bool Init() = 0; 29 virtual bool Init() = 0;
30 virtual bool ShouldInsertCSS() const = 0; 30 virtual bool ShouldInsertCSS() const = 0;
31 virtual bool CanExecuteScriptOnPage() = 0; 31 virtual bool CanExecuteScriptOnPage() = 0;
32 virtual ScriptExecutor* GetScriptExecutor() = 0; 32 virtual ScriptExecutor* GetScriptExecutor() = 0;
33 virtual bool IsWebView() const = 0; 33 virtual bool IsWebView() const = 0;
34 virtual const GURL& GetWebViewSrc() const = 0; 34 virtual const GURL& GetWebViewSrc() const = 0;
35 virtual void OnExecuteCodeFinished(const std::string& error, 35 virtual void OnExecuteCodeFinished(const std::string& error,
36 const GURL& on_url, 36 const GURL& on_url,
37 const base::ListValue& result); 37 const base::ListValue& result);
38 38
39 // The injection details. 39 // The injection details.
40 scoped_ptr<api::tabs::InjectDetails> details_; 40 scoped_ptr<core_api::extension_types::InjectDetails> details_;
41 41
42 private: 42 private:
43 // Called when contents from the file whose path is specified in JSON 43 // Called when contents from the file whose path is specified in JSON
44 // arguments has been loaded. 44 // arguments has been loaded.
45 void DidLoadFile(bool success, const std::string& data); 45 void DidLoadFile(bool success, const std::string& data);
46 46
47 // Runs on FILE thread. Loads message bundles for the extension and 47 // Runs on FILE thread. Loads message bundles for the extension and
48 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. 48 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread.
49 void GetFileURLAndLocalizeCSS( 49 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type,
50 ScriptExecutor::ScriptType script_type, 50 const std::string& data,
51 const std::string& data, 51 const std::string& extension_id,
52 const std::string& extension_id, 52 const base::FilePath& extension_path,
53 const base::FilePath& extension_path, 53 const std::string& extension_default_locale);
54 const std::string& extension_default_locale);
55 54
56 // Called when contents from the loaded file have been localized. 55 // Called when contents from the loaded file have been localized.
57 void DidLoadAndLocalizeFile(bool success, const std::string& data); 56 void DidLoadAndLocalizeFile(bool success, const std::string& data);
58 57
59 // Run in UI thread. Code string contains the code to be executed. Returns 58 // Run in UI thread. Code string contains the code to be executed. Returns
60 // true on success. If true is returned, this does an AddRef. 59 // true on success. If true is returned, this does an AddRef.
61 bool Execute(const std::string& code_string); 60 bool Execute(const std::string& code_string);
62 61
63 // Contains extension resource built from path of file which is 62 // Contains extension resource built from path of file which is
64 // specified in JSON arguments. 63 // specified in JSON arguments.
65 ExtensionResource resource_; 64 ExtensionResource resource_;
66 65
67 // The URL of the file being injected into the page. 66 // The URL of the file being injected into the page.
68 GURL file_url_; 67 GURL file_url_;
69 }; 68 };
70 69
71 } // namespace extensions 70 } // namespace extensions
72 71
73 #endif // CHROME_BROWSER_EXTENSIONS_API_EXECUTE_CODE_FUNCTION_H_ 72 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_
74
OLDNEW
« no previous file with comments | « extensions/browser/api/capture_web_contents_function_impl.h ('k') | extensions/browser/api/execute_code_function.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698