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

Unified Diff: chrome/browser/ui/views/frame/avatar_button_manager.cc

Issue 2832823002: Update avatar button to MD (Closed)
Patch Set: Rebased on CL 2833363002 Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/views/frame/avatar_button_manager.cc
diff --git a/chrome/browser/ui/views/frame/avatar_button_manager.cc b/chrome/browser/ui/views/frame/avatar_button_manager.cc
index 8101bf8b0e16bf11027d8b71cb84f1e4d0e38a71..626bc5412738517c8ed74c96c29ec0931abc7fe5 100644
--- a/chrome/browser/ui/views/frame/avatar_button_manager.cc
+++ b/chrome/browser/ui/views/frame/avatar_button_manager.cc
@@ -4,15 +4,18 @@
#include "chrome/browser/ui/views/frame/avatar_button_manager.h"
+#include "base/win/windows_version.h"
Peter Kasting 2017/04/26 02:09:53 Guard this with an #if OS_WIN block.
emx 2017/04/27 16:30:58 Done.
#include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/themes/theme_service.h"
+#include "chrome/browser/themes/theme_service_factory.h"
#include "chrome/browser/ui/view_ids.h"
#include "chrome/browser/ui/views/frame/browser_frame.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
-#include "chrome/browser/ui/views/profiles/new_avatar_button.h"
+#include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
AvatarButtonManager::AvatarButtonManager(BrowserNonClientFrameView* frame_view)
- : frame_view_(frame_view), view_(nullptr) {}
+ : frame_view_(frame_view), button_(nullptr) {}
void AvatarButtonManager::Update(AvatarButtonStyle style) {
BrowserView* browser_view = frame_view_->browser_view();
@@ -30,15 +33,26 @@ void AvatarButtonManager::Update(AvatarButtonStyle style) {
.GetProfileAttributesWithPath(profile->GetPath(), &unused)) ||
// Desktop guest shows the avatar button.
browser_view->IsIncognito()) {
- if (!view_) {
- view_ = new NewAvatarButton(this, style, profile);
- view_->set_id(VIEW_ID_AVATAR_BUTTON);
- frame_view_->AddChildView(view_);
+ if (!button_) {
+#if defined(OS_WIN)
+ if ((base::win::GetVersion() >= base::win::VERSION_WIN10) &&
+ ThemeServiceFactory::GetForProfile(profile)->UsingSystemTheme()) {
Peter Kasting 2017/04/26 02:09:53 Nit: TODO about expanding this beyond Win 10 and s
emx 2017/04/27 16:30:58 Done.
+ DCHECK_EQ(AvatarButtonStyle::NATIVE, style);
+ button_ = new MaterialDesignAvatarButton(this, profile, browser_view);
+ } else {
+ button_ = new NewAvatarButton(this, style, profile);
+ }
+#else
+ button_ = new NewAvatarButton(this, style, profile);
+#endif // defined(OS_WIN)
+
+ button_->set_id(VIEW_ID_AVATAR_BUTTON);
+ frame_view_->AddChildView(button_);
frame->GetRootView()->Layout();
}
- } else if (view_) {
- delete view_;
- view_ = nullptr;
+ } else if (button_) {
+ delete button_;
+ button_ = nullptr;
frame->GetRootView()->Layout();
}
}
@@ -46,24 +60,25 @@ void AvatarButtonManager::Update(AvatarButtonStyle style) {
void AvatarButtonManager::ButtonPreferredSizeChanged() {
// Perform a re-layout if the avatar button has changed, since that can affect
// the size of the tabs.
- if (!view_ || !frame_view_->browser_view()->initialized())
+ if (!button_ || !frame_view_->browser_view()->initialized())
return; // Ignore the update during view creation.
frame_view_->InvalidateLayout();
frame_view_->frame()->GetRootView()->Layout();
}
-void AvatarButtonManager::ButtonPressed(views::Button* sender,
- const ui::Event& event) {
- DCHECK_EQ(view_, sender);
+void AvatarButtonManager::OnMenuButtonClicked(views::MenuButton* source,
+ const gfx::Point& point,
+ const ui::Event* event) {
+ DCHECK_EQ(button_, source);
BrowserWindow::AvatarBubbleMode mode =
BrowserWindow::AVATAR_BUBBLE_MODE_DEFAULT;
- if ((event.IsMouseEvent() &&
- static_cast<const ui::MouseEvent&>(event).IsRightMouseButton()) ||
- (event.type() == ui::ET_GESTURE_LONG_PRESS)) {
+
+ if (event && event->type() == ui::ET_GESTURE_LONG_PRESS)
Peter Kasting 2017/04/26 02:09:53 This looks like we're showing the dropdown on righ
emx 2017/04/27 16:30:58 We're not - OnMenuButtonClicked is simply not call
return;
- }
+
frame_view_->browser_view()->ShowAvatarBubbleFromAvatarButton(
mode, signin::ManageAccountsParams(),
signin_metrics::AccessPoint::ACCESS_POINT_AVATAR_BUBBLE_SIGN_IN, false);
+ ProfileChooserView::MakeCallingButtonPressedIfShowing(event);
}

Powered by Google App Engine
This is Rietveld 408576698