Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / views / location_bar / zoom_view.cc
blob05c3a24a1bd399ed28732c9d4b619f526a590121
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/location_bar/zoom_view.h"
7 #include "chrome/browser/ui/view_ids.h"
8 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h"
9 #include "chrome/grit/generated_resources.h"
10 #include "components/toolbar/toolbar_model.h"
11 #include "components/ui/zoom/zoom_controller.h"
12 #include "grit/theme_resources.h"
13 #include "ui/accessibility/ax_view_state.h"
14 #include "ui/base/l10n/l10n_util.h"
15 #include "ui/base/resource/resource_bundle.h"
16 #include "ui/events/event.h"
17 #include "ui/gfx/geometry/size.h"
19 ZoomView::ZoomView(LocationBarView::Delegate* location_bar_delegate)
20 : BubbleIconView(nullptr, 0),
21 location_bar_delegate_(location_bar_delegate) {
22 Update(NULL);
25 ZoomView::~ZoomView() {
28 void ZoomView::Update(ui_zoom::ZoomController* zoom_controller) {
29 if (!zoom_controller || zoom_controller->IsAtDefaultZoom() ||
30 location_bar_delegate_->GetToolbarModel()->input_in_progress()) {
31 SetVisible(false);
32 ZoomBubbleView::CloseBubble();
33 return;
36 SetTooltipText(l10n_util::GetStringFUTF16Int(
37 IDS_TOOLTIP_ZOOM, zoom_controller->GetZoomPercent()));
38 int image_id = IDR_ZOOM_NORMAL;
39 ui_zoom::ZoomController::RelativeZoom relative_zoom =
40 zoom_controller->GetZoomRelativeToDefault();
41 if (relative_zoom == ui_zoom::ZoomController::ZOOM_BELOW_DEFAULT_ZOOM)
42 image_id = IDR_ZOOM_MINUS;
43 else if (relative_zoom == ui_zoom::ZoomController::ZOOM_ABOVE_DEFAULT_ZOOM)
44 image_id = IDR_ZOOM_PLUS;
46 SetImage(ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(image_id));
47 SetVisible(true);
50 void ZoomView::OnExecuting(BubbleIconView::ExecuteSource source) {
51 ZoomBubbleView::ShowBubble(location_bar_delegate_->GetWebContents(), false);
54 void ZoomView::GetAccessibleState(ui::AXViewState* state) {
55 BubbleIconView::GetAccessibleState(state);
56 state->name = l10n_util::GetStringUTF16(IDS_ACCNAME_ZOOM);
59 views::BubbleDelegateView* ZoomView::GetBubble() const {
60 return ZoomBubbleView::GetZoomBubble();