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

Side by Side Diff: chrome/browser/ui/fullscreen/fullscreen_exit_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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/fullscreen/fullscreen_exit_bubble.h"
6
7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h"
13 #include "chrome/grit/generated_resources.h"
14 #include "extensions/browser/extension_registry.h"
15 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/gfx/rect.h"
17 #include "ui/strings/grit/ui_strings.h"
18
19 // NOTE(koz): Linux doesn't use the thick shadowed border, so we add padding
20 // here.
21 #if defined(OS_LINUX)
22 const int FullscreenExitBubble::kPaddingPx = 8;
23 #else
24 const int FullscreenExitBubble::kPaddingPx = 15;
25 #endif
26 const int FullscreenExitBubble::kInitialDelayMs = 3800;
27 const int FullscreenExitBubble::kIdleTimeMs = 2300;
28 const int FullscreenExitBubble::kPositionCheckHz = 10;
29 const int FullscreenExitBubble::kSlideInRegionHeightPx = 4;
30 const int FullscreenExitBubble::kSlideInDurationMs = 350;
31 const int FullscreenExitBubble::kSlideOutDurationMs = 700;
32 const int FullscreenExitBubble::kPopupTopPx = 15;
33
34 FullscreenExitBubble::FullscreenExitBubble(Browser* browser,
35 const GURL& url,
36 FullscreenExitBubbleType bubble_type)
37 : browser_(browser),
38 url_(url),
39 bubble_type_(bubble_type) {
40 DCHECK_NE(FEB_TYPE_NONE, bubble_type_);
41 }
42
43 FullscreenExitBubble::~FullscreenExitBubble() {
44 }
45
46 void FullscreenExitBubble::StartWatchingMouse() {
47 // Start the initial delay timer and begin watching the mouse.
48 initial_delay_.Start(FROM_HERE,
49 base::TimeDelta::FromMilliseconds(kInitialDelayMs), this,
50 &FullscreenExitBubble::CheckMousePosition);
51 gfx::Point cursor_pos = GetCursorScreenPoint();
52 last_mouse_pos_ = cursor_pos;
53 mouse_position_checker_.Start(FROM_HERE,
54 base::TimeDelta::FromMilliseconds(1000 / kPositionCheckHz), this,
55 &FullscreenExitBubble::CheckMousePosition);
56 }
57
58 void FullscreenExitBubble::StopWatchingMouse() {
59 initial_delay_.Stop();
60 idle_timeout_.Stop();
61 mouse_position_checker_.Stop();
62 }
63
64 bool FullscreenExitBubble::IsWatchingMouse() const {
65 return mouse_position_checker_.IsRunning();
66 }
67
68 void FullscreenExitBubble::CheckMousePosition() {
69 // Desired behavior:
70 //
71 // +------------+-----------------------------+------------+
72 // | _ _ _ _ | Exit full screen mode (F11) | _ _ _ _ | Slide-in region
73 // | _ _ _ _ \_____________________________/ _ _ _ _ | Neutral region
74 // | | Slide-out region
75 // : :
76 //
77 // * 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.
79 // * 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.
81 // * 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
83 // correcting us if they try to mouse horizontally towards the popup and
84 // unintentionally drop too low.
85 // * 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
87 // change anything's state.
88
89 gfx::Point cursor_pos = GetCursorScreenPoint();
90
91 // Check to see whether the mouse is idle.
92 if (cursor_pos != last_mouse_pos_) {
93 // The mouse moved; reset the idle timer.
94 idle_timeout_.Stop(); // If the timer isn't running, this is a no-op.
95 idle_timeout_.Start(FROM_HERE,
96 base::TimeDelta::FromMilliseconds(kIdleTimeMs), this,
97 &FullscreenExitBubble::CheckMousePosition);
98 }
99 last_mouse_pos_ = cursor_pos;
100
101 if (!IsWindowActive() ||
102 !WindowContainsPoint(cursor_pos) ||
103 (cursor_pos.y() >= GetPopupRect(true).bottom()) ||
104 !idle_timeout_.IsRunning()) {
105 // The cursor is offscreen, in the slide-out region, or idle.
106 if (!initial_delay_.IsRunning()) {
107 Hide();
108 }
109 } else if (cursor_pos.y() < kSlideInRegionHeightPx &&
110 CanMouseTriggerSlideIn()) {
111 Show();
112 } else if (IsAnimating()) {
113 // 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.
115 Show();
116 }
117 }
118
119 void FullscreenExitBubble::ToggleFullscreen() {
120 browser_->fullscreen_controller()->
121 ExitTabOrBrowserFullscreenToPreviousState();
122 }
123
124 void FullscreenExitBubble::Accept() {
125 browser_->fullscreen_controller()->OnAcceptFullscreenPermission();
126 }
127
128 void FullscreenExitBubble::Cancel() {
129 browser_->fullscreen_controller()->OnDenyFullscreenPermission();
130 }
131
132 base::string16 FullscreenExitBubble::GetCurrentMessageText() const {
133 return fullscreen_bubble::GetLabelTextForType(
134 bubble_type_, url_,
135 extensions::ExtensionRegistry::Get(browser_->profile()));
136 }
137
138 base::string16 FullscreenExitBubble::GetCurrentDenyButtonText() const {
139 return fullscreen_bubble::GetDenyButtonTextForType(bubble_type_);
140 }
141
142 base::string16 FullscreenExitBubble::GetAllowButtonText() const {
143 return l10n_util::GetStringUTF16(IDS_FULLSCREEN_ALLOW);
144 }
145
146 base::string16 FullscreenExitBubble::GetInstructionText() const {
147 return l10n_util::GetStringFUTF16(IDS_FULLSCREEN_PRESS_ESC_TO_EXIT,
148 l10n_util::GetStringUTF16(IDS_APP_ESC_KEY));
149 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/fullscreen/fullscreen_exit_bubble.h ('k') | chrome/browser/ui/fullscreen/fullscreen_exit_bubble_type.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698