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

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

Issue 10834004: Correct const accessors in base/values.(h|cc) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Reverting webdriver:Command::parameters_ to const Created 8 years, 4 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
OLDNEW
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/extension_prefs.h" 5 #include "chrome/browser/extensions/extension_prefs.h"
6 6
7 #include "base/string_number_conversions.h" 7 #include "base/string_number_conversions.h"
8 #include "base/string_util.h" 8 #include "base/string_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/admin_policy.h" 10 #include "chrome/browser/extensions/admin_policy.h"
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 304
305 void ExtensionPrefs::MakePathsRelative() { 305 void ExtensionPrefs::MakePathsRelative() {
306 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); 306 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref);
307 if (!dict || dict->empty()) 307 if (!dict || dict->empty())
308 return; 308 return;
309 309
310 // Collect all extensions ids with absolute paths in |absolute_keys|. 310 // Collect all extensions ids with absolute paths in |absolute_keys|.
311 std::set<std::string> absolute_keys; 311 std::set<std::string> absolute_keys;
312 for (DictionaryValue::key_iterator i = dict->begin_keys(); 312 for (DictionaryValue::key_iterator i = dict->begin_keys();
313 i != dict->end_keys(); ++i) { 313 i != dict->end_keys(); ++i) {
314 DictionaryValue* extension_dict = NULL; 314 const DictionaryValue* extension_dict = NULL;
315 if (!dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict)) 315 if (!dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict))
316 continue; 316 continue;
317 int location_value; 317 int location_value;
318 if (extension_dict->GetInteger(kPrefLocation, &location_value) && 318 if (extension_dict->GetInteger(kPrefLocation, &location_value) &&
319 location_value == Extension::LOAD) { 319 location_value == Extension::LOAD) {
320 // Unpacked extensions can have absolute paths. 320 // Unpacked extensions can have absolute paths.
321 continue; 321 continue;
322 } 322 }
323 FilePath::StringType path_string; 323 FilePath::StringType path_string;
324 if (!extension_dict->GetString(kPrefPath, &path_string)) 324 if (!extension_dict->GetString(kPrefPath, &path_string))
325 continue; 325 continue;
326 FilePath path(path_string); 326 FilePath path(path_string);
327 if (path.IsAbsolute()) 327 if (path.IsAbsolute())
328 absolute_keys.insert(*i); 328 absolute_keys.insert(*i);
329 } 329 }
330 if (absolute_keys.empty()) 330 if (absolute_keys.empty())
331 return; 331 return;
332 332
333 // Fix these paths. 333 // Fix these paths.
334 DictionaryPrefUpdate update(prefs_, kExtensionsPref); 334 DictionaryPrefUpdate update(prefs_, kExtensionsPref);
335 const DictionaryValue* update_dict = update.Get(); 335 DictionaryValue* update_dict = update.Get();
336 for (std::set<std::string>::iterator i = absolute_keys.begin(); 336 for (std::set<std::string>::iterator i = absolute_keys.begin();
337 i != absolute_keys.end(); ++i) { 337 i != absolute_keys.end(); ++i) {
338 DictionaryValue* extension_dict = NULL; 338 DictionaryValue* extension_dict = NULL;
339 if (!update_dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict)) { 339 if (!update_dict->GetDictionaryWithoutPathExpansion(*i, &extension_dict)) {
340 NOTREACHED() << "Control should never reach here for extension " << *i; 340 NOTREACHED() << "Control should never reach here for extension " << *i;
341 continue; 341 continue;
342 } 342 }
343 FilePath::StringType path_string; 343 FilePath::StringType path_string;
344 extension_dict->GetString(kPrefPath, &path_string); 344 extension_dict->GetString(kPrefPath, &path_string);
345 FilePath path(path_string); 345 FilePath path(path_string);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 // No such extension yet. 423 // No such extension yet.
424 return false; 424 return false;
425 } 425 }
426 return ReadIntegerFromPref(ext, pref_key, out_value); 426 return ReadIntegerFromPref(ext, pref_key, out_value);
427 } 427 }
428 428
429 bool ExtensionPrefs::ReadExtensionPrefList( 429 bool ExtensionPrefs::ReadExtensionPrefList(
430 const std::string& extension_id, const std::string& pref_key, 430 const std::string& extension_id, const std::string& pref_key,
431 const ListValue** out_value) const { 431 const ListValue** out_value) const {
432 const DictionaryValue* ext = GetExtensionPref(extension_id); 432 const DictionaryValue* ext = GetExtensionPref(extension_id);
433 ListValue* out = NULL; 433 const ListValue* out = NULL;
434 if (!ext || !ext->GetList(pref_key, &out)) 434 if (!ext || !ext->GetList(pref_key, &out))
435 return false; 435 return false;
436 if (out_value) 436 if (out_value)
437 *out_value = out; 437 *out_value = out;
438 438
439 return true; 439 return true;
440 } 440 }
441 441
442 bool ExtensionPrefs::ReadExtensionPrefString( 442 bool ExtensionPrefs::ReadExtensionPrefString(
443 const std::string& extension_id, const std::string& pref_key, 443 const std::string& extension_id, const std::string& pref_key,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 533
534 // Set the scriptable host permissions. 534 // Set the scriptable host permissions.
535 if (!new_value->scriptable_hosts().is_empty()) { 535 if (!new_value->scriptable_hosts().is_empty()) {
536 SetExtensionPrefURLPatternSet(extension_id, 536 SetExtensionPrefURLPatternSet(extension_id,
537 JoinPrefs(pref_key, kPrefScriptableHosts), 537 JoinPrefs(pref_key, kPrefScriptableHosts),
538 new_value->scriptable_hosts()); 538 new_value->scriptable_hosts());
539 } 539 }
540 } 540 }
541 541
542 // static 542 // static
543 bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) { 543 bool ExtensionPrefs::IsBlacklistBitSet(const DictionaryValue* ext) {
544 return ReadBooleanFromPref(ext, kPrefBlacklist); 544 return ReadBooleanFromPref(ext, kPrefBlacklist);
545 } 545 }
546 546
547 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) { 547 bool ExtensionPrefs::IsExtensionBlacklisted(const std::string& extension_id) {
548 return ReadExtensionPrefBoolean(extension_id, kPrefBlacklist); 548 return ReadExtensionPrefBoolean(extension_id, kPrefBlacklist);
549 } 549 }
550 550
551 bool ExtensionPrefs::IsExtensionOrphaned(const std::string& extension_id) { 551 bool ExtensionPrefs::IsExtensionOrphaned(const std::string& extension_id) {
552 // TODO(miket): we believe that this test will hinge on the number of 552 // TODO(miket): we believe that this test will hinge on the number of
553 // consecutive times that an update check has returned a certain response 553 // consecutive times that an update check has returned a certain response
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 700
701 void ExtensionPrefs::UpdateBlacklist( 701 void ExtensionPrefs::UpdateBlacklist(
702 const std::set<std::string>& blacklist_set) { 702 const std::set<std::string>& blacklist_set) {
703 std::vector<std::string> remove_pref_ids; 703 std::vector<std::string> remove_pref_ids;
704 std::set<std::string> used_id_set; 704 std::set<std::string> used_id_set;
705 const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref); 705 const DictionaryValue* extensions = prefs_->GetDictionary(kExtensionsPref);
706 706
707 if (extensions) { 707 if (extensions) {
708 for (DictionaryValue::key_iterator extension_id = extensions->begin_keys(); 708 for (DictionaryValue::key_iterator extension_id = extensions->begin_keys();
709 extension_id != extensions->end_keys(); ++extension_id) { 709 extension_id != extensions->end_keys(); ++extension_id) {
710 DictionaryValue* ext; 710 const DictionaryValue* ext;
711 if (!extensions->GetDictionaryWithoutPathExpansion(*extension_id, &ext)) { 711 if (!extensions->GetDictionaryWithoutPathExpansion(*extension_id, &ext)) {
712 NOTREACHED() << "Invalid pref for extension " << *extension_id; 712 NOTREACHED() << "Invalid pref for extension " << *extension_id;
713 continue; 713 continue;
714 } 714 }
715 const std::string& id(*extension_id); 715 const std::string& id(*extension_id);
716 if (blacklist_set.find(id) == blacklist_set.end()) { 716 if (blacklist_set.find(id) == blacklist_set.end()) {
717 if (!IsBlacklistBitSet(ext)) { 717 if (!IsBlacklistBitSet(ext)) {
718 // This extension is not in blacklist. And it was not blacklisted 718 // This extension is not in blacklist. And it was not blacklisted
719 // before. 719 // before.
720 continue; 720 continue;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 const DictionaryValue* ext = GetExtensionPref(*ext_id); 841 const DictionaryValue* ext = GetExtensionPref(*ext_id);
842 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) 842 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access))
843 continue; 843 continue;
844 844
845 // Remove the full access bit (empty list will get trimmed). 845 // Remove the full access bit (empty list will get trimmed).
846 UpdateExtensionPref( 846 UpdateExtensionPref(
847 *ext_id, kPrefOldGrantedFullAccess, new ListValue()); 847 *ext_id, kPrefOldGrantedFullAccess, new ListValue());
848 848
849 // Add the plugin permission if the full access bit was set. 849 // Add the plugin permission if the full access bit was set.
850 if (full_access) { 850 if (full_access) {
851 ListValue* apis = NULL; 851 const ListValue* apis = NULL;
852 ListValue* new_apis = NULL; 852 ListValue* new_apis = NULL;
853 853
854 std::string granted_apis = 854 std::string granted_apis =
855 JoinPrefs(kPrefGrantedPermissions, kPrefAPIs); 855 JoinPrefs(kPrefGrantedPermissions, kPrefAPIs);
856 if (ext->GetList(kPrefOldGrantedAPIs, &apis)) 856 if (ext->GetList(kPrefOldGrantedAPIs, &apis))
857 new_apis = apis->DeepCopy(); 857 new_apis = apis->DeepCopy();
858 else 858 else
859 new_apis = new ListValue(); 859 new_apis = new ListValue();
860 860
861 std::string plugin_name = info->GetByID( 861 std::string plugin_name = info->GetByID(
862 APIPermission::kPlugin)->name(); 862 APIPermission::kPlugin)->name();
863 new_apis->Append(Value::CreateStringValue(plugin_name)); 863 new_apis->Append(Value::CreateStringValue(plugin_name));
864 UpdateExtensionPref(*ext_id, granted_apis, new_apis); 864 UpdateExtensionPref(*ext_id, granted_apis, new_apis);
865 } 865 }
866 866
867 // The granted permissions originally only held the effective hosts, 867 // The granted permissions originally only held the effective hosts,
868 // which are a combination of host and user script host permissions. 868 // which are a combination of host and user script host permissions.
869 // We now maintain these lists separately. For migration purposes, it 869 // We now maintain these lists separately. For migration purposes, it
870 // does not matter how we treat the old effective hosts as long as the 870 // does not matter how we treat the old effective hosts as long as the
871 // new effective hosts will be the same, so we move them to explicit 871 // new effective hosts will be the same, so we move them to explicit
872 // host permissions. 872 // host permissions.
873 ListValue* hosts; 873 const ListValue* hosts;
874 std::string explicit_hosts = 874 std::string explicit_hosts =
875 JoinPrefs(kPrefGrantedPermissions, kPrefExplicitHosts); 875 JoinPrefs(kPrefGrantedPermissions, kPrefExplicitHosts);
876 if (ext->GetList(kPrefOldGrantedHosts, &hosts)) { 876 if (ext->GetList(kPrefOldGrantedHosts, &hosts)) {
877 UpdateExtensionPref( 877 UpdateExtensionPref(
878 *ext_id, explicit_hosts, hosts->DeepCopy()); 878 *ext_id, explicit_hosts, hosts->DeepCopy());
879 879
880 // We can get rid of the old one by setting it to an empty list. 880 // We can get rid of the old one by setting it to an empty list.
881 UpdateExtensionPref(*ext_id, kPrefOldGrantedHosts, new ListValue()); 881 UpdateExtensionPref(*ext_id, kPrefOldGrantedHosts, new ListValue());
882 } 882 }
883 } 883 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 extension_id, kPrefActivePermissions, permissions); 938 extension_id, kPrefActivePermissions, permissions);
939 } 939 }
940 940
941 std::set<std::string> ExtensionPrefs::GetRegisteredEvents( 941 std::set<std::string> ExtensionPrefs::GetRegisteredEvents(
942 const std::string& extension_id) { 942 const std::string& extension_id) {
943 std::set<std::string> events; 943 std::set<std::string> events;
944 const DictionaryValue* extension = GetExtensionPref(extension_id); 944 const DictionaryValue* extension = GetExtensionPref(extension_id);
945 if (!extension) 945 if (!extension)
946 return events; 946 return events;
947 947
948 ListValue* value = NULL; 948 const ListValue* value = NULL;
949 if (!extension->GetList(kRegisteredEvents, &value)) 949 if (!extension->GetList(kRegisteredEvents, &value))
950 return events; 950 return events;
951 951
952 for (size_t i = 0; i < value->GetSize(); ++i) { 952 for (size_t i = 0; i < value->GetSize(); ++i) {
953 std::string event; 953 std::string event;
954 if (value->GetString(i, &event)) 954 if (value->GetString(i, &event))
955 events.insert(event); 955 events.insert(event);
956 } 956 }
957 return events; 957 return events;
958 } 958 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 break; 997 break;
998 } 998 }
999 } 999 }
1000 } 1000 }
1001 1001
1002 const DictionaryValue* ExtensionPrefs::GetFilteredEvents( 1002 const DictionaryValue* ExtensionPrefs::GetFilteredEvents(
1003 const std::string& extension_id) const { 1003 const std::string& extension_id) const {
1004 const DictionaryValue* extension = GetExtensionPref(extension_id); 1004 const DictionaryValue* extension = GetExtensionPref(extension_id);
1005 if (!extension) 1005 if (!extension)
1006 return NULL; 1006 return NULL;
1007 DictionaryValue* result = NULL; 1007 const DictionaryValue* result = NULL;
1008 if (!extension->GetDictionary(kFilteredEvents, &result)) 1008 if (!extension->GetDictionary(kFilteredEvents, &result))
1009 return NULL; 1009 return NULL;
1010 return result; 1010 return result;
1011 } 1011 }
1012 1012
1013 void ExtensionPrefs::SetRegisteredEvents( 1013 void ExtensionPrefs::SetRegisteredEvents(
1014 const std::string& extension_id, const std::set<std::string>& events) { 1014 const std::string& extension_id, const std::set<std::string>& events) {
1015 ListValue* value = new ListValue(); 1015 ListValue* value = new ListValue();
1016 for (std::set<std::string>::const_iterator it = events.begin(); 1016 for (std::set<std::string>::const_iterator it = events.begin();
1017 it != events.end(); ++it) { 1017 it != events.end(); ++it) {
1018 value->Append(new StringValue(*it)); 1018 value->Append(new StringValue(*it));
1019 } 1019 }
1020 UpdateExtensionPref(extension_id, kRegisteredEvents, value); 1020 UpdateExtensionPref(extension_id, kRegisteredEvents, value);
1021 } 1021 }
1022 1022
1023 ExtensionOmniboxSuggestion 1023 ExtensionOmniboxSuggestion
1024 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) { 1024 ExtensionPrefs::GetOmniboxDefaultSuggestion(const std::string& extension_id) {
1025 ExtensionOmniboxSuggestion suggestion; 1025 ExtensionOmniboxSuggestion suggestion;
1026 1026
1027 const base::DictionaryValue* extension = GetExtensionPref(extension_id); 1027 const DictionaryValue* extension = GetExtensionPref(extension_id);
1028 base::DictionaryValue* dict = NULL; 1028 const DictionaryValue* dict = NULL;
1029 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict)) 1029 if (extension && extension->GetDictionary(kOmniboxDefaultSuggestion, &dict))
1030 suggestion.Populate(*dict, false); 1030 suggestion.Populate(*dict, false);
1031 1031
1032 return suggestion; 1032 return suggestion;
1033 } 1033 }
1034 1034
1035 void ExtensionPrefs::SetOmniboxDefaultSuggestion( 1035 void ExtensionPrefs::SetOmniboxDefaultSuggestion(
1036 const std::string& extension_id, 1036 const std::string& extension_id,
1037 const ExtensionOmniboxSuggestion& suggestion) { 1037 const ExtensionOmniboxSuggestion& suggestion) {
1038 scoped_ptr<base::DictionaryValue> dict = suggestion.ToValue().Pass(); 1038 scoped_ptr<base::DictionaryValue> dict = suggestion.ToValue().Pass();
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 } 1329 }
1330 1330
1331 return version; 1331 return version;
1332 } 1332 }
1333 1333
1334 void ExtensionPrefs::UpdateManifest(const Extension* extension) { 1334 void ExtensionPrefs::UpdateManifest(const Extension* extension) {
1335 if (extension->location() != Extension::LOAD) { 1335 if (extension->location() != Extension::LOAD) {
1336 const DictionaryValue* extension_dict = GetExtensionPref(extension->id()); 1336 const DictionaryValue* extension_dict = GetExtensionPref(extension->id());
1337 if (!extension_dict) 1337 if (!extension_dict)
1338 return; 1338 return;
1339 DictionaryValue* old_manifest = NULL; 1339 const DictionaryValue* old_manifest = NULL;
1340 bool update_required = 1340 bool update_required =
1341 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) || 1341 !extension_dict->GetDictionary(kPrefManifest, &old_manifest) ||
1342 !extension->manifest()->value()->Equals(old_manifest); 1342 !extension->manifest()->value()->Equals(old_manifest);
1343 if (update_required) { 1343 if (update_required) {
1344 UpdateExtensionPref(extension->id(), kPrefManifest, 1344 UpdateExtensionPref(extension->id(), kPrefManifest,
1345 extension->manifest()->value()->DeepCopy()); 1345 extension->manifest()->value()->DeepCopy());
1346 } 1346 }
1347 } 1347 }
1348 } 1348 }
1349 1349
(...skipping 29 matching lines...) Expand all
1379 DictionaryPrefUpdate update(prefs_, kExtensionsPref); 1379 DictionaryPrefUpdate update(prefs_, kExtensionsPref);
1380 DictionaryValue* dict = update.Get(); 1380 DictionaryValue* dict = update.Get();
1381 dict->Remove(extension_id, NULL); 1381 dict->Remove(extension_id, NULL);
1382 } 1382 }
1383 1383
1384 const DictionaryValue* ExtensionPrefs::GetExtensionPref( 1384 const DictionaryValue* ExtensionPrefs::GetExtensionPref(
1385 const std::string& extension_id) const { 1385 const std::string& extension_id) const {
1386 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref); 1386 const DictionaryValue* dict = prefs_->GetDictionary(kExtensionsPref);
1387 if (!dict) 1387 if (!dict)
1388 return NULL; 1388 return NULL;
1389 DictionaryValue* extension = NULL; 1389 const DictionaryValue* extension = NULL;
1390 dict->GetDictionary(extension_id, &extension); 1390 dict->GetDictionary(extension_id, &extension);
1391 return extension; 1391 return extension;
1392 } 1392 }
1393 1393
1394 // Helper function for GetInstalledExtensionsInfo. 1394 // Helper function for GetInstalledExtensionsInfo.
1395 static ExtensionInfo* GetInstalledExtensionInfoImpl( 1395 static ExtensionInfo* GetInstalledExtensionInfoImpl(
1396 DictionaryValue* extension_data, 1396 DictionaryValue* extension_data,
1397 DictionaryValue::key_iterator extension_id) { 1397 DictionaryValue::key_iterator extension_id) {
1398 DictionaryValue* ext; 1398 DictionaryValue* ext;
1399 if (!extension_data->GetDictionaryWithoutPathExpansion(*extension_id, &ext)) { 1399 if (!extension_data->GetDictionaryWithoutPathExpansion(*extension_id, &ext)) {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1511 bool ExtensionPrefs::GetIdleInstallInfo(const std::string& extension_id, 1511 bool ExtensionPrefs::GetIdleInstallInfo(const std::string& extension_id,
1512 FilePath* crx_path, 1512 FilePath* crx_path,
1513 std::string* version, 1513 std::string* version,
1514 base::Time* fetch_time) { 1514 base::Time* fetch_time) {
1515 const DictionaryValue* extension_prefs = GetExtensionPref(extension_id); 1515 const DictionaryValue* extension_prefs = GetExtensionPref(extension_id);
1516 if (!extension_prefs) 1516 if (!extension_prefs)
1517 return false; 1517 return false;
1518 1518
1519 // Do all the reads from the prefs together, and don't do any assignment 1519 // Do all the reads from the prefs together, and don't do any assignment
1520 // to the out parameters unless all the reads succeed. 1520 // to the out parameters unless all the reads succeed.
1521 DictionaryValue* info = NULL; 1521 const DictionaryValue* info = NULL;
1522 if (!extension_prefs->GetDictionary(kIdleInstallInfo, &info)) 1522 if (!extension_prefs->GetDictionary(kIdleInstallInfo, &info))
1523 return false; 1523 return false;
1524 1524
1525 FilePath::StringType path_string; 1525 FilePath::StringType path_string;
1526 if (!info->GetString(kIdleInstallInfoCrxPath, &path_string)) 1526 if (!info->GetString(kIdleInstallInfoCrxPath, &path_string))
1527 return false; 1527 return false;
1528 1528
1529 std::string tmp_version; 1529 std::string tmp_version;
1530 if (!info->GetString(kIdleInstallInfoVersion, &tmp_version)) 1530 if (!info->GetString(kIdleInstallInfoVersion, &tmp_version))
1531 return false; 1531 return false;
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 out->push_back(info->extension_id); 1676 out->push_back(info->extension_id);
1677 } 1677 }
1678 } 1678 }
1679 1679
1680 // static 1680 // static
1681 ExtensionPrefs::ExtensionIdSet ExtensionPrefs::GetExtensionsFrom( 1681 ExtensionPrefs::ExtensionIdSet ExtensionPrefs::GetExtensionsFrom(
1682 const base::DictionaryValue* extension_prefs) { 1682 const base::DictionaryValue* extension_prefs) {
1683 ExtensionIdSet result; 1683 ExtensionIdSet result;
1684 for (base::DictionaryValue::key_iterator it = extension_prefs->begin_keys(); 1684 for (base::DictionaryValue::key_iterator it = extension_prefs->begin_keys();
1685 it != extension_prefs->end_keys(); ++it) { 1685 it != extension_prefs->end_keys(); ++it) {
1686 DictionaryValue* ext; 1686 const DictionaryValue* ext;
1687 if (!extension_prefs->GetDictionaryWithoutPathExpansion(*it, &ext)) { 1687 if (!extension_prefs->GetDictionaryWithoutPathExpansion(*it, &ext)) {
1688 NOTREACHED() << "Invalid pref for extension " << *it; 1688 NOTREACHED() << "Invalid pref for extension " << *it;
1689 continue; 1689 continue;
1690 } 1690 }
1691 if (!IsBlacklistBitSet(ext)) 1691 if (!IsBlacklistBitSet(ext))
1692 result.push_back(*it); 1692 result.push_back(*it);
1693 } 1693 }
1694 return result; 1694 return result;
1695 } 1695 }
1696 1696
(...skipping 14 matching lines...) Expand all
1711 } 1711 }
1712 } 1712 }
1713 1713
1714 void ExtensionPrefs::LoadExtensionControlledPrefs( 1714 void ExtensionPrefs::LoadExtensionControlledPrefs(
1715 const std::string& extension_id, 1715 const std::string& extension_id,
1716 ExtensionPrefsScope scope) { 1716 ExtensionPrefsScope scope) {
1717 std::string scope_string; 1717 std::string scope_string;
1718 bool success = ScopeToPrefKey(scope, &scope_string); 1718 bool success = ScopeToPrefKey(scope, &scope_string);
1719 DCHECK(success); 1719 DCHECK(success);
1720 std::string key = extension_id + "." + scope_string; 1720 std::string key = extension_id + "." + scope_string;
1721 DictionaryValue* preferences = NULL; 1721 const DictionaryValue* preferences = NULL;
1722 // First try the regular lookup. 1722 // First try the regular lookup.
1723 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref); 1723 const DictionaryValue* source_dict = prefs_->GetDictionary(kExtensionsPref);
1724 if (!source_dict->GetDictionary(key, &preferences)) 1724 if (!source_dict->GetDictionary(key, &preferences))
1725 return; 1725 return;
1726 1726
1727 for (DictionaryValue::Iterator i(*preferences); i.HasNext(); i.Advance()) { 1727 for (DictionaryValue::Iterator i(*preferences); i.HasNext(); i.Advance()) {
1728 extension_pref_value_map_->SetExtensionPref( 1728 extension_pref_value_map_->SetExtensionPref(
1729 extension_id, i.key(), scope, i.value().DeepCopy()); 1729 extension_id, i.key(), scope, i.value().DeepCopy());
1730 } 1730 }
1731 } 1731 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1771 LoadExtensionControlledPrefs(*ext_id, kExtensionPrefsScopeRegular); 1771 LoadExtensionControlledPrefs(*ext_id, kExtensionPrefsScopeRegular);
1772 // Set incognito extension controlled prefs. 1772 // Set incognito extension controlled prefs.
1773 LoadExtensionControlledPrefs(*ext_id, 1773 LoadExtensionControlledPrefs(*ext_id,
1774 kExtensionPrefsScopeIncognitoPersistent); 1774 kExtensionPrefsScopeIncognitoPersistent);
1775 // Set regular-only extension controlled prefs. 1775 // Set regular-only extension controlled prefs.
1776 LoadExtensionControlledPrefs(*ext_id, kExtensionPrefsScopeRegularOnly); 1776 LoadExtensionControlledPrefs(*ext_id, kExtensionPrefsScopeRegularOnly);
1777 1777
1778 // Set content settings. 1778 // Set content settings.
1779 const DictionaryValue* extension_prefs = GetExtensionPref(*ext_id); 1779 const DictionaryValue* extension_prefs = GetExtensionPref(*ext_id);
1780 DCHECK(extension_prefs); 1780 DCHECK(extension_prefs);
1781 ListValue* content_settings = NULL; 1781 const ListValue* content_settings = NULL;
1782 if (extension_prefs->GetList(kPrefContentSettings, 1782 if (extension_prefs->GetList(kPrefContentSettings,
1783 &content_settings)) { 1783 &content_settings)) {
1784 content_settings_store_->SetExtensionContentSettingFromList( 1784 content_settings_store_->SetExtensionContentSettingFromList(
1785 *ext_id, content_settings, 1785 *ext_id, content_settings,
1786 kExtensionPrefsScopeRegular); 1786 kExtensionPrefsScopeRegular);
1787 } 1787 }
1788 if (extension_prefs->GetList(kPrefIncognitoContentSettings, 1788 if (extension_prefs->GetList(kPrefIncognitoContentSettings,
1789 &content_settings)) { 1789 &content_settings)) {
1790 content_settings_store_->SetExtensionContentSettingFromList( 1790 content_settings_store_->SetExtensionContentSettingFromList(
1791 *ext_id, content_settings, 1791 *ext_id, content_settings,
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1934 0, // default value 1934 0, // default value
1935 PrefService::UNSYNCABLE_PREF); 1935 PrefService::UNSYNCABLE_PREF);
1936 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, 1936 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck,
1937 0, // default value 1937 0, // default value
1938 PrefService::UNSYNCABLE_PREF); 1938 PrefService::UNSYNCABLE_PREF);
1939 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, 1939 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites,
1940 PrefService::UNSYNCABLE_PREF); 1940 PrefService::UNSYNCABLE_PREF);
1941 } 1941 }
1942 1942
1943 } // namespace extensions 1943 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698