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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 DEPRECATED_EXTERNAL_ITEM_ENABLED = 1, | 66 DEPRECATED_EXTERNAL_ITEM_ENABLED = 1, |
67 EXTERNAL_ITEM_WEBSTORE_DISABLED = 2, | 67 EXTERNAL_ITEM_WEBSTORE_DISABLED = 2, |
68 EXTERNAL_ITEM_WEBSTORE_ENABLED = 3, | 68 EXTERNAL_ITEM_WEBSTORE_ENABLED = 3, |
69 EXTERNAL_ITEM_NONWEBSTORE_DISABLED = 4, | 69 EXTERNAL_ITEM_NONWEBSTORE_DISABLED = 4, |
70 EXTERNAL_ITEM_NONWEBSTORE_ENABLED = 5, | 70 EXTERNAL_ITEM_NONWEBSTORE_ENABLED = 5, |
71 EXTERNAL_ITEM_WEBSTORE_UNINSTALLED = 6, | 71 EXTERNAL_ITEM_WEBSTORE_UNINSTALLED = 6, |
72 EXTERNAL_ITEM_NONWEBSTORE_UNINSTALLED = 7, | 72 EXTERNAL_ITEM_NONWEBSTORE_UNINSTALLED = 7, |
73 EXTERNAL_ITEM_MAX_ITEMS = 8 | 73 EXTERNAL_ITEM_MAX_ITEMS = 8 |
74 }; | 74 }; |
75 | 75 |
76 bool IsManifestCorrupt(const DictionaryValue* manifest) { | 76 bool IsManifestCorrupt(const base::DictionaryValue* manifest) { |
77 if (!manifest) | 77 if (!manifest) |
78 return false; | 78 return false; |
79 | 79 |
80 // Because of bug #272524 sometimes manifests got mangled in the preferences | 80 // Because of bug #272524 sometimes manifests got mangled in the preferences |
81 // file, one particularly bad case resulting in having both a background page | 81 // 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 | 82 // and background scripts values. In those situations we want to reload the |
83 // manifest from the extension to fix this. | 83 // manifest from the extension to fix this. |
84 const Value* background_page; | 84 const base::Value* background_page; |
85 const Value* background_scripts; | 85 const base::Value* background_scripts; |
86 return manifest->Get(manifest_keys::kBackgroundPage, &background_page) && | 86 return manifest->Get(manifest_keys::kBackgroundPage, &background_page) && |
87 manifest->Get(manifest_keys::kBackgroundScripts, &background_scripts); | 87 manifest->Get(manifest_keys::kBackgroundScripts, &background_scripts); |
88 } | 88 } |
89 | 89 |
90 ManifestReloadReason ShouldReloadExtensionManifest(const ExtensionInfo& info) { | 90 ManifestReloadReason ShouldReloadExtensionManifest(const ExtensionInfo& info) { |
91 // Always reload manifests of unpacked extensions, because they can change | 91 // Always reload manifests of unpacked extensions, because they can change |
92 // on disk independent of the manifest in our prefs. | 92 // on disk independent of the manifest in our prefs. |
93 if (Manifest::IsUnpackedLocation(info.extension_location)) | 93 if (Manifest::IsUnpackedLocation(info.extension_location)) |
94 return UNPACKED_DIR; | 94 return UNPACKED_DIR; |
95 | 95 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 GetCreationFlags(info), | 218 GetCreationFlags(info), |
219 &error)); | 219 &error)); |
220 | 220 |
221 if (!extension.get()) { | 221 if (!extension.get()) { |
222 extension_service_->ReportExtensionLoadError( | 222 extension_service_->ReportExtensionLoadError( |
223 info->extension_path, error, false); | 223 info->extension_path, error, false); |
224 continue; | 224 continue; |
225 } | 225 } |
226 | 226 |
227 extensions_info->at(i)->extension_manifest.reset( | 227 extensions_info->at(i)->extension_manifest.reset( |
228 static_cast<DictionaryValue*>( | 228 static_cast<base::DictionaryValue*>( |
229 extension->manifest()->value()->DeepCopy())); | 229 extension->manifest()->value()->DeepCopy())); |
230 should_write_prefs = true; | 230 should_write_prefs = true; |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 for (size_t i = 0; i < extensions_info->size(); ++i) { | 234 for (size_t i = 0; i < extensions_info->size(); ++i) { |
235 if (extensions_info->at(i)->extension_location == Manifest::COMMAND_LINE) | 235 if (extensions_info->at(i)->extension_location == Manifest::COMMAND_LINE) |
236 continue; | 236 continue; |
237 Load(*extensions_info->at(i), should_write_prefs); | 237 Load(*extensions_info->at(i), should_write_prefs); |
238 } | 238 } |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
474 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 474 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
475 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 475 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
476 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 476 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
477 flags |= Extension::REQUIRE_KEY; | 477 flags |= Extension::REQUIRE_KEY; |
478 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 478 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
479 flags |= Extension::ALLOW_FILE_ACCESS; | 479 flags |= Extension::ALLOW_FILE_ACCESS; |
480 return flags; | 480 return flags; |
481 } | 481 } |
482 | 482 |
483 } // namespace extensions | 483 } // namespace extensions |
OLD | NEW |