summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-15 22:06:45 +0000
committerandybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-15 22:06:45 +0000
commit5ee5bef87e0d0ff6506aea55e3310e59ef767b14 (patch)
treecbcbeb869d5fd2e78199b7ed8be77379e5d85eb5
parent83dd4d1b3402a1b3d6f19f6676ebe5597053f467 (diff)
downloadchromium_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
-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_) {