• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 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_MUTABLE_PROFILE_OAUTH2_TOKEN_SERVICE_H_
6 #define CHROME_BROWSER_SIGNIN_MUTABLE_PROFILE_OAUTH2_TOKEN_SERVICE_H_
7 
8 #include "chrome/browser/signin/profile_oauth2_token_service.h"
9 #include "components/webdata/common/web_data_service_base.h"
10 #include "components/webdata/common/web_data_service_consumer.h"
11 
12 // A specialization of ProfileOAuth2TokenService that can can mutate its OAuth2
13 // tokens.
14 //
15 // Note: This class is just a placeholder for now. Methods used to mutate
16 // the tokens are currently being migrated from ProfileOAuth2TokenService.
17 class MutableProfileOAuth2TokenService : public ProfileOAuth2TokenService,
18                                          public WebDataServiceConsumer  {
19  public:
20   // ProfileOAuth2TokenService.
21   virtual void Shutdown() OVERRIDE;
22   virtual void LoadCredentials() OVERRIDE;
23 
24  protected:
25   friend class ProfileOAuth2TokenServiceFactory;
26   MutableProfileOAuth2TokenService();
27   virtual ~MutableProfileOAuth2TokenService();
28 
29  private:
30   FRIEND_TEST_ALL_PREFIXES(MutableProfileOAuth2TokenServiceTest,
31                            TokenServiceUpdateClearsCache);
32   FRIEND_TEST_ALL_PREFIXES(MutableProfileOAuth2TokenServiceTest,
33                            PersistenceDBUpgrade);
34   FRIEND_TEST_ALL_PREFIXES(MutableProfileOAuth2TokenServiceTest,
35                            PersistenceLoadCredentials);
36 
37   // WebDataServiceConsumer implementation:
38   virtual void OnWebDataServiceRequestDone(
39       WebDataServiceBase::Handle handle,
40       const WDTypedResult* result) OVERRIDE;
41 
42   // When migrating an old login-scoped refresh token, this returns the account
43   // ID with which the token was associated.
44   std::string GetAccountIdForMigratingRefreshToken();
45 
46   // Loads credentials into in memory stucture.
47   void LoadAllCredentialsIntoMemory(
48       const std::map<std::string, std::string>& db_tokens);
49 
50   // Handle to the request reading tokens from database.
51   WebDataServiceBase::Handle web_data_service_request_;
52 
53   DISALLOW_COPY_AND_ASSIGN(MutableProfileOAuth2TokenService);
54 };
55 
56 #endif  // CHROME_BROWSER_SIGNIN_MUTABLE_PROFILE_OAUTH2_TOKEN_SERVICE_H_
57