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 1317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 bool update_required = | 1328 bool update_required = |
1329 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || | 1329 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || |
1330 !extension->manifest()->value()->Equals(old_manifest); | 1330 !extension->manifest()->value()->Equals(old_manifest); |
1331 if (update_required) { | 1331 if (update_required) { |
1332 UpdateExtensionPref(extension->id(), kPrefManifest, | 1332 UpdateExtensionPref(extension->id(), kPrefManifest, |
1333 extension->manifest()->value()->DeepCopy()); | 1333 extension->manifest()->value()->DeepCopy()); |
1334 } | 1334 } |
1335 } | 1335 } |
1336 } | 1336 } |
1337 | 1337 |
1338 base::FilePath ExtensionPrefs::GetExtensionPath( | |
1339 const std::string& extension_id) { | |
1340 const base::DictionaryValue* dict = GetExtensionPref(extension_id); | |
1341 if (!dict) | |
1342 return base::FilePath(); | |
1343 | |
1344 std::string path; | |
1345 if (!dict->GetString(kPrefPath, &path)) | |
1346 return base::FilePath(); | |
1347 | |
1348 return install_directory_.Append(base::FilePath::FromUTF8Unsafe(path)); | |
1349 } | |
1350 | |
1351 scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper( | 1338 scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper( |
1352 const std::string& extension_id, | 1339 const std::string& extension_id, |
1353 const base::DictionaryValue* extension) const { | 1340 const base::DictionaryValue* extension) const { |
1354 int location_value; | 1341 int location_value; |
1355 if (!extension->GetInteger(kPrefLocation, &location_value)) | 1342 if (!extension->GetInteger(kPrefLocation, &location_value)) |
1356 return scoped_ptr<ExtensionInfo>(); | 1343 return scoped_ptr<ExtensionInfo>(); |
1357 | 1344 |
1358 base::FilePath::StringType path; | 1345 base::FilePath::StringType path; |
1359 if (!extension->GetString(kPrefPath, &path)) | 1346 if (!extension->GetString(kPrefPath, &path)) |
1360 return scoped_ptr<ExtensionInfo>(); | 1347 return scoped_ptr<ExtensionInfo>(); |
1361 | 1348 |
1362 // Make path absolute. Unpacked extensions will already have absolute paths, | 1349 // Make path absolute. Unpacked extensions will already have absolute paths, |
1363 // otherwise make it so. | 1350 // otherwise make it so. |
1364 Manifest::Location location = static_cast<Manifest::Location>(location_value); | 1351 Manifest::Location location = static_cast<Manifest::Location>(location_value); |
| 1352 #if !defined(OS_CHROMEOS) |
1365 if (!Manifest::IsUnpackedLocation(location)) { | 1353 if (!Manifest::IsUnpackedLocation(location)) { |
1366 DCHECK(location == Manifest::COMPONENT || | 1354 DCHECK(location == Manifest::COMPONENT || |
1367 !base::FilePath(path).IsAbsolute()); | 1355 !base::FilePath(path).IsAbsolute()); |
| 1356 #else |
| 1357 // On Chrome OS some extensions can be installed to shared location and |
| 1358 // thus use absolute paths in prefs. |
| 1359 if (!base::FilePath(path).IsAbsolute()) { |
| 1360 #endif // !defined(OS_CHROMEOS) |
1368 path = install_directory_.Append(path).value(); | 1361 path = install_directory_.Append(path).value(); |
1369 } | 1362 } |
1370 | 1363 |
1371 // Only the following extension types have data saved in the preferences. | 1364 // Only the following extension types have data saved in the preferences. |
1372 if (location != Manifest::INTERNAL && | 1365 if (location != Manifest::INTERNAL && |
1373 !Manifest::IsUnpackedLocation(location) && | 1366 !Manifest::IsUnpackedLocation(location) && |
1374 !Manifest::IsExternalLocation(location)) { | 1367 !Manifest::IsExternalLocation(location)) { |
1375 NOTREACHED(); | 1368 NOTREACHED(); |
1376 return scoped_ptr<ExtensionInfo>(); | 1369 return scoped_ptr<ExtensionInfo>(); |
1377 } | 1370 } |
(...skipping 861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2239 extension_pref_value_map_->RegisterExtension( | 2232 extension_pref_value_map_->RegisterExtension( |
2240 extension_id, install_time, is_enabled, is_incognito_enabled); | 2233 extension_id, install_time, is_enabled, is_incognito_enabled); |
2241 | 2234 |
2242 FOR_EACH_OBSERVER( | 2235 FOR_EACH_OBSERVER( |
2243 ExtensionPrefsObserver, | 2236 ExtensionPrefsObserver, |
2244 observer_list_, | 2237 observer_list_, |
2245 OnExtensionRegistered(extension_id, install_time, is_enabled)); | 2238 OnExtensionRegistered(extension_id, install_time, is_enabled)); |
2246 } | 2239 } |
2247 | 2240 |
2248 } // namespace extensions | 2241 } // namespace extensions |
OLD | NEW |