Index: chrome/browser/ui/views/apps/native_app_window_views.cc |
diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc |
index 090a96acb548d0e35cb9027e5a8688ed489b2ab6..5c1e1d746729b5a827486d3e424e31986879a186 100644 |
--- a/chrome/browser/ui/views/apps/native_app_window_views.cc |
+++ b/chrome/browser/ui/views/apps/native_app_window_views.cc |
@@ -43,12 +43,15 @@ |
#if defined(USE_ASH) |
#include "ash/ash_constants.h" |
+#include "ash/ash_switches.h" |
#include "ash/screen_ash.h" |
#include "ash/shell.h" |
#include "ash/wm/custom_frame_view_ash.h" |
+#include "ash/wm/immersive_fullscreen_controller.h" |
#include "ash/wm/panels/panel_frame_view.h" |
#include "ash/wm/window_state.h" |
#include "ash/wm/window_state_delegate.h" |
+#include "ash/wm/window_state_observer.h" |
#include "chrome/browser/ui/ash/ash_util.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/client/window_tree_client.h" |
@@ -129,27 +132,56 @@ void CreateIconAndSetRelaunchDetails( |
#if defined(USE_ASH) |
// This class handles a user's fullscreen request (Shift+F4/F4). |
-class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate { |
+class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate, |
+ public ash::wm::WindowStateObserver { |
public: |
- explicit NativeAppWindowStateDelegate(ShellWindow* shell_window) |
- : shell_window_(shell_window) { |
- DCHECK(shell_window_); |
+ NativeAppWindowStateDelegate(ShellWindow* shell_window, |
+ apps::NativeAppWindow* native_app_window) |
+ : shell_window_(shell_window), |
+ window_state_( |
+ ash::wm::GetWindowState(native_app_window->GetNativeWindow())) { |
+ // Add a window state observer to exit fullscreen properly in case |
+ // fullscreen is exited without going through ShellWindow::Restore(). This |
+ // is the case when exiting immersive fullscreen via the "Restore" window |
+ // control. |
+ // TODO(pkotwicz): This is a hack. Remove ASAP. |
+ window_state_->AddObserver(this); |
+ } |
+ virtual ~NativeAppWindowStateDelegate(){ |
+ window_state_->RemoveObserver(this); |
} |
- virtual ~NativeAppWindowStateDelegate(){} |
// Overridden from ash::wm::WindowStateDelegate. |
- virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE { |
- // Windows which cannot be maximized should not be fullscreened. |
- DCHECK(window_state->IsFullscreen() || window_state->CanMaximize()); |
- if (window_state->IsFullscreen()) |
+ virtual bool EnterImmersiveFullscreen( |
+ ash::wm::WindowState* window_state) OVERRIDE { |
+ if (!window_state_->IsFullscreen()) { |
+ if (shell_window_->GetBaseWindow()->SupportsImmersiveFullscreen()) |
+ shell_window_->ImmersiveFullscreen(); |
+ else |
+ shell_window_->Fullscreen(); |
oshima
2013/11/07 18:56:13
Isn't it better to do all these check and immersiv
|
+ } |
+ return true; |
+ } |
+ virtual bool ExitFullscreen(ash::wm::WindowState* window_state) OVERRIDE { |
+ if (window_state_->IsFullscreen()) |
shell_window_->Restore(); |
- else if (window_state->CanMaximize()) |
- shell_window_->Fullscreen(); |
return true; |
} |
private: |
- ShellWindow* shell_window_; // not owned. |
+ // Overridden from ash::wm::WindowStateObserver: |
+ virtual void OnWindowShowTypeChanged(ash::wm::WindowState* window_state, |
+ ash::wm::WindowShowType* old_type) { |
+ if (!window_state_->IsFullscreen() && |
+ !window_state_->IsMinimized() && |
+ shell_window_->fullscreen_type() != ShellWindow::FULLSCREEN_TYPE_NONE) { |
+ shell_window_->Restore(); |
+ } |
+ } |
+ |
+ // Not owned. |
+ ShellWindow* shell_window_; |
+ ash::wm::WindowState* window_state_; |
DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); |
}; |
@@ -191,7 +223,7 @@ NativeAppWindowViews::NativeAppWindowViews( |
chrome::HOST_DESKTOP_TYPE_ASH) { |
ash::wm::GetWindowState(GetNativeWindow())->SetDelegate( |
scoped_ptr<ash::wm::WindowStateDelegate>( |
- new NativeAppWindowStateDelegate(shell_window)).Pass()); |
+ new NativeAppWindowStateDelegate(shell_window, this)).Pass()); |
} |
#endif |
} |
@@ -669,7 +701,21 @@ views::NonClientFrameView* NativeAppWindowViews::CreateNonClientFrameView( |
return new ash::PanelFrameView(widget, frame_type); |
} |
if (!frameless_) { |
- return new ash::CustomFrameViewAsh(widget); |
+ ash::CustomFrameViewAsh* custom_frame_view = |
+ new ash::CustomFrameViewAsh(widget); |
+#if defined(OS_CHROMEOS) |
oshima
2013/11/07 18:56:13
why this is chromeos only? shouldn't we use the sa
pkotwicz
2013/11/07 22:21:48
This is chromeos only because browser immersive fu
oshima
2013/11/08 00:26:29
So win8 ash mode doesn't support immersive fullscr
pkotwicz
2013/11/08 01:16:57
No
|
+ // Non-frameless app windows can be put into immersive fullscreen. |
+ // TODO(pkotwicz): Investigate if immersive fullscreen can be enabled for |
+ // Windows Ash. |
+ if (CommandLine::ForCurrentProcess()->HasSwitch( |
+ ash::switches::kAshEnableAppImmersiveFullscreen)) { |
+ immersive_fullscreen_controller_.reset( |
+ new ash::ImmersiveFullscreenController()); |
+ custom_frame_view->InitImmersiveFullscreenControllerForView( |
+ immersive_fullscreen_controller_.get()); |
+ } |
+#endif |
+ return custom_frame_view; |
} |
} |
#endif |
@@ -793,19 +839,33 @@ bool NativeAppWindowViews::AcceleratorPressed( |
// NativeAppWindow implementation. |
-void NativeAppWindowViews::SetFullscreen(bool fullscreen) { |
+void NativeAppWindowViews::SetFullscreen(ShellWindow::FullscreenType type) { |
// Fullscreen not supported by panels. |
if (shell_window_->window_type_is_panel()) |
return; |
- is_fullscreen_ = fullscreen; |
- window_->SetFullscreen(fullscreen); |
+ is_fullscreen_ = (type != ShellWindow::FULLSCREEN_TYPE_NONE); |
+ window_->SetFullscreen(is_fullscreen_); |
+ |
+#if defined(USE_ASH) |
+ if (immersive_fullscreen_controller_.get()) { |
+ bool is_immersive = (type == ShellWindow::FULLSCREEN_TYPE_IMMERSIVE); |
+ if (is_immersive != immersive_fullscreen_controller_->IsEnabled()) { |
+ immersive_fullscreen_controller_->SetEnabled(is_immersive); |
+ shell_window_->OnNativeWindowChanged(); |
+ } |
+ } |
+#endif |
+ |
// TODO(jeremya) we need to call RenderViewHost::ExitFullscreen() if we |
// ever drop the window out of fullscreen in response to something that |
// wasn't the app calling webkitCancelFullScreen(). |
} |
-bool NativeAppWindowViews::IsFullscreenOrPending() const { |
- return is_fullscreen_; |
+bool NativeAppWindowViews::SupportsImmersiveFullscreen() const { |
+#if defined(USE_ASH) |
+ return immersive_fullscreen_controller_.get(); |
+#endif |
+ return false; |
} |
bool NativeAppWindowViews::IsDetached() const { |