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 #include "chrome/browser/extensions/api/execute_code_function.h" | 5 #include "chrome/browser/extensions/api/execute_code_function.h" |
6 | 6 |
7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 7 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
8 #include "chrome/browser/extensions/image_loader.h" | 8 #include "chrome/browser/extensions/image_loader.h" |
9 #include "chrome/browser/extensions/script_executor.h" | 9 #include "chrome/browser/extensions/script_executor.h" |
10 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 10 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
11 #include "chrome/common/extensions/extension_file_util.h" | |
12 #include "chrome/common/extensions/message_bundle.h" | |
13 #include "extensions/browser/file_reader.h" | 11 #include "extensions/browser/file_reader.h" |
14 #include "extensions/common/error_utils.h" | 12 #include "extensions/common/error_utils.h" |
15 #include "extensions/common/extension_messages.h" | 13 #include "extensions/common/extension_messages.h" |
| 14 #include "extensions/common/file_util.h" |
| 15 #include "extensions/common/message_bundle.h" |
16 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
17 #include "ui/base/resource/resource_bundle.h" | 17 #include "ui/base/resource/resource_bundle.h" |
18 | 18 |
19 namespace extensions { | 19 namespace extensions { |
20 | 20 |
21 namespace keys = tabs_constants; | 21 namespace keys = tabs_constants; |
22 using api::tabs::InjectDetails; | 22 using api::tabs::InjectDetails; |
23 | 23 |
24 ExecuteCodeFunction::ExecuteCodeFunction() { | 24 ExecuteCodeFunction::ExecuteCodeFunction() { |
25 } | 25 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 const std::string& extension_id, | 64 const std::string& extension_id, |
65 const base::FilePath& extension_path, | 65 const base::FilePath& extension_path, |
66 const std::string& extension_default_locale) { | 66 const std::string& extension_default_locale) { |
67 | 67 |
68 std::string localized_data = data; | 68 std::string localized_data = data; |
69 // Check if the file is CSS and needs localization. | 69 // Check if the file is CSS and needs localization. |
70 if ((script_type == ScriptExecutor::CSS) && | 70 if ((script_type == ScriptExecutor::CSS) && |
71 !extension_id.empty() && | 71 !extension_id.empty() && |
72 (data.find(MessageBundle::kMessageBegin) != std::string::npos)) { | 72 (data.find(MessageBundle::kMessageBegin) != std::string::npos)) { |
73 scoped_ptr<SubstitutionMap> localization_messages( | 73 scoped_ptr<SubstitutionMap> localization_messages( |
74 extension_file_util::LoadMessageBundleSubstitutionMap( | 74 file_util::LoadMessageBundleSubstitutionMap( |
75 extension_path, extension_id, extension_default_locale)); | 75 extension_path, extension_id, extension_default_locale)); |
76 | 76 |
77 // We need to do message replacement on the data, so it has to be mutable. | 77 // We need to do message replacement on the data, so it has to be mutable. |
78 std::string error; | 78 std::string error; |
79 MessageBundle::ReplaceMessagesWithExternalDictionary(*localization_messages, | 79 MessageBundle::ReplaceMessagesWithExternalDictionary(*localization_messages, |
80 &localized_data, | 80 &localized_data, |
81 &error); | 81 &error); |
82 } | 82 } |
83 | 83 |
84 file_url_ = net::FilePathToFileURL(resource_.GetFilePath()); | 84 file_url_ = net::FilePathToFileURL(resource_.GetFilePath()); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 int32 on_page_id, | 208 int32 on_page_id, |
209 const GURL& on_url, | 209 const GURL& on_url, |
210 const base::ListValue& result) { | 210 const base::ListValue& result) { |
211 if (!error.empty()) | 211 if (!error.empty()) |
212 SetError(error); | 212 SetError(error); |
213 | 213 |
214 SendResponse(error.empty()); | 214 SendResponse(error.empty()); |
215 } | 215 } |
216 | 216 |
217 } // namespace extensions | 217 } // namespace extensions |
OLD | NEW |