Chromium Code Reviews| Index: chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm |
| diff --git a/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm b/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm |
| index 1a5e6e05b44d285c8c3d1062d4d72be572144c58..fbfcc6cd88815831185cda910d23d923b484fa4f 100644 |
| --- a/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm |
| +++ b/chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm |
| @@ -19,14 +19,13 @@ |
| ZoomDecoration::ZoomDecoration(LocationBarViewMac* owner) |
| : owner_(owner), |
| bubble_(nil) { |
| - Update(NULL); |
| } |
| ZoomDecoration::~ZoomDecoration() { |
| } |
| void ZoomDecoration::Update(ZoomController* zoom_controller) { |
| - if (!zoom_controller || zoom_controller->IsAtDefaultZoom()) { |
| + if (!ShouldShowDecoration()) { |
| [bubble_ close]; |
| SetVisible(false); |
| return; |
| @@ -46,6 +45,11 @@ void ZoomDecoration::Update(ZoomController* zoom_controller) { |
| } |
| void ZoomDecoration::ShowBubble(BOOL auto_close) { |
| + if (bubble_) { |
| + [bubble_ close]; |
| + return; |
| + } |
| + |
| content::WebContents* web_contents = owner_->GetWebContents(); |
| if (!web_contents) |
| return; |
| @@ -64,6 +68,8 @@ void ZoomDecoration::ShowBubble(BOOL auto_close) { |
| if (!bubble_) { |
| void(^observer)(ZoomBubbleController*) = ^(ZoomBubbleController*) { |
| bubble_ = nil; |
| + if (IsAtDefaultZoom()) |
| + SetVisible(false); |
|
Robert Sesek
2013/02/26 16:08:24
Is this necessary? Won't Update() be called when t
sail
2013/02/26 22:04:15
This is only for default zoom case. For example:
|
| }; |
| bubble_ = |
| [[ZoomBubbleController alloc] initWithParentWindow:[field window] |
| @@ -76,12 +82,24 @@ void ZoomDecoration::ShowBubble(BOOL auto_close) { |
| } |
| NSPoint ZoomDecoration::GetBubblePointInFrame(NSRect frame) { |
| - NSSize image_size = [GetImage() size]; |
| - frame.origin.x += frame.size.width - image_size.width; |
| - frame.size = image_size; |
| + return NSMakePoint(NSMaxX(frame), NSMaxY(frame)); |
| +} |
| + |
| +bool ZoomDecoration::IsAtDefaultZoom() const { |
| + content::WebContents* web_contents = owner_->GetWebContents(); |
| + if (!web_contents) |
| + return false; |
| + ZoomController* zoomController = |
| + ZoomController::FromWebContents(web_contents); |
| + return zoomController && zoomController->IsAtDefaultZoom(); |
| +} |
| - const NSRect draw_frame = GetDrawRectInFrame(frame); |
| - return NSMakePoint(NSMidX(draw_frame), NSMaxY(draw_frame)); |
| +bool ZoomDecoration::ShouldShowDecoration() const { |
| + if (owner_->toolbar_model()->GetInputInProgress()) |
| + return false; |
| + if (bubble_) |
| + return true; |
| + return !IsAtDefaultZoom(); |
| } |
| bool ZoomDecoration::AcceptsMousePress() { |