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 <cmath> | |
8 | |
9 #include "base/auto_reset.h" | |
7 #include "base/i18n/number_formatting.h" | 10 #include "base/i18n/number_formatting.h" |
8 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
9 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "chrome/app/vector_icons/vector_icons.h" | |
10 #include "chrome/browser/chrome_notification_types.h" | 14 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/platform_util.h" | 15 #include "chrome/browser/platform_util.h" |
12 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/browser_finder.h" | 17 #include "chrome/browser/ui/browser_finder.h" |
14 #include "chrome/browser/ui/browser_tabstrip.h" | 18 #include "chrome/browser/ui/browser_tabstrip.h" |
15 #include "chrome/browser/ui/browser_window.h" | 19 #include "chrome/browser/ui/browser_window.h" |
16 #include "chrome/browser/ui/views/frame/browser_view.h" | 20 #include "chrome/browser/ui/views/frame/browser_view.h" |
21 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | |
17 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 22 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
18 #include "chrome/browser/ui/views/location_bar/zoom_view.h" | 23 #include "chrome/browser/ui/views/location_bar/zoom_view.h" |
19 #include "chrome/common/extensions/api/extension_action/action_info.h" | 24 #include "chrome/common/extensions/api/extension_action/action_info.h" |
20 #include "chrome/grit/generated_resources.h" | 25 #include "chrome/grit/generated_resources.h" |
21 #include "chrome/grit/theme_resources.h" | 26 #include "chrome/grit/theme_resources.h" |
22 #include "components/zoom/page_zoom.h" | 27 #include "components/zoom/page_zoom.h" |
23 #include "components/zoom/zoom_controller.h" | 28 #include "components/zoom/zoom_controller.h" |
24 #include "content/public/browser/notification_source.h" | 29 #include "content/public/browser/notification_source.h" |
25 #include "extensions/browser/extension_zoom_request_client.h" | 30 #include "extensions/browser/extension_zoom_request_client.h" |
26 #include "extensions/common/manifest_handlers/icons_handler.h" | 31 #include "extensions/common/manifest_handlers/icons_handler.h" |
27 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
28 #include "ui/base/material_design/material_design_controller.h" | 33 #include "ui/base/material_design/material_design_controller.h" |
29 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
30 #include "ui/base/ui_features.h" | 35 #include "ui/base/ui_features.h" |
31 #include "ui/gfx/favicon_size.h" | 36 #include "ui/gfx/favicon_size.h" |
37 #include "ui/gfx/text_utils.h" | |
38 #include "ui/gfx/vector_icon_types.h" | |
39 #include "ui/native_theme/native_theme.h" | |
32 #include "ui/views/controls/button/image_button.h" | 40 #include "ui/views/controls/button/image_button.h" |
41 #include "ui/views/controls/button/image_button_factory.h" | |
33 #include "ui/views/controls/button/md_text_button.h" | 42 #include "ui/views/controls/button/md_text_button.h" |
34 #include "ui/views/controls/separator.h" | 43 #include "ui/views/controls/separator.h" |
35 #include "ui/views/layout/grid_layout.h" | 44 #include "ui/views/layout/box_layout.h" |
45 #include "ui/views/layout/fill_layout.h" | |
36 #include "ui/views/layout/layout_constants.h" | 46 #include "ui/views/layout/layout_constants.h" |
37 #include "ui/views/widget/widget.h" | 47 #include "ui/views/widget/widget.h" |
38 | 48 |
49 namespace { | |
50 | |
51 // The default time that the bubble should stay on the screen if it will close | |
52 // automatically. | |
53 constexpr base::TimeDelta kBubbleCloseDelayDefault = | |
54 base::TimeDelta::FromMilliseconds(1500); | |
55 | |
56 // A longer timeout used for how long the bubble should stay on the screen | |
57 // before it will close automatically after + or - buttons have been used. | |
58 constexpr base::TimeDelta kBubbleCloseDelayLong = | |
59 base::TimeDelta::FromMilliseconds(5000); | |
60 | |
61 // Creates an ImageButton using vector |icon|, sets a tooltip with |tooltip_id|. | |
62 // Returns the button. | |
63 std::unique_ptr<views::Button> CreateZoomButton(views::ButtonListener* listener, | |
64 const gfx::VectorIcon& icon, | |
65 int tooltip_id) { | |
66 std::unique_ptr<views::ImageButton> button( | |
67 views::CreateVectorImageButton(listener)); | |
68 views::SetImageFromVectorIcon(button.get(), icon); | |
69 button->SetFocusForPlatform(); | |
70 button->SetTooltipText(l10n_util::GetStringUTF16(tooltip_id)); | |
71 return button; | |
Lei Zhang
2017/05/18 01:59:28
I think you need to std::move(button).
This broke
varkha
2017/05/18 15:04:25
Done.
| |
72 } | |
73 | |
74 class ZoomValue : public views::Label { | |
75 public: | |
76 explicit ZoomValue(const content::WebContents* web_contents) | |
77 : Label(base::string16(), | |
78 views::style::CONTEXT_LABEL, | |
79 views::style::STYLE_PRIMARY), | |
80 max_width_(GetLabelMaxWidth(web_contents)) {} | |
81 ~ZoomValue() override {} | |
82 | |
83 // views::Label: | |
84 gfx::Size GetPreferredSize() const override { | |
85 return gfx::Size(max_width_, GetHeightForWidth(max_width_)); | |
86 } | |
87 | |
88 private: | |
89 int GetLabelMaxWidth(const content::WebContents* web_contents) const { | |
90 int border_width = border() ? border()->GetInsets().width() : 0; | |
91 int max_w = 0; | |
92 auto* zoom_controller = zoom::ZoomController::FromWebContents(web_contents); | |
93 DCHECK(zoom_controller); | |
94 // Enumerate all zoom factors that can be used in PageZoom::Zoom. | |
95 std::vector<double> zoom_factors = | |
96 zoom::PageZoom::PresetZoomFactors(zoom_controller->GetZoomPercent()); | |
97 for (auto zoom : zoom_factors) { | |
98 int w = gfx::GetStringWidth( | |
99 base::FormatPercent(static_cast<int>(std::round(zoom * 100))), | |
100 font_list()); | |
101 max_w = std::max(w, max_w); | |
102 } | |
103 return max_w + border_width; | |
104 } | |
105 | |
106 const int max_width_; | |
107 | |
108 DISALLOW_COPY_AND_ASSIGN(ZoomValue); | |
109 }; | |
110 | |
111 } // namespace | |
112 | |
39 // static | 113 // static |
40 ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = nullptr; | 114 ZoomBubbleView* ZoomBubbleView::zoom_bubble_ = nullptr; |
41 | 115 |
42 // static | 116 // static |
43 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, | 117 void ZoomBubbleView::ShowBubble(content::WebContents* web_contents, |
44 const gfx::Point& anchor_point, | 118 const gfx::Point& anchor_point, |
45 DisplayReason reason) { | 119 DisplayReason reason) { |
46 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 120 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
47 DCHECK(browser && browser->window() && | 121 DCHECK(browser && browser->window() && |
48 browser->exclusive_access_manager()->fullscreen_controller()); | 122 browser->exclusive_access_manager()->fullscreen_controller()); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 zoom_bubble_->set_arrow(views::BubbleBorder::TOP_RIGHT); | 183 zoom_bubble_->set_arrow(views::BubbleBorder::TOP_RIGHT); |
110 zoom_bubble_->set_parent_window(parent); | 184 zoom_bubble_->set_parent_window(parent); |
111 views::BubbleDialogDelegateView::CreateBubble(zoom_bubble_); | 185 views::BubbleDialogDelegateView::CreateBubble(zoom_bubble_); |
112 #endif | 186 #endif |
113 | 187 |
114 // Adjust for fullscreen after creation as it relies on the content size. | 188 // Adjust for fullscreen after creation as it relies on the content size. |
115 if (is_fullscreen) | 189 if (is_fullscreen) |
116 zoom_bubble_->AdjustForFullscreen(browser->window()->GetBounds()); | 190 zoom_bubble_->AdjustForFullscreen(browser->window()->GetBounds()); |
117 | 191 |
118 zoom_bubble_->ShowForReason(reason); | 192 zoom_bubble_->ShowForReason(reason); |
193 zoom_bubble_->UpdateZoomIconVisibility(); | |
119 } | 194 } |
120 | 195 |
121 // static | 196 // static |
122 void ZoomBubbleView::CloseCurrentBubble() { | 197 void ZoomBubbleView::CloseCurrentBubble() { |
123 if (zoom_bubble_) | 198 if (zoom_bubble_) |
124 zoom_bubble_->CloseBubble(); | 199 zoom_bubble_->CloseBubble(); |
125 } | 200 } |
126 | 201 |
127 // static | 202 // static |
128 ZoomBubbleView* ZoomBubbleView::GetZoomBubble() { | 203 ZoomBubbleView* ZoomBubbleView::GetZoomBubble() { |
129 return zoom_bubble_; | 204 return zoom_bubble_; |
130 } | 205 } |
131 | 206 |
132 void ZoomBubbleView::Refresh() { | 207 void ZoomBubbleView::Refresh() { |
133 zoom::ZoomController* zoom_controller = | 208 UpdateZoomPercent(); |
134 zoom::ZoomController::FromWebContents(web_contents_); | |
135 int zoom_percent = zoom_controller->GetZoomPercent(); | |
136 label_->SetText(l10n_util::GetStringFUTF16( | |
137 IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); | |
138 StartTimerIfNecessary(); | 209 StartTimerIfNecessary(); |
139 } | 210 } |
140 | 211 |
141 ZoomBubbleView::ZoomBubbleView( | 212 ZoomBubbleView::ZoomBubbleView( |
142 views::View* anchor_view, | 213 views::View* anchor_view, |
143 const gfx::Point& anchor_point, | 214 const gfx::Point& anchor_point, |
144 content::WebContents* web_contents, | 215 content::WebContents* web_contents, |
145 DisplayReason reason, | 216 DisplayReason reason, |
146 ImmersiveModeController* immersive_mode_controller) | 217 ImmersiveModeController* immersive_mode_controller) |
147 : LocationBarBubbleDelegateView(anchor_view, anchor_point, web_contents), | 218 : LocationBarBubbleDelegateView(anchor_view, anchor_point, web_contents), |
219 auto_close_duration_(kBubbleCloseDelayDefault), | |
148 image_button_(nullptr), | 220 image_button_(nullptr), |
149 label_(nullptr), | 221 label_(nullptr), |
222 zoom_out_button_(nullptr), | |
223 zoom_in_button_(nullptr), | |
224 reset_button_(nullptr), | |
150 web_contents_(web_contents), | 225 web_contents_(web_contents), |
151 auto_close_(reason == AUTOMATIC), | 226 auto_close_(reason == AUTOMATIC), |
227 ignore_close_bubble_(false), | |
152 immersive_mode_controller_(immersive_mode_controller) { | 228 immersive_mode_controller_(immersive_mode_controller) { |
153 set_notify_enter_exit_on_child(true); | 229 set_notify_enter_exit_on_child(true); |
154 if (immersive_mode_controller_) | 230 if (immersive_mode_controller_) |
155 immersive_mode_controller_->AddObserver(this); | 231 immersive_mode_controller_->AddObserver(this); |
156 UseCompactMargins(); | 232 UseCompactMargins(); |
157 } | 233 } |
158 | 234 |
159 ZoomBubbleView::~ZoomBubbleView() { | 235 ZoomBubbleView::~ZoomBubbleView() { |
160 if (immersive_mode_controller_) | 236 if (immersive_mode_controller_) |
161 immersive_mode_controller_->RemoveObserver(this); | 237 immersive_mode_controller_->RemoveObserver(this); |
(...skipping 12 matching lines...) Expand all Loading... | |
174 | 250 |
175 void ZoomBubbleView::OnMouseEntered(const ui::MouseEvent& event) { | 251 void ZoomBubbleView::OnMouseEntered(const ui::MouseEvent& event) { |
176 StopTimer(); | 252 StopTimer(); |
177 } | 253 } |
178 | 254 |
179 void ZoomBubbleView::OnMouseExited(const ui::MouseEvent& event) { | 255 void ZoomBubbleView::OnMouseExited(const ui::MouseEvent& event) { |
180 StartTimerIfNecessary(); | 256 StartTimerIfNecessary(); |
181 } | 257 } |
182 | 258 |
183 void ZoomBubbleView::Init() { | 259 void ZoomBubbleView::Init() { |
184 // Set up the layout of the zoom bubble. A grid layout is used because | 260 // Set up the layout of the zoom bubble. |
185 // sometimes an extension icon is shown next to the zoom label. | 261 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); |
186 views::GridLayout* grid_layout = new views::GridLayout(this); | 262 const int margin = |
187 SetLayoutManager(grid_layout); | 263 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL); |
188 views::ColumnSet* columns = grid_layout->AddColumnSet(0); | 264 views::BoxLayout* box_layout = |
189 // First row. | 265 new views::BoxLayout(views::BoxLayout::kHorizontal, margin, 0, margin); |
190 if (extension_info_.icon_image) { | 266 |
191 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::CENTER, 2, | 267 box_layout->set_main_axis_alignment( |
192 views::GridLayout::USE_PREF, 0, 0); | 268 views::BoxLayout::MAIN_AXIS_ALIGNMENT_CENTER); |
193 } | 269 box_layout->set_cross_axis_alignment( |
194 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 270 views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); |
195 views::GridLayout::USE_PREF, 0, 0); | 271 SetLayoutManager(box_layout); |
196 grid_layout->StartRow(0, 0); | |
197 | 272 |
198 // If this zoom change was initiated by an extension, that extension will be | 273 // If this zoom change was initiated by an extension, that extension will be |
199 // attributed by showing its icon in the zoom bubble. | 274 // attributed by showing its icon in the zoom bubble. |
200 if (extension_info_.icon_image) { | 275 if (extension_info_.icon_image) { |
201 image_button_ = new views::ImageButton(this); | 276 image_button_ = new views::ImageButton(this); |
202 image_button_->SetTooltipText( | 277 image_button_->SetTooltipText( |
203 l10n_util::GetStringFUTF16(IDS_TOOLTIP_ZOOM_EXTENSION_ICON, | 278 l10n_util::GetStringFUTF16(IDS_TOOLTIP_ZOOM_EXTENSION_ICON, |
204 base::UTF8ToUTF16(extension_info_.name))); | 279 base::UTF8ToUTF16(extension_info_.name))); |
205 image_button_->SetImage(views::Button::STATE_NORMAL, | 280 image_button_->SetImage(views::Button::STATE_NORMAL, |
206 &extension_info_.icon_image->image_skia()); | 281 &extension_info_.icon_image->image_skia()); |
207 grid_layout->AddView(image_button_); | 282 AddChildView(image_button_); |
208 } | 283 } |
209 | 284 |
285 // Add Zoom Out ("-") button. | |
286 std::unique_ptr<views::Button> zoom_out_button = | |
287 CreateZoomButton(this, kRemoveIcon, IDS_ACCNAME_ZOOM_MINUS2); | |
288 zoom_out_button_ = zoom_out_button.get(); | |
289 AddChildView(zoom_out_button.release()); | |
290 | |
210 // Add zoom label with the new zoom percent. | 291 // Add zoom label with the new zoom percent. |
211 zoom::ZoomController* zoom_controller = | 292 label_ = new ZoomValue(web_contents_); |
212 zoom::ZoomController::FromWebContents(web_contents_); | 293 UpdateZoomPercent(); |
213 int zoom_percent = zoom_controller->GetZoomPercent(); | 294 AddChildView(label_); |
214 label_ = new views::Label(l10n_util::GetStringFUTF16( | |
215 IDS_TOOLTIP_ZOOM, base::FormatPercent(zoom_percent))); | |
216 label_->SetFontList(GetTitleFontList()); | |
217 grid_layout->AddView(label_); | |
218 | 295 |
219 // Second row. | 296 // Add Zoom In ("+") button. |
220 grid_layout->AddPaddingRow(0, 8); | 297 std::unique_ptr<views::Button> zoom_in_button = |
221 columns = grid_layout->AddColumnSet(1); | 298 CreateZoomButton(this, kAddIcon, IDS_ACCNAME_ZOOM_PLUS2); |
222 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 299 zoom_in_button_ = zoom_in_button.get(); |
223 views::GridLayout::USE_PREF, 0, 0); | 300 AddChildView(zoom_in_button.release()); |
224 grid_layout->StartRow(0, 1); | |
225 | 301 |
226 // Add "Reset to Default" button. | 302 // Add "Reset" button. |
227 grid_layout->AddView( | 303 reset_button_ = views::MdTextButton::CreateSecondaryUiButton( |
228 views::MdTextButton::CreateSecondaryUiButton( | 304 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT)); |
229 this, l10n_util::GetStringUTF16(IDS_ZOOM_SET_DEFAULT))); | 305 reset_button_->SetTooltipText( |
306 l10n_util::GetStringUTF16(IDS_ACCNAME_ZOOM_SET_DEFAULT)); | |
307 AddChildView(reset_button_); | |
230 | 308 |
231 StartTimerIfNecessary(); | 309 StartTimerIfNecessary(); |
232 } | 310 } |
233 | 311 |
234 void ZoomBubbleView::WindowClosing() { | 312 void ZoomBubbleView::WindowClosing() { |
235 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't | 313 // |zoom_bubble_| can be a new bubble by this point (as Close(); doesn't |
236 // call this right away). Only set to nullptr when it's this bubble. | 314 // call this right away). Only set to nullptr when it's this bubble. |
237 if (zoom_bubble_ == this) | 315 bool this_bubble = zoom_bubble_ == this; |
316 if (this_bubble) | |
238 zoom_bubble_ = nullptr; | 317 zoom_bubble_ = nullptr; |
318 UpdateZoomIconVisibility(); | |
319 if (this_bubble) | |
320 web_contents_ = nullptr; | |
239 } | 321 } |
240 | 322 |
241 void ZoomBubbleView::CloseBubble() { | 323 void ZoomBubbleView::CloseBubble() { |
324 if (ignore_close_bubble_) | |
325 return; | |
326 | |
242 // Widget's Close() is async, but we don't want to use zoom_bubble_ after | 327 // Widget's Close() is async, but we don't want to use zoom_bubble_ after |
243 // this. Additionally web_contents_ may have been destroyed. | 328 // this. Additionally web_contents_ may have been destroyed. |
244 zoom_bubble_ = nullptr; | 329 zoom_bubble_ = nullptr; |
245 web_contents_ = nullptr; | |
246 LocationBarBubbleDelegateView::CloseBubble(); | 330 LocationBarBubbleDelegateView::CloseBubble(); |
247 } | 331 } |
248 | 332 |
249 void ZoomBubbleView::ButtonPressed(views::Button* sender, | 333 void ZoomBubbleView::ButtonPressed(views::Button* sender, |
250 const ui::Event& event) { | 334 const ui::Event& event) { |
335 // No button presses in this dialog should cause the dialog to close, | |
336 // including when the zoom level is set to 100% as a result of a button press. | |
337 base::AutoReset<bool> auto_ignore_close_bubble(&ignore_close_bubble_, true); | |
338 | |
339 // Extend the timer to give a user more time after any button is pressed. | |
340 auto_close_duration_ = kBubbleCloseDelayLong; | |
341 StartTimerIfNecessary(); | |
342 | |
251 if (sender == image_button_) { | 343 if (sender == image_button_) { |
252 DCHECK(extension_info_.icon_image) << "Invalid button press."; | 344 DCHECK(extension_info_.icon_image) << "Invalid button press."; |
253 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | 345 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); |
254 chrome::AddSelectedTabWithURL( | 346 chrome::AddSelectedTabWithURL( |
255 browser, GURL(base::StringPrintf("chrome://extensions?id=%s", | 347 browser, GURL(base::StringPrintf("chrome://extensions?id=%s", |
256 extension_info_.id.c_str())), | 348 extension_info_.id.c_str())), |
257 ui::PAGE_TRANSITION_FROM_API); | 349 ui::PAGE_TRANSITION_FROM_API); |
350 } else if (sender == zoom_out_button_) { | |
351 zoom::PageZoom::Zoom(web_contents_, content::PAGE_ZOOM_OUT); | |
352 } else if (sender == zoom_in_button_) { | |
353 zoom::PageZoom::Zoom(web_contents_, content::PAGE_ZOOM_IN); | |
354 } else if (sender == reset_button_) { | |
355 zoom::PageZoom::Zoom(web_contents_, content::PAGE_ZOOM_RESET); | |
258 } else { | 356 } else { |
259 zoom::PageZoom::Zoom(web_contents_, content::PAGE_ZOOM_RESET); | 357 NOTREACHED(); |
260 } | 358 } |
261 } | 359 } |
262 | 360 |
263 void ZoomBubbleView::OnImmersiveRevealStarted() { | 361 void ZoomBubbleView::OnImmersiveRevealStarted() { |
264 CloseBubble(); | 362 CloseBubble(); |
265 } | 363 } |
266 | 364 |
267 void ZoomBubbleView::OnImmersiveModeControllerDestroyed() { | 365 void ZoomBubbleView::OnImmersiveModeControllerDestroyed() { |
268 immersive_mode_controller_ = nullptr; | 366 immersive_mode_controller_ = nullptr; |
269 } | 367 } |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 icon_size = browser_action->default_icon.map().begin()->first; | 410 icon_size = browser_action->default_icon.map().begin()->first; |
313 extension_info_.icon_image.reset( | 411 extension_info_.icon_image.reset( |
314 new extensions::IconImage(web_contents_->GetBrowserContext(), | 412 new extensions::IconImage(web_contents_->GetBrowserContext(), |
315 extension, | 413 extension, |
316 browser_action->default_icon, | 414 browser_action->default_icon, |
317 icon_size, | 415 icon_size, |
318 default_extension_icon_image, | 416 default_extension_icon_image, |
319 this)); | 417 this)); |
320 } | 418 } |
321 | 419 |
420 void ZoomBubbleView::UpdateZoomPercent() { | |
421 label_->SetText(base::FormatPercent( | |
422 zoom::ZoomController::FromWebContents(web_contents_)->GetZoomPercent())); | |
423 } | |
424 | |
425 void ZoomBubbleView::UpdateZoomIconVisibility() { | |
426 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); | |
427 if (browser && browser->window() && browser->window()->GetLocationBar()) | |
428 browser->window()->GetLocationBar()->UpdateZoomViewVisibility(); | |
429 } | |
430 | |
322 void ZoomBubbleView::StartTimerIfNecessary() { | 431 void ZoomBubbleView::StartTimerIfNecessary() { |
323 if (!auto_close_) | 432 if (!auto_close_) |
324 return; | 433 return; |
325 | 434 |
326 if (timer_.IsRunning()) { | 435 timer_.Start(FROM_HERE, auto_close_duration_, this, |
327 timer_.Reset(); | 436 &ZoomBubbleView::CloseBubble); |
328 } else { | |
329 // The number of milliseconds the bubble should stay on the screen if it | |
330 // will close automatically. | |
331 const int kBubbleCloseDelay = 1500; | |
332 timer_.Start(FROM_HERE, | |
333 base::TimeDelta::FromMilliseconds(kBubbleCloseDelay), this, | |
334 &ZoomBubbleView::CloseBubble); | |
335 } | |
336 } | 437 } |
337 | 438 |
338 void ZoomBubbleView::StopTimer() { | 439 void ZoomBubbleView::StopTimer() { |
339 timer_.Stop(); | 440 timer_.Stop(); |
340 } | 441 } |
341 | 442 |
342 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} | 443 ZoomBubbleView::ZoomBubbleExtensionInfo::ZoomBubbleExtensionInfo() {} |
343 | 444 |
344 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} | 445 ZoomBubbleView::ZoomBubbleExtensionInfo::~ZoomBubbleExtensionInfo() {} |
OLD | NEW |