OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/chromeos/extensions/quick_unlock_private/quick_unlock_p
rivate_api.h" | 5 #include "chrome/browser/chromeos/extensions/quick_unlock_private/quick_unlock_p
rivate_api.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/stl_util.h" |
8 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" | 9 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_factory.h" |
9 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" | 10 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_storage.h" |
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 11 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
11 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
12 #include "chromeos/login/auth/extended_authenticator.h" | 13 #include "chromeos/login/auth/extended_authenticator.h" |
13 #include "chromeos/login/auth/user_context.h" | 14 #include "chromeos/login/auth/user_context.h" |
14 #include "components/prefs/pref_service.h" | 15 #include "components/prefs/pref_service.h" |
15 #include "extensions/browser/event_router.h" | 16 #include "extensions/browser/event_router.h" |
16 | 17 |
17 namespace extensions { | 18 namespace extensions { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 // Returns true if |a| and |b| contain the same elements. The elements do not | 61 // Returns true if |a| and |b| contain the same elements. The elements do not |
61 // need to be in the same order. | 62 // need to be in the same order. |
62 bool AreModesEqual(const QuickUnlockModeList& a, const QuickUnlockModeList& b) { | 63 bool AreModesEqual(const QuickUnlockModeList& a, const QuickUnlockModeList& b) { |
63 if (a.size() != b.size()) | 64 if (a.size() != b.size()) |
64 return false; | 65 return false; |
65 | 66 |
66 // This is a slow comparison algorithm, but the number of entries in |a| and | 67 // This is a slow comparison algorithm, but the number of entries in |a| and |
67 // |b| will always be very low (0-3 items) so it doesn't matter. | 68 // |b| will always be very low (0-3 items) so it doesn't matter. |
68 for (size_t i = 0; i < a.size(); ++i) { | 69 for (size_t i = 0; i < a.size(); ++i) { |
69 if (std::find(b.begin(), b.end(), a[i]) == b.end()) | 70 if (!base::ContainsValue(b, a[i])) |
70 return false; | 71 return false; |
71 } | 72 } |
72 | 73 |
73 return true; | 74 return true; |
74 } | 75 } |
75 | 76 |
76 bool IsPinNumeric(const std::string& pin) { | 77 bool IsPinNumeric(const std::string& pin) { |
77 return std::all_of(pin.begin(), pin.end(), ::isdigit); | 78 return std::all_of(pin.begin(), pin.end(), ::isdigit); |
78 } | 79 } |
79 | 80 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 } | 423 } |
423 | 424 |
424 std::unique_ptr<base::ListValue> args = OnActiveModesChanged::Create(modes); | 425 std::unique_ptr<base::ListValue> args = OnActiveModesChanged::Create(modes); |
425 std::unique_ptr<Event> event( | 426 std::unique_ptr<Event> event( |
426 new Event(events::QUICK_UNLOCK_PRIVATE_ON_ACTIVE_MODES_CHANGED, | 427 new Event(events::QUICK_UNLOCK_PRIVATE_ON_ACTIVE_MODES_CHANGED, |
427 OnActiveModesChanged::kEventName, std::move(args))); | 428 OnActiveModesChanged::kEventName, std::move(args))); |
428 EventRouter::Get(browser_context())->BroadcastEvent(std::move(event)); | 429 EventRouter::Get(browser_context())->BroadcastEvent(std::move(event)); |
429 } | 430 } |
430 | 431 |
431 } // namespace extensions | 432 } // namespace extensions |
OLD | NEW |