| 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 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 5 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
| 6 | 6 |
| 7 #include "base/i18n/number_formatting.h" | 7 #include "base/i18n/number_formatting.h" |
| 8 #include "chrome/app/vector_icons/vector_icons.h" | 8 #include "chrome/app/vector_icons/vector_icons.h" |
| 9 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
| 10 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 10 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| 11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 12 #include "components/toolbar/toolbar_model.h" | 12 #include "components/toolbar/toolbar_model.h" |
| 13 #include "components/zoom/zoom_controller.h" | 13 #include "components/zoom/zoom_controller.h" |
| 14 #include "ui/accessibility/ax_node_data.h" | 14 #include "ui/accessibility/ax_node_data.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/events/event.h" | 16 #include "ui/events/event.h" |
| 17 #include "ui/gfx/geometry/size.h" | 17 #include "ui/gfx/geometry/size.h" |
| 18 | 18 |
| 19 ZoomView::ZoomView(LocationBarView::Delegate* location_bar_delegate) | 19 ZoomView::ZoomView(LocationBarView::Delegate* location_bar_delegate) |
| 20 : BubbleIconView(nullptr, 0), | 20 : BubbleIconView(nullptr, 0), |
| 21 location_bar_delegate_(location_bar_delegate), | 21 location_bar_delegate_(location_bar_delegate), |
| 22 icon_(&kZoomMinusIcon) { | 22 icon_(&kZoomMinusIcon) { |
| 23 Update(nullptr); | 23 Update(nullptr); |
| 24 } | 24 } |
| 25 | 25 |
| 26 ZoomView::~ZoomView() { | 26 ZoomView::~ZoomView() { |
| 27 } | 27 } |
| 28 | 28 |
| 29 void ZoomView::Update(zoom::ZoomController* zoom_controller) { | 29 void ZoomView::Update(zoom::ZoomController* zoom_controller) { |
| 30 if (!zoom_controller || | 30 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || |
| 31 (!ZoomBubbleView::GetZoomBubble() && | |
| 32 zoom_controller->IsAtDefaultZoom()) || | |
| 33 location_bar_delegate_->GetToolbarModel()->input_in_progress()) { | 31 location_bar_delegate_->GetToolbarModel()->input_in_progress()) { |
| 34 SetVisible(false); | 32 SetVisible(false); |
| 35 ZoomBubbleView::CloseCurrentBubble(); | 33 ZoomBubbleView::CloseCurrentBubble(); |
| 36 return; | 34 return; |
| 37 } | 35 } |
| 38 | 36 |
| 39 SetTooltipText(l10n_util::GetStringFUTF16( | 37 SetTooltipText(l10n_util::GetStringFUTF16( |
| 40 IDS_TOOLTIP_ZOOM, | 38 IDS_TOOLTIP_ZOOM, |
| 41 base::FormatPercent(zoom_controller->GetZoomPercent()))); | 39 base::FormatPercent(zoom_controller->GetZoomPercent()))); |
| 42 | 40 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 61 node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_ZOOM)); | 59 node_data->SetName(l10n_util::GetStringUTF8(IDS_ACCNAME_ZOOM)); |
| 62 } | 60 } |
| 63 | 61 |
| 64 views::BubbleDialogDelegateView* ZoomView::GetBubble() const { | 62 views::BubbleDialogDelegateView* ZoomView::GetBubble() const { |
| 65 return ZoomBubbleView::GetZoomBubble(); | 63 return ZoomBubbleView::GetZoomBubble(); |
| 66 } | 64 } |
| 67 | 65 |
| 68 const gfx::VectorIcon& ZoomView::GetVectorIcon() const { | 66 const gfx::VectorIcon& ZoomView::GetVectorIcon() const { |
| 69 return *icon_; | 67 return *icon_; |
| 70 } | 68 } |
| OLD | NEW |