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

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

Issue 1529703003: [EXPERIMENT] [MacViews] Enable and handle the profile switcher. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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
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"
(...skipping 16 matching lines...) Expand all
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. 31 // Desktop guest shows the avatar button.
32 browser_view->IsOffTheRecord()) { 32 browser_view->IsOffTheRecord()) {
33 if (!view_) { 33 if (!view_) {
34 view_ = new NewAvatarButton(this, style, profile); 34 view_ = new NewAvatarButton(this, style, profile);
35 view_->set_id(VIEW_ID_AVATAR_BUTTON); 35 view_->set_id(VIEW_ID_AVATAR_BUTTON);
36 frame_view_->AddChildView(view_); 36 frame_view_->AddChildView(view_);
37 frame->GetRootView()->Layout(); 37 // frame->GetRootView()->Layout();
38 } 38 }
39 } else if (view_) { 39 } else if (view_) {
40 delete view_; 40 delete view_;
41 view_ = nullptr; 41 view_ = nullptr;
42 frame->GetRootView()->Layout(); 42 frame->GetRootView()->Layout();
43 } 43 }
44 } 44 }
45 45
46 bool AvatarButtonManager::Intersects(const gfx::Rect& rect) const {
47 return view_ && view_->GetMirroredBounds().Intersects(rect);
48 }
49
50 bool AvatarButtonManager::HitTest(const gfx::Point& point) const {
51 if (!view_)
52 return false;
53
54 gfx::Point point_in_button(point);
55 views::View::ConvertPointToTarget(frame_view_, view_, &point_in_button);
56 return view_->HitTestPoint(point_in_button);
57 }
58
46 void AvatarButtonManager::ButtonPreferredSizeChanged() { 59 void AvatarButtonManager::ButtonPreferredSizeChanged() {
47 // Perform a re-layout if the avatar button has changed, since that can affect 60 // Perform a re-layout if the avatar button has changed, since that can affect
48 // the size of the tabs. 61 // the size of the tabs.
49 if (!view_ || !frame_view_->browser_view()->initialized()) 62 if (!view_ || !frame_view_->browser_view()->initialized())
50 return; // Ignore the update during view creation. 63 return; // Ignore the update during view creation.
51 64
52 frame_view_->InvalidateLayout(); 65 frame_view_->InvalidateLayout();
53 frame_view_->frame()->GetRootView()->Layout(); 66 frame_view_->frame()->GetRootView()->Layout();
54 } 67 }
55 68
56 void AvatarButtonManager::ButtonPressed(views::Button* sender, 69 void AvatarButtonManager::ButtonPressed(views::Button* sender,
57 const ui::Event& event) { 70 const ui::Event& event) {
58 DCHECK_EQ(view_, sender); 71 DCHECK_EQ(view_, sender);
59 BrowserWindow::AvatarBubbleMode mode = 72 BrowserWindow::AvatarBubbleMode mode =
60 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT; 73 BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT;
61 if ((event.IsMouseEvent() && 74 if ((event.IsMouseEvent() &&
62 static_cast<const ui::MouseEvent&>(event).IsRightMouseButton()) || 75 static_cast<const ui::MouseEvent&>(event).IsRightMouseButton()) ||
63 (event.type() == ui::ET_GESTURE_LONG_PRESS)) { 76 (event.type() == ui::ET_GESTURE_LONG_PRESS)) {
64 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH; 77 mode = BrowserWindow::AVATAR_BUBBLE_MODE_FAST_USER_SWITCH;
65 } 78 }
66 frame_view_->browser_view()->ShowAvatarBubbleFromAvatarButton( 79 frame_view_->browser_view()->ShowAvatarBubbleFromAvatarButton(
67 mode, signin::ManageAccountsParams(), 80 mode, signin::ManageAccountsParams(),
68 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN); 81 signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN);
69 } 82 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698