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