Chromium Code Reviews| Index: chrome/browser/ui/views/frame/browser_frame_ash.cc |
| diff --git a/chrome/browser/ui/views/frame/browser_frame_ash.cc b/chrome/browser/ui/views/frame/browser_frame_ash.cc |
| index 07f4e332ebbf953b1a7b1912b59e0d2153efdc9b..787e6858bf874fb7de1fe85bea2bd4d90c09d2bf 100644 |
| --- a/chrome/browser/ui/views/frame/browser_frame_ash.cc |
| +++ b/chrome/browser/ui/views/frame/browser_frame_ash.cc |
| @@ -5,7 +5,11 @@ |
| #include "chrome/browser/ui/views/frame/browser_frame_ash.h" |
| #include "ash/wm/window_state.h" |
| +#include "ash/wm/window_state_delegate.h" |
| #include "ash/wm/window_util.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_view.h" |
| #include "ui/aura/client/aura_constants.h" |
| #include "ui/aura/window.h" |
| @@ -14,6 +18,42 @@ |
| using aura::Window; |
| +namespace { |
| +class BrowserWindowStateDelegate : public ash::wm::WindowStateDelegate { |
| + public: |
| + BrowserWindowStateDelegate() {} |
|
pkotwicz
2013/10/25 23:31:14
I would much rather have a Browser* parameter be p
oshima
2013/10/28 22:57:51
Done.
|
| + virtual ~BrowserWindowStateDelegate(){} |
| + |
| + // Invoked when the user uses Shift+F4 to toggle the window fullscreen state. |
|
pkotwicz
2013/10/25 23:31:14
Shift+F4 -> F4
oshima
2013/10/28 22:57:51
Changed to Shift+F4/F4
|
| + 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 |
|
pkotwicz
2013/10/25 23:31:14
Would it be possible to set a custom delegate in A
oshima
2013/10/28 22:57:51
Done.
|
| + // 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(BrowserWindowStateDelegate); |
| +}; |
| + |
| +} // namespace |
| + |
| //////////////////////////////////////////////////////////////////////////////// |
| // BrowserFrameAsh::WindowPropertyWatcher |
| @@ -86,8 +126,11 @@ BrowserFrameAsh::BrowserFrameAsh(BrowserFrame* browser_frame, |
| window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) { |
| GetNativeWindow()->SetName(kWindowName); |
| GetNativeWindow()->AddObserver(window_property_watcher_.get()); |
| - if (browser_view->browser()->is_type_tabbed()) |
| - ash::wm::SetAnimateToFullscreen(GetNativeWindow(), false); |
| + Browser* browser = browser_view->browser(); |
| + ash::wm::WindowState* window_state = |
| + ash::wm::GetWindowState(GetNativeWindow()); |
| + window_state->SetDelegate(new BrowserWindowStateDelegate()); |
| + window_state->set_animate_to_fullscreen(!browser->is_type_tabbed()); |
| // Turn on auto window management if we don't need an explicit bounds. |
| // This way the requested bounds are honored. |
| @@ -98,10 +141,7 @@ BrowserFrameAsh::BrowserFrameAsh(BrowserFrame* browser_frame, |
| // For legacy reasons v1 apps (like Secure Shell) are allowed to consume keys |
| // like brightness, volume, etc. Otherwise these keys are handled by the |
| // Ash window manager. |
| - if (browser_view->browser()->is_app()) { |
| - ash::wm::GetWindowState(GetNativeWindow())-> |
| - set_can_consume_system_keys(true); |
| - } |
| + window_state->set_can_consume_system_keys(browser_view->browser()->is_app()); |
| #endif // defined(OS_CHROMEOS) |
| } |