Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: extensions/browser/extension_prefs.cc

Issue 2054773002: Replace the WAS_INSTALLED_BY_CUSTODIAN creation flag with a pref (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Response to code review by treib@ Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "extensions/browser/extension_prefs.h" 5 #include "extensions/browser/extension_prefs.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <iterator> 10 #include <iterator>
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 const char kPrefIncognitoEnabled[] = "incognito"; 115 const char kPrefIncognitoEnabled[] = "incognito";
116 116
117 // A preference to control whether an extension is allowed to inject script in 117 // A preference to control whether an extension is allowed to inject script in
118 // pages with file URLs. 118 // pages with file URLs.
119 const char kPrefAllowFileAccess[] = "newAllowFileAccess"; 119 const char kPrefAllowFileAccess[] = "newAllowFileAccess";
120 // TODO(jstritar): As part of fixing http://crbug.com/91577, we revoked all 120 // TODO(jstritar): As part of fixing http://crbug.com/91577, we revoked all
121 // extension file access by renaming the pref. We should eventually clean up 121 // extension file access by renaming the pref. We should eventually clean up
122 // the old flag and possibly go back to that name. 122 // the old flag and possibly go back to that name.
123 // const char kPrefAllowFileAccessOld[] = "allowFileAccess"; 123 // const char kPrefAllowFileAccessOld[] = "allowFileAccess";
124 124
125 // A preference that is relevant only for supervised users
126 // and used to flag an extension as installed by custodian.
127 const char kPrefWasInstalledByCustodian[] = "wasInstalledByCustodian";
128
125 // A preference specifying if the user dragged the app on the NTP. 129 // A preference specifying if the user dragged the app on the NTP.
126 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp"; 130 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp";
127 131
128 // Preferences that hold which permissions the user has granted the extension. 132 // Preferences that hold which permissions the user has granted the extension.
129 // We explicitly keep track of these so that extensions can contain unknown 133 // We explicitly keep track of these so that extensions can contain unknown
130 // permissions, for backwards compatibility reasons, and we can still prompt 134 // permissions, for backwards compatibility reasons, and we can still prompt
131 // the user to accept them once recognized. We store the active permission 135 // the user to accept them once recognized. We store the active permission
132 // permissions because they may differ from those defined in the manifest. 136 // permissions because they may differ from those defined in the manifest.
133 const char kPrefActivePermissions[] = "active_permissions"; 137 const char kPrefActivePermissions[] = "active_permissions";
134 const char kPrefGrantedPermissions[] = "granted_permissions"; 138 const char kPrefGrantedPermissions[] = "granted_permissions";
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
1034 UpdateExtensionPref(extension_id, kPrefAllowFileAccess, 1038 UpdateExtensionPref(extension_id, kPrefAllowFileAccess,
1035 new base::FundamentalValue(allow)); 1039 new base::FundamentalValue(allow));
1036 } 1040 }
1037 1041
1038 bool ExtensionPrefs::HasAllowFileAccessSetting( 1042 bool ExtensionPrefs::HasAllowFileAccessSetting(
1039 const std::string& extension_id) const { 1043 const std::string& extension_id) const {
1040 const base::DictionaryValue* ext = GetExtensionPref(extension_id); 1044 const base::DictionaryValue* ext = GetExtensionPref(extension_id);
1041 return ext && ext->HasKey(kPrefAllowFileAccess); 1045 return ext && ext->HasKey(kPrefAllowFileAccess);
1042 } 1046 }
1043 1047
1048 bool ExtensionPrefs::WasInstalledByCustodian(
1049 const std::string& extension_id) const {
1050 return ReadPrefAsBooleanAndReturn(extension_id, kPrefWasInstalledByCustodian);
1051 }
1052
1053 void ExtensionPrefs::SetWasInstalledByCustodian(const std::string& extension_id,
1054 bool installed_by_custodian) {
1055 UpdateExtensionPref(extension_id, kPrefWasInstalledByCustodian,
1056 new base::FundamentalValue(installed_by_custodian));
1057 }
1058
1044 bool ExtensionPrefs::DoesExtensionHaveState( 1059 bool ExtensionPrefs::DoesExtensionHaveState(
1045 const std::string& id, Extension::State check_state) const { 1060 const std::string& id, Extension::State check_state) const {
1046 const base::DictionaryValue* extension = GetExtensionPref(id); 1061 const base::DictionaryValue* extension = GetExtensionPref(id);
1047 int state = -1; 1062 int state = -1;
1048 if (!extension || !extension->GetInteger(kPrefState, &state)) 1063 if (!extension || !extension->GetInteger(kPrefState, &state))
1049 return false; 1064 return false;
1050 1065
1051 if (state < 0 || state >= Extension::NUM_STATES) { 1066 if (state < 0 || state >= Extension::NUM_STATES) {
1052 LOG(ERROR) << "Bad pref 'state' for extension '" << id << "'"; 1067 LOG(ERROR) << "Bad pref 'state' for extension '" << id << "'";
1053 return false; 1068 return false;
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 extension_pref_value_map_->RegisterExtension( 1984 extension_pref_value_map_->RegisterExtension(
1970 extension_id, install_time, is_enabled, is_incognito_enabled); 1985 extension_id, install_time, is_enabled, is_incognito_enabled);
1971 1986
1972 FOR_EACH_OBSERVER( 1987 FOR_EACH_OBSERVER(
1973 ExtensionPrefsObserver, 1988 ExtensionPrefsObserver,
1974 observer_list_, 1989 observer_list_,
1975 OnExtensionRegistered(extension_id, install_time, is_enabled)); 1990 OnExtensionRegistered(extension_id, install_time, is_enabled));
1976 } 1991 }
1977 1992
1978 } // namespace extensions 1993 } // namespace extensions
OLDNEW
« extensions/browser/extension_prefs.h ('K') | « extensions/browser/extension_prefs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698