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

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

Issue 2023523002: Fix display of "new" avatar menu in guest mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | 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 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" 7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/profiles/profile_manager.h" 8 #include "chrome/browser/profiles/profile_manager.h"
9 #include "chrome/browser/ui/view_ids.h" 9 #include "chrome/browser/ui/view_ids.h"
10 #include "chrome/browser/ui/views/frame/browser_frame.h" 10 #include "chrome/browser/ui/views/frame/browser_frame.h"
11 #include "chrome/browser/ui/views/frame/browser_view.h" 11 #include "chrome/browser/ui/views/frame/browser_view.h"
12 #include "chrome/browser/ui/views/profiles/new_avatar_button.h" 12 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
13 13
14 AvatarButtonManager::AvatarButtonManager(BrowserNonClientFrameView* frame_view) 14 AvatarButtonManager::AvatarButtonManager(BrowserNonClientFrameView* frame_view)
15 : frame_view_(frame_view), view_(nullptr) {} 15 : frame_view_(frame_view), view_(nullptr) {}
16 16
17 void AvatarButtonManager::Update(AvatarButtonStyle style) { 17 void AvatarButtonManager::Update(AvatarButtonStyle style) {
18 BrowserView* browser_view = frame_view_->browser_view(); 18 BrowserView* browser_view = frame_view_->browser_view();
19 BrowserFrame* frame = frame_view_->frame(); 19 BrowserFrame* frame = frame_view_->frame();
20 Profile* profile = browser_view->browser()->profile(); 20 Profile* profile = browser_view->browser()->profile();
21 21
22 // This should never be called in incognito mode. 22 // This should never be called in incognito mode.
23 DCHECK(browser_view->IsRegularOrGuestSession()); 23 DCHECK(browser_view->IsRegularOrGuestSession());
24 ProfileAttributesEntry* unused; 24 ProfileAttributesEntry* unused;
25 if (browser_view->IsBrowserTypeNormal() && 25 if ((browser_view->IsBrowserTypeNormal() &&
26 // Tests may not have a profile manager. 26 // Tests may not have a profile manager.
27 g_browser_process->profile_manager() && 27 g_browser_process->profile_manager() &&
28 g_browser_process->profile_manager() 28 g_browser_process->profile_manager()
29 ->GetProfileAttributesStorage() 29 ->GetProfileAttributesStorage()
30 .GetProfileAttributesWithPath(profile->GetPath(), &unused)) { 30 .GetProfileAttributesWithPath(profile->GetPath(), &unused)) ||
31 // Desktop guest shows the avatar button.
32 browser_view->IsOffTheRecord()) {
Evan Stade 2016/05/27 20:01:26 I failed to correctly copy (move) the logic from B
31 if (!view_) { 33 if (!view_) {
32 view_ = new NewAvatarButton(this, style, profile); 34 view_ = new NewAvatarButton(this, style, profile);
33 view_->set_id(VIEW_ID_AVATAR_BUTTON); 35 view_->set_id(VIEW_ID_AVATAR_BUTTON);
34 frame_view_->AddChildView(view_); 36 frame_view_->AddChildView(view_);
35 frame->GetRootView()->Layout(); 37 frame->GetRootView()->Layout();
36 } 38 }
37 } else if (view_) { 39 } else if (view_) {
38 delete view_; 40 delete view_;
39 view_ = nullptr; 41 view_ = nullptr;
40 frame->GetRootView()->Layout(); 42 frame->GetRootView()->Layout();
(...skipping 17 matching lines...) Expand all
58 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; 60 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT;
59 if ((event.IsMouseEvent() && 61 if ((event.IsMouseEvent() &&
60 static_cast<const ui::MouseEvent&>(event).IsRightMouseButton()) || 62 static_cast<const ui::MouseEvent&>(event).IsRightMouseButton()) ||
61 (event.type() == ui::ET_GESTURE_LONG_PRESS)) { 63 (event.type() == ui::ET_GESTURE_LONG_PRESS)) {
62 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH; 64 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH;
63 } 65 }
64 frame_view_->browser_view()->ShowAvatarBubbleFromAvatarButton( 66 frame_view_->browser_view()->ShowAvatarBubbleFromAvatarButton(
65 mode, signin::ManageAccountsParams(), 67 mode, signin::ManageAccountsParams(),
66 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); 68 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN);
67 } 69 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698