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

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

Issue 789403002: Rename fullscreen_exit_bubble_* to exclusive_access_bubble_* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated based on CR comments Created 6 years 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/fullscreen/fullscreen_exit_bubble.h" 5 #include "chrome/browser/ui/fullscreen/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/browser.h" 10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h" 11 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" 12 #include "chrome/browser/ui/fullscreen/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/rect.h" 16 #include "ui/gfx/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 FullscreenExitBubble::kPaddingPx = 8; 22 const int ExclusiveAccessBubble::kPaddingPx = 8;
23 #else 23 #else
24 const int FullscreenExitBubble::kPaddingPx = 15; 24 const int ExclusiveAccessBubble::kPaddingPx = 15;
25 #endif 25 #endif
26 const int FullscreenExitBubble::kInitialDelayMs = 3800; 26 const int ExclusiveAccessBubble::kInitialDelayMs = 3800;
27 const int FullscreenExitBubble::kIdleTimeMs = 2300; 27 const int ExclusiveAccessBubble::kIdleTimeMs = 2300;
28 const int FullscreenExitBubble::kPositionCheckHz = 10; 28 const int ExclusiveAccessBubble::kPositionCheckHz = 10;
29 const int FullscreenExitBubble::kSlideInRegionHeightPx = 4; 29 const int ExclusiveAccessBubble::kSlideInRegionHeightPx = 4;
30 const int FullscreenExitBubble::kSlideInDurationMs = 350; 30 const int ExclusiveAccessBubble::kSlideInDurationMs = 350;
31 const int FullscreenExitBubble::kSlideOutDurationMs = 700; 31 const int ExclusiveAccessBubble::kSlideOutDurationMs = 700;
32 const int FullscreenExitBubble::kPopupTopPx = 15; 32 const int ExclusiveAccessBubble::kPopupTopPx = 15;
33 33
34 FullscreenExitBubble::FullscreenExitBubble(Browser* browser, 34 ExclusiveAccessBubble::ExclusiveAccessBubble(
35 const GURL& url, 35 Browser* browser,
36 FullscreenExitBubbleType bubble_type) 36 const GURL& url,
37 : browser_(browser), 37 ExclusiveAccessBubbleType bubble_type)
38 url_(url), 38 : browser_(browser), url_(url), bubble_type_(bubble_type) {
39 bubble_type_(bubble_type) { 39 DCHECK_NE(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE, bubble_type_);
40 DCHECK_NE(FEB_TYPE_NONE, bubble_type_);
41 } 40 }
42 41
43 FullscreenExitBubble::~FullscreenExitBubble() { 42 ExclusiveAccessBubble::~ExclusiveAccessBubble() {
44 } 43 }
45 44
46 void FullscreenExitBubble::StartWatchingMouse() { 45 void ExclusiveAccessBubble::StartWatchingMouse() {
47 // Start the initial delay timer and begin watching the mouse. 46 // Start the initial delay timer and begin watching the mouse.
48 initial_delay_.Start(FROM_HERE, 47 initial_delay_.Start(FROM_HERE,
49 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this, 48 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this,
50 &FullscreenExitBubble::CheckMousePosition); 49 &ExclusiveAccessBubble::CheckMousePosition);
51 gfx::Point cursor_pos = GetCursorScreenPoint(); 50 gfx::Point cursor_pos = GetCursorScreenPoint();
52 last_mouse_pos_ = cursor_pos; 51 last_mouse_pos_ = cursor_pos;
53 mouse_position_checker_.Start(FROM_HERE, 52 mouse_position_checker_.Start(
54 base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this, 53 FROM_HERE, base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz),
55 &FullscreenExitBubble::CheckMousePosition); 54 this, &ExclusiveAccessBubble::CheckMousePosition);
56 } 55 }
57 56
58 void FullscreenExitBubble::StopWatchingMouse() { 57 void ExclusiveAccessBubble::StopWatchingMouse() {
59 initial_delay_.Stop(); 58 initial_delay_.Stop();
60 idle_timeout_.Stop(); 59 idle_timeout_.Stop();
61 mouse_position_checker_.Stop(); 60 mouse_position_checker_.Stop();
62 } 61 }
63 62
64 bool FullscreenExitBubble::IsWatchingMouse() const { 63 bool ExclusiveAccessBubble::IsWatchingMouse() const {
65 return mouse_position_checker_.IsRunning(); 64 return mouse_position_checker_.IsRunning();
66 } 65 }
67 66
68 void FullscreenExitBubble::CheckMousePosition() { 67 void ExclusiveAccessBubble::CheckMousePosition() {
69 // Desired behavior: 68 // Desired behavior:
70 // 69 //
71 // +------------+-----------------------------+------------+ 70 // +------------+-----------------------------+------------+
72 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region 71 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region
73 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region 72 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region
74 // | | Slide-out region 73 // | | Slide-out region
75 // : : 74 // : :
76 // 75 //
77 // * If app is not active, we hide the popup. 76 // * If app is not active, we hide the popup.
78 // * If the mouse is offscreen or in the slide-out region, we hide the popup. 77 // * If the mouse is offscreen or in the slide-out region, we hide the popup.
79 // * If the mouse goes idle, we hide the popup. 78 // * If the mouse goes idle, we hide the popup.
80 // * If the mouse is in the slide-in-region and not idle, we show the popup. 79 // * If the mouse is in the slide-in-region and not idle, we show the popup.
81 // * If the mouse is in the neutral region and not idle, and the popup is 80 // * If the mouse is in the neutral region and not idle, and the popup is
82 // currently sliding out, we show it again. This facilitates users 81 // currently sliding out, we show it again. This facilitates users
83 // correcting us if they try to mouse horizontally towards the popup and 82 // correcting us if they try to mouse horizontally towards the popup and
84 // unintentionally drop too low. 83 // unintentionally drop too low.
85 // * Otherwise, we do nothing, because the mouse is in the neutral region and 84 // * Otherwise, we do nothing, because the mouse is in the neutral region and
86 // either the popup is hidden or the mouse is not idle, so we don't want to 85 // either the popup is hidden or the mouse is not idle, so we don't want to
87 // change anything's state. 86 // change anything's state.
88 87
89 gfx::Point cursor_pos = GetCursorScreenPoint(); 88 gfx::Point cursor_pos = GetCursorScreenPoint();
90 89
91 // Check to see whether the mouse is idle. 90 // Check to see whether the mouse is idle.
92 if (cursor_pos != last_mouse_pos_) { 91 if (cursor_pos != last_mouse_pos_) {
93 // The mouse moved; reset the idle timer. 92 // The mouse moved; reset the idle timer.
94 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op. 93 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op.
95 idle_timeout_.Start(FROM_HERE, 94 idle_timeout_.Start(FROM_HERE,
96 base::TimeDelta::FromMilliseconds(kIdleTimeMs), this, 95 base::TimeDelta::FromMilliseconds(kIdleTimeMs), this,
97 &FullscreenExitBubble::CheckMousePosition); 96 &ExclusiveAccessBubble::CheckMousePosition);
98 } 97 }
99 last_mouse_pos_ = cursor_pos; 98 last_mouse_pos_ = cursor_pos;
100 99
101 if (!IsWindowActive() || 100 if (!IsWindowActive() || !WindowContainsPoint(cursor_pos) ||
102 !WindowContainsPoint(cursor_pos) ||
103 (cursor_pos.y() >= GetPopupRect(true).bottom()) || 101 (cursor_pos.y() >= GetPopupRect(true).bottom()) ||
104 !idle_timeout_.IsRunning()) { 102 !idle_timeout_.IsRunning()) {
105 // The cursor is offscreen, in the slide-out region, or idle. 103 // The cursor is offscreen, in the slide-out region, or idle.
106 if (!initial_delay_.IsRunning()) { 104 if (!initial_delay_.IsRunning()) {
107 Hide(); 105 Hide();
108 } 106 }
109 } else if (cursor_pos.y() < kSlideInRegionHeightPx && 107 } else if (cursor_pos.y() < kSlideInRegionHeightPx &&
110 CanMouseTriggerSlideIn()) { 108 CanMouseTriggerSlideIn()) {
111 Show(); 109 Show();
112 } else if (IsAnimating()) { 110 } else if (IsAnimating()) {
113 // The cursor is not idle and either it's in the slide-in region or it's in 111 // The cursor is not idle and either it's in the slide-in region or it's in
114 // the neutral region and we're sliding in or out. 112 // the neutral region and we're sliding in or out.
115 Show(); 113 Show();
116 } 114 }
117 } 115 }
118 116
119 void FullscreenExitBubble::ToggleFullscreen() { 117 void ExclusiveAccessBubble::ToggleFullscreen() {
120 browser_->fullscreen_controller()-> 118 browser_->fullscreen_controller()
121 ExitTabOrBrowserFullscreenToPreviousState(); 119 ->ExitTabOrBrowserFullscreenToPreviousState();
122 } 120 }
123 121
124 void FullscreenExitBubble::Accept() { 122 void ExclusiveAccessBubble::Accept() {
125 browser_->fullscreen_controller()->OnAcceptFullscreenPermission(); 123 browser_->fullscreen_controller()->OnAcceptFullscreenPermission();
126 } 124 }
127 125
128 void FullscreenExitBubble::Cancel() { 126 void ExclusiveAccessBubble::Cancel() {
129 browser_->fullscreen_controller()->OnDenyFullscreenPermission(); 127 browser_->fullscreen_controller()->OnDenyFullscreenPermission();
130 } 128 }
131 129
132 base::string16 FullscreenExitBubble::GetCurrentMessageText() const { 130 base::string16 ExclusiveAccessBubble::GetCurrentMessageText() const {
133 return fullscreen_bubble::GetLabelTextForType( 131 return exclusive_access_bubble::GetLabelTextForType(
134 bubble_type_, url_, 132 bubble_type_, url_,
135 extensions::ExtensionRegistry::Get(browser_->profile())); 133 extensions::ExtensionRegistry::Get(browser_->profile()));
136 } 134 }
137 135
138 base::string16 FullscreenExitBubble::GetCurrentDenyButtonText() const { 136 base::string16 ExclusiveAccessBubble::GetCurrentDenyButtonText() const {
139 return fullscreen_bubble::GetDenyButtonTextForType(bubble_type_); 137 return exclusive_access_bubble::GetDenyButtonTextForType(bubble_type_);
140 } 138 }
141 139
142 base::string16 FullscreenExitBubble::GetAllowButtonText() const { 140 base::string16 ExclusiveAccessBubble::GetAllowButtonText() const {
143 return l10n_util::GetStringUTF16(IDS_FULLSCREEN_ALLOW); 141 return l10n_util::GetStringUTF16(IDS_FULLSCREEN_ALLOW);
144 } 142 }
145 143
146 base::string16 FullscreenExitBubble::GetInstructionText() const { 144 base::string16 ExclusiveAccessBubble::GetInstructionText() const {
147 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, 145 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT,
148 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY)); 146 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY));
149 } 147 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/fullscreen/exclusive_access_bubble.h ('k') | chrome/browser/ui/fullscreen/exclusive_access_bubble_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698