| Index: chrome/browser/extensions/api/passwords_private/passwords_private_api.cc
|
| diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc
|
| index 796b497b6bf660f25b3868e147ffd1dca13240a6..9fcaabfbfc904281ff643fd5c7d241bb15999198 100644
|
| --- a/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc
|
| +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc
|
| @@ -4,6 +4,10 @@
|
|
|
| #include "chrome/browser/extensions/api/passwords_private/passwords_private_api.h"
|
|
|
| +#include "base/bind.h"
|
| +#include "base/bind_helpers.h"
|
| +#include "base/location.h"
|
| +#include "base/threading/thread_task_runner_handle.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.h"
|
| #include "chrome/common/extensions/api/passwords_private.h"
|
| @@ -93,12 +97,26 @@ PasswordsPrivateGetSavedPasswordListFunction::
|
|
|
| ExtensionFunction::ResponseAction
|
| PasswordsPrivateGetSavedPasswordListFunction::Run() {
|
| + // GetList() can immediately call GotList() (which would Respond() before
|
| + // RespondLater()). So we post a task to preserve order.
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GetList, this));
|
| + return RespondLater();
|
| +}
|
| +
|
| +void PasswordsPrivateGetSavedPasswordListFunction::GetList() {
|
| PasswordsPrivateDelegate* delegate =
|
| PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(),
|
| true /* create */);
|
| - return RespondNow(ArgumentList(
|
| - api::passwords_private::GetSavedPasswordList::Results::Create(
|
| - *(delegate->GetSavedPasswordsList()))));
|
| + delegate->GetSavedPasswordsList(
|
| + base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GotList, this));
|
| +}
|
| +
|
| +void PasswordsPrivateGetSavedPasswordListFunction::GotList(
|
| + const PasswordsPrivateDelegate::UiEntries& list) {
|
| + Respond(ArgumentList(
|
| + api::passwords_private::GetSavedPasswordList::Results::Create(list)));
|
| }
|
|
|
| ////////////////////////////////////////////////////////////////////////////////
|
| @@ -109,12 +127,27 @@ PasswordsPrivateGetPasswordExceptionListFunction::
|
|
|
| ExtensionFunction::ResponseAction
|
| PasswordsPrivateGetPasswordExceptionListFunction::Run() {
|
| + // GetList() can immediately call GotList() (which would Respond() before
|
| + // RespondLater()). So we post a task to preserve order.
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&PasswordsPrivateGetPasswordExceptionListFunction::GetList,
|
| + this));
|
| + return RespondLater();
|
| +}
|
| +
|
| +void PasswordsPrivateGetPasswordExceptionListFunction::GetList() {
|
| PasswordsPrivateDelegate* delegate =
|
| PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(),
|
| true /* create */);
|
| - return RespondNow(ArgumentList(
|
| - api::passwords_private::GetPasswordExceptionList::Results::Create(
|
| - *(delegate->GetPasswordExceptionsList()))));
|
| + delegate->GetPasswordExceptionsList(base::Bind(
|
| + &PasswordsPrivateGetPasswordExceptionListFunction::GotList, this));
|
| +}
|
| +
|
| +void PasswordsPrivateGetPasswordExceptionListFunction::GotList(
|
| + const PasswordsPrivateDelegate::ExceptionPairs& list) {
|
| + Respond(ArgumentList(
|
| + api::passwords_private::GetPasswordExceptionList::Results::Create(list)));
|
| }
|
|
|
| } // namespace extensions
|
|
|