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 visible in the toolbar. |
Aaron Boodman
2012/05/14 18:36:17
Change this to:
Whether the browser action is pin
yefimt
2012/05/14 18:50:45
Done.
|
+// It is replacing kBrowserActionVisible, an old one eventualy will be gone. |
+const char kBrowserActionPined[] = "browser_action_pined"; |
Aaron Boodman
2012/05/14 18:36:17
Spelling here and elsewhere: pinned (two 'n's).
yefimt
2012/05/14 18:50:45
Done.
|
+ |
// 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 |
@@ -1268,10 +1274,50 @@ |
content_settings_store_->SetExtensionState(extension_id, enabled); |
} |
+bool ExtensionPrefs::GetBrowserActionPined(const Extension* extension) { |
+ const DictionaryValue* extension_prefs = GetExtensionPref(extension->id()); |
+ if (!extension_prefs) |
+ return true; |
Aaron Boodman
2012/05/14 18:36:17
return false. Default to not-pinned.
yefimt
2012/05/14 18:50:45
Done.
|
+ |
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
+ if (command_line.HasSwitch(switches::kEnableActionBox)) { |
Aaron Boodman
2012/05/14 18:36:17
Do we expect this method to be called when the swi
yefimt
2012/05/14 18:50:45
We do, could be call from ExtensionToolbarModel wh
|
+ bool pined = false; |
+ bool pref_exists = extension_prefs->GetBoolean(kBrowserActionPined, |
+ &pined); |
+ if (pref_exists && pined) |
+ return true; |
+ } else { |
+ return GetBrowserActionVisibility(extension); |
+ } |
+ |
+ return false; |
+} |
+ |
+void ExtensionPrefs::SetBrowserActionPined(const Extension* extension, |
+ bool pined) { |
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
+ bool enable_action_box = command_line.HasSwitch(switches::kEnableActionBox); |
+ |
+ if (enable_action_box) { |
+ if (GetBrowserActionPined(extension) == pined) |
+ return; |
+ |
+ UpdateExtensionPref(extension->id(), kBrowserActionPined, |
+ Value::CreateBooleanValue(pined)); |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_EXTENSION_BROWSER_ACTION_PINED_CHANGED, |
+ content::Source<ExtensionPrefs>(this), |
+ content::Details<const Extension>(extension)); |
+ } else { |
+ SetBrowserActionVisibility(extension, pined); |
+ } |
+} |
+ |
bool ExtensionPrefs::GetBrowserActionVisibility(const Extension* extension) { |
const DictionaryValue* extension_prefs = GetExtensionPref(extension->id()); |
if (!extension_prefs) |
return true; |
+ |
bool visible = false; |
if (!extension_prefs->GetBoolean(kBrowserActionVisible, &visible) || visible) |
return true; |