Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(863)

Side by Side Diff: chrome/browser/extensions/api/passwords_private/passwords_private_api.cc

Issue 2468763002: MD Settings: fix chrome.passwordsPrivate empty list bug (Closed)
Patch Set: git cl format + compile + const ref + bool rename Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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(
103 FROM_HERE,
104 base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GetList, this));
105 return RespondLater();
106 }
107
108 void PasswordsPrivateGetSavedPasswordListFunction::GetList() {
96 PasswordsPrivateDelegate* delegate = 109 PasswordsPrivateDelegate* delegate =
97 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), 110 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(),
98 true /* create */); 111 true /* create */);
99 return RespondNow(ArgumentList( 112 delegate->GetSavedPasswordsList(
100 api::passwords_private::GetSavedPasswordList::Results::Create( 113 base::Bind(&PasswordsPrivateGetSavedPasswordListFunction::GotList, this));
101 *(delegate->GetSavedPasswordsList())))); 114 }
115
116 void PasswordsPrivateGetSavedPasswordListFunction::GotList(
117 const PasswordsPrivateDelegate::UiEntries& list) {
118 Respond(ArgumentList(
119 api::passwords_private::GetSavedPasswordList::Results::Create(list)));
102 } 120 }
103 121
104 //////////////////////////////////////////////////////////////////////////////// 122 ////////////////////////////////////////////////////////////////////////////////
105 // PasswordsPrivateGetPasswordExceptionListFunction 123 // PasswordsPrivateGetPasswordExceptionListFunction
106 124
107 PasswordsPrivateGetPasswordExceptionListFunction:: 125 PasswordsPrivateGetPasswordExceptionListFunction::
108 ~PasswordsPrivateGetPasswordExceptionListFunction() {} 126 ~PasswordsPrivateGetPasswordExceptionListFunction() {}
109 127
110 ExtensionFunction::ResponseAction 128 ExtensionFunction::ResponseAction
111 PasswordsPrivateGetPasswordExceptionListFunction::Run() { 129 PasswordsPrivateGetPasswordExceptionListFunction::Run() {
130 // GetList() can immediately call GotList() (which would Respond() before
131 // RespondLater()). So we post a task to preserve order.
132 base::ThreadTaskRunnerHandle::Get()->PostTask(
133 FROM_HERE,
134 base::Bind(&PasswordsPrivateGetPasswordExceptionListFunction::GetList,
135 this));
136 return RespondLater();
137 }
138
139 void PasswordsPrivateGetPasswordExceptionListFunction::GetList() {
112 PasswordsPrivateDelegate* delegate = 140 PasswordsPrivateDelegate* delegate =
113 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(), 141 PasswordsPrivateDelegateFactory::GetForBrowserContext(browser_context(),
114 true /* create */); 142 true /* create */);
115 return RespondNow(ArgumentList( 143 delegate->GetPasswordExceptionsList(base::Bind(
116 api::passwords_private::GetPasswordExceptionList::Results::Create( 144 &PasswordsPrivateGetPasswordExceptionListFunction::GotList, this));
117 *(delegate->GetPasswordExceptionsList())))); 145 }
146
147 void PasswordsPrivateGetPasswordExceptionListFunction::GotList(
148 const PasswordsPrivateDelegate::ExceptionPairs& list) {
149 Respond(ArgumentList(
150 api::passwords_private::GetPasswordExceptionList::Results::Create(list)));
118 } 151 }
119 152
120 } // namespace extensions 153 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698