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/cros/cros_library.h" | |
| 10 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | |
| 9 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" | 11 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" |
| 10 #include "chrome/browser/chromeos/login/helper.h" | 12 #include "chrome/browser/chromeos/login/helper.h" |
| 11 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 13 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
| 12 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 13 #include "chrome/browser/ui/webui/chromeos/enterprise_enrollment_ui.h" | 15 #include "chrome/browser/ui/webui/chromeos/enterprise_enrollment_ui.h" |
| 14 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 15 #include "content/browser/renderer_host/render_view_host.h" | 17 #include "content/browser/renderer_host/render_view_host.h" |
| 16 #include "content/browser/site_instance.h" | 18 #include "content/browser/site_instance.h" |
| 17 #include "content/browser/tab_contents/tab_contents_delegate.h" | 19 #include "content/browser/tab_contents/tab_contents_delegate.h" |
| 18 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 NavigationType::Type navigation_type) { | 70 NavigationType::Type navigation_type) { |
| 69 return false; | 71 return false; |
| 70 } | 72 } |
| 71 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} | 73 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} |
| 72 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} | 74 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} |
| 73 virtual bool HandleContextMenu(const ContextMenuParams& params) { | 75 virtual bool HandleContextMenu(const ContextMenuParams& params) { |
| 74 return true; | 76 return true; |
| 75 } | 77 } |
| 76 | 78 |
| 77 private: | 79 private: |
| 80 | |
| 78 DISALLOW_COPY_AND_ASSIGN(EnrollmentDomView); | 81 DISALLOW_COPY_AND_ASSIGN(EnrollmentDomView); |
| 79 }; | 82 }; |
| 80 | 83 |
| 81 } // namespace | 84 } // namespace |
| 82 | 85 |
| 83 EnterpriseEnrollmentView::EnterpriseEnrollmentView( | 86 EnterpriseEnrollmentView::EnterpriseEnrollmentView( |
| 84 EnterpriseEnrollmentController* controller) | 87 EnterpriseEnrollmentController* controller) |
| 85 : controller_(controller) {} | 88 : controller_(controller), |
| 89 editable_user_(true) {} | |
| 86 | 90 |
| 87 EnterpriseEnrollmentView::~EnterpriseEnrollmentView() {} | 91 EnterpriseEnrollmentView::~EnterpriseEnrollmentView() {} |
| 88 | 92 |
| 89 void EnterpriseEnrollmentView::Init() { | 93 void EnterpriseEnrollmentView::Init() { |
| 90 // Use rounded rect background. | 94 // Use rounded rect background. |
| 91 views::Painter* painter = | 95 views::Painter* painter = |
| 92 CreateWizardPainter(&BorderDefinition::kScreenBorder); | 96 CreateWizardPainter(&BorderDefinition::kScreenBorder); |
| 93 set_background(views::Background::CreateBackgroundPainter(true, painter)); | 97 set_background(views::Background::CreateBackgroundPainter(true, painter)); |
| 94 | 98 |
| 95 // Create the view that hosts the enrollment page. | 99 // Create the view that hosts the enrollment page. |
| 96 enrollment_page_view_ = new EnrollmentDomView(); | 100 enrollment_page_view_ = new EnrollmentDomView(); |
| 97 enrollment_page_view_->set_border( | 101 enrollment_page_view_->set_border( |
| 98 views::Border::CreateEmptyBorder(kBorderSize, kBorderSize, | 102 views::Border::CreateEmptyBorder(kBorderSize, kBorderSize, |
| 99 kBorderSize, kBorderSize)); | 103 kBorderSize, kBorderSize)); |
| 100 | 104 |
| 101 AddChildView(enrollment_page_view_); | 105 AddChildView(enrollment_page_view_); |
| 102 | 106 |
| 103 // Load the enrollment page. | 107 // Load the enrollment page. |
| 104 Profile* profile = ProfileManager::GetDefaultProfile(); | 108 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 105 GURL url(chrome::kChromeUIEnterpriseEnrollmentURL); | 109 GURL url(chrome::kChromeUIEnterpriseEnrollmentURL); |
| 106 enrollment_page_view_->Init( | 110 enrollment_page_view_->Init( |
| 107 profile, SiteInstance::CreateSiteInstanceForURL(profile, url)); | 111 profile, SiteInstance::CreateSiteInstanceForURL(profile, url)); |
| 108 EnterpriseEnrollmentUI::SetController(enrollment_page_view_->tab_contents(), | 112 EnterpriseEnrollmentUI::SetController(enrollment_page_view_->tab_contents(), |
| 109 this); | 113 this); |
| 110 enrollment_page_view_->LoadURL(url); | 114 enrollment_page_view_->LoadURL(url); |
| 115 | |
| 116 // Check lockbox data and update the view if needed. | |
| 117 chromeos::CryptohomeLibrary* cryptohome = | |
| 118 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); | |
| 119 // TODO(pastarmovj): This is being done either on the eula screen or on first | |
| 120 // login so maybe we should do it already here? If not remove. | |
| 121 if (cryptohome) { | |
| 122 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned() && | |
| 123 !cryptohome->TpmIsOwned()) { | |
| 124 cryptohome->TpmCanAttemptOwnership(); | |
|
kmixter1
2011/04/15 02:06:51
indentation
pastarmovj
2011/04/15 10:05:01
Done.
| |
| 125 } | |
| 126 | |
| 127 if (cryptohome->InstallAttributesIsReady() && | |
| 128 !cryptohome->InstallAttributesIsFirstInstall()) { | |
| 129 std::string value; | |
| 130 if (cryptohome->InstallAttributesGet("enterprise.owned", &value) && | |
| 131 0 == value.compare("true")) { | |
| 132 if (cryptohome->InstallAttributesGet("enterprise.user", &value)) { | |
| 133 DictionaryValue args; | |
| 134 args.SetString("user", value); | |
|
kmixter1
2011/04/15 02:06:51
A comment here may be in order: is this code enfor
pastarmovj
2011/04/15 10:05:01
Done.
| |
| 135 args.SetBoolean("editable_user", false); | |
| 136 editable_user_ = false; | |
| 137 UpdateGaiaLogin(args); | |
| 138 return; | |
| 139 } | |
| 140 } | |
| 141 LOG(ERROR) << "Enrollment can not proceed because the lockbox has been " | |
| 142 << "locked already but does not contain valid data."; | |
| 143 // TODO(pastarmovj): Put some new error message here! | |
| 144 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR); | |
| 145 } | |
| 146 } else { | |
| 147 LOG(ERROR) << "Enrollment can not proceed because the lockbox can not " | |
| 148 << "be accessed."; | |
| 149 // TODO(pastarmovj): Put some new error message here! | |
| 150 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_ENROLLMENT_ERROR); | |
| 151 } | |
| 111 } | 152 } |
| 112 | 153 |
| 113 void EnterpriseEnrollmentView::ShowConfirmationScreen() { | 154 void EnterpriseEnrollmentView::ShowConfirmationScreen() { |
| 114 RenderViewHost* render_view_host = | 155 RenderViewHost* render_view_host = |
| 115 enrollment_page_view_->tab_contents()->render_view_host(); | 156 enrollment_page_view_->tab_contents()->render_view_host(); |
| 116 render_view_host->ExecuteJavascriptInWebFrame( | 157 render_view_host->ExecuteJavascriptInWebFrame( |
| 117 string16(), | 158 string16(), |
| 118 UTF8ToUTF16("enterpriseEnrollment.showScreen('confirmation-screen');")); | 159 UTF8ToUTF16("enterpriseEnrollment.showScreen('confirmation-screen');")); |
| 119 } | 160 } |
| 120 | 161 |
| 121 void EnterpriseEnrollmentView::ShowAuthError( | 162 void EnterpriseEnrollmentView::ShowAuthError( |
| 122 const GoogleServiceAuthError& error) { | 163 const GoogleServiceAuthError& error) { |
| 123 DictionaryValue args; | 164 DictionaryValue args; |
| 124 args.SetInteger("error", error.state()); | 165 args.SetInteger("error", error.state()); |
| 125 args.SetBoolean("editable_user", true); | 166 args.SetBoolean("editable_user", editable_user_); |
| 126 args.SetString("captchaUrl", error.captcha().image_url.spec()); | 167 args.SetString("captchaUrl", error.captcha().image_url.spec()); |
| 127 UpdateGaiaLogin(args); | 168 UpdateGaiaLogin(args); |
| 128 } | 169 } |
| 129 | 170 |
| 130 void EnterpriseEnrollmentView::ShowAccountError() { | 171 void EnterpriseEnrollmentView::ShowAccountError() { |
| 131 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR); | 172 ShowError(IDS_ENTERPRISE_ENROLLMENT_ACCOUNT_ERROR); |
| 132 } | 173 } |
| 133 | 174 |
| 134 void EnterpriseEnrollmentView::ShowFatalAuthError() { | 175 void EnterpriseEnrollmentView::ShowFatalAuthError() { |
| 135 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR); | 176 ShowError(IDS_ENTERPRISE_ENROLLMENT_FATAL_AUTH_ERROR); |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 165 RenderViewHost* render_view_host = | 206 RenderViewHost* render_view_host = |
| 166 enrollment_page_view_->tab_contents()->render_view_host(); | 207 enrollment_page_view_->tab_contents()->render_view_host(); |
| 167 render_view_host->ExecuteJavascriptInWebFrame( | 208 render_view_host->ExecuteJavascriptInWebFrame( |
| 168 ASCIIToUTF16("//iframe[@id='gaialogin']"), | 209 ASCIIToUTF16("//iframe[@id='gaialogin']"), |
| 169 UTF8ToUTF16("showGaiaLogin(" + json + ");")); | 210 UTF8ToUTF16("showGaiaLogin(" + json + ");")); |
| 170 } | 211 } |
| 171 | 212 |
| 172 void EnterpriseEnrollmentView::ShowError(int message_id) { | 213 void EnterpriseEnrollmentView::ShowError(int message_id) { |
| 173 DictionaryValue args; | 214 DictionaryValue args; |
| 174 args.SetInteger("error", GoogleServiceAuthError::NONE); | 215 args.SetInteger("error", GoogleServiceAuthError::NONE); |
| 175 args.SetBoolean("editable_user", true); | 216 args.SetBoolean("editable_user", editable_user_); |
| 176 args.SetString("error_message", l10n_util::GetStringUTF16(message_id)); | 217 args.SetString("error_message", l10n_util::GetStringUTF16(message_id)); |
| 177 UpdateGaiaLogin(args); | 218 UpdateGaiaLogin(args); |
| 178 } | 219 } |
| 179 | 220 |
| 180 void EnterpriseEnrollmentView::Layout() { | 221 void EnterpriseEnrollmentView::Layout() { |
| 181 enrollment_page_view_->SetBoundsRect(GetContentsBounds()); | 222 enrollment_page_view_->SetBoundsRect(GetContentsBounds()); |
| 182 } | 223 } |
| 183 | 224 |
| 184 } // namespace chromeos | 225 } // namespace chromeos |
| OLD | NEW |