diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-20 15:44:59 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-20 15:44:59 +0000 |
commit | f32c7f0bbaae5198442a621100161efd0e9fdb99 (patch) | |
tree | f30862eb3dd6cd361950b97183f5c64a7221b214 /chrome/browser/webdata | |
parent | df51a04a0d9121552b5f6f34bea90a681d47639a (diff) | |
download | chromium_src-f32c7f0bbaae5198442a621100161efd0e9fdb99.zip chromium_src-f32c7f0bbaae5198442a621100161efd0e9fdb99.tar.gz chromium_src-f32c7f0bbaae5198442a621100161efd0e9fdb99.tar.bz2 |
Porting in chrome/browser/
Review URL: http://codereview.chromium.org/17606
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8280 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/webdata')
-rw-r--r-- | chrome/browser/webdata/web_data_service.cc | 69 | ||||
-rw-r--r-- | chrome/browser/webdata/web_data_service.h | 38 | ||||
-rw-r--r-- | chrome/browser/webdata/web_data_service_win.cc | 65 |
3 files changed, 91 insertions, 81 deletions
diff --git a/chrome/browser/webdata/web_data_service.cc b/chrome/browser/webdata/web_data_service.cc index a3f8e55..ced5a6f 100644 --- a/chrome/browser/webdata/web_data_service.cc +++ b/chrome/browser/webdata/web_data_service.cc @@ -2,14 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include <windows.h> - #include "chrome/browser/webdata/web_data_service.h" #include "base/file_util.h" #include "base/path_service.h" #include "base/scoped_ptr.h" -#include "chrome/browser/password_manager/ie7_password.h" #include "chrome/browser/search_engines/template_url.h" #include "chrome/common/chrome_constants.h" #include "webkit/glue/password_form.h" @@ -23,10 +20,10 @@ using base::Time; -WebDataService::WebDataService() : should_commit_(false), - next_request_handle_(1), - thread_(NULL), - db_(NULL) { +WebDataService::WebDataService() : thread_(NULL), + db_(NULL), + should_commit_(false), + next_request_handle_(1) { } WebDataService::~WebDataService() { @@ -289,15 +286,6 @@ void WebDataService::AddLogin(const PasswordForm& form) { request)); } -void WebDataService::AddIE7Login(const IE7PasswordInfo& info) { - GenericRequest<IE7PasswordInfo>* request = - new GenericRequest<IE7PasswordInfo>(this, GetNextRequestHandle(), NULL, - info); - RegisterRequest(request); - ScheduleTask(NewRunnableMethod(this, &WebDataService::AddIE7LoginImpl, - request)); -} - void WebDataService::UpdateLogin(const PasswordForm& form) { GenericRequest<PasswordForm>* request = new GenericRequest<PasswordForm>(this, GetNextRequestHandle(), @@ -316,15 +304,6 @@ void WebDataService::RemoveLogin(const PasswordForm& form) { request)); } -void WebDataService::RemoveIE7Login(const IE7PasswordInfo& info) { - GenericRequest<IE7PasswordInfo>* request = - new GenericRequest<IE7PasswordInfo>(this, GetNextRequestHandle(), NULL, - info); - RegisterRequest(request); - ScheduleTask(NewRunnableMethod(this, &WebDataService::RemoveIE7LoginImpl, - request)); -} - void WebDataService::RemoveLoginsCreatedBetween(const Time delete_begin, const Time delete_end) { GenericRequest2<Time, Time>* request = @@ -367,18 +346,6 @@ WebDataService::Handle WebDataService::GetLogins( return request->GetHandle(); } -WebDataService::Handle WebDataService::GetIE7Login( - const IE7PasswordInfo& info, - WebDataServiceConsumer* consumer) { - GenericRequest<IE7PasswordInfo>* request = - new GenericRequest<IE7PasswordInfo>(this, GetNextRequestHandle(), - consumer, info); - RegisterRequest(request); - ScheduleTask(NewRunnableMethod(this, &WebDataService::GetIE7LoginImpl, - request)); - return request->GetHandle(); -} - WebDataService::Handle WebDataService::GetAllAutofillableLogins( WebDataServiceConsumer* consumer) { WebDataRequest* request = @@ -517,14 +484,6 @@ void WebDataService::AddLoginImpl(GenericRequest<PasswordForm>* request) { request->RequestComplete(); } -void WebDataService::AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request) { - if (db_ && !request->IsCancelled()) { - if (db_->AddIE7Login(request->GetArgument())) - ScheduleCommit(); - } - request->RequestComplete(); -} - void WebDataService::UpdateLoginImpl(GenericRequest<PasswordForm>* request) { if (db_ && !request->IsCancelled()) { if (db_->UpdateLogin(request->GetArgument())) @@ -541,15 +500,6 @@ void WebDataService::RemoveLoginImpl(GenericRequest<PasswordForm>* request) { request->RequestComplete(); } -void WebDataService::RemoveIE7LoginImpl( - GenericRequest<IE7PasswordInfo>* request) { - if (db_ && !request->IsCancelled()) { - if (db_->RemoveIE7Login(request->GetArgument())) - ScheduleCommit(); - } - request->RequestComplete(); -} - void WebDataService::RemoveLoginsCreatedBetweenImpl( GenericRequest2<Time, Time>* request) { if (db_ && !request->IsCancelled()) { @@ -570,17 +520,6 @@ void WebDataService::GetLoginsImpl(GenericRequest<PasswordForm>* request) { request->RequestComplete(); } -void WebDataService::GetIE7LoginImpl( - GenericRequest<IE7PasswordInfo>* request) { - if (db_ && !request->IsCancelled()) { - IE7PasswordInfo result; - db_->GetIE7Login(request->GetArgument(), &result); - request->SetResult( - new WDResult<IE7PasswordInfo>(PASSWORD_IE7_RESULT, result)); - } - request->RequestComplete(); -} - void WebDataService::GetAllAutofillableLoginsImpl(WebDataRequest* request) { if (db_ && !request->IsCancelled()) { std::vector<PasswordForm*> forms; diff --git a/chrome/browser/webdata/web_data_service.h b/chrome/browser/webdata/web_data_service.h index 053644b..4e2786b 100644 --- a/chrome/browser/webdata/web_data_service.h +++ b/chrome/browser/webdata/web_data_service.h @@ -16,7 +16,9 @@ #include "chrome/common/scoped_vector.h" #include "webkit/glue/autofill_form.h" +#if defined(OS_WIN) struct IE7PasswordInfo; +#endif struct PasswordForm; class GURL; class ShutdownTask; @@ -307,15 +309,9 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { // Adds |form| to the list of remembered password forms. void AddLogin(const PasswordForm& form); - // Adds |info| to the list of imported passwords from ie7/ie8. - void AddIE7Login(const IE7PasswordInfo& info); - // Removes |form| from the list of remembered password forms. void RemoveLogin(const PasswordForm& form); - // Removes |info| from the list of imported passwords from ie7/ie8. - void RemoveIE7Login(const IE7PasswordInfo& info); - // Removes all logins created in the specified daterange void RemoveLoginsCreatedBetween(const base::Time delete_begin, const base::Time delete_end); @@ -329,13 +325,6 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { // The result will be null on failure. The |consumer| owns all PasswordForm's. Handle GetLogins(const PasswordForm& form, WebDataServiceConsumer* consumer); - // 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); - // Gets the complete list of password forms that have not been blacklisted and // are thus auto-fillable. // |consumer| will be notified when the request is done. The result is of @@ -349,6 +338,21 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { // The result will be null on failure. The |consumer| owns all PasswordForm's. Handle GetAllLogins(WebDataServiceConsumer* consumer); +#if defined(OS_WIN) + // 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) + // Cancel any pending request. You need to call this method if your // WebDataServiceConsumer is about to be deleted. void CancelRequest(Handle h); @@ -429,16 +433,18 @@ class WebDataService : public base::RefCountedThreadSafe<WebDataService> { // ////////////////////////////////////////////////////////////////////////////// void AddLoginImpl(GenericRequest<PasswordForm>* request); - void AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); void UpdateLoginImpl(GenericRequest<PasswordForm>* request); void RemoveLoginImpl(GenericRequest<PasswordForm>* request); - void RemoveIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); void RemoveLoginsCreatedBetweenImpl( GenericRequest2<base::Time, base::Time>* request); void GetLoginsImpl(GenericRequest<PasswordForm>* request); - void GetIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); void GetAllAutofillableLoginsImpl(WebDataRequest* request); void GetAllLoginsImpl(WebDataRequest* request); +#if defined(OS_WIN) + void AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); + void RemoveIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); + void GetIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request); +#endif // defined(OS_WIN) ////////////////////////////////////////////////////////////////////////////// // diff --git a/chrome/browser/webdata/web_data_service_win.cc b/chrome/browser/webdata/web_data_service_win.cc new file mode 100644 index 0000000..7219b82 --- /dev/null +++ b/chrome/browser/webdata/web_data_service_win.cc @@ -0,0 +1,65 @@ +// Copyright (c) 2009 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 "chrome/browser/password_manager/ie7_password.h" + +void WebDataService::AddIE7Login(const IE7PasswordInfo& info) { + GenericRequest<IE7PasswordInfo>* request = + new GenericRequest<IE7PasswordInfo>(this, GetNextRequestHandle(), NULL, + info); + RegisterRequest(request); + ScheduleTask(NewRunnableMethod(this, &WebDataService::AddIE7LoginImpl, + request)); +} + +void WebDataService::RemoveIE7Login(const IE7PasswordInfo& info) { + GenericRequest<IE7PasswordInfo>* request = + new GenericRequest<IE7PasswordInfo>(this, GetNextRequestHandle(), NULL, + info); + RegisterRequest(request); + ScheduleTask(NewRunnableMethod(this, &WebDataService::RemoveIE7LoginImpl, + request)); +} + +WebDataService::Handle WebDataService::GetIE7Login( + const IE7PasswordInfo& info, + WebDataServiceConsumer* consumer) { + GenericRequest<IE7PasswordInfo>* request = + new GenericRequest<IE7PasswordInfo>(this, GetNextRequestHandle(), + consumer, info); + RegisterRequest(request); + ScheduleTask(NewRunnableMethod(this, &WebDataService::GetIE7LoginImpl, + request)); + return request->GetHandle(); +} + +void WebDataService::AddIE7LoginImpl(GenericRequest<IE7PasswordInfo>* request) { + if (db_ && !request->IsCancelled()) { + if (db_->AddIE7Login(request->GetArgument())) + ScheduleCommit(); + } + request->RequestComplete(); +} + +void WebDataService::RemoveIE7LoginImpl( + GenericRequest<IE7PasswordInfo>* request) { + if (db_ && !request->IsCancelled()) { + if (db_->RemoveIE7Login(request->GetArgument())) + ScheduleCommit(); + } + request->RequestComplete(); +} + +void WebDataService::GetIE7LoginImpl( + GenericRequest<IE7PasswordInfo>* request) { + if (db_ && !request->IsCancelled()) { + IE7PasswordInfo result; + db_->GetIE7Login(request->GetArgument(), &result); + request->SetResult( + new WDResult<IE7PasswordInfo>(PASSWORD_IE7_RESULT, result)); + } + request->RequestComplete(); +} |