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_bubble_view.h" | 5 #include "chrome/browser/ui/views/location_bar/zoom_bubble_view.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "grit/generated_resources.h" | 9 #include "grit/generated_resources.h" |
10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 void ZoomBubbleView::CloseBubble() { | 57 void ZoomBubbleView::CloseBubble() { |
58 if (zoom_bubble_) | 58 if (zoom_bubble_) |
59 zoom_bubble_->Close(); | 59 zoom_bubble_->Close(); |
60 } | 60 } |
61 | 61 |
62 // static | 62 // static |
63 bool ZoomBubbleView::IsShowing() { | 63 bool ZoomBubbleView::IsShowing() { |
64 return zoom_bubble_ != NULL; | 64 return zoom_bubble_ != NULL; |
65 } | 65 } |
66 | 66 |
67 void ZoomBubbleView::WindowClosing() { | 67 ZoomBubbleView::ZoomBubbleView(views::View* anchor_view, |
68 DCHECK(zoom_bubble_ == this); | 68 int zoom_percent, |
69 zoom_bubble_ = NULL; | 69 bool auto_close) |
| 70 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), |
| 71 label_(NULL), |
| 72 zoom_percent_(zoom_percent), |
| 73 auto_close_(auto_close) { |
| 74 set_use_focusless(auto_close); |
| 75 } |
| 76 |
| 77 ZoomBubbleView::~ZoomBubbleView() { |
| 78 } |
| 79 |
| 80 void ZoomBubbleView::Close() { |
| 81 GetWidget()->Close(); |
70 } | 82 } |
71 | 83 |
72 void ZoomBubbleView::Init() { | 84 void ZoomBubbleView::Init() { |
73 SetLayoutManager(new views::FillLayout()); | 85 SetLayoutManager(new views::FillLayout()); |
74 label_ = new views::Label( | 86 label_ = new views::Label( |
75 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom_percent_)); | 87 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, zoom_percent_)); |
76 AddChildView(label_); | 88 AddChildView(label_); |
77 | 89 |
78 if (auto_close_) { | 90 if (auto_close_) { |
79 timer_.Start( | 91 timer_.Start( |
80 FROM_HERE, | 92 FROM_HERE, |
81 base::TimeDelta::FromMilliseconds(kBubbleCloseDelay), | 93 base::TimeDelta::FromMilliseconds(kBubbleCloseDelay), |
82 this, | 94 this, |
83 &ZoomBubbleView::Close); | 95 &ZoomBubbleView::Close); |
84 } | 96 } |
85 } | 97 } |
86 | 98 |
87 ZoomBubbleView::ZoomBubbleView(views::View* anchor_view, | 99 void ZoomBubbleView::WindowClosing() { |
88 int zoom_percent, | 100 DCHECK(zoom_bubble_ == this); |
89 bool auto_close) | 101 zoom_bubble_ = NULL; |
90 : BubbleDelegateView(anchor_view, views::BubbleBorder::TOP_RIGHT), | |
91 zoom_percent_(zoom_percent), | |
92 auto_close_(auto_close) { | |
93 set_use_focusless(auto_close); | |
94 } | 102 } |
95 | |
96 ZoomBubbleView::~ZoomBubbleView() { | |
97 } | |
98 | |
99 void ZoomBubbleView::Close() { | |
100 GetWidget()->Close(); | |
101 } | |
OLD | NEW |