Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_AVATAR_BUTTON_ERROR_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_AVATAR_BUTTON_ERROR_CONTROLLER_H_ | |
| 7 | |
| 8 #include "chrome/browser/ui/avatar_button_error_controller_delegate.h" | |
| 9 #include "components/signin/core/browser/signin_error_controller.h" | |
| 10 #include "components/sync_driver/sync_error_controller.h" | |
| 11 | |
| 12 class Profile; | |
| 13 | |
| 14 // Keeps track of the signin and sync errors that should be exposed to the user | |
| 15 // in the avatar button. | |
| 16 class AvatarButtonErrorController { | |
| 17 public: | |
| 18 AvatarButtonErrorController(AvatarButtonErrorControllerDelegate* delegate, | |
| 19 Profile* profile); | |
| 20 virtual ~AvatarButtonErrorController() {} | |
|
sky
2016/08/01 22:59:40
You shouldn't need this to be virtual anymore, and
Jane
2016/08/02 14:23:18
Done. Removed virtual, and moved the empty dtor to
| |
| 21 | |
| 22 bool HasAvatarError() { return has_signin_error_ || has_sync_error_; } | |
| 23 | |
| 24 // Explicitly requests an update to the signin/sync errors. | |
| 25 void GetAvatarErrorUpdate(); | |
| 26 | |
| 27 private: | |
| 28 friend class SigninErrorObserver; | |
| 29 friend class SyncErrorObserver; | |
| 30 | |
| 31 // Observes signin errors and updates the error controller for the avatar | |
| 32 // button accordingly. | |
| 33 class SigninErrorObserver : public SigninErrorController::Observer { | |
| 34 public: | |
| 35 SigninErrorObserver( | |
| 36 Profile* profile, | |
| 37 AvatarButtonErrorController* avatar_button_error_controller); | |
| 38 ~SigninErrorObserver() override; | |
| 39 | |
| 40 // SigninErrorController::Observer: | |
| 41 void OnErrorChanged() override; | |
| 42 | |
| 43 private: | |
| 44 Profile* profile_; | |
| 45 AvatarButtonErrorController* avatar_button_error_controller_; | |
| 46 | |
| 47 DISALLOW_COPY_AND_ASSIGN(SigninErrorObserver); | |
| 48 }; | |
| 49 | |
| 50 // Observes sync errors and updates the error controller for the avatar | |
| 51 // button accordingly. | |
| 52 class SyncErrorObserver : public SyncErrorController::Observer { | |
| 53 public: | |
| 54 SyncErrorObserver( | |
| 55 Profile* profile, | |
| 56 AvatarButtonErrorController* avatar_button_error_controller); | |
| 57 ~SyncErrorObserver() override; | |
| 58 | |
| 59 // SyncErrorController::Observer: | |
| 60 void OnErrorChanged() override; | |
| 61 | |
| 62 private: | |
| 63 SyncErrorController* GetSyncErrorControllerIfNeeded(); | |
| 64 | |
| 65 Profile* profile_; | |
| 66 AvatarButtonErrorController* avatar_button_error_controller_; | |
| 67 | |
| 68 DISALLOW_COPY_AND_ASSIGN(SyncErrorObserver); | |
| 69 }; | |
| 70 | |
| 71 void UpdateSigninError(bool has_signin_error); | |
| 72 void UpdateSyncError(bool has_sync_error); | |
| 73 | |
| 74 AvatarButtonErrorControllerDelegate* delegate_; | |
| 75 | |
| 76 SigninErrorObserver avatar_signin_error_controller_; | |
| 77 SyncErrorObserver avatar_sync_error_controller_; | |
| 78 | |
| 79 bool has_signin_error_; | |
| 80 bool has_sync_error_; | |
| 81 | |
| 82 DISALLOW_COPY_AND_ASSIGN(AvatarButtonErrorController); | |
| 83 }; | |
| 84 | |
| 85 #endif // CHROME_BROWSER_UI_AVATAR_BUTTON_ERROR_CONTROLLER_H_ | |
| OLD | NEW |