OLD | NEW |
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 <stdint.h> |
| 6 |
5 #include "components/password_manager/content/common/credential_manager_messages
.h" | 7 #include "components/password_manager/content/common/credential_manager_messages
.h" |
6 #include "components/password_manager/content/renderer/credential_manager_client
.h" | 8 #include "components/password_manager/content/renderer/credential_manager_client
.h" |
7 #include "content/public/test/render_view_test.h" | 9 #include "content/public/test/render_view_test.h" |
8 #include "ipc/ipc_test_sink.h" | 10 #include "ipc/ipc_test_sink.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "third_party/WebKit/public/platform/WebCredential.h" | 12 #include "third_party/WebKit/public/platform/WebCredential.h" |
11 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" | 13 #include "third_party/WebKit/public/platform/WebCredentialManagerClient.h" |
12 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" | 14 #include "third_party/WebKit/public/platform/WebCredentialManagerError.h" |
13 #include "third_party/WebKit/public/platform/WebPassOwnPtr.h" | 15 #include "third_party/WebKit/public/platform/WebPassOwnPtr.h" |
14 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" | 16 #include "third_party/WebKit/public/platform/WebPasswordCredential.h" |
(...skipping 24 matching lines...) Expand all Loading... |
39 | 41 |
40 blink::WebCredential* credential() { return credential_.get(); } | 42 blink::WebCredential* credential() { return credential_.get(); } |
41 | 43 |
42 // The browser's response to any of the messages the client sends must contain | 44 // The browser's response to any of the messages the client sends must contain |
43 // a request ID so that the client knows which request is being serviced. This | 45 // a request ID so that the client knows which request is being serviced. This |
44 // method grabs the ID from an outgoing |message_id| message, and sets the | 46 // method grabs the ID from an outgoing |message_id| message, and sets the |
45 // |request_id| param to its value. If no request ID can be found, the method | 47 // |request_id| param to its value. If no request ID can be found, the method |
46 // returns false, and the |request_id| is set to -1. | 48 // returns false, and the |request_id| is set to -1. |
47 // | 49 // |
48 // Clears any pending messages upon return. | 50 // Clears any pending messages upon return. |
49 bool ExtractRequestId(uint32 message_id, int& request_id) { | 51 bool ExtractRequestId(uint32_t message_id, int& request_id) { |
50 request_id = -1; | 52 request_id = -1; |
51 const IPC::Message* message = sink().GetFirstMessageMatching(message_id); | 53 const IPC::Message* message = sink().GetFirstMessageMatching(message_id); |
52 if (!message) | 54 if (!message) |
53 return false; | 55 return false; |
54 | 56 |
55 switch (message_id) { | 57 switch (message_id) { |
56 case CredentialManagerHostMsg_Store::ID: { | 58 case CredentialManagerHostMsg_Store::ID: { |
57 base::Tuple<int, CredentialInfo> param; | 59 base::Tuple<int, CredentialInfo> param; |
58 CredentialManagerHostMsg_Store::Read(message, ¶m); | 60 CredentialManagerHostMsg_Store::Read(message, ¶m); |
59 request_id = base::get<0>(param); | 61 request_id = base::get<0>(param); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, | 206 EXPECT_TRUE(ExtractRequestId(CredentialManagerHostMsg_RequestCredential::ID, |
205 request_id)); | 207 request_id)); |
206 | 208 |
207 CredentialInfo info; // Send an empty credential in response. | 209 CredentialInfo info; // Send an empty credential in response. |
208 client_->OnSendCredential(request_id, info); | 210 client_->OnSendCredential(request_id, info); |
209 EXPECT_TRUE(callback_succeeded()); | 211 EXPECT_TRUE(callback_succeeded()); |
210 EXPECT_FALSE(callback_errored()); | 212 EXPECT_FALSE(callback_errored()); |
211 } | 213 } |
212 | 214 |
213 } // namespace password_manager | 215 } // namespace password_manager |
OLD | NEW |