diff options
author | feldstein@chromium.org <feldstein@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 21:09:57 +0000 |
---|---|---|
committer | feldstein@chromium.org <feldstein@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-04-30 21:09:57 +0000 |
commit | 174cec74c38d2bb5d861e0e570d69b5dc3bef173 (patch) | |
tree | 373075472484214f2bf5d7aaf3d1ca168dd7d769 | |
parent | 709fd2346da26c501a153b1f682970a80c69b06b (diff) | |
download | chromium_src-174cec74c38d2bb5d861e0e570d69b5dc3bef173.zip chromium_src-174cec74c38d2bb5d861e0e570d69b5dc3bef173.tar.gz chromium_src-174cec74c38d2bb5d861e0e570d69b5dc3bef173.tar.bz2 |
Remove Draggability of browser extensions in incognito mode
There is a crash when you hide icons in incognito mode by dragging the container
to zero width. Since these resizes aren't even persisted, and it would be a
decent sized and possibly dangerous change this close to M5, I'm just disabling
the draggability.
BUG=42848
TEST=Shouldn't be able to drag in incognito mode, nor crash as per bug.
Review URL: http://codereview.chromium.org/1817005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46116 0039d316-1c4b-4281-b951-d872f2087c98
4 files changed, 26 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view.h b/chrome/browser/cocoa/extensions/browser_actions_container_view.h index a785361..32c6139 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_container_view.h +++ b/chrome/browser/cocoa/extensions/browser_actions_container_view.h @@ -43,6 +43,11 @@ extern const NSString* kBrowserActionGrippyDragFinishedNotification; // Whether the container is currently being resized by the user. BOOL userIsResizing_; + // Whether the user can resize this at all. Resizing is disabled in incognito + // mode since any changes done in incognito mode are not saved anyway, and + // also to avoid a crash (http://crbug.com/42848). + BOOL resizable_; + // Whether the user is allowed to drag the grippy to the left. NO if all // extensions are shown or the location bar has hit its minimum width (handled // within toolbar_controller.mm). @@ -72,6 +77,7 @@ extern const NSString* kBrowserActionGrippyDragFinishedNotification; @property(nonatomic) BOOL canDragLeft; @property(nonatomic) BOOL canDragRight; @property(nonatomic) BOOL grippyPinned; +@property(nonatomic,getter=isResizable) BOOL resizable; @property(nonatomic) CGFloat maxWidth; @property(readonly, nonatomic) BOOL userIsResizing; @property(nonatomic) BOOL rightBorderShown; diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view.mm b/chrome/browser/cocoa/extensions/browser_actions_container_view.mm index fea701a..2bf6ea2 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_container_view.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_container_view.mm @@ -56,11 +56,23 @@ const CGFloat kUpperPadding = 9.0; grippyRect_ = NSMakeRect(0.0, 0.0, kGrippyWidth, NSHeight([self bounds])); canDragLeft_ = YES; canDragRight_ = YES; + resizable_ = YES; [self setHidden:YES]; } return self; } +- (void)setResizable:(BOOL)resizable { + if (resizable == resizable_) + return; + resizable_ = resizable; + [self setNeedsDisplay:YES]; +} + +- (BOOL)isResizable { + return resizable_; +} + - (void)drawRect:(NSRect)dirtyRect { if (rightBorderShown_) { NSRect bounds = [self bounds]; @@ -95,7 +107,8 @@ const CGFloat kUpperPadding = 9.0; - (void)mouseDown:(NSEvent*)theEvent { initialDragPoint_ = [self convertPoint:[theEvent locationInWindow] fromView:nil]; - if (!NSMouseInRect(initialDragPoint_, grippyRect_, [self isFlipped])) + if (!resizable_ || + !NSMouseInRect(initialDragPoint_, grippyRect_, [self isFlipped])) return; lastXPos_ = [self frame].origin.x; @@ -189,7 +202,7 @@ const CGFloat kUpperPadding = 9.0; // current drag state. - (NSCursor*)appropriateCursorForGrippy { NSCursor* retVal; - if (!canDragLeft_ && !canDragRight_) { + if (!resizable_ || (!canDragLeft_ && !canDragRight_)) { retVal = [NSCursor arrowCursor]; } else if (!canDragLeft_) { retVal = [NSCursor resizeRightCursor]; @@ -202,6 +215,9 @@ const CGFloat kUpperPadding = 9.0; } - (void)drawGrippy { + if (!resizable_) + return; + NSRect grippyRect = NSMakeRect(0.0, kLowerPadding + kGrippyLowerPadding, 1.0, [self bounds].size.height - kUpperPadding - kGrippyUpperPadding); [[NSColor colorWithCalibratedWhite:0.7 alpha:0.5] set]; diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view_unittest.mm b/chrome/browser/cocoa/extensions/browser_actions_container_view_unittest.mm index a471af2..f771ccd 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_container_view_unittest.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_container_view_unittest.mm @@ -24,6 +24,7 @@ class BrowserActionsContainerViewTest : public CocoaTest { }; TEST_F(BrowserActionsContainerViewTest, BasicTests) { + EXPECT_TRUE([view_ isResizable]); EXPECT_TRUE([view_ canDragLeft]); EXPECT_TRUE([view_ canDragRight]); EXPECT_TRUE([view_ isHidden]); diff --git a/chrome/browser/cocoa/extensions/browser_actions_controller.mm b/chrome/browser/cocoa/extensions/browser_actions_controller.mm index 8d9afcc..fb70cc4 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_controller.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_controller.mm @@ -273,6 +273,7 @@ class ExtensionsServiceObserverBridge : public NotificationObserver, [self createButtons]; [self showChevronIfNecessaryInFrame:[containerView_ frame] animate:NO]; [self updateGrippyCursors]; + [container setResizable:!profile_->IsOffTheRecord()]; } return self; |