OLD | NEW |
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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 virtual bool Init() = 0; | 30 virtual bool Init() = 0; |
31 virtual bool ShouldInsertCSS() const = 0; | 31 virtual bool ShouldInsertCSS() const = 0; |
32 virtual bool CanExecuteScriptOnPage() = 0; | 32 virtual bool CanExecuteScriptOnPage() = 0; |
33 virtual ScriptExecutor* GetScriptExecutor() = 0; | 33 virtual ScriptExecutor* GetScriptExecutor() = 0; |
34 virtual bool IsWebView() const = 0; | 34 virtual bool IsWebView() const = 0; |
35 virtual const GURL& GetWebViewSrc() const = 0; | 35 virtual const GURL& GetWebViewSrc() const = 0; |
36 virtual void OnExecuteCodeFinished(const std::string& error, | 36 virtual void OnExecuteCodeFinished(const std::string& error, |
37 const GURL& on_url, | 37 const GURL& on_url, |
38 const base::ListValue& result); | 38 const base::ListValue& result); |
39 | 39 |
40 // The injection details. | 40 virtual bool LoadFile(const std::string& file); |
41 scoped_ptr<core_api::extension_types::InjectDetails> details_; | 41 |
| 42 // Called when contents from the loaded file have been localized. |
| 43 void DidLoadAndLocalizeFile(const std::string& file, |
| 44 bool success, |
| 45 const std::string& data); |
42 | 46 |
43 const HostID& host_id() const { return host_id_; } | 47 const HostID& host_id() const { return host_id_; } |
44 void set_host_id(HostID host_id) { | 48 void set_host_id(HostID host_id) { |
45 host_id_ = host_id; | 49 host_id_ = host_id; |
46 } | 50 } |
47 | 51 |
| 52 // The injection details. |
| 53 scoped_ptr<core_api::extension_types::InjectDetails> details_; |
| 54 |
48 private: | 55 private: |
49 // Called when contents from the file whose path is specified in JSON | 56 // Called when contents from the file whose path is specified in JSON |
50 // arguments has been loaded. | 57 // arguments has been loaded. |
51 void DidLoadFile(bool success, const std::string& data); | 58 void DidLoadFile(bool success, const std::string& data); |
52 | 59 |
53 // Runs on FILE thread. Loads message bundles for the extension and | 60 // Runs on FILE thread. Loads message bundles for the extension and |
54 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. | 61 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. |
55 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type, | 62 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type, |
56 const std::string& data, | 63 const std::string& data, |
57 const std::string& extension_id, | 64 const std::string& extension_id, |
58 const base::FilePath& extension_path, | 65 const base::FilePath& extension_path, |
59 const std::string& extension_default_locale); | 66 const std::string& extension_default_locale); |
60 | 67 |
61 // Called when contents from the loaded file have been localized. | |
62 void DidLoadAndLocalizeFile(bool success, const std::string& data); | |
63 | |
64 // Run in UI thread. Code string contains the code to be executed. Returns | 68 // Run in UI thread. Code string contains the code to be executed. Returns |
65 // true on success. If true is returned, this does an AddRef. | 69 // true on success. If true is returned, this does an AddRef. |
66 bool Execute(const std::string& code_string); | 70 bool Execute(const std::string& code_string); |
67 | 71 |
68 // Contains extension resource built from path of file which is | 72 // Contains extension resource built from path of file which is |
69 // specified in JSON arguments. | 73 // specified in JSON arguments. |
70 ExtensionResource resource_; | 74 ExtensionResource resource_; |
71 | 75 |
72 // The URL of the file being injected into the page. | 76 // The URL of the file being injected into the page. |
73 GURL file_url_; | 77 GURL file_url_; |
74 | 78 |
75 // The ID of the injection host. | 79 // The ID of the injection host. |
76 HostID host_id_; | 80 HostID host_id_; |
77 }; | 81 }; |
78 | 82 |
79 } // namespace extensions | 83 } // namespace extensions |
80 | 84 |
81 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ | 85 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ |
OLD | NEW |