Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Unified Diff: chrome/browser/cocoa/extensions/browser_actions_controller.mm

Issue 1001001: [Mac] Do not take Browser Actions Container view changes into account in inco... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | chrome/browser/cocoa/toolbar_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/extensions/browser_actions_controller.mm
===================================================================
--- chrome/browser/cocoa/extensions/browser_actions_controller.mm (revision 41595)
+++ 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,11 +424,17 @@
}
- (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);
}
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | chrome/browser/cocoa/toolbar_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698