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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 bool success, | 45 bool success, |
46 std::unique_ptr<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 // Retrieves the file url for the given |extension_path| and optionally |
56 // arguments has been loaded. | 56 // localizes |data|. |
57 void DidLoadFile(bool success, std::unique_ptr<std::string> data); | 57 // Localization depends on whether |might_require_localization| was specified. |
| 58 // Only CSS file content needs to be localized. |
| 59 void GetFileURLAndMaybeLocalizeOnFileThread( |
| 60 const std::string& extension_id, |
| 61 const base::FilePath& extension_path, |
| 62 const std::string& extension_default_locale, |
| 63 bool might_require_localization, |
| 64 std::string* data); |
58 | 65 |
59 // Runs on FILE thread. Loads message bundles for the extension and | 66 // Retrieves the file url for the given |extension_path| and optionally |
60 // localizes the CSS data. Calls back DidLoadAndLocalizeFile on the UI thread. | 67 // localizes |data|. |
61 void GetFileURLAndLocalizeCSS(ScriptExecutor::ScriptType script_type, | 68 // Similar to GetFileURLAndMaybeLocalizeOnFileThread, but only applies to |
62 std::unique_ptr<std::string> data, | 69 // component extension resource. |
63 const std::string& extension_id, | 70 void GetFileURLAndLocalizeComponentResourceOnFileThread( |
64 const base::FilePath& extension_path, | 71 std::unique_ptr<std::string> data, |
65 const std::string& extension_default_locale); | 72 const std::string& extension_id, |
| 73 const base::FilePath& extension_path, |
| 74 const std::string& extension_default_locale, |
| 75 bool might_require_localization); |
66 | 76 |
67 // Run in UI thread. Code string contains the code to be executed. Returns | 77 // 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. | 78 // true on success. If true is returned, this does an AddRef. |
69 bool Execute(const std::string& code_string); | 79 bool Execute(const std::string& code_string); |
70 | 80 |
71 // Contains extension resource built from path of file which is | 81 // Contains extension resource built from path of file which is |
72 // specified in JSON arguments. | 82 // specified in JSON arguments. |
73 ExtensionResource resource_; | 83 ExtensionResource resource_; |
74 | 84 |
75 // The URL of the file being injected into the page. | 85 // The URL of the file being injected into the page. |
76 GURL file_url_; | 86 GURL file_url_; |
77 | 87 |
78 // The ID of the injection host. | 88 // The ID of the injection host. |
79 HostID host_id_; | 89 HostID host_id_; |
80 | 90 |
81 DISALLOW_COPY_AND_ASSIGN(ExecuteCodeFunction); | 91 DISALLOW_COPY_AND_ASSIGN(ExecuteCodeFunction); |
82 }; | 92 }; |
83 | 93 |
84 } // namespace extensions | 94 } // namespace extensions |
85 | 95 |
86 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ | 96 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_H_ |
OLD | NEW |