diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-15 22:06:45 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-15 22:06:45 +0000 |
commit | 5ee5bef87e0d0ff6506aea55e3310e59ef767b14 (patch) | |
tree | cbcbeb869d5fd2e78199b7ed8be77379e5d85eb5 /chrome/browser/cocoa/extensions | |
parent | 83dd4d1b3402a1b3d6f19f6676ebe5597053f467 (diff) | |
download | chromium_src-5ee5bef87e0d0ff6506aea55e3310e59ef767b14.zip chromium_src-5ee5bef87e0d0ff6506aea55e3310e59ef767b14.tar.gz chromium_src-5ee5bef87e0d0ff6506aea55e3310e59ef767b14.tar.bz2 |
[Mac] Add support for showing extensions in incognito mode, while fixing a bug where the Browser Actions container was displayed and sized in a popup window.
TEST=none.
BUG=38094
Review URL: http://codereview.chromium.org/1001001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41644 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/extensions')
-rw-r--r-- | chrome/browser/cocoa/extensions/browser_actions_controller.mm | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm index 2da1554..7acd763 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm @@ -172,6 +172,9 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, NSUInteger i = 0; for (ExtensionList::iterator iter = toolbarModel_->begin(); iter != toolbarModel_->end(); ++iter) { + if (![self shouldDisplayBrowserAction:*iter]) + continue; + [self createActionButtonForExtension:*iter withIndex:i++]; } @@ -193,6 +196,9 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, if (![self shouldDisplayBrowserAction:extension]) return; + if (profile_->IsOffTheRecord()) + index = toolbarModel_->OriginalIndexToIncognito(index); + // Show the container if it's the first button. Otherwise it will be shown // already. if ([buttons_ count] == 0) @@ -225,10 +231,11 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, return; BrowserActionButton* button = [buttons_ objectForKey:buttonKey]; - if (!button) { - NOTREACHED(); + // This could be the case in incognito, where only a subset of extensions are + // shown. + if (!button) return; - } + [button removeFromSuperview]; [buttons_ removeObjectForKey:buttonKey]; if ([buttons_ count] == 0) { @@ -244,6 +251,9 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, NSUInteger i = 0; for (ExtensionList::iterator iter = toolbarModel_->begin(); iter != toolbarModel_->end(); ++iter) { + if (![self shouldDisplayBrowserAction:*iter]) + continue; + CGFloat xOffset = kGrippyXOffset + (i * (kBrowserActionWidth + kBrowserActionButtonPadding)); NSString* extensionId = base::SysUTF8ToNSString((*iter)->id()); @@ -274,8 +284,10 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, CGFloat width = [self containerWidthWithButtonCount:[self visibleButtonCount]]; [containerView_ resizeToWidth:width animate:animate]; - profile_->GetPrefs()->SetReal(prefs::kBrowserActionContainerWidth, - NSWidth([containerView_ frame])); + + if (!profile_->IsOffTheRecord()) + profile_->GetPrefs()->SetReal(prefs::kBrowserActionContainerWidth, + NSWidth([containerView_ frame])); [[NSNotificationCenter defaultCenter] postNotificationName:kBrowserActionVisibilityChangedNotification @@ -412,11 +424,17 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, } - (bool)shouldDisplayBrowserAction:(Extension*)extension { + // Only display incognito-enabled extensions while in incognito mode. return (!profile_->IsOffTheRecord() || profile_->GetExtensionsService()->IsIncognitoEnabled(extension)); } - (CGFloat)savedWidth { + // Don't use the standard saved width for incognito until a separate pref is + // added. + if (profile_->IsOffTheRecord()) + return 0.0; + return profile_->GetPrefs()->GetReal(prefs::kBrowserActionContainerWidth); } |