Home | History | Annotate | Download | only in signin
      1 // Copyright (c) 2013 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_SIGNIN_FAKE_AUTH_STATUS_PROVIDER_H_
      6 #define CHROME_BROWSER_SIGNIN_FAKE_AUTH_STATUS_PROVIDER_H_
      7 
      8 #include "chrome/browser/signin/signin_global_error.h"
      9 
     10 // Helper class that reports auth errors to SigninGlobalError. Automatically
     11 // registers and de-registers itself as an AuthStatusProvider in the
     12 // constructor and destructor.
     13 class FakeAuthStatusProvider : public SigninGlobalError::AuthStatusProvider {
     14  public:
     15   explicit FakeAuthStatusProvider(SigninGlobalError* error);
     16   virtual ~FakeAuthStatusProvider();
     17 
     18   // Sets the auth error that this provider reports to SigninGlobalError. Also
     19   // notifies SigninGlobalError via AuthStatusChanged().
     20   void SetAuthError(const std::string& account_id,
     21                     const GoogleServiceAuthError& error);
     22 
     23   void set_error_without_status_change(const GoogleServiceAuthError& error) {
     24     auth_error_ = error;
     25   }
     26 
     27   // AuthStatusProvider implementation.
     28   virtual std::string GetAccountId() const OVERRIDE;
     29   virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
     30 
     31  private:
     32   SigninGlobalError* global_error_;
     33   std::string account_id_;
     34   GoogleServiceAuthError auth_error_;
     35 };
     36 
     37 #endif  // CHROME_BROWSER_SIGNIN_FAKE_AUTH_STATUS_PROVIDER_H_
     38