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

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

Issue 836933005: Refactor fullscreen_controller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix mac build break after rebase to TOT Created 5 years, 11 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
(Empty)
1 // Copyright (c) 2015 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/exclusive_access/exclusive_access_manager.h"
6
7 #include "chrome/browser/app_mode/app_mode_utils.h"
8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/browser_window.h"
10 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
11 #include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h"
12
13 using content::WebContents;
14
15 ExclusiveAccessManager::ExclusiveAccessManager(Browser* browser)
16 : browser_(browser),
17 fullscreen_controller_(this, browser),
18 mouse_lock_controller_(this, browser) {
19 }
20
21 ExclusiveAccessManager::~ExclusiveAccessManager() {
22 }
23
24 ExclusiveAccessBubbleType
25 ExclusiveAccessManager::GetExclusiveAccessExitBubbleType() const {
26 // In kiosk and exclusive app mode we always want to be fullscreen and do not
27 // want to show exit instructions for browser mode fullscreen.
28 bool app_mode = false;
29 #if !defined(OS_MACOSX) // App mode (kiosk) is not available on Mac yet.
30 app_mode = chrome::IsRunningInAppMode();
31 #endif
32
33 if (mouse_lock_controller_.IsMouseLockSilentlyAccepted())
scheib 2015/01/22 22:54:04 There could be a bug here. 1. Clear content settin
Sriram 2015/01/23 07:13:43 Great catch and verified that this repros in TOT c
scheib 2015/01/23 16:42:32 http://images.clipartpanda.com/teamwork-funny-meme
34 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
35
36 if (!fullscreen_controller_.IsWindowFullscreenForTabOrPending()) {
37 if (mouse_lock_controller_.IsMouseLocked())
38 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION;
39 if (mouse_lock_controller_.IsMouseLockRequested())
40 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS;
41 if (fullscreen_controller_.IsExtensionFullscreenOrPending())
42 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION;
43 if (fullscreen_controller_.IsControllerInitiatedFullscreen() && !app_mode)
44 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
45 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
46 }
47
48 if (fullscreen_controller_.IsUserAcceptedFullscreen()) {
49 if (fullscreen_controller_.IsPrivilegedFullscreenForTab())
50 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
51 if (mouse_lock_controller_.IsMouseLocked())
52 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION;
53 if (mouse_lock_controller_.IsMouseLockRequested())
54 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS;
55 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION;
56 }
57
58 if (mouse_lock_controller_.IsMouseLockRequested())
59 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS;
60 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_BUTTONS;
61 }
62
63 void ExclusiveAccessManager::UpdateExclusiveAccessExitBubbleContent() {
64 GURL url = GetExclusiveAccessBubbleURL();
65 ExclusiveAccessBubbleType bubble_type = GetExclusiveAccessExitBubbleType();
66
67 // If bubble displays buttons, unlock mouse to allow pressing them.
68 if (exclusive_access_bubble::ShowButtonsForType(bubble_type) &&
69 mouse_lock_controller_.IsMouseLocked())
70 mouse_lock_controller_.UnlockMouse();
71
72 browser_->window()->UpdateFullscreenExitBubbleContent(url, bubble_type);
73 }
74
75 GURL ExclusiveAccessManager::GetExclusiveAccessBubbleURL() const {
76 GURL result = fullscreen_controller_.GetURLForExclusiveAccessBubble();
77 if (!result.is_valid())
78 result = mouse_lock_controller_.GetURLForExclusiveAccessBubble();
79 return result;
80 }
81
82 void ExclusiveAccessManager::OnTabDeactivated(WebContents* web_contents) {
83 fullscreen_controller_.OnTabDeactivated(web_contents);
84 mouse_lock_controller_.OnTabDeactivated(web_contents);
85 }
86
87 void ExclusiveAccessManager::OnTabDetachedFromView(WebContents* web_contents) {
88 fullscreen_controller_.OnTabDetachedFromView(web_contents);
89 mouse_lock_controller_.OnTabDetachedFromView(web_contents);
90 }
91
92 void ExclusiveAccessManager::OnTabClosing(WebContents* web_contents) {
93 fullscreen_controller_.OnTabClosing(web_contents);
94 mouse_lock_controller_.OnTabClosing(web_contents);
95 }
96
97 bool ExclusiveAccessManager::HandleUserPressedEscape() {
98 bool handled = false;
99 handled = fullscreen_controller_.HandleUserPressedEscape();
100 handled |= mouse_lock_controller_.HandleUserPressedEscape();
101 return handled;
102 }
103
104 void ExclusiveAccessManager::OnAcceptExclusiveAccessPermission() {
105 bool updateBubble =
106 mouse_lock_controller_.OnAcceptExclusiveAccessPermission();
107 updateBubble |= fullscreen_controller_.OnAcceptExclusiveAccessPermission();
108 if (updateBubble)
109 UpdateExclusiveAccessExitBubbleContent();
110 }
111
112 void ExclusiveAccessManager::OnDenyExclusiveAccessPermission() {
113 bool updateBubble = mouse_lock_controller_.OnDenyExclusiveAccessPermission();
114 updateBubble |= fullscreen_controller_.OnDenyExclusiveAccessPermission();
115 if (updateBubble)
116 UpdateExclusiveAccessExitBubbleContent();
117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698