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

Unified Diff: chrome/browser/extensions/extension_prefs.cc

Issue 10378117: With enable-action-box add extensions to BrowserActionContainer only if they have preference kBrows… (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_prefs.cc
===================================================================
--- chrome/browser/extensions/extension_prefs.cc (revision 137006)
+++ chrome/browser/extensions/extension_prefs.cc (working copy)
@@ -15,6 +15,7 @@
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/prefs/scoped_user_pref_update.h"
#include "chrome/common/chrome_notification_types.h"
+#include "chrome/common/extensions/extension_switch_utils.h"
#include "chrome/common/extensions/manifest.h"
#include "chrome/common/extensions/url_pattern.h"
#include "chrome/common/pref_names.h"
@@ -113,6 +114,10 @@
// Whether the browser action is visible in the toolbar.
const char kBrowserActionVisible[] = "browser_action_visible";
+// Whether the browser action is pinned in the toolbar. This will eventually
+// replace kBrowserActionVisible.
+const char kBrowserActionPinned[] = "browser_action_pinned";
+
// Preferences that hold which permissions the user has granted the extension.
// We explicitly keep track of these so that extensions can contain unknown
// permissions, for backwards compatibility reasons, and we can still prompt
@@ -1269,14 +1274,21 @@
}
bool ExtensionPrefs::GetBrowserActionVisibility(const Extension* extension) {
+ bool action_box_enabled = extensions::switch_utils::IsActionBoxEnabled();
+ bool default_value = !action_box_enabled;
+
const DictionaryValue* extension_prefs = GetExtensionPref(extension->id());
if (!extension_prefs)
- return true;
+ return default_value;
+
bool visible = false;
- if (!extension_prefs->GetBoolean(kBrowserActionVisible, &visible) || visible)
- return true;
+ const char* browser_action_pref = action_box_enabled ? kBrowserActionPinned :
+ kBrowserActionVisible;
+ bool pref_exists = extension_prefs->GetBoolean(browser_action_pref, &visible);
+ if (!pref_exists)
+ return default_value;
- return false;
+ return visible;
}
void ExtensionPrefs::SetBrowserActionVisibility(const Extension* extension,
@@ -1284,7 +1296,10 @@
if (GetBrowserActionVisibility(extension) == visible)
return;
- UpdateExtensionPref(extension->id(), kBrowserActionVisible,
+ bool action_box_enabled = extensions::switch_utils::IsActionBoxEnabled();
+ const char* browser_action_pref = action_box_enabled ? kBrowserActionPinned :
+ kBrowserActionVisible;
+ UpdateExtensionPref(extension->id(), browser_action_pref,
Value::CreateBooleanValue(visible));
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED,
« no previous file with comments | « chrome/browser/extensions/extension_context_menu_model.cc ('k') | chrome/browser/extensions/extension_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698