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

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

Issue 7825026: Revert "Currently, base/timer.cc calls PostTask with FROM_HERE as the Location, (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(FROM_HERE, 29 initial_delay_.Start(base::TimeDelta::FromMilliseconds(kInitialDelayMs), this,
30 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this,
31 &FullscreenExitBubble::CheckMousePosition); 30 &FullscreenExitBubble::CheckMousePosition);
32 gfx::Point cursor_pos = GetCursorScreenPoint(); 31 gfx::Point cursor_pos = GetCursorScreenPoint();
33 last_mouse_pos_ = cursor_pos; 32 last_mouse_pos_ = cursor_pos;
34 mouse_position_checker_.Start(FROM_HERE, 33 mouse_position_checker_.Start(
35 base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this, 34 base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this,
36 &FullscreenExitBubble::CheckMousePosition); 35 &FullscreenExitBubble::CheckMousePosition);
37 } 36 }
38 37
39 void FullscreenExitBubble::CheckMousePosition() { 38 void FullscreenExitBubble::CheckMousePosition() {
40 // Desired behavior: 39 // Desired behavior:
41 // 40 //
42 // +------------+-----------------------------+------------+ 41 // +------------+-----------------------------+------------+
43 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region 42 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region
44 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region 43 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region
(...skipping 11 matching lines...) Expand all
56 // * Otherwise, we do nothing, because the mouse is in the neutral region and 55 // * Otherwise, we do nothing, because the mouse is in the neutral region and
57 // 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
58 // change anything's state. 57 // change anything's state.
59 58
60 gfx::Point cursor_pos = GetCursorScreenPoint(); 59 gfx::Point cursor_pos = GetCursorScreenPoint();
61 60
62 // Check to see whether the mouse is idle. 61 // Check to see whether the mouse is idle.
63 if (cursor_pos != last_mouse_pos_) { 62 if (cursor_pos != last_mouse_pos_) {
64 // The mouse moved; reset the idle timer. 63 // The mouse moved; reset the idle timer.
65 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.
66 idle_timeout_.Start(FROM_HERE, 65 idle_timeout_.Start(base::TimeDelta::FromMilliseconds(kIdleTimeMs), this,
67 base::TimeDelta::FromMilliseconds(kIdleTimeMs), this,
68 &FullscreenExitBubble::CheckMousePosition); 66 &FullscreenExitBubble::CheckMousePosition);
69 } 67 }
70 last_mouse_pos_ = cursor_pos; 68 last_mouse_pos_ = cursor_pos;
71 69
72 if (!IsWindowActive() || 70 if (!IsWindowActive() ||
73 !WindowContainsPoint(cursor_pos) || 71 !WindowContainsPoint(cursor_pos) ||
74 (cursor_pos.y() >= GetPopupRect(true).bottom()) || 72 (cursor_pos.y() >= GetPopupRect(true).bottom()) ||
75 !idle_timeout_.IsRunning()) { 73 !idle_timeout_.IsRunning()) {
76 // The cursor is offscreen, in the slide-out region, or idle. 74 // The cursor is offscreen, in the slide-out region, or idle.
77 if (!initial_delay_.IsRunning()) { 75 if (!initial_delay_.IsRunning()) {
78 Hide(); 76 Hide();
79 } 77 }
80 } else if ((cursor_pos.y() < kSlideInRegionHeightPx) || 78 } else if ((cursor_pos.y() < kSlideInRegionHeightPx) ||
81 IsAnimating()) { 79 IsAnimating()) {
82 // 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
83 // the neutral region and we're sliding out. 81 // the neutral region and we're sliding out.
84 Show(); 82 Show();
85 } 83 }
86 } 84 }
87 85
88 void FullscreenExitBubble::ToggleFullscreen() { 86 void FullscreenExitBubble::ToggleFullscreen() {
89 delegate_->ExecuteCommand(IDC_FULLSCREEN); 87 delegate_->ExecuteCommand(IDC_FULLSCREEN);
90 } 88 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/ui/gtk/browser_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698