| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/installed_loader.h" | 5 #include "chrome/browser/extensions/installed_loader.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 DEPRECATED_EXTERNAL_ITEM_DISABLED = 0, | 68 DEPRECATED_EXTERNAL_ITEM_DISABLED = 0, |
| 69 DEPRECATED_EXTERNAL_ITEM_ENABLED = 1, | 69 DEPRECATED_EXTERNAL_ITEM_ENABLED = 1, |
| 70 EXTERNAL_ITEM_WEBSTORE_DISABLED = 2, | 70 EXTERNAL_ITEM_WEBSTORE_DISABLED = 2, |
| 71 EXTERNAL_ITEM_WEBSTORE_ENABLED = 3, | 71 EXTERNAL_ITEM_WEBSTORE_ENABLED = 3, |
| 72 EXTERNAL_ITEM_NONWEBSTORE_DISABLED = 4, | 72 EXTERNAL_ITEM_NONWEBSTORE_DISABLED = 4, |
| 73 EXTERNAL_ITEM_NONWEBSTORE_ENABLED = 5, | 73 EXTERNAL_ITEM_NONWEBSTORE_ENABLED = 5, |
| 74 EXTERNAL_ITEM_MAX_ITEMS = 6 | 74 EXTERNAL_ITEM_MAX_ITEMS = 6 |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 bool IsManifestCorrupt(const DictionaryValue* manifest) { | 77 bool IsManifestCorrupt(const DictionaryValue* manifest) { |
| 78 if (!manifest) return false; | 78 if (!manifest) |
| 79 return false; |
| 79 | 80 |
| 80 // Because of bug #272524 sometimes manifests got mangled in the preferences | 81 // Because of bug #272524 sometimes manifests got mangled in the preferences |
| 81 // file, one particularly bad case resulting in having both a background page | 82 // file, one particularly bad case resulting in having both a background page |
| 82 // and background scripts values. In those situations we want to reload the | 83 // and background scripts values. In those situations we want to reload the |
| 83 // manifest from the extension to fix this. | 84 // manifest from the extension to fix this. |
| 84 const Value* background_page; | 85 const Value* background_page; |
| 85 const Value* background_scripts; | 86 const Value* background_scripts; |
| 86 return manifest->Get(extension_manifest_keys::kBackgroundPage, | 87 return manifest->Get(manifest_keys::kBackgroundPage, &background_page) && |
| 87 &background_page) && | 88 manifest->Get(manifest_keys::kBackgroundScripts, &background_scripts); |
| 88 manifest->Get(extension_manifest_keys::kBackgroundScripts, | |
| 89 &background_scripts); | |
| 90 } | 89 } |
| 91 | 90 |
| 92 ManifestReloadReason ShouldReloadExtensionManifest(const ExtensionInfo& info) { | 91 ManifestReloadReason ShouldReloadExtensionManifest(const ExtensionInfo& info) { |
| 93 // Always reload manifests of unpacked extensions, because they can change | 92 // Always reload manifests of unpacked extensions, because they can change |
| 94 // on disk independent of the manifest in our prefs. | 93 // on disk independent of the manifest in our prefs. |
| 95 if (Manifest::IsUnpackedLocation(info.extension_location)) | 94 if (Manifest::IsUnpackedLocation(info.extension_location)) |
| 96 return UNPACKED_DIR; | 95 return UNPACKED_DIR; |
| 97 | 96 |
| 98 // Reload the manifest if it needs to be relocalized. | 97 // Reload the manifest if it needs to be relocalized. |
| 99 if (extension_l10n_util::ShouldRelocalizeManifest( | 98 if (extension_l10n_util::ShouldRelocalizeManifest( |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 463 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
| 465 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 464 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
| 466 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 465 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
| 467 flags |= Extension::REQUIRE_KEY; | 466 flags |= Extension::REQUIRE_KEY; |
| 468 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 467 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
| 469 flags |= Extension::ALLOW_FILE_ACCESS; | 468 flags |= Extension::ALLOW_FILE_ACCESS; |
| 470 return flags; | 469 return flags; |
| 471 } | 470 } |
| 472 | 471 |
| 473 } // namespace extensions | 472 } // namespace extensions |
| OLD | NEW |