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

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: git try Created 8 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 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 // Mark this window as automatically position managed if no initial
115 // bounds were given or we are not in restore mode. Otherwise this will be
116 // done after the window got shown.
sky 2012/10/22 16:40:50 How about: Turn on auto window management if we do
Mr4D (OOO till 08-26) 2012/10/22 20:27:23 Done.
117 if (!browser_view->browser()->bounds_overridden() &&
118 !browser_view->browser()->is_session_restore())
119 SetWindowAutoManaged();
113 #endif 120 #endif
114 } 121 }
115 122
116 /////////////////////////////////////////////////////////////////////////////// 123 ///////////////////////////////////////////////////////////////////////////////
117 // BrowserFrameAura, views::ContextMenuController overrides: 124 // BrowserFrameAura, views::ContextMenuController overrides:
118 void BrowserFrameAura::ShowContextMenuForView(views::View* source, 125 void BrowserFrameAura::ShowContextMenuForView(views::View* source,
119 const gfx::Point& p) { 126 const gfx::Point& p) {
120 // Only show context menu if point is in unobscured parts of browser, i.e. 127 // Only show context menu if point is in unobscured parts of browser, i.e.
121 // if NonClientHitTest returns : 128 // if NonClientHitTest returns :
122 // - HTCAPTION: in title bar or unobscured part of tabstrip 129 // - 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()); 161 GetNativeWindow()->RemoveObserver(window_property_watcher_.get());
155 views::NativeWidgetAura::OnWindowDestroying(); 162 views::NativeWidgetAura::OnWindowDestroying();
156 } 163 }
157 164
158 void BrowserFrameAura::OnWindowTargetVisibilityChanged(bool visible) { 165 void BrowserFrameAura::OnWindowTargetVisibilityChanged(bool visible) {
159 // On Aura when the BrowserView is shown it tries to restore focus, but can 166 // 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 167 // be blocked when this parent BrowserFrameAura isn't visible. Therefore we
161 // RestoreFocus() when we become visible, which results in the web contents 168 // 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 169 // being asked to focus, which places focus either in the web contents or in
163 // the location bar as appropriate. 170 // the location bar as appropriate.
164 if (visible) 171 if (visible) {
172 // If the window is able to get automatically managed, it can be marked now
sky 2012/10/22 16:40:50 How about: Once the window has been shown we know
Mr4D (OOO till 08-26) 2012/10/22 20:27:23 Done.
173 // for all use cases (since the workspace is now properly set up).
174 SetWindowAutoManaged();
175
165 browser_view_->RestoreFocus(); 176 browser_view_->RestoreFocus();
177 }
166 views::NativeWidgetAura::OnWindowTargetVisibilityChanged(visible); 178 views::NativeWidgetAura::OnWindowTargetVisibilityChanged(visible);
167 } 179 }
168 180
169 //////////////////////////////////////////////////////////////////////////////// 181 ////////////////////////////////////////////////////////////////////////////////
170 // BrowserFrameAura, NativeBrowserFrame implementation: 182 // BrowserFrameAura, NativeBrowserFrame implementation:
171 183
172 views::NativeWidget* BrowserFrameAura::AsNativeWidget() { 184 views::NativeWidget* BrowserFrameAura::AsNativeWidget() {
173 return this; 185 return this;
174 } 186 }
175 187
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 return new DesktopBrowserFrameAura(browser_frame, browser_view); 225 return new DesktopBrowserFrameAura(browser_frame, browser_view);
214 #endif 226 #endif
215 return new BrowserFrameAura(browser_frame, browser_view); 227 return new BrowserFrameAura(browser_frame, browser_view);
216 } 228 }
217 229
218 /////////////////////////////////////////////////////////////////////////////// 230 ///////////////////////////////////////////////////////////////////////////////
219 // BrowserFrameAura, private: 231 // BrowserFrameAura, private:
220 232
221 BrowserFrameAura::~BrowserFrameAura() { 233 BrowserFrameAura::~BrowserFrameAura() {
222 } 234 }
235
236 void BrowserFrameAura::SetWindowAutoManaged() {
237 #if defined(USE_ASH)
238 if (browser_view_->browser()->type() != Browser::TYPE_POPUP ||
239 browser_view_->browser()->is_app())
240 ash::wm::SetWindowPositionManaged(GetNativeWindow(), true);
241 #endif
242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698