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

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

Issue 7631027: Multi-Profiles: Add profile avatar if second profile is added (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/opaque_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 AddChildView(close_button_); 194 AddChildView(close_button_);
195 195
196 // Initializing the TabIconView is expensive, so only do it if we need to. 196 // Initializing the TabIconView is expensive, so only do it if we need to.
197 if (browser_view_->ShouldShowWindowIcon()) { 197 if (browser_view_->ShouldShowWindowIcon()) {
198 window_icon_ = new TabIconView(this); 198 window_icon_ = new TabIconView(this);
199 window_icon_->set_is_light(true); 199 window_icon_->set_is_light(true);
200 AddChildView(window_icon_); 200 AddChildView(window_icon_);
201 window_icon_->Update(); 201 window_icon_->Update();
202 } 202 }
203 203
204 if (browser_view_->ShouldShowAvatar()) { 204 UpdateAvatarInfo();
205 avatar_button_.reset(new AvatarMenuButton( 205 if (!browser_view_->IsOffTheRecord()) {
206 browser_view_->browser(), !browser_view_->IsOffTheRecord())); 206 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
207 AddChildView(avatar_button_.get()); 207 NotificationService::AllSources());
208 UpdateAvatarInfo();
209 if (!browser_view_->IsOffTheRecord()) {
210 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
211 NotificationService::AllSources());
212 }
213 } 208 }
214 } 209 }
215 210
216 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() { 211 OpaqueBrowserFrameView::~OpaqueBrowserFrameView() {
217 } 212 }
218 213
219 /////////////////////////////////////////////////////////////////////////////// 214 ///////////////////////////////////////////////////////////////////////////////
220 // OpaqueBrowserFrameView, protected: 215 // OpaqueBrowserFrameView, protected:
221 216
222 int OpaqueBrowserFrameView::GetReservedHeight() const { 217 int OpaqueBrowserFrameView::GetReservedHeight() const {
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 502
508 /////////////////////////////////////////////////////////////////////////////// 503 ///////////////////////////////////////////////////////////////////////////////
509 // OpaqueBrowserFrameView, protected: 504 // OpaqueBrowserFrameView, protected:
510 505
511 void OpaqueBrowserFrameView::Observe(int type, 506 void OpaqueBrowserFrameView::Observe(int type,
512 const NotificationSource& source, 507 const NotificationSource& source,
513 const NotificationDetails& details) { 508 const NotificationDetails& details) {
514 switch (type) { 509 switch (type) {
515 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED: 510 case chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED:
516 UpdateAvatarInfo(); 511 UpdateAvatarInfo();
517 LayoutAvatar();
518 break; 512 break;
519 default: 513 default:
520 NOTREACHED() << "Got a notification we didn't register for!"; 514 NOTREACHED() << "Got a notification we didn't register for!";
521 break; 515 break;
522 } 516 }
523 } 517 }
524 518
525 /////////////////////////////////////////////////////////////////////////////// 519 ///////////////////////////////////////////////////////////////////////////////
526 // OpaqueBrowserFrameView, private: 520 // OpaqueBrowserFrameView, private:
527 521
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 int height) const { 1140 int height) const {
1147 int top_height = NonClientTopBorderHeight(false, false); 1141 int top_height = NonClientTopBorderHeight(false, false);
1148 int border_thickness = NonClientBorderThickness(); 1142 int border_thickness = NonClientBorderThickness();
1149 return gfx::Rect(border_thickness, top_height, 1143 return gfx::Rect(border_thickness, top_height,
1150 std::max(0, width - (2 * border_thickness)), 1144 std::max(0, width - (2 * border_thickness)),
1151 std::max(0, height - GetReservedHeight() - 1145 std::max(0, height - GetReservedHeight() -
1152 top_height - border_thickness)); 1146 top_height - border_thickness));
1153 } 1147 }
1154 1148
1155 void OpaqueBrowserFrameView::UpdateAvatarInfo() { 1149 void OpaqueBrowserFrameView::UpdateAvatarInfo() {
1150 if (browser_view_->ShouldShowAvatar()) {
1151 if (!avatar_button_.get()) {
1152 avatar_button_.reset(new AvatarMenuButton(
1153 browser_view_->browser(), !browser_view_->IsOffTheRecord()));
1154 AddChildView(avatar_button_.get());
1155 frame_->GetRootView()->Layout();
1156 }
1157 } else if (avatar_button_.get()) {
1158 RemoveChildView(avatar_button_.release());
1159 frame_->GetRootView()->Layout();
1160 }
1161
1162 if (!avatar_button_.get())
1163 return;
1164
1156 if (browser_view_->IsOffTheRecord()) { 1165 if (browser_view_->IsOffTheRecord()) {
1157 avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon()); 1166 avatar_button_->SetIcon(browser_view_->GetOTRAvatarIcon());
1158 } else { 1167 } else {
1159 ProfileInfoCache& cache = 1168 ProfileInfoCache& cache =
1160 g_browser_process->profile_manager()->GetProfileInfoCache(); 1169 g_browser_process->profile_manager()->GetProfileInfoCache();
1161 Profile* profile = browser_view_->browser()->profile(); 1170 Profile* profile = browser_view_->browser()->profile();
1162 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath()); 1171 size_t index = cache.GetIndexOfProfileWithPath(profile->GetPath());
1163 if (index != std::string::npos) { 1172 if (index != std::string::npos) {
1164 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index)); 1173 avatar_button_->SetIcon(cache.GetAvatarIconOfProfileAtIndex(index));
1165 avatar_button_->SetText(UTF16ToWideHack( 1174 avatar_button_->SetText(UTF16ToWideHack(
1166 cache.GetNameOfProfileAtIndex(index))); 1175 cache.GetNameOfProfileAtIndex(index)));
1167 } 1176 }
1168 } 1177 }
1169 } 1178 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_info_cache.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698