| OLD | NEW |
| 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 907 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 918 // The new granted permissions are the union of the already granted | 918 // The new granted permissions are the union of the already granted |
| 919 // permissions and the newly granted permissions. | 919 // permissions and the newly granted permissions. |
| 920 scoped_refptr<ExtensionPermissionSet> new_perms( | 920 scoped_refptr<ExtensionPermissionSet> new_perms( |
| 921 ExtensionPermissionSet::CreateUnion( | 921 ExtensionPermissionSet::CreateUnion( |
| 922 permissions, granted_permissions.get())); | 922 permissions, granted_permissions.get())); |
| 923 | 923 |
| 924 SetExtensionPrefPermissionSet( | 924 SetExtensionPrefPermissionSet( |
| 925 extension_id, kPrefGrantedPermissions, new_perms.get()); | 925 extension_id, kPrefGrantedPermissions, new_perms.get()); |
| 926 } | 926 } |
| 927 | 927 |
| 928 void ExtensionPrefs::RemoveGrantedPermissions( |
| 929 const std::string& extension_id, |
| 930 const ExtensionPermissionSet* permissions) { |
| 931 CHECK(Extension::IdIsValid(extension_id)); |
| 932 |
| 933 scoped_refptr<ExtensionPermissionSet> granted_permissions( |
| 934 GetGrantedPermissions(extension_id)); |
| 935 |
| 936 // The new granted permissions are the difference of the already granted |
| 937 // permissions and the newly ungranted permissions. |
| 938 scoped_refptr<ExtensionPermissionSet> new_perms( |
| 939 ExtensionPermissionSet::CreateDifference( |
| 940 granted_permissions.get(), permissions)); |
| 941 |
| 942 SetExtensionPrefPermissionSet( |
| 943 extension_id, kPrefGrantedPermissions, new_perms.get()); |
| 944 } |
| 945 |
| 928 ExtensionPermissionSet* ExtensionPrefs::GetActivePermissions( | 946 ExtensionPermissionSet* ExtensionPrefs::GetActivePermissions( |
| 929 const std::string& extension_id) { | 947 const std::string& extension_id) { |
| 930 CHECK(Extension::IdIsValid(extension_id)); | 948 CHECK(Extension::IdIsValid(extension_id)); |
| 931 return ReadExtensionPrefPermissionSet(extension_id, kPrefActivePermissions); | 949 return ReadExtensionPrefPermissionSet(extension_id, kPrefActivePermissions); |
| 932 } | 950 } |
| 933 | 951 |
| 934 void ExtensionPrefs::SetActivePermissions( | 952 void ExtensionPrefs::SetActivePermissions( |
| 935 const std::string& extension_id, | 953 const std::string& extension_id, |
| 936 const ExtensionPermissionSet* permissions) { | 954 const ExtensionPermissionSet* permissions) { |
| 937 SetExtensionPrefPermissionSet( | 955 SetExtensionPrefPermissionSet( |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 PrefService::UNSYNCABLE_PREF); | 1897 PrefService::UNSYNCABLE_PREF); |
| 1880 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, | 1898 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, |
| 1881 0, // default value | 1899 0, // default value |
| 1882 PrefService::UNSYNCABLE_PREF); | 1900 PrefService::UNSYNCABLE_PREF); |
| 1883 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, | 1901 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, |
| 1884 0, // default value | 1902 0, // default value |
| 1885 PrefService::UNSYNCABLE_PREF); | 1903 PrefService::UNSYNCABLE_PREF); |
| 1886 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, | 1904 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, |
| 1887 PrefService::UNSYNCABLE_PREF); | 1905 PrefService::UNSYNCABLE_PREF); |
| 1888 } | 1906 } |
| OLD | NEW |