Commit 656b3f2a authored by Jamie Walch's avatar Jamie Walch Committed by Commit Bot

Add --host-id option to start_host.

Change-Id: I612abe51acde87b374038db519b1e5048ffc337a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2492943Reviewed-by: default avatarJoe Downing <joedow@google.com>
Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Commit-Queue: Jamie Walch <jamiewalch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#820018}
parent 58aed3cf
...@@ -46,16 +46,17 @@ std::unique_ptr<HostStarter> HostStarter::Create( ...@@ -46,16 +46,17 @@ std::unique_ptr<HostStarter> HostStarter::Create(
remoting::DaemonController::Create())); remoting::DaemonController::Create()));
} }
void HostStarter::StartHost( void HostStarter::StartHost(const std::string& host_id,
const std::string& host_name, const std::string& host_name,
const std::string& host_pin, const std::string& host_pin,
bool consent_to_data_collection, bool consent_to_data_collection,
const std::string& auth_code, const std::string& auth_code,
const std::string& redirect_url, const std::string& redirect_url,
CompletionCallback on_done) { CompletionCallback on_done) {
DCHECK(main_task_runner_->BelongsToCurrentThread()); DCHECK(main_task_runner_->BelongsToCurrentThread());
DCHECK(on_done_.is_null()); DCHECK(on_done_.is_null());
host_id_ = host_id;
host_name_ = host_name; host_name_ = host_name;
host_pin_ = host_pin; host_pin_ = host_pin;
consent_to_data_collection_ = consent_to_data_collection; consent_to_data_collection_ = consent_to_data_collection;
...@@ -120,7 +121,8 @@ void HostStarter::OnGetUserEmailResponse(const std::string& user_email) { ...@@ -120,7 +121,8 @@ void HostStarter::OnGetUserEmailResponse(const std::string& user_email) {
// This is the first callback, with the host owner credentials. Store the // This is the first callback, with the host owner credentials. Store the
// owner's email, and register the host. // owner's email, and register the host.
host_owner_ = user_email; host_owner_ = user_email;
host_id_ = base::GenerateGUID(); if (host_id_.empty())
host_id_ = base::GenerateGUID();
key_pair_ = RsaKeyPair::Generate(); key_pair_ = RsaKeyPair::Generate();
std::string host_client_id; std::string host_client_id;
......
...@@ -44,7 +44,8 @@ class HostStarter : public gaia::GaiaOAuthClient::Delegate, ...@@ -44,7 +44,8 @@ class HostStarter : public gaia::GaiaOAuthClient::Delegate,
// Registers a new host with the Chromoting service, and starts it. // Registers a new host with the Chromoting service, and starts it.
// |auth_code| must be a valid OAuth2 authorization code, typically acquired // |auth_code| must be a valid OAuth2 authorization code, typically acquired
// from a browser. This method uses that code to get an OAuth2 refresh token. // from a browser. This method uses that code to get an OAuth2 refresh token.
void StartHost(const std::string& host_name, void StartHost(const std::string& host_id,
const std::string& host_name,
const std::string& host_pin, const std::string& host_pin,
bool consent_to_data_collection, bool consent_to_data_collection,
const std::string& auth_code, const std::string& auth_code,
......
...@@ -143,6 +143,7 @@ int StartHostMain(int argc, char** argv) { ...@@ -143,6 +143,7 @@ int StartHostMain(int argc, char** argv) {
std::string host_pin = command_line->GetSwitchValueASCII("pin"); std::string host_pin = command_line->GetSwitchValueASCII("pin");
std::string auth_code = command_line->GetSwitchValueASCII("code"); std::string auth_code = command_line->GetSwitchValueASCII("code");
std::string redirect_url = command_line->GetSwitchValueASCII("redirect-url"); std::string redirect_url = command_line->GetSwitchValueASCII("redirect-url");
std::string host_id = command_line->GetSwitchValueASCII("host-id");
#if defined(OS_POSIX) #if defined(OS_POSIX)
// Check if current user is root. If it is root, then throw an error message. // Check if current user is root. If it is root, then throw an error message.
...@@ -232,7 +233,7 @@ int StartHostMain(int argc, char** argv) { ...@@ -232,7 +233,7 @@ int StartHostMain(int argc, char** argv) {
// Start the host. // Start the host.
std::unique_ptr<HostStarter> host_starter(HostStarter::Create( std::unique_ptr<HostStarter> host_starter(HostStarter::Create(
url_loader_factory_owner.GetURLLoaderFactory())); url_loader_factory_owner.GetURLLoaderFactory()));
host_starter->StartHost(host_name, host_pin, host_starter->StartHost(host_id, host_name, host_pin,
/*consent_to_data_collection=*/true, auth_code, /*consent_to_data_collection=*/true, auth_code,
redirect_url, base::BindOnce(&OnDone)); redirect_url, base::BindOnce(&OnDone));
......
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