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 // Chromium settings and storage represent user-selected preferences and 6 // information and MUST not be extracted, overwritten or modified except 7 // through Chromium defined APIs. 8 9 #ifndef CHROME_BROWSER_WEBDATA_TOKEN_WEB_DATA_H__ 10 #define CHROME_BROWSER_WEBDATA_TOKEN_WEB_DATA_H__ 11 12 #include <map> 13 #include <string> 14 #include <vector> 15 16 #include "base/callback_forward.h" 17 #include "base/files/file_path.h" 18 #include "base/location.h" 19 #include "base/memory/ref_counted.h" 20 #include "components/webdata/common/web_data_results.h" 21 #include "components/webdata/common/web_data_service_base.h" 22 #include "components/webdata/common/web_data_service_consumer.h" 23 #include "components/webdata/common/web_database.h" 24 25 class TokenWebDataBackend; 26 class WebDatabaseService; 27 class WebDataServiceConsumer; 28 29 namespace content { 30 class BrowserContext; 31 } 32 33 // TokenWebData is a data repository for storage of authentication tokens. 34 35 class TokenWebData : public WebDataServiceBase { 36 public: 37 // Retrieve a WebDataService for the given context. 38 static scoped_refptr<TokenWebData> FromBrowserContext( 39 content::BrowserContext* context); 40 41 TokenWebData(scoped_refptr<WebDatabaseService> wdbs, 42 const ProfileErrorCallback& callback); 43 44 // Set a token to use for a specified service. 45 void SetTokenForService(const std::string& service, 46 const std::string& token); 47 48 // Remove all tokens stored in the web database. 49 void RemoveAllTokens(); 50 51 // Removes a token related to |service| from the web database. 52 void RemoveTokenForService(const std::string& service); 53 54 // Null on failure. Success is WDResult<std::vector<std::string> > 55 virtual Handle GetAllTokens(WebDataServiceConsumer* consumer); 56 57 protected: 58 // For unit tests, passes a null callback. 59 TokenWebData(); 60 61 virtual ~TokenWebData(); 62 63 private: 64 scoped_refptr<TokenWebDataBackend> token_backend_; 65 66 DISALLOW_COPY_AND_ASSIGN(TokenWebData); 67 }; 68 69 #endif // CHROME_BROWSER_WEBDATA_TOKEN_WEB_DATA_H__ 70