Commit 5f967259 authored by noamsml@chromium.org's avatar noamsml@chromium.org

PrivetV2 SetupFlow, Session and SetupOperation interfaces

This is a merged CL containing the PrivetV2SetupFlow, PrivetV2Session,
and PrivetV2SetupOperation interfaces.

BUG=372843

Review URL: https://codereview.chromium.org/299123003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272647 0039d316-1c4b-4281-b951-d872f2087c98
parent 3aadc6e4
// 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 "chrome/browser/local_discovery/privetv2_session.h"
#include "base/logging.h"
namespace local_discovery {
scoped_ptr<PrivetV2Session> PrivetV2Session::Create(PrivetHTTPClient* client) {
NOTIMPLEMENTED();
return scoped_ptr<PrivetV2Session>();
}
} // namespace local_discovery
// 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 CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SESSION_H_
#define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SESSION_H_
#include <string>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/values.h"
namespace local_discovery {
class PrivetHTTPClient;
class PrivetV2Session {
public:
typedef base::Callback<
void(bool success, const base::DictionaryValue& response)>
RequestCallback;
class Delegate {
public:
typedef base::Callback<void(bool confirm)> ConfirmationCallback;
virtual ~Delegate() {}
virtual void OnSetupConfirmationNeeded(
const std::string& confirmation_code,
const ConfirmationCallback& callback) = 0;
virtual void OnSessionEstablished() = 0;
virtual void OnCannotEstablishSession() = 0;
};
class Request {
public:
virtual ~Request() {}
virtual void Start() = 0;
};
virtual ~PrivetV2Session() {}
static scoped_ptr<PrivetV2Session> Create(PrivetHTTPClient* client);
// Establish a session, will call |OnSetupConfirmationNeeded| and then
// |OnSessionEstablished|.
virtual void Start() = 0;
// Create a single /privet/v2/session/call request.
virtual scoped_ptr<Request> CreateRequest(
const char* api_name,
const base::DictionaryValue& request,
const RequestCallback& callback);
};
} // namespace local_discovery
#endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SESSION_H_
// 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 "chrome/browser/local_discovery/privetv2_setup_flow.h"
#include "base/logging.h"
namespace local_discovery {
scoped_ptr<PrivetV2SetupFlow> PrivetV2SetupFlow::CreateMDnsOnlyFlow(
ServiceDiscoveryClient* service_discovery_client,
const std::string& service_name) {
NOTIMPLEMENTED();
return scoped_ptr<PrivetV2SetupFlow>();
}
#if defined(ENABLE_WIFI_BOOTSTRAPPING)
scoped_ptr<PrivetV2SetupFlow> PrivetV2SetupFlow::CreateWifiFlow(
ServiceDiscoveryClient* service_discovery_client,
wifi::WifiManager* wifi_manager,
// The SSID of the network whose credentials we will be provisioning.
const std::string& credentials_ssid,
// The SSID of the device we will be provisioning.
const std::string& device_ssid) {
NOTIMPLEMENTED();
return scoped_ptr<PrivetV2SetupFlow>();
}
#endif
} // namespace local_discovery
// 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 CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SETUP_FLOW_H_
#define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SETUP_FLOW_H_
#include <string>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
namespace local_discovery {
class ServiceDiscoveryClient;
#if defined(ENABLE_WIFI_BOOTSTRAPPING)
namespace wifi {
class WifiManager;
};
#endif
class PrivetV2SetupFlow {
public:
class Delegate {
public:
typedef base::Callback<void(bool confirm)> ConfirmationCallback;
typedef base::Callback<void(const std::string& key)> CredentialsCallback;
virtual ~Delegate() {}
#if defined(ENABLE_WIFI_BOOTSTRAPPING)
virtual void OnSetupCredentialsNeeded(const std::string& ssid,
const CredentialsCallback& callback);
#endif
virtual void OnSetupConfirmationNeeded(
const std::string& confirmation_code,
const ConfirmationCallback& callback) = 0;
virtual void OnSetupDone() = 0;
virtual void OnSetupError() = 0;
};
virtual ~PrivetV2SetupFlow() {}
static scoped_ptr<PrivetV2SetupFlow> CreateMDnsOnlyFlow(
ServiceDiscoveryClient* service_discovery_client,
const std::string& service_name);
#if defined(ENABLE_WIFI_BOOTSTRAPPING)
static scoped_ptr<PrivetV2SetupFlow> CreateWifiFlow(
ServiceDiscoveryClient* service_discovery_client,
wifi::WifiManager* wifi_manager,
// The SSID of the network whose credentials we will be provisioning.
const std::string& credentials_ssid,
// The SSID of the device we will be provisioning.
const std::string& device_ssid);
#endif
virtual void Start() = 0;
};
} // namespace local_discovery
#endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SETUP_FLOW_H_
// 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 "chrome/browser/local_discovery/privetv2_setup_operation.h"
#include "base/logging.h"
namespace local_discovery {
scoped_ptr<PrivetV2SetupOperation> PrivetV2SetupOperation::Create(
PrivetV2Session* session,
const SetupStatusCallback& callback,
const std::string& ticket_id) {
NOTIMPLEMENTED();
return scoped_ptr<PrivetV2SetupOperation>();
}
} // namespace local_discovery
// 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 CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SETUP_OPERATION_H_
#define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SETUP_OPERATION_H_
#include <string>
#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
namespace local_discovery {
class PrivetV2Session;
class PrivetV2SetupOperation {
public:
enum Status { STATUS_SUCCESS, STATUS_SETUP_ERROR, STATUS_SESSION_ERROR };
virtual ~PrivetV2SetupOperation() {}
typedef base::Callback<void(Status status)> SetupStatusCallback;
static scoped_ptr<PrivetV2SetupOperation> Create(
PrivetV2Session* session,
const SetupStatusCallback& callback,
const std::string& ticket_id);
virtual void AddWifiCredentials(const std::string& ssid,
const std::string& passwd) = 0;
virtual void Start() = 0;
};
} // namespace local_discovery
#endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV2_SETUP_OPERATION_H_
......@@ -974,6 +974,12 @@
'browser/local_discovery/privet_local_printer_lister.cc',
'browser/local_discovery/privet_url_fetcher.cc',
'browser/local_discovery/privet_url_fetcher.h',
'browser/local_discovery/privetv2_session.cc',
'browser/local_discovery/privetv2_session.h',
'browser/local_discovery/privetv2_setup_flow.cc',
'browser/local_discovery/privetv2_setup_flow.h',
'browser/local_discovery/privetv2_setup_operation.cc',
'browser/local_discovery/privetv2_setup_operation.h',
'browser/local_discovery/pwg_raster_converter.cc',
'browser/local_discovery/pwg_raster_converter.h',
'browser/local_discovery/service_discovery_client_mac.h',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment