| 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 <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include <shellapi.h> | 43 #include <shellapi.h> |
| 44 #include "base/profiler/scoped_tracker.h" | 44 #include "base/profiler/scoped_tracker.h" |
| 45 #include "base/task_runner_util.h" | 45 #include "base/task_runner_util.h" |
| 46 #include "base/win/windows_version.h" | 46 #include "base/win/windows_version.h" |
| 47 #include "chrome/browser/win/app_icon.h" | 47 #include "chrome/browser/win/app_icon.h" |
| 48 #include "ui/base/win/shell.h" | 48 #include "ui/base/win/shell.h" |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 #if defined(USE_AURA) | 51 #if defined(USE_AURA) |
| 52 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" | 52 #include "chrome/browser/ui/aura/accessibility/automation_manager_aura.h" |
| 53 #include "chrome/browser/ui/views/theme_profile_key.h" |
| 53 #include "ui/aura/window.h" | 54 #include "ui/aura/window.h" |
| 54 #include "ui/aura/window_event_dispatcher.h" | 55 #include "ui/aura/window_event_dispatcher.h" |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 #if defined(USE_AURA) && !defined(OS_CHROMEOS) | 58 #if defined(USE_AURA) && !defined(OS_CHROMEOS) |
| 58 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 59 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
| 59 #include "ui/views/widget/native_widget_aura.h" | 60 #include "ui/views/widget/native_widget_aura.h" |
| 60 #endif | 61 #endif |
| 61 | 62 |
| 62 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 63 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 if (params->context) | 444 if (params->context) |
| 444 params->context = params->context->GetRootWindow(); | 445 params->context = params->context->GetRootWindow(); |
| 445 DCHECK(params->parent || params->context || !params->child) | 446 DCHECK(params->parent || params->context || !params->child) |
| 446 << "Please provide a parent or context for this widget."; | 447 << "Please provide a parent or context for this widget."; |
| 447 if (!params->parent && !params->context) | 448 if (!params->parent && !params->context) |
| 448 params->context = ash::Shell::GetPrimaryRootWindow(); | 449 params->context = ash::Shell::GetPrimaryRootWindow(); |
| 449 #elif defined(USE_AURA) | 450 #elif defined(USE_AURA) |
| 450 // While the majority of the time, context wasn't plumbed through due to the | 451 // While the majority of the time, context wasn't plumbed through due to the |
| 451 // existence of a global WindowParentingClient, if this window is toplevel, | 452 // existence of a global WindowParentingClient, if this window is toplevel, |
| 452 // it's possible that there is no contextual state that we can use. | 453 // it's possible that there is no contextual state that we can use. |
| 453 if (params->parent == NULL && params->context == NULL && !params->child) { | 454 gfx::NativeWindow parent_or_context = |
| 454 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | 455 params->parent ? params->parent : params->context; |
| 455 } else if (use_non_toplevel_window) { | 456 Profile* profile = nullptr; |
| 457 if (parent_or_context) |
| 458 profile = GetThemeProfileForWindow(parent_or_context); |
| 459 aura::Window* window = nullptr; |
| 460 if ((!params->parent && !params->context && !params->child) || |
| 461 !use_non_toplevel_window) { |
| 462 views::DesktopNativeWidgetAura* native_widget = |
| 463 new views::DesktopNativeWidgetAura(delegate); |
| 464 params->native_widget = native_widget; |
| 465 window = native_widget->GetNativeWindow(); |
| 466 } else { |
| 456 views::NativeWidgetAura* native_widget = | 467 views::NativeWidgetAura* native_widget = |
| 457 new views::NativeWidgetAura(delegate); | 468 new views::NativeWidgetAura(delegate); |
| 458 if (params->parent) { | 469 if (params->parent) { |
| 459 Profile* parent_profile = reinterpret_cast<Profile*>( | 470 Profile* parent_profile = reinterpret_cast<Profile*>( |
| 460 params->parent->GetNativeWindowProperty(Profile::kProfileKey)); | 471 params->parent->GetNativeWindowProperty(Profile::kProfileKey)); |
| 461 native_widget->SetNativeWindowProperty(Profile::kProfileKey, | 472 native_widget->SetNativeWindowProperty(Profile::kProfileKey, |
| 462 parent_profile); | 473 parent_profile); |
| 463 } | 474 } |
| 464 params->native_widget = native_widget; | 475 params->native_widget = native_widget; |
| 465 } else { | 476 window = native_widget->GetNativeWindow(); |
| 466 params->native_widget = new views::DesktopNativeWidgetAura(delegate); | |
| 467 } | 477 } |
| 478 SetThemeProfileForWindow(window, profile); |
| 468 #endif | 479 #endif |
| 469 } | 480 } |
| 470 | 481 |
| 471 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 482 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 472 bool ChromeViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { | 483 bool ChromeViewsDelegate::WindowManagerProvidesTitleBar(bool maximized) { |
| 473 // On Ubuntu Unity, the system always provides a title bar for maximized | 484 // On Ubuntu Unity, the system always provides a title bar for maximized |
| 474 // windows. | 485 // windows. |
| 475 views::LinuxUI* ui = views::LinuxUI::instance(); | 486 views::LinuxUI* ui = views::LinuxUI::instance(); |
| 476 return maximized && ui && ui->UnityIsRunning(); | 487 return maximized && ui && ui->UnityIsRunning(); |
| 477 } | 488 } |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); | 588 LayoutDelegate::Metric::PANEL_CONTENT_MARGIN)); |
| 578 } | 589 } |
| 579 | 590 |
| 580 #if !defined(USE_ASH) | 591 #if !defined(USE_ASH) |
| 581 views::Widget::InitParams::WindowOpacity | 592 views::Widget::InitParams::WindowOpacity |
| 582 ChromeViewsDelegate::GetOpacityForInitParams( | 593 ChromeViewsDelegate::GetOpacityForInitParams( |
| 583 const views::Widget::InitParams& params) { | 594 const views::Widget::InitParams& params) { |
| 584 return views::Widget::InitParams::OPAQUE_WINDOW; | 595 return views::Widget::InitParams::OPAQUE_WINDOW; |
| 585 } | 596 } |
| 586 #endif | 597 #endif |
| OLD | NEW |