| Index: chrome/browser/ui/exclusive_access/exclusive_access_controller_manager.cc
|
| diff --git a/chrome/browser/ui/exclusive_access/exclusive_access_controller_manager.cc b/chrome/browser/ui/exclusive_access/exclusive_access_controller_manager.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..24391b433f650d4c24a8133055d45442176649d4
|
| --- /dev/null
|
| +++ b/chrome/browser/ui/exclusive_access/exclusive_access_controller_manager.cc
|
| @@ -0,0 +1,133 @@
|
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "chrome/browser/ui/exclusive_access/exclusive_access_controller_manager.h"
|
| +
|
| +#include "chrome/browser/app_mode/app_mode_utils.h"
|
| +#include "chrome/browser/ui/browser.h"
|
| +#include "chrome/browser/ui/browser_window.h"
|
| +#include "chrome/browser/ui/exclusive_access/fullscreen_controller.h"
|
| +#include "chrome/browser/ui/exclusive_access/mouse_lock_controller.h"
|
| +
|
| +using content::WebContents;
|
| +
|
| +ExclusiveAccessControllerManager::ExclusiveAccessControllerManager(
|
| + Browser* browser)
|
| + : browser_(browser), window_(browser->window()) {
|
| + DCHECK(window_);
|
| +
|
| + fullscreen_controller_.reset(new FullscreenController(this, browser_));
|
| + mouse_lock_controller_.reset(new MouseLockController(this, browser_));
|
| +}
|
| +
|
| +ExclusiveAccessControllerManager::~ExclusiveAccessControllerManager() {
|
| +}
|
| +
|
| +FullscreenController*
|
| +ExclusiveAccessControllerManager::GetFullscreenController() {
|
| + return fullscreen_controller_.get();
|
| +}
|
| +
|
| +MouseLockController*
|
| +ExclusiveAccessControllerManager::GetMouseLockController() {
|
| + return mouse_lock_controller_.get();
|
| +}
|
| +
|
| +ExclusiveAccessBubbleType
|
| +ExclusiveAccessControllerManager::GetExclusiveAccessExitBubbleType() const {
|
| + // In kiosk and exclusive app mode we always want to be fullscreen and do not
|
| + // want to show exit instructions for browser mode fullscreen.
|
| + bool app_mode = false;
|
| +#if !defined(OS_MACOSX) // App mode (kiosk) is not available on Mac yet.
|
| + app_mode = chrome::IsRunningInAppMode();
|
| +#endif
|
| +
|
| + if (mouse_lock_controller_->IsMouseLockSilentlyAccepted())
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
|
| +
|
| + if (!fullscreen_controller_->IsWindowFullscreenForTabOrPending()) {
|
| + if (mouse_lock_controller_->IsMouseLocked())
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION;
|
| + if (mouse_lock_controller_->IsMouseLockRequested())
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS;
|
| + if (fullscreen_controller_->IsExtensionFullscreenOrPending())
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_EXTENSION_FULLSCREEN_EXIT_INSTRUCTION;
|
| + if (fullscreen_controller_->IsControllerInitiatedFullscreen() && !app_mode)
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
|
| + }
|
| +
|
| + if (fullscreen_controller_->IsUserAcceptedFullscreen()) {
|
| + if (fullscreen_controller_->IsPrivilegedFullscreenForTab())
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
|
| + if (mouse_lock_controller_->IsMouseLocked())
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION;
|
| + if (mouse_lock_controller_->IsMouseLockRequested())
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_BUTTONS;
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_EXIT_INSTRUCTION;
|
| + }
|
| +
|
| + if (mouse_lock_controller_->IsMouseLockRequested())
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_BUTTONS;
|
| + return EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_BUTTONS;
|
| +}
|
| +
|
| +void ExclusiveAccessControllerManager::
|
| + UpdateExclusiveAccessExitBubbleContent() {
|
| + GURL url = GetExclusiveAccessBubbleURL();
|
| + ExclusiveAccessBubbleType bubble_type = GetExclusiveAccessExitBubbleType();
|
| +
|
| + // If bubble displays buttons, unlock mouse to allow pressing them.
|
| + if (exclusive_access_bubble::ShowButtonsForType(bubble_type) &&
|
| + mouse_lock_controller_->IsMouseLocked())
|
| + mouse_lock_controller_->UnlockMouse();
|
| +
|
| + browser_->window()->UpdateFullscreenExitBubbleContent(url, bubble_type);
|
| +}
|
| +
|
| +GURL ExclusiveAccessControllerManager::GetExclusiveAccessBubbleURL() const {
|
| + GURL result = fullscreen_controller_->GetURLForExclusiveAccessBubble();
|
| + if (!result.is_valid())
|
| + result = mouse_lock_controller_->GetURLForExclusiveAccessBubble();
|
| + return result;
|
| +}
|
| +
|
| +void ExclusiveAccessControllerManager::OnTabDeactivated(
|
| + WebContents* web_contents) {
|
| + fullscreen_controller_->OnTabDeactivated(web_contents);
|
| + mouse_lock_controller_->OnTabDeactivated(web_contents);
|
| +}
|
| +
|
| +void ExclusiveAccessControllerManager::OnTabDetachedFromView(
|
| + WebContents* web_contents) {
|
| + fullscreen_controller_->OnTabDetachedFromView(web_contents);
|
| + mouse_lock_controller_->OnTabDetachedFromView(web_contents);
|
| +}
|
| +
|
| +void ExclusiveAccessControllerManager::OnTabClosing(WebContents* web_contents) {
|
| + fullscreen_controller_->OnTabClosing(web_contents);
|
| + mouse_lock_controller_->OnTabClosing(web_contents);
|
| +}
|
| +
|
| +bool ExclusiveAccessControllerManager::HandleUserPressedEscape() {
|
| + bool handled = false;
|
| + handled = fullscreen_controller_->HandleUserPressedEscape();
|
| + handled |= mouse_lock_controller_->HandleUserPressedEscape();
|
| + return handled;
|
| +}
|
| +
|
| +void ExclusiveAccessControllerManager::OnAcceptExclusiveAccessPermission() {
|
| + bool updateBubble =
|
| + mouse_lock_controller_->OnAcceptExclusiveAccessPermission();
|
| + updateBubble |= fullscreen_controller_->OnAcceptExclusiveAccessPermission();
|
| + if (updateBubble)
|
| + UpdateExclusiveAccessExitBubbleContent();
|
| +}
|
| +
|
| +void ExclusiveAccessControllerManager::OnDenyExclusiveAccessPermission() {
|
| + bool updateBubble = mouse_lock_controller_->OnDenyExclusiveAccessPermission();
|
| + updateBubble |= fullscreen_controller_->OnDenyExclusiveAccessPermission();
|
| + if (updateBubble)
|
| + UpdateExclusiveAccessExitBubbleContent();
|
| +}
|
|
|