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

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

Issue 2179283002: Refactored signin/sync error controllers for the avatar button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prototype Created 4 years, 4 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/sync/avatar_sync_error.h"
10 #include "chrome/browser/ui/views/profiles/avatar_button_style.h" 11 #include "chrome/browser/ui/views/profiles/avatar_button_style.h"
11 #include "components/signin/core/browser/signin_error_controller.h" 12 #include "components/signin/core/browser/signin_error_controller.h"
12 #include "components/sync_driver/sync_error_controller.h" 13 #include "components/sync_driver/sync_error_controller.h"
13 #include "ui/views/controls/button/label_button.h" 14 #include "ui/views/controls/button/label_button.h"
14 15
15 class AvatarButtonDelegate; 16 class AvatarButtonDelegate;
16 class Profile; 17 class Profile;
17 18
18 // Avatar button that displays the active profile's name in the caption area. 19 // Avatar button that displays the active profile's name in the caption area.
19 class NewAvatarButton : public views::LabelButton, 20 class NewAvatarButton : public views::LabelButton,
20 public ProfileAttributesStorage::Observer { 21 public ProfileAttributesStorage::Observer {
21 public: 22 public:
23 class AvatarSyncErrorObserver : public AvatarSyncError {
24 public:
25 AvatarSyncErrorObserver(Profile* profile, NewAvatarButton* parent_button);
26 void OnErrorChanged() override;
27
28 private:
29 NewAvatarButton* parent_button_;
30 };
31
22 class SigninErrorObserver : public SigninErrorController::Observer { 32 class SigninErrorObserver : public SigninErrorController::Observer {
23 public: 33 public:
24 SigninErrorObserver(NewAvatarButton* parent_button, Profile* profile); 34 SigninErrorObserver(NewAvatarButton* parent_button, Profile* profile);
25 ~SigninErrorObserver() override; 35 ~SigninErrorObserver() override;
26 36
27 private: 37 private:
28 // SigninErrorController::Observer: 38 // SigninErrorController::Observer:
29 void OnErrorChanged() override; 39 void OnErrorChanged() override;
30 40
31 NewAvatarButton* parent_button_; 41 NewAvatarButton* parent_button_;
32 Profile* profile_; 42 Profile* profile_;
33 43
34 DISALLOW_COPY_AND_ASSIGN(SigninErrorObserver); 44 DISALLOW_COPY_AND_ASSIGN(SigninErrorObserver);
35 }; 45 };
36 46
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
52 NewAvatarButton(AvatarButtonDelegate* delegate, 47 NewAvatarButton(AvatarButtonDelegate* delegate,
53 AvatarButtonStyle button_style, 48 AvatarButtonStyle button_style,
54 Profile* profile); 49 Profile* profile);
55 ~NewAvatarButton() override; 50 ~NewAvatarButton() override;
56 51
57 // Views::LabelButton 52 // Views::LabelButton
58 bool OnMousePressed(const ui::MouseEvent& event) override; 53 bool OnMousePressed(const ui::MouseEvent& event) override;
59 void OnMouseReleased(const ui::MouseEvent& event) override; 54 void OnMouseReleased(const ui::MouseEvent& event) override;
60 55
61 // Views 56 // Views
(...skipping 11 matching lines...) Expand all
73 void OnProfileNameChanged(const base::FilePath& profile_path, 68 void OnProfileNameChanged(const base::FilePath& profile_path,
74 const base::string16& old_profile_name) override; 69 const base::string16& old_profile_name) override;
75 void OnProfileSupervisedUserIdChanged( 70 void OnProfileSupervisedUserIdChanged(
76 const base::FilePath& profile_path) override; 71 const base::FilePath& profile_path) override;
77 72
78 // Called when the profile info cache has changed, which means we might 73 // Called when the profile info cache has changed, which means we might
79 // have to update the icon/text of the button. 74 // have to update the icon/text of the button.
80 void Update(); 75 void Update();
81 76
82 SigninErrorObserver signin_error_observer_; 77 SigninErrorObserver signin_error_observer_;
83 SyncErrorObserver sync_error_observer_; 78 AvatarSyncErrorObserver avatar_sync_error_;
84 79
85 AvatarButtonDelegate* delegate_; 80 AvatarButtonDelegate* delegate_;
86 Profile* profile_; 81 Profile* profile_;
87 82
88 // Whether the signed in profile has any authentication error or sync error. 83 // Whether the signed in profile has any authentication error or sync error.
89 // Used to display an error icon next to the button text. 84 // Used to display an error icon next to the button text.
90 bool has_error_; 85 bool has_signin_error_;
86 bool has_sync_error_;
Roger Tawa OOO till Jul 10th 2016/07/26 14:34:24 I don't think you need this member anymore. Anywh
Jane 2016/07/26 17:31:17 Done.
91 87
92 // The icon displayed instead of the profile name in the local profile case. 88 // The icon displayed instead of the profile name in the local profile case.
93 // Different assets are used depending on the OS version. 89 // Different assets are used depending on the OS version.
94 gfx::ImageSkia generic_avatar_; 90 gfx::ImageSkia generic_avatar_;
95 91
96 // This is used to check if the bubble was showing during the mouse pressed 92 // This is used to check if the bubble was showing during the mouse pressed
97 // event. If this is true then the mouse released event is ignored to prevent 93 // event. If this is true then the mouse released event is ignored to prevent
98 // the bubble from reshowing. 94 // the bubble from reshowing.
99 bool suppress_mouse_released_action_; 95 bool suppress_mouse_released_action_;
100 96
101 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); 97 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton);
102 }; 98 };
103 99
104 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ 100 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698