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
3// found in the LICENSE file.
4
5#include "components/pairing/shark_connection_listener.h"
6
7#include "base/logging.h"
8#include "base/threading/thread_restrictions.h"
9#include "components/pairing/bluetooth_host_pairing_controller.h"
10
11namespace pairing_chromeos {
12
13SharkConnectionListener::SharkConnectionListener(OnConnectedCallback callback)
14    : callback_(callback) {
15  controller_.reset(new BluetoothHostPairingController());
16  controller_->AddObserver(this);
17  controller_->StartPairing();
18}
19
20SharkConnectionListener::~SharkConnectionListener() {
21  if (controller_)
22    controller_->RemoveObserver(this);
23}
24
25void SharkConnectionListener::PairingStageChanged(Stage new_stage) {
26  if (new_stage == HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION) {
27    controller_->RemoveObserver(this);
28    callback_.Run(controller_.Pass());
29    callback_.Reset();
30  }
31}
32
33void SharkConnectionListener::ConfigureHost(
34    bool accepted_eula,
35    const std::string& lang,
36    const std::string& timezone,
37    bool send_reports,
38    const std::string& keyboard_layout) {
39  NOTREACHED();
40}
41
42void SharkConnectionListener::EnrollHost(const std::string& auth_token) {
43  NOTREACHED();
44}
45
46}  // namespace pairing_chromeos
47