Index: chrome/browser/extensions/extension_prefs.cc |
=================================================================== |
--- chrome/browser/extensions/extension_prefs.cc (revision 136343) |
+++ chrome/browser/extensions/extension_prefs.cc (working copy) |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/extensions/extension_prefs.h" |
+#include "base/command_line.h" |
#include "base/string_number_conversions.h" |
#include "base/string_util.h" |
#include "base/utf_string_conversions.h" |
@@ -15,6 +16,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/chrome_switches.h" |
#include "chrome/common/extensions/manifest.h" |
#include "chrome/common/extensions/url_pattern.h" |
#include "chrome/common/pref_names.h" |
@@ -113,6 +115,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 |
@@ -1270,11 +1276,24 @@ |
bool ExtensionPrefs::GetBrowserActionVisibility(const Extension* extension) { |
const DictionaryValue* extension_prefs = GetExtensionPref(extension->id()); |
- if (!extension_prefs) |
- return true; |
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
+ bool enable_action_box = command_line.HasSwitch(switches::kEnableActionBox); |
Aaron Boodman
2012/05/14 20:18:13
Nit: variable should not have typically have verb
yefimt
2012/05/14 21:07:36
Done.
|
+ if (!extension_prefs) { |
Aaron Boodman
2012/05/14 20:18:13
Nit: If an if statement is less than two lines tot
Aaron Boodman
2012/05/14 20:18:13
You can simplify this logic somewhat:
bool defaul
yefimt
2012/05/14 21:07:36
Done.
yefimt
2012/05/14 21:07:36
Done.
yefimt
2012/05/14 21:07:36
Done.
|
+ return enable_action_box ? false : true; |
+ } |
+ |
bool visible = false; |
- if (!extension_prefs->GetBoolean(kBrowserActionVisible, &visible) || visible) |
- return true; |
+ const char* browser_action_pref = enable_action_box ? kBrowserActionPinned : |
+ kBrowserActionVisible; |
+ bool pref_exists = extension_prefs->GetBoolean(browser_action_pref, |
+ &visible); |
+ if (enable_action_box) { |
+ if (pref_exists && visible) |
+ return true; |
+ } else { |
+ if (!pref_exists || visible) |
+ return true; |
+ } |
return false; |
} |
@@ -1284,7 +1303,11 @@ |
if (GetBrowserActionVisibility(extension) == visible) |
return; |
- UpdateExtensionPref(extension->id(), kBrowserActionVisible, |
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
+ bool enable_action_box = command_line.HasSwitch(switches::kEnableActionBox); |
Aaron Boodman
2012/05/14 20:18:13
Since you are checking this in multiple places, ca
|
+ const char* browser_action_pref = enable_action_box ? kBrowserActionPinned : |
+ kBrowserActionVisible; |
+ UpdateExtensionPref(extension->id(), browser_action_pref, |
Value::CreateBooleanValue(visible)); |
content::NotificationService::current()->Notify( |
chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_VISIBILITY_CHANGED, |