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

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

Issue 1972033002: Simplify some old avatar menu button code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 years, 7 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/avatar_button_manager.h" 5 #include "chrome/browser/ui/views/frame/avatar_button_manager.h"
6 6
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/profile_manager.h"
7 #include "chrome/browser/ui/view_ids.h" 9 #include "chrome/browser/ui/view_ids.h"
8 #include "chrome/browser/ui/views/frame/browser_frame.h" 10 #include "chrome/browser/ui/views/frame/browser_frame.h"
9 #include "chrome/browser/ui/views/frame/browser_view.h" 11 #include "chrome/browser/ui/views/frame/browser_view.h"
10 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 12 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
11 13
12 AvatarButtonManager::AvatarButtonManager(BrowserNonClientFrameView* frame_view) 14 AvatarButtonManager::AvatarButtonManager(BrowserNonClientFrameView* frame_view)
13 : frame_view_(frame_view), view_(nullptr) {} 15 : frame_view_(frame_view), view_(nullptr) {}
14 16
15 void AvatarButtonManager::Update(AvatarButtonStyle style) { 17 void AvatarButtonManager::Update(AvatarButtonStyle style) {
16 BrowserView* browser_view = frame_view_->browser_view(); 18 BrowserView* browser_view = frame_view_->browser_view();
17 BrowserFrame* frame = frame_view_->frame(); 19 BrowserFrame* frame = frame_view_->frame();
18 Profile* profile = browser_view->browser()->profile(); 20 Profile* profile = browser_view->browser()->profile();
19 21
20 // This should never be called in incognito mode. 22 // This should never be called in incognito mode.
21 DCHECK(browser_view->IsRegularOrGuestSession()); 23 DCHECK(browser_view->IsRegularOrGuestSession());
24 ProfileAttributesEntry* entry;
25 bool show_avatar =
Peter Kasting 2016/05/17 03:51:42 Nit: I'd just inline this into the next statement.
Evan Stade 2016/05/17 18:13:08 Done.
26 browser_view->IsBrowserTypeNormal() &&
27 // Tests may not have a profile manager.
28 g_browser_process->profile_manager() &&
29 g_browser_process->profile_manager()
30 ->GetProfileAttributesStorage()
31 .GetProfileAttributesWithPath(profile->GetPath(), &entry);
22 32
23 if (browser_view->ShouldShowAvatar()) { 33 if (show_avatar) {
24 if (!view_) { 34 if (!view_) {
25 view_ = new NewAvatarButton(this, style, profile); 35 view_ = new NewAvatarButton(this, style, profile);
26 view_->set_id(VIEW_ID_NEW_AVATAR_BUTTON); 36 view_->set_id(VIEW_ID_NEW_AVATAR_BUTTON);
27 frame_view_->AddChildView(view_); 37 frame_view_->AddChildView(view_);
28 frame->GetRootView()->Layout(); 38 frame->GetRootView()->Layout();
29 } 39 }
30 } else if (view_) { 40 } else if (view_) {
31 delete view_; 41 delete view_;
32 view_ = nullptr; 42 view_ = nullptr;
33 frame->GetRootView()->Layout(); 43 frame->GetRootView()->Layout();
(...skipping 17 matching lines...) Expand all
51 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; 61 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT;
52 if ((event.IsMouseEvent() && 62 if ((event.IsMouseEvent() &&
53 static_cast<const ui::MouseEvent&>(event).IsRightMouseButton()) || 63 static_cast<const ui::MouseEvent&>(event).IsRightMouseButton()) ||
54 (event.type() == ui::ET_GESTURE_LONG_PRESS)) { 64 (event.type() == ui::ET_GESTURE_LONG_PRESS)) {
55 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH; 65 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH;
56 } 66 }
57 frame_view_->browser_view()->ShowAvatarBubbleFromAvatarButton( 67 frame_view_->browser_view()->ShowAvatarBubbleFromAvatarButton(
58 mode, signin::ManageAccountsParams(), 68 mode, signin::ManageAccountsParams(),
59 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); 69 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN);
60 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698