Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Side by Side Diff: chrome/browser/ui/fullscreen_exit_bubble.cc

Issue 7812036: Update base/timer.h code to pass through Location from call sites. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "ui/gfx/rect.h" 8 #include "ui/gfx/rect.h"
9 9
10 const double FullscreenExitBubble::kOpacity = 0.7; 10 const double FullscreenExitBubble::kOpacity = 0.7;
11 const int FullscreenExitBubble::kPaddingPx = 8; 11 const int FullscreenExitBubble::kPaddingPx = 8;
12 const int FullscreenExitBubble::kInitialDelayMs = 2300; 12 const int FullscreenExitBubble::kInitialDelayMs = 2300;
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 18
19 FullscreenExitBubble::FullscreenExitBubble( 19 FullscreenExitBubble::FullscreenExitBubble(
20 CommandUpdater::CommandUpdaterDelegate* delegate) 20 CommandUpdater::CommandUpdaterDelegate* delegate)
21 : delegate_(delegate) { 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(base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, 29 initial_delay_.Start(base::TimeDelta::FromMilliseconds(kInitialDelayMs), this,
30 &FullscreenExitBubble::CheckMousePosition); 30 &FullscreenExitBubble::CheckMousePosition, FROM_HERE);
31 gfx::Point cursor_pos = GetCursorScreenPoint(); 31 gfx::Point cursor_pos = GetCursorScreenPoint();
32 last_mouse_pos_ = cursor_pos; 32 last_mouse_pos_ = cursor_pos;
33 mouse_position_checker_.Start( 33 mouse_position_checker_.Start(
34 base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this, 34 base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this,
35 &FullscreenExitBubble::CheckMousePosition); 35 &FullscreenExitBubble::CheckMousePosition, FROM_HERE);
36 } 36 }
37 37
38 void FullscreenExitBubble::CheckMousePosition() { 38 void FullscreenExitBubble::CheckMousePosition() {
39 // Desired behavior: 39 // Desired behavior:
40 // 40 //
41 // +------------+-----------------------------+------------+ 41 // +------------+-----------------------------+------------+
42 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region 42 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region
43 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region 43 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region
44 // | | Slide-out region 44 // | | Slide-out region
45 // : : 45 // : :
(...skipping 10 matching lines...) Expand all
56 // either the popup is hidden or the mouse is not idle, so we don't want to 56 // either the popup is hidden or the mouse is not idle, so we don't want to
57 // change anything's state. 57 // change anything's state.
58 58
59 gfx::Point cursor_pos = GetCursorScreenPoint(); 59 gfx::Point cursor_pos = GetCursorScreenPoint();
60 60
61 // Check to see whether the mouse is idle. 61 // Check to see whether the mouse is idle.
62 if (cursor_pos != last_mouse_pos_) { 62 if (cursor_pos != last_mouse_pos_) {
63 // The mouse moved; reset the idle timer. 63 // The mouse moved; reset the idle timer.
64 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op. 64 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op.
65 idle_timeout_.Start(base::TimeDelta::FromMilliseconds(kIdleTimeMs), this, 65 idle_timeout_.Start(base::TimeDelta::FromMilliseconds(kIdleTimeMs), this,
66 &FullscreenExitBubble::CheckMousePosition); 66 &FullscreenExitBubble::CheckMousePosition, FROM_HERE);
67 } 67 }
68 last_mouse_pos_ = cursor_pos; 68 last_mouse_pos_ = cursor_pos;
69 69
70 if (!IsWindowActive() || 70 if (!IsWindowActive() ||
71 !WindowContainsPoint(cursor_pos) || 71 !WindowContainsPoint(cursor_pos) ||
72 (cursor_pos.y() >= GetPopupRect(true).bottom()) || 72 (cursor_pos.y() >= GetPopupRect(true).bottom()) ||
73 !idle_timeout_.IsRunning()) { 73 !idle_timeout_.IsRunning()) {
74 // The cursor is offscreen, in the slide-out region, or idle. 74 // The cursor is offscreen, in the slide-out region, or idle.
75 if (!initial_delay_.IsRunning()) { 75 if (!initial_delay_.IsRunning()) {
76 Hide(); 76 Hide();
77 } 77 }
78 } else if ((cursor_pos.y() < kSlideInRegionHeightPx) || 78 } else if ((cursor_pos.y() < kSlideInRegionHeightPx) ||
79 IsAnimating()) { 79 IsAnimating()) {
80 // The cursor is not idle, and either it's in the slide-in region or it's in 80 // The cursor is not idle, and either it's in the slide-in region or it's in
81 // the neutral region and we're sliding out. 81 // the neutral region and we're sliding out.
82 Show(); 82 Show();
83 } 83 }
84 } 84 }
85 85
86 void FullscreenExitBubble::ToggleFullscreen() { 86 void FullscreenExitBubble::ToggleFullscreen() {
87 delegate_->ExecuteCommand(IDC_FULLSCREEN); 87 delegate_->ExecuteCommand(IDC_FULLSCREEN);
88 } 88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698