summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-24 11:01:16 +0000
committerjianli@chromium.org <jianli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-24 11:01:16 +0000
commitbfeaa8f446e907448865024b3b175fa0831e6c35 (patch)
tree93601ce32b58011269e5a837ca5ad7975dbf06e4
parentd74359fa091d79baf4d4e4f7ad5d235a8d08043c (diff)
downloadchromium_src-bfeaa8f446e907448865024b3b175fa0831e6c35.zip
chromium_src-bfeaa8f446e907448865024b3b175fa0831e6c35.tar.gz
chromium_src-bfeaa8f446e907448865024b3b175fa0831e6c35.tar.bz2
Fix bug 112240: Panels [OSX]: Panels don't hide when Chrome goes into full screen or presentation mode on Lion
BUG=112240 TEST=Manual test by launching panels and making chrome tab window fullscreen Review URL: https://chromiumcodereview.appspot.com/10409099 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@138767 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/fullscreen_controller.cc9
-rw-r--r--chrome/browser/ui/fullscreen_controller.h2
-rw-r--r--chrome/browser/ui/panels/display_settings_provider.cc12
-rw-r--r--chrome/browser/ui/panels/display_settings_provider.h8
-rw-r--r--chrome/browser/ui/panels/display_settings_provider_cocoa.mm61
5 files changed, 82 insertions, 10 deletions
diff --git a/chrome/browser/ui/fullscreen_controller.cc b/chrome/browser/ui/fullscreen_controller.cc
index 088437a..1280bc3 100644
--- a/chrome/browser/ui/fullscreen_controller.cc
+++ b/chrome/browser/ui/fullscreen_controller.cc
@@ -281,14 +281,15 @@ void FullscreenController::OnDenyFullscreenPermission(
}
void FullscreenController::WindowFullscreenStateChanged() {
- MessageLoop::current()->PostTask(FROM_HERE,
- base::Bind(&FullscreenController::NotifyFullscreenChange, this));
bool exiting_fullscreen;
#if defined(OS_MACOSX)
exiting_fullscreen = !window_->InPresentationMode();
#else
exiting_fullscreen = !window_->IsFullscreen();
#endif
+ MessageLoop::current()->PostTask(FROM_HERE,
+ base::Bind(&FullscreenController::NotifyFullscreenChange,
+ this, !exiting_fullscreen));
if (exiting_fullscreen)
NotifyTabOfExitIfNecessary();
if (exiting_fullscreen)
@@ -366,11 +367,11 @@ void FullscreenController::UpdateFullscreenExitBubbleContent() {
window_->UpdateFullscreenExitBubbleContent(url, bubble_type);
}
-void FullscreenController::NotifyFullscreenChange() {
+void FullscreenController::NotifyFullscreenChange(bool is_fullscreen) {
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_FULLSCREEN_CHANGED,
content::Source<FullscreenController>(this),
- content::NotificationService::NoDetails());
+ content::Details<bool>(&is_fullscreen));
}
void FullscreenController::NotifyMouseLockChange() {
diff --git a/chrome/browser/ui/fullscreen_controller.h b/chrome/browser/ui/fullscreen_controller.h
index 99ca6517..3bb2d84 100644
--- a/chrome/browser/ui/fullscreen_controller.h
+++ b/chrome/browser/ui/fullscreen_controller.h
@@ -99,7 +99,7 @@ class FullscreenController : public base::RefCounted<FullscreenController> {
// Make the current tab exit fullscreen mode or mouse lock if it is in it.
void ExitTabFullscreenOrMouseLockIfNecessary();
void UpdateFullscreenExitBubbleContent();
- void NotifyFullscreenChange();
+ void NotifyFullscreenChange(bool is_fullscreen);
void NotifyMouseLockChange();
ContentSetting GetFullscreenSetting(const GURL& url) const;
ContentSetting GetMouseLockSetting(const GURL& url) const;
diff --git a/chrome/browser/ui/panels/display_settings_provider.cc b/chrome/browser/ui/panels/display_settings_provider.cc
index 08d5f1b..13ed0ad 100644
--- a/chrome/browser/ui/panels/display_settings_provider.cc
+++ b/chrome/browser/ui/panels/display_settings_provider.cc
@@ -45,7 +45,7 @@ void DisplaySettingsProvider::AddFullScreenObserver(
FullScreenObserver* observer) {
full_screen_observers_.AddObserver(observer);
- if (full_screen_observers_.size() == 1) {
+ if (full_screen_observers_.size() == 1 && NeedsPeriodicFullScreenCheck()) {
full_screen_mode_timer_.Start(FROM_HERE,
base::TimeDelta::FromMilliseconds(kFullScreenModeCheckIntervalMs),
this, &DisplaySettingsProvider::CheckFullScreenMode);
@@ -149,8 +149,12 @@ void DisplaySettingsProvider::AdjustWorkAreaForAutoHidingDesktopBars() {
}
}
+bool DisplaySettingsProvider::NeedsPeriodicFullScreenCheck() const {
+ return true;
+}
+
void DisplaySettingsProvider::CheckFullScreenMode() {
- bool is_full_screen = IsFullScreenMode();
+ bool is_full_screen = IsFullScreen();
if (is_full_screen == is_full_screen_)
return;
is_full_screen_ = is_full_screen;
@@ -160,6 +164,10 @@ void DisplaySettingsProvider::CheckFullScreenMode() {
OnFullScreenModeChanged(is_full_screen_));
}
+bool DisplaySettingsProvider::IsFullScreen() const {
+ return IsFullScreenMode();
+}
+
#if defined(USE_AURA)
// static
DisplaySettingsProvider* DisplaySettingsProvider::Create() {
diff --git a/chrome/browser/ui/panels/display_settings_provider.h b/chrome/browser/ui/panels/display_settings_provider.h
index 8354eea..90e7f88 100644
--- a/chrome/browser/ui/panels/display_settings_provider.h
+++ b/chrome/browser/ui/panels/display_settings_provider.h
@@ -125,8 +125,14 @@ class DisplaySettingsProvider {
// testing code.
virtual gfx::Rect GetWorkArea() const;
+ // Returns true if we need to perform fullscreen check periodically.
+ virtual bool NeedsPeriodicFullScreenCheck() const;
+
+ // Returns true if full screen or presentation mode in main screen is entered.
+ virtual bool IsFullScreen() const;
+
// Callback to perform periodic check for full screen mode changes.
- virtual void CheckFullScreenMode();
+ void CheckFullScreenMode();
void OnAutoHidingDesktopBarChanged();
diff --git a/chrome/browser/ui/panels/display_settings_provider_cocoa.mm b/chrome/browser/ui/panels/display_settings_provider_cocoa.mm
index 41d7b41..7cf4fb0 100644
--- a/chrome/browser/ui/panels/display_settings_provider_cocoa.mm
+++ b/chrome/browser/ui/panels/display_settings_provider_cocoa.mm
@@ -2,29 +2,60 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/mac/mac_util.h"
#include "chrome/browser/ui/panels/display_settings_provider.h"
#include "ui/base/work_area_watcher_observer.h"
#import "chrome/browser/app_controller_mac.h"
+#include "chrome/common/chrome_notification_types.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"
namespace {
class DisplaySettingsProviderCocoa : public DisplaySettingsProvider,
- public ui::WorkAreaWatcherObserver {
+ public ui::WorkAreaWatcherObserver,
+ public content::NotificationObserver {
public:
DisplaySettingsProviderCocoa();
virtual ~DisplaySettingsProviderCocoa();
protected:
+ // Overridden from DisplaySettingsProvider:
+ virtual bool NeedsPeriodicFullScreenCheck() const OVERRIDE;
+ virtual bool IsFullScreen() const OVERRIDE;
+
// Overridden from ui::WorkAreaWatcherObserver:
virtual void WorkAreaChanged() OVERRIDE;
+ // Overridden from content::NotificationObserver:
+ virtual void Observe(int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) OVERRIDE;
+
private:
+ content::NotificationRegistrar registrar_;
+ bool is_chrome_fullscreen_;
+
DISALLOW_COPY_AND_ASSIGN(DisplaySettingsProviderCocoa);
};
-DisplaySettingsProviderCocoa::DisplaySettingsProviderCocoa() {
+DisplaySettingsProviderCocoa::DisplaySettingsProviderCocoa()
+ // Ideally we should initialize the value below with current state. However,
+ // there is not a centralized place we can pull the state from and we need
+ // to query all chrome browser windows to find it out.
+ // This will get automatically fixed when DisplaySettingsProvider is changed
+ // to be initialized before any chrome window is created with planning
+ // refactor effort to move it out of panel scope.
+ : is_chrome_fullscreen_(false) {
AppController* appController = static_cast<AppController*>([NSApp delegate]);
[appController addObserverForWorkAreaChange:this];
+
+ registrar_.Add(
+ this,
+ chrome::NOTIFICATION_FULLSCREEN_CHANGED,
+ content::NotificationService::AllSources());
}
DisplaySettingsProviderCocoa::~DisplaySettingsProviderCocoa() {
@@ -32,10 +63,36 @@ DisplaySettingsProviderCocoa::~DisplaySettingsProviderCocoa() {
[appController removeObserverForWorkAreaChange:this];
}
+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 !base::mac::IsOSLionOrLater();
+}
+
+bool DisplaySettingsProviderCocoa::IsFullScreen() const {
+ // For Lion and later, we only need to check if chrome enters fullscreen mode
+ // (see detailed reason above in NeedsPeriodicFullScreenCheck).
+ return base::mac::IsOSLionOrLater() ? is_chrome_fullscreen_ :
+ DisplaySettingsProvider::IsFullScreen();
+}
+
void DisplaySettingsProviderCocoa::WorkAreaChanged() {
OnDisplaySettingsChanged();
}
+void DisplaySettingsProviderCocoa::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_FULLSCREEN_CHANGED, type);
+ is_chrome_fullscreen_ = *(content::Details<bool>(details)).ptr();
+ CheckFullScreenMode();
+}
+
} // namespace
// static