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

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

Issue 2862113002: Linux Aura: Use incognito profile to theme incognito browser windows (Closed)
Patch Set: address estade@'s comments Created 3 years, 7 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"
9 #include "ui/aura/window.h" 8 #include "ui/aura/window.h"
10 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" 9 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
11 #include "ui/views/widget/native_widget_aura.h" 10 #include "ui/views/widget/native_widget_aura.h"
12 11
13 views::NativeWidget* CreateNativeWidget( 12 views::NativeWidget* CreateNativeWidget(
14 NativeWidgetType type, 13 NativeWidgetType type,
15 views::Widget::InitParams* params, 14 views::Widget::InitParams* params,
16 views::internal::NativeWidgetDelegate* delegate) { 15 views::internal::NativeWidgetDelegate* delegate) {
17 // While the majority of the time, context wasn't plumbed through due to the 16 // While the majority of the time, context wasn't plumbed through due to the
18 // existence of a global WindowParentingClient, if this window is toplevel, 17 // existence of a global WindowParentingClient, if this window is toplevel,
19 // it's possible that there is no contextual state that we can use. 18 // it's possible that there is no contextual state that we can use.
20 gfx::NativeWindow parent_or_context = 19 gfx::NativeWindow parent_or_context =
21 params->parent ? params->parent : params->context; 20 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.
22 Profile* profile = nullptr; 25 Profile* profile = nullptr;
23 if (parent_or_context) 26 if (parent_or_context) {
24 profile = GetThemeProfileForWindow(parent_or_context); 27 profile = reinterpret_cast<Profile*>(
25 views::NativeWidget* native_widget = nullptr; 28 parent_or_context->GetNativeWindowProperty(Profile::kProfileKey));
26 aura::Window* window = nullptr; 29 }
30 // Use the original profile because |window| may outlive the profile
31 // of the context window. This can happen with incognito profiles.
32 // However, the original profile will stick around until shutdown.
sky 2017/05/09 16:58:24 I think it's worth a comment that BrowserView rese
Tom (Use chromium acct) 2017/05/09 17:24:09 Already done. See the comment above this one
sky 2017/05/09 19:27:46 Sorry. I some how missed that.
33 if (profile)
34 profile = profile->GetOriginalProfile();
27 if (type == NativeWidgetType::DESKTOP_NATIVE_WIDGET_AURA || 35 if (type == NativeWidgetType::DESKTOP_NATIVE_WIDGET_AURA ||
28 (!params->parent && !params->context && !params->child)) { 36 (!params->parent && !params->context && !params->child)) {
29 views::DesktopNativeWidgetAura* desktop_native_widget = 37 views::DesktopNativeWidgetAura* desktop_native_widget =
30 new views::DesktopNativeWidgetAura(delegate); 38 new views::DesktopNativeWidgetAura(delegate);
31 window = desktop_native_widget->GetNativeWindow(); 39 desktop_native_widget->SetNativeWindowProperty(Profile::kProfileKey,
32 native_widget = desktop_native_widget; 40 profile);
33 } else { 41 return desktop_native_widget;
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;
44 } 42 }
45 SetThemeProfileForWindow(window, profile); 43 views::NativeWidgetAura* native_widget_aura =
46 return native_widget; 44 new views::NativeWidgetAura(delegate);
45 native_widget_aura->SetNativeWindowProperty(Profile::kProfileKey, profile);
46 return native_widget_aura;
47 } 47 }
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