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/frame/browser_non_client_frame_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view.h" |
6 | 6 |
7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/profiles/avatar_menu.h" | 9 #include "chrome/browser/profiles/avatar_menu.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 11 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
12 #include "chrome/browser/profiles/profile_info_cache.h" | |
13 #include "chrome/browser/profiles/profile_manager.h" | 12 #include "chrome/browser/profiles/profile_manager.h" |
14 #include "chrome/browser/profiles/profiles_state.h" | 13 #include "chrome/browser/profiles/profiles_state.h" |
15 #include "chrome/browser/themes/theme_properties.h" | 14 #include "chrome/browser/themes/theme_properties.h" |
16 #include "chrome/browser/ui/view_ids.h" | 15 #include "chrome/browser/ui/view_ids.h" |
17 #include "chrome/browser/ui/views/frame/browser_view.h" | 16 #include "chrome/browser/ui/views/frame/browser_view.h" |
18 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" | 17 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" |
19 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" | 18 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h" |
20 #include "chrome/browser/ui/views/tabs/tab_strip.h" | 19 #include "chrome/browser/ui/views/tabs/tab_strip.h" |
21 #include "components/signin/core/common/profile_management_switches.h" | 20 #include "components/signin/core/common/profile_management_switches.h" |
22 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
23 #include "third_party/skia/include/core/SkColor.h" | 22 #include "third_party/skia/include/core/SkColor.h" |
24 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
25 #include "ui/base/theme_provider.h" | 24 #include "ui/base/theme_provider.h" |
26 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
27 #include "ui/resources/grit/ui_resources.h" | 26 #include "ui/resources/grit/ui_resources.h" |
28 #include "ui/views/background.h" | 27 #include "ui/views/background.h" |
29 #include "ui/views/resources/grit/views_resources.h" | 28 #include "ui/views/resources/grit/views_resources.h" |
30 | 29 |
31 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, | 30 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, |
32 BrowserView* browser_view) | 31 BrowserView* browser_view) |
33 : frame_(frame), | 32 : frame_(frame), |
34 browser_view_(browser_view), | 33 browser_view_(browser_view) { |
35 avatar_button_(nullptr) { | |
36 // The profile manager may by null in tests. | 34 // The profile manager may by null in tests. |
37 if (g_browser_process->profile_manager()) { | 35 if (g_browser_process->profile_manager()) { |
38 ProfileInfoCache& cache = | 36 g_browser_process->profile_manager()-> |
39 g_browser_process->profile_manager()->GetProfileInfoCache(); | 37 GetProfileAttributesStorage().AddObserver(this); |
40 cache.AddObserver(this); | |
41 } | 38 } |
42 } | 39 } |
43 | 40 |
44 BrowserNonClientFrameView::~BrowserNonClientFrameView() { | 41 BrowserNonClientFrameView::~BrowserNonClientFrameView() { |
45 // The profile manager may by null in tests. | 42 // The profile manager may by null in tests. |
46 if (g_browser_process->profile_manager()) { | 43 if (g_browser_process->profile_manager()) { |
47 ProfileInfoCache& cache = | 44 g_browser_process->profile_manager()-> |
48 g_browser_process->profile_manager()->GetProfileInfoCache(); | 45 GetProfileAttributesStorage().RemoveObserver(this); |
49 cache.RemoveObserver(this); | |
50 } | 46 } |
51 } | 47 } |
52 | 48 |
53 void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() {} | 49 void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() {} |
54 | 50 |
55 void BrowserNonClientFrameView::UpdateToolbar() { | 51 void BrowserNonClientFrameView::UpdateToolbar() { |
56 } | 52 } |
57 | 53 |
58 views::View* BrowserNonClientFrameView::GetLocationIconView() const { | 54 views::View* BrowserNonClientFrameView::GetLocationIconView() const { |
59 return nullptr; | 55 return nullptr; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // pinned the badge-less Chrome shortcut which will cause windows to ignore | 222 // pinned the badge-less Chrome shortcut which will cause windows to ignore |
227 // the relaunch details. | 223 // the relaunch details. |
228 // TODO(calamity): ideally this should not be necessary but due to issues | 224 // TODO(calamity): ideally this should not be necessary but due to issues |
229 // with the default shortcut being pinned, we add the runtime badge for | 225 // with the default shortcut being pinned, we add the runtime badge for |
230 // safety. See crbug.com/313800. | 226 // safety. See crbug.com/313800. |
231 bool show_decoration = AvatarMenu::ShouldShowAvatarMenu() && | 227 bool show_decoration = AvatarMenu::ShouldShowAvatarMenu() && |
232 !browser_view_->browser()->profile()->IsGuestSession(); | 228 !browser_view_->browser()->profile()->IsGuestSession(); |
233 // In tests, make sure that the browser process and profile manager are | 229 // In tests, make sure that the browser process and profile manager are |
234 // valid before using. | 230 // valid before using. |
235 if (g_browser_process && g_browser_process->profile_manager()) { | 231 if (g_browser_process && g_browser_process->profile_manager()) { |
236 const ProfileInfoCache& cache = | 232 const ProfileAttributesStorage& storage = |
237 g_browser_process->profile_manager()->GetProfileInfoCache(); | 233 g_browser_process->profile_manager()->GetProfileAttributesStorage(); |
238 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; | 234 show_decoration = show_decoration && storage.GetNumberOfProfiles() > 1; |
239 } | 235 } |
240 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), | 236 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), |
241 show_decoration | 237 show_decoration |
242 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) | 238 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) |
243 : nullptr); | 239 : nullptr); |
244 } | 240 } |
245 } | 241 } |
OLD | NEW |