summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-13 00:47:19 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-01-13 00:47:19 +0000
commit6fd024b93e4a708a767c1892e5091e3585a5c72f (patch)
treeb0add200ec27e58d517d820602ea61c75db0da71
parent346fb30b0ee89a94ea203b8e60307e10c5466a56 (diff)
downloadchromium_src-6fd024b93e4a708a767c1892e5091e3585a5c72f.zip
chromium_src-6fd024b93e4a708a767c1892e5091e3585a5c72f.tar.gz
chromium_src-6fd024b93e4a708a767c1892e5091e3585a5c72f.tar.bz2
Bugfixes for the remoting setup wizard:
1. Proper error message when directory rejects request - this requires changes in gaia_login.html to support custom error messages. 2. Fixed login OTP-enabled account. BUG=67218 TEST=None Review URL: http://codereview.chromium.org/6178012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71277 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd3
-rw-r--r--chrome/browser/remoting/remoting_resources_source.cc10
-rw-r--r--chrome/browser/remoting/setup_flow_login_step.cc31
-rw-r--r--chrome/browser/remoting/setup_flow_login_step.h6
-rw-r--r--chrome/browser/remoting/setup_flow_register_step.cc7
-rw-r--r--chrome/browser/sync/resources/gaia_login.html45
6 files changed, 76 insertions, 26 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 3ca5235..04487da 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -8465,6 +8465,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_REMOTING_REGISTRATION_FAILED_MESSAGE" desc="Message shown during remoting host setup if there was an error registering the host.">
Failed to register this computer for remote access.
</message>
+ <message name="IDS_REMOTING_REGISTRATION_ACCESS_DENIED" desc="Error message during remoting host setup if access to the remoting directory was denied.">
+ Access to the remoting host directory was denied. Please try with another account.
+ </message>
<message name="IDS_REMOTING_RETRY_BUTTON_TEXT" desc="Text for retry button">
Retry
</message>
diff --git a/chrome/browser/remoting/remoting_resources_source.cc b/chrome/browser/remoting/remoting_resources_source.cc
index 776db3e..5c8d869 100644
--- a/chrome/browser/remoting/remoting_resources_source.cc
+++ b/chrome/browser/remoting/remoting_resources_source.cc
@@ -20,6 +20,7 @@
#include "grit/browser_resources.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
+#include "grit/locale_settings.h"
// Define the values of standard URLs.
const char RemotingResourcesSource::kInvalidPasswordHelpUrl[] =
@@ -87,6 +88,15 @@ void RemotingResourcesSource::StartDataRequest(const std::string& path_raw,
l10n_util::GetStringUTF16(IDS_SYNC_ERROR_SIGNING_IN));
localized_strings.SetString("captchainstructions",
l10n_util::GetStringUTF16(IDS_SYNC_GAIA_CAPTCHA_INSTRUCTIONS));
+ localized_strings.SetString("invalidaccesscode",
+ l10n_util::GetStringUTF16(IDS_SYNC_INVALID_ACCESS_CODE_LABEL));
+ localized_strings.SetString("enteraccesscode",
+ l10n_util::GetStringUTF16(IDS_SYNC_ENTER_ACCESS_CODE_LABEL));
+ localized_strings.SetString("getaccesscodehelp",
+ l10n_util::GetStringUTF16(IDS_SYNC_ACCESS_CODE_HELP_LABEL));
+ localized_strings.SetString("getaccesscodeurl",
+ l10n_util::GetStringUTF16(IDS_SYNC_GET_ACCESS_CODE_URL));
+
static const base::StringPiece html(ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_GAIA_LOGIN_HTML));
SetFontAndTextDirection(&localized_strings);
diff --git a/chrome/browser/remoting/setup_flow_login_step.cc b/chrome/browser/remoting/setup_flow_login_step.cc
index 71ee79b..ada7d2f 100644
--- a/chrome/browser/remoting/setup_flow_login_step.cc
+++ b/chrome/browser/remoting/setup_flow_login_step.cc
@@ -20,6 +20,11 @@ namespace remoting {
static const wchar_t kLoginIFrameXPath[] = L"//iframe[@id='login']";
SetupFlowLoginStep::SetupFlowLoginStep() { }
+
+SetupFlowLoginStep::SetupFlowLoginStep(const string16& error_message)
+ : error_message_(error_message) {
+}
+
SetupFlowLoginStep::~SetupFlowLoginStep() { }
void SetupFlowLoginStep::HandleMessage(const std::string& message,
@@ -41,17 +46,18 @@ void SetupFlowLoginStep::HandleMessage(const std::string& message,
CHECK(parsed_value->IsType(Value::TYPE_DICTIONARY));
- std::string username, password, captcha;
+ std::string username, password, captcha, access_code;
const DictionaryValue* result =
static_cast<const DictionaryValue*>(parsed_value.get());
if (!result->GetString("user", &username) ||
!result->GetString("pass", &password) ||
- !result->GetString("captcha", &captcha)) {
+ !result->GetString("captcha", &captcha) ||
+ !result->GetString("access_code", &access_code)) {
NOTREACHED() << "Unable to parse auth data";
return;
}
- OnUserSubmittedAuth(username, password, captcha);
+ OnUserSubmittedAuth(username, password, captcha, access_code);
}
}
@@ -62,14 +68,22 @@ void SetupFlowLoginStep::Cancel() {
void SetupFlowLoginStep::OnUserSubmittedAuth(const std::string& user,
const std::string& password,
- const std::string& captcha) {
+ const std::string& captcha,
+ const std::string& access_code) {
flow()->context()->login = user;
// Start the authenticator.
authenticator_.reset(
new GaiaAuthFetcher(this, GaiaConstants::kChromeSource,
flow()->profile()->GetRequestContext()));
- authenticator_->StartClientLogin(user, password,
+
+ std::string remoting_password;
+ if (!access_code.empty())
+ remoting_password = access_code;
+ else
+ remoting_password = password;
+
+ authenticator_->StartClientLogin(user, remoting_password,
GaiaConstants::kRemotingService,
"", captcha,
GaiaAuthFetcher::HostedAccountsAllowed);
@@ -112,6 +126,8 @@ void SetupFlowLoginStep::DoStart() {
// TODO(sergeyu): Supply current login name if the service was started before.
args.SetString("user", "");
args.SetBoolean("editable_user", true);
+ if (!error_message_.empty())
+ args.SetString("error_message", error_message_);
ShowGaiaLogin(args);
}
@@ -123,14 +139,13 @@ void SetupFlowLoginStep::ShowGaiaLogin(const DictionaryValue& args) {
std::string json;
base::JSONWriter::Write(&args, false, &json);
- std::wstring javascript = std::wstring(L"showGaiaLogin") +
- L"(" + UTF8ToWide(json) + L");";
+ std::wstring javascript = std::wstring(L"showGaiaLogin(") +
+ UTF8ToWide(json) + L");";
ExecuteJavascriptInIFrame(kLoginIFrameXPath, javascript);
}
void SetupFlowLoginStep::ShowGaiaFailed(const GoogleServiceAuthError& error) {
DictionaryValue args;
- args.SetString("user", "");
args.SetInteger("error", error.state());
args.SetBoolean("editable_user", true);
args.SetString("captchaUrl", error.captcha().image_url.spec());
diff --git a/chrome/browser/remoting/setup_flow_login_step.h b/chrome/browser/remoting/setup_flow_login_step.h
index a7d8911..6a41d99 100644
--- a/chrome/browser/remoting/setup_flow_login_step.h
+++ b/chrome/browser/remoting/setup_flow_login_step.h
@@ -15,6 +15,7 @@ namespace remoting {
class SetupFlowLoginStep : public SetupFlowStepBase, public GaiaAuthConsumer {
public:
SetupFlowLoginStep();
+ SetupFlowLoginStep(const string16& error_message);
virtual ~SetupFlowLoginStep();
// SetupFlowStep implementation.
@@ -36,12 +37,15 @@ class SetupFlowLoginStep : public SetupFlowStepBase, public GaiaAuthConsumer {
private:
void OnUserSubmittedAuth(const std::string& user,
const std::string& password,
- const std::string& captcha);
+ const std::string& captcha,
+ const std::string& access_code);
void ShowGaiaLogin(const DictionaryValue& args);
void ShowGaiaSuccessAndSettingUp();
void ShowGaiaFailed(const GoogleServiceAuthError& error);
+ string16 error_message_;
+
// Fetcher to obtain the Chromoting Directory token.
scoped_ptr<GaiaAuthFetcher> authenticator_;
diff --git a/chrome/browser/remoting/setup_flow_register_step.cc b/chrome/browser/remoting/setup_flow_register_step.cc
index 3adcad2..1e85388 100644
--- a/chrome/browser/remoting/setup_flow_register_step.cc
+++ b/chrome/browser/remoting/setup_flow_register_step.cc
@@ -41,12 +41,13 @@ void SetupFlowRegisterStep::OnRequestDone(DirectoryAddRequest::Result result,
FinishStep(new SetupFlowStartHostStep());
break;
case DirectoryAddRequest::ERROR_EXISTS:
- LOG(INFO) << "Chromoting host is already reagistered.";
+ LOG(INFO) << "Chromoting host is already registered.";
FinishStep(new SetupFlowStartHostStep());
break;
case DirectoryAddRequest::ERROR_AUTH:
- LOG(ERROR) << "Chromoting Directory didn't accept auth token.";
- FinishStep(new SetupFlowLoginStep());
+ LOG(ERROR) << "Access denied by Chromoting Directory.";
+ FinishStep(new SetupFlowLoginStep(l10n_util::GetStringUTF16(
+ IDS_REMOTING_REGISTRATION_ACCESS_DENIED)));
break;
default:
LOG(ERROR) << "Chromoting Host registration failed: "
diff --git a/chrome/browser/sync/resources/gaia_login.html b/chrome/browser/sync/resources/gaia_login.html
index 2ae8727..ff0defe 100644
--- a/chrome/browser/sync/resources/gaia_login.html
+++ b/chrome/browser/sync/resources/gaia_login.html
@@ -176,11 +176,18 @@
}
function showGaiaLogin(args) {
- var throbber = document.getElementById('throbber_container');
- throbber.style.display = "none";
+ document.getElementById('throbber_container').style.display = "none";
+ document.getElementById('Email').disabled = false;
+ document.getElementById('Passwd').disabled = false;
+
var f = document.getElementById("gaia_loginform");
if (f) {
- f.Email.value = args.user;
+ if (args.user != undefined) {
+ if (f.Email.value != args.user)
+ f.Passwd.value = ""; // Reset the password field
+ f.Email.value = args.user;
+ }
+
if (!args.editable_user) {
f.Email.style.display = 'none';
var span = document.getElementById('email_readonly');
@@ -191,6 +198,7 @@
f.AccessCode.disabled = true;
}
+
if (1 == args.error) {
var access_code = document.getElementById('AccessCode');
if (access_code.value && access_code.value != "") {
@@ -199,18 +207,18 @@
} else {
setElementDisplay("errormsg_1_Password", 'table-row');
}
- setBlurbError();
- }
- if (3 == args.error) {
+ setBlurbError(args.error_message);
+ } else if (3 == args.error) {
setElementDisplay("errormsg_0_Connection", 'table-row');
- setBlurbError();
- }
- if (4 == args.error) {
+ setBlurbError(args.error_message);
+ } else if (4 == args.error) {
showCaptcha(args);
- }
- if (8 == args.error) {
+ } else if (8 == args.error) {
showAccessCodeRequired();
+ } else if (args.error_message) {
+ setBlurbError(args.error_message);
}
+
document.getElementById("signIn").disabled = false;
document.getElementById("signIn").value = templateData['signin'];
gaia_setFocus();
@@ -311,14 +319,22 @@
if (d)
d.style.display = display;
}
-
+
function hideBlurb() {
setElementDisplay('top_blurb', 'none');
}
- function setBlurbError() {
+ function setBlurbError(error_message) {
if (g_is_captcha_challenge_active)
return; // No blurb in captcha challenge mode.
+ if (error_message) {
+ document.getElementById('error_signing_in').style.display = 'none';
+ document.getElementById('error_custom').style.display = 'inline';
+ document.getElementById('error_custom').textContent = error_message;
+ } else {
+ document.getElementById('error_signing_in').style.display = 'inline';
+ document.getElementById('error_custom').style.display = 'none';
+ }
document.getElementById("top_blurb_error").style.visibility = "visible";
document.getElementById('Email').disabled = false;
document.getElementById('Passwd').disabled = false;
@@ -372,7 +388,8 @@
<span i18n-content="introduction"></span>
</div>
<div id="top_blurb_error" style="visibility:hidden">
- <span i18n-content="errorsigningin"></span>
+ <span id="error_signing_in" i18n-content="errorsigningin"></span>
+ <span id="error_custom" style="display:none;"></span>
</div>
<form id="gaia_loginform" onsubmit="sendCredentialsAndClose(); return false;">
<div id="gaia_loginbox">