Commit 54dd68c0 authored by Kyle Horimoto's avatar Kyle Horimoto Committed by Commit Bot

[CrOS MultiDevice] Implement "Retry" settings button functionality.

Previously, the button was not hooked up to anything. Now, clicking the
button results in a call to the MultiDeviceSetup service, which
completes the retry attempt.

Bug: 824568
Change-Id: I0de5ead024f63dda2cb3a26dfb07a987ab54b877
Reviewed-on: https://chromium-review.googlesource.com/1159202
Commit-Queue: Kyle Horimoto <khorimoto@chromium.org>
Reviewed-by: default avatarTommy Li <tommycli@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580413}
parent e452c958
...@@ -9,6 +9,8 @@ cr.define('settings', function() { ...@@ -9,6 +9,8 @@ cr.define('settings', function() {
/** @return {!Promise<!MultiDevicePageContentData>} */ /** @return {!Promise<!MultiDevicePageContentData>} */
getPageContentData() {} getPageContentData() {}
retryPendingHostSetup() {}
} }
/** /**
...@@ -24,6 +26,11 @@ cr.define('settings', function() { ...@@ -24,6 +26,11 @@ cr.define('settings', function() {
getPageContentData() { getPageContentData() {
return cr.sendWithPromise('getPageContentData'); return cr.sendWithPromise('getPageContentData');
} }
/** @override */
retryPendingHostSetup() {
chrome.send('retryPendingHostSetup');
}
} }
cr.addSingletonGetter(MultiDeviceBrowserProxyImpl); cr.addSingletonGetter(MultiDeviceBrowserProxyImpl);
......
...@@ -135,13 +135,11 @@ Polymer({ ...@@ -135,13 +135,11 @@ Polymer({
this.browserProxy_.showMultiDeviceSetupDialog(); this.browserProxy_.showMultiDeviceSetupDialog();
return; return;
case settings.MultiDeviceSettingsMode.HOST_SET_WAITING_FOR_SERVER: case settings.MultiDeviceSettingsMode.HOST_SET_WAITING_FOR_SERVER:
// TODO(jordynass): Implement this when API is ready. // Intentional fall-through.
console.log('Trying to connect to server again.');
return;
case settings.MultiDeviceSettingsMode.HOST_SET_WAITING_FOR_VERIFICATION: case settings.MultiDeviceSettingsMode.HOST_SET_WAITING_FOR_VERIFICATION:
// TODO(jordynass): Implement this when API is ready. // If this device is waiting for action on the server or the host
console.log('Trying to verify multidevice connection.'); // device, clicking the button should trigger this action.
return; this.browserProxy_.retryPendingHostSetup();
} }
}, },
}); });
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/logging.h" #include "base/logging.h"
#include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h" #include "chrome/browser/ui/webui/chromeos/multidevice_setup/multidevice_setup_dialog.h"
#include "chromeos/components/proximity_auth/logging/logging.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
namespace chromeos { namespace chromeos {
...@@ -45,6 +46,14 @@ std::unique_ptr<base::DictionaryValue> GeneratePageContentDataDictionary( ...@@ -45,6 +46,14 @@ std::unique_ptr<base::DictionaryValue> GeneratePageContentDataDictionary(
return page_content_dictionary; return page_content_dictionary;
} }
void OnRetrySetHostNowResult(bool success) {
if (success)
return;
PA_LOG(WARNING) << "OnRetrySetHostNowResult(): Attempt to retry setting the "
<< "host device failed.";
}
} // namespace } // namespace
MultideviceHandler::MultideviceHandler( MultideviceHandler::MultideviceHandler(
...@@ -64,6 +73,10 @@ void MultideviceHandler::RegisterMessages() { ...@@ -64,6 +73,10 @@ void MultideviceHandler::RegisterMessages() {
"getPageContentData", "getPageContentData",
base::BindRepeating(&MultideviceHandler::HandleGetPageContent, base::BindRepeating(&MultideviceHandler::HandleGetPageContent,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback(
"retryPendingHostSetup",
base::BindRepeating(&MultideviceHandler::HandleRetryPendingHostSetup,
base::Unretained(this)));
} }
void MultideviceHandler::OnJavascriptAllowed() { void MultideviceHandler::OnJavascriptAllowed() {
...@@ -105,6 +118,13 @@ void MultideviceHandler::HandleGetPageContent(const base::ListValue* args) { ...@@ -105,6 +118,13 @@ void MultideviceHandler::HandleGetPageContent(const base::ListValue* args) {
callback_weak_ptr_factory_.GetWeakPtr(), callback_id)); callback_weak_ptr_factory_.GetWeakPtr(), callback_id));
} }
void MultideviceHandler::HandleRetryPendingHostSetup(
const base::ListValue* args) {
DCHECK(args->empty());
multidevice_setup_client_->RetrySetHostNow(
base::BindOnce(&OnRetrySetHostNowResult));
}
void MultideviceHandler::OnHostStatusFetched( void MultideviceHandler::OnHostStatusFetched(
const std::string& js_callback_id, const std::string& js_callback_id,
multidevice_setup::mojom::HostStatus host_status, multidevice_setup::mojom::HostStatus host_status,
......
...@@ -42,6 +42,7 @@ class MultideviceHandler ...@@ -42,6 +42,7 @@ class MultideviceHandler
void HandleShowMultiDeviceSetupDialog(const base::ListValue* args); void HandleShowMultiDeviceSetupDialog(const base::ListValue* args);
void HandleGetPageContent(const base::ListValue* args); void HandleGetPageContent(const base::ListValue* args);
void HandleRetryPendingHostSetup(const base::ListValue* args);
void OnHostStatusFetched( void OnHostStatusFetched(
const std::string& js_callback_id, const std::string& js_callback_id,
......
...@@ -122,6 +122,13 @@ class MultideviceHandlerTest : public testing::Test { ...@@ -122,6 +122,13 @@ class MultideviceHandlerTest : public testing::Test {
VerifyPageContentDict(call_data.arg2(), host_status, host_device); VerifyPageContentDict(call_data.arg2(), host_status, host_device);
} }
void CallRetryPendingHostSetup(bool success) {
base::ListValue empty_args;
test_web_ui()->HandleReceivedMessage("retryPendingHostSetup", &empty_args);
fake_multidevice_setup_client()->InvokePendingRetrySetHostNowCallback(
success);
}
const content::TestWebUI::CallData& CallDataAtIndex(size_t index) { const content::TestWebUI::CallData& CallDataAtIndex(size_t index) {
return *test_web_ui_->call_data()[index]; return *test_web_ui_->call_data()[index];
} }
...@@ -177,6 +184,11 @@ TEST_F(MultideviceHandlerTest, HostStatusUpdates) { ...@@ -177,6 +184,11 @@ TEST_F(MultideviceHandlerTest, HostStatusUpdates) {
test_device_); test_device_);
} }
TEST_F(MultideviceHandlerTest, RetryPendingHostSetup) {
CallRetryPendingHostSetup(true /* success */);
CallRetryPendingHostSetup(false /* success */);
}
} // namespace settings } // namespace settings
} // namespace chromeos } // namespace chromeos
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