| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_pref_store.h" | 10 #include "chrome/browser/extensions/extension_pref_store.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 | 60 |
| 61 // Path for settings specific to blacklist update. | 61 // Path for settings specific to blacklist update. |
| 62 const char kExtensionsBlacklistUpdate[] = "extensions.blacklistupdate"; | 62 const char kExtensionsBlacklistUpdate[] = "extensions.blacklistupdate"; |
| 63 | 63 |
| 64 // Path and sub-keys for the idle install info dictionary preference. | 64 // Path and sub-keys for the idle install info dictionary preference. |
| 65 const char kIdleInstallInfo[] = "idle_install_info"; | 65 const char kIdleInstallInfo[] = "idle_install_info"; |
| 66 const char kIdleInstallInfoCrxPath[] = "crx_path"; | 66 const char kIdleInstallInfoCrxPath[] = "crx_path"; |
| 67 const char kIdleInstallInfoVersion[] = "version"; | 67 const char kIdleInstallInfoVersion[] = "version"; |
| 68 const char kIdleInstallInfoFetchTime[] = "fetch_time"; | 68 const char kIdleInstallInfoFetchTime[] = "fetch_time"; |
| 69 | 69 |
| 70 | |
| 71 // A preference that, if true, will allow this extension to run in incognito | 70 // A preference that, if true, will allow this extension to run in incognito |
| 72 // mode. | 71 // mode. |
| 73 const char kPrefIncognitoEnabled[] = "incognito"; | 72 const char kPrefIncognitoEnabled[] = "incognito"; |
| 74 | 73 |
| 75 // A preference to control whether an extension is allowed to inject script in | 74 // A preference to control whether an extension is allowed to inject script in |
| 76 // pages with file URLs. | 75 // pages with file URLs. |
| 77 const char kPrefAllowFileAccess[] = "allowFileAccess"; | 76 const char kPrefAllowFileAccess[] = "allowFileAccess"; |
| 78 | 77 |
| 79 // A preference set by the web store to indicate login information for | 78 // A preference set by the web store to indicate login information for |
| 80 // purchased apps. | 79 // purchased apps. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 96 // A preference for storing extra data sent in update checks for an extension. | 95 // A preference for storing extra data sent in update checks for an extension. |
| 97 const char kUpdateUrlData[] = "update_url_data"; | 96 const char kUpdateUrlData[] = "update_url_data"; |
| 98 | 97 |
| 99 // Whether the browser action is visible in the toolbar. | 98 // Whether the browser action is visible in the toolbar. |
| 100 const char kBrowserActionVisible[] = "browser_action_visible"; | 99 const char kBrowserActionVisible[] = "browser_action_visible"; |
| 101 | 100 |
| 102 // Preferences that hold which permissions the user has granted the extension. | 101 // Preferences that hold which permissions the user has granted the extension. |
| 103 // We explicitly keep track of these so that extensions can contain unknown | 102 // We explicitly keep track of these so that extensions can contain unknown |
| 104 // permissions, for backwards compatibility reasons, and we can still prompt | 103 // permissions, for backwards compatibility reasons, and we can still prompt |
| 105 // the user to accept them once recognized. | 104 // the user to accept them once recognized. |
| 106 const char kPrefGrantedPermissionsAPI[] = "granted_permissions.api"; | 105 const char kPrefGrantedAPIs[] = "granted_permissions.api"; |
| 107 const char kPrefGrantedPermissionsHost[] = "granted_permissions.host"; | 106 const char kPrefGrantedExplicitHosts[] = "granted_permissions.explicit_host"; |
| 108 const char kPrefGrantedPermissionsAll[] = "granted_permissions.full"; | 107 const char kPrefGrantedScriptableHosts[] = |
| 108 "granted_permissions.scriptable_host"; |
| 109 |
| 110 // The preference names for the old granted permissions scheme. |
| 111 const char kPrefOldGrantedFullAccess[] = "granted_permissions.full"; |
| 112 const char kPrefOldGrantedHosts[] = "granted_permissions.host"; |
| 113 const char kPrefOldGrantedAPIs[] = "granted_permissions.api"; |
| 109 | 114 |
| 110 // A preference that indicates when an extension was installed. | 115 // A preference that indicates when an extension was installed. |
| 111 const char kPrefInstallTime[] = "install_time"; | 116 const char kPrefInstallTime[] = "install_time"; |
| 112 | 117 |
| 113 // A preference that contains any extension-controlled preferences. | 118 // A preference that contains any extension-controlled preferences. |
| 114 const char kPrefPreferences[] = "preferences"; | 119 const char kPrefPreferences[] = "preferences"; |
| 115 | 120 |
| 116 // A preference that contains any extension-controlled incognito preferences. | 121 // A preference that contains any extension-controlled incognito preferences. |
| 117 const char kPrefIncognitoPreferences[] = "incognito_preferences"; | 122 const char kPrefIncognitoPreferences[] = "incognito_preferences"; |
| 118 | 123 |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 Value* extension_prefs = NULL; | 254 Value* extension_prefs = NULL; |
| 250 CHECK(update_dictionary->RemoveWithoutPathExpansion( | 255 CHECK(update_dictionary->RemoveWithoutPathExpansion( |
| 251 i->first, &extension_prefs)); | 256 i->first, &extension_prefs)); |
| 252 update_dictionary->SetWithoutPathExpansion(i->second, extension_prefs); | 257 update_dictionary->SetWithoutPathExpansion(i->second, extension_prefs); |
| 253 } | 258 } |
| 254 | 259 |
| 255 prefs->ScheduleSavePersistentPrefs(); | 260 prefs->ScheduleSavePersistentPrefs(); |
| 256 } | 261 } |
| 257 } | 262 } |
| 258 | 263 |
| 259 static void ExtentToStringSet(const URLPatternSet& host_extent, | |
| 260 std::set<std::string>* result) { | |
| 261 URLPatternList patterns = host_extent.patterns(); | |
| 262 URLPatternList::const_iterator i; | |
| 263 | |
| 264 for (i = patterns.begin(); i != patterns.end(); ++i) | |
| 265 result->insert(i->GetAsString()); | |
| 266 } | |
| 267 | |
| 268 } // namespace | 264 } // namespace |
| 269 | 265 |
| 270 ExtensionPrefs::ExtensionPrefs( | 266 ExtensionPrefs::ExtensionPrefs( |
| 271 PrefService* prefs, | 267 PrefService* prefs, |
| 272 const FilePath& root_dir, | 268 const FilePath& root_dir, |
| 273 ExtensionPrefValueMap* extension_pref_value_map) | 269 ExtensionPrefValueMap* extension_pref_value_map) |
| 274 : prefs_(prefs), | 270 : prefs_(prefs), |
| 275 install_directory_(root_dir), | 271 install_directory_(root_dir), |
| 276 extension_pref_value_map_(extension_pref_value_map), | 272 extension_pref_value_map_(extension_pref_value_map), |
| 277 content_settings_store_(new ExtensionContentSettingsStore()) { | 273 content_settings_store_(new ExtensionContentSettingsStore()) { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 const DictionaryValue* ext = GetExtensionPref(extension_id); | 427 const DictionaryValue* ext = GetExtensionPref(extension_id); |
| 432 ListValue* out = NULL; | 428 ListValue* out = NULL; |
| 433 if (!ext || !ext->GetList(pref_key, &out)) | 429 if (!ext || !ext->GetList(pref_key, &out)) |
| 434 return false; | 430 return false; |
| 435 if (out_value) | 431 if (out_value) |
| 436 *out_value = out; | 432 *out_value = out; |
| 437 | 433 |
| 438 return true; | 434 return true; |
| 439 } | 435 } |
| 440 | 436 |
| 441 bool ExtensionPrefs::ReadExtensionPrefStringSet( | 437 bool ExtensionPrefs::ReadExtensionPrefURLPatternSet( |
| 442 const std::string& extension_id, | 438 const std::string& extension_id, |
| 443 const std::string& pref_key, | 439 const std::string& pref_key, |
| 444 std::set<std::string>* result) { | 440 URLPatternSet* result, |
| 441 int valid_schemes) { |
| 445 const ListValue* value = NULL; | 442 const ListValue* value = NULL; |
| 446 if (!ReadExtensionPrefList(extension_id, pref_key, &value)) | 443 if (!ReadExtensionPrefList(extension_id, pref_key, &value)) |
| 447 return false; | 444 return false; |
| 448 | 445 |
| 449 result->clear(); | 446 result->ClearPatterns(); |
| 447 bool allow_file_access = AllowFileAccess(extension_id); |
| 450 | 448 |
| 451 for (size_t i = 0; i < value->GetSize(); ++i) { | 449 for (size_t i = 0; i < value->GetSize(); ++i) { |
| 452 std::string item; | 450 std::string item; |
| 453 if (!value->GetString(i, &item)) | 451 if (!value->GetString(i, &item)) |
| 454 return false; | 452 return false; |
| 455 result->insert(item); | 453 URLPattern pattern(valid_schemes); |
| 454 if (pattern.Parse(item, URLPattern::PARSE_LENIENT) != |
| 455 URLPattern::PARSE_SUCCESS) { |
| 456 NOTREACHED(); |
| 457 return false; |
| 458 } |
| 459 if (!allow_file_access && pattern.MatchesScheme(chrome::kFileScheme)) { |
| 460 pattern.set_valid_schemes( |
| 461 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); |
| 462 } |
| 463 result->AddPattern(pattern); |
| 456 } | 464 } |
| 457 | 465 |
| 458 return true; | 466 return true; |
| 459 } | 467 } |
| 460 | 468 |
| 461 void ExtensionPrefs::AddToExtensionPrefStringSet( | 469 void ExtensionPrefs::SetExtensionPrefURLPatternSet( |
| 462 const std::string& extension_id, | 470 const std::string& extension_id, |
| 463 const std::string& pref_key, | 471 const std::string& pref_key, |
| 464 const std::set<std::string>& added_value) { | 472 const URLPatternSet& new_value) { |
| 465 std::set<std::string> old_value; | |
| 466 std::set<std::string> new_value; | |
| 467 ReadExtensionPrefStringSet(extension_id, pref_key, &old_value); | |
| 468 | |
| 469 std::set_union(old_value.begin(), old_value.end(), | |
| 470 added_value.begin(), added_value.end(), | |
| 471 std::inserter(new_value, new_value.begin())); | |
| 472 | |
| 473 ListValue* value = new ListValue(); | 473 ListValue* value = new ListValue(); |
| 474 for (std::set<std::string>::const_iterator iter = new_value.begin(); | 474 for (URLPatternList::const_iterator i = new_value.patterns().begin(); |
| 475 iter != new_value.end(); ++iter) | 475 i != new_value.patterns().end(); ++i) |
| 476 value->Append(Value::CreateStringValue(*iter)); | 476 value->AppendIfNotPresent(Value::CreateStringValue(i->GetAsString())); |
| 477 | 477 |
| 478 UpdateExtensionPref(extension_id, pref_key, value); | 478 UpdateExtensionPref(extension_id, pref_key, value); |
| 479 } | 479 } |
| 480 | 480 |
| 481 void ExtensionPrefs::SavePrefs() { | 481 void ExtensionPrefs::SavePrefs() { |
| 482 prefs_->ScheduleSavePersistentPrefs(); | 482 prefs_->ScheduleSavePersistentPrefs(); |
| 483 } | 483 } |
| 484 | 484 |
| 485 // static | 485 // static |
| 486 bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) { | 486 bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 return result; | 664 return result; |
| 665 return false; | 665 return false; |
| 666 } | 666 } |
| 667 | 667 |
| 668 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, | 668 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, |
| 669 bool active) { | 669 bool active) { |
| 670 UpdateExtensionPref(extension_id, kActiveBit, | 670 UpdateExtensionPref(extension_id, kActiveBit, |
| 671 Value::CreateBooleanValue(active)); | 671 Value::CreateBooleanValue(active)); |
| 672 } | 672 } |
| 673 | 673 |
| 674 bool ExtensionPrefs::GetGrantedPermissions( | 674 void ExtensionPrefs::MigratePermissions(const ExtensionIdSet& extension_ids) { |
| 675 const std::string& extension_id, | 675 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); |
| 676 bool* full_access, | 676 for (ExtensionIdSet::const_iterator ext_id = extension_ids.begin(); |
| 677 std::set<std::string>* api_permissions, | 677 ext_id != extension_ids.end(); ++ext_id) { |
| 678 URLPatternSet* host_extent) { | 678 |
| 679 // An extension's granted permissions need to be migrated if the |
| 680 // full_access bit is present. This bit was always present in the previous |
| 681 // scheme and is never present now. |
| 682 bool full_access; |
| 683 const DictionaryValue* ext = GetExtensionPref(*ext_id); |
| 684 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) |
| 685 continue; |
| 686 |
| 687 // Remove the full access bit (empty list will get trimmed). |
| 688 UpdateExtensionPref( |
| 689 *ext_id, kPrefOldGrantedFullAccess, new ListValue()); |
| 690 |
| 691 // Add the plugin permission if the full access bit was set. |
| 692 if (full_access) { |
| 693 ListValue* apis = NULL; |
| 694 ListValue* new_apis = NULL; |
| 695 |
| 696 if (ext->GetList(kPrefGrantedAPIs, &apis)) |
| 697 new_apis = apis->DeepCopy(); |
| 698 else |
| 699 new_apis = new ListValue(); |
| 700 |
| 701 std::string plugin_name = info->GetByID( |
| 702 ExtensionAPIPermission::kPlugin)->name(); |
| 703 new_apis->Append(Value::CreateStringValue(plugin_name)); |
| 704 UpdateExtensionPref(*ext_id, kPrefGrantedAPIs, new_apis); |
| 705 } |
| 706 |
| 707 // The granted permissions originally only held the effective hosts, |
| 708 // which are a combination of host and user script host permissions. |
| 709 // We now maintain these lists separately. For migration purposes, it |
| 710 // does not matter how we treat the old effective hosts as long as the |
| 711 // new effective hosts will be the same, so we move them to explicit |
| 712 // host permissions. |
| 713 ListValue* hosts; |
| 714 if (ext->GetList(kPrefOldGrantedHosts, &hosts)) { |
| 715 UpdateExtensionPref( |
| 716 *ext_id, kPrefGrantedExplicitHosts, hosts->DeepCopy()); |
| 717 |
| 718 // We can get rid of the old one by setting it to an empty list. |
| 719 UpdateExtensionPref(*ext_id, kPrefOldGrantedHosts, new ListValue()); |
| 720 } |
| 721 } |
| 722 } |
| 723 |
| 724 ExtensionPermissionSet* ExtensionPrefs::GetGrantedPermissions( |
| 725 const std::string& extension_id) { |
| 679 CHECK(Extension::IdIsValid(extension_id)); | 726 CHECK(Extension::IdIsValid(extension_id)); |
| 680 | 727 |
| 681 const DictionaryValue* ext = GetExtensionPref(extension_id); | 728 const DictionaryValue* ext = GetExtensionPref(extension_id); |
| 682 if (!ext || !ext->GetBoolean(kPrefGrantedPermissionsAll, full_access)) | 729 if (!ext) |
| 683 return false; | 730 return NULL; |
| 684 | 731 |
| 685 ReadExtensionPrefStringSet( | 732 // Retrieve the API permissions. |
| 686 extension_id, kPrefGrantedPermissionsAPI, api_permissions); | 733 ExtensionAPIPermissionSet apis; |
| 687 | 734 const ListValue* api_values = NULL; |
| 688 std::set<std::string> host_permissions; | 735 if (ReadExtensionPrefList(extension_id, kPrefGrantedAPIs, &api_values)) { |
| 689 ReadExtensionPrefStringSet( | 736 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); |
| 690 extension_id, kPrefGrantedPermissionsHost, &host_permissions); | 737 for (size_t i = 0; i < api_values->GetSize(); ++i) { |
| 691 bool allow_file_access = AllowFileAccess(extension_id); | 738 std::string permission_name; |
| 692 | 739 if (api_values->GetString(i, &permission_name)) { |
| 693 // The granted host permissions contain hosts from the manifest's | 740 ExtensionAPIPermission *permission = info->GetByName(permission_name); |
| 694 // "permissions" array and from the content script "matches" arrays, | 741 if (permission) |
| 695 // so the URLPattern needs to accept valid schemes from both types. | 742 apis.insert(permission->id()); |
| 696 for (std::set<std::string>::iterator i = host_permissions.begin(); | |
| 697 i != host_permissions.end(); ++i) { | |
| 698 URLPattern pattern( | |
| 699 Extension::kValidHostPermissionSchemes | | |
| 700 UserScript::kValidUserScriptSchemes); | |
| 701 | |
| 702 // Parse without strict checks, so that new strict checks do not | |
| 703 // fail on a pattern in an installed extension. | |
| 704 if (URLPattern::PARSE_SUCCESS != pattern.Parse( | |
| 705 *i, URLPattern::PARSE_LENIENT)) { | |
| 706 NOTREACHED(); // Corrupt prefs? Hand editing? | |
| 707 } else { | |
| 708 if (!allow_file_access && pattern.MatchesScheme(chrome::kFileScheme)) { | |
| 709 pattern.set_valid_schemes( | |
| 710 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); | |
| 711 } | 743 } |
| 712 host_extent->AddPattern(pattern); | |
| 713 } | 744 } |
| 714 } | 745 } |
| 715 | 746 |
| 716 return true; | 747 // Retrieve the explicit host permissions. |
| 748 URLPatternSet explicit_hosts; |
| 749 ReadExtensionPrefURLPatternSet( |
| 750 extension_id, kPrefGrantedExplicitHosts, |
| 751 &explicit_hosts, Extension::kValidHostPermissionSchemes); |
| 752 |
| 753 // Retrieve the scriptable host permissions. |
| 754 URLPatternSet scriptable_hosts; |
| 755 ReadExtensionPrefURLPatternSet( |
| 756 extension_id, kPrefGrantedScriptableHosts, |
| 757 &scriptable_hosts, UserScript::kValidUserScriptSchemes); |
| 758 |
| 759 return new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts); |
| 717 } | 760 } |
| 718 | 761 |
| 719 void ExtensionPrefs::AddGrantedPermissions( | 762 void ExtensionPrefs::AddGrantedPermissions( |
| 720 const std::string& extension_id, | 763 const std::string& extension_id, |
| 721 const bool full_access, | 764 const ExtensionPermissionSet* permissions) { |
| 722 const std::set<std::string>& api_permissions, | |
| 723 const URLPatternSet& host_extent) { | |
| 724 CHECK(Extension::IdIsValid(extension_id)); | 765 CHECK(Extension::IdIsValid(extension_id)); |
| 725 | 766 |
| 726 UpdateExtensionPref(extension_id, kPrefGrantedPermissionsAll, | 767 scoped_ptr<ExtensionPermissionSet> granted_permissions( |
| 727 Value::CreateBooleanValue(full_access)); | 768 GetGrantedPermissions(extension_id)); |
| 728 | 769 |
| 729 if (!api_permissions.empty()) { | 770 // The new granted permissions are the union of the already granted |
| 730 AddToExtensionPrefStringSet( | 771 // permissions and the newly granted permissions. |
| 731 extension_id, kPrefGrantedPermissionsAPI, api_permissions); | 772 scoped_ptr<ExtensionPermissionSet> new_perms( |
| 773 ExtensionPermissionSet::CreateUnion( |
| 774 permissions, granted_permissions.get())); |
| 775 |
| 776 // Set the API permissions. |
| 777 ListValue* api_values = new ListValue(); |
| 778 ExtensionAPIPermissionSet apis = new_perms->apis(); |
| 779 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); |
| 780 for (ExtensionAPIPermissionSet::const_iterator i = apis.begin(); |
| 781 i != apis.end(); ++i) { |
| 782 ExtensionAPIPermission* perm = info->GetByID(*i); |
| 783 if (perm) |
| 784 api_values->Append(Value::CreateStringValue(perm->name())); |
| 785 } |
| 786 UpdateExtensionPref(extension_id, kPrefGrantedAPIs, api_values); |
| 787 |
| 788 // Set the explicit host permissions. |
| 789 if (!new_perms->explicit_hosts().is_empty()) { |
| 790 SetExtensionPrefURLPatternSet(extension_id, |
| 791 kPrefGrantedExplicitHosts, |
| 792 new_perms->explicit_hosts()); |
| 732 } | 793 } |
| 733 | 794 |
| 734 if (!host_extent.is_empty()) { | 795 // Set the scriptable host permissions. |
| 735 std::set<std::string> host_permissions; | 796 if (!new_perms->scriptable_hosts().is_empty()) { |
| 736 ExtentToStringSet(host_extent, &host_permissions); | 797 SetExtensionPrefURLPatternSet(extension_id, |
| 737 | 798 kPrefGrantedScriptableHosts, |
| 738 AddToExtensionPrefStringSet( | 799 new_perms->scriptable_hosts()); |
| 739 extension_id, kPrefGrantedPermissionsHost, host_permissions); | |
| 740 } | 800 } |
| 741 } | 801 } |
| 742 | 802 |
| 743 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) { | 803 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) { |
| 744 return ReadExtensionPrefBoolean(extension_id, kPrefIncognitoEnabled); | 804 return ReadExtensionPrefBoolean(extension_id, kPrefIncognitoEnabled); |
| 745 } | 805 } |
| 746 | 806 |
| 747 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id, | 807 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id, |
| 748 bool enabled) { | 808 bool enabled) { |
| 749 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled, | 809 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled, |
| (...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1425 // Create empty preferences dictionary for each extension (these dictionaries | 1485 // Create empty preferences dictionary for each extension (these dictionaries |
| 1426 // are pruned when persisting the preferences to disk). | 1486 // are pruned when persisting the preferences to disk). |
| 1427 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); | 1487 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); |
| 1428 ext_id != extension_ids.end(); ++ext_id) { | 1488 ext_id != extension_ids.end(); ++ext_id) { |
| 1429 ScopedExtensionPrefUpdate update(prefs_, *ext_id); | 1489 ScopedExtensionPrefUpdate update(prefs_, *ext_id); |
| 1430 // This creates an empty dictionary if none is stored. | 1490 // This creates an empty dictionary if none is stored. |
| 1431 update.Get(); | 1491 update.Get(); |
| 1432 } | 1492 } |
| 1433 | 1493 |
| 1434 FixMissingPrefs(extension_ids); | 1494 FixMissingPrefs(extension_ids); |
| 1495 MigratePermissions(extension_ids); |
| 1496 |
| 1435 // Store extension controlled preference values in the | 1497 // Store extension controlled preference values in the |
| 1436 // |extension_pref_value_map_|, which then informs the subscribers | 1498 // |extension_pref_value_map_|, which then informs the subscribers |
| 1437 // (ExtensionPrefStores) about the winning values. | 1499 // (ExtensionPrefStores) about the winning values. |
| 1438 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); | 1500 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); |
| 1439 ext_id != extension_ids.end(); ++ext_id) { | 1501 ext_id != extension_ids.end(); ++ext_id) { |
| 1440 extension_pref_value_map_->RegisterExtension( | 1502 extension_pref_value_map_->RegisterExtension( |
| 1441 *ext_id, | 1503 *ext_id, |
| 1442 GetInstallTime(*ext_id), | 1504 GetInstallTime(*ext_id), |
| 1443 GetExtensionState(*ext_id) == Extension::ENABLED); | 1505 GetExtensionState(*ext_id) == Extension::ENABLED); |
| 1444 content_settings_store_->RegisterExtension( | 1506 content_settings_store_->RegisterExtension( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 &content_settings)) { | 1544 &content_settings)) { |
| 1483 content_settings_store_->SetExtensionContentSettingsFromList( | 1545 content_settings_store_->SetExtensionContentSettingsFromList( |
| 1484 *ext_id, content_settings, | 1546 *ext_id, content_settings, |
| 1485 kExtensionPrefsScopeIncognitoPersistent); | 1547 kExtensionPrefsScopeIncognitoPersistent); |
| 1486 } | 1548 } |
| 1487 } | 1549 } |
| 1488 | 1550 |
| 1489 extension_pref_value_map_->NotifyInitializationCompleted(); | 1551 extension_pref_value_map_->NotifyInitializationCompleted(); |
| 1490 } | 1552 } |
| 1491 | 1553 |
| 1492 | |
| 1493 void ExtensionPrefs::SetExtensionControlledPref( | 1554 void ExtensionPrefs::SetExtensionControlledPref( |
| 1494 const std::string& extension_id, | 1555 const std::string& extension_id, |
| 1495 const std::string& pref_key, | 1556 const std::string& pref_key, |
| 1496 ExtensionPrefsScope scope, | 1557 ExtensionPrefsScope scope, |
| 1497 Value* value) { | 1558 Value* value) { |
| 1498 #ifndef NDEBUG | 1559 #ifndef NDEBUG |
| 1499 const PrefService::Preference* pref = | 1560 const PrefService::Preference* pref = |
| 1500 pref_service()->FindPreference(pref_key.c_str()); | 1561 pref_service()->FindPreference(pref_key.c_str()); |
| 1501 DCHECK(pref) << "Extension controlled preference key " << pref_key | 1562 DCHECK(pref) << "Extension controlled preference key " << pref_key |
| 1502 << " not registered."; | 1563 << " not registered."; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1599 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1660 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
| 1600 PrefService::UNSYNCABLE_PREF); | 1661 PrefService::UNSYNCABLE_PREF); |
| 1601 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1662 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
| 1602 PrefService::UNSYNCABLE_PREF); | 1663 PrefService::UNSYNCABLE_PREF); |
| 1603 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1664 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
| 1604 PrefService::UNSYNCABLE_PREF); | 1665 PrefService::UNSYNCABLE_PREF); |
| 1605 prefs->RegisterStringPref(kWebStoreLogin, | 1666 prefs->RegisterStringPref(kWebStoreLogin, |
| 1606 std::string() /* default_value */, | 1667 std::string() /* default_value */, |
| 1607 PrefService::UNSYNCABLE_PREF); | 1668 PrefService::UNSYNCABLE_PREF); |
| 1608 } | 1669 } |
| OLD | NEW |