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

Unified Diff: chrome/browser/extensions/extension_prefs.cc

Issue 10049006: Add OAuth2 scopes to the ExtensionPermissionSet and granted permissions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_prefs.cc
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc
index 8aa723a8d354e95d69688b662352a751a029e328..9ab3412280c34b3160d663931acab9e8d8064de5 100644
--- a/chrome/browser/extensions/extension_prefs.cc
+++ b/chrome/browser/extensions/extension_prefs.cc
@@ -124,6 +124,7 @@ const char kPrefGrantedPermissions[] = "granted_permissions";
const char kPrefAPIs[] = "api";
const char kPrefExplicitHosts[] = "explicit_host";
const char kPrefScriptableHosts[] = "scriptable_host";
+const char kPrefScopes[] = "scopes";
Yoyo Zhou 2012/04/24 23:16:36 The ones just above this aren't plural, so conside
jstritar 2012/04/24 23:33:34 Yeah, this is weird.... I don't remember why we ma
// The preference names for the old granted permissions scheme.
const char kPrefOldGrantedFullAccess[] = "granted_permissions.full";
@@ -495,7 +496,20 @@ ExtensionPermissionSet* ExtensionPrefs::ReadExtensionPrefPermissionSet(
extension_id, JoinPrefs(pref_key, kPrefScriptableHosts),
&scriptable_hosts, UserScript::kValidUserScriptSchemes);
- return new ExtensionPermissionSet(apis, explicit_hosts, scriptable_hosts);
+ // Retrieve the oauth2 scopes.
+ ExtensionOAuth2Scopes scopes;
+ const ListValue* scope_values = NULL;
+ std::string scope_pref = JoinPrefs(pref_key, kPrefScopes);
+ if (ReadExtensionPrefList(extension_id, scope_pref, &scope_values)) {
+ for (size_t i = 0; i < scope_values->GetSize(); ++i) {
+ std::string scope;
+ if (scope_values->GetString(i, &scope))
+ scopes.insert(scope);
+ }
+ }
+
+ return new ExtensionPermissionSet(
+ apis, explicit_hosts, scriptable_hosts, scopes);
}
void ExtensionPrefs::SetExtensionPrefPermissionSet(
@@ -528,6 +542,18 @@ void ExtensionPrefs::SetExtensionPrefPermissionSet(
JoinPrefs(pref_key, kPrefScriptableHosts),
new_value->scriptable_hosts());
}
+
+ // Set the oauth2 scopes.
+ ExtensionOAuth2Scopes scopes = new_value->scopes();
+ if (!scopes.empty()) {
+ ListValue* scope_values = new ListValue();
+ for (ExtensionOAuth2Scopes::iterator i = scopes.begin();
+ i != scopes.end(); ++i) {
+ scope_values->Append(Value::CreateStringValue(*i));
+ }
+ std::string scope_pref = JoinPrefs(pref_key, kPrefScopes);
+ UpdateExtensionPref(extension_id, scope_pref, scope_values);
+ }
}
// static
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_prefs_unittest.cc » ('j') | chrome/common/extensions/extension.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698