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/number_formatting.h" |
7 #include "base/i18n/rtl.h" | 8 #include "base/i18n/rtl.h" |
8 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
9 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
10 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
12 #include "chrome/browser/ui/browser_tabstrip.h" | 13 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
14 #include "chrome/browser/ui/views/frame/browser_view.h" | 15 #include "chrome/browser/ui/views/frame/browser_view.h" |
15 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 16 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
16 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 17 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 base::UTF8ToUTF16(extension_info_.name))); | 170 base::UTF8ToUTF16(extension_info_.name))); |
170 image_button_->SetImage(views::Button::STATE_NORMAL, | 171 image_button_->SetImage(views::Button::STATE_NORMAL, |
171 &extension_info_.icon_image->image_skia()); | 172 &extension_info_.icon_image->image_skia()); |
172 grid_layout->AddView(image_button_); | 173 grid_layout->AddView(image_button_); |
173 } | 174 } |
174 | 175 |
175 // Add zoom label with the new zoom percent. | 176 // Add zoom label with the new zoom percent. |
176 ui_zoom::ZoomController* zoom_controller = | 177 ui_zoom::ZoomController* zoom_controller = |
177 ui_zoom::ZoomController::FromWebContents(web_contents_); | 178 ui_zoom::ZoomController::FromWebContents(web_contents_); |
178 int zoom_percent = zoom_controller->GetZoomPercent(); | 179 int zoom_percent = zoom_controller->GetZoomPercent(); |
179 label_ = new views::Label( | 180 label_ = new views::Label(l10n_util::GetStringFUTF16( |
180 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); | 181 IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); |
181 label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( | 182 label_->SetFontList(ui::ResourceBundle::GetSharedInstance().GetFontList( |
182 ui::ResourceBundle::MediumFont)); | 183 ui::ResourceBundle::MediumFont)); |
183 grid_layout->AddView(label_); | 184 grid_layout->AddView(label_); |
184 | 185 |
185 // Second row. | 186 // Second row. |
186 grid_layout->AddPaddingRow(0, 8); | 187 grid_layout->AddPaddingRow(0, 8); |
187 columns = grid_layout->AddColumnSet(1); | 188 columns = grid_layout->AddColumnSet(1); |
188 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 189 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
189 views::GridLayout::USE_PREF, 0, 0); | 190 views::GridLayout::USE_PREF, 0, 0); |
190 grid_layout->StartRow(0, 1); | 191 grid_layout->StartRow(0, 1); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 extensions::IconImage* /* image */) { | 239 extensions::IconImage* /* image */) { |
239 image_button_->SetImage(views::Button::STATE_NORMAL, | 240 image_button_->SetImage(views::Button::STATE_NORMAL, |
240 &extension_info_.icon_image->image_skia()); | 241 &extension_info_.icon_image->image_skia()); |
241 image_button_->SchedulePaint(); | 242 image_button_->SchedulePaint(); |
242 } | 243 } |
243 | 244 |
244 void ZoomBubbleView::Refresh() { | 245 void ZoomBubbleView::Refresh() { |
245 ui_zoom::ZoomController* zoom_controller = | 246 ui_zoom::ZoomController* zoom_controller = |
246 ui_zoom::ZoomController::FromWebContents(web_contents_); | 247 ui_zoom::ZoomController::FromWebContents(web_contents_); |
247 int zoom_percent = zoom_controller->GetZoomPercent(); | 248 int zoom_percent = zoom_controller->GetZoomPercent(); |
248 label_->SetText( | 249 label_->SetText(l10n_util::GetStringFUTF16( |
249 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); | 250 IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); |
250 StartTimerIfNecessary(); | 251 StartTimerIfNecessary(); |
251 } | 252 } |
252 | 253 |
253 void ZoomBubbleView::SetExtensionInfo(const extensions::Extension* extension) { | 254 void ZoomBubbleView::SetExtensionInfo(const extensions::Extension* extension) { |
254 DCHECK(extension); | 255 DCHECK(extension); |
255 extension_info_.id = extension->id(); | 256 extension_info_.id = extension->id(); |
256 extension_info_.name = extension->name(); | 257 extension_info_.name = extension->name(); |
257 | 258 |
258 ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 259 ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
259 const gfx::ImageSkia& default_extension_icon_image = | 260 const gfx::ImageSkia& default_extension_icon_image = |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 311 } |
311 } | 312 } |
312 | 313 |
313 void ZoomBubbleView::StopTimer() { | 314 void ZoomBubbleView::StopTimer() { |
314 timer_.Stop(); | 315 timer_.Stop(); |
315 } | 316 } |
316 | 317 |
317 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} | 318 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} |
318 | 319 |
319 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} | 320 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} |
OLD | NEW |