OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/browser/extension_prefs.h" | 5 #include "extensions/browser/extension_prefs.h" |
6 | 6 |
7 #include <iterator> | 7 #include <iterator> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/prefs/pref_notifier.h" | 10 #include "base/prefs/pref_notifier.h" |
(...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1322 bool update_required = | 1322 bool update_required = |
1323 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || | 1323 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || |
1324 !extension->manifest()->value()->Equals(old_manifest); | 1324 !extension->manifest()->value()->Equals(old_manifest); |
1325 if (update_required) { | 1325 if (update_required) { |
1326 UpdateExtensionPref(extension->id(), kPrefManifest, | 1326 UpdateExtensionPref(extension->id(), kPrefManifest, |
1327 extension->manifest()->value()->DeepCopy()); | 1327 extension->manifest()->value()->DeepCopy()); |
1328 } | 1328 } |
1329 } | 1329 } |
1330 } | 1330 } |
1331 | 1331 |
1332 base::FilePath ExtensionPrefs::GetExtensionPath( | |
1333 const std::string& extension_id) { | |
1334 const base::DictionaryValue* dict = GetExtensionPref(extension_id); | |
1335 if (!dict) | |
1336 return base::FilePath(); | |
1337 | |
1338 std::string path; | |
1339 if (!dict->GetString(kPrefPath, &path)) | |
1340 return base::FilePath(); | |
1341 | |
1342 return install_directory_.Append(base::FilePath::FromUTF8Unsafe(path)); | |
1343 } | |
1344 | |
1345 scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper( | 1332 scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper( |
1346 const std::string& extension_id, | 1333 const std::string& extension_id, |
1347 const base::DictionaryValue* extension) const { | 1334 const base::DictionaryValue* extension) const { |
1348 int location_value; | 1335 int location_value; |
1349 if (!extension->GetInteger(kPrefLocation, &location_value)) | 1336 if (!extension->GetInteger(kPrefLocation, &location_value)) |
1350 return scoped_ptr<ExtensionInfo>(); | 1337 return scoped_ptr<ExtensionInfo>(); |
1351 | 1338 |
1352 base::FilePath::StringType path; | 1339 base::FilePath::StringType path; |
1353 if (!extension->GetString(kPrefPath, &path)) | 1340 if (!extension->GetString(kPrefPath, &path)) |
1354 return scoped_ptr<ExtensionInfo>(); | 1341 return scoped_ptr<ExtensionInfo>(); |
1355 | 1342 |
1356 // Make path absolute. Unpacked extensions will already have absolute paths, | 1343 // Make path absolute. Unpacked extensions will already have absolute paths, |
1357 // otherwise make it so. | 1344 // otherwise make it so. |
1358 Manifest::Location location = static_cast<Manifest::Location>(location_value); | 1345 Manifest::Location location = static_cast<Manifest::Location>(location_value); |
| 1346 #if !defined(OS_CHROMEOS) |
1359 if (!Manifest::IsUnpackedLocation(location)) { | 1347 if (!Manifest::IsUnpackedLocation(location)) { |
1360 DCHECK(location == Manifest::COMPONENT || | 1348 DCHECK(location == Manifest::COMPONENT || |
1361 !base::FilePath(path).IsAbsolute()); | 1349 !base::FilePath(path).IsAbsolute()); |
| 1350 #else |
| 1351 // On Chrome OS some extensions can be installed to shared location and |
| 1352 // thus use absolute paths in prefs. |
| 1353 if (!base::FilePath(path).IsAbsolute()) { |
| 1354 #endif // !defined(OS_CHROMEOS) |
1362 path = install_directory_.Append(path).value(); | 1355 path = install_directory_.Append(path).value(); |
1363 } | 1356 } |
1364 | 1357 |
1365 // Only the following extension types have data saved in the preferences. | 1358 // Only the following extension types have data saved in the preferences. |
1366 if (location != Manifest::INTERNAL && | 1359 if (location != Manifest::INTERNAL && |
1367 !Manifest::IsUnpackedLocation(location) && | 1360 !Manifest::IsUnpackedLocation(location) && |
1368 !Manifest::IsExternalLocation(location)) { | 1361 !Manifest::IsExternalLocation(location)) { |
1369 NOTREACHED(); | 1362 NOTREACHED(); |
1370 return scoped_ptr<ExtensionInfo>(); | 1363 return scoped_ptr<ExtensionInfo>(); |
1371 } | 1364 } |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 extension_pref_value_map_->RegisterExtension( | 2226 extension_pref_value_map_->RegisterExtension( |
2234 extension_id, install_time, is_enabled, is_incognito_enabled); | 2227 extension_id, install_time, is_enabled, is_incognito_enabled); |
2235 | 2228 |
2236 FOR_EACH_OBSERVER( | 2229 FOR_EACH_OBSERVER( |
2237 ExtensionPrefsObserver, | 2230 ExtensionPrefsObserver, |
2238 observer_list_, | 2231 observer_list_, |
2239 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2232 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
2240 } | 2233 } |
2241 | 2234 |
2242 } // namespace extensions | 2235 } // namespace extensions |
OLD | NEW |