| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/api/passwords_private/passwords_private_api.
h" | 5 #include "chrome/browser/extensions/api/passwords_private/passwords_private_api.
h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 PasswordsPrivateGetSavedPasswordListFunction:: | 95 PasswordsPrivateGetSavedPasswordListFunction:: |
| 96 ~PasswordsPrivateGetSavedPasswordListFunction() {} | 96 ~PasswordsPrivateGetSavedPasswordListFunction() {} |
| 97 | 97 |
| 98 ExtensionFunction::ResponseAction | 98 ExtensionFunction::ResponseAction |
| 99 PasswordsPrivateGetSavedPasswordListFunction::Run() { | 99 PasswordsPrivateGetSavedPasswordListFunction::Run() { |
| 100 // GetList() can immediately call GotList() (which would Respond() before | 100 // GetList() can immediately call GotList() (which would Respond() before |
| 101 // RespondLater()). So we post a task to preserve order. | 101 // RespondLater()). So we post a task to preserve order. |
| 102 base::ThreadTaskRunnerHandle::Get()->PostTask( | 102 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 103 FROM_HERE, | 103 FROM_HERE, |
| 104 base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GetList, this)); | 104 base::BindOnce(&PasswordsPrivateGetSavedPasswordListFunction::GetList, |
| 105 this)); |
| 105 return RespondLater(); | 106 return RespondLater(); |
| 106 } | 107 } |
| 107 | 108 |
| 108 void PasswordsPrivateGetSavedPasswordListFunction::GetList() { | 109 void PasswordsPrivateGetSavedPasswordListFunction::GetList() { |
| 109 PasswordsPrivateDelegate* delegate = | 110 PasswordsPrivateDelegate* delegate = |
| 110 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), | 111 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), |
| 111 true /* create */); | 112 true /* create */); |
| 112 delegate->GetSavedPasswordsList( | 113 delegate->GetSavedPasswordsList( |
| 113 base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GotList, this)); | 114 base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GotList, this)); |
| 114 } | 115 } |
| 115 | 116 |
| 116 void PasswordsPrivateGetSavedPasswordListFunction::GotList( | 117 void PasswordsPrivateGetSavedPasswordListFunction::GotList( |
| 117 const PasswordsPrivateDelegate::UiEntries& list) { | 118 const PasswordsPrivateDelegate::UiEntries& list) { |
| 118 Respond(ArgumentList( | 119 Respond(ArgumentList( |
| 119 api::passwords_private::GetSavedPasswordList::Results::Create(list))); | 120 api::passwords_private::GetSavedPasswordList::Results::Create(list))); |
| 120 } | 121 } |
| 121 | 122 |
| 122 //////////////////////////////////////////////////////////////////////////////// | 123 //////////////////////////////////////////////////////////////////////////////// |
| 123 // PasswordsPrivateGetPasswordExceptionListFunction | 124 // PasswordsPrivateGetPasswordExceptionListFunction |
| 124 | 125 |
| 125 PasswordsPrivateGetPasswordExceptionListFunction:: | 126 PasswordsPrivateGetPasswordExceptionListFunction:: |
| 126 ~PasswordsPrivateGetPasswordExceptionListFunction() {} | 127 ~PasswordsPrivateGetPasswordExceptionListFunction() {} |
| 127 | 128 |
| 128 ExtensionFunction::ResponseAction | 129 ExtensionFunction::ResponseAction |
| 129 PasswordsPrivateGetPasswordExceptionListFunction::Run() { | 130 PasswordsPrivateGetPasswordExceptionListFunction::Run() { |
| 130 // GetList() can immediately call GotList() (which would Respond() before | 131 // GetList() can immediately call GotList() (which would Respond() before |
| 131 // RespondLater()). So we post a task to preserve order. | 132 // RespondLater()). So we post a task to preserve order. |
| 132 base::ThreadTaskRunnerHandle::Get()->PostTask( | 133 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 133 FROM_HERE, | 134 FROM_HERE, |
| 134 base::Bind(&PasswordsPrivateGetPasswordExceptionListFunction::GetList, | 135 base::BindOnce(&PasswordsPrivateGetPasswordExceptionListFunction::GetList, |
| 135 this)); | 136 this)); |
| 136 return RespondLater(); | 137 return RespondLater(); |
| 137 } | 138 } |
| 138 | 139 |
| 139 void PasswordsPrivateGetPasswordExceptionListFunction::GetList() { | 140 void PasswordsPrivateGetPasswordExceptionListFunction::GetList() { |
| 140 PasswordsPrivateDelegate* delegate = | 141 PasswordsPrivateDelegate* delegate = |
| 141 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), | 142 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), |
| 142 true /* create */); | 143 true /* create */); |
| 143 delegate->GetPasswordExceptionsList(base::Bind( | 144 delegate->GetPasswordExceptionsList(base::Bind( |
| 144 &PasswordsPrivateGetPasswordExceptionListFunction::GotList, this)); | 145 &PasswordsPrivateGetPasswordExceptionListFunction::GotList, this)); |
| 145 } | 146 } |
| 146 | 147 |
| 147 void PasswordsPrivateGetPasswordExceptionListFunction::GotList( | 148 void PasswordsPrivateGetPasswordExceptionListFunction::GotList( |
| 148 const PasswordsPrivateDelegate::ExceptionPairs& list) { | 149 const PasswordsPrivateDelegate::ExceptionPairs& list) { |
| 149 Respond(ArgumentList( | 150 Respond(ArgumentList( |
| 150 api::passwords_private::GetPasswordExceptionList::Results::Create(list))); | 151 api::passwords_private::GetPasswordExceptionList::Results::Create(list))); |
| 151 } | 152 } |
| 152 | 153 |
| 153 } // namespace extensions | 154 } // namespace extensions |
| OLD | NEW |