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

Unified Diff: chrome/browser/ui/cocoa/panels/display_settings_provider_cocoa.mm

Issue 2263863002: Remove implementation of Panels on OSes other than ChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR feedback Created 4 years, 4 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
« no previous file with comments | « chrome/browser/ui/cocoa/panels/OWNERS ('k') | chrome/browser/ui/cocoa/panels/mouse_drag_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/panels/display_settings_provider_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/panels/display_settings_provider_cocoa.mm b/chrome/browser/ui/cocoa/panels/display_settings_provider_cocoa.mm
deleted file mode 100644
index 5894801f6e0b159374e3315ba89af8b861594bc1..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/cocoa/panels/display_settings_provider_cocoa.mm
+++ /dev/null
@@ -1,148 +0,0 @@
-// Copyright (c) 2012 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 "base/bind.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "base/message_loop/message_loop.h"
-#include "base/threading/thread_task_runner_handle.h"
-#import "chrome/browser/app_controller_mac.h"
-#include "chrome/browser/chrome_notification_types.h"
-#include "chrome/browser/fullscreen.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h"
-#include "chrome/browser/ui/panels/display_settings_provider.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
-#include "ui/base/work_area_watcher_observer.h"
-
-namespace {
-
-// The time, in milliseconds, that a fullscreen check will be started after
-// the active workspace change is notified. This value is from experiment.
-const int kCheckFullScreenDelayTimeMs = 200;
-
-class DisplaySettingsProviderCocoa : public DisplaySettingsProvider,
- public ui::WorkAreaWatcherObserver,
- public content::NotificationObserver {
- public:
- DisplaySettingsProviderCocoa();
- ~DisplaySettingsProviderCocoa() override;
-
- void ActiveSpaceChanged();
-
- protected:
- // Overridden from DisplaySettingsProvider:
- bool NeedsPeriodicFullScreenCheck() const override;
- bool IsFullScreen() override;
-
- // Overridden from ui::WorkAreaWatcherObserver:
- void WorkAreaChanged() override;
-
- // Overridden from content::NotificationObserver:
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
- private:
- void ActiveWorkSpaceChanged();
-
- content::NotificationRegistrar registrar_;
- id active_space_change_;
-
- // Owned by MessageLoop after posting.
- base::WeakPtrFactory<DisplaySettingsProviderCocoa> weak_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(DisplaySettingsProviderCocoa);
-};
-
-DisplaySettingsProviderCocoa::DisplaySettingsProviderCocoa()
- : active_space_change_(nil),
- weak_factory_(this) {
- AppController* appController = static_cast<AppController*>([NSApp delegate]);
- [appController addObserverForWorkAreaChange:this];
-
- registrar_.Add(
- this,
- chrome::NOTIFICATION_FULLSCREEN_CHANGED,
- content::NotificationService::AllSources());
-
- active_space_change_ = [[[NSWorkspace sharedWorkspace] notificationCenter]
- addObserverForName:NSWorkspaceActiveSpaceDidChangeNotification
- object:nil
- queue:[NSOperationQueue mainQueue]
- usingBlock:^(NSNotification* notification) {
- ActiveWorkSpaceChanged();
- }];
-}
-
-DisplaySettingsProviderCocoa::~DisplaySettingsProviderCocoa() {
- AppController* appController = static_cast<AppController*>([NSApp delegate]);
- [appController removeObserverForWorkAreaChange:this];
-
- [[[NSWorkspace sharedWorkspace] notificationCenter]
- removeObserver:active_space_change_];
-}
-
-bool DisplaySettingsProviderCocoa::NeedsPeriodicFullScreenCheck() const {
- // Lion system introduces fullscreen support. When a window of an application
- // enters fullscreen mode, the system will automatically hide all other
- // windows, even including topmost windows that come from other applications.
- // So we don't need to do anything when any other application enters
- // fullscreen mode. We still need to handle the case when chrome enters
- // fullscreen mode and our topmost windows will not get hided by the system.
- return false;
-}
-
-bool DisplaySettingsProviderCocoa::IsFullScreen() {
- Browser* browser = chrome::GetLastActiveBrowser();
- if (!browser)
- return false;
- BrowserWindow* browser_window = browser->window();
- if (!browser_window->IsFullscreen())
- return false;
-
- // If the user switches to another space where the fullscreen browser window
- // does not live, we do not call it fullscreen.
- NSWindow* native_window = browser_window->GetNativeWindow();
- return [native_window isOnActiveSpace];
-}
-
-void DisplaySettingsProviderCocoa::WorkAreaChanged() {
- OnDisplaySettingsChanged();
-}
-
-void DisplaySettingsProviderCocoa::Observe(
- int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) {
- DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type);
- // When we receive the fullscreen notification, the Chrome Window has not been
- // put on the active space yet and thus IsFullScreen will return false.
- // Since the fullscreen result is already known here, we can pass it dierctly
- // to CheckFullScreenMode.
- bool is_fullscreen = *(content::Details<bool>(details)).ptr();
- CheckFullScreenMode(
- is_fullscreen ? ASSUME_FULLSCREEN_ON : ASSUME_FULLSCREEN_OFF);
-}
-
-void DisplaySettingsProviderCocoa::ActiveWorkSpaceChanged() {
- // The active workspace notification might be received earlier than the
- // browser window knows that it is not in active space.
- base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
- FROM_HERE,
- base::Bind(&DisplaySettingsProviderCocoa::CheckFullScreenMode,
- weak_factory_.GetWeakPtr(), PERFORM_FULLSCREEN_CHECK),
- base::TimeDelta::FromMilliseconds(kCheckFullScreenDelayTimeMs));
-}
-
-} // namespace
-
-// static
-DisplaySettingsProvider* DisplaySettingsProvider::Create() {
- return new DisplaySettingsProviderCocoa();
-}
« no previous file with comments | « chrome/browser/ui/cocoa/panels/OWNERS ('k') | chrome/browser/ui/cocoa/panels/mouse_drag_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698