OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ui/webui/settings/chromeos/fingerprint_handler.h" | 5 #include "chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/stl_util.h" |
11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
12 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
17 #include "chrome/grit/generated_resources.h" | 18 #include "chrome/grit/generated_resources.h" |
18 #include "components/prefs/pref_service.h" | 19 #include "components/prefs/pref_service.h" |
19 #include "components/session_manager/core/session_manager.h" | 20 #include "components/session_manager/core/session_manager.h" |
20 #include "content/public/common/service_manager_connection.h" | 21 #include "content/public/common/service_manager_connection.h" |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 ResolveJavascriptCallback(base::Value(callback_id), | 215 ResolveJavascriptCallback(base::Value(callback_id), |
215 base::Value(fingerprints_num)); | 216 base::Value(fingerprints_num)); |
216 } | 217 } |
217 | 218 |
218 void FingerprintHandler::HandleStartEnroll(const base::ListValue* args) { | 219 void FingerprintHandler::HandleStartEnroll(const base::ListValue* args) { |
219 // Determines what the newly added fingerprint's name should be. | 220 // Determines what the newly added fingerprint's name should be. |
220 for (int i = 1; i <= kMaxAllowedFingerprints; ++i) { | 221 for (int i = 1; i <= kMaxAllowedFingerprints; ++i) { |
221 std::string fingerprint_name = l10n_util::GetStringFUTF8( | 222 std::string fingerprint_name = l10n_util::GetStringFUTF8( |
222 IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME, | 223 IDS_SETTINGS_PEOPLE_LOCK_SCREEN_NEW_FINGERPRINT_DEFAULT_NAME, |
223 base::IntToString16(i)); | 224 base::IntToString16(i)); |
224 if (std::find(fingerprints_labels_.begin(), fingerprints_labels_.end(), | 225 if (!base::ContainsValue(fingerprints_labels_, fingerprint_name)) { |
225 fingerprint_name) == fingerprints_labels_.end()) { | |
226 fp_service_->StartEnrollSession(user_id_, fingerprint_name); | 226 fp_service_->StartEnrollSession(user_id_, fingerprint_name); |
227 break; | 227 break; |
228 } | 228 } |
229 } | 229 } |
230 } | 230 } |
231 | 231 |
232 void FingerprintHandler::HandleCancelCurrentEnroll( | 232 void FingerprintHandler::HandleCancelCurrentEnroll( |
233 const base::ListValue* args) { | 233 const base::ListValue* args) { |
234 fp_service_->CancelCurrentEnrollSession( | 234 fp_service_->CancelCurrentEnrollSession( |
235 base::Bind(&FingerprintHandler::OnCancelCurrentEnrollSession, | 235 base::Bind(&FingerprintHandler::OnCancelCurrentEnrollSession, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 weak_ptr_factory_.GetWeakPtr())); | 320 weak_ptr_factory_.GetWeakPtr())); |
321 } | 321 } |
322 | 322 |
323 void FingerprintHandler::OnEndCurrentAuthSession(bool success) { | 323 void FingerprintHandler::OnEndCurrentAuthSession(bool success) { |
324 if (!success) | 324 if (!success) |
325 LOG(ERROR) << "Failed to end current fingerprint authentication session."; | 325 LOG(ERROR) << "Failed to end current fingerprint authentication session."; |
326 } | 326 } |
327 | 327 |
328 } // namespace settings | 328 } // namespace settings |
329 } // namespace chromeos | 329 } // namespace chromeos |
OLD | NEW |