summaryrefslogtreecommitdiffstats
path: root/components/pairing
diff options
context:
space:
mode:
authorzork <zork@chromium.org>2014-09-08 23:53:49 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-09 06:59:38 +0000
commitfd2bb5ea266c362ac7efc217f349a78ea4f1dcb5 (patch)
tree9f1d9bf23e1e7976f5049b8daf9755bc024c1099 /components/pairing
parent966607ad9fc89b31dfc991ab65ba941132e2d2bf (diff)
downloadchromium_src-fd2bb5ea266c362ac7efc217f349a78ea4f1dcb5.zip
chromium_src-fd2bb5ea266c362ac7efc217f349a78ea4f1dcb5.tar.gz
chromium_src-fd2bb5ea266c362ac7efc217f349a78ea4f1dcb5.tar.bz2
Add method for telling the Pairing API that enrollment is complete
BUG=None Review URL: https://codereview.chromium.org/555003002 Cr-Commit-Position: refs/heads/master@{#293879}
Diffstat (limited to 'components/pairing')
-rw-r--r--components/pairing/bluetooth_host_pairing_controller.cc16
-rw-r--r--components/pairing/bluetooth_host_pairing_controller.h1
-rw-r--r--components/pairing/bluetooth_pairing_constants.cc1
-rw-r--r--components/pairing/bluetooth_pairing_constants.h1
-rw-r--r--components/pairing/fake_host_pairing_controller.cc3
-rw-r--r--components/pairing/fake_host_pairing_controller.h1
-rw-r--r--components/pairing/host_pairing_controller.h3
7 files changed, 23 insertions, 3 deletions
diff --git a/components/pairing/bluetooth_host_pairing_controller.cc b/components/pairing/bluetooth_host_pairing_controller.cc
index 74f1a5e..29d2bca 100644
--- a/components/pairing/bluetooth_host_pairing_controller.cc
+++ b/components/pairing/bluetooth_host_pairing_controller.cc
@@ -269,9 +269,19 @@ void BluetoothHostPairingController::OnPairDevicesMessage(
// TODO(zork,achuith): Enroll device, send error on error.
// (http://crbug.com/374990)
// For now, test domain is sent in the access token.
- enrollment_domain_ = message.parameters().admin_access_token();
- ChangeStage(STAGE_PAIRING_DONE);
- SendHostStatus();
+ FOR_EACH_OBSERVER(Observer, observers_,
+ EnrollHost(message.parameters().admin_access_token()));
+}
+
+void BluetoothHostPairingController::SetEnrollmentComplete(bool success) {
+ DCHECK_EQ(current_stage_, STAGE_ENROLLING);
+ DCHECK(thread_checker_.CalledOnValidThread());
+ if (success) {
+ ChangeStage(STAGE_PAIRING_DONE);
+ SendHostStatus();
+ } else {
+ AbortWithError(PAIRING_ERROR_PAIRING_OR_ENROLLMENT, kErrorEnrollmentFailed);
+ }
}
void BluetoothHostPairingController::OnCompleteSetupMessage(
diff --git a/components/pairing/bluetooth_host_pairing_controller.h b/components/pairing/bluetooth_host_pairing_controller.h
index 6f64bf5..4dd0962 100644
--- a/components/pairing/bluetooth_host_pairing_controller.h
+++ b/components/pairing/bluetooth_host_pairing_controller.h
@@ -67,6 +67,7 @@ class BluetoothHostPairingController
virtual std::string GetConfirmationCode() OVERRIDE;
virtual std::string GetEnrollmentDomain() OVERRIDE;
virtual void OnUpdateStatusChanged(UpdateStatus update_status) OVERRIDE;
+ virtual void SetEnrollmentComplete(bool success) OVERRIDE;
// ProtoDecoder::Observer:
virtual void OnHostStatusMessage(
diff --git a/components/pairing/bluetooth_pairing_constants.cc b/components/pairing/bluetooth_pairing_constants.cc
index f25f8f7..9cad0f3 100644
--- a/components/pairing/bluetooth_pairing_constants.cc
+++ b/components/pairing/bluetooth_pairing_constants.cc
@@ -10,6 +10,7 @@ const char* kPairingServiceUUID = "f035ff16-c025-468e-bb16-967704d141ea";
const char* kPairingServiceName = "ChromeboxPairing";
const char* kDeviceNamePrefix = "Chromebox_";
const char* kErrorInvalidProtocol = "Invalid protocol";
+const char* kErrorEnrollmentFailed = "Enrollment failed";
const int kPairingAPIVersion = 1;
} // namespace pairing_chromeos
diff --git a/components/pairing/bluetooth_pairing_constants.h b/components/pairing/bluetooth_pairing_constants.h
index f28d7ab..a53e8e6 100644
--- a/components/pairing/bluetooth_pairing_constants.h
+++ b/components/pairing/bluetooth_pairing_constants.h
@@ -11,6 +11,7 @@ extern const char* kPairingServiceUUID;
extern const char* kPairingServiceName;
extern const char* kDeviceNamePrefix;
extern const char* kErrorInvalidProtocol;
+extern const char* kErrorEnrollmentFailed;
extern const int kPairingAPIVersion;
enum {
diff --git a/components/pairing/fake_host_pairing_controller.cc b/components/pairing/fake_host_pairing_controller.cc
index 80c00c8..541a433 100644
--- a/components/pairing/fake_host_pairing_controller.cc
+++ b/components/pairing/fake_host_pairing_controller.cc
@@ -128,6 +128,9 @@ void FakeHostPairingController::OnUpdateStatusChanged(
UpdateStatus update_status) {
}
+void FakeHostPairingController::SetEnrollmentComplete(bool success) {
+}
+
void FakeHostPairingController::PairingStageChanged(Stage new_stage) {
switch (new_stage) {
case STAGE_WAITING_FOR_CONTROLLER: {
diff --git a/components/pairing/fake_host_pairing_controller.h b/components/pairing/fake_host_pairing_controller.h
index ce63b09..f665aa6 100644
--- a/components/pairing/fake_host_pairing_controller.h
+++ b/components/pairing/fake_host_pairing_controller.h
@@ -42,6 +42,7 @@ class FakeHostPairingController
virtual std::string GetConfirmationCode() OVERRIDE;
virtual std::string GetEnrollmentDomain() OVERRIDE;
virtual void OnUpdateStatusChanged(UpdateStatus update_status) OVERRIDE;
+ virtual void SetEnrollmentComplete(bool success) OVERRIDE;
private:
void ChangeStage(Stage new_stage);
diff --git a/components/pairing/host_pairing_controller.h b/components/pairing/host_pairing_controller.h
index 207fef5..6ca88ea 100644
--- a/components/pairing/host_pairing_controller.h
+++ b/components/pairing/host_pairing_controller.h
@@ -80,6 +80,9 @@ class HostPairingController {
// Can be called on stage |STAGE_UPDATING|.
virtual void OnUpdateStatusChanged(UpdateStatus update_status) = 0;
+ // Called when enrollment has completed.
+ virtual void SetEnrollmentComplete(bool success) = 0;
+
virtual void AddObserver(Observer* observer) = 0;
virtual void RemoveObserver(Observer* observer) = 0;