| Index: chrome/browser/cocoa/extensions/browser_actions_controller.mm
|
| ===================================================================
|
| --- chrome/browser/cocoa/extensions/browser_actions_controller.mm (revision 42872)
|
| +++ chrome/browser/cocoa/extensions/browser_actions_controller.mm (working copy)
|
| @@ -172,6 +172,9 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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,9 +284,11 @@
|
| 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
|
| object:self];
|
| @@ -412,12 +424,18 @@
|
| }
|
|
|
| - (bool)shouldDisplayBrowserAction:(Extension*)extension {
|
| + // Only display incognito-enabled extensions while in incognito mode.
|
| return (!profile_->IsOffTheRecord() ||
|
| profile_->GetExtensionsService()->
|
| IsIncognitoEnabled(extension->id()));
|
| }
|
|
|
| - (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);
|
| }
|
|
|
|
|