| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/enterprise_enrollment_view.h" | 5 #include "chrome/browser/chromeos/login/enterprise_enrollment_view.h" |
| 6 | 6 |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" | 9 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" |
| 10 #include "chrome/browser/chromeos/login/helper.h" | 10 #include "chrome/browser/chromeos/login/helper.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 DISALLOW_COPY_AND_ASSIGN(EnrollmentDomView); | 78 DISALLOW_COPY_AND_ASSIGN(EnrollmentDomView); |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 } // namespace | 81 } // namespace |
| 82 | 82 |
| 83 EnterpriseEnrollmentView::EnterpriseEnrollmentView( | 83 EnterpriseEnrollmentView::EnterpriseEnrollmentView( |
| 84 EnterpriseEnrollmentController* controller) | 84 EnterpriseEnrollmentController* controller) |
| 85 : controller_(controller) {} | 85 : controller_(controller), |
| 86 editable_user_(true) {} |
| 86 | 87 |
| 87 EnterpriseEnrollmentView::~EnterpriseEnrollmentView() {} | 88 EnterpriseEnrollmentView::~EnterpriseEnrollmentView() {} |
| 88 | 89 |
| 89 void EnterpriseEnrollmentView::Init() { | 90 void EnterpriseEnrollmentView::Init() { |
| 90 // Use rounded rect background. | 91 // Use rounded rect background. |
| 91 views::Painter* painter = | 92 views::Painter* painter = |
| 92 CreateWizardPainter(&BorderDefinition::kScreenBorder); | 93 CreateWizardPainter(&BorderDefinition::kScreenBorder); |
| 93 set_background(views::Background::CreateBackgroundPainter(true, painter)); | 94 set_background(views::Background::CreateBackgroundPainter(true, painter)); |
| 94 | 95 |
| 95 // Create the view that hosts the enrollment page. | 96 // Create the view that hosts the enrollment page. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 115 enrollment_page_view_->tab_contents()->render_view_host(); | 116 enrollment_page_view_->tab_contents()->render_view_host(); |
| 116 render_view_host->ExecuteJavascriptInWebFrame( | 117 render_view_host->ExecuteJavascriptInWebFrame( |
| 117 string16(), | 118 string16(), |
| 118 UTF8ToUTF16("enterpriseEnrollment.showScreen('confirmation-screen');")); | 119 UTF8ToUTF16("enterpriseEnrollment.showScreen('confirmation-screen');")); |
| 119 } | 120 } |
| 120 | 121 |
| 121 void EnterpriseEnrollmentView::ShowAuthError( | 122 void EnterpriseEnrollmentView::ShowAuthError( |
| 122 const GoogleServiceAuthError& error) { | 123 const GoogleServiceAuthError& error) { |
| 123 DictionaryValue args; | 124 DictionaryValue args; |
| 124 args.SetInteger("error", error.state()); | 125 args.SetInteger("error", error.state()); |
| 125 args.SetBoolean("editable_user", true); | 126 args.SetBoolean("editable_user", editable_user_); |
| 126 args.SetString("captchaUrl", error.captcha().image_url.spec()); | 127 args.SetString("captchaUrl", error.captcha().image_url.spec()); |
| 127 UpdateGaiaLogin(args); | 128 UpdateGaiaLogin(args); |
| 128 } | 129 } |
| 129 | 130 |
| 130 void EnterpriseEnrollmentView::ShowAccountError() { | 131 void EnterpriseEnrollmentView::ShowAccountError() { |
| 131 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR); | 132 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR); |
| 132 } | 133 } |
| 133 | 134 |
| 134 void EnterpriseEnrollmentView::ShowFatalAuthError() { | 135 void EnterpriseEnrollmentView::ShowFatalAuthError() { |
| 135 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR); | 136 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 151 } | 152 } |
| 152 | 153 |
| 153 void EnterpriseEnrollmentView::OnAuthCancelled() { | 154 void EnterpriseEnrollmentView::OnAuthCancelled() { |
| 154 controller_->CancelEnrollment(); | 155 controller_->CancelEnrollment(); |
| 155 } | 156 } |
| 156 | 157 |
| 157 void EnterpriseEnrollmentView::OnConfirmationClosed() { | 158 void EnterpriseEnrollmentView::OnConfirmationClosed() { |
| 158 controller_->CloseConfirmation(); | 159 controller_->CloseConfirmation(); |
| 159 } | 160 } |
| 160 | 161 |
| 162 bool EnterpriseEnrollmentView::GetInitialUser(std::string* user) { |
| 163 return controller_->GetInitialUser(user); |
| 164 } |
| 165 |
| 161 void EnterpriseEnrollmentView::UpdateGaiaLogin(const DictionaryValue& args) { | 166 void EnterpriseEnrollmentView::UpdateGaiaLogin(const DictionaryValue& args) { |
| 162 std::string json; | 167 std::string json; |
| 163 base::JSONWriter::Write(&args, false, &json); | 168 base::JSONWriter::Write(&args, false, &json); |
| 164 | 169 |
| 165 RenderViewHost* render_view_host = | 170 RenderViewHost* render_view_host = |
| 166 enrollment_page_view_->tab_contents()->render_view_host(); | 171 enrollment_page_view_->tab_contents()->render_view_host(); |
| 167 render_view_host->ExecuteJavascriptInWebFrame( | 172 render_view_host->ExecuteJavascriptInWebFrame( |
| 168 ASCIIToUTF16("//iframe[@id='gaialogin']"), | 173 ASCIIToUTF16("//iframe[@id='gaialogin']"), |
| 169 UTF8ToUTF16("showGaiaLogin(" + json + ");")); | 174 UTF8ToUTF16("showGaiaLogin(" + json + ");")); |
| 170 } | 175 } |
| 171 | 176 |
| 172 void EnterpriseEnrollmentView::ShowError(int message_id) { | 177 void EnterpriseEnrollmentView::ShowError(int message_id) { |
| 173 DictionaryValue args; | 178 DictionaryValue args; |
| 174 args.SetInteger("error", GoogleServiceAuthError::NONE); | 179 args.SetInteger("error", GoogleServiceAuthError::NONE); |
| 175 args.SetBoolean("editable_user", true); | 180 args.SetBoolean("editable_user", editable_user_); |
| 176 args.SetString("error_message", l10n_util::GetStringUTF16(message_id)); | 181 args.SetString("error_message", l10n_util::GetStringUTF16(message_id)); |
| 177 UpdateGaiaLogin(args); | 182 UpdateGaiaLogin(args); |
| 178 } | 183 } |
| 179 | 184 |
| 180 void EnterpriseEnrollmentView::Layout() { | 185 void EnterpriseEnrollmentView::Layout() { |
| 181 enrollment_page_view_->SetBoundsRect(GetContentsBounds()); | 186 enrollment_page_view_->SetBoundsRect(GetContentsBounds()); |
| 182 } | 187 } |
| 183 | 188 |
| 189 void EnterpriseEnrollmentView::set_editable_user(bool editable) { |
| 190 editable_user_ = editable; |
| 191 } |
| 192 |
| 184 } // namespace chromeos | 193 } // namespace chromeos |
| OLD | NEW |