| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/prefs/scoped_user_pref_update.h" | 9 #include "base/prefs/scoped_user_pref_update.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 return; | 261 return; |
| 262 | 262 |
| 263 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 263 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
| 264 bool use_non_toplevel_window = | 264 bool use_non_toplevel_window = |
| 265 params->parent && params->type != views::Widget::InitParams::TYPE_MENU; | 265 params->parent && params->type != views::Widget::InitParams::TYPE_MENU; |
| 266 | 266 |
| 267 #if defined(OS_WIN) | 267 #if defined(OS_WIN) |
| 268 // On desktop Linux Chrome must run in an environment that supports a variety | 268 // On desktop Linux Chrome must run in an environment that supports a variety |
| 269 // of window managers, some of which do not play nicely with parts of our UI | 269 // of window managers, some of which do not play nicely with parts of our UI |
| 270 // that have specific expectations about window sizing and placement. For this | 270 // that have specific expectations about window sizing and placement. For this |
| 271 // reason windows opened as top level (params.top_level) are always | 271 // reason windows opened as top level (!params.child) are always constrained |
| 272 // constrained by the browser frame, so we can position them correctly. This | 272 // by the browser frame, so we can position them correctly. This has some |
| 273 // has some negative side effects, like dialogs being clipped by the browser | 273 // negative side effects, like dialogs being clipped by the browser frame, but |
| 274 // frame, but the side effects are not as bad as the poor window manager | 274 // the side effects are not as bad as the poor window manager interactions. On |
| 275 // interactions. On Windows however these WM interactions are not an issue, so | 275 // Windows however these WM interactions are not an issue, so we open windows |
| 276 // we open windows requested as top_level as actual top level windows on the | 276 // requested as top_level as actual top level windows on the desktop. |
| 277 // desktop. | |
| 278 use_non_toplevel_window = use_non_toplevel_window && | 277 use_non_toplevel_window = use_non_toplevel_window && |
| 279 (!params->top_level || | 278 (params->child || |
| 280 chrome::GetHostDesktopTypeForNativeView(params->parent) != | 279 chrome::GetHostDesktopTypeForNativeView(params->parent) != |
| 281 chrome::HOST_DESKTOP_TYPE_NATIVE); | 280 chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 282 | 281 |
| 283 if (!ui::win::IsAeroGlassEnabled()) { | 282 if (!ui::win::IsAeroGlassEnabled()) { |
| 284 // If we don't have composition (either because Glass is not enabled or | 283 // If we don't have composition (either because Glass is not enabled or |
| 285 // because it was disabled at the command line), anything that requires | 284 // because it was disabled at the command line), anything that requires |
| 286 // transparency will be broken with a toplevel window, so force the use of | 285 // transparency will be broken with a toplevel window, so force the use of |
| 287 // a non toplevel window. | 286 // a non toplevel window. |
| 288 if (params->opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW && | 287 if (params->opacity == views::Widget::InitParams::TRANSLUCENT_WINDOW && |
| 289 params->type != views::Widget::InitParams::TYPE_MENU) | 288 params->type != views::Widget::InitParams::TYPE_MENU) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 307 | 306 |
| 308 #if defined(OS_CHROMEOS) | 307 #if defined(OS_CHROMEOS) |
| 309 // When we are doing straight chromeos builds, we still need to handle the | 308 // When we are doing straight chromeos builds, we still need to handle the |
| 310 // toplevel window case. | 309 // toplevel window case. |
| 311 // There may be a few remaining widgets in Chrome OS that are not top level, | 310 // There may be a few remaining widgets in Chrome OS that are not top level, |
| 312 // but have neither a context nor a parent. Provide a fallback context so | 311 // but have neither a context nor a parent. Provide a fallback context so |
| 313 // users don't crash. Developers will hit the DCHECK and should provide a | 312 // users don't crash. Developers will hit the DCHECK and should provide a |
| 314 // context. | 313 // context. |
| 315 if (params->context) | 314 if (params->context) |
| 316 params->context = params->context->GetRootWindow(); | 315 params->context = params->context->GetRootWindow(); |
| 317 DCHECK(params->parent || params->context || params->top_level) | 316 DCHECK(params->parent || params->context || !params->child) |
| 318 << "Please provide a parent or context for this widget."; | 317 << "Please provide a parent or context for this widget."; |
| 319 if (!params->parent && !params->context) | 318 if (!params->parent && !params->context) |
| 320 params->context = ash::Shell::GetPrimaryRootWindow(); | 319 params->context = ash::Shell::GetPrimaryRootWindow(); |
| 321 #elif defined(USE_AURA) | 320 #elif defined(USE_AURA) |
| 322 // While the majority of the time, context wasn't plumbed through due to the | 321 // While the majority of the time, context wasn't plumbed through due to the |
| 323 // existence of a global WindowTreeClient, if this window is a toplevel, it's | 322 // existence of a global WindowTreeClient, if this window is toplevel, it's |
| 324 // possible that there is no contextual state that we can use. | 323 // possible that there is no contextual state that we can use. |
| 325 if (params->parent == NULL && params->context == NULL && params->top_level) { | 324 if (params->parent == NULL && |
| 325 params->context == NULL && |
| 326 !params->child && |
| 327 params->type != views::Widget::InitParams::TYPE_TOOLTIP) { |
| 326 // We need to make a decision about where to place this window based on the | 328 // We need to make a decision about where to place this window based on the |
| 327 // desktop type. | 329 // desktop type. |
| 328 switch (chrome::GetActiveDesktop()) { | 330 switch (chrome::GetActiveDesktop()) { |
| 329 case chrome::HOST_DESKTOP_TYPE_NATIVE: | 331 case chrome::HOST_DESKTOP_TYPE_NATIVE: |
| 330 // If we're native, we should give this window its own toplevel desktop | 332 // If we're native, we should give this window its own toplevel desktop |
| 331 // widget. | 333 // widget. |
| 332 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | 334 params->native_widget = new views::DesktopNativeWidgetAura(delegate); |
| 333 break; | 335 break; |
| 334 #if defined(USE_ASH) | 336 #if defined(USE_ASH) |
| 335 case chrome::HOST_DESKTOP_TYPE_ASH: | 337 case chrome::HOST_DESKTOP_TYPE_ASH: |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 } | 420 } |
| 419 #endif | 421 #endif |
| 420 | 422 |
| 421 #if !defined(USE_AURA) && !defined(USE_CHROMEOS) | 423 #if !defined(USE_AURA) && !defined(USE_CHROMEOS) |
| 422 views::Widget::InitParams::WindowOpacity | 424 views::Widget::InitParams::WindowOpacity |
| 423 ChromeViewsDelegate::GetOpacityForInitParams( | 425 ChromeViewsDelegate::GetOpacityForInitParams( |
| 424 const views::Widget::InitParams& params) { | 426 const views::Widget::InitParams& params) { |
| 425 return views::Widget::InitParams::OPAQUE_WINDOW; | 427 return views::Widget::InitParams::OPAQUE_WINDOW; |
| 426 } | 428 } |
| 427 #endif | 429 #endif |
| OLD | NEW |