| 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/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 Loading... |
| 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(ShouldShowDecoration() && !zoom_controller->IsAtDefaultZoom()); | 51 SetVisible(true); |
| 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 Loading... |
| 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_ = nullptr; | 130 vector_icon_ = zoom_controller->GetZoomRelativeToDefault() == |
| 131 zoom::ZoomController::RelativeZoom relative_zoom = | 131 zoom::ZoomController::ZOOM_BELOW_DEFAULT_ZOOM |
| 132 zoom_controller->GetZoomRelativeToDefault(); | 132 ? &kZoomMinusIcon |
| 133 // There is no icon at the default zoom factor. | 133 : &kZoomPlusIcon; |
| 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 } | |
| 139 | 134 |
| 140 SetImage(GetMaterialIcon(location_bar_is_dark)); | 135 SetImage(GetMaterialIcon(location_bar_is_dark)); |
| 141 | 136 |
| 142 tooltip_.reset([tooltip_string retain]); | 137 tooltip_.reset([tooltip_string retain]); |
| 143 | 138 |
| 144 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) | 139 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 145 chrome::RefreshZoomBubbleViews(); | 140 chrome::RefreshZoomBubbleViews(); |
| 146 else | 141 else |
| 147 [bubble_ onZoomChanged]; | 142 [bubble_ onZoomChanged]; |
| 148 } | 143 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 // closed the decoration can be hidden. | 207 // closed the decoration can be hidden. |
| 213 if (IsAtDefaultZoom() && IsVisible()) { | 208 if (IsAtDefaultZoom() && IsVisible()) { |
| 214 SetVisible(false); | 209 SetVisible(false); |
| 215 owner_->OnDecorationsChanged(); | 210 owner_->OnDecorationsChanged(); |
| 216 } | 211 } |
| 217 } | 212 } |
| 218 | 213 |
| 219 const gfx::VectorIcon* ZoomDecoration::GetMaterialVectorIcon() const { | 214 const gfx::VectorIcon* ZoomDecoration::GetMaterialVectorIcon() const { |
| 220 return vector_icon_; | 215 return vector_icon_; |
| 221 } | 216 } |
| OLD | NEW |