| 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 "chrome/browser/signin/easy_unlock_auth_attempt.h" | 5 #include "chrome/browser/signin/easy_unlock_auth_attempt.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/signin/easy_unlock_app_manager.h" | 10 #include "chrome/browser/signin/easy_unlock_app_manager.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 proximity_auth::ScreenlockBridge::Get()->lock_handler()->GetAuthType( | 111 proximity_auth::ScreenlockBridge::Get()->lock_handler()->GetAuthType( |
| 112 user_id_); | 112 user_id_); |
| 113 | 113 |
| 114 if (auth_type != proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK) { | 114 if (auth_type != proximity_auth::ScreenlockBridge::LockHandler::USER_CLICK) { |
| 115 Cancel(user_id_); | 115 Cancel(user_id_); |
| 116 return false; | 116 return false; |
| 117 } | 117 } |
| 118 | 118 |
| 119 state_ = STATE_RUNNING; | 119 state_ = STATE_RUNNING; |
| 120 | 120 |
| 121 if (!app_manager_->SendAuthAttemptEvent()) { | 121 // We need this workaround for ProximityAuthBleSystem, which is already |
| 122 // notified in EasyUnlockService. No notification is sent when only the |
| 123 // |kEnableBluetoothLowEnergyDiscovery| flag is set, and |
| 124 // |app_manager_->SendAuthAttemptEvent()| returns false. As a result, the auth |
| 125 // attempt will always fail. |
| 126 // TODO(sacomoto): Remove this when it's not needed anymore. |
| 127 if (!app_manager_->SendAuthAttemptEvent() && |
| 128 !base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 129 proximity_auth::switches::kEnableBluetoothLowEnergyDiscovery)) { |
| 122 Cancel(user_id_); | 130 Cancel(user_id_); |
| 123 return false; | 131 return false; |
| 124 } | 132 } |
| 125 | 133 |
| 126 return true; | 134 return true; |
| 127 } | 135 } |
| 128 | 136 |
| 129 void EasyUnlockAuthAttempt::FinalizeUnlock(const std::string& user_id, | 137 void EasyUnlockAuthAttempt::FinalizeUnlock(const std::string& user_id, |
| 130 bool success) { | 138 bool success) { |
| 131 if (state_ != STATE_RUNNING || user_id != user_id_) | 139 if (state_ != STATE_RUNNING || user_id != user_id_) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 state_ = STATE_DONE; | 184 state_ = STATE_DONE; |
| 177 } | 185 } |
| 178 | 186 |
| 179 void EasyUnlockAuthAttempt::Cancel(const std::string& user_id) { | 187 void EasyUnlockAuthAttempt::Cancel(const std::string& user_id) { |
| 180 state_ = STATE_DONE; | 188 state_ = STATE_DONE; |
| 181 | 189 |
| 182 const bool kFailure = false; | 190 const bool kFailure = false; |
| 183 finalized_callback_.Run(type_, kFailure, user_id, std::string(), | 191 finalized_callback_.Run(type_, kFailure, user_id, std::string(), |
| 184 std::string()); | 192 std::string()); |
| 185 } | 193 } |
| OLD | NEW |