| 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 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 const ListValue** out_value) { | 426 const ListValue** out_value) { |
| 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 *out_value = out; | 431 *out_value = out; |
| 436 | 432 |
| 437 return out_value != NULL; | 433 return out_value != NULL; |
| 438 } | 434 } |
| 439 | 435 |
| 440 bool ExtensionPrefs::ReadExtensionPrefStringSet( | 436 bool ExtensionPrefs::ReadExtensionPrefURLPatternSet( |
| 441 const std::string& extension_id, | 437 const std::string& extension_id, |
| 442 const std::string& pref_key, | 438 const std::string& pref_key, |
| 443 std::set<std::string>* result) { | 439 URLPatternSet* result, |
| 440 int valid_schemes) { |
| 444 const ListValue* value = NULL; | 441 const ListValue* value = NULL; |
| 445 if (!ReadExtensionPrefList(extension_id, pref_key, &value)) | 442 if (!ReadExtensionPrefList(extension_id, pref_key, &value)) |
| 446 return false; | 443 return false; |
| 447 | 444 |
| 448 result->clear(); | 445 result->ClearPatterns(); |
| 446 bool allow_file_access = AllowFileAccess(extension_id); |
| 449 | 447 |
| 450 for (size_t i = 0; i < value->GetSize(); ++i) { | 448 for (size_t i = 0; i < value->GetSize(); ++i) { |
| 451 std::string item; | 449 std::string item; |
| 452 if (!value->GetString(i, &item)) | 450 if (!value->GetString(i, &item)) |
| 453 return false; | 451 return false; |
| 454 result->insert(item); | 452 URLPattern pattern(valid_schemes); |
| 453 if (pattern.Parse(item, URLPattern::PARSE_LENIENT) != |
| 454 URLPattern::PARSE_SUCCESS) { |
| 455 NOTREACHED(); |
| 456 return false; |
| 457 } |
| 458 if (!allow_file_access && pattern.MatchesScheme(chrome::kFileScheme)) { |
| 459 pattern.set_valid_schemes( |
| 460 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); |
| 461 } |
| 462 result->AddPattern(pattern); |
| 455 } | 463 } |
| 456 | 464 |
| 457 return true; | 465 return true; |
| 458 } | 466 } |
| 459 | 467 |
| 460 void ExtensionPrefs::AddToExtensionPrefStringSet( | 468 void ExtensionPrefs::SetExtensionPrefURLPatternSet( |
| 461 const std::string& extension_id, | 469 const std::string& extension_id, |
| 462 const std::string& pref_key, | 470 const std::string& pref_key, |
| 463 const std::set<std::string>& added_value) { | 471 const URLPatternSet& new_value) { |
| 464 std::set<std::string> old_value; | |
| 465 std::set<std::string> new_value; | |
| 466 ReadExtensionPrefStringSet(extension_id, pref_key, &old_value); | |
| 467 | |
| 468 std::set_union(old_value.begin(), old_value.end(), | |
| 469 added_value.begin(), added_value.end(), | |
| 470 std::inserter(new_value, new_value.begin())); | |
| 471 | |
| 472 ListValue* value = new ListValue(); | 472 ListValue* value = new ListValue(); |
| 473 for (std::set<std::string>::const_iterator iter = new_value.begin(); | 473 for (URLPatternList::const_iterator i = new_value.patterns().begin(); |
| 474 iter != new_value.end(); ++iter) | 474 i != new_value.patterns().end(); ++i) |
| 475 value->Append(Value::CreateStringValue(*iter)); | 475 value->AppendIfNotPresent(Value::CreateStringValue(i->GetAsString())); |
| 476 | 476 |
| 477 UpdateExtensionPref(extension_id, pref_key, value); | 477 UpdateExtensionPref(extension_id, pref_key, value); |
| 478 } | 478 } |
| 479 | 479 |
| 480 void ExtensionPrefs::SavePrefs() { | 480 void ExtensionPrefs::SavePrefs() { |
| 481 prefs_->ScheduleSavePersistentPrefs(); | 481 prefs_->ScheduleSavePersistentPrefs(); |
| 482 } | 482 } |
| 483 | 483 |
| 484 // static | 484 // static |
| 485 bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) { | 485 bool ExtensionPrefs::IsBlacklistBitSet(DictionaryValue* ext) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 return result; | 663 return result; |
| 664 return false; | 664 return false; |
| 665 } | 665 } |
| 666 | 666 |
| 667 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, | 667 void ExtensionPrefs::SetActiveBit(const std::string& extension_id, |
| 668 bool active) { | 668 bool active) { |
| 669 UpdateExtensionPref(extension_id, kActiveBit, | 669 UpdateExtensionPref(extension_id, kActiveBit, |
| 670 Value::CreateBooleanValue(active)); | 670 Value::CreateBooleanValue(active)); |
| 671 } | 671 } |
| 672 | 672 |
| 673 bool ExtensionPrefs::GetGrantedPermissions( | 673 void ExtensionPrefs::MigratePermissions(const ExtensionIdSet& extension_ids) { |
| 674 const std::string& extension_id, | 674 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); |
| 675 bool* full_access, | 675 for (ExtensionIdSet::const_iterator ext_id = extension_ids.begin(); |
| 676 std::set<std::string>* api_permissions, | 676 ext_id != extension_ids.end(); ++ext_id) { |
| 677 URLPatternSet* host_extent) { | 677 |
| 678 // An extension's granted permissions need to be migrated if the |
| 679 // full_access bit is present. This bit was always present in the previous |
| 680 // scheme and is never present now. |
| 681 bool full_access; |
| 682 const DictionaryValue* ext = GetExtensionPref(*ext_id); |
| 683 if (!ext || !ext->GetBoolean(kPrefOldGrantedFullAccess, &full_access)) |
| 684 continue; |
| 685 |
| 686 // Remove the full access bit (empty list will get trimmed). |
| 687 UpdateExtensionPref( |
| 688 *ext_id, kPrefOldGrantedFullAccess, new ListValue()); |
| 689 |
| 690 // Add the plugin permission if the full access bit was set. |
| 691 if (full_access) { |
| 692 ListValue* apis = NULL; |
| 693 ListValue* new_apis = NULL; |
| 694 |
| 695 if (ext->GetList(kPrefGrantedAPIs, &apis)) |
| 696 new_apis = apis->DeepCopy(); |
| 697 else |
| 698 new_apis = new ListValue(); |
| 699 |
| 700 std::string plugin_name = info->GetByID( |
| 701 ExtensionAPIPermission::kPlugin)->name(); |
| 702 new_apis->Append(Value::CreateStringValue(plugin_name)); |
| 703 UpdateExtensionPref(*ext_id, kPrefGrantedAPIs, new_apis); |
| 704 } |
| 705 |
| 706 // The granted permissions originally only held the effective hosts, |
| 707 // which are a combination of host and user script host permissions. |
| 708 // We now maintain these lists separately. For migration purposes, it |
| 709 // does not matter how we treat the old effective hosts as long as the |
| 710 // new effective hosts will be the same, so we move them to explicit |
| 711 // host permissions. |
| 712 ListValue* hosts; |
| 713 if (ext->GetList(kPrefOldGrantedHosts, &hosts)) { |
| 714 UpdateExtensionPref( |
| 715 *ext_id, kPrefGrantedExplicitHosts, hosts->DeepCopy()); |
| 716 |
| 717 // We can get rid of the old one by setting it to an empty list. |
| 718 UpdateExtensionPref(*ext_id, kPrefOldGrantedHosts, new ListValue()); |
| 719 } |
| 720 } |
| 721 SavePrefs(); |
| 722 } |
| 723 |
| 724 ExtensionPermissionSet* ExtensionPrefs::GetGrantedPermissions( |
| 725 const std::string& extension_id) { |
| 678 CHECK(Extension::IdIsValid(extension_id)); | 726 CHECK(Extension::IdIsValid(extension_id)); |
| 679 | 727 |
| 680 const DictionaryValue* ext = GetExtensionPref(extension_id); | 728 const DictionaryValue* ext = GetExtensionPref(extension_id); |
| 681 if (!ext || !ext->GetBoolean(kPrefGrantedPermissionsAll, full_access)) | 729 if (!ext) |
| 682 return false; | 730 return NULL; |
| 683 | 731 |
| 684 ReadExtensionPrefStringSet( | 732 // Retrieve the API permissions. |
| 685 extension_id, kPrefGrantedPermissionsAPI, api_permissions); | 733 ExtensionAPIPermissionSet apis; |
| 686 | 734 const ListValue* api_values = NULL; |
| 687 std::set<std::string> host_permissions; | 735 if (ReadExtensionPrefList(extension_id, kPrefGrantedAPIs, &api_values)) { |
| 688 ReadExtensionPrefStringSet( | 736 ExtensionPermissionsInfo* info = ExtensionPermissionsInfo::GetInstance(); |
| 689 extension_id, kPrefGrantedPermissionsHost, &host_permissions); | 737 for (size_t i = 0; i < api_values->GetSize(); ++i) { |
| 690 bool allow_file_access = AllowFileAccess(extension_id); | 738 std::string permission_name; |
| 691 | 739 if (api_values->GetString(i, &permission_name)) { |
| 692 // The granted host permissions contain hosts from the manifest's | 740 ExtensionAPIPermission *permission = info->GetByName(permission_name); |
| 693 // "permissions" array and from the content script "matches" arrays, | 741 if (permission) |
| 694 // so the URLPattern needs to accept valid schemes from both types. | 742 apis.insert(permission->id()); |
| 695 for (std::set<std::string>::iterator i = host_permissions.begin(); | |
| 696 i != host_permissions.end(); ++i) { | |
| 697 URLPattern pattern( | |
| 698 Extension::kValidHostPermissionSchemes | | |
| 699 UserScript::kValidUserScriptSchemes); | |
| 700 | |
| 701 // Parse without strict checks, so that new strict checks do not | |
| 702 // fail on a pattern in an installed extension. | |
| 703 if (URLPattern::PARSE_SUCCESS != pattern.Parse( | |
| 704 *i, URLPattern::PARSE_LENIENT)) { | |
| 705 NOTREACHED(); // Corrupt prefs? Hand editing? | |
| 706 } else { | |
| 707 if (!allow_file_access && pattern.MatchesScheme(chrome::kFileScheme)) { | |
| 708 pattern.set_valid_schemes( | |
| 709 pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); | |
| 710 } | 743 } |
| 711 host_extent->AddPattern(pattern); | |
| 712 } | 744 } |
| 713 } | 745 } |
| 714 | 746 |
| 715 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); |
| 716 } | 760 } |
| 717 | 761 |
| 718 void ExtensionPrefs::AddGrantedPermissions( | 762 void ExtensionPrefs::AddGrantedPermissions( |
| 719 const std::string& extension_id, | 763 const std::string& extension_id, |
| 720 const bool full_access, | 764 const ExtensionPermissionSet* permissions) { |
| 721 const std::set<std::string>& api_permissions, | |
| 722 const URLPatternSet& host_extent) { | |
| 723 CHECK(Extension::IdIsValid(extension_id)); | 765 CHECK(Extension::IdIsValid(extension_id)); |
| 724 | 766 |
| 725 UpdateExtensionPref(extension_id, kPrefGrantedPermissionsAll, | 767 scoped_ptr<ExtensionPermissionSet> granted_permissions( |
| 726 Value::CreateBooleanValue(full_access)); | 768 GetGrantedPermissions(extension_id)); |
| 727 | 769 |
| 728 if (!api_permissions.empty()) { | 770 // The new granted permissions are the union of the already granted |
| 729 AddToExtensionPrefStringSet( | 771 // permissions and the newly granted permissions. |
| 730 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()); |
| 731 } | 793 } |
| 732 | 794 |
| 733 if (!host_extent.is_empty()) { | 795 // Set the scriptable host permissions. |
| 734 std::set<std::string> host_permissions; | 796 if (!new_perms->scriptable_hosts().is_empty()) { |
| 735 ExtentToStringSet(host_extent, &host_permissions); | 797 SetExtensionPrefURLPatternSet(extension_id, |
| 736 | 798 kPrefGrantedScriptableHosts, |
| 737 AddToExtensionPrefStringSet( | 799 new_perms->scriptable_hosts()); |
| 738 extension_id, kPrefGrantedPermissionsHost, host_permissions); | |
| 739 } | 800 } |
| 740 } | 801 } |
| 741 | 802 |
| 742 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) { | 803 bool ExtensionPrefs::IsIncognitoEnabled(const std::string& extension_id) { |
| 743 return ReadExtensionPrefBoolean(extension_id, kPrefIncognitoEnabled); | 804 return ReadExtensionPrefBoolean(extension_id, kPrefIncognitoEnabled); |
| 744 } | 805 } |
| 745 | 806 |
| 746 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id, | 807 void ExtensionPrefs::SetIsIncognitoEnabled(const std::string& extension_id, |
| 747 bool enabled) { | 808 bool enabled) { |
| 748 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled, | 809 UpdateExtensionPref(extension_id, kPrefIncognitoEnabled, |
| (...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1421 // Create empty preferences dictionary for each extension (these dictionaries | 1482 // Create empty preferences dictionary for each extension (these dictionaries |
| 1422 // are pruned when persisting the preferences to disk). | 1483 // are pruned when persisting the preferences to disk). |
| 1423 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); | 1484 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); |
| 1424 ext_id != extension_ids.end(); ++ext_id) { | 1485 ext_id != extension_ids.end(); ++ext_id) { |
| 1425 ScopedExtensionPrefUpdate update(prefs_, *ext_id); | 1486 ScopedExtensionPrefUpdate update(prefs_, *ext_id); |
| 1426 // This creates an empty dictionary if none is stored. | 1487 // This creates an empty dictionary if none is stored. |
| 1427 update.Get(); | 1488 update.Get(); |
| 1428 } | 1489 } |
| 1429 | 1490 |
| 1430 FixMissingPrefs(extension_ids); | 1491 FixMissingPrefs(extension_ids); |
| 1492 MigratePermissions(extension_ids); |
| 1493 |
| 1431 // Store extension controlled preference values in the | 1494 // Store extension controlled preference values in the |
| 1432 // |extension_pref_value_map_|, which then informs the subscribers | 1495 // |extension_pref_value_map_|, which then informs the subscribers |
| 1433 // (ExtensionPrefStores) about the winning values. | 1496 // (ExtensionPrefStores) about the winning values. |
| 1434 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); | 1497 for (ExtensionIdSet::iterator ext_id = extension_ids.begin(); |
| 1435 ext_id != extension_ids.end(); ++ext_id) { | 1498 ext_id != extension_ids.end(); ++ext_id) { |
| 1436 extension_pref_value_map_->RegisterExtension( | 1499 extension_pref_value_map_->RegisterExtension( |
| 1437 *ext_id, | 1500 *ext_id, |
| 1438 GetInstallTime(*ext_id), | 1501 GetInstallTime(*ext_id), |
| 1439 GetExtensionState(*ext_id) == Extension::ENABLED); | 1502 GetExtensionState(*ext_id) == Extension::ENABLED); |
| 1440 content_settings_store_->RegisterExtension( | 1503 content_settings_store_->RegisterExtension( |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1478 &content_settings)) { | 1541 &content_settings)) { |
| 1479 content_settings_store_->SetExtensionContentSettingsFromList( | 1542 content_settings_store_->SetExtensionContentSettingsFromList( |
| 1480 *ext_id, content_settings, | 1543 *ext_id, content_settings, |
| 1481 kExtensionPrefsScopeIncognitoPersistent); | 1544 kExtensionPrefsScopeIncognitoPersistent); |
| 1482 } | 1545 } |
| 1483 } | 1546 } |
| 1484 | 1547 |
| 1485 extension_pref_value_map_->NotifyInitializationCompleted(); | 1548 extension_pref_value_map_->NotifyInitializationCompleted(); |
| 1486 } | 1549 } |
| 1487 | 1550 |
| 1488 | |
| 1489 void ExtensionPrefs::SetExtensionControlledPref( | 1551 void ExtensionPrefs::SetExtensionControlledPref( |
| 1490 const std::string& extension_id, | 1552 const std::string& extension_id, |
| 1491 const std::string& pref_key, | 1553 const std::string& pref_key, |
| 1492 ExtensionPrefsScope scope, | 1554 ExtensionPrefsScope scope, |
| 1493 Value* value) { | 1555 Value* value) { |
| 1494 #ifndef NDEBUG | 1556 #ifndef NDEBUG |
| 1495 const PrefService::Preference* pref = | 1557 const PrefService::Preference* pref = |
| 1496 pref_service()->FindPreference(pref_key.c_str()); | 1558 pref_service()->FindPreference(pref_key.c_str()); |
| 1497 DCHECK(pref) << "Extension controlled preference key " << pref_key | 1559 DCHECK(pref) << "Extension controlled preference key " << pref_key |
| 1498 << " not registered."; | 1560 << " not registered."; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1595 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, | 1657 prefs->RegisterListPref(prefs::kExtensionInstallAllowList, |
| 1596 PrefService::UNSYNCABLE_PREF); | 1658 PrefService::UNSYNCABLE_PREF); |
| 1597 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, | 1659 prefs->RegisterListPref(prefs::kExtensionInstallDenyList, |
| 1598 PrefService::UNSYNCABLE_PREF); | 1660 PrefService::UNSYNCABLE_PREF); |
| 1599 prefs->RegisterListPref(prefs::kExtensionInstallForceList, | 1661 prefs->RegisterListPref(prefs::kExtensionInstallForceList, |
| 1600 PrefService::UNSYNCABLE_PREF); | 1662 PrefService::UNSYNCABLE_PREF); |
| 1601 prefs->RegisterStringPref(kWebStoreLogin, | 1663 prefs->RegisterStringPref(kWebStoreLogin, |
| 1602 std::string() /* default_value */, | 1664 std::string() /* default_value */, |
| 1603 PrefService::UNSYNCABLE_PREF); | 1665 PrefService::UNSYNCABLE_PREF); |
| 1604 } | 1666 } |
| OLD | NEW |