Chromium Code Reviews| 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" | |
| 8 #include "base/bind_helpers.h" | |
| 9 #include "base/location.h" | |
| 10 #include "base/threading/thread_task_runner_handle.h" | |
| 7 #include "base/values.h" | 11 #include "base/values.h" |
| 8 #include "chrome/browser/extensions/api/passwords_private/passwords_private_dele gate_factory.h" | 12 #include "chrome/browser/extensions/api/passwords_private/passwords_private_dele gate_factory.h" |
| 9 #include "chrome/common/extensions/api/passwords_private.h" | 13 #include "chrome/common/extensions/api/passwords_private.h" |
| 10 #include "components/password_manager/core/common/experiments.h" | 14 #include "components/password_manager/core/common/experiments.h" |
| 11 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
| 12 #include "extensions/browser/extension_function_registry.h" | 16 #include "extensions/browser/extension_function_registry.h" |
| 13 | 17 |
| 14 namespace extensions { | 18 namespace extensions { |
| 15 | 19 |
| 16 //////////////////////////////////////////////////////////////////////////////// | 20 //////////////////////////////////////////////////////////////////////////////// |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 86 } | 90 } |
| 87 | 91 |
| 88 //////////////////////////////////////////////////////////////////////////////// | 92 //////////////////////////////////////////////////////////////////////////////// |
| 89 // PasswordsPrivateGetSavedPasswordListFunction | 93 // PasswordsPrivateGetSavedPasswordListFunction |
| 90 | 94 |
| 91 PasswordsPrivateGetSavedPasswordListFunction:: | 95 PasswordsPrivateGetSavedPasswordListFunction:: |
| 92 ~PasswordsPrivateGetSavedPasswordListFunction() {} | 96 ~PasswordsPrivateGetSavedPasswordListFunction() {} |
| 93 | 97 |
| 94 ExtensionFunction::ResponseAction | 98 ExtensionFunction::ResponseAction |
| 95 PasswordsPrivateGetSavedPasswordListFunction::Run() { | 99 PasswordsPrivateGetSavedPasswordListFunction::Run() { |
| 100 // GetList() can immediately call GotList() (which would Respond() before | |
| 101 // RespondLater()). So we post a task to preserve order. | |
| 102 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
| |
| 103 base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GetList, this)); | |
| 104 return RespondLater(); | |
| 105 } | |
| 106 | |
| 107 void PasswordsPrivateGetSavedPasswordListFunction::GetList() { | |
| 96 PasswordsPrivateDelegate* delegate = | 108 PasswordsPrivateDelegate* delegate = |
| 97 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), | 109 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), |
| 98 true /* create */); | 110 true /* create */); |
| 99 return RespondNow(ArgumentList( | 111 delegate->GetSavedPasswordsList( |
| 100 api::passwords_private::GetSavedPasswordList::Results::Create( | 112 base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GotList, this)); |
| 101 *(delegate->GetSavedPasswordsList())))); | 113 } |
| 114 | |
| 115 void PasswordsPrivateGetSavedPasswordListFunction::GotList( | |
| 116 const PasswordsPrivateDelegate::UiEntries* list) { | |
| 117 Respond(ArgumentList( | |
| 118 api::passwords_private::GetSavedPasswordList::Results::Create(*list))); | |
| 102 } | 119 } |
| 103 | 120 |
| 104 //////////////////////////////////////////////////////////////////////////////// | 121 //////////////////////////////////////////////////////////////////////////////// |
| 105 // PasswordsPrivateGetPasswordExceptionListFunction | 122 // PasswordsPrivateGetPasswordExceptionListFunction |
| 106 | 123 |
| 107 PasswordsPrivateGetPasswordExceptionListFunction:: | 124 PasswordsPrivateGetPasswordExceptionListFunction:: |
| 108 ~PasswordsPrivateGetPasswordExceptionListFunction() {} | 125 ~PasswordsPrivateGetPasswordExceptionListFunction() {} |
| 109 | 126 |
| 110 ExtensionFunction::ResponseAction | 127 ExtensionFunction::ResponseAction |
| 111 PasswordsPrivateGetPasswordExceptionListFunction::Run() { | 128 PasswordsPrivateGetPasswordExceptionListFunction::Run() { |
| 129 // GetList() can immediately call GotList() (which would Respond() before | |
| 130 // RespondLater()). So we post a task to preserve order. | |
| 131 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, | |
| 132 base::Bind(&PasswordsPrivateGetPasswordExceptionListFunction::GetList, | |
| 133 this)); | |
| 134 return RespondLater(); | |
| 135 } | |
| 136 | |
| 137 void PasswordsPrivateGetPasswordExceptionListFunction::GetList() { | |
| 112 PasswordsPrivateDelegate* delegate = | 138 PasswordsPrivateDelegate* delegate = |
| 113 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), | 139 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), |
| 114 true /* create */); | 140 true /* create */); |
| 115 return RespondNow(ArgumentList( | 141 delegate->GetPasswordExceptionsList( |
| 142 base::Bind(&PasswordsPrivateGetPasswordExceptionListFunction::GotList, | |
| 143 this)); | |
| 144 } | |
| 145 | |
| 146 void PasswordsPrivateGetPasswordExceptionListFunction::GotList( | |
| 147 const PasswordsPrivateDelegate::ExceptionPairs* list) { | |
| 148 Respond(ArgumentList( | |
| 116 api::passwords_private::GetPasswordExceptionList::Results::Create( | 149 api::passwords_private::GetPasswordExceptionList::Results::Create( |
| 117 *(delegate->GetPasswordExceptionsList())))); | 150 *list))); |
| 118 } | 151 } |
| 119 | 152 |
| 120 } // namespace extensions | 153 } // namespace extensions |
| OLD | NEW |