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" |
| 19 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 20 #include "views/border.h" | 22 #include "views/border.h" |
| 21 #include "views/layout/layout_constants.h" | 23 #include "views/layout/layout_constants.h" |
| 22 | 24 |
| 23 namespace chromeos { | 25 namespace chromeos { |
| 24 | 26 |
| 25 namespace { | 27 namespace { |
| 26 | 28 |
| 29 // Retry for lockbox initialization every 500ms. | |
| 30 const int kLockboxRetryInterval = 500; | |
| 31 | |
| 27 // Layout constants. | 32 // Layout constants. |
| 28 const int kBorderSize = 30; | 33 const int kBorderSize = 30; |
| 29 | 34 |
| 30 // Renders the registration page. | 35 // Renders the registration page. |
| 31 class EnrollmentDomView : public WebPageDomView, | 36 class EnrollmentDomView : public WebPageDomView, |
| 32 public TabContentsDelegate { | 37 public TabContentsDelegate { |
| 33 public: | 38 public: |
| 34 EnrollmentDomView() {} | 39 EnrollmentDomView() {} |
| 35 virtual ~EnrollmentDomView() {} | 40 virtual ~EnrollmentDomView() {} |
| 36 | 41 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 NavigationType::Type navigation_type) { | 73 NavigationType::Type navigation_type) { |
| 69 return false; | 74 return false; |
| 70 } | 75 } |
| 71 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} | 76 virtual void MoveContents(TabContents* source, const gfx::Rect& pos) {} |
| 72 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} | 77 virtual void ToolbarSizeChanged(TabContents* source, bool is_animating) {} |
| 73 virtual bool HandleContextMenu(const ContextMenuParams& params) { | 78 virtual bool HandleContextMenu(const ContextMenuParams& params) { |
| 74 return true; | 79 return true; |
| 75 } | 80 } |
| 76 | 81 |
| 77 private: | 82 private: |
| 83 | |
| 78 DISALLOW_COPY_AND_ASSIGN(EnrollmentDomView); | 84 DISALLOW_COPY_AND_ASSIGN(EnrollmentDomView); |
| 79 }; | 85 }; |
| 80 | 86 |
| 81 } // namespace | 87 } // namespace |
| 82 | 88 |
| 83 EnterpriseEnrollmentView::EnterpriseEnrollmentView( | 89 EnterpriseEnrollmentView::EnterpriseEnrollmentView( |
| 84 EnterpriseEnrollmentController* controller) | 90 EnterpriseEnrollmentController* controller) |
| 85 : controller_(controller) {} | 91 : controller_(controller), |
| 92 ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) {} | |
| 86 | 93 |
| 87 EnterpriseEnrollmentView::~EnterpriseEnrollmentView() {} | 94 EnterpriseEnrollmentView::~EnterpriseEnrollmentView() {} |
| 88 | 95 |
| 89 void EnterpriseEnrollmentView::Init() { | 96 void EnterpriseEnrollmentView::Init() { |
| 90 // Use rounded rect background. | 97 // Use rounded rect background. |
| 91 views::Painter* painter = | 98 views::Painter* painter = |
| 92 CreateWizardPainter(&BorderDefinition::kScreenBorder); | 99 CreateWizardPainter(&BorderDefinition::kScreenBorder); |
| 93 set_background(views::Background::CreateBackgroundPainter(true, painter)); | 100 set_background(views::Background::CreateBackgroundPainter(true, painter)); |
| 94 | 101 |
| 95 // Create the view that hosts the enrollment page. | 102 // Create the view that hosts the enrollment page. |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 } | 147 } |
| 141 | 148 |
| 142 void EnterpriseEnrollmentView::ShowNetworkEnrollmentError() { | 149 void EnterpriseEnrollmentView::ShowNetworkEnrollmentError() { |
| 143 ShowError(IDS_ENTERPRISE_ENROLLMENT_NETWORK_ENROLLMENT_ERROR); | 150 ShowError(IDS_ENTERPRISE_ENROLLMENT_NETWORK_ENROLLMENT_ERROR); |
| 144 } | 151 } |
| 145 | 152 |
| 146 void EnterpriseEnrollmentView::OnAuthSubmitted(const std::string& user, | 153 void EnterpriseEnrollmentView::OnAuthSubmitted(const std::string& user, |
| 147 const std::string& password, | 154 const std::string& password, |
| 148 const std::string& captcha, | 155 const std::string& captcha, |
| 149 const std::string& access_code) { | 156 const std::string& access_code) { |
| 157 user_ = user; | |
| 150 controller_->Authenticate(user, password, captcha, access_code); | 158 controller_->Authenticate(user, password, captcha, access_code); |
| 151 } | 159 } |
| 152 | 160 |
| 153 void EnterpriseEnrollmentView::OnAuthCancelled() { | 161 void EnterpriseEnrollmentView::OnAuthCancelled() { |
| 154 controller_->CancelEnrollment(); | 162 controller_->CancelEnrollment(); |
| 155 } | 163 } |
| 156 | 164 |
| 157 void EnterpriseEnrollmentView::OnConfirmationClosed() { | 165 void EnterpriseEnrollmentView::OnConfirmationClosed() { |
| 158 controller_->CloseConfirmation(); | 166 controller_->CloseConfirmation(); |
| 159 } | 167 } |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 174 args.SetInteger("error", GoogleServiceAuthError::NONE); | 182 args.SetInteger("error", GoogleServiceAuthError::NONE); |
| 175 args.SetBoolean("editable_user", true); | 183 args.SetBoolean("editable_user", true); |
| 176 args.SetString("error_message", l10n_util::GetStringUTF16(message_id)); | 184 args.SetString("error_message", l10n_util::GetStringUTF16(message_id)); |
| 177 UpdateGaiaLogin(args); | 185 UpdateGaiaLogin(args); |
| 178 } | 186 } |
| 179 | 187 |
| 180 void EnterpriseEnrollmentView::Layout() { | 188 void EnterpriseEnrollmentView::Layout() { |
| 181 enrollment_page_view_->SetBoundsRect(GetContentsBounds()); | 189 enrollment_page_view_->SetBoundsRect(GetContentsBounds()); |
| 182 } | 190 } |
| 183 | 191 |
| 192 | |
| 193 void EnterpriseEnrollmentView::WriteLockboxData() { | |
| 194 // Since this method is also called directly. | |
| 195 runnable_method_factory_.RevokeAll(); | |
| 196 | |
| 197 chromeos::CryptohomeLibrary* cryptohome = | |
| 198 chromeos::CrosLibrary::Get()->GetCryptohomeLibrary(); | |
| 199 // TODO(pastarmovj): This is being done either on the eula screen or on first | |
| 200 // login so maybe we should do it already here? If not remove. | |
| 201 if (cryptohome->TpmIsEnabled() && !cryptohome->TpmIsBeingOwned()) { | |
| 202 if (cryptohome->TpmIsOwned()) | |
| 203 cryptohome->TpmClearStoredPassword(); | |
| 204 else | |
| 205 cryptohome->TpmCanAttemptOwnership(); | |
| 206 } | |
| 207 | |
| 208 if (!cryptohome->InstallAttributesIsReady()) { | |
|
kmixter1
2011/04/14 16:52:22
How does this look to the user? Do they provide c
| |
| 209 // Lockbox is not read yet, reschedule pulling. | |
| 210 LOG(INFO) << "Lockbox is not ready yet will retry in " | |
| 211 << kLockboxRetryInterval << "ms."; | |
| 212 MessageLoop::current()->PostDelayedTask( | |
| 213 FROM_HERE, | |
| 214 runnable_method_factory_.NewRunnableMethod( | |
| 215 &EnterpriseEnrollmentView::WriteLockboxData), | |
| 216 kLockboxRetryInterval); | |
| 217 } else { | |
| 218 // Set values in the lockbox and lock it. | |
| 219 /* | |
|
kmixter1
2011/04/14 16:52:22
remove?
| |
| 220 DCHECK(cryptohome->InstallAttributesIsFirstInstall()); | |
| 221 cryptohome->InstallAttributesSet("enterprise.owned", "true"); | |
| 222 cryptohome->InstallAttributesSet("enterprise.user", user_); | |
| 223 DCHECK(cryptohome->InstallAttributesCount() == 2); | |
| 224 cryptohome->InstallAttributesFinalize(); | |
| 225 DCHECK(cryptohome->InstallAttributesIsSecure()); | |
| 226 */ | |
| 227 | |
| 228 // The same code but much more verbose for debugging! | |
| 229 LOG(ERROR) << "### FI : " << cryptohome->InstallAttributesIsFirstInstall(); | |
|
kmixter1
2011/04/14 16:52:22
remove?
| |
| 230 LOG(ERROR) << "### count : " << cryptohome->InstallAttributesCount(); | |
| 231 LOG(ERROR) << "### set : " | |
| 232 << cryptohome->InstallAttributesSet("enterprise.owned", "true"); | |
| 233 LOG(ERROR) << "### set : " | |
| 234 << cryptohome->InstallAttributesSet("enterprise.user", user_); | |
| 235 LOG(ERROR) << "### count : " << cryptohome->InstallAttributesCount(); | |
| 236 std::string test; | |
| 237 LOG(ERROR) << "### get owned : " | |
| 238 << cryptohome->InstallAttributesGet("enterprise.owned", &test); | |
| 239 LOG(ERROR) << "### " << test; | |
| 240 LOG(ERROR) << "### get user : " | |
| 241 << cryptohome->InstallAttributesGet("enterprise.user", &test); | |
| 242 LOG(ERROR) << "### " << test; | |
| 243 LOG(ERROR) << "### stat : " << cryptohome->InstallAttributesIsSecure(); | |
| 244 LOG(ERROR) << "### lock : " << cryptohome->InstallAttributesFinalize(); | |
| 245 LOG(ERROR) << "### stat : " << cryptohome->InstallAttributesIsSecure(); | |
| 246 | |
| 247 ShowConfirmationScreen(); | |
| 248 } | |
| 249 } | |
| 250 | |
| 251 | |
| 252 | |
| 184 } // namespace chromeos | 253 } // namespace chromeos |
| OLD | NEW |