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/fullscreen_exit_bubble_views.h" | 5 #include "chrome/browser/ui/views/fullscreen_exit_bubble_views.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
11 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 11 #include "chrome/browser/ui/fullscreen/fullscreen_controller.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/frame/immersive_mode_controller.h" | 13 #include "chrome/browser/ui/views/frame/immersive_mode_controller.h" |
14 #include "chrome/browser/ui/views/frame/top_container_view.h" | 14 #include "chrome/browser/ui/views/frame/top_container_view.h" |
15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
16 #include "grit/generated_resources.h" | 16 #include "grit/generated_resources.h" |
17 #include "grit/ui_strings.h" | 17 #include "grit/ui_strings.h" |
18 #include "ui/base/animation/slide_animation.h" | |
19 #include "ui/base/keycodes/keyboard_codes.h" | 18 #include "ui/base/keycodes/keyboard_codes.h" |
20 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/base/resource/resource_bundle.h" | 20 #include "ui/base/resource/resource_bundle.h" |
| 21 #include "ui/gfx/animation/slide_animation.h" |
22 #include "ui/gfx/canvas.h" | 22 #include "ui/gfx/canvas.h" |
23 #include "ui/gfx/screen.h" | 23 #include "ui/gfx/screen.h" |
24 #include "ui/views/bubble/bubble_border.h" | 24 #include "ui/views/bubble/bubble_border.h" |
25 #include "ui/views/controls/button/label_button.h" | 25 #include "ui/views/controls/button/label_button.h" |
26 #include "ui/views/controls/link.h" | 26 #include "ui/views/controls/link.h" |
27 #include "ui/views/controls/link_listener.h" | 27 #include "ui/views/controls/link_listener.h" |
28 #include "ui/views/layout/box_layout.h" | 28 #include "ui/views/layout/box_layout.h" |
29 #include "ui/views/layout/grid_layout.h" | 29 #include "ui/views/layout/grid_layout.h" |
30 #include "ui/views/view.h" | 30 #include "ui/views/view.h" |
31 #include "ui/views/widget/widget.h" | 31 #include "ui/views/widget/widget.h" |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 | 254 |
255 // FullscreenExitBubbleViews --------------------------------------------------- | 255 // FullscreenExitBubbleViews --------------------------------------------------- |
256 | 256 |
257 FullscreenExitBubbleViews::FullscreenExitBubbleViews( | 257 FullscreenExitBubbleViews::FullscreenExitBubbleViews( |
258 BrowserView* browser_view, | 258 BrowserView* browser_view, |
259 const GURL& url, | 259 const GURL& url, |
260 FullscreenExitBubbleType bubble_type) | 260 FullscreenExitBubbleType bubble_type) |
261 : FullscreenExitBubble(browser_view->browser(), url, bubble_type), | 261 : FullscreenExitBubble(browser_view->browser(), url, bubble_type), |
262 browser_view_(browser_view), | 262 browser_view_(browser_view), |
263 popup_(NULL), | 263 popup_(NULL), |
264 animation_(new ui::SlideAnimation(this)), | 264 animation_(new gfx::SlideAnimation(this)), |
265 animated_attribute_(ANIMATED_ATTRIBUTE_BOUNDS) { | 265 animated_attribute_(ANIMATED_ATTRIBUTE_BOUNDS) { |
266 animation_->Reset(1); | 266 animation_->Reset(1); |
267 | 267 |
268 // Create the contents view. | 268 // Create the contents view. |
269 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); | 269 ui::Accelerator accelerator(ui::VKEY_UNKNOWN, ui::EF_NONE); |
270 bool got_accelerator = browser_view_->GetWidget()->GetAccelerator( | 270 bool got_accelerator = browser_view_->GetWidget()->GetAccelerator( |
271 IDC_FULLSCREEN, &accelerator); | 271 IDC_FULLSCREEN, &accelerator); |
272 DCHECK(got_accelerator); | 272 DCHECK(got_accelerator); |
273 view_ = new FullscreenExitView( | 273 view_ = new FullscreenExitView( |
274 this, accelerator.GetShortcutText(), url, bubble_type_); | 274 this, accelerator.GetShortcutText(), url, bubble_type_); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 popup_->SetBounds(popup_rect); | 397 popup_->SetBounds(popup_rect); |
398 view_->SetY(popup_rect.height() - view_->height()); | 398 view_->SetY(popup_rect.height() - view_->height()); |
399 } | 399 } |
400 } | 400 } |
401 | 401 |
402 views::View* FullscreenExitBubbleViews::GetBrowserRootView() const { | 402 views::View* FullscreenExitBubbleViews::GetBrowserRootView() const { |
403 return browser_view_->GetWidget()->GetRootView(); | 403 return browser_view_->GetWidget()->GetRootView(); |
404 } | 404 } |
405 | 405 |
406 void FullscreenExitBubbleViews::AnimationProgressed( | 406 void FullscreenExitBubbleViews::AnimationProgressed( |
407 const ui::Animation* animation) { | 407 const gfx::Animation* animation) { |
408 if (animated_attribute_ == ANIMATED_ATTRIBUTE_OPACITY) { | 408 if (animated_attribute_ == ANIMATED_ATTRIBUTE_OPACITY) { |
409 int opacity = animation_->CurrentValueBetween(0, 255); | 409 int opacity = animation_->CurrentValueBetween(0, 255); |
410 if (opacity == 0) { | 410 if (opacity == 0) { |
411 popup_->Hide(); | 411 popup_->Hide(); |
412 } else { | 412 } else { |
413 popup_->Show(); | 413 popup_->Show(); |
414 popup_->SetOpacity(opacity); | 414 popup_->SetOpacity(opacity); |
415 } | 415 } |
416 } else { | 416 } else { |
417 if (GetPopupRect(false).IsEmpty()) { | 417 if (GetPopupRect(false).IsEmpty()) { |
418 popup_->Hide(); | 418 popup_->Hide(); |
419 } else { | 419 } else { |
420 UpdateBounds(); | 420 UpdateBounds(); |
421 popup_->Show(); | 421 popup_->Show(); |
422 } | 422 } |
423 } | 423 } |
424 } | 424 } |
425 | 425 |
426 void FullscreenExitBubbleViews::AnimationEnded( | 426 void FullscreenExitBubbleViews::AnimationEnded( |
427 const ui::Animation* animation) { | 427 const gfx::Animation* animation) { |
428 AnimationProgressed(animation); | 428 AnimationProgressed(animation); |
429 } | 429 } |
430 | 430 |
431 gfx::Rect FullscreenExitBubbleViews::GetPopupRect( | 431 gfx::Rect FullscreenExitBubbleViews::GetPopupRect( |
432 bool ignore_animation_state) const { | 432 bool ignore_animation_state) const { |
433 gfx::Size size(view_->GetPreferredSize()); | 433 gfx::Size size(view_->GetPreferredSize()); |
434 // NOTE: don't use the bounds of the root_view_. On linux GTK changing window | 434 // NOTE: don't use the bounds of the root_view_. On linux GTK changing window |
435 // size is async. Instead we use the size of the screen. | 435 // size is async. Instead we use the size of the screen. |
436 gfx::Screen* screen = | 436 gfx::Screen* screen = |
437 gfx::Screen::GetScreenFor(browser_view_->GetWidget()->GetNativeView()); | 437 gfx::Screen::GetScreenFor(browser_view_->GetWidget()->GetNativeView()); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 const content::NotificationDetails& details) { | 505 const content::NotificationDetails& details) { |
506 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); | 506 DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type); |
507 UpdateForImmersiveState(); | 507 UpdateForImmersiveState(); |
508 } | 508 } |
509 | 509 |
510 void FullscreenExitBubbleViews::OnWidgetVisibilityChanged( | 510 void FullscreenExitBubbleViews::OnWidgetVisibilityChanged( |
511 views::Widget* widget, | 511 views::Widget* widget, |
512 bool visible) { | 512 bool visible) { |
513 UpdateMouseWatcher(); | 513 UpdateMouseWatcher(); |
514 } | 514 } |
OLD | NEW |