| 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 ~AvatarButtonErrorController(); |
| 21 |
| 22 bool HasAvatarError() { return has_signin_error_ || has_sync_error_; } |
| 23 |
| 24 private: |
| 25 friend class SigninErrorObserver; |
| 26 friend class SyncErrorObserver; |
| 27 |
| 28 // Observes signin errors and updates the error controller for the avatar |
| 29 // button accordingly. |
| 30 class SigninErrorObserver : public SigninErrorController::Observer { |
| 31 public: |
| 32 SigninErrorObserver( |
| 33 Profile* profile, |
| 34 AvatarButtonErrorController* avatar_button_error_controller); |
| 35 ~SigninErrorObserver() override; |
| 36 |
| 37 // SigninErrorController::Observer: |
| 38 void OnErrorChanged() override; |
| 39 |
| 40 bool HasSigninError(); |
| 41 |
| 42 private: |
| 43 Profile* profile_; |
| 44 AvatarButtonErrorController* avatar_button_error_controller_; |
| 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(SigninErrorObserver); |
| 47 }; |
| 48 |
| 49 // Observes sync errors and updates the error controller for the avatar |
| 50 // button accordingly. |
| 51 class SyncErrorObserver : public SyncErrorController::Observer { |
| 52 public: |
| 53 SyncErrorObserver( |
| 54 Profile* profile, |
| 55 AvatarButtonErrorController* avatar_button_error_controller); |
| 56 ~SyncErrorObserver() override; |
| 57 |
| 58 // SyncErrorController::Observer: |
| 59 void OnErrorChanged() override; |
| 60 |
| 61 bool HasSyncError(); |
| 62 |
| 63 private: |
| 64 SyncErrorController* GetSyncErrorControllerIfNeeded(); |
| 65 |
| 66 Profile* profile_; |
| 67 AvatarButtonErrorController* avatar_button_error_controller_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(SyncErrorObserver); |
| 70 }; |
| 71 |
| 72 void UpdateSigninError(bool has_signin_error); |
| 73 void UpdateSyncError(bool has_sync_error); |
| 74 |
| 75 AvatarButtonErrorControllerDelegate* delegate_; |
| 76 |
| 77 SigninErrorObserver avatar_signin_error_controller_; |
| 78 SyncErrorObserver avatar_sync_error_controller_; |
| 79 |
| 80 bool has_signin_error_; |
| 81 bool has_sync_error_; |
| 82 |
| 83 DISALLOW_COPY_AND_ASSIGN(AvatarButtonErrorController); |
| 84 }; |
| 85 |
| 86 #endif // CHROME_BROWSER_UI_AVATAR_BUTTON_ERROR_CONTROLLER_H_ |
| OLD | NEW |