OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/fullscreen_exit_bubble.h" | 5 #include "chrome/browser/ui/fullscreen_exit_bubble.h" |
6 | 6 |
7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
8 #include "chrome/browser/ui/browser.h" | |
8 #include "ui/gfx/rect.h" | 9 #include "ui/gfx/rect.h" |
9 | 10 |
10 const double FullscreenExitBubble::kOpacity = 0.7; | |
11 const int FullscreenExitBubble::kPaddingPx = 8; | 11 const int FullscreenExitBubble::kPaddingPx = 8; |
12 const int FullscreenExitBubble::kInitialDelayMs = 3800; | 12 const int FullscreenExitBubble::kInitialDelayMs = 3800; |
13 const int FullscreenExitBubble::kIdleTimeMs = 2300; | 13 const int FullscreenExitBubble::kIdleTimeMs = 2300; |
14 const int FullscreenExitBubble::kPositionCheckHz = 10; | 14 const int FullscreenExitBubble::kPositionCheckHz = 10; |
15 const int FullscreenExitBubble::kSlideInRegionHeightPx = 4; | 15 const int FullscreenExitBubble::kSlideInRegionHeightPx = 4; |
16 const int FullscreenExitBubble::kSlideInDurationMs = 350; | 16 const int FullscreenExitBubble::kSlideInDurationMs = 350; |
17 const int FullscreenExitBubble::kSlideOutDurationMs = 700; | 17 const int FullscreenExitBubble::kSlideOutDurationMs = 700; |
18 const int FullscreenExitBubble::kPopupTopPx = 15; | |
18 | 19 |
19 FullscreenExitBubble::FullscreenExitBubble( | 20 FullscreenExitBubble::FullscreenExitBubble(Browser* browser) |
20 CommandUpdater::CommandUpdaterDelegate* delegate) | 21 : browser_(browser) { |
21 : delegate_(delegate) { | |
22 } | 22 } |
23 | 23 |
24 FullscreenExitBubble::~FullscreenExitBubble() { | 24 FullscreenExitBubble::~FullscreenExitBubble() { |
25 } | 25 } |
26 | 26 |
27 void FullscreenExitBubble::StartWatchingMouse() { | 27 void FullscreenExitBubble::StartWatchingMouse() { |
28 // Start the initial delay timer and begin watching the mouse. | 28 // Start the initial delay timer and begin watching the mouse. |
29 initial_delay_.Start(FROM_HERE, | 29 initial_delay_.Start(FROM_HERE, |
30 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, | 30 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, |
31 &FullscreenExitBubble::CheckMousePosition); | 31 &FullscreenExitBubble::CheckMousePosition); |
32 gfx::Point cursor_pos = GetCursorScreenPoint(); | 32 gfx::Point cursor_pos = GetCursorScreenPoint(); |
33 last_mouse_pos_ = cursor_pos; | 33 last_mouse_pos_ = cursor_pos; |
34 mouse_position_checker_.Start(FROM_HERE, | 34 mouse_position_checker_.Start(FROM_HERE, |
35 base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this, | 35 base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this, |
36 &FullscreenExitBubble::CheckMousePosition); | 36 &FullscreenExitBubble::CheckMousePosition); |
37 } | 37 } |
38 | 38 |
39 void FullscreenExitBubble::CheckMousePosition() { | 39 void FullscreenExitBubble::CheckMousePosition() { |
40 // Desired behavior: | 40 // Desired behavior: |
41 // | 41 // |
42 // +------------+-----------------------------+------------+ | 42 // +------------+-----------------------------+------------+ |
43 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region | 43 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region |
tony
2011/10/14 17:29:56
Nit: You may want to update this text or change it
| |
44 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region | 44 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region |
45 // | | Slide-out region | 45 // | | Slide-out region |
46 // : : | 46 // : : |
47 // | 47 // |
48 // * If app is not active, we hide the popup. | 48 // * If app is not active, we hide the popup. |
49 // * If the mouse is offscreen or in the slide-out region, we hide the popup. | 49 // * If the mouse is offscreen or in the slide-out region, we hide the popup. |
50 // * If the mouse goes idle, we hide the popup. | 50 // * If the mouse goes idle, we hide the popup. |
51 // * If the mouse is in the slide-in-region and not idle, we show the popup. | 51 // * If the mouse is in the slide-in-region and not idle, we show the popup. |
52 // * If the mouse is in the neutral region and not idle, and the popup is | 52 // * If the mouse is in the neutral region and not idle, and the popup is |
53 // currently sliding out, we show it again. This facilitates users | 53 // currently sliding out, we show it again. This facilitates users |
(...skipping 25 matching lines...) Expand all Loading... | |
79 } | 79 } |
80 } else if ((cursor_pos.y() < kSlideInRegionHeightPx) || | 80 } else if ((cursor_pos.y() < kSlideInRegionHeightPx) || |
81 IsAnimating()) { | 81 IsAnimating()) { |
82 // The cursor is not idle, and either it's in the slide-in region or it's in | 82 // The cursor is not idle, and either it's in the slide-in region or it's in |
83 // the neutral region and we're sliding out. | 83 // the neutral region and we're sliding out. |
84 Show(); | 84 Show(); |
85 } | 85 } |
86 } | 86 } |
87 | 87 |
88 void FullscreenExitBubble::ToggleFullscreen() { | 88 void FullscreenExitBubble::ToggleFullscreen() { |
89 delegate_->ExecuteCommand(IDC_FULLSCREEN); | 89 browser_->ExecuteCommand(IDC_FULLSCREEN); |
90 } | 90 } |
91 | |
92 void FullscreenExitBubble::AcceptFullscreen(const GURL& url) { | |
93 browser_->OnAcceptFullscreenPermission(url); | |
94 } | |
95 | |
96 void FullscreenExitBubble::CancelFullscreen() { | |
97 browser_->OnDenyFullscreenPermission(); | |
98 } | |
OLD | NEW |