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/i18n/rtl.h" | 7 #include "base/i18n/rtl.h" |
8 #include "chrome/browser/chrome_page_zoom.h" | 8 #include "chrome/browser/chrome_page_zoom.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
11 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
12 #include "chrome/browser/ui/views/frame/browser_view.h" | 12 #include "chrome/browser/ui/views/frame/browser_view.h" |
13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 13 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
14 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 14 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
15 #include "chrome/browser/ui/zoom/zoom_controller.h" | 15 #include "chrome/browser/ui/zoom/zoom_controller.h" |
16 #include "chrome/common/chrome_notification_types.h" | 16 #include "chrome/common/chrome_notification_types.h" |
17 #include "content/public/browser/notification_source.h" | 17 #include "content/public/browser/notification_source.h" |
18 #include "content/public/browser/web_contents_view.h" | 18 #include "content/public/browser/web_contents_view.h" |
19 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 21 #include "ui/base/resource/resource_bundle.h" |
22 #include "ui/views/controls/button/label_button.h" | |
22 #include "ui/views/controls/separator.h" | 23 #include "ui/views/controls/separator.h" |
23 #include "ui/views/layout/box_layout.h" | 24 #include "ui/views/layout/box_layout.h" |
24 #include "ui/views/layout/layout_constants.h" | 25 #include "ui/views/layout/layout_constants.h" |
25 #include "ui/views/widget/widget.h" | 26 #include "ui/views/widget/widget.h" |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 // The number of milliseconds the bubble should stay on the screen if it will | 30 // The number of milliseconds the bubble should stay on the screen if it will |
30 // close automatically. | 31 // close automatically. |
31 const int kBubbleCloseDelay = 1500; | 32 const int kBubbleCloseDelay = 1500; |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
194 | 195 |
195 ZoomController* zoom_controller = | 196 ZoomController* zoom_controller = |
196 ZoomController::FromWebContents(web_contents_); | 197 ZoomController::FromWebContents(web_contents_); |
197 int zoom_percent = zoom_controller->zoom_percent(); | 198 int zoom_percent = zoom_controller->zoom_percent(); |
198 label_ = new views::Label( | 199 label_ = new views::Label( |
199 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); | 200 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); |
200 label_->SetFont( | 201 label_->SetFont( |
201 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); | 202 ResourceBundle::GetSharedInstance().GetFont(ResourceBundle::MediumFont)); |
202 AddChildView(label_); | 203 AddChildView(label_); |
203 | 204 |
204 views::NativeTextButton* set_default_button = new views::NativeTextButton( | 205 views::LabelButton* set_default_button = new views::LabelButton( |
205 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT)); | 206 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT)); |
206 set_default_button->set_alignment(views::TextButtonBase::ALIGN_CENTER); | 207 set_default_button->SetHorizontalAlignment(gfx::ALIGN_CENTER); |
msw
2013/04/04 02:31:03
Add set_default_button->SetStyle(views::Button::ST
tfarina
2013/04/04 22:36:52
Done.
| |
207 AddChildView(set_default_button); | 208 AddChildView(set_default_button); |
208 | 209 |
209 StartTimerIfNecessary(); | 210 StartTimerIfNecessary(); |
210 } | 211 } |
211 | 212 |
212 void ZoomBubbleView::Observe(int type, | 213 void ZoomBubbleView::Observe(int type, |
213 const content::NotificationSource& source, | 214 const content::NotificationSource& source, |
214 const content::NotificationDetails& details) { | 215 const content::NotificationDetails& details) { |
215 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); | 216 DCHECK_EQ(type, chrome::NOTIFICATION_FULLSCREEN_CHANGED); |
216 CloseBubble(); | 217 CloseBubble(); |
217 } | 218 } |
218 | 219 |
219 void ZoomBubbleView::WindowClosing() { | 220 void ZoomBubbleView::WindowClosing() { |
220 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't | 221 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
221 // call this right away). Only set to NULL when it's this bubble. | 222 // call this right away). Only set to NULL when it's this bubble. |
222 if (zoom_bubble_ == this) | 223 if (zoom_bubble_ == this) |
223 zoom_bubble_ = NULL; | 224 zoom_bubble_ = NULL; |
224 } | 225 } |
OLD | NEW |