| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ | 5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ |
| 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ | 6 #define COMPONENTS_SIGNIN_CORE_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "components/webdata/common/web_database_table.h" | 13 #include "components/webdata/common/web_database_table.h" |
| 14 | 14 |
| 15 class WebDatabase; | 15 class WebDatabase; |
| 16 | 16 |
| 17 class TokenServiceTable : public WebDatabaseTable { | 17 class TokenServiceTable : public WebDatabaseTable { |
| 18 public: | 18 public: |
| 19 enum Result { |
| 20 TOKEN_DB_RESULT_SQL_INVALID_STATEMENT, |
| 21 TOKEN_DB_RESULT_BAD_ENTRY, |
| 22 TOKEN_DB_RESULT_DECRYPT_ERROR, |
| 23 TOKEN_DB_RESULT_SUCCESS |
| 24 }; |
| 25 |
| 19 TokenServiceTable() {} | 26 TokenServiceTable() {} |
| 20 ~TokenServiceTable() override {} | 27 ~TokenServiceTable() override {} |
| 21 | 28 |
| 22 // Retrieves the TokenServiceTable* owned by |database|. | 29 // Retrieves the TokenServiceTable* owned by |database|. |
| 23 static TokenServiceTable* FromWebDatabase(WebDatabase* db); | 30 static TokenServiceTable* FromWebDatabase(WebDatabase* db); |
| 24 | 31 |
| 25 WebDatabaseTable::TypeKey GetTypeKey() const override; | 32 WebDatabaseTable::TypeKey GetTypeKey() const override; |
| 26 bool CreateTablesIfNecessary() override; | 33 bool CreateTablesIfNecessary() override; |
| 27 bool IsSyncable() override; | 34 bool IsSyncable() override; |
| 28 bool MigrateToVersion(int version, bool* update_compatible_version) override; | 35 bool MigrateToVersion(int version, bool* update_compatible_version) override; |
| 29 | 36 |
| 30 // Remove all tokens previously set with SetTokenForService. | 37 // Remove all tokens previously set with SetTokenForService. |
| 31 bool RemoveAllTokens(); | 38 bool RemoveAllTokens(); |
| 32 | 39 |
| 33 // Removes a token related to the service from the token_service table. | 40 // Removes a token related to the service from the token_service table. |
| 34 bool RemoveTokenForService(const std::string& service); | 41 bool RemoveTokenForService(const std::string& service); |
| 35 | 42 |
| 36 // Retrieves all tokens previously set with SetTokenForService. | 43 // Retrieves all tokens previously set with SetTokenForService. |
| 37 // Returns true if there were tokens and we decrypted them, | 44 // Returns true if there were tokens and we decrypted them, |
| 38 // false if there was a failure somehow | 45 // false if there was a failure somehow |
| 39 bool GetAllTokens(std::map<std::string, std::string>* tokens); | 46 Result GetAllTokens(std::map<std::string, std::string>* tokens); |
| 40 | 47 |
| 41 // Store a token in the token_service table. Stored encrypted. May cause | 48 // Store a token in the token_service table. Stored encrypted. May cause |
| 42 // a mac keychain popup. | 49 // a mac keychain popup. |
| 43 // True if we encrypted a token and stored it, false otherwise. | 50 // True if we encrypted a token and stored it, false otherwise. |
| 44 bool SetTokenForService(const std::string& service, | 51 bool SetTokenForService(const std::string& service, |
| 45 const std::string& token); | 52 const std::string& token); |
| 46 | 53 |
| 47 private: | 54 private: |
| 48 DISALLOW_COPY_AND_ASSIGN(TokenServiceTable); | 55 DISALLOW_COPY_AND_ASSIGN(TokenServiceTable); |
| 49 }; | 56 }; |
| 50 | 57 |
| 51 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ | 58 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_WEBDATA_TOKEN_SERVICE_TABLE_H_ |
| OLD | NEW |