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