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

Side by Side Diff: components/password_manager/content/renderer/credential_manager_client_browsertest.cc

Issue 2867743002: Use OnceCallback on Mojo interfaces in //components/password_manager (Closed)
Patch Set: . Created 3 years, 7 months 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
« no previous file with comments | « components/password_manager/content/common/BUILD.gn ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/password_manager/content/renderer/credential_manager_client .h" 5 #include "components/password_manager/content/renderer/credential_manager_client .h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <tuple> 10 #include <tuple>
11 #include <utility>
11 12
12 #include "base/location.h" 13 #include "base/location.h"
13 #include "base/run_loop.h" 14 #include "base/run_loop.h"
14 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
15 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
16 #include "content/public/renderer/render_frame.h" 17 #include "content/public/renderer/render_frame.h"
17 #include "content/public/renderer/render_view.h" 18 #include "content/public/renderer/render_view.h"
18 #include "content/public/test/render_view_test.h" 19 #include "content/public/test/render_view_test.h"
19 #include "mojo/public/cpp/bindings/binding_set.h" 20 #include "mojo/public/cpp/bindings/binding_set.h"
20 #include "services/service_manager/public/cpp/interface_provider.h" 21 #include "services/service_manager/public/cpp/interface_provider.h"
(...skipping 16 matching lines...) Expand all
37 FakeCredentialManager() {} 38 FakeCredentialManager() {}
38 ~FakeCredentialManager() override {} 39 ~FakeCredentialManager() override {}
39 40
40 void BindRequest(mojom::CredentialManagerRequest request) { 41 void BindRequest(mojom::CredentialManagerRequest request) {
41 bindings_.AddBinding(this, std::move(request)); 42 bindings_.AddBinding(this, std::move(request));
42 } 43 }
43 44
44 private: 45 private:
45 // mojom::CredentialManager methods: 46 // mojom::CredentialManager methods:
46 void Store(const CredentialInfo& credential, 47 void Store(const CredentialInfo& credential,
47 const StoreCallback& callback) override { 48 StoreCallback callback) override {
48 callback.Run(); 49 std::move(callback).Run();
49 } 50 }
50 51
51 void RequireUserMediation( 52 void RequireUserMediation(RequireUserMediationCallback callback) override {
52 const RequireUserMediationCallback& callback) override { 53 std::move(callback).Run();
53 callback.Run();
54 } 54 }
55 55
56 void Get(bool zero_click_only, 56 void Get(bool zero_click_only,
57 bool include_passwords, 57 bool include_passwords,
58 const std::vector<GURL>& federations, 58 const std::vector<GURL>& federations,
59 const GetCallback& callback) override { 59 GetCallback callback) override {
60 const std::string& url = federations[0].spec(); 60 const std::string& url = federations[0].spec();
61 61
62 if (url == kTestCredentialPassword) { 62 if (url == kTestCredentialPassword) {
63 CredentialInfo info; 63 CredentialInfo info;
64 info.type = CredentialType::CREDENTIAL_TYPE_PASSWORD; 64 info.type = CredentialType::CREDENTIAL_TYPE_PASSWORD;
65 callback.Run(mojom::CredentialManagerError::SUCCESS, info); 65 std::move(callback).Run(mojom::CredentialManagerError::SUCCESS, info);
66 } else if (url == kTestCredentialEmpty) { 66 } else if (url == kTestCredentialEmpty) {
67 callback.Run(mojom::CredentialManagerError::SUCCESS, CredentialInfo()); 67 std::move(callback).Run(mojom::CredentialManagerError::SUCCESS,
68 CredentialInfo());
68 } else if (url == kTestCredentialReject) { 69 } else if (url == kTestCredentialReject) {
69 callback.Run(mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE, 70 std::move(callback).Run(
70 base::nullopt); 71 mojom::CredentialManagerError::PASSWORDSTOREUNAVAILABLE,
72 base::nullopt);
71 } 73 }
72 } 74 }
73 75
74 mojo::BindingSet<mojom::CredentialManager> bindings_; 76 mojo::BindingSet<mojom::CredentialManager> bindings_;
75 }; 77 };
76 78
77 class CredentialManagerClientTest : public content::RenderViewTest { 79 class CredentialManagerClientTest : public content::RenderViewTest {
78 public: 80 public:
79 CredentialManagerClientTest() 81 CredentialManagerClientTest()
80 : callback_errored_(false), callback_succeeded_(false) {} 82 : callback_errored_(false), callback_succeeded_(false) {}
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 243
242 EXPECT_FALSE(callback_succeeded()); 244 EXPECT_FALSE(callback_succeeded());
243 EXPECT_TRUE(callback_errored()); 245 EXPECT_TRUE(callback_errored());
244 EXPECT_FALSE(credential_); 246 EXPECT_FALSE(credential_);
245 EXPECT_EQ(blink::WebCredentialManagerError:: 247 EXPECT_EQ(blink::WebCredentialManagerError::
246 kWebCredentialManagerPasswordStoreUnavailableError, 248 kWebCredentialManagerPasswordStoreUnavailableError,
247 error_); 249 error_);
248 } 250 }
249 251
250 } // namespace password_manager 252 } // namespace password_manager
OLDNEW
« no previous file with comments | « components/password_manager/content/common/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698