Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/fingerprint_handler.cc

Issue 2947593005: Use ContainsValue() instead of std::find() in chrome/browser/ui/ (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_strip.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698