summaryrefslogtreecommitdiffstats
path: root/chrome/browser/remoting
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/remoting')
-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
4 files changed, 42 insertions, 12 deletions
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: "