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

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

Issue 11189094: Implement sideload wipeout for Extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 2 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 | Annotate | Revision Log
OLDNEW
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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 // Key for Media Gallery ID. 216 // Key for Media Gallery ID.
217 const char kMediaGalleryIdKey[] = "id"; 217 const char kMediaGalleryIdKey[] = "id";
218 218
219 // Key for Media Gallery Permission Value. 219 // Key for Media Gallery Permission Value.
220 const char kMediaGalleryHasPermissionKey[] = "has_permission"; 220 const char kMediaGalleryHasPermissionKey[] = "has_permission";
221 221
222 // Key for what version chrome was last time the extension prefs were loaded. 222 // Key for what version chrome was last time the extension prefs were loaded.
223 const char kExtensionsLastChromeVersion[] = "extensions.last_chrome_version"; 223 const char kExtensionsLastChromeVersion[] = "extensions.last_chrome_version";
224 224
225 // Key for whether the sideload wipeout effort is done.
226 const char kSideloadWipeoutDone[] = "extensions.sideload_wipeout_done";
227
225 // Provider of write access to a dictionary storing extension prefs. 228 // Provider of write access to a dictionary storing extension prefs.
226 class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate { 229 class ScopedExtensionPrefUpdate : public DictionaryPrefUpdate {
227 public: 230 public:
228 ScopedExtensionPrefUpdate(PrefService* service, 231 ScopedExtensionPrefUpdate(PrefService* service,
229 const std::string& extension_id) : 232 const std::string& extension_id) :
230 DictionaryPrefUpdate(service, ExtensionPrefs::kExtensionsPref), 233 DictionaryPrefUpdate(service, ExtensionPrefs::kExtensionsPref),
231 extension_id_(extension_id) {} 234 extension_id_(extension_id) {}
232 235
233 virtual ~ScopedExtensionPrefUpdate() { 236 virtual ~ScopedExtensionPrefUpdate() {
234 } 237 }
(...skipping 1564 matching lines...) Expand 10 before | Expand all | Expand 10 after
1799 *result = prefs_->GetString(kWebStoreLogin); 1802 *result = prefs_->GetString(kWebStoreLogin);
1800 return true; 1803 return true;
1801 } 1804 }
1802 return false; 1805 return false;
1803 } 1806 }
1804 1807
1805 void ExtensionPrefs::SetWebStoreLogin(const std::string& login) { 1808 void ExtensionPrefs::SetWebStoreLogin(const std::string& login) {
1806 prefs_->SetString(kWebStoreLogin, login); 1809 prefs_->SetString(kWebStoreLogin, login);
1807 } 1810 }
1808 1811
1812 bool ExtensionPrefs::GetSideloadWipeoutDone() const {
1813 return prefs_->GetBoolean(kSideloadWipeoutDone);
1814 }
1815
1816 void ExtensionPrefs::SetSideloadWipeoutDone() {
1817 return prefs_->SetBoolean(kSideloadWipeoutDone, true);
1818 }
1819
1809 bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) { 1820 bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) {
1810 return ReadExtensionPrefBoolean(extension_id, kPrefUserDraggedApp); 1821 return ReadExtensionPrefBoolean(extension_id, kPrefUserDraggedApp);
1811 } 1822 }
1812 1823
1813 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) { 1824 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) {
1814 UpdateExtensionPref(extension_id, kPrefUserDraggedApp, 1825 UpdateExtensionPref(extension_id, kPrefUserDraggedApp,
1815 Value::CreateBooleanValue(true)); 1826 Value::CreateBooleanValue(true));
1816 } 1827 }
1817 1828
1818 void ExtensionPrefs::SetUpdateUrlData(const std::string& extension_id, 1829 void ExtensionPrefs::SetUpdateUrlData(const std::string& extension_id,
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
2191 0, // default value 2202 0, // default value
2192 PrefService::UNSYNCABLE_PREF); 2203 PrefService::UNSYNCABLE_PREF);
2193 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck, 2204 prefs->RegisterInt64Pref(prefs::kNextExtensionsUpdateCheck,
2194 0, // default value 2205 0, // default value
2195 PrefService::UNSYNCABLE_PREF); 2206 PrefService::UNSYNCABLE_PREF);
2196 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites, 2207 prefs->RegisterListPref(prefs::kExtensionAllowedInstallSites,
2197 PrefService::UNSYNCABLE_PREF); 2208 PrefService::UNSYNCABLE_PREF);
2198 prefs->RegisterStringPref(kExtensionsLastChromeVersion, 2209 prefs->RegisterStringPref(kExtensionsLastChromeVersion,
2199 std::string(), // default value 2210 std::string(), // default value
2200 PrefService::UNSYNCABLE_PREF); 2211 PrefService::UNSYNCABLE_PREF);
2212 prefs->RegisterBooleanPref(kSideloadWipeoutDone,
2213 false,
2214 PrefService::UNSYNCABLE_PREF);
2201 } 2215 }
2202 2216
2203 ExtensionIdList ExtensionPrefs::GetExtensionPrefAsVector( 2217 ExtensionIdList ExtensionPrefs::GetExtensionPrefAsVector(
2204 const char* pref) { 2218 const char* pref) {
2205 ExtensionIdList extension_ids; 2219 ExtensionIdList extension_ids;
2206 const ListValue* list_of_values = prefs_->GetList(pref); 2220 const ListValue* list_of_values = prefs_->GetList(pref);
2207 if (!list_of_values) 2221 if (!list_of_values)
2208 return extension_ids; 2222 return extension_ids;
2209 2223
2210 std::string extension_id; 2224 std::string extension_id;
2211 for (size_t i = 0; i < list_of_values->GetSize(); ++i) { 2225 for (size_t i = 0; i < list_of_values->GetSize(); ++i) {
2212 if (list_of_values->GetString(i, &extension_id)) 2226 if (list_of_values->GetString(i, &extension_id))
2213 extension_ids.push_back(extension_id); 2227 extension_ids.push_back(extension_id);
2214 } 2228 }
2215 return extension_ids; 2229 return extension_ids;
2216 } 2230 }
2217 2231
2218 void ExtensionPrefs::SetExtensionPrefFromVector( 2232 void ExtensionPrefs::SetExtensionPrefFromVector(
2219 const char* pref, 2233 const char* pref,
2220 const ExtensionIdList& strings) { 2234 const ExtensionIdList& strings) {
2221 ListPrefUpdate update(prefs_, pref); 2235 ListPrefUpdate update(prefs_, pref);
2222 ListValue* list_of_values = update.Get(); 2236 ListValue* list_of_values = update.Get();
2223 list_of_values->Clear(); 2237 list_of_values->Clear();
2224 for (ExtensionIdList::const_iterator iter = strings.begin(); 2238 for (ExtensionIdList::const_iterator iter = strings.begin();
2225 iter != strings.end(); ++iter) 2239 iter != strings.end(); ++iter)
2226 list_of_values->Append(new StringValue(*iter)); 2240 list_of_values->Append(new StringValue(*iter));
2227 } 2241 }
2228 2242
2229 } // namespace extensions 2243 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698