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

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

Issue 9702055: Automated tests for full screen & mouse lock M16 features (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Valgrind error fix, merge to 130358 Created 8 years, 8 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
« no previous file with comments | « chrome/browser/ui/fullscreen_controller.h ('k') | chrome/browser/ui/tests/browser_uitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_controller.h" 5 #include "chrome/browser/ui/fullscreen_controller.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "chrome/browser/content_settings/host_content_settings_map.h" 10 #include "chrome/browser/content_settings/host_content_settings_map.h"
(...skipping 21 matching lines...) Expand all
32 profile_(profile), 32 profile_(profile),
33 browser_(browser), 33 browser_(browser),
34 fullscreened_tab_(NULL), 34 fullscreened_tab_(NULL),
35 tab_caused_fullscreen_(false), 35 tab_caused_fullscreen_(false),
36 tab_fullscreen_accepted_(false), 36 tab_fullscreen_accepted_(false),
37 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED) { 37 mouse_lock_state_(MOUSELOCK_NOT_REQUESTED) {
38 } 38 }
39 39
40 FullscreenController::~FullscreenController() {} 40 FullscreenController::~FullscreenController() {}
41 41
42 bool FullscreenController::IsFullscreenForTab() const { 42 bool FullscreenController::IsFullscreenForBrowser() const {
43 return window_->IsFullscreen() && !tab_caused_fullscreen_;
44 }
45
46 bool FullscreenController::IsFullscreenForTabOrPending() const {
43 return fullscreened_tab_ != NULL; 47 return fullscreened_tab_ != NULL;
44 } 48 }
45 49
46 bool FullscreenController::IsFullscreenForTab(const WebContents* tab) const {
47 if (IsFullscreenForTabOrPending(tab)) {
48 DCHECK(window_->IsFullscreen());
49 return true;
50 }
51 return false;
52 }
53
54 bool FullscreenController::IsFullscreenForTabOrPending( 50 bool FullscreenController::IsFullscreenForTabOrPending(
55 const WebContents* tab) const { 51 const WebContents* tab) const {
56 const TabContentsWrapper* wrapper = 52 const TabContentsWrapper* wrapper =
57 TabContentsWrapper::GetCurrentWrapperForContents(tab); 53 TabContentsWrapper::GetCurrentWrapperForContents(tab);
58 if (!wrapper || (wrapper != fullscreened_tab_)) 54 if (!wrapper || (wrapper != fullscreened_tab_))
59 return false; 55 return false;
60 DCHECK(tab == browser_->GetSelectedWebContents()); 56 DCHECK(tab == browser_->GetSelectedWebContents());
61 return true; 57 return true;
62 } 58 }
63 59
60 bool FullscreenController::IsMouseLockedOrPending() const {
61 return mouse_lock_state_ != MOUSELOCK_NOT_REQUESTED;
62 }
63
64 void FullscreenController::RequestToLockMouse(WebContents* tab) { 64 void FullscreenController::RequestToLockMouse(WebContents* tab) {
65 // Mouse Lock is only permitted when browser is in tab fullscreen. 65 // Mouse Lock is only permitted when browser is in tab fullscreen.
66 if (!IsFullscreenForTabOrPending(tab)) { 66 if (!IsFullscreenForTabOrPending(tab)) {
67 tab->GotResponseToLockMouseRequest(false); 67 tab->GotResponseToLockMouseRequest(false);
68 return; 68 return;
69 } 69 }
70 70
71 if (mouse_lock_state_ == MOUSELOCK_ACCEPTED) { 71 if (mouse_lock_state_ == MOUSELOCK_ACCEPTED) {
72 tab->GotResponseToLockMouseRequest(true); 72 tab->GotResponseToLockMouseRequest(true);
73 return; 73 return;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 extension_caused_fullscreen_ = extension_url; 164 extension_caused_fullscreen_ = extension_url;
165 ToggleFullscreenModeInternal(false); 165 ToggleFullscreenModeInternal(false);
166 } 166 }
167 167
168 void FullscreenController::LostMouseLock() { 168 void FullscreenController::LostMouseLock() {
169 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED; 169 mouse_lock_state_ = MOUSELOCK_NOT_REQUESTED;
170 UpdateFullscreenExitBubbleContent(); 170 UpdateFullscreenExitBubbleContent();
171 } 171 }
172 172
173 void FullscreenController::OnTabClosing(WebContents* web_contents) { 173 void FullscreenController::OnTabClosing(WebContents* web_contents) {
174 if (IsFullscreenForTab(web_contents)) { 174 if (IsFullscreenForTabOrPending(web_contents)) {
175 ExitTabbedFullscreenModeIfNecessary(); 175 ExitTabbedFullscreenModeIfNecessary();
176 // The call to exit fullscreen may result in asynchronous notification of 176 // The call to exit fullscreen may result in asynchronous notification of
177 // fullscreen state change (e.g., on Linux). We don't want to rely on it 177 // fullscreen state change (e.g., on Linux). We don't want to rely on it
178 // to call NotifyTabOfFullscreenExitIfNecessary(), because at that point 178 // to call NotifyTabOfFullscreenExitIfNecessary(), because at that point
179 // |fullscreen_tab_| may not be valid. Instead, we call it here to clean up 179 // |fullscreen_tab_| may not be valid. Instead, we call it here to clean up
180 // tab fullscreen related state. 180 // tab fullscreen related state.
181 NotifyTabOfFullscreenExitIfNecessary(); 181 NotifyTabOfFullscreenExitIfNecessary();
182 } 182 }
183 } 183 }
184 184
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 NotifyTabOfFullscreenExitIfNecessary(); 258 NotifyTabOfFullscreenExitIfNecessary();
259 #if !defined(OS_CHROMEOS) 259 #if !defined(OS_CHROMEOS)
260 if (exiting_fullscreen) 260 if (exiting_fullscreen)
261 window_->GetDownloadShelf()->Unhide(); 261 window_->GetDownloadShelf()->Unhide();
262 else 262 else
263 window_->GetDownloadShelf()->Hide(); 263 window_->GetDownloadShelf()->Hide();
264 #endif 264 #endif
265 } 265 }
266 266
267 bool FullscreenController::HandleUserPressedEscape() { 267 bool FullscreenController::HandleUserPressedEscape() {
268 if (!IsFullscreenForTab()) 268 if (!IsFullscreenForTabOrPending())
269 return false; 269 return false;
270 ExitTabbedFullscreenModeIfNecessary(); 270 ExitTabbedFullscreenModeIfNecessary();
271 return true; 271 return true;
272 } 272 }
273 273
274 void FullscreenController::NotifyTabOfFullscreenExitIfNecessary() { 274 void FullscreenController::NotifyTabOfFullscreenExitIfNecessary() {
275 if (fullscreened_tab_) { 275 if (fullscreened_tab_) {
276 RenderViewHost* rvh = 276 RenderViewHost* rvh =
277 fullscreened_tab_->web_contents()->GetRenderViewHost(); 277 fullscreened_tab_->web_contents()->GetRenderViewHost();
278 fullscreened_tab_ = NULL; 278 fullscreened_tab_ = NULL;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 // WindowFullscreenStateChanged(). We don't do this immediately as 403 // WindowFullscreenStateChanged(). We don't do this immediately as
404 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let 404 // BrowserWindow::EnterFullscreen() asks for bookmark_bar_state_, so we let
405 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate. 405 // the BrowserWindow invoke WindowFullscreenStateChanged when appropriate.
406 406
407 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates 407 // TODO: convert mac to invoke WindowFullscreenStateChanged once it updates
408 // the necessary state of the frame. 408 // the necessary state of the frame.
409 #if defined(OS_MACOSX) 409 #if defined(OS_MACOSX)
410 WindowFullscreenStateChanged(); 410 WindowFullscreenStateChanged();
411 #endif 411 #endif
412 } 412 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/fullscreen_controller.h ('k') | chrome/browser/ui/tests/browser_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698