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 215eae927bff86bd9ea924ffea7e4c9095170f03..e5a9df82017400d9c73e260ab7ea8b2fd92fd645 100644 |
--- a/chrome/browser/ui/views/apps/native_app_window_views.cc |
+++ b/chrome/browser/ui/views/apps/native_app_window_views.cc |
@@ -4,6 +4,8 @@ |
#include "chrome/browser/ui/views/apps/native_app_window_views.h" |
+#include "apps/shell_window.h" |
+#include "apps/shell_window_registry.h" |
#include "apps/ui/views/shell_window_frame_view.h" |
#include "base/command_line.h" |
#include "base/file_util.h" |
@@ -13,6 +15,7 @@ |
#include "chrome/browser/extensions/extension_host.h" |
#include "chrome/browser/favicon/favicon_tab_helper.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/ui/host_desktop.h" |
#include "chrome/browser/ui/views/extensions/extension_keybinding_registry_views.h" |
#include "chrome/browser/web_applications/web_app.h" |
#include "chrome/common/chrome_switches.h" |
@@ -46,6 +49,7 @@ |
#include "ash/wm/custom_frame_view_ash.h" |
#include "ash/wm/panels/panel_frame_view.h" |
#include "ash/wm/window_state.h" |
+#include "ash/wm/window_state_delegate.h" |
#include "chrome/browser/ui/ash/ash_util.h" |
#include "ui/aura/client/aura_constants.h" |
#include "ui/aura/client/window_tree_client.h" |
@@ -121,6 +125,36 @@ void CreateIconAndSetRelaunchDetails( |
} |
#endif |
+#if defined(USE_ASH) |
+class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate { |
+ public: |
+ NativeAppWindowStateDelegate() {} |
+ virtual ~NativeAppWindowStateDelegate(){} |
+ |
+ virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE { |
+ bool is_fullscreen = window_state->IsFullscreen(); |
+ |
+ // Windows which cannot be maximized should not be fullscreened. |
+ if (!is_fullscreen && !window_state->CanMaximize()) |
+ return true; |
+ // |window| may belong to a shell window. |
+ apps::ShellWindow* shell_window = apps::ShellWindowRegistry:: |
+ GetShellWindowForNativeWindowAnyProfile(window_state->window()); |
+ DCHECK(shell_window); |
+ if (!shell_window) |
+ return true; |
+ if (is_fullscreen) |
+ shell_window->Restore(); |
+ else |
+ shell_window->Fullscreen(); |
+ return true; |
+ } |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(NativeAppWindowStateDelegate); |
+}; |
+#endif // USE_ASH |
+ |
} // namespace |
NativeAppWindowViews::NativeAppWindowViews( |
@@ -152,6 +186,13 @@ NativeAppWindowViews::NativeAppWindowViews( |
OnViewWasResized(); |
window_->AddObserver(this); |
+#if defined(USE_ASH) |
+ if (chrome::GetHostDesktopTypeForNativeView(GetNativeWindow()) == |
+ chrome::HOST_DESKTOP_TYPE_ASH) { |
+ ash::wm::GetWindowState(GetNativeWindow())->SetDelegate( |
+ new NativeAppWindowStateDelegate()); |
+ } |
+#endif |
} |
NativeAppWindowViews::~NativeAppWindowViews() { |