summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm3
-rw-r--r--chrome/browser/cocoa/extensions/browser_actions_controller.mm28
-rw-r--r--chrome/browser/cocoa/toolbar_controller.mm7
3 files changed, 31 insertions, 7 deletions
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index 209604d..61fad98 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -299,7 +299,8 @@
// This must be done after the view is added to the window since it relies
// on the window bounds to determine whether to show buttons or not.
- [toolbarController_ createBrowserActionButtons];
+ if ([self hasToolbar]) // Do not create the buttons in popups.
+ [toolbarController_ createBrowserActionButtons];
// We are done initializing now.
initializing_ = NO;
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);
}
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm
index 631bc74..6ea0d2b 100644
--- a/chrome/browser/cocoa/toolbar_controller.mm
+++ b/chrome/browser/cocoa/toolbar_controller.mm
@@ -592,7 +592,7 @@ class PrefObserverBridge : public NotificationObserver {
}
- (void)createBrowserActionButtons {
- if (browserActionsController_.get() == nil) {
+ if (!browserActionsController_.get()) {
browserActionsController_.reset([[BrowserActionsController alloc]
initWithBrowser:browser_
containerView:browserActionsContainerView_]);
@@ -662,6 +662,11 @@ class PrefObserverBridge : public NotificationObserver {
}
- (void)toolbarFrameChanged {
+ // Do nothing if the frame changes but no Browser Action Controller is
+ // present.
+ if (!browserActionsController_.get())
+ return;
+
[self maintainMinimumLocationBarWidth];
if (locationBarAtMinSize_) {