diff options
author | dzhioev@chromium.org <dzhioev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-03 16:11:23 +0000 |
---|---|---|
committer | dzhioev@chromium.org <dzhioev@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-03 16:11:23 +0000 |
commit | e19f59dc85c8537d805328827f5216ccef2d1749 (patch) | |
tree | 0927ed184d953113d878fa4b1bd806ad8a97cd97 | |
parent | 6134bdcb440537df5fd2a3d7ab6161d1742b0e37 (diff) | |
download | chromium_src-e19f59dc85c8537d805328827f5216ccef2d1749.zip chromium_src-e19f59dc85c8537d805328827f5216ccef2d1749.tar.gz chromium_src-e19f59dc85c8537d805328827f5216ccef2d1749.tar.bz2 |
Created paring flow interface for controller side.
This interface will be used by controller's UI to pass through pairing.
BUG=375191
Review URL: https://codereview.chromium.org/304603002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274545 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chromeos/chromeos.gyp | 2 | ||||
-rw-r--r-- | chromeos/pairing/OWNERS | 3 | ||||
-rw-r--r-- | chromeos/pairing/controller_pairing_flow.cc | 17 | ||||
-rw-r--r-- | chromeos/pairing/controller_pairing_flow.h | 109 |
4 files changed, 131 insertions, 0 deletions
diff --git a/chromeos/chromeos.gyp b/chromeos/chromeos.gyp index d3aca5f..d97e43d 100644 --- a/chromeos/chromeos.gyp +++ b/chromeos/chromeos.gyp @@ -357,6 +357,8 @@ 'network/shill_property_util.h', 'network/dhcp_proxy_script_fetcher_chromeos.cc', 'network/dhcp_proxy_script_fetcher_chromeos.h', + 'pairing/controller_pairing_flow.cc', + 'pairing/controller_pairing_flow.h', 'process_proxy/process_output_watcher.cc', 'process_proxy/process_output_watcher.h', 'process_proxy/process_proxy.cc', diff --git a/chromeos/pairing/OWNERS b/chromeos/pairing/OWNERS new file mode 100644 index 0000000..14942e3 --- /dev/null +++ b/chromeos/pairing/OWNERS @@ -0,0 +1,3 @@ +achuith@chromium.org +dzhioev@chromium.org +zork@chromium.org diff --git a/chromeos/pairing/controller_pairing_flow.cc b/chromeos/pairing/controller_pairing_flow.cc new file mode 100644 index 0000000..17f536b --- /dev/null +++ b/chromeos/pairing/controller_pairing_flow.cc @@ -0,0 +1,17 @@ +// 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. + +#include "chromeos/pairing/controller_pairing_flow.h" + +namespace chromeos { + +ControllerPairingFlow::Observer::Observer() {} + +ControllerPairingFlow::Observer::~Observer() {} + +ControllerPairingFlow::ControllerPairingFlow() {} + +ControllerPairingFlow::~ControllerPairingFlow() {} + +} // namespace chromeos diff --git a/chromeos/pairing/controller_pairing_flow.h b/chromeos/pairing/controller_pairing_flow.h new file mode 100644 index 0000000..1b60a76 --- /dev/null +++ b/chromeos/pairing/controller_pairing_flow.h @@ -0,0 +1,109 @@ +// 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. + +#ifndef CHROMEOS_PAIRING_CONTROLLER_PAIRING_FLOW_H_ +#define CHROMEOS_PAIRING_CONTROLLER_PAIRING_FLOW_H_ + +#include <string> +#include <vector> + +#include "base/macros.h" +#include "chromeos/chromeos_export.h" + +namespace chromeos { +class UserContext; +} + +namespace content { +class BrowserContext; +} + +namespace chromeos { + +class CHROMEOS_EXPORT ControllerPairingFlow { + public: + enum Stage { + STAGE_NONE, + STAGE_DEVICES_DISCOVERY, + STAGE_DEVICE_NOT_FOUND, + STAGE_ESTABLISHING_CONNECTION, + STAGE_ESTABLISHING_CONNECTION_ERROR, + STAGE_WAITING_FOR_CODE_CONFIRMATION, + STAGE_HOST_UPDATE_IN_PROGRESS, + STAGE_HOST_CONNECTION_LOST, + STAGE_WAITING_FOR_CREDENTIALS, + STAGE_HOST_ENROLLMENT_IN_PROGRESS, + STAGE_HOST_ENROLLMENT_ERROR, + STAGE_PAIRING_DONE, + STAGE_STARTING_SESSION, + STAGE_FINISHED + }; + + class Observer { + public: + Observer(); + virtual ~Observer(); + + // Called when flow has moved on from one stage to another. + virtual void PairingStageChanged(Stage new_stage) = 0; + + // Called when new device was discovered or existing device was lost. + // This notification is made only on |STAGE_SCANNING_FOR_DEVICES| stage. + virtual void DiscoveredDevicesListChanged() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(Observer); + }; + + typedef std::vector<std::string> DeviceIdList; + + ControllerPairingFlow(); + virtual ~ControllerPairingFlow(); + + virtual void AddObserver(Observer* observer) = 0; + virtual void RemoveObserver(Observer* observer) = 0; + + // Returns current stage of flow. + virtual Stage GetCurrentStage() = 0; + + // Starts pairing flow. Can be called only on |STAGE_NONE| stage. + virtual void StartFlow() = 0; + + // Returns list of discovered devices. Can be called only on + // |STAGE_DEVICES_DISCOVERY| stage. + virtual DeviceIdList GetDiscoveredDevices() = 0; + + // This method is called to start pairing with the device having |device_id| + // ID. Can be called only on |STAGE_DEVICES_DISCOVERY| stage. + virtual void ChooseDeviceForPairing(const std::string& device_id) = 0; + + // Rescan for devices to pair with. Can be called only on + // |STAGE_DEVICE_NOT_FOUND| stage. + virtual void RepeatDiscovery() = 0; + + // Returns pairing confirmation code. + // Could be called only on |STATE_WAITING_FOR_CODE_CONFIRMATION| stage. + virtual std::string GetConfirmationCode() = 0; + + // Called to confirm or deny confirmation code. Can be called only on + // |STAGE_WAITING_FOR_CODE_CONFIRMATION| stage. + virtual void SetConfirmationCodeIsCorrect(bool right) = 0; + + // Called when user successfully authenticated on GAIA page. Can be called + // only on |STAGE_WAITING_FOR_CREDENTIALS| stage. + virtual void OnAuthenticationDone( + const chromeos::UserContext& user_context, + content::BrowserContext* browser_context) = 0; + + // Installs app and starts session. + // Can be called only on |STAGE_PAIRING_DONE| stage. + virtual void StartSession() = 0; + + private: + DISALLOW_COPY_AND_ASSIGN(ControllerPairingFlow); +}; + +} // namespace chromeos + +#endif // CHROMEOS_PAIRING_CONTROLLER_PAIRING_FLOW_H_ |