| 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 918 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 929 // The new granted permissions are the union of the already granted | 929 // The new granted permissions are the union of the already granted |
| 930 // permissions and the newly granted permissions. | 930 // permissions and the newly granted permissions. |
| 931 scoped_refptr<PermissionSet> new_perms( | 931 scoped_refptr<PermissionSet> new_perms( |
| 932 PermissionSet::CreateUnion( | 932 PermissionSet::CreateUnion( |
| 933 permissions, granted_permissions.get())); | 933 permissions, granted_permissions.get())); |
| 934 | 934 |
| 935 SetExtensionPrefPermissionSet( | 935 SetExtensionPrefPermissionSet( |
| 936 extension_id, kPrefGrantedPermissions, new_perms.get()); | 936 extension_id, kPrefGrantedPermissions, new_perms.get()); |
| 937 } | 937 } |
| 938 | 938 |
| 939 void ExtensionPrefs::RemoveGrantedPermissions( |
| 940 const std::string& extension_id, |
| 941 const PermissionSet* permissions) { |
| 942 CHECK(Extension::IdIsValid(extension_id)); |
| 943 |
| 944 scoped_refptr<PermissionSet> granted_permissions( |
| 945 GetGrantedPermissions(extension_id)); |
| 946 |
| 947 // The new granted permissions are the difference of the already granted |
| 948 // permissions and the newly ungranted permissions. |
| 949 scoped_refptr<PermissionSet> new_perms( |
| 950 PermissionSet::CreateDifference( |
| 951 granted_permissions.get(), permissions)); |
| 952 |
| 953 SetExtensionPrefPermissionSet( |
| 954 extension_id, kPrefGrantedPermissions, new_perms.get()); |
| 955 } |
| 956 |
| 939 PermissionSet* ExtensionPrefs::GetActivePermissions( | 957 PermissionSet* ExtensionPrefs::GetActivePermissions( |
| 940 const std::string& extension_id) { | 958 const std::string& extension_id) { |
| 941 CHECK(Extension::IdIsValid(extension_id)); | 959 CHECK(Extension::IdIsValid(extension_id)); |
| 942 return ReadExtensionPrefPermissionSet(extension_id, kPrefActivePermissions); | 960 return ReadExtensionPrefPermissionSet(extension_id, kPrefActivePermissions); |
| 943 } | 961 } |
| 944 | 962 |
| 945 void ExtensionPrefs::SetActivePermissions( | 963 void ExtensionPrefs::SetActivePermissions( |
| 946 const std::string& extension_id, | 964 const std::string& extension_id, |
| 947 const PermissionSet* permissions) { | 965 const PermissionSet* permissions) { |
| 948 SetExtensionPrefPermissionSet( | 966 SetExtensionPrefPermissionSet( |
| (...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1890 PrefService::UNSYNCABLE_PREF); | 1908 PrefService::UNSYNCABLE_PREF); |
| 1891 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, | 1909 prefs->RegisterInt64Pref(prefs::kLastExtensionsUpdateCheck, |
| 1892 0, // default value | 1910 0, // default value |
| 1893 PrefService::UNSYNCABLE_PREF); | 1911 PrefService::UNSYNCABLE_PREF); |
| 1894 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, | 1912 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, |
| 1895 0, // default value | 1913 0, // default value |
| 1896 PrefService::UNSYNCABLE_PREF); | 1914 PrefService::UNSYNCABLE_PREF); |
| 1897 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, | 1915 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, |
| 1898 PrefService::UNSYNCABLE_PREF); | 1916 PrefService::UNSYNCABLE_PREF); |
| 1899 } | 1917 } |
| OLD | NEW |