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

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

Issue 2891883002: Revert of Updates Zoom bubble layout and adds +/- buttons (Closed)
Patch Set: Created 3 years, 7 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
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/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/strings/string16.h" 8 #include "base/strings/string16.h"
9 #include "base/strings/string_number_conversions.h" 9 #include "base/strings/string_number_conversions.h"
10 #include "chrome/app/chrome_command_ids.h" 10 #include "chrome/app/chrome_command_ids.h"
(...skipping 30 matching lines...) Expand all
41 bool location_bar_is_dark) { 41 bool location_bar_is_dark) {
42 if (!ShouldShowDecoration()) { 42 if (!ShouldShowDecoration()) {
43 if (!IsVisible() && !IsBubbleShown()) 43 if (!IsVisible() && !IsBubbleShown())
44 return false; 44 return false;
45 45
46 HideUI(); 46 HideUI();
47 return true; 47 return true;
48 } 48 }
49 49
50 BOOL old_visibility = IsVisible(); 50 BOOL old_visibility = IsVisible();
51 SetVisible(true); 51 SetVisible(ShouldShowDecoration() && !zoom_controller->IsAtDefaultZoom());
52 52
53 base::string16 zoom_percent = 53 base::string16 zoom_percent =
54 base::FormatPercent(zoom_controller->GetZoomPercent()); 54 base::FormatPercent(zoom_controller->GetZoomPercent());
55 // There is no icon at the default zoom factor (100%), so don't display a 55 // There is no icon at the default zoom factor (100%), so don't display a
56 // tooltip either. 56 // tooltip either.
57 NSString* tooltip_string = 57 NSString* tooltip_string =
58 zoom_controller->IsAtDefaultZoom() 58 zoom_controller->IsAtDefaultZoom()
59 ? @"" 59 ? @""
60 : l10n_util::GetNSStringF(IDS_TOOLTIP_ZOOM, zoom_percent); 60 : l10n_util::GetNSStringF(IDS_TOOLTIP_ZOOM, zoom_percent);
61 61
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 } 120 }
121 121
122 void ZoomDecoration::HideUI() { 122 void ZoomDecoration::HideUI() {
123 CloseBubble(); 123 CloseBubble();
124 SetVisible(false); 124 SetVisible(false);
125 } 125 }
126 126
127 void ZoomDecoration::UpdateUI(zoom::ZoomController* zoom_controller, 127 void ZoomDecoration::UpdateUI(zoom::ZoomController* zoom_controller,
128 NSString* tooltip_string, 128 NSString* tooltip_string,
129 bool location_bar_is_dark) { 129 bool location_bar_is_dark) {
130 vector_icon_ = zoom_controller->GetZoomRelativeToDefault() == 130 vector_icon_ = nullptr;
131 zoom::ZoomController::ZOOM_BELOW_DEFAULT_ZOOM 131 zoom::ZoomController::RelativeZoom relative_zoom =
132 ? &kZoomMinusIcon 132 zoom_controller->GetZoomRelativeToDefault();
133 : &kZoomPlusIcon; 133 // There is no icon at the default zoom factor.
134 if (relative_zoom == zoom::ZoomController::ZOOM_BELOW_DEFAULT_ZOOM) {
135 vector_icon_ = &kZoomMinusIcon;
136 } else if (relative_zoom == zoom::ZoomController::ZOOM_ABOVE_DEFAULT_ZOOM) {
137 vector_icon_ = &kZoomPlusIcon;
138 }
134 139
135 SetImage(GetMaterialIcon(location_bar_is_dark)); 140 SetImage(GetMaterialIcon(location_bar_is_dark));
136 141
137 tooltip_.reset([tooltip_string retain]); 142 tooltip_.reset([tooltip_string retain]);
138 143
139 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) 144 if (ui::MaterialDesignController::IsSecondaryUiMaterial())
140 chrome::RefreshZoomBubbleViews(); 145 chrome::RefreshZoomBubbleViews();
141 else 146 else
142 [bubble_ onZoomChanged]; 147 [bubble_ onZoomChanged];
143 } 148 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // closed the decoration can be hidden. 212 // closed the decoration can be hidden.
208 if (IsAtDefaultZoom() && IsVisible()) { 213 if (IsAtDefaultZoom() && IsVisible()) {
209 SetVisible(false); 214 SetVisible(false);
210 owner_->OnDecorationsChanged(); 215 owner_->OnDecorationsChanged();
211 } 216 }
212 } 217 }
213 218
214 const gfx::VectorIcon* ZoomDecoration::GetMaterialVectorIcon() const { 219 const gfx::VectorIcon* ZoomDecoration::GetMaterialVectorIcon() const {
215 return vector_icon_; 220 return vector_icon_;
216 } 221 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698