| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/ui/webui/chromeos/login/encryption_migration_screen_han
dler.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_han
dler.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 "Cryptohome.MigrationUI.ConsumedBatteryPercent"; | 64 "Cryptohome.MigrationUI.ConsumedBatteryPercent"; |
| 65 constexpr char kUmaNameVisibleScreen[] = "Cryptohome.MigrationUI.VisibleScreen"; | 65 constexpr char kUmaNameVisibleScreen[] = "Cryptohome.MigrationUI.VisibleScreen"; |
| 66 | 66 |
| 67 // This enum must match the numbering for MigrationUIFirstScreen in | 67 // This enum must match the numbering for MigrationUIFirstScreen in |
| 68 // histograms/enums.xml. Do not reorder or remove items, only add new items | 68 // histograms/enums.xml. Do not reorder or remove items, only add new items |
| 69 // before FIRST_SCREEN_COUNT. | 69 // before FIRST_SCREEN_COUNT. |
| 70 enum class FirstScreen { | 70 enum class FirstScreen { |
| 71 FIRST_SCREEN_READY = 0, | 71 FIRST_SCREEN_READY = 0, |
| 72 FIRST_SCREEN_RESUME = 1, | 72 FIRST_SCREEN_RESUME = 1, |
| 73 FIRST_SCREEN_LOW_STORAGE = 2, | 73 FIRST_SCREEN_LOW_STORAGE = 2, |
| 74 FIRST_SCREEN_ARC_KIOSK = 3, |
| 74 FIRST_SCREEN_COUNT | 75 FIRST_SCREEN_COUNT |
| 75 }; | 76 }; |
| 76 | 77 |
| 77 // This enum must match the numbering for MigrationUIUserChoice in | 78 // This enum must match the numbering for MigrationUIUserChoice in |
| 78 // histograms/enums.xml. Do not reorder or remove items, only add new items | 79 // histograms/enums.xml. Do not reorder or remove items, only add new items |
| 79 // before USER_CHOICE_COUNT. | 80 // before USER_CHOICE_COUNT. |
| 80 enum class UserChoice { | 81 enum class UserChoice { |
| 81 USER_CHOICE_UPDATE = 0, | 82 USER_CHOICE_UPDATE = 0, |
| 82 USER_CHOICE_SKIP = 1, | 83 USER_CHOICE_SKIP = 1, |
| 83 USER_CHOICE_RESTART_ON_FAILURE = 2, | 84 USER_CHOICE_RESTART_ON_FAILURE = 2, |
| 84 USER_CHOICE_RESTART_ON_LOW_STORAGE = 3, | 85 USER_CHOICE_RESTART_ON_LOW_STORAGE = 3, |
| 85 USER_CHOICE_REPORT_AN_ISSUE = 4, | 86 USER_CHOICE_REPORT_AN_ISSUE = 4, |
| 86 USER_CHOICE_COUNT | 87 USER_CHOICE_COUNT |
| 87 }; | 88 }; |
| 88 | 89 |
| 89 // This enum must match the numbering for MigrationUIMigrationResult in | 90 // This enum must match the numbering for MigrationUIMigrationResult in |
| 90 // histograms/enums.xml. Do not reorder or remove items, only add new items | 91 // histograms/enums.xml. Do not reorder or remove items, only add new items |
| 91 // before COUNT. | 92 // before COUNT. |
| 92 enum class MigrationResult { | 93 enum class MigrationResult { |
| 93 SUCCESS_IN_NEW_MIGRATION = 0, | 94 SUCCESS_IN_NEW_MIGRATION = 0, |
| 94 SUCCESS_IN_RESUMED_MIGRATION = 1, | 95 SUCCESS_IN_RESUMED_MIGRATION = 1, |
| 95 GENERAL_FAILURE_IN_NEW_MIGRATION = 2, | 96 GENERAL_FAILURE_IN_NEW_MIGRATION = 2, |
| 96 GENERAL_FAILURE_IN_RESUMED_MIGRATION = 3, | 97 GENERAL_FAILURE_IN_RESUMED_MIGRATION = 3, |
| 97 REQUEST_FAILURE_IN_NEW_MIGRATION = 4, | 98 REQUEST_FAILURE_IN_NEW_MIGRATION = 4, |
| 98 REQUEST_FAILURE_IN_RESUMED_MIGRATION = 5, | 99 REQUEST_FAILURE_IN_RESUMED_MIGRATION = 5, |
| 99 MOUNT_FAILURE_IN_NEW_MIGRATION = 6, | 100 MOUNT_FAILURE_IN_NEW_MIGRATION = 6, |
| 100 MOUNT_FAILURE_IN_RESUMED_MIGRATION = 7, | 101 MOUNT_FAILURE_IN_RESUMED_MIGRATION = 7, |
| 102 SUCCESS_IN_ARC_KIOSK_MIGRATION = 8, |
| 103 GENERAL_FAILURE_IN_ARC_KIOSK_MIGRATION = 9, |
| 104 REQUEST_FAILURE_IN_ARC_KIOSK_MIGRATION = 10, |
| 105 MOUNT_FAILURE_IN_ARC_KIOSK_MIGRATION = 11, |
| 101 COUNT | 106 COUNT |
| 102 }; | 107 }; |
| 103 | 108 |
| 104 // This enum must match the numbering for MigrationUIRemoveCryptohomeResult in | 109 // This enum must match the numbering for MigrationUIRemoveCryptohomeResult in |
| 105 // histograms/enums.xml. Do not reorder or remove items, only add new items | 110 // histograms/enums.xml. Do not reorder or remove items, only add new items |
| 106 // before COUNT. | 111 // before COUNT. |
| 107 enum class RemoveCryptohomeResult { | 112 enum class RemoveCryptohomeResult { |
| 108 SUCCESS_IN_NEW_MIGRATION = 0, | 113 SUCCESS_IN_NEW_MIGRATION = 0, |
| 109 SUCCESS_IN_RESUMED_MIGRATION = 1, | 114 SUCCESS_IN_RESUMED_MIGRATION = 1, |
| 110 FAILURE_IN_NEW_MIGRATION = 2, | 115 FAILURE_IN_NEW_MIGRATION = 2, |
| 111 FAILURE_IN_RESUMED_MIGRATION = 3, | 116 FAILURE_IN_RESUMED_MIGRATION = 3, |
| 117 SUCCESS_IN_ARC_KIOSK_MIGRATION = 4, |
| 118 FAILURE_IN_ARC_KIOSK_MIGRATION = 5, |
| 112 COUNT | 119 COUNT |
| 113 }; | 120 }; |
| 114 | 121 |
| 115 bool IsTestingUI() { | 122 bool IsTestingUI() { |
| 116 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 123 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 117 chromeos::switches::kTestEncryptionMigrationUI); | 124 chromeos::switches::kTestEncryptionMigrationUI); |
| 118 } | 125 } |
| 119 | 126 |
| 120 // Wrapper functions for histogram macros to avoid duplication of expanded code. | 127 // Wrapper functions for histogram macros to avoid duplication of expanded code. |
| 121 void RecordFirstScreen(FirstScreen first_screen) { | 128 void RecordFirstScreen(FirstScreen first_screen) { |
| 122 UMA_HISTOGRAM_ENUMERATION(kUmaNameFirstScreen, first_screen, | 129 UMA_HISTOGRAM_ENUMERATION(kUmaNameFirstScreen, first_screen, |
| 123 FirstScreen::FIRST_SCREEN_COUNT); | 130 FirstScreen::FIRST_SCREEN_COUNT); |
| 124 } | 131 } |
| 125 | 132 |
| 126 void RecordUserChoice(UserChoice user_choice) { | 133 void RecordUserChoice(UserChoice user_choice) { |
| 127 UMA_HISTOGRAM_ENUMERATION(kUmaNameUserChoice, user_choice, | 134 UMA_HISTOGRAM_ENUMERATION(kUmaNameUserChoice, user_choice, |
| 128 UserChoice::USER_CHOICE_COUNT); | 135 UserChoice::USER_CHOICE_COUNT); |
| 129 } | 136 } |
| 130 | 137 |
| 131 void RecordMigrationResult(MigrationResult migration_result) { | 138 void RecordMigrationResult(MigrationResult migration_result) { |
| 132 UMA_HISTOGRAM_ENUMERATION(kUmaNameMigrationResult, migration_result, | 139 UMA_HISTOGRAM_ENUMERATION(kUmaNameMigrationResult, migration_result, |
| 133 MigrationResult::COUNT); | 140 MigrationResult::COUNT); |
| 134 } | 141 } |
| 135 | 142 |
| 136 void RecordRemoveCryptohomeResult(bool success, bool is_resumed_migration) { | 143 void RecordMigrationResultSuccess(bool resume, bool arc_kiosk) { |
| 137 RemoveCryptohomeResult result = | 144 if (arc_kiosk) |
| 138 success ? (is_resumed_migration | 145 RecordMigrationResult(MigrationResult::SUCCESS_IN_ARC_KIOSK_MIGRATION); |
| 139 ? RemoveCryptohomeResult::SUCCESS_IN_RESUMED_MIGRATION | 146 else if (resume) |
| 140 : RemoveCryptohomeResult::SUCCESS_IN_NEW_MIGRATION) | 147 RecordMigrationResult(MigrationResult::SUCCESS_IN_RESUMED_MIGRATION); |
| 141 : (is_resumed_migration | 148 else |
| 142 ? RemoveCryptohomeResult::FAILURE_IN_RESUMED_MIGRATION | 149 RecordMigrationResult(MigrationResult::SUCCESS_IN_NEW_MIGRATION); |
| 143 : RemoveCryptohomeResult::FAILURE_IN_NEW_MIGRATION); | 150 } |
| 151 |
| 152 void RecordMigrationResultGeneralFailure(bool resume, bool arc_kiosk) { |
| 153 if (arc_kiosk) { |
| 154 RecordMigrationResult( |
| 155 MigrationResult::GENERAL_FAILURE_IN_ARC_KIOSK_MIGRATION); |
| 156 } else if (resume) { |
| 157 RecordMigrationResult( |
| 158 MigrationResult::GENERAL_FAILURE_IN_RESUMED_MIGRATION); |
| 159 } else { |
| 160 RecordMigrationResult(MigrationResult::GENERAL_FAILURE_IN_NEW_MIGRATION); |
| 161 } |
| 162 } |
| 163 |
| 164 void RecordMigrationResultRequestFailure(bool resume, bool arc_kiosk) { |
| 165 if (arc_kiosk) { |
| 166 RecordMigrationResult( |
| 167 MigrationResult::REQUEST_FAILURE_IN_ARC_KIOSK_MIGRATION); |
| 168 } else if (resume) { |
| 169 RecordMigrationResult( |
| 170 MigrationResult::REQUEST_FAILURE_IN_RESUMED_MIGRATION); |
| 171 } else { |
| 172 RecordMigrationResult(MigrationResult::REQUEST_FAILURE_IN_NEW_MIGRATION); |
| 173 } |
| 174 } |
| 175 |
| 176 void RecordMigrationResultMountFailure(bool resume, bool arc_kiosk) { |
| 177 if (arc_kiosk) { |
| 178 RecordMigrationResult( |
| 179 MigrationResult::MOUNT_FAILURE_IN_ARC_KIOSK_MIGRATION); |
| 180 } else if (resume) { |
| 181 RecordMigrationResult(MigrationResult::MOUNT_FAILURE_IN_RESUMED_MIGRATION); |
| 182 } else { |
| 183 RecordMigrationResult(MigrationResult::MOUNT_FAILURE_IN_NEW_MIGRATION); |
| 184 } |
| 185 } |
| 186 |
| 187 void RecordRemoveCryptohomeResult(RemoveCryptohomeResult result) { |
| 144 UMA_HISTOGRAM_ENUMERATION(kUmaNameRemoveCryptohomeResult, result, | 188 UMA_HISTOGRAM_ENUMERATION(kUmaNameRemoveCryptohomeResult, result, |
| 145 RemoveCryptohomeResult::COUNT); | 189 RemoveCryptohomeResult::COUNT); |
| 146 } | 190 } |
| 147 | 191 |
| 192 void RecordRemoveCryptohomeResultSuccess(bool resume, bool arc_kiosk) { |
| 193 if (arc_kiosk) { |
| 194 RecordRemoveCryptohomeResult( |
| 195 RemoveCryptohomeResult::SUCCESS_IN_ARC_KIOSK_MIGRATION); |
| 196 } else if (resume) { |
| 197 RecordRemoveCryptohomeResult( |
| 198 RemoveCryptohomeResult::SUCCESS_IN_RESUMED_MIGRATION); |
| 199 } else { |
| 200 RecordRemoveCryptohomeResult( |
| 201 RemoveCryptohomeResult::SUCCESS_IN_NEW_MIGRATION); |
| 202 } |
| 203 } |
| 204 |
| 205 void RecordRemoveCryptohomeResultFailure(bool resume, bool arc_kiosk) { |
| 206 if (arc_kiosk) { |
| 207 RecordRemoveCryptohomeResult( |
| 208 RemoveCryptohomeResult::FAILURE_IN_ARC_KIOSK_MIGRATION); |
| 209 } else if (resume) { |
| 210 RecordRemoveCryptohomeResult( |
| 211 RemoveCryptohomeResult::FAILURE_IN_RESUMED_MIGRATION); |
| 212 } else { |
| 213 RecordRemoveCryptohomeResult( |
| 214 RemoveCryptohomeResult::FAILURE_IN_NEW_MIGRATION); |
| 215 } |
| 216 } |
| 217 |
| 148 } // namespace | 218 } // namespace |
| 149 | 219 |
| 150 namespace chromeos { | 220 namespace chromeos { |
| 151 | 221 |
| 152 EncryptionMigrationScreenHandler::EncryptionMigrationScreenHandler() | 222 EncryptionMigrationScreenHandler::EncryptionMigrationScreenHandler() |
| 153 : BaseScreenHandler(kScreenId), weak_ptr_factory_(this) { | 223 : BaseScreenHandler(kScreenId), weak_ptr_factory_(this) { |
| 154 set_call_js_prefix(kJsScreenPath); | 224 set_call_js_prefix(kJsScreenPath); |
| 155 } | 225 } |
| 156 | 226 |
| 157 EncryptionMigrationScreenHandler::~EncryptionMigrationScreenHandler() { | 227 EncryptionMigrationScreenHandler::~EncryptionMigrationScreenHandler() { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 187 should_resume_ = should_resume; | 257 should_resume_ = should_resume; |
| 188 CallJS("setIsResuming", should_resume_); | 258 CallJS("setIsResuming", should_resume_); |
| 189 } | 259 } |
| 190 | 260 |
| 191 void EncryptionMigrationScreenHandler::SetContinueLoginCallback( | 261 void EncryptionMigrationScreenHandler::SetContinueLoginCallback( |
| 192 ContinueLoginCallback callback) { | 262 ContinueLoginCallback callback) { |
| 193 continue_login_callback_ = std::move(callback); | 263 continue_login_callback_ = std::move(callback); |
| 194 } | 264 } |
| 195 | 265 |
| 196 void EncryptionMigrationScreenHandler::SetupInitialView() { | 266 void EncryptionMigrationScreenHandler::SetupInitialView() { |
| 267 // If old encryption is detected in ARC kiosk mode, skip all checks (user |
| 268 // confirmation, battery level, and remaining space) and start migration |
| 269 // immediately. |
| 270 if (IsArcKiosk()) { |
| 271 RecordFirstScreen(FirstScreen::FIRST_SCREEN_ARC_KIOSK); |
| 272 StartMigration(); |
| 273 return; |
| 274 } |
| 197 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); | 275 DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this); |
| 198 CheckAvailableStorage(); | 276 CheckAvailableStorage(); |
| 199 } | 277 } |
| 200 | 278 |
| 201 void EncryptionMigrationScreenHandler::DeclareLocalizedValues( | 279 void EncryptionMigrationScreenHandler::DeclareLocalizedValues( |
| 202 ::login::LocalizedValuesBuilder* builder) { | 280 ::login::LocalizedValuesBuilder* builder) { |
| 203 builder->Add("migrationReadyTitle", IDS_ENCRYPTION_MIGRATION_READY_TITLE); | 281 builder->Add("migrationReadyTitle", IDS_ENCRYPTION_MIGRATION_READY_TITLE); |
| 204 builder->Add("migrationReadyDescription", | 282 builder->Add("migrationReadyDescription", |
| 205 ash::SubstituteChromeOSDeviceType( | 283 ash::SubstituteChromeOSDeviceType( |
| 206 IDS_ENCRYPTION_MIGRATION_READY_DESCRIPTION)); | 284 IDS_ENCRYPTION_MIGRATION_READY_DESCRIPTION)); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(); | 485 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(); |
| 408 } | 486 } |
| 409 | 487 |
| 410 void EncryptionMigrationScreenHandler::StartMigration() { | 488 void EncryptionMigrationScreenHandler::StartMigration() { |
| 411 UpdateUIState(UIState::MIGRATING); | 489 UpdateUIState(UIState::MIGRATING); |
| 412 initial_battery_percent_ = *current_battery_percent_; | 490 initial_battery_percent_ = *current_battery_percent_; |
| 413 | 491 |
| 414 // Mount the existing eCryptfs vault to a temporary location for migration. | 492 // Mount the existing eCryptfs vault to a temporary location for migration. |
| 415 cryptohome::MountParameters mount(false); | 493 cryptohome::MountParameters mount(false); |
| 416 mount.to_migrate_from_ecryptfs = true; | 494 mount.to_migrate_from_ecryptfs = true; |
| 417 cryptohome::HomedirMethods::GetInstance()->MountEx( | 495 if (IsArcKiosk()) { |
| 418 cryptohome::Identification(user_context_.GetAccountId()), | 496 mount.public_mount = true; |
| 419 cryptohome::Authorization(GetAuthKey()), mount, | 497 cryptohome::HomedirMethods::GetInstance()->MountEx( |
| 420 base::Bind(&EncryptionMigrationScreenHandler::OnMountExistingVault, | 498 cryptohome::Identification(user_context_.GetAccountId()), |
| 421 weak_ptr_factory_.GetWeakPtr())); | 499 cryptohome::Authorization(cryptohome::KeyDefinition()), mount, |
| 500 base::Bind(&EncryptionMigrationScreenHandler::OnMountExistingVault, |
| 501 weak_ptr_factory_.GetWeakPtr())); |
| 502 |
| 503 } else { |
| 504 cryptohome::HomedirMethods::GetInstance()->MountEx( |
| 505 cryptohome::Identification(user_context_.GetAccountId()), |
| 506 cryptohome::Authorization(GetAuthKey()), mount, |
| 507 base::Bind(&EncryptionMigrationScreenHandler::OnMountExistingVault, |
| 508 weak_ptr_factory_.GetWeakPtr())); |
| 509 } |
| 422 } | 510 } |
| 423 | 511 |
| 424 void EncryptionMigrationScreenHandler::OnMountExistingVault( | 512 void EncryptionMigrationScreenHandler::OnMountExistingVault( |
| 425 bool success, | 513 bool success, |
| 426 cryptohome::MountError return_code, | 514 cryptohome::MountError return_code, |
| 427 const std::string& mount_hash) { | 515 const std::string& mount_hash) { |
| 428 if (!success || return_code != cryptohome::MOUNT_ERROR_NONE) { | 516 if (!success || return_code != cryptohome::MOUNT_ERROR_NONE) { |
| 429 RecordMigrationResult( | 517 RecordMigrationResultMountFailure(should_resume_, IsArcKiosk()); |
| 430 should_resume_ ? MigrationResult::MOUNT_FAILURE_IN_RESUMED_MIGRATION | |
| 431 : MigrationResult::MOUNT_FAILURE_IN_NEW_MIGRATION); | |
| 432 UpdateUIState(UIState::MIGRATION_FAILED); | 518 UpdateUIState(UIState::MIGRATION_FAILED); |
| 433 return; | 519 return; |
| 434 } | 520 } |
| 435 | 521 |
| 436 DBusThreadManager::Get() | 522 DBusThreadManager::Get() |
| 437 ->GetCryptohomeClient() | 523 ->GetCryptohomeClient() |
| 438 ->SetDircryptoMigrationProgressHandler( | 524 ->SetDircryptoMigrationProgressHandler( |
| 439 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationProgress, | 525 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationProgress, |
| 440 weak_ptr_factory_.GetWeakPtr())); | 526 weak_ptr_factory_.GetWeakPtr())); |
| 441 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto( | 527 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 cryptohome::Identification(user_context_.GetAccountId()), | 559 cryptohome::Identification(user_context_.GetAccountId()), |
| 474 base::Bind(&EncryptionMigrationScreenHandler::OnRemoveCryptohome, | 560 base::Bind(&EncryptionMigrationScreenHandler::OnRemoveCryptohome, |
| 475 weak_ptr_factory_.GetWeakPtr())); | 561 weak_ptr_factory_.GetWeakPtr())); |
| 476 } | 562 } |
| 477 | 563 |
| 478 void EncryptionMigrationScreenHandler::OnRemoveCryptohome( | 564 void EncryptionMigrationScreenHandler::OnRemoveCryptohome( |
| 479 bool success, | 565 bool success, |
| 480 cryptohome::MountError return_code) { | 566 cryptohome::MountError return_code) { |
| 481 LOG_IF(ERROR, !success) << "Removing cryptohome failed. return code: " | 567 LOG_IF(ERROR, !success) << "Removing cryptohome failed. return code: " |
| 482 << return_code; | 568 << return_code; |
| 483 RecordRemoveCryptohomeResult(success, should_resume_); | 569 if (success) |
| 570 RecordRemoveCryptohomeResultSuccess(should_resume_, IsArcKiosk()); |
| 571 else |
| 572 RecordRemoveCryptohomeResultFailure(should_resume_, IsArcKiosk()); |
| 573 |
| 484 UpdateUIState(UIState::MIGRATION_FAILED); | 574 UpdateUIState(UIState::MIGRATION_FAILED); |
| 485 } | 575 } |
| 486 | 576 |
| 487 cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() { | 577 cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() { |
| 488 // |auth_key| is created in the same manner as CryptohomeAuthenticator. | 578 // |auth_key| is created in the same manner as CryptohomeAuthenticator. |
| 489 const Key* key = user_context_.GetKey(); | 579 const Key* key = user_context_.GetKey(); |
| 490 // If the |key| is a plain text password, crash rather than attempting to | 580 // If the |key| is a plain text password, crash rather than attempting to |
| 491 // mount the cryptohome with a plain text password. | 581 // mount the cryptohome with a plain text password. |
| 492 CHECK_NE(Key::KEY_TYPE_PASSWORD_PLAIN, key->GetKeyType()); | 582 CHECK_NE(Key::KEY_TYPE_PASSWORD_PLAIN, key->GetKeyType()); |
| 493 // Set the authentication's key label to an empty string, which is a wildcard | 583 // Set the authentication's key label to an empty string, which is a wildcard |
| 494 // allowing any key to match. This is necessary because cryptohomes created by | 584 // allowing any key to match. This is necessary because cryptohomes created by |
| 495 // Chrome OS M38 and older will have a legacy key with no label while those | 585 // Chrome OS M38 and older will have a legacy key with no label while those |
| 496 // created by Chrome OS M39 and newer will have a key with the label | 586 // created by Chrome OS M39 and newer will have a key with the label |
| 497 // kCryptohomeGAIAKeyLabel. | 587 // kCryptohomeGAIAKeyLabel. |
| 498 return cryptohome::KeyDefinition(key->GetSecret(), std::string(), | 588 return cryptohome::KeyDefinition(key->GetSecret(), std::string(), |
| 499 cryptohome::PRIV_DEFAULT); | 589 cryptohome::PRIV_DEFAULT); |
| 500 } | 590 } |
| 501 | 591 |
| 592 bool EncryptionMigrationScreenHandler::IsArcKiosk() const { |
| 593 return user_context_.GetUserType() == user_manager::USER_TYPE_ARC_KIOSK_APP; |
| 594 } |
| 595 |
| 502 void EncryptionMigrationScreenHandler::OnMigrationProgress( | 596 void EncryptionMigrationScreenHandler::OnMigrationProgress( |
| 503 cryptohome::DircryptoMigrationStatus status, | 597 cryptohome::DircryptoMigrationStatus status, |
| 504 uint64_t current, | 598 uint64_t current, |
| 505 uint64_t total) { | 599 uint64_t total) { |
| 506 switch (status) { | 600 switch (status) { |
| 507 case cryptohome::DIRCRYPTO_MIGRATION_INITIALIZING: | 601 case cryptohome::DIRCRYPTO_MIGRATION_INITIALIZING: |
| 508 UpdateUIState(UIState::MIGRATING); | 602 UpdateUIState(UIState::MIGRATING); |
| 509 break; | 603 break; |
| 510 case cryptohome::DIRCRYPTO_MIGRATION_IN_PROGRESS: | 604 case cryptohome::DIRCRYPTO_MIGRATION_IN_PROGRESS: |
| 511 UpdateUIState(UIState::MIGRATING); | 605 UpdateUIState(UIState::MIGRATING); |
| 512 CallJS("setMigrationProgress", static_cast<double>(current) / total); | 606 CallJS("setMigrationProgress", static_cast<double>(current) / total); |
| 513 break; | 607 break; |
| 514 case cryptohome::DIRCRYPTO_MIGRATION_SUCCESS: | 608 case cryptohome::DIRCRYPTO_MIGRATION_SUCCESS: |
| 515 RecordMigrationResult(should_resume_ | 609 RecordMigrationResultSuccess(should_resume_, IsArcKiosk()); |
| 516 ? MigrationResult::SUCCESS_IN_RESUMED_MIGRATION | |
| 517 : MigrationResult::SUCCESS_IN_NEW_MIGRATION); | |
| 518 // If the battery level decreased during migration, record the consumed | 610 // If the battery level decreased during migration, record the consumed |
| 519 // battery level. | 611 // battery level. |
| 520 if (*current_battery_percent_ < initial_battery_percent_) { | 612 if (*current_battery_percent_ < initial_battery_percent_) { |
| 521 UMA_HISTOGRAM_PERCENTAGE( | 613 UMA_HISTOGRAM_PERCENTAGE( |
| 522 kUmaNameConsumedBatteryPercent, | 614 kUmaNameConsumedBatteryPercent, |
| 523 static_cast<int>(std::round(initial_battery_percent_ - | 615 static_cast<int>(std::round(initial_battery_percent_ - |
| 524 *current_battery_percent_))); | 616 *current_battery_percent_))); |
| 525 } | 617 } |
| 526 // Restart immediately after successful migration. | 618 // Restart immediately after successful migration. |
| 527 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 619 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 528 break; | 620 break; |
| 529 case cryptohome::DIRCRYPTO_MIGRATION_FAILED: | 621 case cryptohome::DIRCRYPTO_MIGRATION_FAILED: |
| 530 RecordMigrationResult( | 622 RecordMigrationResultGeneralFailure(should_resume_, IsArcKiosk()); |
| 531 should_resume_ ? MigrationResult::GENERAL_FAILURE_IN_RESUMED_MIGRATION | |
| 532 : MigrationResult::GENERAL_FAILURE_IN_NEW_MIGRATION); | |
| 533 // Stop listening to the progress updates. | 623 // Stop listening to the progress updates. |
| 534 DBusThreadManager::Get() | 624 DBusThreadManager::Get() |
| 535 ->GetCryptohomeClient() | 625 ->GetCryptohomeClient() |
| 536 ->SetDircryptoMigrationProgressHandler( | 626 ->SetDircryptoMigrationProgressHandler( |
| 537 CryptohomeClient::DircryptoMigrationProgessHandler()); | 627 CryptohomeClient::DircryptoMigrationProgessHandler()); |
| 538 // Shows error screen after removing user directory is completed. | 628 // Shows error screen after removing user directory is completed. |
| 539 RemoveCryptohome(); | 629 RemoveCryptohome(); |
| 540 break; | 630 break; |
| 541 default: | 631 default: |
| 542 break; | 632 break; |
| 543 } | 633 } |
| 544 } | 634 } |
| 545 | 635 |
| 546 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { | 636 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { |
| 547 if (!success) { | 637 if (!success) { |
| 548 LOG(ERROR) << "Requesting MigrateToDircrypto failed."; | 638 LOG(ERROR) << "Requesting MigrateToDircrypto failed."; |
| 549 RecordMigrationResult( | 639 RecordMigrationResultRequestFailure(should_resume_, IsArcKiosk()); |
| 550 should_resume_ ? MigrationResult::REQUEST_FAILURE_IN_RESUMED_MIGRATION | |
| 551 : MigrationResult::REQUEST_FAILURE_IN_NEW_MIGRATION); | |
| 552 UpdateUIState(UIState::MIGRATION_FAILED); | 640 UpdateUIState(UIState::MIGRATION_FAILED); |
| 553 } | 641 } |
| 554 } | 642 } |
| 555 | 643 |
| 556 void EncryptionMigrationScreenHandler::OnDelayedRecordVisibleScreen( | 644 void EncryptionMigrationScreenHandler::OnDelayedRecordVisibleScreen( |
| 557 UIState ui_state) { | 645 UIState ui_state) { |
| 558 if (current_ui_state_ != ui_state) | 646 if (current_ui_state_ != ui_state) |
| 559 return; | 647 return; |
| 560 | 648 |
| 561 // If |current_ui_state_| is not changed for a second, record the current | 649 // If |current_ui_state_| is not changed for a second, record the current |
| 562 // screen as a "visible" screen. | 650 // screen as a "visible" screen. |
| 563 UMA_HISTOGRAM_ENUMERATION(kUmaNameVisibleScreen, ui_state, UIState::COUNT); | 651 UMA_HISTOGRAM_ENUMERATION(kUmaNameVisibleScreen, ui_state, UIState::COUNT); |
| 564 } | 652 } |
| 565 | 653 |
| 566 } // namespace chromeos | 654 } // namespace chromeos |
| OLD | NEW |