| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/test_runner/mock_credential_manager_client.h" | |
| 6 | |
| 7 #include <memory> | |
| 8 #include <utility> | |
| 9 | |
| 10 #include "third_party/WebKit/public/platform/WebCredential.h" | |
| 11 | |
| 12 namespace test_runner { | |
| 13 | |
| 14 MockCredentialManagerClient::MockCredentialManagerClient() | |
| 15 : error_(blink::WebCredentialManagerNoError) {} | |
| 16 | |
| 17 MockCredentialManagerClient::~MockCredentialManagerClient() { | |
| 18 } | |
| 19 | |
| 20 void MockCredentialManagerClient::SetResponse( | |
| 21 blink::WebCredential* credential) { | |
| 22 credential_.reset(credential); | |
| 23 } | |
| 24 | |
| 25 void MockCredentialManagerClient::SetError(const std::string& error) { | |
| 26 if (error == "pending") | |
| 27 error_ = blink::WebCredentialManagerPendingRequestError; | |
| 28 if (error == "disabled") | |
| 29 error_ = blink::WebCredentialManagerDisabledError; | |
| 30 if (error == "unknown") | |
| 31 error_ = blink::WebCredentialManagerUnknownError; | |
| 32 if (error.empty()) | |
| 33 error_ = blink::WebCredentialManagerNoError; | |
| 34 } | |
| 35 | |
| 36 void MockCredentialManagerClient::dispatchStore( | |
| 37 const blink::WebCredential&, | |
| 38 blink::WebCredentialManagerClient::NotificationCallbacks* callbacks) { | |
| 39 callbacks->onSuccess(); | |
| 40 delete callbacks; | |
| 41 } | |
| 42 | |
| 43 void MockCredentialManagerClient::dispatchRequireUserMediation( | |
| 44 NotificationCallbacks* callbacks) { | |
| 45 callbacks->onSuccess(); | |
| 46 delete callbacks; | |
| 47 } | |
| 48 | |
| 49 void MockCredentialManagerClient::dispatchGet( | |
| 50 bool zero_click_only, | |
| 51 bool include_passwords, | |
| 52 const blink::WebVector<blink::WebURL>& federations, | |
| 53 RequestCallbacks* callbacks) { | |
| 54 if (error_ != blink::WebCredentialManagerNoError) | |
| 55 callbacks->onError(error_); | |
| 56 else | |
| 57 callbacks->onSuccess(std::move(credential_)); | |
| 58 delete callbacks; | |
| 59 } | |
| 60 | |
| 61 } // namespace test_runner | |
| OLD | NEW |