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

Side by Side Diff: chrome/browser/ui/views/frame/browser_frame_ash.cc

Issue 42353002: Introduce WindowStateDelegate::ToggleFullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/browser_frame_ash.h" 5 #include "chrome/browser/ui/views/frame/browser_frame_ash.h"
6 6
7 #include "ash/wm/window_state.h" 7 #include "ash/wm/window_state.h"
8 #include "ash/wm/window_state_delegate.h"
8 #include "ash/wm/window_util.h" 9 #include "ash/wm/window_util.h"
10 #include "chrome/browser/ui/browser_commands.h"
11 #include "chrome/browser/ui/browser_finder.h"
12 #include "chrome/browser/ui/browser_window.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 13 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "ui/aura/client/aura_constants.h" 14 #include "ui/aura/client/aura_constants.h"
11 #include "ui/aura/window.h" 15 #include "ui/aura/window.h"
12 #include "ui/aura/window_observer.h" 16 #include "ui/aura/window_observer.h"
13 #include "ui/views/view.h" 17 #include "ui/views/view.h"
14 18
15 using aura::Window; 19 using aura::Window;
16 20
21 namespace {
22 class BrowserWindowStateDelegate : public ash::wm::WindowStateDelegate {
23 public:
24 BrowserWindowStateDelegate() {}
25 virtual ~BrowserWindowStateDelegate(){}
26
27 // Invoked when the user uses Shift+F4 to toggle the window fullscreen state.
28 virtual bool ToggleFullscreen(ash::wm::WindowState* window_state) OVERRIDE {
29 bool is_fullscreen = window_state->IsFullscreen();
30
31 // Windows which cannot be maximized should not be fullscreened.
32 if (!is_fullscreen && !window_state->CanMaximize())
33 return true;
34
35 Browser* browser = chrome::FindBrowserWithWindow(window_state->window());
36 DCHECK(browser);
pkotwicz 2013/10/25 19:56:38 I would make this CHECK() and remmove the followin
oshima 2013/10/25 22:36:20 Done.
37 if (!browser)
38 return true;
39 if (is_fullscreen) {
40 chrome::ToggleFullscreenMode(browser);
41 return true;
42 }
43 // AppNonClientFrameViewAsh shows only the window controls and no other
44 // window decorations which is pretty close to fullscreen. Put v1 apps
45 // into maximized mode instead of fullscreen to avoid showing the ugly
46 // fullscreen exit bubble.
47 if (browser->is_app() && browser->app_type() != Browser::APP_TYPE_CHILD)
48 window_state->ToggleMaximized();
49 else
50 chrome::ToggleFullscreenMode(browser);
51 return true;
52 }
53 private:
54 DISALLOW_COPY_AND_ASSIGN(BrowserWindowStateDelegate);
55 };
56
57 } // namespace
58
17 //////////////////////////////////////////////////////////////////////////////// 59 ////////////////////////////////////////////////////////////////////////////////
18 // BrowserFrameAsh::WindowPropertyWatcher 60 // BrowserFrameAsh::WindowPropertyWatcher
19 61
20 class BrowserFrameAsh::WindowPropertyWatcher : public aura::WindowObserver { 62 class BrowserFrameAsh::WindowPropertyWatcher : public aura::WindowObserver {
21 public: 63 public:
22 explicit WindowPropertyWatcher(BrowserFrameAsh* browser_frame_ash, 64 explicit WindowPropertyWatcher(BrowserFrameAsh* browser_frame_ash,
23 BrowserFrame* browser_frame) 65 BrowserFrame* browser_frame)
24 : browser_frame_ash_(browser_frame_ash), 66 : browser_frame_ash_(browser_frame_ash),
25 browser_frame_(browser_frame) {} 67 browser_frame_(browser_frame) {}
26 68
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 // static 121 // static
80 const char BrowserFrameAsh::kWindowName[] = "BrowserFrameAsh"; 122 const char BrowserFrameAsh::kWindowName[] = "BrowserFrameAsh";
81 123
82 BrowserFrameAsh::BrowserFrameAsh(BrowserFrame* browser_frame, 124 BrowserFrameAsh::BrowserFrameAsh(BrowserFrame* browser_frame,
83 BrowserView* browser_view) 125 BrowserView* browser_view)
84 : views::NativeWidgetAura(browser_frame), 126 : views::NativeWidgetAura(browser_frame),
85 browser_view_(browser_view), 127 browser_view_(browser_view),
86 window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) { 128 window_property_watcher_(new WindowPropertyWatcher(this, browser_frame)) {
87 GetNativeWindow()->SetName(kWindowName); 129 GetNativeWindow()->SetName(kWindowName);
88 GetNativeWindow()->AddObserver(window_property_watcher_.get()); 130 GetNativeWindow()->AddObserver(window_property_watcher_.get());
89 if (browser_view->browser()->is_type_tabbed()) 131 Browser* browser = browser_view->browser();
90 ash::wm::SetAnimateToFullscreen(GetNativeWindow(), false); 132 ash::wm::WindowState* window_state =
133 ash::wm::GetWindowState(GetNativeWindow());
134 window_state->SetDelegate(new BrowserWindowStateDelegate());
135 window_state->set_animate_to_fullscreen(!browser->is_type_tabbed());
pkotwicz 2013/10/25 19:56:38 FYI: This property seems to be to avoid animating
91 136
92 // Turn on auto window management if we don't need an explicit bounds. 137 // Turn on auto window management if we don't need an explicit bounds.
93 // This way the requested bounds are honored. 138 // This way the requested bounds are honored.
94 if (!browser_view->browser()->bounds_overridden() && 139 if (!browser_view->browser()->bounds_overridden() &&
95 !browser_view->browser()->is_session_restore()) 140 !browser_view->browser()->is_session_restore())
96 SetWindowAutoManaged(); 141 SetWindowAutoManaged();
97 #if defined(OS_CHROMEOS) 142 #if defined(OS_CHROMEOS)
98 // For legacy reasons v1 apps (like Secure Shell) are allowed to consume keys 143 // For legacy reasons v1 apps (like Secure Shell) are allowed to consume keys
99 // like brightness, volume, etc. Otherwise these keys are handled by the 144 // like brightness, volume, etc. Otherwise these keys are handled by the
100 // Ash window manager. 145 // Ash window manager.
101 if (browser_view->browser()->is_app()) { 146 window_state->set_can_consume_system_keys(browser_view->browser()->is_app());
102 ash::wm::GetWindowState(GetNativeWindow())->
103 set_can_consume_system_keys(true);
104 }
105 #endif // defined(OS_CHROMEOS) 147 #endif // defined(OS_CHROMEOS)
106 } 148 }
107 149
108 /////////////////////////////////////////////////////////////////////////////// 150 ///////////////////////////////////////////////////////////////////////////////
109 // BrowserFrameAsh, views::NativeWidgetAura overrides: 151 // BrowserFrameAsh, views::NativeWidgetAura overrides:
110 152
111 void BrowserFrameAsh::OnWindowDestroying() { 153 void BrowserFrameAsh::OnWindowDestroying() {
112 // Window is destroyed before our destructor is called, so clean up our 154 // Window is destroyed before our destructor is called, so clean up our
113 // observer here. 155 // observer here.
114 GetNativeWindow()->RemoveObserver(window_property_watcher_.get()); 156 GetNativeWindow()->RemoveObserver(window_property_watcher_.get());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 BrowserFrameAsh::~BrowserFrameAsh() { 194 BrowserFrameAsh::~BrowserFrameAsh() {
153 } 195 }
154 196
155 void BrowserFrameAsh::SetWindowAutoManaged() { 197 void BrowserFrameAsh::SetWindowAutoManaged() {
156 if (browser_view_->browser()->type() != Browser::TYPE_POPUP || 198 if (browser_view_->browser()->type() != Browser::TYPE_POPUP ||
157 browser_view_->browser()->is_app()) { 199 browser_view_->browser()->is_app()) {
158 ash::wm::GetWindowState(GetNativeWindow())-> 200 ash::wm::GetWindowState(GetNativeWindow())->
159 set_window_position_managed(true); 201 set_window_position_managed(true);
160 } 202 }
161 } 203 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698