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

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: Latest Master for CQ 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 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 // A preference set by the the NTP to persist the desired launch container type 142 // A preference set by the the NTP to persist the desired launch container type
143 // used for apps. 143 // used for apps.
144 const char kPrefLaunchType[] = "launchType"; 144 const char kPrefLaunchType[] = "launchType";
145 145
146 // A preference specifying if the user dragged the app on the NTP. 146 // A preference specifying if the user dragged the app on the NTP.
147 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp"; 147 const char kPrefUserDraggedApp[] = "user_dragged_app_ntp";
148 148
149 // A preference for storing extra data sent in update checks for an extension. 149 // A preference for storing extra data sent in update checks for an extension.
150 const char kUpdateUrlData[] = "update_url_data"; 150 const char kUpdateUrlData[] = "update_url_data";
151 151
152 // Whether the browser action is visible in the toolbar.
153 const char kBrowserActionVisible[] = "browser_action_visible";
154
155 // Preferences that hold which permissions the user has granted the extension. 152 // Preferences that hold which permissions the user has granted the extension.
156 // We explicitly keep track of these so that extensions can contain unknown 153 // We explicitly keep track of these so that extensions can contain unknown
157 // permissions, for backwards compatibility reasons, and we can still prompt 154 // permissions, for backwards compatibility reasons, and we can still prompt
158 // the user to accept them once recognized. We store the active permission 155 // the user to accept them once recognized. We store the active permission
159 // permissions because they may differ from those defined in the manifest. 156 // permissions because they may differ from those defined in the manifest.
160 const char kPrefActivePermissions[] = "active_permissions"; 157 const char kPrefActivePermissions[] = "active_permissions";
161 const char kPrefGrantedPermissions[] = "granted_permissions"; 158 const char kPrefGrantedPermissions[] = "granted_permissions";
162 159
163 // The preference names for PermissionSet values. 160 // The preference names for PermissionSet values.
164 const char kPrefAPIs[] = "api"; 161 const char kPrefAPIs[] = "api";
(...skipping 1249 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 1411
1415 void ExtensionPrefs::SetExtensionState(const std::string& extension_id, 1412 void ExtensionPrefs::SetExtensionState(const std::string& extension_id,
1416 Extension::State state) { 1413 Extension::State state) {
1417 UpdateExtensionPref(extension_id, kPrefState, 1414 UpdateExtensionPref(extension_id, kPrefState,
1418 Value::CreateIntegerValue(state)); 1415 Value::CreateIntegerValue(state));
1419 bool enabled = (state == Extension::ENABLED); 1416 bool enabled = (state == Extension::ENABLED);
1420 extension_pref_value_map_->SetExtensionState(extension_id, enabled); 1417 extension_pref_value_map_->SetExtensionState(extension_id, enabled);
1421 content_settings_store_->SetExtensionState(extension_id, enabled); 1418 content_settings_store_->SetExtensionState(extension_id, enabled);
1422 } 1419 }
1423 1420
1424 bool ExtensionPrefs::GetBrowserActionVisibility(const Extension* extension) {
1425 const DictionaryValue* extension_prefs =
1426 GetExtensionPref(extension->id());
1427 if (!extension_prefs)
1428 return true;
1429
1430 bool visible = false;
1431 if (!extension_prefs->GetBoolean(kBrowserActionVisible, &visible))
1432 return true;
1433
1434 return visible;
1435 }
1436
1437 void ExtensionPrefs::SetBrowserActionVisibility(const Extension* extension,
1438 bool visible) {
1439 if (GetBrowserActionVisibility(extension) == visible)
1440 return;
1441
1442 UpdateExtensionPref(extension->id(), kBrowserActionVisible,
1443 Value::CreateBooleanValue(visible));
1444 content::NotificationService::current()->Notify(
1445 chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED,
1446 content::Source<ExtensionPrefs>(this),
1447 content::Details<const Extension>(extension));
1448 }
1449
1450 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) { 1421 std::string ExtensionPrefs::GetVersionString(const std::string& extension_id) {
1451 const DictionaryValue* extension = GetExtensionPref(extension_id); 1422 const DictionaryValue* extension = GetExtensionPref(extension_id);
1452 if (!extension) 1423 if (!extension)
1453 return std::string(); 1424 return std::string();
1454 1425
1455 std::string version; 1426 std::string version;
1456 extension->GetString(kPrefVersion, &version); 1427 extension->GetString(kPrefVersion, &version);
1457 1428
1458 return version; 1429 return version;
1459 } 1430 }
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after
2259 is_enabled = initial_state == Extension::ENABLED; 2230 is_enabled = initial_state == Extension::ENABLED;
2260 } 2231 }
2261 2232
2262 extension_pref_value_map_->RegisterExtension(extension_id, install_time, 2233 extension_pref_value_map_->RegisterExtension(extension_id, install_time,
2263 is_enabled); 2234 is_enabled);
2264 content_settings_store_->RegisterExtension(extension_id, install_time, 2235 content_settings_store_->RegisterExtension(extension_id, install_time,
2265 is_enabled); 2236 is_enabled);
2266 } 2237 }
2267 2238
2268 } // namespace extensions 2239 } // 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