| 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 "chrome/browser/ui/view_ids.h" | 7 #include "chrome/browser/ui/view_ids.h" |
| 8 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" | 8 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
| 9 #include "chrome/grit/generated_resources.h" | 9 #include "chrome/grit/generated_resources.h" |
| 10 #include "components/toolbar/toolbar_model.h" | 10 #include "components/toolbar/toolbar_model.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 Update(NULL); | 22 Update(NULL); |
| 23 } | 23 } |
| 24 | 24 |
| 25 ZoomView::~ZoomView() { | 25 ZoomView::~ZoomView() { |
| 26 } | 26 } |
| 27 | 27 |
| 28 void ZoomView::Update(ui_zoom::ZoomController* zoom_controller) { | 28 void ZoomView::Update(ui_zoom::ZoomController* zoom_controller) { |
| 29 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || | 29 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() || |
| 30 location_bar_delegate_->GetToolbarModel()->input_in_progress()) { | 30 location_bar_delegate_->GetToolbarModel()->input_in_progress()) { |
| 31 SetVisible(false); | 31 SetVisible(false); |
| 32 ZoomBubbleView::CloseBubble(); | 32 ZoomBubbleView::CloseCurrentBubble(); |
| 33 return; | 33 return; |
| 34 } | 34 } |
| 35 | 35 |
| 36 SetTooltipText(l10n_util::GetStringFUTF16Int( | 36 SetTooltipText(l10n_util::GetStringFUTF16Int( |
| 37 IDS_TOOLTIP_ZOOM, zoom_controller->GetZoomPercent())); | 37 IDS_TOOLTIP_ZOOM, zoom_controller->GetZoomPercent())); |
| 38 | 38 |
| 39 // The icon is hidden when the zoom level is default. | 39 // The icon is hidden when the zoom level is default. |
| 40 image_id_ = zoom_controller->GetZoomRelativeToDefault() == | 40 image_id_ = zoom_controller->GetZoomRelativeToDefault() == |
| 41 ui_zoom::ZoomController::ZOOM_BELOW_DEFAULT_ZOOM | 41 ui_zoom::ZoomController::ZOOM_BELOW_DEFAULT_ZOOM |
| 42 ? gfx::VectorIconId::ZOOM_MINUS | 42 ? gfx::VectorIconId::ZOOM_MINUS |
| 43 : gfx::VectorIconId::ZOOM_PLUS; | 43 : gfx::VectorIconId::ZOOM_PLUS; |
| 44 if (GetNativeTheme()) | 44 if (GetNativeTheme()) |
| 45 UpdateIcon(); | 45 UpdateIcon(); |
| 46 | 46 |
| 47 SetVisible(true); | 47 SetVisible(true); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void ZoomView::OnExecuting(BubbleIconView::ExecuteSource source) { | 50 void ZoomView::OnExecuting(BubbleIconView::ExecuteSource source) { |
| 51 ZoomBubbleView::ShowBubble(location_bar_delegate_->GetWebContents(), | 51 ZoomBubbleView::ShowBubble(location_bar_delegate_->GetWebContents(), |
| 52 ZoomBubbleView::USER_GESTURE); | 52 ZoomBubbleView::USER_GESTURE); |
| 53 } | 53 } |
| 54 | 54 |
| 55 void ZoomView::GetAccessibleState(ui::AXViewState* state) { | 55 void ZoomView::GetAccessibleState(ui::AXViewState* state) { |
| 56 BubbleIconView::GetAccessibleState(state); | 56 BubbleIconView::GetAccessibleState(state); |
| 57 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_ZOOM); | 57 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_ZOOM); |
| 58 } | 58 } |
| 59 | 59 |
| 60 views::BubbleDelegateView* ZoomView::GetBubble() const { | 60 views::BubbleDialogDelegateView* ZoomView::GetBubble() const { |
| 61 return ZoomBubbleView::GetZoomBubble(); | 61 return ZoomBubbleView::GetZoomBubble(); |
| 62 } | 62 } |
| 63 | 63 |
| 64 gfx::VectorIconId ZoomView::GetVectorIcon() const { | 64 gfx::VectorIconId ZoomView::GetVectorIcon() const { |
| 65 return image_id_; | 65 return image_id_; |
| 66 } | 66 } |
| OLD | NEW |