OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "extensions/common/manifest_handlers/background_info.h" | 5 #include "extensions/common/manifest_handlers/background_info.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "extensions/common/constants.h" | 13 #include "extensions/common/constants.h" |
14 #include "extensions/common/error_utils.h" | 14 #include "extensions/common/error_utils.h" |
15 #include "extensions/common/file_util.h" | 15 #include "extensions/common/file_util.h" |
16 #include "extensions/common/manifest_constants.h" | 16 #include "extensions/common/manifest_constants.h" |
17 #include "extensions/common/permissions/api_permission_set.h" | 17 #include "extensions/common/permissions/api_permission_set.h" |
18 #include "extensions/common/permissions/permissions_data.h" | 18 #include "extensions/common/permissions/permissions_data.h" |
19 #include "extensions/common/switches.h" | 19 #include "extensions/common/switches.h" |
20 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
22 | 22 |
| 23 using base::ASCIIToUTF16; |
23 using base::DictionaryValue; | 24 using base::DictionaryValue; |
24 | 25 |
25 namespace extensions { | 26 namespace extensions { |
26 | 27 |
27 namespace keys = manifest_keys; | 28 namespace keys = manifest_keys; |
28 namespace values = manifest_values; | 29 namespace values = manifest_values; |
29 namespace errors = manifest_errors; | 30 namespace errors = manifest_errors; |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 std::string* error, | 269 std::string* error, |
269 std::vector<InstallWarning>* warnings) const { | 270 std::vector<InstallWarning>* warnings) const { |
270 // Validate that background scripts exist. | 271 // Validate that background scripts exist. |
271 const std::vector<std::string>& background_scripts = | 272 const std::vector<std::string>& background_scripts = |
272 BackgroundInfo::GetBackgroundScripts(extension); | 273 BackgroundInfo::GetBackgroundScripts(extension); |
273 for (size_t i = 0; i < background_scripts.size(); ++i) { | 274 for (size_t i = 0; i < background_scripts.size(); ++i) { |
274 if (!base::PathExists( | 275 if (!base::PathExists( |
275 extension->GetResource(background_scripts[i]).GetFilePath())) { | 276 extension->GetResource(background_scripts[i]).GetFilePath())) { |
276 *error = l10n_util::GetStringFUTF8( | 277 *error = l10n_util::GetStringFUTF8( |
277 IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, | 278 IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED, |
278 UTF8ToUTF16(background_scripts[i])); | 279 base::UTF8ToUTF16(background_scripts[i])); |
279 return false; | 280 return false; |
280 } | 281 } |
281 } | 282 } |
282 | 283 |
283 // Validate background page location, except for hosted apps, which should use | 284 // Validate background page location, except for hosted apps, which should use |
284 // an external URL. Background page for hosted apps are verified when the | 285 // an external URL. Background page for hosted apps are verified when the |
285 // extension is created (in Extension::InitFromValue) | 286 // extension is created (in Extension::InitFromValue) |
286 if (BackgroundInfo::HasBackgroundPage(extension) && | 287 if (BackgroundInfo::HasBackgroundPage(extension) && |
287 !extension->is_hosted_app() && background_scripts.empty()) { | 288 !extension->is_hosted_app() && background_scripts.empty()) { |
288 base::FilePath page_path = file_util::ExtensionURLToRelativeFilePath( | 289 base::FilePath page_path = file_util::ExtensionURLToRelativeFilePath( |
(...skipping 21 matching lines...) Expand all Loading... |
310 keys::kBackgroundPageLegacy, | 311 keys::kBackgroundPageLegacy, |
311 keys::kBackgroundPersistent, | 312 keys::kBackgroundPersistent, |
312 keys::kBackgroundScripts, | 313 keys::kBackgroundScripts, |
313 keys::kPlatformAppBackgroundPage, | 314 keys::kPlatformAppBackgroundPage, |
314 keys::kPlatformAppBackgroundScripts | 315 keys::kPlatformAppBackgroundScripts |
315 }; | 316 }; |
316 return std::vector<std::string>(keys, keys + arraysize(keys)); | 317 return std::vector<std::string>(keys, keys + arraysize(keys)); |
317 } | 318 } |
318 | 319 |
319 } // namespace extensions | 320 } // namespace extensions |
OLD | NEW |