| 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) | |
| 28 #include "ui/aura/root_window.h" | |
| 29 #endif | |
| 30 | |
| 31 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 27 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
| 32 #include "chrome/browser/ui/host_desktop.h" | 28 #include "chrome/browser/ui/host_desktop.h" |
| 29 #include "ui/aura/root_window.h" |
| 33 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 30 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 34 #include "ui/views/widget/native_widget_aura.h" | 31 #include "ui/views/widget/native_widget_aura.h" |
| 35 #endif | 32 #endif |
| 36 | 33 |
| 37 #if defined(USE_ASH) | 34 #if defined(USE_ASH) |
| 38 #include "ash/shell.h" | 35 #include "ash/shell.h" |
| 39 #include "chrome/browser/ui/ash/ash_init.h" | 36 #include "chrome/browser/ui/ash/ash_init.h" |
| 40 #include "chrome/browser/ui/ash/ash_util.h" | 37 #include "chrome/browser/ui/ash/ash_util.h" |
| 41 #endif | 38 #endif |
| 42 | 39 |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 167 |
| 171 content::WebContents* ChromeViewsDelegate::CreateWebContents( | 168 content::WebContents* ChromeViewsDelegate::CreateWebContents( |
| 172 content::BrowserContext* browser_context, | 169 content::BrowserContext* browser_context, |
| 173 content::SiteInstance* site_instance) { | 170 content::SiteInstance* site_instance) { |
| 174 return NULL; | 171 return NULL; |
| 175 } | 172 } |
| 176 | 173 |
| 177 void ChromeViewsDelegate::OnBeforeWidgetInit( | 174 void ChromeViewsDelegate::OnBeforeWidgetInit( |
| 178 views::Widget::InitParams* params, | 175 views::Widget::InitParams* params, |
| 179 views::internal::NativeWidgetDelegate* delegate) { | 176 views::internal::NativeWidgetDelegate* delegate) { |
| 177 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
| 180 // If we already have a native_widget, we don't have to try to come | 178 // If we already have a native_widget, we don't have to try to come |
| 181 // up with one. | 179 // up with one. |
| 182 if (params->native_widget) | 180 if (params->native_widget) |
| 183 return; | 181 return; |
| 184 | 182 |
| 185 #if defined(OS_CHROMEOS) | |
| 186 // When we are doing straight chromeos builds, we still need to handle the | |
| 187 // toplevel window case. | |
| 188 if (params->parent == NULL && params->context == NULL && params->top_level) | |
| 189 params->context = ash::Shell::GetPrimaryRootWindow(); | |
| 190 #elif defined(USE_AURA) | |
| 191 // While the majority of the time, context wasn't plumbed through due to the | 183 // While the majority of the time, context wasn't plumbed through due to the |
| 192 // existence of a global StackingClient, if this window is a toplevel, it's | 184 // existence of a global StackingClient, if this window is a toplevel, it's |
| 193 // possible that there is no contextual state that we can use. | 185 // possible that there is no contextual state that we can use. |
| 194 if (params->parent == NULL && params->context == NULL && params->top_level) { | 186 if (params->parent == NULL && params->context == NULL && params->top_level) { |
| 195 // We need to make a decision about where to place this window based on the | 187 // We need to make a decision about where to place this window based on the |
| 196 // desktop type. | 188 // desktop type. |
| 197 switch (chrome::GetActiveDesktop()) { | 189 switch (chrome::GetActiveDesktop()) { |
| 198 case chrome::HOST_DESKTOP_TYPE_NATIVE: | 190 case chrome::HOST_DESKTOP_TYPE_NATIVE: |
| 199 // If we're native, we should give this window its own toplevel desktop | 191 // If we're native, we should give this window its own toplevel desktop |
| 200 // widget. | 192 // widget. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 217 // should remove this check here. | 209 // should remove this check here. |
| 218 gfx::NativeView to_check = | 210 gfx::NativeView to_check = |
| 219 params->context ? params->context : params->parent; | 211 params->context ? params->context : params->parent; |
| 220 if (chrome::GetHostDesktopTypeForNativeView(to_check) == | 212 if (chrome::GetHostDesktopTypeForNativeView(to_check) == |
| 221 chrome::HOST_DESKTOP_TYPE_NATIVE) { | 213 chrome::HOST_DESKTOP_TYPE_NATIVE) { |
| 222 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | 214 params->native_widget = new views::DesktopNativeWidgetAura(delegate); |
| 223 } | 215 } |
| 224 } | 216 } |
| 225 #endif | 217 #endif |
| 226 } | 218 } |
| OLD | NEW |