1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved. 2116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Use of this source code is governed by a BSD-style license that can be 3116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// found in the LICENSE file. 4116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 5116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_WEBDATA_PASSWORD_WEB_DATA_SERVICE_WIN_H_ 6116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_WEBDATA_PASSWORD_WEB_DATA_SERVICE_WIN_H_ 7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 8116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include <vector> 9116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 10116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/memory/ref_counted.h" 11116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/sequenced_task_runner_helpers.h" 12116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/webdata/common/web_data_results.h" 13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/webdata/common/web_data_service_base.h" 14116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/webdata/common/web_data_service_consumer.h" 15116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/webdata/common/web_database.h" 16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 17116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass GURL; 18116680a4aac90f2aa7413d9095a592090648e557Ben Murdochstruct IE7PasswordInfo; 19116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass Profile; 20116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass WebDatabaseService; 21116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 22116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace base { 23116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass MessageLoopProxy; 24116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass Thread; 25116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} 26116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 27116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace content { 28116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass BrowserContext; 29116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch} 30116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 31116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// PasswordWebDataService is used to access IE7/8 Password data stored in the 32116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// web database. All data is retrieved and archived in an asynchronous way. 33116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 34116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass WebDataServiceConsumer; 35116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 36116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass PasswordWebDataService : public WebDataServiceBase { 37116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch public: 38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Retrieves a WebDataService for the given context. 39116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch static scoped_refptr<PasswordWebDataService> FromBrowserContext( 40116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch content::BrowserContext* context); 41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch PasswordWebDataService(scoped_refptr<WebDatabaseService> wdbs, 43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch scoped_refptr<base::MessageLoopProxy> ui_thread, 44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch const ProfileErrorCallback& callback); 45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Adds |info| to the list of imported passwords from ie7/ie8. 47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void AddIE7Login(const IE7PasswordInfo& info); 48116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 49116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Removes |info| from the list of imported passwords from ie7/ie8. 50116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch void RemoveIE7Login(const IE7PasswordInfo& info); 51116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 52116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // Gets the login matching the information in |info|. |consumer| will be 53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // notified when the request is done. The result is of type 54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // WDResult<IE7PasswordInfo>. 55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // If there is no match, the fields of the IE7PasswordInfo will be empty. 56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // All requests return a handle. The handle can be used to cancel the request. 57116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch Handle GetIE7Login(const IE7PasswordInfo& info, 58116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch WebDataServiceConsumer* consumer); 59116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch protected: 61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // For unit tests, passes a null callback. 62116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch PasswordWebDataService(scoped_refptr<base::MessageLoopProxy> ui_thread); 63116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 64116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch virtual ~PasswordWebDataService(); 65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 66116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch private: 67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch // The following methods are only invoked on the DB thread. 68116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch WebDatabase::State AddIE7LoginImpl(const IE7PasswordInfo& info, 69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch WebDatabase* db); 70116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch WebDatabase::State RemoveIE7LoginImpl(const IE7PasswordInfo& info, 71116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch WebDatabase* db); 72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch scoped_ptr<WDTypedResult> GetIE7LoginImpl(const IE7PasswordInfo& info, 73116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch WebDatabase* db); 74116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 75116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch DISALLOW_COPY_AND_ASSIGN(PasswordWebDataService); 76116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}; 77116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch 78116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_WEBDATA_PASSWORD_WEB_DATA_SERVICE_WIN_H_ 79