Mattias Nissler | 04ef43e | 2019-06-14 12:52:36 | [diff] [blame] | 1 | // Copyright 2019 The Chromium Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #ifndef CHROME_BROWSER_CHROMEOS_U2F_NOTIFICATION_H_ |
| 6 | #define CHROME_BROWSER_CHROMEOS_U2F_NOTIFICATION_H_ |
| 7 | |
| 8 | #include <set> |
| 9 | #include <string> |
| 10 | |
| 11 | #include "base/macros.h" |
| 12 | #include "base/memory/weak_ptr.h" |
| 13 | #include "base/optional.h" |
| 14 | |
| 15 | namespace chromeos { |
| 16 | |
| 17 | // Detects whether the legacy, never-officially-launched built-in U2F feature is |
| 18 | // enabled. If so, shows a notification to tell the user about a security issue. |
| 19 | class U2FNotification { |
| 20 | public: |
| 21 | U2FNotification(); |
| 22 | ~U2FNotification(); |
| 23 | |
| 24 | // Asynchronously checks whether the legacy implementation is enabled and if |
| 25 | // so, displays a notification. |
| 26 | void Check(); |
| 27 | |
| 28 | private: |
| 29 | // Checks status given the current U2F flags. |
| 30 | void CheckStatus(base::Optional<std::set<std::string>> flags); |
| 31 | |
| 32 | // Shows the notification. |
| 33 | void ShowNotification(); |
| 34 | |
| 35 | // Handles clicks on the notification. |
| 36 | void OnNotificationClick(const base::Optional<int> button_index); |
| 37 | |
| 38 | base::WeakPtrFactory<U2FNotification> weak_factory_{this}; |
| 39 | |
| 40 | DISALLOW_COPY_AND_ASSIGN(U2FNotification); |
| 41 | }; |
| 42 | |
| 43 | } // namespace chromeos |
| 44 | |
| 45 | #endif // CHROME_BROWSER_CHROMEOS_U2F_NOTIFICATION_H_ |