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

Unified Diff: chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm

Issue 1650483002: Refactor: Untangle Mac's ExclusiveAccessContext from BrowserWindow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: self nits, More robust interface, fix other random stuff Created 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
diff --git a/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm b/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
new file mode 100644
index 0000000000000000000000000000000000000000..c3004f3f14041b6c2255751d79cf8ed37bded048
--- /dev/null
+++ b/chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.mm
@@ -0,0 +1,120 @@
+// Copyright 2016 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.
+
+#import "chrome/browser/ui/cocoa/browser/exclusive_access_controller_views.h"
+
+#include "chrome/browser/download/download_shelf.h"
+#include "chrome/browser/fullscreen.h"
+#include "chrome/browser/ui/browser_window.h"
+#import "chrome/browser/ui/cocoa/browser_window_controller.h"
+#import "chrome/browser/ui/cocoa/exclusive_access_bubble_window_controller.h"
+#include "chrome/browser/ui/status_bubble.h"
+
+ExclusiveAccessController::ExclusiveAccessController(
+ BrowserWindowController* controller,
+ Browser* browser)
+ : controller_(controller),
+ browser_(browser),
+ bubble_type_(EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE) {}
+
+ExclusiveAccessController::~ExclusiveAccessController() {}
+
+void ExclusiveAccessController::Show() {
+ [cocoa_bubble_ closeImmediately];
+ cocoa_bubble_.reset([[ExclusiveAccessBubbleWindowController alloc]
+ initWithOwner:controller_
+ exclusive_access_manager:browser_->exclusive_access_manager()
+ profile:browser_->profile()
+ url:url_
+ bubbleType:bubble_type_]);
+ [cocoa_bubble_ showWindow];
+}
+
+void ExclusiveAccessController::Destroy() {
+ [cocoa_bubble_ closeImmediately];
+ cocoa_bubble_.reset();
+ url_ = GURL();
+ bubble_type_ = EXCLUSIVE_ACCESS_BUBBLE_TYPE_NONE;
+}
+
+void ExclusiveAccessController::Layout(CGFloat max_y) {
+ [cocoa_bubble_ positionInWindowAtTop:max_y];
+}
+
+Profile* ExclusiveAccessController::GetProfile() {
+ return browser_->profile();
+}
+
+bool ExclusiveAccessController::IsFullscreen() const {
+ return [controller_ isInAnyFullscreenMode];
+}
+
+bool ExclusiveAccessController::SupportsFullscreenWithToolbar() const {
+ return chrome::mac::SupportsSystemFullscreen();
+}
+
+void ExclusiveAccessController::UpdateFullscreenWithToolbar(bool with_toolbar) {
+ [controller_ updateFullscreenWithToolbar:with_toolbar];
+}
+
+void ExclusiveAccessController::ToggleFullscreenToolbar() {
+ [controller_ toggleFullscreenToolbar];
+}
+
+bool ExclusiveAccessController::IsFullscreenWithToolbar() const {
+ return IsFullscreen() && ![controller_ inPresentationMode];
+}
+
+// See browser_window_controller.h for a detailed explanation of the logic in
+// this method.
+void ExclusiveAccessController::EnterFullscreen(
+ const GURL& url,
+ ExclusiveAccessBubbleType bubble_type,
+ bool with_toolbar) {
+ url_ = url;
+ bubble_type_ = bubble_type;
+ if (browser_->exclusive_access_manager()
+ ->fullscreen_controller()
+ ->IsWindowFullscreenForTabOrPending())
+ [controller_ enterWebContentFullscreen];
+ else if (!url.is_empty())
+ [controller_ enterExtensionFullscreen];
+ else
+ [controller_ enterBrowserFullscreenWithToolbar:with_toolbar];
+}
+
+void ExclusiveAccessController::ExitFullscreen() {
+ [controller_ exitAnyFullscreen];
+}
+
+void ExclusiveAccessController::UpdateExclusiveAccessExitBubbleContent(
+ const GURL& url,
+ ExclusiveAccessBubbleType bubble_type) {
+ url_ = url;
+ bubble_type_ = bubble_type;
+ [controller_ updateFullscreenExitBubble];
+}
+
+void ExclusiveAccessController::OnExclusiveAccessUserInput() {
+ // TODO(mgiuca): Route this signal to the exclusive access bubble on Mac.
+}
+
+content::WebContents* ExclusiveAccessController::GetActiveWebContents() {
+ return browser_->tab_strip_model()->GetActiveWebContents();
+}
+
+void ExclusiveAccessController::UnhideDownloadShelf() {
+ GetBrowserWindow()->GetDownloadShelf()->Unhide();
+}
+
+void ExclusiveAccessController::HideDownloadShelf() {
+ GetBrowserWindow()->GetDownloadShelf()->Hide();
+ StatusBubble* statusBubble = GetBrowserWindow()->GetStatusBubble();
+ if (statusBubble)
+ statusBubble->Hide();
+}
+
+BrowserWindow* ExclusiveAccessController::GetBrowserWindow() const {
+ return [controller_ browserWindow];
+}

Powered by Google App Engine
This is Rietveld 408576698