From fede7212df489fd072a868d87434d6119323b978 Mon Sep 17 00:00:00 2001 From: "dgrogan@chromium.org" Date: Wed, 9 Jul 2014 23:36:12 +0000 Subject: [PATCH] Probably broke Win7 Tests (dbg)(6). http://build.chromium.org/p/chromium.win/builders/Win7%20Tests%20%28dbg%29%286%29/builds/27654/steps/browser_tests/logs/SendQuery [ RUN ] GcdPrivateAPITest.SendQuery [4036:2900:0709/150928:ERROR:singleton_hwnd.cc(43)] Cannot create windows on non-UI thread! [956:2412:0709/150928:WARNING:extension_apitest.cc(282)] Workaround for 177163, prematurely returning c:\b\build\slave\win_builder__dbg_\build\src\chrome\browser\extensions\api\gcd_private\gcd_private_apitest.cc(276): error: Actual function call count doesn't match EXPECT_CALL(*test_service_discovery_client_, OnSendTo(std::string(reinterpret_cast\u003Cconst char*>(kQueryPacket), sizeof(kQueryPacket))))... Expected: to be called twice Actual: never called - unsatisfied and active [ FAILED ] GcdPrivateAPITest.SendQuery, where TypeParam = and GetParam() = (5746 ms) Revert 282099 "Add API stubs for GCD device commands." > Add API stubs for GCD device commands. > Changed registration API to work for one network at once. > Fixed comments. > Replaced argument GCDDevice with just string id. > > BUG=383167 > R=alexsemenov@chromium.org, asargent@chromium.org, asvitkine@chromium.org, noamsml@chromium.org > > Review URL: https://codereview.chromium.org/363883002 TBR=vitalybuka@chromium.org Review URL: https://codereview.chromium.org/385483002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282175 0039d316-1c4b-4281-b951-d872f2087c98 --- .../extensions/api/gcd_private/gcd_private_api.cc | 154 ++++-------- .../extensions/api/gcd_private/gcd_private_api.h | 101 +------- chrome/common/extensions/api/gcd_private.idl | 274 +++++++++------------ .../api_test/gcd_private/api/get_cloud_list.js | 6 +- .../api_test/gcd_private/api/receive_new_device.js | 46 ++-- .../api_test/gcd_private/api/remove_device.js | 28 ++- .../api_test/gcd_private/api/send_query.js | 13 +- .../browser/extension_function_histogram_value.h | 9 +- tools/metrics/histograms/histograms.xml | 5 - 9 files changed, 222 insertions(+), 414 deletions(-) rewrite chrome/common/extensions/api/gcd_private.idl (62%) rewrite chrome/test/data/extensions/api_test/gcd_private/api/receive_new_device.js (74%) 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 78d8e7051e1c..87e923184e45 100644 --- a/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc +++ b/chrome/browser/extensions/api/gcd_private/gcd_private_api.cc @@ -23,28 +23,21 @@ namespace gcd_private = api::gcd_private; namespace { -const int kNumRequestsNeeded = 2; - -const char kIDPrefixCloudPrinter[] = "cloudprint:"; -const char kIDPrefixGcd[] = "gcd:"; -const char kIDPrefixMdns[] = "mdns:"; - -scoped_ptr MakeDeviceStateChangedEvent( +scoped_ptr MakeCloudDeviceStateChangedEvent( + bool available, const gcd_private::GCDDevice& device) { scoped_ptr params = - gcd_private::OnDeviceStateChanged::Create(device); - scoped_ptr event( - new Event(gcd_private::OnDeviceStateChanged::kEventName, params.Pass())); + gcd_private::OnCloudDeviceStateChanged::Create(available, device); + scoped_ptr event(new Event( + gcd_private::OnCloudDeviceStateChanged::kEventName, params.Pass())); return event.Pass(); } -scoped_ptr MakeDeviceRemovedEvent(const std::string& device) { - scoped_ptr params = - gcd_private::OnDeviceRemoved::Create(device); - scoped_ptr event( - new Event(gcd_private::OnDeviceRemoved::kEventName, params.Pass())); - return event.Pass(); -} +const int kNumRequestsNeeded = 2; + +const char kIDPrefixCloudPrinter[] = "cloudprint:"; +const char kIDPrefixGcd[] = "gcd:"; +const char kIDPrefixMdns[] = "mdns:"; GcdPrivateAPI::GCDApiFlowFactoryForTests* g_gcd_api_flow_factory = NULL; @@ -76,10 +69,8 @@ GcdPrivateAPI::GcdPrivateAPI(content::BrowserContext* context) : num_device_listeners_(0), browser_context_(context) { DCHECK(browser_context_); if (EventRouter::Get(context)) { - EventRouter::Get(context) - ->RegisterObserver(this, gcd_private::OnDeviceStateChanged::kEventName); - EventRouter::Get(context) - ->RegisterObserver(this, gcd_private::OnDeviceRemoved::kEventName); + EventRouter::Get(context)->RegisterObserver( + this, gcd_private::OnCloudDeviceStateChanged::kEventName); } } @@ -96,36 +87,31 @@ GcdPrivateAPI::GetFactoryInstance() { } void GcdPrivateAPI::OnListenerAdded(const EventListenerInfo& details) { - if (details.event_name == gcd_private::OnDeviceStateChanged::kEventName || - details.event_name == gcd_private::OnDeviceRemoved::kEventName) { - num_device_listeners_++; - - if (num_device_listeners_ == 1) { - service_discovery_client_ = - local_discovery::ServiceDiscoverySharedClient::GetInstance(); - privet_device_lister_.reset(new local_discovery::PrivetDeviceListerImpl( - service_discovery_client_.get(), this)); - privet_device_lister_->Start(); - } + num_device_listeners_++; + + if (num_device_listeners_ == 1) { + service_discovery_client_ = + local_discovery::ServiceDiscoverySharedClient::GetInstance(); + privet_device_lister_.reset(new local_discovery::PrivetDeviceListerImpl( + service_discovery_client_.get(), this)); + privet_device_lister_->Start(); + } - for (GCDDeviceMap::iterator i = known_devices_.begin(); - i != known_devices_.end(); - i++) { - EventRouter::Get(browser_context_)->DispatchEventToExtension( - details.extension_id, MakeDeviceStateChangedEvent(*i->second)); - } + for (GCDDeviceMap::iterator i = known_devices_.begin(); + i != known_devices_.end(); + i++) { + EventRouter::Get(browser_context_)->DispatchEventToExtension( + details.extension_id, + MakeCloudDeviceStateChangedEvent(true, *i->second)); } } void GcdPrivateAPI::OnListenerRemoved(const EventListenerInfo& details) { - if (details.event_name == gcd_private::OnDeviceStateChanged::kEventName || - details.event_name == gcd_private::OnDeviceRemoved::kEventName) { - num_device_listeners_--; + num_device_listeners_--; - if (num_device_listeners_ == 0) { - privet_device_lister_.reset(); - service_discovery_client_ = NULL; - } + if (num_device_listeners_ == 0) { + privet_device_lister_.reset(); + service_discovery_client_ = NULL; } } @@ -135,17 +121,17 @@ void GcdPrivateAPI::DeviceChanged( const local_discovery::DeviceDescription& description) { linked_ptr device(new gcd_private::GCDDevice); device->setup_type = gcd_private::SETUP_TYPE_MDNS; - device->device_id = kIDPrefixMdns + name; + device->id_string = kIDPrefixMdns + name; device->device_type = description.type; device->device_name = description.name; device->device_description = description.description; if (!description.id.empty()) device->cloud_id.reset(new std::string(description.id)); - known_devices_[device->device_id] = device; + known_devices_[device->id_string] = device; EventRouter::Get(browser_context_) - ->BroadcastEvent(MakeDeviceStateChangedEvent(*device)); + ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(true, *device)); } void GcdPrivateAPI::DeviceRemoved(const std::string& name) { @@ -154,7 +140,7 @@ void GcdPrivateAPI::DeviceRemoved(const std::string& name) { known_devices_.erase(found); EventRouter::Get(browser_context_) - ->BroadcastEvent(MakeDeviceRemovedEvent(device->device_id)); + ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(false, *device)); } void GcdPrivateAPI::DeviceCacheFlushed() { @@ -162,7 +148,7 @@ void GcdPrivateAPI::DeviceCacheFlushed() { i != known_devices_.end(); i++) { EventRouter::Get(browser_context_) - ->BroadcastEvent(MakeDeviceRemovedEvent(i->second->device_id)); + ->BroadcastEvent(MakeCloudDeviceStateChangedEvent(false, *i->second)); } known_devices_.clear(); @@ -239,9 +225,9 @@ void GcdPrivateGetCloudDeviceListFunction::CheckListingDone() { linked_ptr device(new gcd_private::GCDDevice); device->setup_type = gcd_private::SETUP_TYPE_CLOUD; if (i->type == local_discovery::kGCDTypePrinter) { - device->device_id = kIDPrefixCloudPrinter + i->id; + device->id_string = kIDPrefixCloudPrinter + i->id; } else { - device->device_id = kIDPrefixGcd + i->id; + device->id_string = kIDPrefixGcd + i->id; } device->cloud_id.reset(new std::string(i->id)); @@ -291,23 +277,23 @@ bool GcdPrivateStartSetupFunction::RunAsync() { return false; } -GcdPrivateSetWiFiNetworkFunction::GcdPrivateSetWiFiNetworkFunction() { +GcdPrivateSetWiFiNetworksFunction::GcdPrivateSetWiFiNetworksFunction() { } -GcdPrivateSetWiFiNetworkFunction::~GcdPrivateSetWiFiNetworkFunction() { +GcdPrivateSetWiFiNetworksFunction::~GcdPrivateSetWiFiNetworksFunction() { } -bool GcdPrivateSetWiFiNetworkFunction::RunAsync() { +bool GcdPrivateSetWiFiNetworksFunction::RunAsync() { return false; } -GcdPrivateSetWiFiPasswordFunction::GcdPrivateSetWiFiPasswordFunction() { +GcdPrivateSetWiFiCredentialsFunction::GcdPrivateSetWiFiCredentialsFunction() { } -GcdPrivateSetWiFiPasswordFunction::~GcdPrivateSetWiFiPasswordFunction() { +GcdPrivateSetWiFiCredentialsFunction::~GcdPrivateSetWiFiCredentialsFunction() { } -bool GcdPrivateSetWiFiPasswordFunction::RunAsync() { +bool GcdPrivateSetWiFiCredentialsFunction::RunAsync() { return false; } @@ -331,56 +317,4 @@ bool GcdPrivateStopSetupFunction::RunAsync() { return false; } -GcdPrivateGetCommandDefinitionsFunction:: - GcdPrivateGetCommandDefinitionsFunction() { -} - -GcdPrivateGetCommandDefinitionsFunction:: - ~GcdPrivateGetCommandDefinitionsFunction() { -} - -bool GcdPrivateGetCommandDefinitionsFunction::RunAsync() { - return false; -} - -GcdPrivateInsertCommandFunction::GcdPrivateInsertCommandFunction() { -} - -GcdPrivateInsertCommandFunction::~GcdPrivateInsertCommandFunction() { -} - -bool GcdPrivateInsertCommandFunction::RunAsync() { - return false; -} - -GcdPrivateGetCommandFunction::GcdPrivateGetCommandFunction() { -} - -GcdPrivateGetCommandFunction::~GcdPrivateGetCommandFunction() { -} - -bool GcdPrivateGetCommandFunction::RunAsync() { - return false; -} - -GcdPrivateCancelCommandFunction::GcdPrivateCancelCommandFunction() { -} - -GcdPrivateCancelCommandFunction::~GcdPrivateCancelCommandFunction() { -} - -bool GcdPrivateCancelCommandFunction::RunAsync() { - return false; -} - -GcdPrivateGetCommandsListFunction::GcdPrivateGetCommandsListFunction() { -} - -GcdPrivateGetCommandsListFunction::~GcdPrivateGetCommandsListFunction() { -} - -bool GcdPrivateGetCommandsListFunction::RunAsync() { - return false; -} - } // namespace extensions diff --git a/chrome/browser/extensions/api/gcd_private/gcd_private_api.h b/chrome/browser/extensions/api/gcd_private/gcd_private_api.h index 208744d261c4..bf57f454aef6 100644 --- a/chrome/browser/extensions/api/gcd_private/gcd_private_api.h +++ b/chrome/browser/extensions/api/gcd_private/gcd_private_api.h @@ -130,15 +130,15 @@ class GcdPrivateStartSetupFunction : public ChromeAsyncExtensionFunction { private: }; -class GcdPrivateSetWiFiNetworkFunction : public ChromeAsyncExtensionFunction { +class GcdPrivateSetWiFiNetworksFunction : public ChromeAsyncExtensionFunction { public: - DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiNetwork", - GCDPRIVATE_SETWIFINETWORK) + DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiNetworks", + GCDPRIVATE_SETWIFINETWORKS) - GcdPrivateSetWiFiNetworkFunction(); + GcdPrivateSetWiFiNetworksFunction(); protected: - virtual ~GcdPrivateSetWiFiNetworkFunction(); + virtual ~GcdPrivateSetWiFiNetworksFunction(); // AsyncExtensionFunction overrides. virtual bool RunAsync() OVERRIDE; @@ -146,15 +146,16 @@ class GcdPrivateSetWiFiNetworkFunction : public ChromeAsyncExtensionFunction { private: }; -class GcdPrivateSetWiFiPasswordFunction : public ChromeAsyncExtensionFunction { +class GcdPrivateSetWiFiCredentialsFunction + : public ChromeAsyncExtensionFunction { public: - DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiPassword", - GCDPRIVATE_SETWIFIPASSWORD) + DECLARE_EXTENSION_FUNCTION("gcdPrivate.setWiFiCredentials", + GCDPRIVATE_SETWIFICREDENTIALS) - GcdPrivateSetWiFiPasswordFunction(); + GcdPrivateSetWiFiCredentialsFunction(); protected: - virtual ~GcdPrivateSetWiFiPasswordFunction(); + virtual ~GcdPrivateSetWiFiCredentialsFunction(); // AsyncExtensionFunction overrides. virtual bool RunAsync() OVERRIDE; @@ -192,86 +193,6 @@ class GcdPrivateStopSetupFunction : public ChromeAsyncExtensionFunction { private: }; -class GcdPrivateGetCommandDefinitionsFunction - : public ChromeAsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("gcdPrivate.getCommandDefinitions", - GCDPRIVATE_GETCOMMANDDEFINITIONS) - - GcdPrivateGetCommandDefinitionsFunction(); - - protected: - virtual ~GcdPrivateGetCommandDefinitionsFunction(); - - // AsyncExtensionFunction overrides. - virtual bool RunAsync() OVERRIDE; - - private: -}; - -class GcdPrivateInsertCommandFunction : public ChromeAsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("gcdPrivate.insertCommand", - GCDPRIVATE_INSERTCOMMAND) - - GcdPrivateInsertCommandFunction(); - - protected: - virtual ~GcdPrivateInsertCommandFunction(); - - // AsyncExtensionFunction overrides. - virtual bool RunAsync() OVERRIDE; - - private: -}; - -class GcdPrivateGetCommandFunction : public ChromeAsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("gcdPrivate.getCommand", GCDPRIVATE_GETCOMMAND) - - GcdPrivateGetCommandFunction(); - - protected: - virtual ~GcdPrivateGetCommandFunction(); - - // AsyncExtensionFunction overrides. - virtual bool RunAsync() OVERRIDE; - - private: -}; - -class GcdPrivateCancelCommandFunction : public ChromeAsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("gcdPrivate.cancelCommand", - GCDPRIVATE_CANCELCOMMAND) - - GcdPrivateCancelCommandFunction(); - - protected: - virtual ~GcdPrivateCancelCommandFunction(); - - // AsyncExtensionFunction overrides. - virtual bool RunAsync() OVERRIDE; - - private: -}; - -class GcdPrivateGetCommandsListFunction : public ChromeAsyncExtensionFunction { - public: - DECLARE_EXTENSION_FUNCTION("gcdPrivate.getCommandsList", - GCDPRIVATE_GETCOMMANDSLIST) - - GcdPrivateGetCommandsListFunction(); - - protected: - virtual ~GcdPrivateGetCommandsListFunction(); - - // AsyncExtensionFunction overrides. - virtual bool RunAsync() OVERRIDE; - - private: -}; - } // namespace extensions #endif // CHROME_BROWSER_EXTENSIONS_API_GCD_PRIVATE_GCD_PRIVATE_API_H_ diff --git a/chrome/common/extensions/api/gcd_private.idl b/chrome/common/extensions/api/gcd_private.idl dissimilarity index 62% index 10add632498e..7d0ff1337b66 100644 --- a/chrome/common/extensions/api/gcd_private.idl +++ b/chrome/common/extensions/api/gcd_private.idl @@ -1,164 +1,110 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Use the chrome.gcdPrivate API to discover GCD APIs and register -// them. -namespace gcdPrivate { - - enum SetupType { mdns, wifi, cloud }; - - // Represents a GCD device discovered locally or registered to a given user. - dictionary GCDDevice { - // Opaque device identifier to be passed to API. - DOMString deviceId; - - // How this device was discovered. - SetupType setupType; - - // Cloud identifier string. - DOMString? cloudId; - - // Device type (camera, printer, etc) - DOMString deviceType; - - // Device human readable name - DOMString deviceName; - - // Device human readable description - DOMString deviceDescription; - }; - - callback CloudDeviceListCallback = void(GCDDevice[] devices); - - // |commandDefinitions| : Is "commandDefs" value of device described at - // https://developers.google.com/cloud-devices/v1/reference/devices - // TODO(vitalybuka): consider to describe object in IDL. - callback CommandDefinitionsCallback = void(object commandDefinitions); - - // |command| : Described at - // https://developers.google.com/cloud-devices/v1/reference/commands - // TODO(vitalybuka): consider to describe object in IDL. - callback CommandCallback = void(object command); - - // |commands| : Array of commands described at - // https://developers.google.com/cloud-devices/v1/reference/commands - // TODO(vitalybuka): consider to describe object in IDL. - callback CommandListCallback = void(object[] commands); - - interface Functions { - // Returns the list of cloud devices visible locally or available in the - // cloud for user account. - static void getCloudDeviceList(CloudDeviceListCallback callback); - - // Queries network for local devices. Triggers an onDeviceStateChanged and - // onDeviceRemoved events. Call this function *only* after registering for - // onDeviceStateChanged and onDeviceRemoved events, or it will do nothing. - static void queryForNewLocalDevices(); - - // Starts device setup process. Returns id of setup process. Id should be - // used as |setupId| in all subsequent setup related calls, and for - // filtering setup events. - static long startSetup(DOMString deviceId); - - // Sets WiFi network as reply to |onGetWifiNetworks| event. - // |setupId| : The value returned by |startSetup|. - // |network| : The wifi network for device setup. - static void setWiFiNetwork(long setupId, DOMString network); - - // Sets WiFi network password as reply to |onGetWifiPassword| event. - // |setupId| : The value returned by |startSetup|. - // |password| : The password for network selected with |setWiFiNetwork|. - static void setWiFiPassword(long setupId, DOMString password); - - // Confirms that security code known to application match to the code known - // to device. - // |setupId| : The value returned by |startSetup|. - static void confirmCode(long setupId); - - // Stops registration process. - // This call triggers |onSetupError| event. App should wait this even before - // starting new registration. - // |setupId| : The value returned by |startSetup|. - static void stopSetup(long setupId); - - // Returns command definitions. - // |deviceId| : The device to get command definitions for. - // |callback| : The result callback. - static void getCommandDefinitions(DOMString deviceId, - CommandDefinitionsCallback callback); - - // Creates and sends a new command. - // |deviceId| : The device to send the command to. - // |expireInMs| : The number of milliseconds since now before the command - // expires. Expired command should not be executed by device. Acceptable - // values are 10000 to 2592000000, inclusive. All values outside that range - // will be replaced by 2592000000. - // |command| : Described at - // https://developers.google.com/cloud-devices/v1/reference/commands - // |callback| : The result callback. - static void insertCommand(DOMString deviceId, - long expireInMs, - object command, - CommandCallback callback); - - // Returns a particular command. - // |commandId| : Unique command ID. - // |callback| : The result callback. - static void getCommand(DOMString commandId, CommandCallback callback); - - // Cancels a command. - // |commandId| : Unique command ID. - // |callback| : The result callback. - static void cancelCommand(DOMString commandId, CommandCallback callback); - - // Lists all commands in order of creation. - // |deviceId| : The device to get the commands for. - // |byUser| : List all the commands issued by the user. Special value 'me' - // can be used to list by the current user. - // |state| : Command state. - // |callback| : The result callback. - static void getCommandsList(DOMString deviceId, - DOMString byUser, - DOMString state, - CommandListCallback callback); - }; - - interface Events { - // Subscribe to this event to start listening new or updated devices. New - // listeners will get called with all known devices on the network, and - // status updates for devices available through the cloud. - static void onDeviceStateChanged(GCDDevice device); - - // Notifies that device has disappeared. - // |deviceId| : The device has disappeared. - static void onDeviceRemoved(DOMString deviceId); - - // Notifies app that setup is waiting for a wifi network. App should reply - // with |setWiFiNetwork|. - // |setupId| : The value returned by |startSetup|. - static void onGetWifiNetwork(long setupId); - - // Notifies app that setup is waiting for password for the network provided - // with |setWiFiNetwork|. Even will be called if setup flow would unable to - // get password from the system. - // App should reply with |setWiFiPassword|. - // |setupId| : The value returned by |startSetup|. - static void onGetWifiPassword(long setupId); - - // Notifies app that setup is waiting for confirmation that code is the same - // as code known to device. App should reply with |confirmCode|, or - // |stopSetup| if code does not match. - // |confirmationCode| : The code to confirm. - // |setupId| : The value returned by |startSetup|. - static void onConfirmCode(long setupId, DOMString confirmationCode); - - // Notifies app that setup is completed successfully. - // |setupId| : The value returned by |startSetup|. - static void onSetupSuccess(long setupId); - - // Notifies app that setup is failed or stopped. - // |setupId| : The value returned by |startSetup|. - static void onSetupError(long setupId); - }; -}; +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Use the chrome.gcdPrivate API to discover GCD APIs and register +// them. +namespace gcdPrivate { + + enum SetupType { mdns, wifi, cloud }; + + // Represents a GCD device discovered locally or registered to a given user. + dictionary GCDDevice { + // How this device was discovered. + SetupType setupType; + + // Opaque device identifier to be passed to API. + DOMString idString; + + // Cloud identifier string. + DOMString? cloudId; + + // Device type (camera, printer, etc) + DOMString deviceType; + + // Device human readable name + DOMString deviceName; + + // Device human readable description + DOMString deviceDescription; + }; + + // Represents wifi network credentials. + dictionary WiFiCredentials { + DOMString ssid; + DOMString password; + }; + + callback CloudDeviceListCallback = void(GCDDevice[] devices); + + interface Functions { + static void getCloudDeviceList(CloudDeviceListCallback callback); + + // Call this function *only* after registering for onDeviceStateChanged + // events, or it will do nothing. This will trigger an + // onLocalDeviceStateChanged event per device. + static void queryForNewLocalDevices(); + + // Starts device setup process. Returns id of setup process. Id should be + // used as |setupId| in all subsequent setup related calls, and for + // filtering setup events. + static long startSetup(GCDDevice device); + + // Sets WiFi network list as reply to |onGetWifiNetworks| event. + // |setupId| : The value returned by |startSetup|. + // |networks| : The list of network device should be registered on. + static void setWiFiNetworks(long setupId, DOMString[] networks); + + // Sets WiFi network credentials as reply to |onGetWifiCredentials| + // event. + // |setupId| : The value returned by |startSetup|. + // |credentials| : The list of ssid with passwoors. The list is not required + // to match |networks| provided with |setWiFiNetworks| or + // |onGetWifiCredentials|. + static void setWiFiCredentials(long setupId, WiFiCredentials[] credentials); + + // Confirms that security code known to application match to the code known + // to device. + // |setupId| : The value returned by |startSetup|. + static void confirmCode(long setupId); + + // Stops registration process. + // This call triggers |onSetupError| event. App should wait this even before + // starting new registration. + // |setupId| : The value returned by |startSetup|. + static void stopSetup(long setupId); + }; + + interface Events { + // Subscribe to this event to start listening to cloud devices. New + // listeners will get called with all known devices on the network. + static void onCloudDeviceStateChanged(boolean available, GCDDevice device); + + // Notifies app that setup is waiting for network list. App should reply + // with |setWiFiNetworks|. + // |setupId| : The value returned by |startSetup|. + static void onGetWifiNetworks(long setupId); + + // Notifies app that setup is waiting for credentions for |networks| list. + // App should reply with |setWiFiCredentials|. + // |setupId| : The value returned by |startSetup|. + // |networks| : A subset of the list provided in |setWiFiNetworks| for which + // setup flow is unable to find credentials + static void onGetWifiCredentials(long setupId, DOMString[] networks); + + // Notifies app that setup is waiting for confirmation that code is the same + // as code known to device. App should reply with |confirmCode|, or + // |stopSetup| if code does not match. + // |confirmationCode| : The code to confirm. + // |setupId| : The value returned by |startSetup|. + static void onConfirmCode(long setupId, DOMString confirmationCode); + + // Notifies app that setup is completed successfully. + // |setupId| : The value returned by |startSetup|. + static void onSetupSuccess(long setupId); + + // Notifies app that setup is failed or stoped. + // |setupId| : The value returned by |startSetup|. + static void onSetupError(long setupId); + }; +}; diff --git a/chrome/test/data/extensions/api_test/gcd_private/api/get_cloud_list.js b/chrome/test/data/extensions/api_test/gcd_private/api/get_cloud_list.js index 3dfb44ff4f1c..0ea069c3c79b 100644 --- a/chrome/test/data/extensions/api_test/gcd_private/api/get_cloud_list.js +++ b/chrome/test/data/extensions/api_test/gcd_private/api/get_cloud_list.js @@ -8,13 +8,13 @@ onload = function() { chrome.gcdPrivate.getCloudDeviceList(function(services) { // Sort to avoid order dependence services.sort(function(a,b) { - return a.deviceId.localeCompare(b.deviceId); + return a.idString.localeCompare(b.idString); }); chrome.test.assertEq(2, services.length); chrome.test.assertEq(services[0].setupType, "cloud"); - chrome.test.assertEq(services[0].deviceId, + chrome.test.assertEq(services[0].idString, "cloudprint:someCloudPrintID"); chrome.test.assertEq(services[0].cloudId, "someCloudPrintID"); chrome.test.assertEq(services[0].deviceType, "printer"); @@ -24,7 +24,7 @@ onload = function() { "someCloudPrintDescription"); chrome.test.assertEq(services[1].setupType, "cloud"); - chrome.test.assertEq(services[1].deviceId, "gcd:someGCDID"); + chrome.test.assertEq(services[1].idString, "gcd:someGCDID"); chrome.test.assertEq(services[1].cloudId, "someGCDID"); chrome.test.assertEq(services[1].deviceType, "someType"); chrome.test.assertEq(services[1].deviceName, "someGCDDisplayName"); diff --git a/chrome/test/data/extensions/api_test/gcd_private/api/receive_new_device.js b/chrome/test/data/extensions/api_test/gcd_private/api/receive_new_device.js dissimilarity index 74% index cc52e80dc980..2ccd68894c57 100644 --- a/chrome/test/data/extensions/api_test/gcd_private/api/receive_new_device.js +++ b/chrome/test/data/extensions/api_test/gcd_private/api/receive_new_device.js @@ -1,22 +1,24 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -onload = function() { - chrome.test.runTests([ - function receiveNewDevice() { - chrome.gcdPrivate.onDeviceStateChanged.addListener( - function(device) { - chrome.test.assertEq(device.setupType, "mdns"); - chrome.test.assertEq(device.deviceId, - "mdns:myService._privet._tcp.local"); - chrome.test.assertEq(device.deviceType, "printer"); - chrome.test.assertEq(device.deviceName, - "Sample device"); - chrome.test.assertEq(device.deviceDescription, - "Sample device description"); - - chrome.test.notifyPass(); - }) - }]); -}; +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +onload = function() { + chrome.test.runTests([ + function receiveNewDevice() { + chrome.gcdPrivate.onCloudDeviceStateChanged.addListener( + function(available, device) { + chrome.test.assertTrue(available); + + chrome.test.assertEq(device.setupType, "mdns"); + chrome.test.assertEq(device.idString, + "mdns:myService._privet._tcp.local"); + chrome.test.assertEq(device.deviceType, "printer"); + chrome.test.assertEq(device.deviceName, + "Sample device"); + chrome.test.assertEq(device.deviceDescription, + "Sample device description"); + + chrome.test.notifyPass(); + }) + }]); +}; diff --git a/chrome/test/data/extensions/api_test/gcd_private/api/remove_device.js b/chrome/test/data/extensions/api_test/gcd_private/api/remove_device.js index af281bf21734..072b79b7ff91 100644 --- a/chrome/test/data/extensions/api_test/gcd_private/api/remove_device.js +++ b/chrome/test/data/extensions/api_test/gcd_private/api/remove_device.js @@ -4,12 +4,26 @@ onload = function() { chrome.test.runTests([ - function addRemoveDevice() { - chrome.gcdPrivate.onDeviceRemoved.addListener( - function(deviceId) { - chrome.test.assertEq(deviceId, - "mdns:myService._privet._tcp.local"); - chrome.test.notifyPass(); - }) + function addRemoveDevice() { + var should_be_available = true; + chrome.gcdPrivate.onCloudDeviceStateChanged.addListener( + function(available, device) { + chrome.test.assertEq(available, should_be_available); + should_be_available = false; + + chrome.test.assertEq(device.setupType, "mdns"); + chrome.test.assertEq(device.idString, + "mdns:myService._privet._tcp.local"); + chrome.test.assertEq(device.deviceType, "printer"); + chrome.test.assertEq(device.deviceName, + "Sample device"); + chrome.test.assertEq(device.deviceDescription, + "Sample device description"); + + if (!available) { + // Only pass after device is removed + chrome.test.notifyPass(); + } + }) }]); }; diff --git a/chrome/test/data/extensions/api_test/gcd_private/api/send_query.js b/chrome/test/data/extensions/api_test/gcd_private/api/send_query.js index 0b149a1b9f3d..dd24da7a39e7 100644 --- a/chrome/test/data/extensions/api_test/gcd_private/api/send_query.js +++ b/chrome/test/data/extensions/api_test/gcd_private/api/send_query.js @@ -4,10 +4,11 @@ onload = function() { chrome.test.runTests([ - function receiveNewDevice() { - chrome.gcdPrivate.onDeviceStateChanged.addListener(function(device) {}); - chrome.gcdPrivate.queryForNewLocalDevices(); - chrome.test.notifyPass(); - } - ]); + function receiveNewDevice() { + chrome.gcdPrivate.onCloudDeviceStateChanged.addListener( + function(available, device) {}); + + chrome.gcdPrivate.queryForNewLocalDevices(); + chrome.test.notifyPass(); + }]); }; diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index 8003a5184108..57deac346d1c 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h @@ -884,19 +884,14 @@ enum HistogramValue { GCDPRIVATE_GETCLOUDDEVICELIST, GCDPRIVATE_QUERYFORNEWLOCALDEVICES, GCDPRIVATE_STARTSETUP, - GCDPRIVATE_SETWIFINETWORK, - GCDPRIVATE_SETWIFIPASSWORD, + GCDPRIVATE_SETWIFINETWORKS, + GCDPRIVATE_SETWIFICREDENTIALS, GCDPRIVATE_CONFIRMCODE, GCDPRIVATE_STOPSETUP, TABS_SETZOOM, TABS_GETZOOM, TABS_SETZOOMSETTINGS, TABS_GETZOOMSETTINGS, - GCDPRIVATE_GETCOMMANDDEFINITIONS, - GCDPRIVATE_INSERTCOMMAND, - GCDPRIVATE_GETCOMMAND, - GCDPRIVATE_CANCELCOMMAND, - GCDPRIVATE_GETCOMMANDSLIST, // Last entry: Add new entries above and ensure to update // tools/metrics/histograms/histograms/histograms.xml. ENUM_BOUNDARY diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 410c095b0607..eeaab506a61b 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -38425,11 +38425,6 @@ Therefore, the affected-histogram name has to have at least one dot in it. - - - - - -- 2.11.4.GIT