Commit bd386e6e authored by caitkp@chromium.org's avatar caitkp@chromium.org

Following https://codereview.chromium.org/355573008, the only code left in...

Following https://codereview.chromium.org/355573008, the only code left in WebDataService deals with IE 7/8 password data, so move this into a separate (WIN only class) and kill WebDataService.

BUG=181277
TEST=Everything still works
TBR=noms@chromium.org, zea@chromium.org, phajdan.jr@chromium.org
TBR'ing for removal of unneeded includes and API changes in (c/b/profile, c/b/sync, and  c/test/base respectively).

Review URL: https://codereview.chromium.org/364343002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282143 0039d316-1c4b-4281-b951-d872f2087c98
parent 1a6193fb
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include "chrome/browser/password_manager/password_store_factory.h" #include "chrome/browser/password_manager/password_store_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search_engines/template_url_service_factory.h" #include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/importer/imported_bookmark_entry.h" #include "chrome/common/importer/imported_bookmark_entry.h"
#include "chrome/common/importer/imported_favicon_usage.h" #include "chrome/common/importer/imported_favicon_usage.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
...@@ -31,6 +30,11 @@ ...@@ -31,6 +30,11 @@
#include "components/search_engines/template_url.h" #include "components/search_engines/template_url.h"
#include "components/search_engines/template_url_service.h" #include "components/search_engines/template_url_service.h"
#if defined(OS_WIN)
#include "chrome/browser/webdata/password_web_data_service_win.h"
#include "chrome/browser/webdata/web_data_service_factory.h"
#endif
namespace { namespace {
// Generates a unique folder name. If |folder_name| is not unique, then this // Generates a unique folder name. If |folder_name| is not unique, then this
...@@ -86,7 +90,8 @@ void ProfileWriter::AddPasswordForm(const autofill::PasswordForm& form) { ...@@ -86,7 +90,8 @@ void ProfileWriter::AddPasswordForm(const autofill::PasswordForm& form) {
#if defined(OS_WIN) #if defined(OS_WIN)
void ProfileWriter::AddIE7PasswordInfo(const IE7PasswordInfo& info) { void ProfileWriter::AddIE7PasswordInfo(const IE7PasswordInfo& info) {
WebDataService::FromBrowserContext(profile_)->AddIE7Login(info); WebDataServiceFactory::GetPasswordWebDataForProfile(
profile_, Profile::EXPLICIT_ACCESS)->AddIE7Login(info);
} }
#endif #endif
......
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "chrome/browser/profiles/incognito_helpers.h" #include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/sync/glue/sync_start_util.h" #include "chrome/browser/sync/glue/sync_start_util.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_data_service_factory.h" #include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
...@@ -24,6 +23,7 @@ ...@@ -24,6 +23,7 @@
#if defined(OS_WIN) #if defined(OS_WIN)
#include "chrome/browser/password_manager/password_store_win.h" #include "chrome/browser/password_manager/password_store_win.h"
#include "chrome/browser/webdata/password_web_data_service_win.h"
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
#include "chrome/browser/password_manager/password_store_mac.h" #include "chrome/browser/password_manager/password_store_mac.h"
#include "crypto/apple_keychain.h" #include "crypto/apple_keychain.h"
...@@ -148,7 +148,8 @@ KeyedService* PasswordStoreFactory::BuildServiceInstanceFor( ...@@ -148,7 +148,8 @@ KeyedService* PasswordStoreFactory::BuildServiceInstanceFor(
ps = new PasswordStoreWin(main_thread_runner, ps = new PasswordStoreWin(main_thread_runner,
db_thread_runner, db_thread_runner,
login_db.release(), login_db.release(),
WebDataService::FromBrowserContext(profile)); WebDataServiceFactory::GetPasswordWebDataForProfile(
profile, Profile::EXPLICIT_ACCESS));
#elif defined(OS_MACOSX) #elif defined(OS_MACOSX)
crypto::AppleKeychain* keychain = crypto::AppleKeychain* keychain =
CommandLine::ForCurrentProcess()->HasSwitch( CommandLine::ForCurrentProcess()->HasSwitch(
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/password_web_data_service_win.h"
#include "components/os_crypt/ie7_password_win.h" #include "components/os_crypt/ie7_password_win.h"
#include "components/password_manager/core/browser/password_manager.h" #include "components/password_manager/core/browser/password_manager.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
...@@ -20,10 +20,10 @@ using autofill::PasswordForm; ...@@ -20,10 +20,10 @@ using autofill::PasswordForm;
using content::BrowserThread; using content::BrowserThread;
using password_manager::PasswordStoreDefault; using password_manager::PasswordStoreDefault;
// Handles requests to WebDataService. // Handles requests to PasswordWebDataService.
class PasswordStoreWin::DBHandler : public WebDataServiceConsumer { class PasswordStoreWin::DBHandler : public WebDataServiceConsumer {
public: public:
DBHandler(WebDataService* web_data_service, DBHandler(PasswordWebDataService* web_data_service,
PasswordStoreWin* password_store) PasswordStoreWin* password_store)
: web_data_service_(web_data_service), : web_data_service_(web_data_service),
password_store_(password_store) { password_store_(password_store) {
...@@ -51,7 +51,8 @@ class PasswordStoreWin::DBHandler : public WebDataServiceConsumer { ...@@ -51,7 +51,8 @@ class PasswordStoreWin::DBHandler : public WebDataServiceConsumer {
}; };
// Holds info associated with in-flight GetIE7Login requests. // Holds info associated with in-flight GetIE7Login requests.
typedef std::map<WebDataService::Handle, RequestInfo> PendingRequestMap; typedef std::map<PasswordWebDataService::Handle, RequestInfo>
PendingRequestMap;
// Gets logins from IE7 if no others are found. Also copies them into // Gets logins from IE7 if no others are found. Also copies them into
// Chrome's WebDatabase so we don't need to look next time. // Chrome's WebDatabase so we don't need to look next time.
...@@ -61,10 +62,10 @@ class PasswordStoreWin::DBHandler : public WebDataServiceConsumer { ...@@ -61,10 +62,10 @@ class PasswordStoreWin::DBHandler : public WebDataServiceConsumer {
// WebDataServiceConsumer implementation. // WebDataServiceConsumer implementation.
virtual void OnWebDataServiceRequestDone( virtual void OnWebDataServiceRequestDone(
WebDataService::Handle handle, PasswordWebDataService::Handle handle,
const WDTypedResult* result) OVERRIDE; const WDTypedResult* result) OVERRIDE;
scoped_refptr<WebDataService> web_data_service_; scoped_refptr<PasswordWebDataService> web_data_service_;
// This creates a cycle between us and PasswordStore. The cycle is broken // This creates a cycle between us and PasswordStore. The cycle is broken
// from PasswordStoreWin::Shutdown, which deletes us. // from PasswordStoreWin::Shutdown, which deletes us.
...@@ -92,7 +93,8 @@ void PasswordStoreWin::DBHandler::GetIE7Login( ...@@ -92,7 +93,8 @@ void PasswordStoreWin::DBHandler::GetIE7Login(
IE7PasswordInfo info; IE7PasswordInfo info;
info.url_hash = info.url_hash =
ie7_password::GetUrlHash(base::UTF8ToWide(form.origin.spec())); ie7_password::GetUrlHash(base::UTF8ToWide(form.origin.spec()));
WebDataService::Handle handle = web_data_service_->GetIE7Login(info, this); PasswordWebDataService::Handle handle =
web_data_service_->GetIE7Login(info, this);
pending_requests_[handle] = pending_requests_[handle] =
RequestInfo(new PasswordForm(form), callback_runner); RequestInfo(new PasswordForm(form), callback_runner);
} }
...@@ -138,7 +140,7 @@ std::vector<PasswordForm*> PasswordStoreWin::DBHandler::GetIE7Results( ...@@ -138,7 +140,7 @@ std::vector<PasswordForm*> PasswordStoreWin::DBHandler::GetIE7Results(
} }
void PasswordStoreWin::DBHandler::OnWebDataServiceRequestDone( void PasswordStoreWin::DBHandler::OnWebDataServiceRequestDone(
WebDataService::Handle handle, PasswordWebDataService::Handle handle,
const WDTypedResult* result) { const WDTypedResult* result) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::DB));
...@@ -168,7 +170,7 @@ PasswordStoreWin::PasswordStoreWin( ...@@ -168,7 +170,7 @@ PasswordStoreWin::PasswordStoreWin(
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner,
password_manager::LoginDatabase* login_database, password_manager::LoginDatabase* login_database,
WebDataService* web_data_service) PasswordWebDataService* web_data_service)
: PasswordStoreDefault(main_thread_runner, : PasswordStoreDefault(main_thread_runner,
db_thread_runner, db_thread_runner,
login_database) { login_database) {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "base/memory/scoped_ptr.h" #include "base/memory/scoped_ptr.h"
#include "components/password_manager/core/browser/password_store_default.h" #include "components/password_manager/core/browser/password_store_default.h"
class WebDataService; class PasswordWebDataService;
namespace autofill { namespace autofill {
struct PasswordForm; struct PasswordForm;
...@@ -22,12 +22,12 @@ class LoginDatabase; ...@@ -22,12 +22,12 @@ class LoginDatabase;
// but also uses IE7 passwords if no others found. // but also uses IE7 passwords if no others found.
class PasswordStoreWin : public password_manager::PasswordStoreDefault { class PasswordStoreWin : public password_manager::PasswordStoreDefault {
public: public:
// WebDataService is only used for IE7 password fetching. // PasswordWebDataService is only used for IE7 password fetching.
PasswordStoreWin( PasswordStoreWin(
scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner, scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner,
scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner, scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner,
password_manager::LoginDatabase* login_database, password_manager::LoginDatabase* login_database,
WebDataService* web_data_service); PasswordWebDataService* web_data_service);
// PasswordStore: // PasswordStore:
virtual void Shutdown() OVERRIDE; virtual void Shutdown() OVERRIDE;
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
#include "base/time/time.h" #include "base/time/time.h"
#include "chrome/browser/password_manager/password_store_win.h" #include "chrome/browser/password_manager/password_store_win.h"
#include "chrome/browser/webdata/logins_table.h" #include "chrome/browser/webdata/logins_table.h"
#include "chrome/browser/webdata/web_data_service.h" #include "chrome/browser/webdata/password_web_data_service_win.h"
#include "chrome/test/base/testing_profile.h" #include "chrome/test/base/testing_profile.h"
#include "components/os_crypt/ie7_password_win.h" #include "components/os_crypt/ie7_password_win.h"
#include "components/password_manager/core/browser/password_form_data.h" #include "components/password_manager/core/browser/password_form_data.h"
...@@ -52,7 +52,7 @@ class MockPasswordStoreConsumer : public PasswordStoreConsumer { ...@@ -52,7 +52,7 @@ class MockPasswordStoreConsumer : public PasswordStoreConsumer {
class MockWebDataServiceConsumer : public WebDataServiceConsumer { class MockWebDataServiceConsumer : public WebDataServiceConsumer {
public: public:
MOCK_METHOD2(OnWebDataServiceRequestDone, MOCK_METHOD2(OnWebDataServiceRequestDone,
void(WebDataService::Handle, const WDTypedResult*)); void(PasswordWebDataService::Handle, const WDTypedResult*));
}; };
} // anonymous namespace } // anonymous namespace
...@@ -125,8 +125,8 @@ class PasswordStoreWinTest : public testing::Test { ...@@ -125,8 +125,8 @@ class PasswordStoreWinTest : public testing::Test {
// Need to add at least one table so the database gets created. // Need to add at least one table so the database gets created.
wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable())); wdbs_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable()));
wdbs_->LoadDatabase(); wdbs_->LoadDatabase();
wds_ = new WebDataService(wdbs_, wds_ = new PasswordWebDataService(
WebDataServiceBase::ProfileErrorCallback()); wdbs_, WebDataServiceBase::ProfileErrorCallback());
wds_->Init(); wds_->Init();
} }
...@@ -163,7 +163,7 @@ class PasswordStoreWinTest : public testing::Test { ...@@ -163,7 +163,7 @@ class PasswordStoreWinTest : public testing::Test {
base::ScopedTempDir temp_dir_; base::ScopedTempDir temp_dir_;
scoped_ptr<TestingProfile> profile_; scoped_ptr<TestingProfile> profile_;
scoped_ptr<LoginDatabase> login_db_; scoped_ptr<LoginDatabase> login_db_;
scoped_refptr<WebDataService> wds_; scoped_refptr<PasswordWebDataService> wds_;
scoped_refptr<WebDatabaseService> wdbs_; scoped_refptr<WebDatabaseService> wdbs_;
scoped_refptr<PasswordStore> store_; scoped_refptr<PasswordStore> store_;
}; };
......
...@@ -26,7 +26,6 @@ class PrefService; ...@@ -26,7 +26,6 @@ class PrefService;
class PromoCounter; class PromoCounter;
class ProtocolHandlerRegistry; class ProtocolHandlerRegistry;
class TestingProfile; class TestingProfile;
class WebDataService;
namespace android { namespace android {
class TabContentsProvider; class TabContentsProvider;
......
...@@ -73,7 +73,6 @@ ...@@ -73,7 +73,6 @@
#include "chrome/browser/sessions/session_service_factory.h" #include "chrome/browser/sessions/session_service_factory.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h" #include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h" #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h" #include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
......
...@@ -115,7 +115,7 @@ class MockWebDataServiceWrapperSyncable : public MockWebDataServiceWrapper { ...@@ -115,7 +115,7 @@ class MockWebDataServiceWrapperSyncable : public MockWebDataServiceWrapper {
} }
MockWebDataServiceWrapperSyncable() MockWebDataServiceWrapperSyncable()
: MockWebDataServiceWrapper(NULL, new FakeWebDataService(), NULL) { : MockWebDataServiceWrapper(new FakeWebDataService(), NULL) {
} }
virtual void Shutdown() OVERRIDE { virtual void Shutdown() OVERRIDE {
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
class PasswordStore; class PasswordStore;
class Profile; class Profile;
class ProfileSyncService; class ProfileSyncService;
class WebDataService;
namespace browser_sync { namespace browser_sync {
class AssociatorInterface; class AssociatorInterface;
......
...@@ -209,7 +209,7 @@ class TokenWebDataServiceFake : public TokenWebData { ...@@ -209,7 +209,7 @@ class TokenWebDataServiceFake : public TokenWebData {
return true; return true;
} }
virtual WebDataService::Handle GetAllTokens( virtual AutofillWebDataService::Handle GetAllTokens(
WebDataServiceConsumer* consumer) OVERRIDE { WebDataServiceConsumer* consumer) OVERRIDE {
// TODO(tim): It would be nice if WebDataService was injected on // TODO(tim): It would be nice if WebDataService was injected on
// construction of ProfileOAuth2TokenService rather than fetched by // construction of ProfileOAuth2TokenService rather than fetched by
...@@ -343,7 +343,6 @@ class WebDataServiceFake : public AutofillWebDataService { ...@@ -343,7 +343,6 @@ class WebDataServiceFake : public AutofillWebDataService {
KeyedService* BuildMockWebDataServiceWrapper(content::BrowserContext* profile) { KeyedService* BuildMockWebDataServiceWrapper(content::BrowserContext* profile) {
return new MockWebDataServiceWrapper( return new MockWebDataServiceWrapper(
NULL,
new WebDataServiceFake(), new WebDataServiceFake(),
new TokenWebDataServiceFake()); new TokenWebDataServiceFake());
} }
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/webdata/password_web_data_service_win.h"
#include "base/bind.h"
#include "chrome/browser/webdata/logins_table.h"
#include "components/os_crypt/ie7_password_win.h"
#include "components/webdata/common/web_database_service.h"
#include "content/public/browser/browser_thread.h"
PasswordWebDataService::PasswordWebDataService(
scoped_refptr<WebDatabaseService> wdbs,
const ProfileErrorCallback& callback)
: WebDataServiceBase(
wdbs,
callback,
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI)) {
}
void PasswordWebDataService::AddIE7Login(const IE7PasswordInfo& info) {
wdbs_->ScheduleDBTask(
FROM_HERE,
base::Bind(&PasswordWebDataService::AddIE7LoginImpl, this, info));
}
void PasswordWebDataService::RemoveIE7Login(const IE7PasswordInfo& info) {
wdbs_->ScheduleDBTask(
FROM_HERE,
base::Bind(&PasswordWebDataService::RemoveIE7LoginImpl, this, info));
}
PasswordWebDataService::Handle PasswordWebDataService::GetIE7Login(
const IE7PasswordInfo& info,
WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(
FROM_HERE,
base::Bind(&PasswordWebDataService::GetIE7LoginImpl, this, info),
consumer);
}
WebDatabase::State PasswordWebDataService::AddIE7LoginImpl(
const IE7PasswordInfo& info,
WebDatabase* db) {
return LoginsTable::FromWebDatabase(db)->AddIE7Login(info) ?
WebDatabase::COMMIT_NEEDED : WebDatabase::COMMIT_NOT_NEEDED;
}
WebDatabase::State PasswordWebDataService::RemoveIE7LoginImpl(
const IE7PasswordInfo& info,
WebDatabase* db) {
return LoginsTable::FromWebDatabase(db)->RemoveIE7Login(info) ?
WebDatabase::COMMIT_NEEDED : WebDatabase::COMMIT_NOT_NEEDED;
}
scoped_ptr<WDTypedResult> PasswordWebDataService::GetIE7LoginImpl(
const IE7PasswordInfo& info,
WebDatabase* db) {
IE7PasswordInfo result;
LoginsTable::FromWebDatabase(db)->GetIE7Login(info, &result);
return scoped_ptr<WDTypedResult>(
new WDResult<IE7PasswordInfo>(PASSWORD_IE7_RESULT, result));
}
////////////////////////////////////////////////////////////////////////////////
PasswordWebDataService::PasswordWebDataService()
: WebDataServiceBase(
NULL,
ProfileErrorCallback(),
content::BrowserThread::GetMessageLoopProxyForThread(
content::BrowserThread::UI)) {
}
PasswordWebDataService::~PasswordWebDataService() {
}
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_WEBDATA_PASSWORD_WEB_DATA_SERVICE_WIN_H_
#define CHROME_BROWSER_WEBDATA_PASSWORD_WEB_DATA_SERVICE_WIN_H_
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner_helpers.h"
#include "components/webdata/common/web_data_results.h"
#include "components/webdata/common/web_data_service_base.h"
#include "components/webdata/common/web_data_service_consumer.h"
#include "components/webdata/common/web_database.h"
class GURL;
struct IE7PasswordInfo;
class Profile;
class WebDatabaseService;
namespace base {
class Thread;
}
namespace content {
class BrowserContext;
}
// PasswordWebDataService is used to access IE7/8 Password data stored in the
// web database. All data is retrieved and archived in an asynchronous way.
class WebDataServiceConsumer;
class PasswordWebDataService : public WebDataServiceBase {
public:
// Retrieves a WebDataService for the given context.
static scoped_refptr<PasswordWebDataService> FromBrowserContext(
content::BrowserContext* context);
PasswordWebDataService(scoped_refptr<WebDatabaseService> wdbs,
const ProfileErrorCallback& callback);
// Adds |info| to the list of imported passwords from ie7/ie8.
void AddIE7Login(const IE7PasswordInfo& info);
// Removes |info| from the list of imported passwords from ie7/ie8.
void RemoveIE7Login(const IE7PasswordInfo& info);
// Gets the login matching the information in |info|. |consumer| will be
// notified when the request is done. The result is of type
// WDResult<IE7PasswordInfo>.
// If there is no match, the fields of the IE7PasswordInfo will be empty.
// All requests return a handle. The handle can be used to cancel the request.
Handle GetIE7Login(const IE7PasswordInfo& info,
WebDataServiceConsumer* consumer);
protected:
// For unit tests, passes a null callback.
PasswordWebDataService();
virtual ~PasswordWebDataService();
private:
// The following methods are only invoked on the DB thread.
WebDatabase::State AddIE7LoginImpl(const IE7PasswordInfo& info,
WebDatabase* db);
WebDatabase::State RemoveIE7LoginImpl(const IE7PasswordInfo& info,
WebDatabase* db);
scoped_ptr<WDTypedResult> GetIE7LoginImpl(const IE7PasswordInfo& info,
WebDatabase* db);
DISALLOW_COPY_AND_ASSIGN(PasswordWebDataService);
};
#endif // CHROME_BROWSER_WEBDATA_PASSWORD_WEB_DATA_SERVICE_WIN_H_
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/webdata/web_data_service.h"
#include "base/bind.h"
#include "chrome/browser/webdata/logins_table.h"
#include "chrome/browser/webdata/web_apps_table.h"
#include "chrome/browser/webdata/web_intents_table.h"
#include "components/search_engines/template_url.h"
#include "components/signin/core/browser/webdata/token_service_table.h"
#include "components/webdata/common/web_database_service.h"
#include "content/public/browser/browser_thread.h"
#include "third_party/skia/include/core/SkBitmap.h"
////////////////////////////////////////////////////////////////////////////////
//
// WebDataService implementation.
//
////////////////////////////////////////////////////////////////////////////////
using base::Bind;
using content::BrowserThread;
WDAppImagesResult::WDAppImagesResult() : has_all_images(false) {}
WDAppImagesResult::~WDAppImagesResult() {}
WebDataService::WebDataService(scoped_refptr<WebDatabaseService> wdbs,
const ProfileErrorCallback& callback)
: WebDataServiceBase(
wdbs, callback,
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)) {
}
//////////////////////////////////////////////////////////////////////////////
//
// Web Apps
//
//////////////////////////////////////////////////////////////////////////////
void WebDataService::SetWebAppImage(const GURL& app_url,
const SkBitmap& image) {
wdbs_->ScheduleDBTask(FROM_HERE,
Bind(&WebDataService::SetWebAppImageImpl, this, app_url, image));
}
void WebDataService::SetWebAppHasAllImages(const GURL& app_url,
bool has_all_images) {
wdbs_->ScheduleDBTask(FROM_HERE,
Bind(&WebDataService::SetWebAppHasAllImagesImpl, this, app_url,
has_all_images));
}
void WebDataService::RemoveWebApp(const GURL& app_url) {
wdbs_->ScheduleDBTask(FROM_HERE,
Bind(&WebDataService::RemoveWebAppImpl, this, app_url));
}
WebDataServiceBase::Handle WebDataService::GetWebAppImages(
const GURL& app_url, WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(FROM_HERE,
Bind(&WebDataService::GetWebAppImagesImpl, this, app_url), consumer);
}
////////////////////////////////////////////////////////////////////////////////
WebDataService::WebDataService()
: WebDataServiceBase(
NULL, ProfileErrorCallback(),
BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI)) {
}
WebDataService::~WebDataService() {
}
////////////////////////////////////////////////////////////////////////////////
//
// Web Apps implementation.
//
////////////////////////////////////////////////////////////////////////////////
WebDatabase::State WebDataService::SetWebAppImageImpl(
const GURL& app_url, const SkBitmap& image, WebDatabase* db) {
WebAppsTable::FromWebDatabase(db)->SetWebAppImage(app_url, image);
return WebDatabase::COMMIT_NEEDED;
}
WebDatabase::State WebDataService::SetWebAppHasAllImagesImpl(
const GURL& app_url, bool has_all_images, WebDatabase* db) {
WebAppsTable::FromWebDatabase(db)->SetWebAppHasAllImages(app_url,
has_all_images);
return WebDatabase::COMMIT_NEEDED;
}
WebDatabase::State WebDataService::RemoveWebAppImpl(
const GURL& app_url, WebDatabase* db) {
WebAppsTable::FromWebDatabase(db)->RemoveWebApp(app_url);
return WebDatabase::COMMIT_NEEDED;
}
scoped_ptr<WDTypedResult> WebDataService::GetWebAppImagesImpl(
const GURL& app_url, WebDatabase* db) {
WDAppImagesResult result;
result.has_all_images =
WebAppsTable::FromWebDatabase(db)->GetWebAppHasAllImages(app_url);
WebAppsTable::FromWebDatabase(db)->GetWebAppImages(app_url, &result.images);
return scoped_ptr<WDTypedResult>(
new WDResult<WDAppImagesResult>(WEB_APP_IMAGES, result));
}
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Chromium settings and storage represent user-selected preferences and
// information and MUST not be extracted, overwritten or modified except
// through Chromium defined APIs.
#ifndef CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
#define CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
#include <vector>
#include "base/memory/ref_counted.h"
#include "base/sequenced_task_runner_helpers.h"
#include "components/webdata/common/web_data_results.h"
#include "components/webdata/common/web_data_service_base.h"
#include "components/webdata/common/web_data_service_consumer.h"
#include "components/webdata/common/web_database.h"
struct DefaultWebIntentService;
class GURL;
#if defined(OS_WIN)
struct IE7PasswordInfo;
#endif
class Profile;
class SkBitmap;
class WebDatabaseService;
namespace base {
class Thread;
}
namespace content {
class BrowserContext;
}
namespace webkit_glue {
struct WebIntentServiceData;
}
////////////////////////////////////////////////////////////////////////////////
//
// WebDataService is a generic data repository for meta data associated with
// web pages. All data is retrieved and archived in an asynchronous way.
//
// All requests return a handle. The handle can be used to cancel the request.
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// WebDataService results
//
////////////////////////////////////////////////////////////////////////////////
// Result from GetWebAppImages.
struct WDAppImagesResult {
WDAppImagesResult();
~WDAppImagesResult();
// True if SetWebAppHasAllImages(true) was invoked.
bool has_all_images;
// The images, may be empty.
std::vector<SkBitmap> images;
};
class WebDataServiceConsumer;
class WebDataService : public WebDataServiceBase {
public:
// Retrieve a WebDataService for the given context.
static scoped_refptr<WebDataService> FromBrowserContext(
content::BrowserContext* context);
WebDataService(scoped_refptr<WebDatabaseService> wdbs,
const ProfileErrorCallback& callback);
//////////////////////////////////////////////////////////////////////////////
//
// Web Apps
//
//////////////////////////////////////////////////////////////////////////////
// Sets the image for the specified web app. A web app can have any number of
// images, but only one at a particular size. If there was an image for the
// web app at the size of the given image it is replaced.
void SetWebAppImage(const GURL& app_url, const SkBitmap& image);
// Sets whether all the images have been downloaded for the specified web app.
void SetWebAppHasAllImages(const GURL& app_url, bool has_all_images);
// Removes all images for the specified web app.
void RemoveWebApp(const GURL& app_url);
// Fetches the images and whether all images have been downloaded for the
// specified web app.
Handle GetWebAppImages(const GURL& app_url, WebDataServiceConsumer* consumer);
#if defined(OS_WIN)
//////////////////////////////////////////////////////////////////////////////
//
// IE7/8 Password Access (used by PasswordStoreWin - do not use elsewhere)
//
//////////////////////////////////////////////////////////////////////////////
// Adds |info| to the list of imported passwords from ie7/ie8.
void AddIE7Login(const IE7PasswordInfo& info);
// Removes |info| from the list of imported passwords from ie7/ie8.
void RemoveIE7Login(const IE7PasswordInfo& info);
// Get the login matching the information in |info|. |consumer| will be
// notified when the request is done. The result is of type
// WDResult<IE7PasswordInfo>.
// If there is no match, the fields of the IE7PasswordInfo will be empty.
Handle GetIE7Login(const IE7PasswordInfo& info,
WebDataServiceConsumer* consumer);
#endif // defined(OS_WIN)
protected:
// For unit tests, passes a null callback.
WebDataService();
virtual ~WebDataService();
private:
//////////////////////////////////////////////////////////////////////////////
//
// The following methods are only invoked on the DB thread.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Web Apps.
//
//////////////////////////////////////////////////////////////////////////////
WebDatabase::State SetWebAppImageImpl(const GURL& app_url,
const SkBitmap& image, WebDatabase* db);
WebDatabase::State SetWebAppHasAllImagesImpl(const GURL& app_url,
bool has_all_images, WebDatabase* db);
WebDatabase::State RemoveWebAppImpl(const GURL& app_url, WebDatabase* db);
scoped_ptr<WDTypedResult> GetWebAppImagesImpl(
const GURL& app_url, WebDatabase* db);
#if defined(ENABLE_WEB_INTENTS)
//////////////////////////////////////////////////////////////////////////////
//
// Web Intents.
//
//////////////////////////////////////////////////////////////////////////////
WebDatabase::State AddWebIntentServiceImpl(
const webkit_glue::WebIntentServiceData& service);
WebDatabase::State RemoveWebIntentServiceImpl(
const webkit_glue::WebIntentServiceData& service);
scoped_ptr<WDTypedResult> GetWebIntentServicesImpl(
const base::string16& action);
scoped_ptr<WDTypedResult> GetWebIntentServicesForURLImpl(
const base::string16& service_url);
scoped_ptr<WDTypedResult> GetAllWebIntentServicesImpl();
WebDatabase::State AddDefaultWebIntentServiceImpl(
const DefaultWebIntentService& service);
WebDatabase::State RemoveDefaultWebIntentServiceImpl(
const DefaultWebIntentService& service);
WebDatabase::State RemoveWebIntentServiceDefaultsImpl(
const GURL& service_url);
scoped_ptr<WDTypedResult> GetDefaultWebIntentServicesForActionImpl(
const base::string16& action);
scoped_ptr<WDTypedResult> GetAllDefaultWebIntentServicesImpl();
#endif
#if defined(OS_WIN)
//////////////////////////////////////////////////////////////////////////////
//
// Password manager.
//
//////////////////////////////////////////////////////////////////////////////
WebDatabase::State AddIE7LoginImpl(
const IE7PasswordInfo& info, WebDatabase* db);
WebDatabase::State RemoveIE7LoginImpl(
const IE7PasswordInfo& info, WebDatabase* db);
scoped_ptr<WDTypedResult> GetIE7LoginImpl(
const IE7PasswordInfo& info, WebDatabase* db);
#endif // defined(OS_WIN)
DISALLOW_COPY_AND_ASSIGN(WebDataService);
};
#endif // CHROME_BROWSER_WEBDATA_WEB_DATA_SERVICE_H__
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "chrome/browser/webdata/autocomplete_syncable_service.h" #include "chrome/browser/webdata/autocomplete_syncable_service.h"
#include "chrome/browser/webdata/logins_table.h" #include "chrome/browser/webdata/logins_table.h"
#include "chrome/browser/webdata/web_apps_table.h" #include "chrome/browser/webdata/web_apps_table.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_intents_table.h" #include "chrome/browser/webdata/web_intents_table.h"
#include "components/autofill/core/browser/autofill_country.h" #include "components/autofill/core/browser/autofill_country.h"
#include "components/autofill/core/browser/webdata/autofill_profile_syncable_service.h" #include "components/autofill/core/browser/webdata/autofill_profile_syncable_service.h"
...@@ -29,6 +28,10 @@ ...@@ -29,6 +28,10 @@
#include "grit/chromium_strings.h" #include "grit/chromium_strings.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#if defined(OS_WIN)
#include "chrome/browser/webdata/password_web_data_service_win.h"
#endif
using autofill::AutofillWebDataService; using autofill::AutofillWebDataService;
using autofill::AutofillProfileSyncableService; using autofill::AutofillProfileSyncableService;
using content::BrowserThread; using content::BrowserThread;
...@@ -40,7 +43,7 @@ void ProfileErrorCallback(ProfileErrorType type, sql::InitStatus status) { ...@@ -40,7 +43,7 @@ void ProfileErrorCallback(ProfileErrorType type, sql::InitStatus status) {
ShowProfileErrorDialog( ShowProfileErrorDialog(
type, type,
(status == sql::INIT_FAILURE) ? (status == sql::INIT_FAILURE) ?
IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR); IDS_COULDNT_OPEN_PROFILE_ERROR : IDS_PROFILE_TOO_NEW_ERROR);
} }
void InitSyncableServicesOnDBThread( void InitSyncableServicesOnDBThread(
...@@ -56,17 +59,18 @@ void InitSyncableServicesOnDBThread( ...@@ -56,17 +59,18 @@ void InitSyncableServicesOnDBThread(
autofill_web_data.get(), autofill_backend); autofill_web_data.get(), autofill_backend);
AutocompleteSyncableService::FromWebDataService(autofill_web_data.get()) AutocompleteSyncableService::FromWebDataService(autofill_web_data.get())
->InjectStartSyncFlare( ->InjectStartSyncFlare(
sync_start_util::GetFlareForSyncableService(profile_path)); sync_start_util::GetFlareForSyncableService(profile_path));
AutofillProfileSyncableService::CreateForWebDataServiceAndBackend( AutofillProfileSyncableService::CreateForWebDataServiceAndBackend(
autofill_web_data.get(), autofill_backend, app_locale); autofill_web_data.get(), autofill_backend, app_locale);
AutofillProfileSyncableService::FromWebDataService(autofill_web_data.get()) AutofillProfileSyncableService::FromWebDataService(autofill_web_data.get())
->InjectStartSyncFlare( ->InjectStartSyncFlare(
sync_start_util::GetFlareForSyncableService(profile_path)); sync_start_util::GetFlareForSyncableService(profile_path));
} }
} // namespace } // namespace
WebDataServiceWrapper::WebDataServiceWrapper() {} WebDataServiceWrapper::WebDataServiceWrapper() {
}
WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
base::FilePath profile_path = profile->GetPath(); base::FilePath profile_path = profile->GetPath();
...@@ -80,52 +84,56 @@ WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) { ...@@ -80,52 +84,56 @@ WebDataServiceWrapper::WebDataServiceWrapper(Profile* profile) {
// All tables objects that participate in managing the database must // All tables objects that participate in managing the database must
// be added here. // be added here.
web_database_->AddTable( web_database_->AddTable(scoped_ptr<WebDatabaseTable>(
scoped_ptr<WebDatabaseTable>(new autofill::AutofillTable( new autofill::AutofillTable(g_browser_process->GetApplicationLocale())));
g_browser_process->GetApplicationLocale()))); web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new KeywordTable()));
web_database_->AddTable(
scoped_ptr<WebDatabaseTable>(new KeywordTable()));
// TODO(mdm): We only really need the LoginsTable on Windows for IE7 password // TODO(mdm): We only really need the LoginsTable on Windows for IE7 password
// access, but for now, we still create it on all platforms since it deletes // access, but for now, we still create it on all platforms since it deletes
// the old logins table. We can remove this after a while, e.g. in M22 or so. // the old logins table. We can remove this after a while, e.g. in M22 or so.
web_database_->AddTable( web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new LoginsTable()));
scoped_ptr<WebDatabaseTable>(new LoginsTable()));
web_database_->AddTable( web_database_->AddTable(
scoped_ptr<WebDatabaseTable>(new TokenServiceTable())); scoped_ptr<WebDatabaseTable>(new TokenServiceTable()));
web_database_->AddTable( // TODO(caitkp): Add a migration to delete the SQL table used by
scoped_ptr<WebDatabaseTable>(new WebAppsTable())); // WebIntentsTable, then remove this.
web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new WebAppsTable()));
// TODO(thakis): Add a migration to delete the SQL table used by // TODO(thakis): Add a migration to delete the SQL table used by
// WebIntentsTable, then remove this. // WebIntentsTable, then remove this.
web_database_->AddTable( web_database_->AddTable(scoped_ptr<WebDatabaseTable>(new WebIntentsTable()));
scoped_ptr<WebDatabaseTable>(new WebIntentsTable()));
web_database_->LoadDatabase(); web_database_->LoadDatabase();
autofill_web_data_ = new AutofillWebDataService( autofill_web_data_ = new AutofillWebDataService(
web_database_, ui_thread, db_thread, base::Bind( web_database_,
&ProfileErrorCallback, PROFILE_ERROR_DB_AUTOFILL_WEB_DATA)); ui_thread,
db_thread,
base::Bind(&ProfileErrorCallback, PROFILE_ERROR_DB_AUTOFILL_WEB_DATA));
autofill_web_data_->Init(); autofill_web_data_->Init();
keyword_web_data_ = new KeywordWebDataService( keyword_web_data_ = new KeywordWebDataService(
web_database_, ui_thread, base::Bind( web_database_,
&ProfileErrorCallback, PROFILE_ERROR_DB_KEYWORD_WEB_DATA)); ui_thread,
base::Bind(&ProfileErrorCallback, PROFILE_ERROR_DB_KEYWORD_WEB_DATA));
keyword_web_data_->Init(); keyword_web_data_->Init();
token_web_data_ = new TokenWebData( token_web_data_ = new TokenWebData(
web_database_, ui_thread, db_thread, base::Bind( web_database_,
&ProfileErrorCallback, PROFILE_ERROR_DB_TOKEN_WEB_DATA)); ui_thread,
db_thread,
base::Bind(&ProfileErrorCallback, PROFILE_ERROR_DB_TOKEN_WEB_DATA));
token_web_data_->Init(); token_web_data_->Init();
web_data_ = new WebDataService( #if defined(OS_WIN)
web_database_, base::Bind(&ProfileErrorCallback, password_web_data_ = new PasswordWebDataService(
PROFILE_ERROR_DB_WEB_DATA)); web_database_,
web_data_->Init(); base::Bind(&ProfileErrorCallback, PROFILE_ERROR_DB_WEB_DATA));
password_web_data_->Init();
#endif
autofill_web_data_->GetAutofillBackend( autofill_web_data_->GetAutofillBackend(
base::Bind(&InitSyncableServicesOnDBThread, base::Bind(&InitSyncableServicesOnDBThread,
autofill_web_data_, autofill_web_data_,
profile_path, profile_path,
g_browser_process->GetApplicationLocale())); g_browser_process->GetApplicationLocale()));
} }
WebDataServiceWrapper::~WebDataServiceWrapper() { WebDataServiceWrapper::~WebDataServiceWrapper() {
...@@ -135,7 +143,10 @@ void WebDataServiceWrapper::Shutdown() { ...@@ -135,7 +143,10 @@ void WebDataServiceWrapper::Shutdown() {
autofill_web_data_->ShutdownOnUIThread(); autofill_web_data_->ShutdownOnUIThread();
keyword_web_data_->ShutdownOnUIThread(); keyword_web_data_->ShutdownOnUIThread();
token_web_data_->ShutdownOnUIThread(); token_web_data_->ShutdownOnUIThread();
web_data_->ShutdownOnUIThread();
#if defined(OS_WIN)
password_web_data_->ShutdownOnUIThread();
#endif
web_database_->ShutdownDatabase(); web_database_->ShutdownDatabase();
} }
...@@ -149,37 +160,26 @@ WebDataServiceWrapper::GetKeywordWebData() { ...@@ -149,37 +160,26 @@ WebDataServiceWrapper::GetKeywordWebData() {
return keyword_web_data_.get(); return keyword_web_data_.get();
} }
scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() {
return web_data_.get();
}
scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() { scoped_refptr<TokenWebData> WebDataServiceWrapper::GetTokenWebData() {
return token_web_data_.get(); return token_web_data_.get();
} }
// static #if defined(OS_WIN)
scoped_refptr<WebDataService> WebDataService::FromBrowserContext( scoped_refptr<PasswordWebDataService>
content::BrowserContext* context) { WebDataServiceWrapper::GetPasswordWebData() {
// For this service, the implicit/explicit distinction doesn't return password_web_data_.get();
// really matter; it's just used for a DCHECK. So we currently
// cheat and always say EXPLICIT_ACCESS.
WebDataServiceWrapper* wrapper =
WebDataServiceFactory::GetForProfile(
static_cast<Profile*>(context), Profile::EXPLICIT_ACCESS);
if (wrapper)
return wrapper->GetWebData();
// |wrapper| can be NULL in Incognito mode.
return scoped_refptr<WebDataService>(NULL);
} }
#endif
WebDataServiceFactory::WebDataServiceFactory() WebDataServiceFactory::WebDataServiceFactory()
: BrowserContextKeyedServiceFactory( : BrowserContextKeyedServiceFactory(
"WebDataService", "WebDataService",
BrowserContextDependencyManager::GetInstance()) { BrowserContextDependencyManager::GetInstance()) {
// WebDataServiceFactory has no dependecies. // WebDataServiceFactory has no dependecies.
} }
WebDataServiceFactory::~WebDataServiceFactory() {} WebDataServiceFactory::~WebDataServiceFactory() {
}
// static // static
WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( WebDataServiceWrapper* WebDataServiceFactory::GetForProfile(
...@@ -190,7 +190,7 @@ WebDataServiceWrapper* WebDataServiceFactory::GetForProfile( ...@@ -190,7 +190,7 @@ WebDataServiceWrapper* WebDataServiceFactory::GetForProfile(
// the *WebDataService::FromBrowserContext() functions (see above). // the *WebDataService::FromBrowserContext() functions (see above).
DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
return static_cast<WebDataServiceWrapper*>( return static_cast<WebDataServiceWrapper*>(
GetInstance()->GetServiceForBrowserContext(profile, true)); GetInstance()->GetServiceForBrowserContext(profile, true));
} }
// static // static
...@@ -202,7 +202,7 @@ WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists( ...@@ -202,7 +202,7 @@ WebDataServiceWrapper* WebDataServiceFactory::GetForProfileIfExists(
// the *WebDataService::FromBrowserContext() functions (see above). // the *WebDataService::FromBrowserContext() functions (see above).
DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord()); DCHECK(access_type != Profile::IMPLICIT_ACCESS || !profile->IsOffTheRecord());
return static_cast<WebDataServiceWrapper*>( return static_cast<WebDataServiceWrapper*>(
GetInstance()->GetServiceForBrowserContext(profile, false)); GetInstance()->GetServiceForBrowserContext(profile, false));
} }
// static // static
...@@ -231,16 +231,30 @@ WebDataServiceFactory::GetKeywordWebDataForProfile( ...@@ -231,16 +231,30 @@ WebDataServiceFactory::GetKeywordWebDataForProfile(
} }
// static // static
scoped_refptr<TokenWebData> scoped_refptr<TokenWebData> WebDataServiceFactory::GetTokenWebDataForProfile(
WebDataServiceFactory::GetTokenWebDataForProfile( Profile* profile,
Profile::ServiceAccessType access_type) {
WebDataServiceWrapper* wrapper =
WebDataServiceFactory::GetForProfile(profile, access_type);
// |wrapper| can be NULL in Incognito mode.
return wrapper ?
wrapper->GetTokenWebData() : scoped_refptr<TokenWebData>(NULL);
}
#if defined(OS_WIN)
// static
scoped_refptr<PasswordWebDataService>
WebDataServiceFactory::GetPasswordWebDataForProfile(
Profile* profile, Profile* profile,
Profile::ServiceAccessType access_type) { Profile::ServiceAccessType access_type) {
WebDataServiceWrapper* wrapper = WebDataServiceWrapper* wrapper =
WebDataServiceFactory::GetForProfile(profile, access_type); WebDataServiceFactory::GetForProfile(profile, access_type);
// |wrapper| can be NULL in Incognito mode. // |wrapper| can be NULL in Incognito mode.
return wrapper ? wrapper->GetTokenWebData() return wrapper ?
: scoped_refptr<TokenWebData>(NULL); wrapper->GetPasswordWebData() :
scoped_refptr<PasswordWebDataService>(NULL);
} }
#endif
// static // static
WebDataServiceFactory* WebDataServiceFactory::GetInstance() { WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
......
...@@ -15,7 +15,10 @@ ...@@ -15,7 +15,10 @@
class KeywordWebDataService; class KeywordWebDataService;
class TokenWebData; class TokenWebData;
class WebDataService;
#if defined(OS_WIN)
class PasswordWebDataService;
#endif
namespace autofill { namespace autofill {
class AutofillWebDataService; class AutofillWebDataService;
...@@ -38,17 +41,22 @@ class WebDataServiceWrapper : public KeyedService { ...@@ -38,17 +41,22 @@ class WebDataServiceWrapper : public KeyedService {
virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData(); virtual scoped_refptr<KeywordWebDataService> GetKeywordWebData();
virtual scoped_refptr<WebDataService> GetWebData();
virtual scoped_refptr<TokenWebData> GetTokenWebData(); virtual scoped_refptr<TokenWebData> GetTokenWebData();
#if defined(OS_WIN)
virtual scoped_refptr<PasswordWebDataService> GetPasswordWebData();
#endif
private: private:
scoped_refptr<WebDatabaseService> web_database_; scoped_refptr<WebDatabaseService> web_database_;
scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_; scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_;
scoped_refptr<KeywordWebDataService> keyword_web_data_; scoped_refptr<KeywordWebDataService> keyword_web_data_;
scoped_refptr<TokenWebData> token_web_data_; scoped_refptr<TokenWebData> token_web_data_;
scoped_refptr<WebDataService> web_data_;
#if defined(OS_WIN)
scoped_refptr<PasswordWebDataService> password_web_data_;
#endif
DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper); DISALLOW_COPY_AND_ASSIGN(WebDataServiceWrapper);
}; };
...@@ -72,13 +80,21 @@ class WebDataServiceFactory : public BrowserContextKeyedServiceFactory { ...@@ -72,13 +80,21 @@ class WebDataServiceFactory : public BrowserContextKeyedServiceFactory {
Profile::ServiceAccessType access_type); Profile::ServiceAccessType access_type);
// Returns the KeywordWebDataService associated with the |profile|. // Returns the KeywordWebDataService associated with the |profile|.
static scoped_refptr<KeywordWebDataService> static scoped_refptr<KeywordWebDataService> GetKeywordWebDataForProfile(
GetKeywordWebDataForProfile(Profile* profile, Profile* profile,
Profile::ServiceAccessType access_type); Profile::ServiceAccessType access_type);
// Returns the TokenWebData associated with the |profile|. // Returns the TokenWebData associated with the |profile|.
static scoped_refptr<TokenWebData> GetTokenWebDataForProfile(Profile* profile, static scoped_refptr<TokenWebData> GetTokenWebDataForProfile(
Profile* profile,
Profile::ServiceAccessType access_type);
#if defined(OS_WIN)
// Returns the PasswordWebDataService associated with the |profile|.
static scoped_refptr<PasswordWebDataService> GetPasswordWebDataForProfile(
Profile* profile,
Profile::ServiceAccessType access_type); Profile::ServiceAccessType access_type);
#endif
static WebDataServiceFactory* GetInstance(); static WebDataServiceFactory* GetInstance();
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/webdata/web_data_service.h"
#include "base/bind.h"
#include "chrome/browser/webdata/logins_table.h"
#include "components/os_crypt/ie7_password_win.h"
#include "components/webdata/common/web_database_service.h"
using base::Bind;
void WebDataService::AddIE7Login(const IE7PasswordInfo& info) {
wdbs_->ScheduleDBTask(
FROM_HERE, Bind(&WebDataService::AddIE7LoginImpl, this, info));
}
void WebDataService::RemoveIE7Login(const IE7PasswordInfo& info) {
wdbs_->ScheduleDBTask(
FROM_HERE, Bind(&WebDataService::RemoveIE7LoginImpl, this, info));
}
WebDataService::Handle WebDataService::GetIE7Login(
const IE7PasswordInfo& info,
WebDataServiceConsumer* consumer) {
return wdbs_->ScheduleDBTaskWithResult(
FROM_HERE, Bind(&WebDataService::GetIE7LoginImpl, this, info), consumer);
}
WebDatabase::State WebDataService::AddIE7LoginImpl(
const IE7PasswordInfo& info, WebDatabase* db) {
if (LoginsTable::FromWebDatabase(db)->AddIE7Login(info))
return WebDatabase::COMMIT_NEEDED;
return WebDatabase::COMMIT_NOT_NEEDED;
}
WebDatabase::State WebDataService::RemoveIE7LoginImpl(
const IE7PasswordInfo& info, WebDatabase* db) {
if (LoginsTable::FromWebDatabase(db)->RemoveIE7Login(info))
return WebDatabase::COMMIT_NEEDED;
return WebDatabase::COMMIT_NOT_NEEDED;
}
scoped_ptr<WDTypedResult> WebDataService::GetIE7LoginImpl(
const IE7PasswordInfo& info, WebDatabase* db) {
IE7PasswordInfo result;
LoginsTable::FromWebDatabase(db)->GetIE7Login(info, &result);
return scoped_ptr<WDTypedResult>(
new WDResult<IE7PasswordInfo>(PASSWORD_IE7_RESULT, result));
}
...@@ -1439,13 +1439,12 @@ ...@@ -1439,13 +1439,12 @@
'browser/webdata/logins_table.cc', 'browser/webdata/logins_table.cc',
'browser/webdata/logins_table.h', 'browser/webdata/logins_table.h',
'browser/webdata/logins_table_win.cc', 'browser/webdata/logins_table_win.cc',
'browser/webdata/password_web_data_service_win.cc',
'browser/webdata/password_web_data_service_win.h',
'browser/webdata/web_apps_table.cc', 'browser/webdata/web_apps_table.cc',
'browser/webdata/web_apps_table.h', 'browser/webdata/web_apps_table.h',
'browser/webdata/web_data_service.cc',
'browser/webdata/web_data_service.h',
'browser/webdata/web_data_service_factory.cc', 'browser/webdata/web_data_service_factory.cc',
'browser/webdata/web_data_service_factory.h', 'browser/webdata/web_data_service_factory.h',
'browser/webdata/web_data_service_win.cc',
'browser/webdata/web_intents_table.cc', 'browser/webdata/web_intents_table.cc',
'browser/webdata/web_intents_table.h', 'browser/webdata/web_intents_table.h',
], ],
......
...@@ -46,7 +46,6 @@ ...@@ -46,7 +46,6 @@
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/profiles/storage_partition_descriptor.h" #include "chrome/browser/profiles/storage_partition_descriptor.h"
#include "chrome/browser/search_engines/template_url_fetcher_factory.h" #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_data_service_factory.h" #include "chrome/browser/webdata/web_data_service_factory.h"
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include "components/webdata/common/web_data_service_base.h" #include "components/webdata/common/web_data_service_base.h"
#include "components/webdata/common/web_data_service_consumer.h" #include "components/webdata/common/web_data_service_consumer.h"
class WebDataService;
class WebDataServiceConsumer; class WebDataServiceConsumer;
class WebDataRequestManager; class WebDataRequestManager;
......
...@@ -21,12 +21,10 @@ void MockWebDataServiceWrapperBase::Shutdown() { ...@@ -21,12 +21,10 @@ void MockWebDataServiceWrapperBase::Shutdown() {
// will probably need a better way to create these mocks rather than passing // will probably need a better way to create these mocks rather than passing
// all the webdatas in. // all the webdatas in.
MockWebDataServiceWrapper::MockWebDataServiceWrapper( MockWebDataServiceWrapper::MockWebDataServiceWrapper(
scoped_refptr<WebDataService> fake_service,
scoped_refptr<AutofillWebDataService> fake_autofill, scoped_refptr<AutofillWebDataService> fake_autofill,
scoped_refptr<TokenWebData> fake_token) scoped_refptr<TokenWebData> fake_token)
: fake_autofill_web_data_(fake_autofill), : fake_autofill_web_data_(fake_autofill),
fake_token_web_data_(fake_token), fake_token_web_data_(fake_token) {
fake_web_data_(fake_service) {
} }
MockWebDataServiceWrapper::~MockWebDataServiceWrapper() { MockWebDataServiceWrapper::~MockWebDataServiceWrapper() {
...@@ -40,7 +38,3 @@ scoped_refptr<AutofillWebDataService> ...@@ -40,7 +38,3 @@ scoped_refptr<AutofillWebDataService>
scoped_refptr<TokenWebData> MockWebDataServiceWrapper::GetTokenWebData() { scoped_refptr<TokenWebData> MockWebDataServiceWrapper::GetTokenWebData() {
return fake_token_web_data_; return fake_token_web_data_;
} }
scoped_refptr<WebDataService> MockWebDataServiceWrapper::GetWebData() {
return fake_web_data_;
}
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include "base/basictypes.h" #include "base/basictypes.h"
#include "base/message_loop/message_loop.h" #include "base/message_loop/message_loop.h"
#include "chrome/browser/webdata/web_data_service.h"
#include "chrome/browser/webdata/web_data_service_factory.h" #include "chrome/browser/webdata/web_data_service_factory.h"
#include "components/signin/core/browser/webdata/token_web_data.h" #include "components/signin/core/browser/webdata/token_web_data.h"
...@@ -29,7 +28,6 @@ class MockWebDataServiceWrapperBase : public WebDataServiceWrapper { ...@@ -29,7 +28,6 @@ class MockWebDataServiceWrapperBase : public WebDataServiceWrapper {
class MockWebDataServiceWrapper : public MockWebDataServiceWrapperBase { class MockWebDataServiceWrapper : public MockWebDataServiceWrapperBase {
public: public:
MockWebDataServiceWrapper( MockWebDataServiceWrapper(
scoped_refptr<WebDataService> fake_service,
scoped_refptr<autofill::AutofillWebDataService> fake_autofill, scoped_refptr<autofill::AutofillWebDataService> fake_autofill,
scoped_refptr<TokenWebData> fake_token); scoped_refptr<TokenWebData> fake_token);
...@@ -40,12 +38,9 @@ class MockWebDataServiceWrapper : public MockWebDataServiceWrapperBase { ...@@ -40,12 +38,9 @@ class MockWebDataServiceWrapper : public MockWebDataServiceWrapperBase {
virtual scoped_refptr<TokenWebData> GetTokenWebData() OVERRIDE; virtual scoped_refptr<TokenWebData> GetTokenWebData() OVERRIDE;
virtual scoped_refptr<WebDataService> GetWebData() OVERRIDE;
protected: protected:
scoped_refptr<autofill::AutofillWebDataService> fake_autofill_web_data_; scoped_refptr<autofill::AutofillWebDataService> fake_autofill_web_data_;
scoped_refptr<TokenWebData> fake_token_web_data_; scoped_refptr<TokenWebData> fake_token_web_data_;
scoped_refptr<WebDataService> fake_web_data_;
private: private:
DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapper); DISALLOW_COPY_AND_ASSIGN(MockWebDataServiceWrapper);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment