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

Unified Diff: chrome/browser/ui/views/native_widget_factory.cc

Issue 2923323002: Linux Aura: Use Separate profile key specifically for theme usage (Closed)
Patch Set: Add comment 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/native_widget_factory.cc
diff --git a/chrome/browser/ui/views/native_widget_factory.cc b/chrome/browser/ui/views/native_widget_factory.cc
index b4ad4ae84ba0cb0241fca4acccdc4170cf2e5883..b72680b466e558c24b8b922c900b9d97c2119267 100644
--- a/chrome/browser/ui/views/native_widget_factory.cc
+++ b/chrome/browser/ui/views/native_widget_factory.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/views/native_widget_factory.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/views/theme_profile_key.h"
#include "ui/aura/window.h"
#include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h"
#include "ui/views/widget/native_widget_aura.h"
@@ -18,30 +19,36 @@ views::NativeWidget* CreateNativeWidget(
// it's possible that there is no contextual state that we can use.
gfx::NativeWindow parent_or_context =
params->parent ? params->parent : params->context;
- // Set the profile key based on the profile of |parent_or_context|
- // so that the widget will be styled with the apropriate
- // NativeTheme. For browser windows, BrowserView will reset the
- // profile key to profile of the corresponding Browser.
Profile* profile = nullptr;
- if (parent_or_context) {
- profile = reinterpret_cast<Profile*>(
- parent_or_context->GetNativeWindowProperty(Profile::kProfileKey));
- }
- // Use the original profile because |window| may outlive the profile
- // of the context window. This can happen with incognito profiles.
- // However, the original profile will stick around until shutdown.
- if (profile)
- profile = profile->GetOriginalProfile();
+ if (parent_or_context)
+ profile = GetThemeProfileForWindow(parent_or_context);
+ views::NativeWidget* native_widget = nullptr;
+ aura::Window* window = nullptr;
if (type == NativeWidgetType::DESKTOP_NATIVE_WIDGET_AURA ||
(!params->parent && !params->context && !params->child)) {
+ // In the desktop case, do not always set the profile window
+ // property from the parent since there are windows (like the task
+ // manager) that are not associated with a specific profile.
views::DesktopNativeWidgetAura* desktop_native_widget =
new views::DesktopNativeWidgetAura(delegate);
- desktop_native_widget->SetNativeWindowProperty(Profile::kProfileKey,
- profile);
- return desktop_native_widget;
+ window = desktop_native_widget->GetNativeWindow();
+ native_widget = desktop_native_widget;
+ } else {
+ views::NativeWidgetAura* native_widget_aura =
+ new views::NativeWidgetAura(delegate);
+ if (params->parent) {
+ Profile* parent_profile = reinterpret_cast<Profile*>(
+ params->parent->GetNativeWindowProperty(Profile::kProfileKey));
+ native_widget_aura->SetNativeWindowProperty(Profile::kProfileKey,
+ parent_profile);
+ }
+ window = native_widget_aura->GetNativeWindow();
+ native_widget = native_widget_aura;
}
- views::NativeWidgetAura* native_widget_aura =
- new views::NativeWidgetAura(delegate);
- native_widget_aura->SetNativeWindowProperty(Profile::kProfileKey, profile);
- return native_widget_aura;
+ // Use the original profile because |window| may outlive the profile
+ // of the context window. This can happen with incognito profiles.
+ // However, the original profile will stick around until shutdown.
+ SetThemeProfileForWindow(window,
+ profile ? profile->GetOriginalProfile() : nullptr);
+ return native_widget;
}
« 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