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

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

Issue 24647003: Redesign of the avatar menu button. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: unbork test Created 7 years, 2 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 "chrome/browser/browser_process.h" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/avatar_menu.h" 8 #include "chrome/browser/profiles/avatar_menu.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 10 #include "chrome/browser/profiles/profile_info_cache.h"
11 #include "chrome/browser/profiles/profile_manager.h" 11 #include "chrome/browser/profiles/profile_manager.h"
12 #include "chrome/browser/profiles/profiles_state.h"
12 #include "chrome/browser/ui/view_ids.h" 13 #include "chrome/browser/ui/view_ids.h"
13 #include "chrome/browser/ui/views/avatar_label.h" 14 #include "chrome/browser/ui/views/avatar_label.h"
14 #include "chrome/browser/ui/views/avatar_menu_button.h" 15 #include "chrome/browser/ui/views/avatar_menu_button.h"
15 #include "chrome/browser/ui/views/frame/browser_view.h" 16 #include "chrome/browser/ui/views/frame/browser_view.h"
16 #include "chrome/browser/ui/views/frame/taskbar_decorator.h" 17 #include "chrome/browser/ui/views/frame/taskbar_decorator.h"
18 #include "chrome/browser/ui/views/new_avatar_button.h"
17 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
18 #include "grit/theme_resources.h" 20 #include "grit/theme_resources.h"
19 #include "third_party/skia/include/core/SkColor.h" 21 #include "third_party/skia/include/core/SkColor.h"
20 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
21 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
22 #include "ui/base/theme_provider.h" 24 #include "ui/base/theme_provider.h"
23 #include "ui/gfx/image/image.h" 25 #include "ui/gfx/image/image.h"
24 #include "ui/views/background.h" 26 #include "ui/views/background.h"
25 27
26 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame, 28 BrowserNonClientFrameView::BrowserNonClientFrameView(BrowserFrame* frame,
27 BrowserView* browser_view) 29 BrowserView* browser_view)
28 : frame_(frame), 30 : frame_(frame),
29 browser_view_(browser_view), 31 browser_view_(browser_view),
30 avatar_button_(NULL), 32 avatar_button_(NULL),
31 avatar_label_(NULL) { 33 avatar_label_(NULL),
34 new_avatar_button_(NULL) {
32 } 35 }
33 36
34 BrowserNonClientFrameView::~BrowserNonClientFrameView() { 37 BrowserNonClientFrameView::~BrowserNonClientFrameView() {
35 } 38 }
36 39
37 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from, 40 void BrowserNonClientFrameView::VisibilityChanged(views::View* starting_from,
38 bool is_visible) { 41 bool is_visible) {
39 if (!is_visible) 42 if (!is_visible)
40 return; 43 return;
41 // The first time UpdateAvatarInfo() is called the window is not visible so 44 // The first time UpdateAvatarInfo() is called the window is not visible so
42 // DrawTaskBarDecoration() has no effect. Therefore we need to call it again 45 // DrawTaskBarDecoration() has no effect. Therefore we need to call it again
43 // once the window is visible. 46 // once the window is visible.
44 UpdateAvatarInfo(); 47 if (!browser_view_->IsRegularOrGuestSession() ||
48 !profiles::IsNewProfileManagementEnabled())
49 UpdateAvatarInfo();
45 } 50 }
46 51
47 void BrowserNonClientFrameView::OnThemeChanged() { 52 void BrowserNonClientFrameView::OnThemeChanged() {
48 if (avatar_label_) 53 if (avatar_label_)
49 avatar_label_->UpdateLabelStyle(); 54 avatar_label_->UpdateLabelStyle();
50 } 55 }
51 56
52 void BrowserNonClientFrameView::UpdateAvatarInfo() { 57 void BrowserNonClientFrameView::UpdateAvatarInfo() {
53 if (browser_view_->ShouldShowAvatar()) { 58 if (browser_view_->ShouldShowAvatar()) {
54 if (!avatar_button_) { 59 if (!avatar_button_) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 if (!text.empty()) 109 if (!text.empty())
105 avatar_button_->SetText(text); 110 avatar_button_->SetText(text);
106 } 111 }
107 112
108 // For popups and panels which don't have the avatar button, we still 113 // For popups and panels which don't have the avatar button, we still
109 // need to draw the taskbar decoration. 114 // need to draw the taskbar decoration.
110 chrome::DrawTaskbarDecoration( 115 chrome::DrawTaskbarDecoration(
111 frame_->GetNativeWindow(), 116 frame_->GetNativeWindow(),
112 AvatarMenu::ShouldShowAvatarMenu() ? &avatar : NULL); 117 AvatarMenu::ShouldShowAvatarMenu() ? &avatar : NULL);
113 } 118 }
119
120 void BrowserNonClientFrameView::UpdateNewStyleAvatarInfo() {
121 DCHECK(profiles::IsNewProfileManagementEnabled());
122 // This should never be called in incognito mode.
123 DCHECK(browser_view_->IsRegularOrGuestSession());
124
125 if (browser_view_->ShouldShowAvatar()) {
126 if (!new_avatar_button_) {
127 // The name of the profile that should be displayed in the button.
128 string16 profile_name;
129 if (browser_view_->IsGuestSession()) {
sky 2013/10/03 23:23:11 Can this making of profile to name be moved else w
noms (inactive) 2013/10/07 21:18:15 Done.
130 profile_name = l10n_util::GetStringUTF16(IDS_GUEST_PROFILE_NAME);
131 } else {
132 ProfileInfoCache& cache =
133 g_browser_process->profile_manager()->GetProfileInfoCache();
134 Profile* profile = browser_view_->browser()->profile();
135 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
136 if (index != std::string::npos)
137 profile_name = cache.GetNameOfProfileAtIndex(index);
138 }
139 new_avatar_button_ = new NewAvatarButton(browser_view_, profile_name);
140 new_avatar_button_->set_id(VIEW_ID_NEW_AVATAR_BUTTON);
141 AddChildView(new_avatar_button_);
142 frame_->GetRootView()->Layout();
143 }
144 } else if (new_avatar_button_) {
145 RemoveChildView(new_avatar_button_);
sky 2013/10/03 23:23:11 Not needed, you can delete.
noms (inactive) 2013/10/07 21:18:15 Done.
146 delete new_avatar_button_;
147 new_avatar_button_ = NULL;
148 frame_->GetRootView()->Layout();
149 }
150 }
151
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698