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 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_SHORT_LIVED_USER_CONTEXT_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_SHORT_LIVED_USER_CONTEXT_H_ |
6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_SHORT_LIVED_USER_CONTEXT_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_SHORT_LIVED_USER_CONTEXT_H_ |
7 | 7 |
8 #include "apps/app_lifetime_monitor.h" | 8 #include "apps/app_lifetime_monitor.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
11 | 11 |
12 namespace base { | 12 namespace base { |
13 class TaskRunner; | 13 class TaskRunner; |
14 } | 14 } |
15 | 15 |
16 namespace chromeos { | 16 namespace chromeos { |
17 | 17 |
18 class UserContext; | 18 class UserContext; |
19 | 19 |
20 // Stores the UserContext of an authentication operation on the sign-in/lock | 20 // Stores the UserContext of an authentication operation on the sign-in/lock |
21 // screen, which is used to generate the keys for Easy Sign-in. | 21 // screen, which is used to generate the keys for Easy Sign-in. |
22 // The lifetime of the user context is bound the the setup app window. As a | 22 // The lifetime of the user context is bound the the setup app window. As a |
23 // fail-safe, the user context will also be deleted after a set period of time | 23 // fail-safe, the user context will also be deleted after a set period of time |
24 // in case the app is left open indefintely. | 24 // in case the app is left open indefintely. |
25 class ShortLivedUserContext : public apps::AppLifetimeMonitor::Observer { | 25 class ShortLivedUserContext : public apps::AppLifetimeMonitor::Observer { |
26 public: | 26 public: |
27 ShortLivedUserContext(const UserContext& user_context, | 27 ShortLivedUserContext(const UserContext& user_context, |
28 apps::AppLifetimeMonitor* app_lifetime_monitor, | 28 apps::AppLifetimeMonitor* app_lifetime_monitor, |
29 base::TaskRunner* task_runner); | 29 base::TaskRunner* task_runner); |
30 virtual ~ShortLivedUserContext(); | 30 ~ShortLivedUserContext() override; |
31 | 31 |
32 // The UserContext returned here can be NULL if its time-to-live has expired. | 32 // The UserContext returned here can be NULL if its time-to-live has expired. |
33 UserContext* user_context() { return user_context_.get(); } | 33 UserContext* user_context() { return user_context_.get(); } |
34 | 34 |
35 private: | 35 private: |
36 void Reset(); | 36 void Reset(); |
37 | 37 |
38 // apps::AppLifetimeMonitor::Observer: | 38 // apps::AppLifetimeMonitor::Observer: |
39 virtual void OnAppDeactivated(Profile* profile, | 39 void OnAppDeactivated(Profile* profile, const std::string& app_id) override; |
40 const std::string& app_id) override; | |
41 | 40 |
42 scoped_ptr<UserContext> user_context_; | 41 scoped_ptr<UserContext> user_context_; |
43 | 42 |
44 apps::AppLifetimeMonitor* app_lifetime_monitor_; | 43 apps::AppLifetimeMonitor* app_lifetime_monitor_; |
45 | 44 |
46 base::WeakPtrFactory<ShortLivedUserContext> weak_ptr_factory_; | 45 base::WeakPtrFactory<ShortLivedUserContext> weak_ptr_factory_; |
47 | 46 |
48 DISALLOW_COPY_AND_ASSIGN(ShortLivedUserContext); | 47 DISALLOW_COPY_AND_ASSIGN(ShortLivedUserContext); |
49 }; | 48 }; |
50 | 49 |
51 } // namespace chromeos | 50 } // namespace chromeos |
52 | 51 |
53 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_SHORT_LIVED_USER_CONTEXT_H_ | 52 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_EASY_UNLOCK_SHORT_LIVED_USER_CONTEXT_H_ |
OLD | NEW |