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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/zoom_decoration.mm

Issue 867183006: Revert of Allow new zoom bubble to override current one. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/zoom_decoration.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" 11 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h"
12 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" 12 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h"
13 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h" 13 #import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
14 #include "chrome/grit/generated_resources.h" 14 #include "chrome/grit/generated_resources.h"
15 #include "components/ui/zoom/zoom_controller.h" 15 #include "components/ui/zoom/zoom_controller.h"
16 #include "grit/theme_resources.h" 16 #include "grit/theme_resources.h"
17 #include "ui/base/l10n/l10n_util_mac.h" 17 #include "ui/base/l10n/l10n_util_mac.h"
18 18
19 ZoomDecoration::ZoomDecoration(LocationBarViewMac* owner) 19 ZoomDecoration::ZoomDecoration(LocationBarViewMac* owner)
20 : owner_(owner), 20 : owner_(owner),
21 bubble_(nil) { 21 bubble_(nil) {
22 } 22 }
23 23
24 ZoomDecoration::~ZoomDecoration() { 24 ZoomDecoration::~ZoomDecoration() {
25 [bubble_ closeWithoutAnimation]; 25 [bubble_ closeWithoutAnimation];
26 bubble_.delegate = nil;
27 } 26 }
28 27
29 bool ZoomDecoration::UpdateIfNecessary( 28 bool ZoomDecoration::UpdateIfNecessary(
30 ui_zoom::ZoomController* zoom_controller) { 29 ui_zoom::ZoomController* zoom_controller) {
31 if (!ShouldShowDecoration()) { 30 if (!ShouldShowDecoration()) {
32 if (!IsVisible() && !bubble_) 31 if (!IsVisible() && !bubble_)
33 return false; 32 return false;
34 33
35 HideUI(); 34 HideUI();
36 return true; 35 return true;
37 } 36 }
38 37
39 base::string16 zoom_percent = 38 base::string16 zoom_percent =
40 base::IntToString16(zoom_controller->GetZoomPercent()); 39 base::IntToString16(zoom_controller->GetZoomPercent());
41 NSString* zoom_string = 40 NSString* zoom_string =
42 l10n_util::GetNSStringFWithFixup(IDS_TOOLTIP_ZOOM, zoom_percent); 41 l10n_util::GetNSStringFWithFixup(IDS_TOOLTIP_ZOOM, zoom_percent);
43 42
44 if (IsVisible() && [tooltip_ isEqualToString:zoom_string]) 43 if (IsVisible() && [tooltip_ isEqualToString:zoom_string])
45 return false; 44 return false;
46 45
47 ShowAndUpdateUI(zoom_controller, zoom_string); 46 ShowAndUpdateUI(zoom_controller, zoom_string);
48 return true; 47 return true;
49 } 48 }
50 49
51 void ZoomDecoration::ShowBubble(BOOL auto_close) { 50 void ZoomDecoration::ShowBubble(BOOL auto_close) {
52 ZoomBubbleController* old_bubble = bubble_; 51 if (bubble_)
53 old_bubble.delegate = nil; 52 return;
54 53
55 content::WebContents* web_contents = owner_->GetWebContents(); 54 content::WebContents* web_contents = owner_->GetWebContents();
56 if (!web_contents) 55 if (!web_contents)
57 return; 56 return;
58 57
59 // Get the frame of the decoration. 58 // Get the frame of the decoration.
60 AutocompleteTextField* field = owner_->GetAutocompleteTextField(); 59 AutocompleteTextField* field = owner_->GetAutocompleteTextField();
61 const NSRect frame = 60 const NSRect frame =
62 [[field cell] frameForDecoration:this inFrame:[field bounds]]; 61 [[field cell] frameForDecoration:this inFrame:[field bounds]];
63 62
64 // Find point for bubble's arrow in screen coordinates. 63 // Find point for bubble's arrow in screen coordinates.
65 NSPoint anchor = GetBubblePointInFrame(frame); 64 NSPoint anchor = GetBubblePointInFrame(frame);
66 anchor = [field convertPoint:anchor toView:nil]; 65 anchor = [field convertPoint:anchor toView:nil];
67 anchor = [[field window] convertBaseToScreen:anchor]; 66 anchor = [[field window] convertBaseToScreen:anchor];
68 67
69 bubble_ = [[ZoomBubbleController alloc] initWithParentWindow:[field window] 68 bubble_ = [[ZoomBubbleController alloc] initWithParentWindow:[field window]
70 delegate:this]; 69 delegate:this];
71 [bubble_ showAnchoredAt:anchor autoClose:auto_close]; 70 [bubble_ showAnchoredAt:anchor autoClose:auto_close];
72
73 [old_bubble.window orderOut:nil];
74 [old_bubble closeWithoutAnimation];
75 } 71 }
76 72
77 void ZoomDecoration::CloseBubble() { 73 void ZoomDecoration::CloseBubble() {
78 [bubble_ close]; 74 [bubble_ close];
79 } 75 }
80 76
81 void ZoomDecoration::HideUI() { 77 void ZoomDecoration::HideUI() {
82 [bubble_ close]; 78 [bubble_ close];
83 SetVisible(false); 79 SetVisible(false);
84 } 80 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 131
136 NSString* ZoomDecoration::GetToolTip() { 132 NSString* ZoomDecoration::GetToolTip() {
137 return tooltip_.get(); 133 return tooltip_.get();
138 } 134 }
139 135
140 content::WebContents* ZoomDecoration::GetWebContents() { 136 content::WebContents* ZoomDecoration::GetWebContents() {
141 return owner_->GetWebContents(); 137 return owner_->GetWebContents();
142 } 138 }
143 139
144 void ZoomDecoration::OnClose() { 140 void ZoomDecoration::OnClose() {
145 bubble_.delegate = nil;
146 bubble_ = nil; 141 bubble_ = nil;
147 142
148 // If the page is at default zoom then hiding the zoom decoration 143 // If the page is at default zoom then hiding the zoom decoration
149 // was suppressed while the bubble was open. Now that the bubble is 144 // was suppressed while the bubble was open. Now that the bubble is
150 // closed the decoration can be hidden. 145 // closed the decoration can be hidden.
151 if (IsAtDefaultZoom() && IsVisible()) { 146 if (IsAtDefaultZoom() && IsVisible()) {
152 SetVisible(false); 147 SetVisible(false);
153 owner_->OnDecorationsChanged(); 148 owner_->OnDecorationsChanged();
154 } 149 }
155 } 150 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/zoom_decoration.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698