Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" | 5 #import "chrome/browser/ui/cocoa/location_bar/zoom_decoration.h" |
| 6 | 6 |
| 7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
| 8 #include "base/strings/string_number_conversions.h" | 8 #include "base/strings/string_number_conversions.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 l10n_util::GetNSStringFWithFixup(IDS_TOOLTIP_ZOOM, zoom_percent); | 41 l10n_util::GetNSStringFWithFixup(IDS_TOOLTIP_ZOOM, zoom_percent); |
| 42 | 42 |
| 43 if (IsVisible() && [tooltip_ isEqualToString:zoom_string]) | 43 if (IsVisible() && [tooltip_ isEqualToString:zoom_string]) |
| 44 return false; | 44 return false; |
| 45 | 45 |
| 46 ShowAndUpdateUI(zoom_controller, zoom_string); | 46 ShowAndUpdateUI(zoom_controller, zoom_string); |
| 47 return true; | 47 return true; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void ZoomDecoration::ShowBubble(BOOL auto_close) { | 50 void ZoomDecoration::ShowBubble(BOOL auto_close) { |
| 51 if (bubble_) | |
| 52 return; | |
| 53 | |
| 54 content::WebContents* web_contents = owner_->GetWebContents(); | 51 content::WebContents* web_contents = owner_->GetWebContents(); |
| 55 if (!web_contents) | 52 if (!web_contents) |
| 56 return; | 53 return; |
| 57 | 54 |
| 58 // Get the frame of the decoration. | 55 // Get the frame of the decoration. |
| 59 AutocompleteTextField* field = owner_->GetAutocompleteTextField(); | 56 AutocompleteTextField* field = owner_->GetAutocompleteTextField(); |
| 60 const NSRect frame = | 57 const NSRect frame = |
| 61 [[field cell] frameForDecoration:this inFrame:[field bounds]]; | 58 [[field cell] frameForDecoration:this inFrame:[field bounds]]; |
| 62 | 59 |
| 63 // Find point for bubble's arrow in screen coordinates. | 60 // Find point for bubble's arrow in screen coordinates. |
| 64 NSPoint anchor = GetBubblePointInFrame(frame); | 61 NSPoint anchor = GetBubblePointInFrame(frame); |
| 65 anchor = [field convertPoint:anchor toView:nil]; | 62 anchor = [field convertPoint:anchor toView:nil]; |
| 66 anchor = [[field window] convertBaseToScreen:anchor]; | 63 anchor = [[field window] convertBaseToScreen:anchor]; |
| 67 | 64 |
| 68 bubble_ = [[ZoomBubbleController alloc] initWithParentWindow:[field window] | 65 bubble_ = [[ZoomBubbleController alloc] initWithParentWindow:[field window] |
|
sky
2015/01/22 20:40:56
This seems like you're going to end up with two bu
| |
| 69 delegate:this]; | 66 delegate:this]; |
| 70 [bubble_ showAnchoredAt:anchor autoClose:auto_close]; | 67 [bubble_ showAnchoredAt:anchor autoClose:auto_close]; |
| 71 } | 68 } |
| 72 | 69 |
| 73 void ZoomDecoration::CloseBubble() { | 70 void ZoomDecoration::CloseBubble() { |
| 74 [bubble_ close]; | 71 [bubble_ close]; |
| 75 } | 72 } |
| 76 | 73 |
| 77 void ZoomDecoration::HideUI() { | 74 void ZoomDecoration::HideUI() { |
| 78 [bubble_ close]; | 75 [bubble_ close]; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 141 bubble_ = nil; | 138 bubble_ = nil; |
| 142 | 139 |
| 143 // If the page is at default zoom then hiding the zoom decoration | 140 // If the page is at default zoom then hiding the zoom decoration |
| 144 // was suppressed while the bubble was open. Now that the bubble is | 141 // was suppressed while the bubble was open. Now that the bubble is |
| 145 // closed the decoration can be hidden. | 142 // closed the decoration can be hidden. |
| 146 if (IsAtDefaultZoom() && IsVisible()) { | 143 if (IsAtDefaultZoom() && IsVisible()) { |
| 147 SetVisible(false); | 144 SetVisible(false); |
| 148 owner_->OnDecorationsChanged(); | 145 owner_->OnDecorationsChanged(); |
| 149 } | 146 } |
| 150 } | 147 } |
| OLD | NEW |