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

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

Issue 14699002: Move BrowserAction references from ExtensionPrefs to ExtensionActionAPI (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 7 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
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/prefs/pref_notifier.h" 8 #include "base/prefs/pref_notifier.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 // A preference set by the the NTP to persist the desired launch container type 132 // A preference set by the the NTP to persist the desired launch container type
133 // used for apps. 133 // used for apps.
134 const char kPrefLaunchType[] = "launchType"; 134 const char kPrefLaunchType[] = "launchType";
135 135
136 // A preference specifying if the user dragged the app on the NTP. 136 // A preference specifying if the user dragged the app on the NTP.
137 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp"; 137 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp";
138 138
139 // A preference for storing extra data sent in update checks for an extension. 139 // A preference for storing extra data sent in update checks for an extension.
140 const char kUpdateUrlData[] = "update_url_data"; 140 const char kUpdateUrlData[] = "update_url_data";
141 141
142 // Whether the browser action is visible in the toolbar.
143 const char kBrowserActionVisible[] = "browser_action_visible";
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 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1355 1352
1356 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, 1353 void ExtensionPrefs::SetExtensionState(const std::string& extension_id,
1357 Extension::State state) { 1354 Extension::State state) {
1358 UpdateExtensionPref(extension_id, kPrefState, 1355 UpdateExtensionPref(extension_id, kPrefState,
1359 Value::CreateIntegerValue(state)); 1356 Value::CreateIntegerValue(state));
1360 bool enabled = (state == Extension::ENABLED); 1357 bool enabled = (state == Extension::ENABLED);
1361 extension_pref_value_map_->SetExtensionState(extension_id, enabled); 1358 extension_pref_value_map_->SetExtensionState(extension_id, enabled);
1362 content_settings_store_->SetExtensionState(extension_id, enabled); 1359 content_settings_store_->SetExtensionState(extension_id, enabled);
1363 } 1360 }
1364 1361
1365 bool ExtensionPrefs::GetBrowserActionVisibility(const Extension* extension) {
1366 const DictionaryValue* extension_prefs =
1367 GetExtensionPref(extension->id());
1368 if (!extension_prefs)
1369 return true;
1370
1371 bool visible = false;
1372 if (!extension_prefs->GetBoolean(kBrowserActionVisible, &visible))
1373 return true;
1374
1375 return visible;
1376 }
1377
1378 void ExtensionPrefs::SetBrowserActionVisibility(const Extension* extension,
1379 bool visible) {
1380 if (GetBrowserActionVisibility(extension) == visible)
1381 return;
1382
1383 UpdateExtensionPref(extension->id(), kBrowserActionVisible,
1384 Value::CreateBooleanValue(visible));
1385 content::NotificationService::current()->Notify(
1386 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED,
1387 content::Source<ExtensionPrefs>(this),
1388 content::Details<const Extension>(extension));
1389 }
1390
1391 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { 1362 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) {
1392 const DictionaryValue* extension = GetExtensionPref(extension_id); 1363 const DictionaryValue* extension = GetExtensionPref(extension_id);
1393 if (!extension) 1364 if (!extension)
1394 return std::string(); 1365 return std::string();
1395 1366
1396 std::string version; 1367 std::string version;
1397 extension->GetString(kPrefVersion, &version); 1368 extension->GetString(kPrefVersion, &version);
1398 1369
1399 return version; 1370 return version;
1400 } 1371 }
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 is_enabled = initial_state == Extension::ENABLED; 2171 is_enabled = initial_state == Extension::ENABLED;
2201 } 2172 }
2202 2173
2203 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 2174 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
2204 is_enabled); 2175 is_enabled);
2205 content_settings_store_->RegisterExtension(extension_id, install_time, 2176 content_settings_store_->RegisterExtension(extension_id, install_time,
2206 is_enabled); 2177 is_enabled);
2207 } 2178 }
2208 2179
2209 } // namespace extensions 2180 } // namespace extensions
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