Chromium Code Reviews| 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); |
| 191 | 192 |
| 192 // Add "Reset to Default" button. | 193 // Add "Reset to Default" button. |
| 193 grid_layout->AddView( | 194 grid_layout->AddView( |
| 194 views::MdTextButton::CreateSecondaryUiButton( | 195 views::MdTextButton::CreateSecondaryUiButton( |
| 195 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT))); | 196 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT))); |
|
Greg Levin
2016/05/18 21:33:44
This is just a merge
| |
| 196 | 197 |
| 197 StartTimerIfNecessary(); | 198 StartTimerIfNecessary(); |
| 198 } | 199 } |
| 199 | 200 |
| 200 void ZoomBubbleView::WindowClosing() { | 201 void ZoomBubbleView::WindowClosing() { |
| 201 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't | 202 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
| 202 // call this right away). Only set to NULL when it's this bubble. | 203 // call this right away). Only set to NULL when it's this bubble. |
| 203 if (zoom_bubble_ == this) | 204 if (zoom_bubble_ == this) |
| 204 zoom_bubble_ = NULL; | 205 zoom_bubble_ = NULL; |
| 205 } | 206 } |
| (...skipping 32 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 |