Chromium Code Reviews| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 NavigationType::Type navigation_type) { | 68 NavigationType::Type navigation_type) { |
| 69 return false; | 69 return false; |
| 70 } | 70 } |
| 71 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} | 71 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} |
| 72 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} | 72 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} |
| 73 virtual bool HandleContextMenu(const ContextMenuParams& params) { | 73 virtual bool HandleContextMenu(const ContextMenuParams& params) { |
| 74 return true; | 74 return true; |
| 75 } | 75 } |
| 76 | 76 |
| 77 private: | 77 private: |
| 78 | |
|
Mattias Nissler (ping if slow)
2011/04/15 18:17:58
no need for newline.
pastarmovj
2011/04/15 18:44:49
Done.
| |
| 78 DISALLOW_COPY_AND_ASSIGN(EnrollmentDomView); | 79 DISALLOW_COPY_AND_ASSIGN(EnrollmentDomView); |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 } // namespace | 82 } // namespace |
| 82 | 83 |
| 83 EnterpriseEnrollmentView::EnterpriseEnrollmentView( | 84 EnterpriseEnrollmentView::EnterpriseEnrollmentView( |
| 84 EnterpriseEnrollmentController* controller) | 85 EnterpriseEnrollmentController* controller) |
| 85 : controller_(controller) {} | 86 : controller_(controller), |
| 87 editable_user_(true) {} | |
| 86 | 88 |
| 87 EnterpriseEnrollmentView::~EnterpriseEnrollmentView() {} | 89 EnterpriseEnrollmentView::~EnterpriseEnrollmentView() {} |
| 88 | 90 |
| 89 void EnterpriseEnrollmentView::Init() { | 91 void EnterpriseEnrollmentView::Init() { |
| 90 // Use rounded rect background. | 92 // Use rounded rect background. |
| 91 views::Painter* painter = | 93 views::Painter* painter = |
| 92 CreateWizardPainter(&BorderDefinition::kScreenBorder); | 94 CreateWizardPainter(&BorderDefinition::kScreenBorder); |
| 93 set_background(views::Background::CreateBackgroundPainter(true, painter)); | 95 set_background(views::Background::CreateBackgroundPainter(true, painter)); |
| 94 | 96 |
| 95 // Create the view that hosts the enrollment page. | 97 // Create the view that hosts the enrollment page. |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 115 enrollment_page_view_->tab_contents()->render_view_host(); | 117 enrollment_page_view_->tab_contents()->render_view_host(); |
| 116 render_view_host->ExecuteJavascriptInWebFrame( | 118 render_view_host->ExecuteJavascriptInWebFrame( |
| 117 string16(), | 119 string16(), |
| 118 UTF8ToUTF16("enterpriseEnrollment.showScreen('confirmation-screen');")); | 120 UTF8ToUTF16("enterpriseEnrollment.showScreen('confirmation-screen');")); |
| 119 } | 121 } |
| 120 | 122 |
| 121 void EnterpriseEnrollmentView::ShowAuthError( | 123 void EnterpriseEnrollmentView::ShowAuthError( |
| 122 const GoogleServiceAuthError& error) { | 124 const GoogleServiceAuthError& error) { |
| 123 DictionaryValue args; | 125 DictionaryValue args; |
| 124 args.SetInteger("error", error.state()); | 126 args.SetInteger("error", error.state()); |
| 125 args.SetBoolean("editable_user", true); | 127 args.SetBoolean("editable_user", editable_user_); |
| 126 args.SetString("captchaUrl", error.captcha().image_url.spec()); | 128 args.SetString("captchaUrl", error.captcha().image_url.spec()); |
| 127 UpdateGaiaLogin(args); | 129 UpdateGaiaLogin(args); |
| 128 } | 130 } |
| 129 | 131 |
| 130 void EnterpriseEnrollmentView::ShowAccountError() { | 132 void EnterpriseEnrollmentView::ShowAccountError() { |
| 131 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR); | 133 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR); |
| 132 } | 134 } |
| 133 | 135 |
| 134 void EnterpriseEnrollmentView::ShowFatalAuthError() { | 136 void EnterpriseEnrollmentView::ShowFatalAuthError() { |
| 135 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR); | 137 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 151 } | 153 } |
| 152 | 154 |
| 153 void EnterpriseEnrollmentView::OnAuthCancelled() { | 155 void EnterpriseEnrollmentView::OnAuthCancelled() { |
| 154 controller_->CancelEnrollment(); | 156 controller_->CancelEnrollment(); |
| 155 } | 157 } |
| 156 | 158 |
| 157 void EnterpriseEnrollmentView::OnConfirmationClosed() { | 159 void EnterpriseEnrollmentView::OnConfirmationClosed() { |
| 158 controller_->CloseConfirmation(); | 160 controller_->CloseConfirmation(); |
| 159 } | 161 } |
| 160 | 162 |
| 163 bool EnterpriseEnrollmentView::SetInitialUser(std::string* user) { | |
| 164 return controller_->GetInitialUser(user); | |
| 165 } | |
| 166 | |
| 161 void EnterpriseEnrollmentView::UpdateGaiaLogin(const DictionaryValue& args) { | 167 void EnterpriseEnrollmentView::UpdateGaiaLogin(const DictionaryValue& args) { |
| 162 std::string json; | 168 std::string json; |
| 163 base::JSONWriter::Write(&args, false, &json); | 169 base::JSONWriter::Write(&args, false, &json); |
| 164 | 170 |
| 165 RenderViewHost* render_view_host = | 171 RenderViewHost* render_view_host = |
| 166 enrollment_page_view_->tab_contents()->render_view_host(); | 172 enrollment_page_view_->tab_contents()->render_view_host(); |
| 167 render_view_host->ExecuteJavascriptInWebFrame( | 173 render_view_host->ExecuteJavascriptInWebFrame( |
| 168 ASCIIToUTF16("//iframe[@id='gaialogin']"), | 174 ASCIIToUTF16("//iframe[@id='gaialogin']"), |
| 169 UTF8ToUTF16("showGaiaLogin(" + json + ");")); | 175 UTF8ToUTF16("showGaiaLogin(" + json + ");")); |
| 170 } | 176 } |
| 171 | 177 |
| 172 void EnterpriseEnrollmentView::ShowError(int message_id) { | 178 void EnterpriseEnrollmentView::ShowError(int message_id) { |
| 173 DictionaryValue args; | 179 DictionaryValue args; |
| 174 args.SetInteger("error", GoogleServiceAuthError::NONE); | 180 args.SetInteger("error", GoogleServiceAuthError::NONE); |
| 175 args.SetBoolean("editable_user", true); | 181 args.SetBoolean("editable_user", editable_user_); |
| 176 args.SetString("error_message", l10n_util::GetStringUTF16(message_id)); | 182 args.SetString("error_message", l10n_util::GetStringUTF16(message_id)); |
| 177 UpdateGaiaLogin(args); | 183 UpdateGaiaLogin(args); |
| 178 } | 184 } |
| 179 | 185 |
| 180 void EnterpriseEnrollmentView::Layout() { | 186 void EnterpriseEnrollmentView::Layout() { |
| 181 enrollment_page_view_->SetBoundsRect(GetContentsBounds()); | 187 enrollment_page_view_->SetBoundsRect(GetContentsBounds()); |
| 182 } | 188 } |
| 183 | 189 |
| 190 void EnterpriseEnrollmentView::editable_user(bool editable) { | |
| 191 editable_user_ = editable; | |
| 192 } | |
| 193 | |
| 184 } // namespace chromeos | 194 } // namespace chromeos |
| OLD | NEW |