Chromium Code Reviews| 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..520fafaa618c866325fba9c563aa4003159146f0 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,25 @@ 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, |
|
Devlin
2016/11/01 00:09:57
Is this git cl formatted?
Dan Beam
2016/11/01 21:08:25
is now
|
| + 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 +126,28 @@ 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( |
| + delegate->GetPasswordExceptionsList( |
| + base::Bind(&PasswordsPrivateGetPasswordExceptionListFunction::GotList, |
| + this)); |
| +} |
| + |
| +void PasswordsPrivateGetPasswordExceptionListFunction::GotList( |
| + const PasswordsPrivateDelegate::ExceptionPairs* list) { |
| + Respond(ArgumentList( |
| api::passwords_private::GetPasswordExceptionList::Results::Create( |
| - *(delegate->GetPasswordExceptionsList())))); |
| + *list))); |
| } |
| } // namespace extensions |