OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ | 5 #ifndef COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ |
6 #define COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ | 6 #define COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <string> | |
9 #include <vector> | 10 #include <vector> |
10 | 11 |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/task_runner.h" | 14 #include "base/task_runner.h" |
14 #include "base/threading/thread_checker.h" | 15 #include "base/threading/thread_checker.h" |
16 #include "components/prefs/pref_member.h" | |
15 #include "components/signin/core/account_id/account_id.h" | 17 #include "components/signin/core/account_id/account_id.h" |
16 | 18 |
17 namespace arc { | 19 namespace arc { |
18 | 20 |
19 class ArcBridgeService; | 21 class ArcBridgeService; |
20 class ArcService; | 22 class ArcService; |
23 class ArcUserDataService; | |
21 | 24 |
22 // Manages creation and destruction of services that communicate with the ARC | 25 // Manages creation and destruction of services that communicate with the ARC |
23 // instance via the ArcBridgeService. | 26 // instance via the ArcBridgeService. |
24 class ArcServiceManager { | 27 class ArcServiceManager { |
25 public: | 28 public: |
26 explicit ArcServiceManager( | 29 explicit ArcServiceManager( |
27 scoped_refptr<base::TaskRunner> blocking_task_runner); | 30 scoped_refptr<base::TaskRunner> blocking_task_runner); |
28 virtual ~ArcServiceManager(); | 31 virtual ~ArcServiceManager(); |
29 | 32 |
30 // |arc_bridge_service| can only be accessed on the thread that this | 33 // |arc_bridge_service| can only be accessed on the thread that this |
31 // class was created on. | 34 // class was created on. |
32 ArcBridgeService* arc_bridge_service(); | 35 ArcBridgeService* arc_bridge_service(); |
33 | 36 |
34 // Adds a service to the managed services list. | 37 // Adds a service to the managed services list. |
35 void AddService(std::unique_ptr<ArcService> service); | 38 void AddService(std::unique_ptr<ArcService> service); |
36 | 39 |
37 // Gets the global instance of the ARC Service Manager. This can only be | 40 // Gets the global instance of the ARC Service Manager. This can only be |
38 // called on the thread that this class was created on. | 41 // called on the thread that this class was created on. |
39 static ArcServiceManager* Get(); | 42 static ArcServiceManager* Get(); |
40 | 43 |
41 // Called when the main profile is initialized after user logs in. | 44 // Called when the main profile is initialized after user logs in. |
42 void OnPrimaryUserProfilePrepared(const AccountId& account_id); | 45 void OnPrimaryUserProfilePrepared( |
46 const AccountId& account_id, | |
47 std::unique_ptr<BooleanPrefMember> arc_enabled_pref); | |
48 | |
49 // Has the user enabled arc in their preferences? | |
Daniel Erat
2016/05/24 16:00:01
nit: s/arc/ARC/
dspaid
2016/05/25 00:06:48
Done.
| |
50 bool IsArcEnabled() const; | |
43 | 51 |
44 // Called once the windowing system (ash) has been started. | 52 // Called once the windowing system (ash) has been started. |
45 void OnAshStarted(); | 53 void OnAshStarted(); |
46 | 54 |
47 // Called to shut down all ARC services. | 55 // Called to shut down all ARC services. |
48 void Shutdown(); | 56 void Shutdown(); |
49 | 57 |
50 scoped_refptr<base::TaskRunner> blocking_task_runner() const { | 58 scoped_refptr<base::TaskRunner> blocking_task_runner() const { |
51 return blocking_task_runner_; | 59 return blocking_task_runner_; |
52 } | 60 } |
53 | 61 |
54 // Set ArcBridgeService instance for testing. Call before ArcServiceManager | 62 // Set ArcBridgeService instance for testing. Call before ArcServiceManager |
55 // creation. ArcServiceManager owns |arc_bridge_service|. | 63 // creation. ArcServiceManager owns |arc_bridge_service|. |
56 static void SetArcBridgeServiceForTesting( | 64 static void SetArcBridgeServiceForTesting( |
57 std::unique_ptr<ArcBridgeService> arc_bridge_service); | 65 std::unique_ptr<ArcBridgeService> arc_bridge_service); |
58 | 66 |
59 private: | 67 private: |
60 base::ThreadChecker thread_checker_; | 68 base::ThreadChecker thread_checker_; |
61 scoped_refptr<base::TaskRunner> blocking_task_runner_; | 69 scoped_refptr<base::TaskRunner> blocking_task_runner_; |
62 | 70 |
63 std::unique_ptr<ArcBridgeService> arc_bridge_service_; | 71 std::unique_ptr<ArcBridgeService> arc_bridge_service_; |
64 std::vector<std::unique_ptr<ArcService>> services_; | 72 std::vector<std::unique_ptr<ArcService>> services_; |
73 std::unique_ptr<ArcUserDataService> arc_user_data_service_; | |
65 | 74 |
66 // True once the window manager service got added, barring adding any more | 75 // True once the window manager service got added, barring adding any more |
67 // of those since OnAshStarted() might be called multiple times. | 76 // of those since OnAshStarted() might be called multiple times. |
68 bool on_ash_started_called_ = false; | 77 bool on_ash_started_called_ = false; |
69 | 78 |
79 // User preference indicating whether or not arc has been enabled. | |
Daniel Erat
2016/05/24 16:00:01
nit: s/arc/ARC/
dspaid
2016/05/25 00:06:48
Done.
| |
80 std::unique_ptr<BooleanPrefMember> arc_enabled_pref_; | |
81 | |
70 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); | 82 DISALLOW_COPY_AND_ASSIGN(ArcServiceManager); |
71 }; | 83 }; |
72 | 84 |
73 } // namespace arc | 85 } // namespace arc |
74 | 86 |
75 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ | 87 #endif // COMPONENTS_ARC_ARC_SERVICE_MANAGER_H_ |
OLD | NEW |