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

Side by Side Diff: chrome/browser/ui/exclusive_access/exclusive_access_bubble.cc

Issue 1254543002: Change exclusive access popup behaviour with simplified-fullscreen-ui. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@exclusiveaccess-remove-confirmation
Patch Set: Minor. Created 5 years, 4 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
OLDNEW
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::kInitialDebounceTimeMs = 500;
msw 2015/08/04 18:21:50 nit: rename this |kInitialNotifyTimeMs| to match |
Matt Giuca 2015/08/05 03:27:20 Since scheib told me to rename kRenotifyTimeMs, I'
29 const int ExclusiveAccessBubble::kRenotifyTimeMs = 60000; // 1 minute.
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/keyboard input.
msw 2015/08/04 18:21:51 nit: no keyboard...
Matt Giuca 2015/08/05 03:27:20 Done.
45 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) {
46 aggressive_notify_timeout_.Start(
47 FROM_HERE, base::TimeDelta::FromMilliseconds(kInitialDebounceTimeMs),
48 this, &ExclusiveAccessBubble::CheckMousePosition);
49 }
40 } 50 }
41 51
42 ExclusiveAccessBubble::~ExclusiveAccessBubble() { 52 ExclusiveAccessBubble::~ExclusiveAccessBubble() {
43 } 53 }
44 54
45 void ExclusiveAccessBubble::StartWatchingMouse() { 55 void ExclusiveAccessBubble::StartWatchingMouse() {
46 // Start the initial delay timer and begin watching the mouse. 56 // Start the initial delay timer and begin watching the mouse.
msw 2015/08/04 18:21:50 nit: update comment ('initial delay')?
Matt Giuca 2015/08/05 03:27:19 I think this comment is OK (we are using hide_time
47 initial_delay_.Start(FROM_HERE, 57 if (!ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) {
48 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, 58 hide_timeout_.Start(FROM_HERE,
49 &ExclusiveAccessBubble::CheckMousePosition); 59 base::TimeDelta::FromMilliseconds(kInitialDelayMs),
60 this, &ExclusiveAccessBubble::CheckMousePosition);
61 }
50 gfx::Point cursor_pos = GetCursorScreenPoint(); 62 gfx::Point cursor_pos = GetCursorScreenPoint();
51 last_mouse_pos_ = cursor_pos; 63 last_mouse_pos_ = cursor_pos;
52 mouse_position_checker_.Start( 64 mouse_position_checker_.Start(
53 FROM_HERE, base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), 65 FROM_HERE, base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz),
54 this, &ExclusiveAccessBubble::CheckMousePosition); 66 this, &ExclusiveAccessBubble::CheckMousePosition);
55 } 67 }
56 68
57 void ExclusiveAccessBubble::StopWatchingMouse() { 69 void ExclusiveAccessBubble::StopWatchingMouse() {
58 initial_delay_.Stop(); 70 hide_timeout_.Stop();
59 idle_timeout_.Stop(); 71 idle_timeout_.Stop();
60 mouse_position_checker_.Stop(); 72 mouse_position_checker_.Stop();
61 } 73 }
62 74
63 bool ExclusiveAccessBubble::IsWatchingMouse() const { 75 bool ExclusiveAccessBubble::IsWatchingMouse() const {
64 return mouse_position_checker_.IsRunning(); 76 return mouse_position_checker_.IsRunning();
65 } 77 }
66 78
67 void ExclusiveAccessBubble::CheckMousePosition() { 79 void ExclusiveAccessBubble::CheckMousePosition() {
68 // Desired behavior: 80 // Desired behavior:
(...skipping 18 matching lines...) Expand all
87 99
88 gfx::Point cursor_pos = GetCursorScreenPoint(); 100 gfx::Point cursor_pos = GetCursorScreenPoint();
89 101
90 // Check to see whether the mouse is idle. 102 // Check to see whether the mouse is idle.
91 if (cursor_pos != last_mouse_pos_) { 103 if (cursor_pos != last_mouse_pos_) {
92 // The mouse moved; reset the idle timer. 104 // The mouse moved; reset the idle timer.
93 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op. 105 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op.
94 idle_timeout_.Start(FROM_HERE, 106 idle_timeout_.Start(FROM_HERE,
95 base::TimeDelta::FromMilliseconds(kIdleTimeMs), this, 107 base::TimeDelta::FromMilliseconds(kIdleTimeMs), this,
96 &ExclusiveAccessBubble::CheckMousePosition); 108 &ExclusiveAccessBubble::CheckMousePosition);
109
110 if (ExclusiveAccessManager::IsSimplifiedFullscreenUIEnabled()) {
111 // If the aggressive notification timer has elapsed, show the notification
112 // regardless of where the mouse is on the screen.
113 if (!aggressive_notify_timeout_.IsRunning()) {
114 Show();
115 // Do not allow the notification to hide for a few seconds.
116 hide_timeout_.Start(FROM_HERE,
117 base::TimeDelta::FromMilliseconds(kIdleTimeMs),
118 this, &ExclusiveAccessBubble::CheckMousePosition);
119 // Do not aggressively show the notification again until a long time has
msw 2015/08/04 18:21:50 nit: remove 'aggressively', maybe rephrase to some
Matt Giuca 2015/08/05 03:27:19 Done.
120 // elapsed.
121 aggressive_notify_timeout_.Start(
122 FROM_HERE, base::TimeDelta::FromMilliseconds(kRenotifyTimeMs), this,
123 &ExclusiveAccessBubble::CheckMousePosition);
124 return;
125 } else {
126 // The timer has not elapsed, but the user moved the mouse. Reset the
127 // timer. (We only want to re-show the message after a period of
128 // inactivity.)
129 aggressive_notify_timeout_.Reset();
130 }
131 }
97 } 132 }
98 last_mouse_pos_ = cursor_pos; 133 last_mouse_pos_ = cursor_pos;
99 134
100 if (!IsWindowActive() || !WindowContainsPoint(cursor_pos) || 135 if (!IsWindowActive() || !WindowContainsPoint(cursor_pos) ||
101 (cursor_pos.y() >= GetPopupRect(true).bottom()) || 136 (cursor_pos.y() >= GetPopupRect(true).bottom()) ||
102 !idle_timeout_.IsRunning()) { 137 !idle_timeout_.IsRunning()) {
103 // The cursor is offscreen, in the slide-out region, or idle. 138 // The cursor is offscreen, in the slide-out region, or idle.
104 if (!initial_delay_.IsRunning()) { 139 if (!hide_timeout_.IsRunning()) {
105 Hide(); 140 Hide();
106 } 141 }
107 } else if (cursor_pos.y() < kSlideInRegionHeightPx && 142 } else if (cursor_pos.y() < kSlideInRegionHeightPx &&
108 CanMouseTriggerSlideIn()) { 143 CanMouseTriggerSlideIn()) {
109 Show(); 144 Show();
110 } else if (IsAnimating()) { 145 } else if (IsAnimating()) {
111 // The cursor is not idle and either it's in the slide-in region or it's in 146 // 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. 147 // the neutral region and we're sliding in or out.
113 Show(); 148 Show();
114 } 149 }
(...skipping 22 matching lines...) Expand all
137 } 172 }
138 173
139 base::string16 ExclusiveAccessBubble::GetCurrentAllowButtonText() const { 174 base::string16 ExclusiveAccessBubble::GetCurrentAllowButtonText() const {
140 return exclusive_access_bubble::GetAllowButtonTextForType(bubble_type_, url_); 175 return exclusive_access_bubble::GetAllowButtonTextForType(bubble_type_, url_);
141 } 176 }
142 177
143 base::string16 ExclusiveAccessBubble::GetInstructionText() const { 178 base::string16 ExclusiveAccessBubble::GetInstructionText() const {
144 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, 179 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT,
145 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY)); 180 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY));
146 } 181 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698