Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: extensions/browser/extension_prefs.cc

Issue 273193006: Install Chrome OS apps to shared location (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment fixed Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1332 bool update_required = 1332 bool update_required =
1333 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || 1333 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) ||
1334 !extension->manifest()->value()->Equals(old_manifest); 1334 !extension->manifest()->value()->Equals(old_manifest);
1335 if (update_required) { 1335 if (update_required) {
1336 UpdateExtensionPref(extension->id(), kPrefManifest, 1336 UpdateExtensionPref(extension->id(), kPrefManifest,
1337 extension->manifest()->value()->DeepCopy()); 1337 extension->manifest()->value()->DeepCopy());
1338 } 1338 }
1339 } 1339 }
1340 } 1340 }
1341 1341
1342 base::FilePath ExtensionPrefs::GetExtensionPath(
1343 const std::string& extension_id) {
1344 const base::DictionaryValue* dict = GetExtensionPref(extension_id);
1345 if (!dict)
1346 return base::FilePath();
1347
1348 std::string path;
1349 if (!dict->GetString(kPrefPath, &path))
1350 return base::FilePath();
1351
1352 return install_directory_.Append(base::FilePath::FromUTF8Unsafe(path));
1353 }
1354
1355 scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper( 1342 scoped_ptr<ExtensionInfo> ExtensionPrefs::GetInstalledInfoHelper(
1356 const std::string& extension_id, 1343 const std::string& extension_id,
1357 const base::DictionaryValue* extension) const { 1344 const base::DictionaryValue* extension) const {
1358 int location_value; 1345 int location_value;
1359 if (!extension->GetInteger(kPrefLocation, &location_value)) 1346 if (!extension->GetInteger(kPrefLocation, &location_value))
1360 return scoped_ptr<ExtensionInfo>(); 1347 return scoped_ptr<ExtensionInfo>();
1361 1348
1362 base::FilePath::StringType path; 1349 base::FilePath::StringType path;
1363 if (!extension->GetString(kPrefPath, &path)) 1350 if (!extension->GetString(kPrefPath, &path))
1364 return scoped_ptr<ExtensionInfo>(); 1351 return scoped_ptr<ExtensionInfo>();
1365 1352
1366 // Make path absolute. Unpacked extensions will already have absolute paths, 1353 // Make path absolute. Unpacked extensions will already have absolute paths,
1367 // otherwise make it so. 1354 // otherwise make it so.
1368 Manifest::Location location = static_cast<Manifest::Location>(location_value); 1355 Manifest::Location location = static_cast<Manifest::Location>(location_value);
1356 #if !defined(OS_CHROMEOS)
1369 if (!Manifest::IsUnpackedLocation(location)) { 1357 if (!Manifest::IsUnpackedLocation(location)) {
1370 DCHECK(location == Manifest::COMPONENT || 1358 DCHECK(location == Manifest::COMPONENT ||
1371 !base::FilePath(path).IsAbsolute()); 1359 !base::FilePath(path).IsAbsolute());
1360 #else
1361 // On Chrome OS some extensions can be installed to shared location and
1362 // thus use absolute paths in prefs.
1363 if (!base::FilePath(path).IsAbsolute()) {
1364 #endif // !defined(OS_CHROMEOS)
1372 path = install_directory_.Append(path).value(); 1365 path = install_directory_.Append(path).value();
1373 } 1366 }
1374 1367
1375 // Only the following extension types have data saved in the preferences. 1368 // Only the following extension types have data saved in the preferences.
1376 if (location != Manifest::INTERNAL && 1369 if (location != Manifest::INTERNAL &&
1377 !Manifest::IsUnpackedLocation(location) && 1370 !Manifest::IsUnpackedLocation(location) &&
1378 !Manifest::IsExternalLocation(location)) { 1371 !Manifest::IsExternalLocation(location)) {
1379 NOTREACHED(); 1372 NOTREACHED();
1380 return scoped_ptr<ExtensionInfo>(); 1373 return scoped_ptr<ExtensionInfo>();
1381 } 1374 }
(...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 extension_pref_value_map_->RegisterExtension( 2261 extension_pref_value_map_->RegisterExtension(
2269 extension_id, install_time, is_enabled, is_incognito_enabled); 2262 extension_id, install_time, is_enabled, is_incognito_enabled);
2270 2263
2271 FOR_EACH_OBSERVER( 2264 FOR_EACH_OBSERVER(
2272 ExtensionPrefsObserver, 2265 ExtensionPrefsObserver,
2273 observer_list_, 2266 observer_list_,
2274 OnExtensionRegistered(extension_id, install_time, is_enabled)); 2267 OnExtensionRegistered(extension_id, install_time, is_enabled));
2275 } 2268 }
2276 2269
2277 } // namespace extensions 2270 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/extension_prefs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698