| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 extensions::IconImage* /* image */) { | 240 extensions::IconImage* /* image */) { |
| 240 image_button_->SetImage(views::Button::STATE_NORMAL, | 241 image_button_->SetImage(views::Button::STATE_NORMAL, |
| 241 &extension_info_.icon_image->image_skia()); | 242 &extension_info_.icon_image->image_skia()); |
| 242 image_button_->SchedulePaint(); | 243 image_button_->SchedulePaint(); |
| 243 } | 244 } |
| 244 | 245 |
| 245 void ZoomBubbleView::Refresh() { | 246 void ZoomBubbleView::Refresh() { |
| 246 ui_zoom::ZoomController* zoom_controller = | 247 ui_zoom::ZoomController* zoom_controller = |
| 247 ui_zoom::ZoomController::FromWebContents(web_contents_); | 248 ui_zoom::ZoomController::FromWebContents(web_contents_); |
| 248 int zoom_percent = zoom_controller->GetZoomPercent(); | 249 int zoom_percent = zoom_controller->GetZoomPercent(); |
| 249 label_->SetText( | 250 label_->SetText(l10n_util::GetStringFUTF16( |
| 250 l10n_util::GetStringFUTF16Int(IDS_TOOLTIP_ZOOM, zoom_percent)); | 251 IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); |
| 251 StartTimerIfNecessary(); | 252 StartTimerIfNecessary(); |
| 252 } | 253 } |
| 253 | 254 |
| 254 void ZoomBubbleView::SetExtensionInfo(const extensions::Extension* extension) { | 255 void ZoomBubbleView::SetExtensionInfo(const extensions::Extension* extension) { |
| 255 DCHECK(extension); | 256 DCHECK(extension); |
| 256 extension_info_.id = extension->id(); | 257 extension_info_.id = extension->id(); |
| 257 extension_info_.name = extension->name(); | 258 extension_info_.name = extension->name(); |
| 258 | 259 |
| 259 ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 260 ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 260 const gfx::ImageSkia& default_extension_icon_image = | 261 const gfx::ImageSkia& default_extension_icon_image = |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 312 } |
| 312 } | 313 } |
| 313 | 314 |
| 314 void ZoomBubbleView::StopTimer() { | 315 void ZoomBubbleView::StopTimer() { |
| 315 timer_.Stop(); | 316 timer_.Stop(); |
| 316 } | 317 } |
| 317 | 318 |
| 318 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} | 319 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} |
| 319 | 320 |
| 320 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} | 321 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} |
| OLD | NEW |