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

Unified Diff: chrome/browser/ui/views/frame/app_non_client_frame_view_ash.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/frame/app_non_client_frame_view_ash.cc
diff --git a/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc b/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
index 89f4dabf4f07605c3e9dafbcc65b3f8b06a90f19..5781ec192f04787009bfb7387ee96082f8ac6bcd 100644
--- a/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
+++ b/chrome/browser/ui/views/frame/app_non_client_frame_view_ash.cc
@@ -5,7 +5,12 @@
#include "chrome/browser/ui/views/frame/app_non_client_frame_view_ash.h"
#include "ash/wm/caption_buttons/frame_caption_button_container_view.h"
+#include "ash/wm/window_state.h"
+#include "ash/wm/window_state_delegate.h"
#include "base/i18n/rtl.h"
+#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "grit/ash_resources.h"
@@ -85,6 +90,40 @@ class ControlViewBackground : public views::Background {
DISALLOW_COPY_AND_ASSIGN(ControlViewBackground);
};
+class FrameWindowStateDelegate : public ash::wm::WindowStateDelegate {
+ public:
+ FrameWindowStateDelegate() {}
+ virtual ~FrameWindowStateDelegate(){}
+
+ // Invoked when the user uses Shift+F4/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;
+
+ Browser* browser = chrome::FindBrowserWithWindow(window_state->window());
+ CHECK(browser);
+ if (is_fullscreen) {
+ chrome::ToggleFullscreenMode(browser);
+ return true;
+ }
+ // AppNonClientFrameViewAsh shows only the window controls and no other
+ // window decorations which is pretty close to fullscreen. Put v1 apps
+ // into maximized mode instead of fullscreen to avoid showing the ugly
+ // fullscreen exit bubble.
+ if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD)
+ window_state->ToggleMaximized();
+ else
+ chrome::ToggleFullscreenMode(browser);
+ return true;
+ }
+ private:
+ DISALLOW_COPY_AND_ASSIGN(FrameWindowStateDelegate);
+};
+
} // namespace
// Observer to detect when the browser frame widget closes so we can clean
@@ -153,6 +192,9 @@ AppNonClientFrameViewAsh::AppNonClientFrameViewAsh(
}
window->SetHitTestBoundsOverrideOuter(hit_test_insets, hit_test_insets);
+
+ ash::wm::GetWindowState(window)->SetDelegate(new FrameWindowStateDelegate());
+
gfx::Rect control_bounds = GetControlBounds();
window->SetBounds(control_bounds);
control_widget_->Show();

Powered by Google App Engine
This is Rietveld 408576698