diff options
-rw-r--r-- | base/mac_util.h | 12 | ||||
-rw-r--r-- | base/mac_util.mm | 22 | ||||
-rw-r--r-- | chrome/browser/cocoa/browser_window_controller.mm | 4 | ||||
-rw-r--r-- | chrome/browser/plugin_process_host.cc | 24 | ||||
-rw-r--r-- | chrome/browser/plugin_process_host.h | 2 | ||||
-rw-r--r-- | chrome/browser/plugin_process_host_mac.cc | 19 |
6 files changed, 64 insertions, 19 deletions
diff --git a/base/mac_util.h b/base/mac_util.h index 0baab02..fc886e54 100644 --- a/base/mac_util.h +++ b/base/mac_util.h @@ -60,6 +60,18 @@ CGColorSpaceRef GetSRGBColorSpace(); // is a static value; do not release it! CGColorSpaceRef GetSystemColorSpace(); +// Add a request for full screen mode. This does not by itself create a +// fullscreen window; rather, it manages per-application state related to +// fullscreen windows. For example, if the menu bar is not currently +// hidden, this will hide it. Must be called on main thread. +void RequestFullScreen(); + +// Release a request for full screen mode. As with RequestFullScree(), this +// does not affect windows directly, but rather manages per-application state. +// For example, if there are no other outstanding requests for full screen, +// this will show the menu bar. Must be called on main thread. +void ReleaseFullScreen(); + } // namespace mac_util #endif // BASE_MAC_UTIL_H_ diff --git a/base/mac_util.mm b/base/mac_util.mm index 014342c..f31ca42 100644 --- a/base/mac_util.mm +++ b/base/mac_util.mm @@ -8,6 +8,7 @@ #include "base/file_path.h" #include "base/logging.h" +#include "base/message_loop.h" #include "base/scoped_cftyperef.h" #include "base/sys_string_conversions.h" @@ -138,4 +139,25 @@ CGColorSpaceRef GetSystemColorSpace() { return g_system_color_space; } +// a count of currently outstanding requests for full screen mode from browser +// windows, plugins, etc. +static int g_full_screen_requests = 0; + +// Add a request for full screen mode. If the menu bar is not currently +// hidden, hide it. Must be called on main thread. +void RequestFullScreen() { + if (!g_full_screen_requests) + SetSystemUIMode(kUIModeAllSuppressed, kUIOptionAutoShowMenuBar); + ++g_full_screen_requests; +} + +// Release a request for full screen mode. If there are no other outstanding +// requests, show the menu bar. Must be called on main thread. +void ReleaseFullScreen() { + DCHECK(g_full_screen_requests > 0); + --g_full_screen_requests; + if (g_full_screen_requests == 0) + SetSystemUIMode(kUIModeNormal, 0); +} + } // namespace mac_util diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index 7c37bbb..8daa0d9 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -887,9 +887,9 @@ willPositionSheet:(NSWindow*)sheet // Hide the menubar, and allow it to un-hide when moving the mouse // to the top of the screen. Does this eliminate the need for an // info bubble describing how to exit fullscreen mode? - SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); + mac_util::RequestFullScreen(); } else { - SetSystemUIMode(kUIModeNormal, 0); + mac_util::ReleaseFullScreen(); [[[self window] contentView] addSubview:[toolbarController_ view]]; if (browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR)) { [bookmarkBarController_ setBookmarkBarEnabled:YES]; diff --git a/chrome/browser/plugin_process_host.cc b/chrome/browser/plugin_process_host.cc index 573e0a9..350319b 100644 --- a/chrome/browser/plugin_process_host.cc +++ b/chrome/browser/plugin_process_host.cc @@ -70,6 +70,7 @@ #endif #if defined(OS_MACOSX) +#include "base/mac_util.h" #include "chrome/common/plugin_carbon_interpose_constants_mac.h" #endif @@ -329,16 +330,19 @@ PluginProcessHost::~PluginProcessHost() { PostMessage(*window_index, WM_CLOSE, 0, 0); } #elif defined(OS_MACOSX) - // If the plugin process crashed but had windows open at the time, make - // sure that the menu bar is visible. - // TODO: only do this if the browser window is not also in fullscreen mode. - // (see http://code.google.com/p/chromium/issues/detail?id=23571) - if (!plugin_visible_windows_set_.empty()) { - SystemUIMode mode; - SystemUIOptions options; - GetSystemUIMode(&mode, &options); - if (mode != kUIModeNormal) - SetSystemUIMode(kUIModeNormal, 0); + // If the plugin process crashed but had fullscreen windows open at the time, + // make sure that the menu bar is visible. + std::set<uint32>::iterator window_index; + for (window_index = plugin_fullscreen_windows_set_.begin(); + window_index != plugin_fullscreen_windows_set_.end(); + window_index++) { + if (MessageLoop::current() == + ChromeThread::GetMessageLoop(ChromeThread::UI)) { + mac_util::ReleaseFullScreen(); + } else { + ChromeThread::GetMessageLoop(ChromeThread::UI)->PostTask(FROM_HERE, + NewRunnableFunction(mac_util::ReleaseFullScreen)); + } } #endif } diff --git a/chrome/browser/plugin_process_host.h b/chrome/browser/plugin_process_host.h index 6c5e17f..e397c4c 100644 --- a/chrome/browser/plugin_process_host.h +++ b/chrome/browser/plugin_process_host.h @@ -153,6 +153,8 @@ class PluginProcessHost : public ChildProcessHost, #if defined(OS_MACOSX) // Tracks plugin windows currently visible std::set<uint32> plugin_visible_windows_set_; + // Tracks full screen windows currently visible + std::set<uint32> plugin_fullscreen_windows_set_; #endif DISALLOW_COPY_AND_ASSIGN(PluginProcessHost); diff --git a/chrome/browser/plugin_process_host_mac.cc b/chrome/browser/plugin_process_host_mac.cc index 65ead0a..2c64245 100644 --- a/chrome/browser/plugin_process_host_mac.cc +++ b/chrome/browser/plugin_process_host_mac.cc @@ -9,6 +9,8 @@ #include <vector> #include "base/logging.h" +#include "base/mac_util.h" +#include "chrome/browser/chrome_thread.h" #include "chrome/browser/plugin_process_host.h" void PluginProcessHost::OnPluginSelectWindow(uint32 window_id, @@ -25,23 +27,26 @@ void PluginProcessHost::OnPluginShowWindow(uint32 window_id, }; CGRect main_display_bounds = CGDisplayBounds(CGMainDisplayID()); if (CGRectEqualToRect(window_bounds, main_display_bounds)) { + plugin_fullscreen_windows_set_.insert(window_id); // If the plugin has just shown a window that's the same dimensions as // the main display, hide the menubar so that it has the whole screen. - SetSystemUIMode(kUIModeAllSuppressed, kUIOptionAutoShowMenuBar); + ChromeThread::GetMessageLoop(ChromeThread::UI)->PostTask(FROM_HERE, + NewRunnableFunction(mac_util::RequestFullScreen)); } } void PluginProcessHost::OnPluginHideWindow(uint32 window_id, gfx::Rect window_rect) { plugin_visible_windows_set_.erase(window_id); - SystemUIMode mode; - SystemUIOptions options; - GetSystemUIMode(&mode, &options); - if (mode != kUIModeNormal) - SetSystemUIMode(kUIModeNormal, 0); + if (plugin_fullscreen_windows_set_.find(window_id) != + plugin_fullscreen_windows_set_.end()) { + plugin_fullscreen_windows_set_.erase(window_id); + ChromeThread::GetMessageLoop(ChromeThread::UI)->PostTask(FROM_HERE, + NewRunnableFunction(mac_util::ReleaseFullScreen)); + } } void PluginProcessHost::OnPluginDisposeWindow(uint32 window_id, gfx::Rect window_rect) { - plugin_visible_windows_set_.erase(window_id); + OnPluginHideWindow(window_id, window_rect); } |