| 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 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 927 // The new granted permissions are the union of the already granted | 927 // The new granted permissions are the union of the already granted |
| 928 // permissions and the newly granted permissions. | 928 // permissions and the newly granted permissions. |
| 929 scoped_refptr<ExtensionPermissionSet> new_perms( | 929 scoped_refptr<ExtensionPermissionSet> new_perms( |
| 930 ExtensionPermissionSet::CreateUnion( | 930 ExtensionPermissionSet::CreateUnion( |
| 931 permissions, granted_permissions.get())); | 931 permissions, granted_permissions.get())); |
| 932 | 932 |
| 933 SetExtensionPrefPermissionSet( | 933 SetExtensionPrefPermissionSet( |
| 934 extension_id, kPrefGrantedPermissions, new_perms.get()); | 934 extension_id, kPrefGrantedPermissions, new_perms.get()); |
| 935 } | 935 } |
| 936 | 936 |
| 937 void ExtensionPrefs::RemoveGrantedPermissions( |
| 938 const std::string& extension_id, |
| 939 const ExtensionPermissionSet* permissions) { |
| 940 CHECK(Extension::IdIsValid(extension_id)); |
| 941 |
| 942 scoped_refptr<ExtensionPermissionSet> granted_permissions( |
| 943 GetGrantedPermissions(extension_id)); |
| 944 |
| 945 // The new granted permissions are the difference of the already granted |
| 946 // permissions and the newly ungranted permissions. |
| 947 scoped_refptr<ExtensionPermissionSet> new_perms( |
| 948 ExtensionPermissionSet::CreateDifference( |
| 949 granted_permissions.get(), permissions)); |
| 950 |
| 951 SetExtensionPrefPermissionSet( |
| 952 extension_id, kPrefGrantedPermissions, new_perms.get()); |
| 953 } |
| 954 |
| 937 ExtensionPermissionSet* ExtensionPrefs::GetActivePermissions( | 955 ExtensionPermissionSet* ExtensionPrefs::GetActivePermissions( |
| 938 const std::string& extension_id) { | 956 const std::string& extension_id) { |
| 939 CHECK(Extension::IdIsValid(extension_id)); | 957 CHECK(Extension::IdIsValid(extension_id)); |
| 940 return ReadExtensionPrefPermissionSet(extension_id, kPrefActivePermissions); | 958 return ReadExtensionPrefPermissionSet(extension_id, kPrefActivePermissions); |
| 941 } | 959 } |
| 942 | 960 |
| 943 void ExtensionPrefs::SetActivePermissions( | 961 void ExtensionPrefs::SetActivePermissions( |
| 944 const std::string& extension_id, | 962 const std::string& extension_id, |
| 945 const ExtensionPermissionSet* permissions) { | 963 const ExtensionPermissionSet* permissions) { |
| 946 SetExtensionPrefPermissionSet( | 964 SetExtensionPrefPermissionSet( |
| (...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 PrefService::UNSYNCABLE_PREF); | 1959 PrefService::UNSYNCABLE_PREF); |
| 1942 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, | 1960 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, |
| 1943 0, // default value | 1961 0, // default value |
| 1944 PrefService::UNSYNCABLE_PREF); | 1962 PrefService::UNSYNCABLE_PREF); |
| 1945 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, | 1963 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, |
| 1946 0, // default value | 1964 0, // default value |
| 1947 PrefService::UNSYNCABLE_PREF); | 1965 PrefService::UNSYNCABLE_PREF); |
| 1948 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, | 1966 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, |
| 1949 PrefService::UNSYNCABLE_PREF); | 1967 PrefService::UNSYNCABLE_PREF); |
| 1950 } | 1968 } |
| OLD | NEW |