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

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

Issue 11085053: Improving window auto management between workspaces (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No auto movement for tab dragging Created 8 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_aura.h" 5 #include "chrome/browser/ui/views/frame/browser_frame_aura.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 9 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "chrome/browser/ui/views/frame/system_menu_model_delegate.h" 10 #include "chrome/browser/ui/views/frame/system_menu_model_delegate.h"
11 #include "grit/chromium_strings.h" 11 #include "grit/chromium_strings.h"
12 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
13 #include "ui/aura/client/aura_constants.h" 13 #include "ui/aura/client/aura_constants.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/aura/window_observer.h" 15 #include "ui/aura/window_observer.h"
16 #include "ui/base/hit_test.h" 16 #include "ui/base/hit_test.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/base/models/simple_menu_model.h" 18 #include "ui/base/models/simple_menu_model.h"
19 #include "ui/gfx/font.h" 19 #include "ui/gfx/font.h"
20 #include "ui/views/controls/menu/menu_model_adapter.h" 20 #include "ui/views/controls/menu/menu_model_adapter.h"
21 #include "ui/views/controls/menu/menu_runner.h" 21 #include "ui/views/controls/menu/menu_runner.h"
22 #include "ui/views/view.h" 22 #include "ui/views/view.h"
23 #include "ui/views/views_switches.h" 23 #include "ui/views/views_switches.h"
24 24
25 #if defined(USE_ASH) 25 #if defined(USE_ASH)
26 #include "ash/wm/property_util.h" 26 #include "ash/wm/property_util.h"
27 #include "ash/wm/window_util.h"
27 #endif 28 #endif
28 29
29 #if !defined(OS_CHROMEOS) 30 #if !defined(OS_CHROMEOS)
30 #include "chrome/browser/ui/views/frame/desktop_browser_frame_aura.h" 31 #include "chrome/browser/ui/views/frame/desktop_browser_frame_aura.h"
31 #endif 32 #endif
32 33
33 using aura::Window; 34 using aura::Window;
34 35
35 //////////////////////////////////////////////////////////////////////////////// 36 ////////////////////////////////////////////////////////////////////////////////
36 // BrowserFrameAura::WindowPropertyWatcher 37 // BrowserFrameAura::WindowPropertyWatcher
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 GetNativeWindow()->AddObserver(window_property_watcher_.get()); 104 GetNativeWindow()->AddObserver(window_property_watcher_.get());
104 #if defined(USE_ASH) 105 #if defined(USE_ASH)
105 // Tabbed browsers and apps (some apps are TYPE_POPUP) get their own 106 // Tabbed browsers and apps (some apps are TYPE_POPUP) get their own
106 // workspace. 107 // workspace.
107 if (browser_view->browser()->type() != Browser::TYPE_POPUP || 108 if (browser_view->browser()->type() != Browser::TYPE_POPUP ||
108 browser_view->browser()->is_app()) { 109 browser_view->browser()->is_app()) {
109 ash::SetPersistsAcrossAllWorkspaces( 110 ash::SetPersistsAcrossAllWorkspaces(
110 GetNativeWindow(), 111 GetNativeWindow(),
111 ash::WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO); 112 ash::WINDOW_PERSISTS_ACROSS_ALL_WORKSPACES_VALUE_NO);
112 } 113 }
114 // Turn on auto window management if we don't need an explicit bounds.
115 // This way the requested bounds are honored.
116 if (!browser_view->browser()->bounds_overridden() &&
117 !browser_view->browser()->is_session_restore())
118 SetWindowAutoManaged();
113 #endif 119 #endif
114 } 120 }
115 121
116 /////////////////////////////////////////////////////////////////////////////// 122 ///////////////////////////////////////////////////////////////////////////////
117 // BrowserFrameAura, views::ContextMenuController overrides: 123 // BrowserFrameAura, views::ContextMenuController overrides:
118 void BrowserFrameAura::ShowContextMenuForView(views::View* source, 124 void BrowserFrameAura::ShowContextMenuForView(views::View* source,
119 const gfx::Point& p) { 125 const gfx::Point& p) {
120 // Only show context menu if point is in unobscured parts of browser, i.e. 126 // Only show context menu if point is in unobscured parts of browser, i.e.
121 // if NonClientHitTest returns : 127 // if NonClientHitTest returns :
122 // - HTCAPTION: in title bar or unobscured part of tabstrip 128 // - HTCAPTION: in title bar or unobscured part of tabstrip
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 GetNativeWindow()->RemoveObserver(window_property_watcher_.get()); 160 GetNativeWindow()->RemoveObserver(window_property_watcher_.get());
155 views::NativeWidgetAura::OnWindowDestroying(); 161 views::NativeWidgetAura::OnWindowDestroying();
156 } 162 }
157 163
158 void BrowserFrameAura::OnWindowTargetVisibilityChanged(bool visible) { 164 void BrowserFrameAura::OnWindowTargetVisibilityChanged(bool visible) {
159 // On Aura when the BrowserView is shown it tries to restore focus, but can 165 // On Aura when the BrowserView is shown it tries to restore focus, but can
160 // be blocked when this parent BrowserFrameAura isn't visible. Therefore we 166 // be blocked when this parent BrowserFrameAura isn't visible. Therefore we
161 // RestoreFocus() when we become visible, which results in the web contents 167 // RestoreFocus() when we become visible, which results in the web contents
162 // being asked to focus, which places focus either in the web contents or in 168 // being asked to focus, which places focus either in the web contents or in
163 // the location bar as appropriate. 169 // the location bar as appropriate.
164 if (visible) 170 if (visible) {
171 // Once the window has been shown we know the requested bounds
172 // (if provided) have been honored and we can switch on window management.
173 SetWindowAutoManaged();
174
165 browser_view_->RestoreFocus(); 175 browser_view_->RestoreFocus();
176 }
166 views::NativeWidgetAura::OnWindowTargetVisibilityChanged(visible); 177 views::NativeWidgetAura::OnWindowTargetVisibilityChanged(visible);
167 } 178 }
168 179
169 //////////////////////////////////////////////////////////////////////////////// 180 ////////////////////////////////////////////////////////////////////////////////
170 // BrowserFrameAura, NativeBrowserFrame implementation: 181 // BrowserFrameAura, NativeBrowserFrame implementation:
171 182
172 views::NativeWidget* BrowserFrameAura::AsNativeWidget() { 183 views::NativeWidget* BrowserFrameAura::AsNativeWidget() {
173 return this; 184 return this;
174 } 185 }
175 186
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return new DesktopBrowserFrameAura(browser_frame, browser_view); 224 return new DesktopBrowserFrameAura(browser_frame, browser_view);
214 #endif 225 #endif
215 return new BrowserFrameAura(browser_frame, browser_view); 226 return new BrowserFrameAura(browser_frame, browser_view);
216 } 227 }
217 228
218 /////////////////////////////////////////////////////////////////////////////// 229 ///////////////////////////////////////////////////////////////////////////////
219 // BrowserFrameAura, private: 230 // BrowserFrameAura, private:
220 231
221 BrowserFrameAura::~BrowserFrameAura() { 232 BrowserFrameAura::~BrowserFrameAura() {
222 } 233 }
234
235 void BrowserFrameAura::SetWindowAutoManaged() {
236 #if defined(USE_ASH)
237 if (browser_view_->browser()->type() != Browser::TYPE_POPUP ||
238 browser_view_->browser()->is_app())
239 ash::wm::SetWindowPositionManaged(GetNativeWindow(), true);
240 #endif
241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698