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

Side by Side Diff: chrome/browser/ui/views/profiles/new_avatar_button.h

Issue 2151513002: Revamped signin/sync error surfacing on desktop user menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed rogerta's last comment Created 4 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "chrome/browser/profiles/profile_attributes_storage.h" 9 #include "chrome/browser/profiles/profile_attributes_storage.h"
10 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" 10 #include "chrome/browser/ui/views/profiles/avatar_button_style.h"
11 #include "components/signin/core/browser/signin_error_controller.h" 11 #include "components/signin/core/browser/signin_error_controller.h"
12 #include "components/sync_driver/sync_error_controller.h"
12 #include "ui/views/controls/button/label_button.h" 13 #include "ui/views/controls/button/label_button.h"
13 14
14 class AvatarButtonDelegate; 15 class AvatarButtonDelegate;
15 class Profile; 16 class Profile;
16 17
17 // Avatar button that displays the active profile's name in the caption area. 18 // Avatar button that displays the active profile's name in the caption area.
18 class NewAvatarButton : public views::LabelButton, 19 class NewAvatarButton : public views::LabelButton,
19 public ProfileAttributesStorage::Observer, 20 public ProfileAttributesStorage::Observer {
20 public SigninErrorController::Observer {
21 public: 21 public:
22 class SigninErrorObserver : public SigninErrorController::Observer {
23 public:
24 SigninErrorObserver(NewAvatarButton* parent_button, Profile* profile);
25 ~SigninErrorObserver() override;
26
27 private:
28 // SigninErrorController::Observer:
29 void OnErrorChanged() override;
30
31 NewAvatarButton* parent_button_;
32 Profile* profile_;
33
34 DISALLOW_COPY_AND_ASSIGN(SigninErrorObserver);
35 };
36
37 class SyncErrorObserver : public SyncErrorController::Observer {
38 public:
39 SyncErrorObserver(NewAvatarButton* parent_button, Profile* profile);
40 ~SyncErrorObserver() override;
41
42 private:
43 // SyncErrorController::Observer:
44 void OnErrorChanged() override;
45
46 NewAvatarButton* parent_button_;
47 Profile* profile_;
48
49 DISALLOW_COPY_AND_ASSIGN(SyncErrorObserver);
50 };
51
22 NewAvatarButton(AvatarButtonDelegate* delegate, 52 NewAvatarButton(AvatarButtonDelegate* delegate,
23 AvatarButtonStyle button_style, 53 AvatarButtonStyle button_style,
24 Profile* profile); 54 Profile* profile);
25 ~NewAvatarButton() override; 55 ~NewAvatarButton() override;
26 56
27 // Views::LabelButton 57 // Views::LabelButton
28 bool OnMousePressed(const ui::MouseEvent& event) override; 58 bool OnMousePressed(const ui::MouseEvent& event) override;
29 void OnMouseReleased(const ui::MouseEvent& event) override; 59 void OnMouseReleased(const ui::MouseEvent& event) override;
30 60
31 // Views 61 // Views
32 void OnGestureEvent(ui::GestureEvent* event) override; 62 void OnGestureEvent(ui::GestureEvent* event) override;
33 63
64 void OnErrorChanged();
65
34 private: 66 private:
35 friend class ProfileChooserViewExtensionsTest; 67 friend class ProfileChooserViewExtensionsTest;
36 68
37 // ProfileAttributesStorage::Observer: 69 // ProfileAttributesStorage::Observer:
38 void OnProfileAdded(const base::FilePath& profile_path) override; 70 void OnProfileAdded(const base::FilePath& profile_path) override;
39 void OnProfileWasRemoved(const base::FilePath& profile_path, 71 void OnProfileWasRemoved(const base::FilePath& profile_path,
40 const base::string16& profile_name) override; 72 const base::string16& profile_name) override;
41 void OnProfileNameChanged(const base::FilePath& profile_path, 73 void OnProfileNameChanged(const base::FilePath& profile_path,
42 const base::string16& old_profile_name) override; 74 const base::string16& old_profile_name) override;
43 void OnProfileSupervisedUserIdChanged( 75 void OnProfileSupervisedUserIdChanged(
44 const base::FilePath& profile_path) override; 76 const base::FilePath& profile_path) override;
45 77
46 // SigninErrorController::Observer:
47 void OnErrorChanged() override;
48
49 // Called when the profile info cache has changed, which means we might 78 // Called when the profile info cache has changed, which means we might
50 // have to update the icon/text of the button. 79 // have to update the icon/text of the button.
51 void Update(); 80 void Update();
52 81
82 SigninErrorObserver signin_error_observer_;
83 SyncErrorObserver sync_error_observer_;
84
53 AvatarButtonDelegate* delegate_; 85 AvatarButtonDelegate* delegate_;
54 Profile* profile_; 86 Profile* profile_;
55 87
56 // Whether the signed in profile has an authentication error. Used to display 88 // Whether the signed in profile has any authentication error or sync error.
57 // an error icon next to the button text. 89 // Used to display an error icon next to the button text.
58 bool has_auth_error_; 90 bool has_error_;
59 91
60 // The icon displayed instead of the profile name in the local profile case. 92 // The icon displayed instead of the profile name in the local profile case.
61 // Different assets are used depending on the OS version. 93 // Different assets are used depending on the OS version.
62 gfx::ImageSkia generic_avatar_; 94 gfx::ImageSkia generic_avatar_;
63 95
64 // This is used to check if the bubble was showing during the mouse pressed 96 // This is used to check if the bubble was showing during the mouse pressed
65 // event. If this is true then the mouse released event is ignored to prevent 97 // event. If this is true then the mouse released event is ignored to prevent
66 // the bubble from reshowing. 98 // the bubble from reshowing.
67 bool suppress_mouse_released_action_; 99 bool suppress_mouse_released_action_;
68 100
69 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); 101 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton);
70 }; 102 };
71 103
72 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ 104 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
OLDNEW
« no previous file with comments | « chrome/app/google_chrome_strings.grd ('k') | chrome/browser/ui/views/profiles/new_avatar_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698