OLD | NEW |
---|---|
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 SigninErrorController::Observer, |
22 public SyncErrorController::Observer { | |
21 public: | 23 public: |
22 NewAvatarButton(AvatarButtonDelegate* delegate, | 24 NewAvatarButton(AvatarButtonDelegate* delegate, |
23 AvatarButtonStyle button_style, | 25 AvatarButtonStyle button_style, |
24 Profile* profile); | 26 Profile* profile); |
25 ~NewAvatarButton() override; | 27 ~NewAvatarButton() override; |
26 | 28 |
27 // Views::LabelButton | 29 // Views::LabelButton |
28 bool OnMousePressed(const ui::MouseEvent& event) override; | 30 bool OnMousePressed(const ui::MouseEvent& event) override; |
29 void OnMouseReleased(const ui::MouseEvent& event) override; | 31 void OnMouseReleased(const ui::MouseEvent& event) override; |
30 | 32 |
31 // Views | 33 // Views |
32 void OnGestureEvent(ui::GestureEvent* event) override; | 34 void OnGestureEvent(ui::GestureEvent* event) override; |
33 | 35 |
34 private: | 36 private: |
35 friend class ProfileChooserViewExtensionsTest; | 37 friend class ProfileChooserViewExtensionsTest; |
36 | 38 |
37 // ProfileAttributesStorage::Observer: | 39 // ProfileAttributesStorage::Observer: |
38 void OnProfileAdded(const base::FilePath& profile_path) override; | 40 void OnProfileAdded(const base::FilePath& profile_path) override; |
39 void OnProfileWasRemoved(const base::FilePath& profile_path, | 41 void OnProfileWasRemoved(const base::FilePath& profile_path, |
40 const base::string16& profile_name) override; | 42 const base::string16& profile_name) override; |
41 void OnProfileNameChanged(const base::FilePath& profile_path, | 43 void OnProfileNameChanged(const base::FilePath& profile_path, |
42 const base::string16& old_profile_name) override; | 44 const base::string16& old_profile_name) override; |
43 void OnProfileSupervisedUserIdChanged( | 45 void OnProfileSupervisedUserIdChanged( |
44 const base::FilePath& profile_path) override; | 46 const base::FilePath& profile_path) override; |
45 | 47 |
46 // SigninErrorController::Observer: | 48 // SigninErrorController::Observer and SyncErrorController::Observer |
msw
2016/07/13 22:31:37
This is bad practice... maybe rename one or both f
Jane
2016/07/14 00:18:57
Do you mean changing the function name "OnErrorCha
msw
2016/07/14 02:23:33
Yes, renaming the interfaces' OnErrorChanged was m
Jane
2016/07/14 15:34:37
I discussed with Roger about this, and he suggeste
| |
47 void OnErrorChanged() override; | 49 void OnErrorChanged() override; |
48 | 50 |
49 // Called when the profile info cache has changed, which means we might | 51 // Called when the profile info cache has changed, which means we might |
50 // have to update the icon/text of the button. | 52 // have to update the icon/text of the button. |
51 void Update(); | 53 void Update(); |
52 | 54 |
53 AvatarButtonDelegate* delegate_; | 55 AvatarButtonDelegate* delegate_; |
54 Profile* profile_; | 56 Profile* profile_; |
55 | 57 |
56 // Whether the signed in profile has an authentication error. Used to display | 58 // Whether the signed in profile has any authentication error or sync error. |
57 // an error icon next to the button text. | 59 // Used to display an error icon next to the button text. |
58 bool has_auth_error_; | 60 bool has_sync_error_; |
59 | 61 |
60 // The icon displayed instead of the profile name in the local profile case. | 62 // The icon displayed instead of the profile name in the local profile case. |
61 // Different assets are used depending on the OS version. | 63 // Different assets are used depending on the OS version. |
62 gfx::ImageSkia generic_avatar_; | 64 gfx::ImageSkia generic_avatar_; |
63 | 65 |
64 // This is used to check if the bubble was showing during the mouse pressed | 66 // 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 | 67 // event. If this is true then the mouse released event is ignored to prevent |
66 // the bubble from reshowing. | 68 // the bubble from reshowing. |
67 bool suppress_mouse_released_action_; | 69 bool suppress_mouse_released_action_; |
68 | 70 |
69 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); | 71 DISALLOW_COPY_AND_ASSIGN(NewAvatarButton); |
70 }; | 72 }; |
71 | 73 |
72 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ | 74 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_NEW_AVATAR_BUTTON_H_ |
OLD | NEW |