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 "components/proximity_auth/webui/reachable_phone_flow.h" | 5 #include "components/proximity_auth/webui/reachable_phone_flow.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
| 12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
| 13 #include "components/cryptauth/cryptauth_client.h" | 13 #include "components/cryptauth/cryptauth_client.h" |
| 14 #include "components/cryptauth/proto/cryptauth_api.pb.h" | 14 #include "components/cryptauth/proto/cryptauth_api.pb.h" |
| 15 #include "components/proximity_auth/logging/logging.h" | 15 #include "components/proximity_auth/logging/logging.h" |
| 16 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 16 | 17 |
| 17 namespace proximity_auth { | 18 namespace proximity_auth { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // The time, in milliseconds, to wait for phones to respond to the CryptAuth | 22 // The time, in milliseconds, to wait for phones to respond to the CryptAuth |
| 22 // ping before querying for reachable devices. | 23 // ping before querying for reachable devices. |
| 23 const int kWaitTimeMillis = 7000; | 24 const int kWaitTimeMillis = 7000; |
| 24 | 25 |
| 25 } // namespace | 26 } // namespace |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 36 callback.Run(std::vector<cryptauth::ExternalDeviceInfo>()); | 37 callback.Run(std::vector<cryptauth::ExternalDeviceInfo>()); |
| 37 return; | 38 return; |
| 38 } | 39 } |
| 39 | 40 |
| 40 callback_ = callback; | 41 callback_ = callback; |
| 41 client_ = client_factory_->CreateInstance(); | 42 client_ = client_factory_->CreateInstance(); |
| 42 | 43 |
| 43 // Ping the user's devices to update themselves with CryptAuth. | 44 // Ping the user's devices to update themselves with CryptAuth. |
| 44 cryptauth::SendDeviceSyncTickleRequest tickle_request; | 45 cryptauth::SendDeviceSyncTickleRequest tickle_request; |
| 45 tickle_request.set_tickle_type(cryptauth::UPDATE_ENROLLMENT); | 46 tickle_request.set_tickle_type(cryptauth::UPDATE_ENROLLMENT); |
| 47 net::PartialNetworkTrafficAnnotationTag partial_traffic_annotation = | |
| 48 net::DefinePartialNetworkTrafficAnnotation("...", "oauth2_api_call_flow", | |
|
sacomoto
2017/06/19 18:25:39
cryptauth_device_sync_tickle
Ramin Halavati
2017/06/20 05:35:34
Done.
| |
| 49 R"( | |
| 50 semantics { | |
| 51 sender: "..." | |
|
sacomoto
2017/06/19 18:25:39
EasyUnlock Debug UI
Ramin Halavati
2017/06/20 05:35:34
Done.
| |
| 52 description: "..." | |
|
sacomoto
2017/06/19 18:25:39
Triggers a sync on all other device (for the same
Ramin Halavati
2017/06/20 05:35:34
Done.
| |
| 53 trigger: "..." | |
|
sacomoto
2017/06/19 18:25:39
User manually open the EasyUnlock debug UI.
Ramin Halavati
2017/06/20 05:35:34
Done.
| |
| 54 data: "..." | |
|
sacomoto
2017/06/19 18:25:39
The device public key.
Ramin Halavati
2017/06/20 05:35:34
Done.
| |
| 55 destination: GOOGLE_OWNED_SERVICE | |
| 56 } | |
| 57 policy { | |
| 58 setting: "..." | |
|
sacomoto
2017/06/19 18:25:39
This feature cannot be disabled in settings, but t
Ramin Halavati
2017/06/20 05:35:34
Done.
| |
| 59 chrome_policy { | |
| 60 [POLICY_NAME] { | |
|
sacomoto
2017/06/19 18:25:38
SigninAllowed
Ramin Halavati
2017/06/20 05:35:34
Done.
| |
| 61 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 62 [POLICY_NAME]: ... //(value to disable it) | |
|
sacomoto
2017/06/19 18:25:39
SigninAllowed: false
Ramin Halavati
2017/06/20 05:35:34
Done.
| |
| 63 } | |
| 64 } | |
| 65 policy_exception_justification: "..." | |
| 66 })"); | |
| 46 client_->SendDeviceSyncTickle( | 67 client_->SendDeviceSyncTickle( |
| 47 tickle_request, base::Bind(&ReachablePhoneFlow::OnSyncTickleSuccess, | 68 tickle_request, |
| 48 weak_ptr_factory_.GetWeakPtr()), | 69 base::Bind(&ReachablePhoneFlow::OnSyncTickleSuccess, |
| 70 weak_ptr_factory_.GetWeakPtr()), | |
| 49 base::Bind(&ReachablePhoneFlow::OnApiCallError, | 71 base::Bind(&ReachablePhoneFlow::OnApiCallError, |
| 50 weak_ptr_factory_.GetWeakPtr())); | 72 weak_ptr_factory_.GetWeakPtr()), |
| 73 partial_traffic_annotation); | |
| 51 } | 74 } |
| 52 | 75 |
| 53 void ReachablePhoneFlow::OnSyncTickleSuccess( | 76 void ReachablePhoneFlow::OnSyncTickleSuccess( |
| 54 const cryptauth::SendDeviceSyncTickleResponse& response) { | 77 const cryptauth::SendDeviceSyncTickleResponse& response) { |
| 55 PA_LOG(INFO) << "Waiting " << kWaitTimeMillis | 78 PA_LOG(INFO) << "Waiting " << kWaitTimeMillis |
| 56 << "ms for phones to callback to CryptAuth..."; | 79 << "ms for phones to callback to CryptAuth..."; |
| 57 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 80 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 58 FROM_HERE, base::Bind(&ReachablePhoneFlow::QueryReachablePhones, | 81 FROM_HERE, base::Bind(&ReachablePhoneFlow::QueryReachablePhones, |
| 59 weak_ptr_factory_.GetWeakPtr()), | 82 weak_ptr_factory_.GetWeakPtr()), |
| 60 base::TimeDelta::FromMilliseconds(kWaitTimeMillis)); | 83 base::TimeDelta::FromMilliseconds(kWaitTimeMillis)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 84 response.eligible_devices().end(), reachable_phones.begin()); | 107 response.eligible_devices().end(), reachable_phones.begin()); |
| 85 callback_.Run(reachable_phones); | 108 callback_.Run(reachable_phones); |
| 86 } | 109 } |
| 87 | 110 |
| 88 void ReachablePhoneFlow::OnApiCallError(const std::string& error) { | 111 void ReachablePhoneFlow::OnApiCallError(const std::string& error) { |
| 89 PA_LOG(ERROR) << "Error making api call: " << error; | 112 PA_LOG(ERROR) << "Error making api call: " << error; |
| 90 callback_.Run(std::vector<cryptauth::ExternalDeviceInfo>()); | 113 callback_.Run(std::vector<cryptauth::ExternalDeviceInfo>()); |
| 91 } | 114 } |
| 92 | 115 |
| 93 } // namespace proximity_auth | 116 } // namespace proximity_auth |
| OLD | NEW |