1effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
5effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#ifndef COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_AUTH_STATUS_PROVIDER_H_
6effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#define COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_AUTH_STATUS_PROVIDER_H_
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
8effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#include "components/signin/core/browser/signin_error_controller.h"
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
10a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)// Helper class that reports auth errors to SigninErrorController. Automatically
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// registers and de-registers itself as an AuthStatusProvider in the
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// constructor and destructor.
13a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)class FakeAuthStatusProvider
14a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)    : public SigninErrorController::AuthStatusProvider {
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
16a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  explicit FakeAuthStatusProvider(SigninErrorController* error);
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual ~FakeAuthStatusProvider();
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
19a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Sets the auth error that this provider reports to SigninErrorController.
20a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  // Also notifies SigninErrorController via AuthStatusChanged().
214e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void SetAuthError(const std::string& account_id,
22cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)                    const std::string& username,
234e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)                    const GoogleServiceAuthError& error);
244e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)
254e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  void set_error_without_status_change(const GoogleServiceAuthError& error) {
264e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)    auth_error_ = error;
274e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  }
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // AuthStatusProvider implementation.
304e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  virtual std::string GetAccountId() const OVERRIDE;
31cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  virtual std::string GetUsername() const OVERRIDE;
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  virtual GoogleServiceAuthError GetAuthStatus() const OVERRIDE;
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
35a1401311d1ab56c4ed0a474bd38c108f75cb0cd9Torne (Richard Coles)  SigninErrorController* error_provider_;
364e180b6a0b4720a9b8e9e959a882386f690f08ffTorne (Richard Coles)  std::string account_id_;
37cedac228d2dd51db4b79ea1e72c7f249408ee061Torne (Richard Coles)  std::string username_;
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GoogleServiceAuthError auth_error_;
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
41effb81e5f8246d0db0270817048dc992db66e9fbBen Murdoch#endif  // COMPONENTS_SIGNIN_CORE_BROWSER_FAKE_AUTH_STATUS_PROVIDER_H_
42