Index: chrome/browser/ui/views/frame/browser_non_client_frame_view.cc |
diff --git a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc |
index b2a6caa11f4a1a742423856ffd7672b9b0d93168..eb50d337154d943bc789cbc15ff0bd4478ea0076 100644 |
--- a/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc |
+++ b/chrome/browser/ui/views/frame/browser_non_client_frame_view.cc |
@@ -31,14 +31,11 @@ |
#include "ui/views/background.h" |
#include "ui/views/resources/grit/views_resources.h" |
-#if defined(OS_WIN) |
-#include "base/win/windows_version.h" |
-#endif |
- |
BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, |
BrowserView* browser_view) |
: frame_(frame), |
- browser_view_(browser_view) { |
+ browser_view_(browser_view), |
+ observer_(this) { |
sky
2016/03/17 21:00:31
Feels wrong to have an observer on Widget when the
Peter Kasting
2016/03/17 23:14:10
Done.
|
// The profile manager may by null in tests. |
if (g_browser_process->profile_manager()) { |
g_browser_process->profile_manager()-> |
@@ -59,14 +56,8 @@ void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() {} |
gfx::ImageSkia BrowserNonClientFrameView::GetOTRAvatarIcon() const { |
if (!ui::MaterialDesignController::IsModeMaterial()) |
return *GetThemeProviderForProfile()->GetImageSkiaNamed(IDR_OTR_ICON); |
- SkColor icon_color = SK_ColorWHITE; |
-#if defined(OS_WIN) |
- // On Windows 10+, we assume the native frame color is white. |
- // TODO(pkasting): Read the correct frame color from the registry or APIs. |
- if (GetWidget() && GetWidget()->ShouldUseNativeFrame() && |
- (base::win::GetVersion() >= base::win::VERSION_WIN10)) |
- icon_color = gfx::kChromeIconGrey; |
-#endif |
+ const SkColor icon_color = color_utils::PickContrastingColor( |
+ SK_ColorWHITE, gfx::kChromeIconGrey, GetFrameColor()); |
return gfx::CreateVectorIcon(gfx::VectorIconId::INCOGNITO, 24, icon_color); |
} |
@@ -99,9 +90,10 @@ SkColor BrowserNonClientFrameView::GetFrameColor(bool active) const { |
ThemeProperties::OverwritableByUserThemeProperty color_id = |
active ? ThemeProperties::COLOR_FRAME |
: ThemeProperties::COLOR_FRAME_INACTIVE; |
- return ShouldPaintAsThemed() ? GetThemeProvider()->GetColor(color_id) |
- : ThemeProperties::GetDefaultColor( |
- color_id, browser_view_->IsOffTheRecord()); |
+ return ShouldPaintAsThemed() ? |
+ GetThemeProviderForProfile()->GetColor(color_id) : |
+ ThemeProperties::GetDefaultColor(color_id, |
+ browser_view_->IsOffTheRecord()); |
} |
gfx::ImageSkia BrowserNonClientFrameView::GetFrameImage(bool active) const { |
@@ -191,8 +183,28 @@ void BrowserNonClientFrameView::UpdateOldAvatarButton() { |
void BrowserNonClientFrameView::ViewHierarchyChanged( |
const ViewHierarchyChangedDetails& details) { |
- if (details.is_add && details.child == this) |
+ if (details.is_add && details.child == this) { |
+ if (ui::MaterialDesignController::IsModeMaterial()) |
+ observer_.Add(GetWidget()); |
UpdateAvatar(); |
+ } |
+} |
+ |
+// TODO(pkasting): This probably isn't needed, I bet the widget is guaranteed to |
+// outlive us. |
+void BrowserNonClientFrameView::OnWidgetDestroyed(views::Widget* widget) { |
+ observer_.Remove(widget); |
+} |
+ |
+void BrowserNonClientFrameView::OnWidgetActivationChanged(views::Widget* widget, |
+ bool active) { |
+ // On Windows, while deactivating the widget, this is called before the active |
+ // HWND has actually been changed. Since we want the avatar state to reflect |
+ // that the window is inactive, we force NonClientFrameView to see the |
+ // "correct" state as an override. |
+ set_active_state_override(&active); |
+ UpdateAvatar(); |
+ set_active_state_override(nullptr); |
} |
void BrowserNonClientFrameView::OnProfileAdded( |