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

Side by Side Diff: chrome/browser/ui/views/native_widget_factory.cc

Issue 2923323002: Linux Aura: Use Separate profile key specifically for theme usage (Closed)
Patch Set: Created 3 years, 6 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
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/native_widget_factory.h" 5 #include "chrome/browser/ui/views/native_widget_factory.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/views/theme_profile_key.h"
8 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
9 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 10 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
10 #include "ui/views/widget/native_widget_aura.h" 11 #include "ui/views/widget/native_widget_aura.h"
11 12
12 views::NativeWidget* CreateNativeWidget( 13 views::NativeWidget* CreateNativeWidget(
13 NativeWidgetType type, 14 NativeWidgetType type,
14 views::Widget::InitParams* params, 15 views::Widget::InitParams* params,
15 views::internal::NativeWidgetDelegate* delegate) { 16 views::internal::NativeWidgetDelegate* delegate) {
16 // While the majority of the time, context wasn't plumbed through due to the 17 // While the majority of the time, context wasn't plumbed through due to the
17 // existence of a global WindowParentingClient, if this window is toplevel, 18 // existence of a global WindowParentingClient, if this window is toplevel,
18 // it's possible that there is no contextual state that we can use. 19 // it's possible that there is no contextual state that we can use.
19 gfx::NativeWindow parent_or_context = 20 gfx::NativeWindow parent_or_context =
20 params->parent ? params->parent : params->context; 21 params->parent ? params->parent : params->context;
21 // Set the profile key based on the profile of |parent_or_context|
22 // so that the widget will be styled with the apropriate
23 // NativeTheme. For browser windows, BrowserView will reset the
24 // profile key to profile of the corresponding Browser.
25 Profile* profile = nullptr; 22 Profile* profile = nullptr;
26 if (parent_or_context) { 23 if (parent_or_context)
27 profile = reinterpret_cast<Profile*>( 24 profile = GetThemeProfileForWindow(parent_or_context);
28 parent_or_context->GetNativeWindowProperty(Profile::kProfileKey)); 25 views::NativeWidget* native_widget = nullptr;
26 aura::Window* window = nullptr;
27 if (type == NativeWidgetType::DESKTOP_NATIVE_WIDGET_AURA ||
28 (!params->parent && !params->context && !params->child)) {
29 views::DesktopNativeWidgetAura* desktop_native_widget =
30 new views::DesktopNativeWidgetAura(delegate);
31 window = desktop_native_widget->GetNativeWindow();
sky 2017/06/07 16:24:50 How come you aren't setting the kProfileKey here?
Tom Anderson 2017/06/07 18:25:22 Because doing that would set it for the task manag
sky 2017/06/07 19:47:41 Ok. Please add a comment here then.
Tom Anderson 2017/06/08 00:13:26 Done.
32 native_widget = desktop_native_widget;
33 } else {
34 views::NativeWidgetAura* native_widget_aura =
35 new views::NativeWidgetAura(delegate);
36 if (params->parent) {
37 Profile* parent_profile = reinterpret_cast<Profile*>(
38 params->parent->GetNativeWindowProperty(Profile::kProfileKey));
39 native_widget_aura->SetNativeWindowProperty(Profile::kProfileKey,
40 parent_profile);
41 }
42 window = native_widget_aura->GetNativeWindow();
43 native_widget = native_widget_aura;
29 } 44 }
30 // Use the original profile because |window| may outlive the profile 45 // Use the original profile because |window| may outlive the profile
31 // of the context window. This can happen with incognito profiles. 46 // of the context window. This can happen with incognito profiles.
32 // However, the original profile will stick around until shutdown. 47 // However, the original profile will stick around until shutdown.
33 if (profile) 48 SetThemeProfileForWindow(window,
34 profile = profile->GetOriginalProfile(); 49 profile ? profile->GetOriginalProfile() : nullptr);
35 if (type == NativeWidgetType::DESKTOP_NATIVE_WIDGET_AURA || 50 return native_widget;
36 (!params->parent && !params->context && !params->child)) {
37 views::DesktopNativeWidgetAura* desktop_native_widget =
38 new views::DesktopNativeWidgetAura(delegate);
39 desktop_native_widget->SetNativeWindowProperty(Profile::kProfileKey,
40 profile);
41 return desktop_native_widget;
42 }
43 views::NativeWidgetAura* native_widget_aura =
44 new views::NativeWidgetAura(delegate);
45 native_widget_aura->SetNativeWindowProperty(Profile::kProfileKey, profile);
46 return native_widget_aura;
47 } 51 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/browser_view.cc ('k') | chrome/browser/ui/views/theme_profile_key.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698