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

Unified Diff: chrome/browser/ui/views/apps/native_app_window_views.cc

Issue 42353002: Introduce WindowStateDelegate::ToggleFullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 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
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..872a19dbe61b68f21557b18ac6011decf8dab489 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,37 @@ void CreateIconAndSetRelaunchDetails(
}
#endif
+#if defined(USE_ASH)
+class NativeAppWindowStateDelegate : public ash::wm::WindowStateDelegate {
+ public:
+ NativeAppWindowStateDelegate() {}
+ virtual ~NativeAppWindowStateDelegate(){}
+
+ // Invoked when the user uses Shift+F4 to toggle the window fullscreen state.
+ 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 +187,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());
pkotwicz 2013/10/25 19:56:38 It MAY be worth passing in |shell_window_| to Nati
oshima 2013/10/25 22:36:20 I'm fine with either way. I'm just using what the
pkotwicz 2013/10/25 23:31:14 I think that it is worth investigating if passing
+ }
+#endif
}
NativeAppWindowViews::~NativeAppWindowViews() {

Powered by Google App Engine
This is Rietveld 408576698