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

Side by Side Diff: chrome/browser/ui/views/frame/browser_non_client_frame_view.cc

Issue 1701563002: Refactor ProfileInfoCache in c/b/ui/views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments Created 4 years, 10 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 (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 #if defined(FRAME_AVATAR_BUTTON) 34 #if defined(FRAME_AVATAR_BUTTON)
36 profile_switcher_(this), 35 profile_switcher_(this),
37 #endif 36 #endif
38 avatar_button_(nullptr) { 37 avatar_button_(nullptr) {
achuithb 2016/02/19 11:55:22 nit: initialize this in header
lwchkg 2016/02/19 15:00:10 Normally your suggestion is the better solution. B
achuithb 2016/02/19 15:06:18 Personally I'm fine with this provided you leave a
lwchkg 2016/02/19 16:46:04 Appears that someone has patched away the #if bloc
39 // The profile manager may by null in tests. 38 // The profile manager may by null in tests.
40 if (g_browser_process->profile_manager()) { 39 if (g_browser_process->profile_manager()) {
41 ProfileInfoCache& cache = 40 g_browser_process->profile_manager()->
42 g_browser_process->profile_manager()->GetProfileInfoCache(); 41 GetProfileAttributesStorage().AddObserver(this);
43 cache.AddObserver(this);
44 } 42 }
45 } 43 }
46 44
47 BrowserNonClientFrameView::~BrowserNonClientFrameView() { 45 BrowserNonClientFrameView::~BrowserNonClientFrameView() {
48 // The profile manager may by null in tests. 46 // The profile manager may by null in tests.
49 if (g_browser_process->profile_manager()) { 47 if (g_browser_process->profile_manager()) {
50 ProfileInfoCache& cache = 48 g_browser_process->profile_manager()->
51 g_browser_process->profile_manager()->GetProfileInfoCache(); 49 GetProfileAttributesStorage().RemoveObserver(this);
52 cache.RemoveObserver(this);
53 } 50 }
54 } 51 }
55 52
56 void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() {} 53 void BrowserNonClientFrameView::OnBrowserViewInitViewsComplete() {}
57 54
58 void BrowserNonClientFrameView::UpdateToolbar() { 55 void BrowserNonClientFrameView::UpdateToolbar() {
59 } 56 }
60 57
61 views::View* BrowserNonClientFrameView::GetLocationIconView() const { 58 views::View* BrowserNonClientFrameView::GetLocationIconView() const {
62 return nullptr; 59 return nullptr;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // pinned the badge-less Chrome shortcut which will cause windows to ignore 249 // pinned the badge-less Chrome shortcut which will cause windows to ignore
253 // the relaunch details. 250 // the relaunch details.
254 // TODO(calamity): ideally this should not be necessary but due to issues 251 // TODO(calamity): ideally this should not be necessary but due to issues
255 // with the default shortcut being pinned, we add the runtime badge for 252 // with the default shortcut being pinned, we add the runtime badge for
256 // safety. See crbug.com/313800. 253 // safety. See crbug.com/313800.
257 bool show_decoration = AvatarMenu::ShouldShowAvatarMenu() && 254 bool show_decoration = AvatarMenu::ShouldShowAvatarMenu() &&
258 !browser_view_->browser()->profile()->IsGuestSession(); 255 !browser_view_->browser()->profile()->IsGuestSession();
259 // In tests, make sure that the browser process and profile manager are 256 // In tests, make sure that the browser process and profile manager are
260 // valid before using. 257 // valid before using.
261 if (g_browser_process && g_browser_process->profile_manager()) { 258 if (g_browser_process && g_browser_process->profile_manager()) {
262 const ProfileInfoCache& cache = 259 const ProfileAttributesStorage& storage =
263 g_browser_process->profile_manager()->GetProfileInfoCache(); 260 g_browser_process->profile_manager()->GetProfileAttributesStorage();
264 show_decoration = show_decoration && cache.GetNumberOfProfiles() > 1; 261 show_decoration = show_decoration && storage.GetNumberOfProfiles() > 1;
265 } 262 }
266 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(), 263 chrome::DrawTaskbarDecoration(frame_->GetNativeWindow(),
267 show_decoration 264 show_decoration
268 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar) 265 ? (taskbar_badge_avatar.IsEmpty() ? &avatar : &taskbar_badge_avatar)
269 : nullptr); 266 : nullptr);
270 } 267 }
271 } 268 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698