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

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: Sync 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() &&
34 (!fullscreen_controller_.IsWindowFullscreenForTabOrPending() ||
35 fullscreen_controller_.IsUserAcceptedFullscreen()))
36 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
37
38 if (!fullscreen_controller_.IsWindowFullscreenForTabOrPending()) {
39 if (mouse_lock_controller_.IsMouseLocked())
40 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION;
41 if (mouse_lock_controller_.IsMouseLockRequested())
42 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS;
43 if (fullscreen_controller_.IsExtensionFullscreenOrPending())
44 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION;
45 if (fullscreen_controller_.IsControllerInitiatedFullscreen() && !app_mode)
46 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
47 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
48 }
49
50 if (fullscreen_controller_.IsUserAcceptedFullscreen()) {
51 if (fullscreen_controller_.IsPrivilegedFullscreenForTab())
52 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
53 if (mouse_lock_controller_.IsMouseLocked())
54 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION;
55 if (mouse_lock_controller_.IsMouseLockRequested())
56 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS;
57 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION;
58 }
59
60 if (mouse_lock_controller_.IsMouseLockRequested())
61 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS;
62 return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_BUTTONS;
63 }
64
65 void ExclusiveAccessManager::UpdateExclusiveAccessExitBubbleContent() {
66 GURL url = GetExclusiveAccessBubbleURL();
67 ExclusiveAccessBubbleType bubble_type = GetExclusiveAccessExitBubbleType();
68
69 // If bubble displays buttons, unlock mouse to allow pressing them.
70 if (exclusive_access_bubble::ShowButtonsForType(bubble_type) &&
71 mouse_lock_controller_.IsMouseLocked())
72 mouse_lock_controller_.UnlockMouse();
73
74 browser_->window()->UpdateFullscreenExitBubbleContent(url, bubble_type);
75 }
76
77 GURL ExclusiveAccessManager::GetExclusiveAccessBubbleURL() const {
78 GURL result = fullscreen_controller_.GetURLForExclusiveAccessBubble();
79 if (!result.is_valid())
80 result = mouse_lock_controller_.GetURLForExclusiveAccessBubble();
81 return result;
82 }
83
84 void ExclusiveAccessManager::OnTabDeactivated(WebContents* web_contents) {
85 fullscreen_controller_.OnTabDeactivated(web_contents);
86 mouse_lock_controller_.OnTabDeactivated(web_contents);
87 }
88
89 void ExclusiveAccessManager::OnTabDetachedFromView(WebContents* web_contents) {
90 fullscreen_controller_.OnTabDetachedFromView(web_contents);
91 mouse_lock_controller_.OnTabDetachedFromView(web_contents);
92 }
93
94 void ExclusiveAccessManager::OnTabClosing(WebContents* web_contents) {
95 fullscreen_controller_.OnTabClosing(web_contents);
96 mouse_lock_controller_.OnTabClosing(web_contents);
97 }
98
99 bool ExclusiveAccessManager::HandleUserPressedEscape() {
100 bool handled = false;
101 handled = fullscreen_controller_.HandleUserPressedEscape();
102 handled |= mouse_lock_controller_.HandleUserPressedEscape();
103 return handled;
104 }
105
106 void ExclusiveAccessManager::OnAcceptExclusiveAccessPermission() {
107 bool updateBubble =
108 mouse_lock_controller_.OnAcceptExclusiveAccessPermission();
109 updateBubble |= fullscreen_controller_.OnAcceptExclusiveAccessPermission();
110 if (updateBubble)
111 UpdateExclusiveAccessExitBubbleContent();
112 }
113
114 void ExclusiveAccessManager::OnDenyExclusiveAccessPermission() {
115 bool updateBubble = mouse_lock_controller_.OnDenyExclusiveAccessPermission();
116 updateBubble |= fullscreen_controller_.OnDenyExclusiveAccessPermission();
117 if (updateBubble)
118 UpdateExclusiveAccessExitBubbleContent();
119 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698