Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: components/arc/arc_bridge_service.h

Issue 1475563002: arc-bridge: Implement IPC message for app launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renaming and nits Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_BRIDGE_SERVICE_H_ 5 #ifndef COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 6 #define COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
7 7
8 #include "base/files/scoped_file.h" 8 #include "base/files/scoped_file.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 STARTING, 57 STARTING,
58 58
59 // The ARC instance has been fully initialized and is now ready for user 59 // The ARC instance has been fully initialized and is now ready for user
60 // interaction. 60 // interaction.
61 READY, 61 READY,
62 62
63 // The ARC instance has started shutting down. 63 // The ARC instance has started shutting down.
64 STOPPING, 64 STOPPING,
65 }; 65 };
66 66
67 // Notifies life cycle events of ArcBridgeService.
67 class Observer { 68 class Observer {
68 public: 69 public:
69 // Called whenever the state of the bridge has changed. 70 // Called whenever the state of the bridge has changed.
70 virtual void OnStateChanged(State state) {} 71 virtual void OnStateChanged(State state) {}
71 72
72 // Called when the instance has reached a boot phase 73 // Called when the instance has reached a boot phase
73 virtual void OnInstanceBootPhase(InstanceBootPhase phase) {} 74 virtual void OnInstanceBootPhase(InstanceBootPhase phase) {}
74 75
75 // Called whenever ARC's availability has changed for this system. 76 // Called whenever ARC's availability has changed for this system.
76 virtual void OnAvailableChanged(bool available) {} 77 virtual void OnAvailableChanged(bool available) {}
77 78
78 protected: 79 protected:
79 virtual ~Observer() {} 80 virtual ~Observer() {}
80 }; 81 };
81 82
83 // Notifies ARC apps related events.
84 class AppObserver {
85 public:
86 // Called whenever ARC sends information about available apps.
87 virtual void OnAppListRefreshed(const std::vector<AppInfo>& apps) {}
khmel1 2015/12/01 09:49:32 Additionally renamed for consistency.
88
89 // Called whenever ARC sends app icon data for specific scale factor.
90 virtual void OnAppIcon(const std::string& package,
91 const std::string& activity,
92 int scale_factor,
93 const std::vector<uint8_t>& icon_png_data) {}
94
95 protected:
96 virtual ~AppObserver() {}
97 };
98
82 virtual ~ArcBridgeService(); 99 virtual ~ArcBridgeService();
83 100
84 // Creates instance of |ArcBridgeService| for normal use. 101 // Creates instance of |ArcBridgeService| for normal use.
85 static scoped_ptr<ArcBridgeService> Create( 102 static scoped_ptr<ArcBridgeService> Create(
86 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner, 103 const scoped_refptr<base::SingleThreadTaskRunner>& ipc_task_runner,
87 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner); 104 const scoped_refptr<base::SequencedTaskRunner>& file_task_runner);
88 105
89 // Gets the global instance of the ARC Bridge Service. This can only be 106 // Gets the global instance of the ARC Bridge Service. This can only be
90 // called on the thread that this class was created on. 107 // called on the thread that this class was created on.
91 static ArcBridgeService* Get(); 108 static ArcBridgeService* Get();
(...skipping 14 matching lines...) Expand all
106 123
107 // Shutdown() should be called when the browser is shutting down. This can 124 // Shutdown() should be called when the browser is shutting down. This can
108 // only be called on the thread that this class was created on. 125 // only be called on the thread that this class was created on.
109 virtual void Shutdown() = 0; 126 virtual void Shutdown() = 0;
110 127
111 // Adds or removes observers. This can only be called on the thread that this 128 // Adds or removes observers. This can only be called on the thread that this
112 // class was created on. 129 // class was created on.
113 void AddObserver(Observer* observer); 130 void AddObserver(Observer* observer);
114 void RemoveObserver(Observer* observer); 131 void RemoveObserver(Observer* observer);
115 132
133 // Adds or removes ARC app observers. This can only be called on the thread
134 // that this class was created on.
135 void AddAppObserver(AppObserver* observer);
136 void RemoveAppObserver(AppObserver* observer);
137
116 // Gets the current state of the bridge service. 138 // Gets the current state of the bridge service.
117 State state() const { return state_; } 139 State state() const { return state_; }
118 140
119 // Gets if ARC is available in this system. 141 // Gets if ARC is available in this system.
120 bool available() const { return available_; } 142 bool available() const { return available_; }
121 143
122 // Requests registration of an input device on the ARC instance. 144 // Requests registration of an input device on the ARC instance.
123 // TODO(denniskempin): Make this interface more typesafe. 145 // TODO(denniskempin): Make this interface more typesafe.
124 // |name| should be the displayable name of the emulated device (e.g. "Chrome 146 // |name| should be the displayable name of the emulated device (e.g. "Chrome
125 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard") 147 // OS Keyboard"), |device_type| the name of the device type (e.g. "keyboard")
126 // and |fd| a file descriptor that emulates the kernel events of the device. 148 // and |fd| a file descriptor that emulates the kernel events of the device.
127 // This can only be called on the thread that this class was created on. 149 // This can only be called on the thread that this class was created on.
128 virtual bool RegisterInputDevice(const std::string& name, 150 virtual bool RegisterInputDevice(const std::string& name,
129 const std::string& device_type, 151 const std::string& device_type,
130 base::ScopedFD fd) = 0; 152 base::ScopedFD fd) = 0;
131 153
154 // Requests to refresh an app list.
155 virtual bool RefreshAppList() = 0;
156
157 // Requests to launch an app.
158 virtual bool LaunchApp(const std::string& package,
159 const std::string& activity) = 0;
160
161 // Requests to load an icon of specific scale_factor.
162 virtual bool RequestAppIcon(const std::string& package,
khmel1 2015/12/01 09:49:32 Additionally renamed for consistency.
163 const std::string& activity,
164 int scale_factor) = 0;
165
132 protected: 166 protected:
133 ArcBridgeService(); 167 ArcBridgeService();
134 168
135 // Changes the current state and notifies all observers. 169 // Changes the current state and notifies all observers.
136 void SetState(State state); 170 void SetState(State state);
137 171
138 // Changes the current availability and notifies all observers. 172 // Changes the current availability and notifies all observers.
139 void SetAvailable(bool availability); 173 void SetAvailable(bool availability);
140 174
141 const scoped_refptr<base::SequencedTaskRunner>& origin_task_runner() const { 175 const scoped_refptr<base::SequencedTaskRunner>& origin_task_runner() const {
142 return origin_task_runner_; 176 return origin_task_runner_;
143 } 177 }
144 178
145 base::ObserverList<Observer>& observer_list() { return observer_list_; } 179 base::ObserverList<Observer>& observer_list() { return observer_list_; }
146 180
181 base::ObserverList<AppObserver>& app_observer_list() {
182 return app_observer_list_;
183 }
184
147 private: 185 private:
148 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_; 186 scoped_refptr<base::SequencedTaskRunner> origin_task_runner_;
149 187
150 base::ObserverList<Observer> observer_list_; 188 base::ObserverList<Observer> observer_list_;
151 189
190 base::ObserverList<AppObserver> app_observer_list_;
191
152 // If the ARC instance service is available. 192 // If the ARC instance service is available.
153 bool available_; 193 bool available_;
154 194
155 // The current state of the bridge. 195 // The current state of the bridge.
156 ArcBridgeService::State state_; 196 ArcBridgeService::State state_;
157 197
158 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService); 198 DISALLOW_COPY_AND_ASSIGN(ArcBridgeService);
159 }; 199 };
160 200
161 } // namespace arc 201 } // namespace arc
162 202
163 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_ 203 #endif // COMPONENTS_ARC_ARC_BRIDGE_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698