OLD | NEW |
---|---|
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/chrome_views_delegate.h" | 5 #include "chrome/browser/ui/views/chrome_views_delegate.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/event_disposition.h" | 12 #include "chrome/browser/event_disposition.h" |
13 #include "chrome/browser/prefs/pref_service.h" | 13 #include "chrome/browser/prefs/pref_service.h" |
14 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 14 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/browser/ui/views/accessibility/accessibility_event_router_views .h" | 16 #include "chrome/browser/ui/views/accessibility/accessibility_event_router_views .h" |
17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
18 #include "ui/gfx/rect.h" | 18 #include "ui/gfx/rect.h" |
19 #include "ui/gfx/screen.h" | 19 #include "ui/gfx/screen.h" |
20 #include "ui/views/widget/native_widget.h" | 20 #include "ui/views/widget/native_widget.h" |
21 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
22 | 22 |
23 #if defined(OS_WIN) | 23 #if defined(OS_WIN) |
24 #include "chrome/browser/app_icon_win.h" | 24 #include "chrome/browser/app_icon_win.h" |
25 #endif | 25 #endif |
26 | 26 |
27 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 27 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
28 #include "chrome/browser/ui/host_desktop.h" | |
28 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 29 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
29 #include "ui/views/widget/native_widget_aura.h" | 30 #include "ui/views/widget/native_widget_aura.h" |
30 #endif | 31 #endif |
31 | 32 |
32 #if defined(USE_ASH) | 33 #if defined(USE_ASH) |
33 #include "ash/shell.h" | 34 #include "ash/shell.h" |
34 #include "chrome/browser/ui/ash/ash_init.h" | 35 #include "chrome/browser/ui/ash/ash_init.h" |
35 #include "chrome/browser/ui/ash/ash_util.h" | 36 #include "chrome/browser/ui/ash/ash_util.h" |
36 #endif | 37 #endif |
37 | 38 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { | 167 int ChromeViewsDelegate::GetDispositionForEvent(int event_flags) { |
167 return chrome::DispositionFromEventFlags(event_flags); | 168 return chrome::DispositionFromEventFlags(event_flags); |
168 } | 169 } |
169 | 170 |
170 content::WebContents* ChromeViewsDelegate::CreateWebContents( | 171 content::WebContents* ChromeViewsDelegate::CreateWebContents( |
171 content::BrowserContext* browser_context, | 172 content::BrowserContext* browser_context, |
172 content::SiteInstance* site_instance) { | 173 content::SiteInstance* site_instance) { |
173 return NULL; | 174 return NULL; |
174 } | 175 } |
175 | 176 |
176 views::NativeWidget* ChromeViewsDelegate::CreateNativeWidget( | 177 void ChromeViewsDelegate::OnWidgetInit( |
177 views::Widget::InitParams::Type type, | 178 views::Widget::InitParams* params, |
178 views::internal::NativeWidgetDelegate* delegate, | 179 views::internal::NativeWidgetDelegate* delegate) { |
179 gfx::NativeView parent, | |
180 gfx::NativeView context) { | |
181 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 180 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
182 if (parent && type != views::Widget::InitParams::TYPE_MENU) | 181 // While the majority of the time, context wasn't plumbed through due to the |
183 return new views::NativeWidgetAura(delegate); | 182 // existence of a global StackingClient, if this window is a toplevel, it's |
184 // TODO(erg): Once we've threaded context to everywhere that needs it, we | 183 // possible that there is no contextual state that we can use. |
185 // should remove this check here. | 184 if (params->parent == NULL && |
186 gfx::NativeView to_check = context ? context : parent; | 185 params->context == NULL && |
187 if (chrome::GetHostDesktopTypeForNativeView(to_check) == | 186 params->top_level == true) { |
Ben Goodger (Google)
2012/12/13 23:47:41
params->top_level
| |
188 chrome::HOST_DESKTOP_TYPE_NATIVE) | 187 // We need to make a decision about where to place this window based on the |
189 return new views::DesktopNativeWidgetAura(delegate); | 188 // desktop type. |
189 switch (chrome::GetActiveDesktop()) { | |
190 case chrome::HOST_DESKTOP_TYPE_NATIVE: { | |
Ben Goodger (Google)
2012/12/13 23:47:41
you don't need the braces on each case since you'r
| |
191 // If we're native, we should give this window its own toplevel desktop | |
192 // widget. | |
193 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | |
194 break; | |
195 } | |
196 case chrome::HOST_DESKTOP_TYPE_ASH: { | |
197 #if defined(USE_ASH) | |
robertshield
2012/12/14 01:15:58
How about moving the #if to completely surround th
| |
198 // If we're in ash, give this window the context of the main monitor. | |
199 params->context = ash::Shell::GetPrimaryRootWindow(); | |
190 #endif | 200 #endif |
191 return NULL; | 201 break; |
202 } | |
203 default: { | |
204 NOTREACHED(); | |
205 } | |
206 } | |
207 } else { | |
208 if (params->parent && params->type != views::Widget::InitParams::TYPE_MENU) | |
209 params->native_widget = new views::NativeWidgetAura(delegate); | |
210 | |
211 // TODO(erg): Once we've threaded context to everywhere that needs it, we | |
212 // should remove this check here. | |
213 gfx::NativeView to_check = | |
214 params->context ? params->context : params->parent; | |
215 if (chrome::GetHostDesktopTypeForNativeView(to_check) == | |
216 chrome::HOST_DESKTOP_TYPE_NATIVE) { | |
217 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | |
218 } | |
219 } | |
220 #endif | |
192 } | 221 } |
OLD | NEW |