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/exclusive_access/exclusive_access_bubble.h" | 5 #include "chrome/browser/ui/exclusive_access/exclusive_access_bubble.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" | 10 #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" |
11 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" | 11 #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" |
12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 12 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
13 #include "chrome/grit/generated_resources.h" | 13 #include "chrome/grit/generated_resources.h" |
14 #include "extensions/browser/extension_registry.h" | 14 #include "extensions/browser/extension_registry.h" |
15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
16 #include "ui/gfx/geometry/rect.h" | 16 #include "ui/gfx/geometry/rect.h" |
17 #include "ui/strings/grit/ui_strings.h" | 17 #include "ui/strings/grit/ui_strings.h" |
18 | 18 |
19 // NOTE(koz): Linux doesn't use the thick shadowed border, so we add padding | 19 // NOTE(koz): Linux doesn't use the thick shadowed border, so we add padding |
20 // here. | 20 // here. |
21 #if defined(OS_LINUX) | 21 #if defined(OS_LINUX) |
22 const int ExclusiveAccessBubble::kPaddingPx = 8; | 22 const int ExclusiveAccessBubble::kPaddingPx = 8; |
23 #else | 23 #else |
24 const int ExclusiveAccessBubble::kPaddingPx = 15; | 24 const int ExclusiveAccessBubble::kPaddingPx = 15; |
25 #endif | 25 #endif |
26 const int ExclusiveAccessBubble::kInitialDelayMs = 3800; | 26 const int ExclusiveAccessBubble::kInitialDelayMs = 3800; |
27 const int ExclusiveAccessBubble::kIdleTimeMs = 2300; | 27 const int ExclusiveAccessBubble::kIdleTimeMs = 2300; |
28 const int ExclusiveAccessBubble::kDebounceNotificationsTimeMs = 500; | |
29 const int ExclusiveAccessBubble::kSnoozeNotificationsTimeMs = 60000; // 1m. | |
scheib
2015/08/05 05:24:19
1 minute is too small. We had a previous email thr
Matt Giuca
2015/08/06 03:33:03
OK let's go 1 hour.
| |
28 const int ExclusiveAccessBubble::kPositionCheckHz = 10; | 30 const int ExclusiveAccessBubble::kPositionCheckHz = 10; |
29 const int ExclusiveAccessBubble::kSlideInRegionHeightPx = 4; | 31 const int ExclusiveAccessBubble::kSlideInRegionHeightPx = 4; |
30 const int ExclusiveAccessBubble::kSlideInDurationMs = 350; | 32 const int ExclusiveAccessBubble::kSlideInDurationMs = 350; |
31 const int ExclusiveAccessBubble::kSlideOutDurationMs = 700; | 33 const int ExclusiveAccessBubble::kSlideOutDurationMs = 700; |
32 const int ExclusiveAccessBubble::kPopupTopPx = 15; | 34 const int ExclusiveAccessBubble::kPopupTopPx = 15; |
33 | 35 |
34 ExclusiveAccessBubble::ExclusiveAccessBubble( | 36 ExclusiveAccessBubble::ExclusiveAccessBubble( |
35 ExclusiveAccessManager* manager, | 37 ExclusiveAccessManager* manager, |
36 const GURL& url, | 38 const GURL& url, |
37 ExclusiveAccessBubbleType bubble_type) | 39 ExclusiveAccessBubbleType bubble_type) |
38 : manager_(manager), url_(url), bubble_type_(bubble_type) { | 40 : manager_(manager), url_(url), bubble_type_(bubble_type) { |
39 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type_); | 41 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type_); |
42 | |
43 // Wait for a short time to let the user stop moving the mouse. After this | |
44 // time elapses, we will notify the user upon the next mouse input. | |
45 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | |
46 suppress_notify_timeout_.Start( | |
47 FROM_HERE, | |
48 base::TimeDelta::FromMilliseconds(kDebounceNotificationsTimeMs), this, | |
49 &ExclusiveAccessBubble::CheckMousePosition); | |
50 } | |
40 } | 51 } |
41 | 52 |
42 ExclusiveAccessBubble::~ExclusiveAccessBubble() { | 53 ExclusiveAccessBubble::~ExclusiveAccessBubble() { |
43 } | 54 } |
44 | 55 |
45 void ExclusiveAccessBubble::StartWatchingMouse() { | 56 void ExclusiveAccessBubble::StartWatchingMouse() { |
46 // Start the initial delay timer and begin watching the mouse. | 57 // Start the initial delay timer and begin watching the mouse. |
47 initial_delay_.Start(FROM_HERE, | 58 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { |
48 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, | 59 hide_timeout_.Start(FROM_HERE, |
49 &ExclusiveAccessBubble::CheckMousePosition); | 60 base::TimeDelta::FromMilliseconds(kInitialDelayMs), |
61 this, &ExclusiveAccessBubble::CheckMousePosition); | |
62 } | |
50 gfx::Point cursor_pos = GetCursorScreenPoint(); | 63 gfx::Point cursor_pos = GetCursorScreenPoint(); |
51 last_mouse_pos_ = cursor_pos; | 64 last_mouse_pos_ = cursor_pos; |
52 mouse_position_checker_.Start( | 65 mouse_position_checker_.Start( |
53 FROM_HERE, base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), | 66 FROM_HERE, base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), |
54 this, &ExclusiveAccessBubble::CheckMousePosition); | 67 this, &ExclusiveAccessBubble::CheckMousePosition); |
55 } | 68 } |
56 | 69 |
57 void ExclusiveAccessBubble::StopWatchingMouse() { | 70 void ExclusiveAccessBubble::StopWatchingMouse() { |
58 initial_delay_.Stop(); | 71 hide_timeout_.Stop(); |
59 idle_timeout_.Stop(); | 72 idle_timeout_.Stop(); |
60 mouse_position_checker_.Stop(); | 73 mouse_position_checker_.Stop(); |
61 } | 74 } |
62 | 75 |
63 bool ExclusiveAccessBubble::IsWatchingMouse() const { | 76 bool ExclusiveAccessBubble::IsWatchingMouse() const { |
64 return mouse_position_checker_.IsRunning(); | 77 return mouse_position_checker_.IsRunning(); |
65 } | 78 } |
66 | 79 |
67 void ExclusiveAccessBubble::CheckMousePosition() { | 80 void ExclusiveAccessBubble::CheckMousePosition() { |
68 // Desired behavior: | 81 // Desired behavior: |
(...skipping 18 matching lines...) Expand all Loading... | |
87 | 100 |
88 gfx::Point cursor_pos = GetCursorScreenPoint(); | 101 gfx::Point cursor_pos = GetCursorScreenPoint(); |
89 | 102 |
90 // Check to see whether the mouse is idle. | 103 // Check to see whether the mouse is idle. |
91 if (cursor_pos != last_mouse_pos_) { | 104 if (cursor_pos != last_mouse_pos_) { |
92 // The mouse moved; reset the idle timer. | 105 // The mouse moved; reset the idle timer. |
93 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op. | 106 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op. |
94 idle_timeout_.Start(FROM_HERE, | 107 idle_timeout_.Start(FROM_HERE, |
95 base::TimeDelta::FromMilliseconds(kIdleTimeMs), this, | 108 base::TimeDelta::FromMilliseconds(kIdleTimeMs), this, |
96 &ExclusiveAccessBubble::CheckMousePosition); | 109 &ExclusiveAccessBubble::CheckMousePosition); |
110 | |
111 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) { | |
112 // If the notification suppression timer has elapsed, show the | |
113 // notification regardless of where the mouse is on the screen. | |
114 if (!suppress_notify_timeout_.IsRunning()) { | |
115 Show(); | |
116 // Do not allow the notification to hide for a few seconds. | |
117 hide_timeout_.Start(FROM_HERE, | |
118 base::TimeDelta::FromMilliseconds(kIdleTimeMs), | |
119 this, &ExclusiveAccessBubble::CheckMousePosition); | |
120 // Do not show the notification again until a long time has elapsed. | |
121 suppress_notify_timeout_.Start( | |
122 FROM_HERE, | |
123 base::TimeDelta::FromMilliseconds(kSnoozeNotificationsTimeMs), this, | |
124 &ExclusiveAccessBubble::CheckMousePosition); | |
125 return; | |
126 } else { | |
127 // The timer has not elapsed, but the user moved the mouse. Reset the | |
128 // timer. (We only want to re-show the message after a period of | |
129 // inactivity.) | |
130 suppress_notify_timeout_.Reset(); | |
131 } | |
132 } | |
97 } | 133 } |
98 last_mouse_pos_ = cursor_pos; | 134 last_mouse_pos_ = cursor_pos; |
99 | 135 |
100 if (!IsWindowActive() || !WindowContainsPoint(cursor_pos) || | 136 if (!IsWindowActive() || !WindowContainsPoint(cursor_pos) || |
101 (cursor_pos.y() >= GetPopupRect(true).bottom()) || | 137 (cursor_pos.y() >= GetPopupRect(true).bottom()) || |
102 !idle_timeout_.IsRunning()) { | 138 !idle_timeout_.IsRunning()) { |
103 // The cursor is offscreen, in the slide-out region, or idle. | 139 // The cursor is offscreen, in the slide-out region, or idle. |
104 if (!initial_delay_.IsRunning()) { | 140 if (!hide_timeout_.IsRunning()) { |
105 Hide(); | 141 Hide(); |
106 } | 142 } |
107 } else if (cursor_pos.y() < kSlideInRegionHeightPx && | 143 } else if (cursor_pos.y() < kSlideInRegionHeightPx && |
108 CanMouseTriggerSlideIn()) { | 144 CanMouseTriggerSlideIn()) { |
109 Show(); | 145 Show(); |
110 } else if (IsAnimating()) { | 146 } else if (IsAnimating()) { |
111 // The cursor is not idle and either it's in the slide-in region or it's in | 147 // The cursor is not idle and either it's in the slide-in region or it's in |
112 // the neutral region and we're sliding in or out. | 148 // the neutral region and we're sliding in or out. |
113 Show(); | 149 Show(); |
114 } | 150 } |
(...skipping 22 matching lines...) Expand all Loading... | |
137 } | 173 } |
138 | 174 |
139 base::string16 ExclusiveAccessBubble::GetCurrentAllowButtonText() const { | 175 base::string16 ExclusiveAccessBubble::GetCurrentAllowButtonText() const { |
140 return exclusive_access_bubble::GetAllowButtonTextForType(bubble_type_, url_); | 176 return exclusive_access_bubble::GetAllowButtonTextForType(bubble_type_, url_); |
141 } | 177 } |
142 | 178 |
143 base::string16 ExclusiveAccessBubble::GetInstructionText() const { | 179 base::string16 ExclusiveAccessBubble::GetInstructionText() const { |
144 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, | 180 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, |
145 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY)); | 181 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY)); |
146 } | 182 } |
OLD | NEW |