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 #include "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" | 5 #include "chrome/browser/extensions/api/gcd_private/gcd_private_api.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "chrome/browser/local_discovery/cloud_device_list.h" | 9 #include "chrome/browser/local_discovery/cloud_device_list.h" |
10 #include "chrome/browser/local_discovery/cloud_print_printer_list.h" | 10 #include "chrome/browser/local_discovery/cloud_print_printer_list.h" |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
147 for (GCDDeviceMap::iterator i = known_devices_.begin(); | 147 for (GCDDeviceMap::iterator i = known_devices_.begin(); |
148 i != known_devices_.end(); | 148 i != known_devices_.end(); |
149 i++) { | 149 i++) { |
150 EventRouter::Get(browser_context_) | 150 EventRouter::Get(browser_context_) |
151 ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(false, *i->second)); | 151 ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(false, *i->second)); |
152 } | 152 } |
153 | 153 |
154 known_devices_.clear(); | 154 known_devices_.clear(); |
155 } | 155 } |
156 | 156 |
157 bool GcdPrivateAPI::QueryForDevices() { | |
158 if (!privet_device_lister_) | |
159 return false; | |
160 | |
161 privet_device_lister_->DiscoverNewDevices(true); | |
162 | |
163 return true; | |
164 } | |
165 | |
157 // static | 166 // static |
158 void GcdPrivateAPI::SetGCDApiFlowFactoryForTests( | 167 void GcdPrivateAPI::SetGCDApiFlowFactoryForTests( |
159 GCDApiFlowFactoryForTests* factory) { | 168 GCDApiFlowFactoryForTests* factory) { |
160 g_gcd_api_flow_factory = factory; | 169 g_gcd_api_flow_factory = factory; |
161 } | 170 } |
162 | 171 |
163 GcdPrivateGetCloudDeviceListFunction::GcdPrivateGetCloudDeviceListFunction() { | 172 GcdPrivateGetCloudDeviceListFunction::GcdPrivateGetCloudDeviceListFunction() { |
164 } | 173 } |
165 GcdPrivateGetCloudDeviceListFunction::~GcdPrivateGetCloudDeviceListFunction() { | 174 GcdPrivateGetCloudDeviceListFunction::~GcdPrivateGetCloudDeviceListFunction() { |
166 } | 175 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
228 | 237 |
229 devices.push_back(device); | 238 devices.push_back(device); |
230 } | 239 } |
231 | 240 |
232 results_ = gcd_private::GetCloudDeviceList::Results::Create(devices); | 241 results_ = gcd_private::GetCloudDeviceList::Results::Create(devices); |
233 | 242 |
234 SendResponse(true); | 243 SendResponse(true); |
235 Release(); | 244 Release(); |
236 } | 245 } |
237 | 246 |
247 GcdPrivateQueryForNewLocalDevicesFunction:: | |
248 GcdPrivateQueryForNewLocalDevicesFunction() { | |
249 } | |
250 | |
251 GcdPrivateQueryForNewLocalDevicesFunction:: | |
252 ~GcdPrivateQueryForNewLocalDevicesFunction() { | |
253 } | |
254 | |
255 bool GcdPrivateQueryForNewLocalDevicesFunction::RunSync() { | |
256 GcdPrivateAPI* gcd_api = | |
257 BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile()); | |
258 | |
259 if (!gcd_api) | |
260 return false; | |
261 | |
262 if (!gcd_api->QueryForDevices()) { | |
263 error_ = | |
264 "You must first subscribe to onCloudDeviceStateChanged notifications"; | |
Vitaly Buka (NO REVIEWS)
2014/07/09 04:34:09
please update this
| |
265 return false; | |
266 } | |
267 | |
268 return true; | |
269 } | |
270 | |
238 GcdPrivateStartSetupFunction::GcdPrivateStartSetupFunction() { | 271 GcdPrivateStartSetupFunction::GcdPrivateStartSetupFunction() { |
239 } | 272 } |
240 | 273 |
241 GcdPrivateStartSetupFunction::~GcdPrivateStartSetupFunction() { | 274 GcdPrivateStartSetupFunction::~GcdPrivateStartSetupFunction() { |
242 } | 275 } |
243 | 276 |
244 bool GcdPrivateStartSetupFunction::RunAsync() { | 277 bool GcdPrivateStartSetupFunction::RunAsync() { |
245 return false; | 278 return false; |
246 } | 279 } |
247 | 280 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
279 } | 312 } |
280 | 313 |
281 GcdPrivateStopSetupFunction::~GcdPrivateStopSetupFunction() { | 314 GcdPrivateStopSetupFunction::~GcdPrivateStopSetupFunction() { |
282 } | 315 } |
283 | 316 |
284 bool GcdPrivateStopSetupFunction::RunAsync() { | 317 bool GcdPrivateStopSetupFunction::RunAsync() { |
285 return false; | 318 return false; |
286 } | 319 } |
287 | 320 |
288 } // namespace extensions | 321 } // namespace extensions |
OLD | NEW |