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, |