| 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/prefs/pref_notifier.h" | 7 #include "base/prefs/pref_notifier.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 // purchased apps. | 132 // purchased apps. |
| 133 const char kWebStoreLogin[] = "extensions.webstore_login"; | 133 const char kWebStoreLogin[] = "extensions.webstore_login"; |
| 134 | 134 |
| 135 // A preference set by the the NTP to persist the desired launch container type | 135 // A preference set by the the NTP to persist the desired launch container type |
| 136 // used for apps. | 136 // used for apps. |
| 137 const char kPrefLaunchType[] = "launchType"; | 137 const char kPrefLaunchType[] = "launchType"; |
| 138 | 138 |
| 139 // A preference specifying if the user dragged the app on the NTP. | 139 // A preference specifying if the user dragged the app on the NTP. |
| 140 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp"; | 140 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp"; |
| 141 | 141 |
| 142 // A preference for storing extra data sent in update checks for an extension. | |
| 143 const char kUpdateUrlData[] = "update_url_data"; | |
| 144 | |
| 145 // Preferences that hold which permissions the user has granted the extension. | 142 // Preferences that hold which permissions the user has granted the extension. |
| 146 // We explicitly keep track of these so that extensions can contain unknown | 143 // We explicitly keep track of these so that extensions can contain unknown |
| 147 // permissions, for backwards compatibility reasons, and we can still prompt | 144 // permissions, for backwards compatibility reasons, and we can still prompt |
| 148 // the user to accept them once recognized. We store the active permission | 145 // the user to accept them once recognized. We store the active permission |
| 149 // permissions because they may differ from those defined in the manifest. | 146 // permissions because they may differ from those defined in the manifest. |
| 150 const char kPrefActivePermissions[] = "active_permissions"; | 147 const char kPrefActivePermissions[] = "active_permissions"; |
| 151 const char kPrefGrantedPermissions[] = "granted_permissions"; | 148 const char kPrefGrantedPermissions[] = "granted_permissions"; |
| 152 | 149 |
| 153 // The preference names for PermissionSet values. | 150 // The preference names for PermissionSet values. |
| 154 const char kPrefAPIs[] = "api"; | 151 const char kPrefAPIs[] = "api"; |
| (...skipping 1350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 | 1502 |
| 1506 bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) { | 1503 bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) { |
| 1507 return ReadPrefAsBooleanAndReturn(extension_id, kPrefUserDraggedApp); | 1504 return ReadPrefAsBooleanAndReturn(extension_id, kPrefUserDraggedApp); |
| 1508 } | 1505 } |
| 1509 | 1506 |
| 1510 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) { | 1507 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) { |
| 1511 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, | 1508 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, |
| 1512 Value::CreateBooleanValue(true)); | 1509 Value::CreateBooleanValue(true)); |
| 1513 } | 1510 } |
| 1514 | 1511 |
| 1515 void ExtensionPrefs::SetUpdateUrlData(const std::string& extension_id, | |
| 1516 const std::string& data) { | |
| 1517 UpdateExtensionPref(extension_id, kUpdateUrlData, | |
| 1518 Value::CreateStringValue(data)); | |
| 1519 } | |
| 1520 | |
| 1521 std::string ExtensionPrefs::GetUpdateUrlData(const std::string& extension_id) { | |
| 1522 const DictionaryValue* dictionary = GetExtensionPref(extension_id); | |
| 1523 if (!dictionary) | |
| 1524 return std::string(); | |
| 1525 | |
| 1526 std::string data; | |
| 1527 dictionary->GetString(kUpdateUrlData, &data); | |
| 1528 return data; | |
| 1529 } | |
| 1530 | |
| 1531 void ExtensionPrefs::OnContentSettingChanged( | 1512 void ExtensionPrefs::OnContentSettingChanged( |
| 1532 const std::string& extension_id, | 1513 const std::string& extension_id, |
| 1533 bool incognito) { | 1514 bool incognito) { |
| 1534 if (incognito) { | 1515 if (incognito) { |
| 1535 UpdateExtensionPref( | 1516 UpdateExtensionPref( |
| 1536 extension_id, kPrefIncognitoContentSettings, | 1517 extension_id, kPrefIncognitoContentSettings, |
| 1537 content_settings_store_->GetSettingsForExtension( | 1518 content_settings_store_->GetSettingsForExtension( |
| 1538 extension_id, kExtensionPrefsScopeIncognitoPersistent)); | 1519 extension_id, kExtensionPrefsScopeIncognitoPersistent)); |
| 1539 } else { | 1520 } else { |
| 1540 UpdateExtensionPref( | 1521 UpdateExtensionPref( |
| (...skipping 538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2079 is_enabled = initial_state == Extension::ENABLED; | 2060 is_enabled = initial_state == Extension::ENABLED; |
| 2080 } | 2061 } |
| 2081 | 2062 |
| 2082 extension_pref_value_map_->RegisterExtension(extension_id, install_time, | 2063 extension_pref_value_map_->RegisterExtension(extension_id, install_time, |
| 2083 is_enabled); | 2064 is_enabled); |
| 2084 content_settings_store_->RegisterExtension(extension_id, install_time, | 2065 content_settings_store_->RegisterExtension(extension_id, install_time, |
| 2085 is_enabled); | 2066 is_enabled); |
| 2086 } | 2067 } |
| 2087 | 2068 |
| 2088 } // namespace extensions | 2069 } // namespace extensions |
| OLD | NEW |