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"; |
// 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 |