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

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

Issue 6543017: Track which apps the user has re-ordered on the NTP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix presubmit check Created 9 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/string_util.h" 7 #include "base/string_util.h"
8 #include "base/string_number_conversions.h" 8 #include "base/string_number_conversions.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/extensions/extension_pref_store.h" 10 #include "chrome/browser/extensions/extension_pref_store.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // purchased apps. 72 // purchased apps.
73 const char kWebStoreLogin[] = "extensions.webstore_login"; 73 const char kWebStoreLogin[] = "extensions.webstore_login";
74 74
75 // A preference set by the the NTP to persist the desired launch container type 75 // A preference set by the the NTP to persist the desired launch container type
76 // used for apps. 76 // used for apps.
77 const char kPrefLaunchType[] = "launchType"; 77 const char kPrefLaunchType[] = "launchType";
78 78
79 // A preference determining the order of which the apps appear on the NTP. 79 // A preference determining the order of which the apps appear on the NTP.
80 const char kPrefAppLaunchIndex[] = "app_launcher_index"; 80 const char kPrefAppLaunchIndex[] = "app_launcher_index";
81 81
82 // A preference specifying if the user dragged the app on the NTP.
83 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp";
84
82 // A preference for storing extra data sent in update checks for an extension. 85 // A preference for storing extra data sent in update checks for an extension.
83 const char kUpdateUrlData[] = "update_url_data"; 86 const char kUpdateUrlData[] = "update_url_data";
84 87
85 // Whether the browser action is visible in the toolbar. 88 // Whether the browser action is visible in the toolbar.
86 const char kBrowserActionVisible[] = "browser_action_visible"; 89 const char kBrowserActionVisible[] = "browser_action_visible";
87 90
88 // Preferences that hold which permissions the user has granted the extension. 91 // Preferences that hold which permissions the user has granted the extension.
89 // We explicitly keep track of these so that extensions can contain unknown 92 // We explicitly keep track of these so that extensions can contain unknown
90 // permissions, for backwards compatibility reasons, and we can still prompt 93 // permissions, for backwards compatibility reasons, and we can still prompt
91 // the user to accept them once recognized. 94 // the user to accept them once recognized.
(...skipping 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1119 const std::vector<std::string>& extension_ids) { 1122 const std::vector<std::string>& extension_ids) {
1120 for (size_t i = 0; i < extension_ids.size(); ++i) 1123 for (size_t i = 0; i < extension_ids.size(); ++i)
1121 SetAppLaunchIndex(extension_ids.at(i), i); 1124 SetAppLaunchIndex(extension_ids.at(i), i);
1122 1125
1123 NotificationService::current()->Notify( 1126 NotificationService::current()->Notify(
1124 NotificationType::EXTENSION_LAUNCHER_REORDERED, 1127 NotificationType::EXTENSION_LAUNCHER_REORDERED,
1125 Source<ExtensionPrefs>(this), 1128 Source<ExtensionPrefs>(this),
1126 NotificationService::NoDetails()); 1129 NotificationService::NoDetails());
1127 } 1130 }
1128 1131
1132 bool ExtensionPrefs::WasAppDraggedByUser(const std::string& extension_id) {
1133 DictionaryValue* dictionary = GetExtensionPref(extension_id);
1134 if (!dictionary) {
1135 NOTREACHED();
1136 return false;
1137 }
1138
1139 return ReadBooleanFromPref(dictionary, kPrefUserDraggedApp);
1140 }
1141
1142 void ExtensionPrefs::SetAppDraggedByUser(const std::string& extension_id) {
1143 DictionaryValue* dictionary = GetExtensionPref(extension_id);
1144 if (!dictionary) {
1145 NOTREACHED();
1146 return;
1147 }
1148
1149 dictionary->SetBoolean(kPrefUserDraggedApp, true);
1150 SavePrefsAndNotify();
1151 }
1152
1129 void ExtensionPrefs::SetUpdateUrlData(const std::string& extension_id, 1153 void ExtensionPrefs::SetUpdateUrlData(const std::string& extension_id,
1130 const std::string& data) { 1154 const std::string& data) {
1131 DictionaryValue* dictionary = GetExtensionPref(extension_id); 1155 DictionaryValue* dictionary = GetExtensionPref(extension_id);
1132 if (!dictionary) { 1156 if (!dictionary) {
1133 NOTREACHED(); 1157 NOTREACHED();
1134 return; 1158 return;
1135 } 1159 }
1136 1160
1137 dictionary->SetString(kUpdateUrlData, data); 1161 dictionary->SetString(kUpdateUrlData, data);
1138 SavePrefsAndNotify(); 1162 SavePrefsAndNotify();
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
1293 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) { 1317 void ExtensionPrefs::RegisterUserPrefs(PrefService* prefs) {
1294 prefs->RegisterDictionaryPref(kExtensionsPref); 1318 prefs->RegisterDictionaryPref(kExtensionsPref);
1295 prefs->RegisterListPref(kExtensionToolbar); 1319 prefs->RegisterListPref(kExtensionToolbar);
1296 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1); 1320 prefs->RegisterIntegerPref(prefs::kExtensionToolbarSize, -1);
1297 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate); 1321 prefs->RegisterDictionaryPref(kExtensionsBlacklistUpdate);
1298 prefs->RegisterListPref(prefs::kExtensionInstallAllowList); 1322 prefs->RegisterListPref(prefs::kExtensionInstallAllowList);
1299 prefs->RegisterListPref(prefs::kExtensionInstallDenyList); 1323 prefs->RegisterListPref(prefs::kExtensionInstallDenyList);
1300 prefs->RegisterListPref(prefs::kExtensionInstallForceList); 1324 prefs->RegisterListPref(prefs::kExtensionInstallForceList);
1301 prefs->RegisterStringPref(kWebStoreLogin, std::string() /* default_value */); 1325 prefs->RegisterStringPref(kWebStoreLogin, std::string() /* default_value */);
1302 } 1326 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_prefs.h ('k') | chrome/browser/extensions/extension_prefs_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698