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

Unified Diff: chrome/browser/extensions/api/gcd_private/gcd_private_api.cc

Issue 387453002: Re-submit of https://codereview.chromium.org/356613002 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Thu 07/10/2014 2:23:32.16 Created 6 years, 5 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/gcd_private/gcd_private_api.cc
diff --git a/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc b/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc
index 6a2921624a7813f94a4ba517edfc5cb6d3c9e11e..aae88e1e37693322f8ff33f6c294984751aabc15 100644
--- a/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc
+++ b/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc
@@ -168,6 +168,15 @@ void GcdPrivateAPI::DeviceCacheFlushed() {
known_devices_.clear();
}
+bool GcdPrivateAPI::QueryForDevices() {
+ if (!privet_device_lister_)
+ return false;
+
+ privet_device_lister_->DiscoverNewDevices(true);
+
+ return true;
+}
+
// static
void GcdPrivateAPI::SetGCDApiFlowFactoryForTests(
GCDApiFlowFactoryForTests* factory) {
@@ -176,6 +185,7 @@ void GcdPrivateAPI::SetGCDApiFlowFactoryForTests(
GcdPrivateGetCloudDeviceListFunction::GcdPrivateGetCloudDeviceListFunction() {
}
+
GcdPrivateGetCloudDeviceListFunction::~GcdPrivateGetCloudDeviceListFunction() {
}
@@ -258,7 +268,20 @@ GcdPrivateQueryForNewLocalDevicesFunction::
}
bool GcdPrivateQueryForNewLocalDevicesFunction::RunSync() {
- return false;
+ GcdPrivateAPI* gcd_api =
+ BrowserContextKeyedAPIFactory<GcdPrivateAPI>::Get(GetProfile());
+
+ if (!gcd_api)
+ return false;
+
+ if (!gcd_api->QueryForDevices()) {
+ error_ =
+ "You must first subscribe to onDeviceStateChanged or onDeviceRemoved "
+ "notifications";
+ return false;
+ }
+
+ return true;
}
GcdPrivateStartSetupFunction::GcdPrivateStartSetupFunction() {

Powered by Google App Engine
This is Rietveld 408576698