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 |
11 #include "ash/system/devicetype_utils.h" | 11 #include "ash/system/devicetype_utils.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "base/sys_info.h" | 17 #include "base/sys_info.h" |
18 #include "base/task_scheduler/post_task.h" | 18 #include "base/task_scheduler/post_task.h" |
| 19 #include "base/threading/thread_task_runner_handle.h" |
| 20 #include "base/time/time.h" |
19 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
20 #include "chrome/browser/chromeos/arc/arc_migration_constants.h" | 22 #include "chrome/browser/chromeos/arc/arc_migration_constants.h" |
21 #include "chrome/browser/chromeos/login/ui/login_feedback.h" | 23 #include "chrome/browser/chromeos/login/ui/login_feedback.h" |
22 #include "chrome/browser/lifetime/application_lifetime.h" | 24 #include "chrome/browser/lifetime/application_lifetime.h" |
23 #include "chrome/browser/profiles/profile.h" | 25 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/grit/generated_resources.h" | 26 #include "chrome/grit/generated_resources.h" |
25 #include "chromeos/chromeos_switches.h" | 27 #include "chromeos/chromeos_switches.h" |
26 #include "chromeos/cryptohome/async_method_caller.h" | 28 #include "chromeos/cryptohome/async_method_caller.h" |
27 #include "chromeos/cryptohome/homedir_methods.h" | 29 #include "chromeos/cryptohome/homedir_methods.h" |
28 #include "chromeos/dbus/cryptohome_client.h" | 30 #include "chromeos/dbus/cryptohome_client.h" |
(...skipping 10 matching lines...) Expand all Loading... |
39 namespace { | 41 namespace { |
40 | 42 |
41 constexpr char kJsScreenPath[] = "login.EncryptionMigrationScreen"; | 43 constexpr char kJsScreenPath[] = "login.EncryptionMigrationScreen"; |
42 | 44 |
43 // Path to the mount point to check the available space. | 45 // Path to the mount point to check the available space. |
44 constexpr char kCheckStoragePath[] = "/home"; | 46 constexpr char kCheckStoragePath[] = "/home"; |
45 | 47 |
46 // JS API callbacks names. | 48 // JS API callbacks names. |
47 constexpr char kJsApiStartMigration[] = "startMigration"; | 49 constexpr char kJsApiStartMigration[] = "startMigration"; |
48 constexpr char kJsApiSkipMigration[] = "skipMigration"; | 50 constexpr char kJsApiSkipMigration[] = "skipMigration"; |
49 constexpr char kJsApiRequestRestart[] = "requestRestart"; | 51 constexpr char kJsApiRequestRestartOnLowStorage[] = |
| 52 "requestRestartOnLowStorage"; |
| 53 constexpr char kJsApiRequestRestartOnFailure[] = "requestRestartOnFailure"; |
50 constexpr char kJsApiOpenFeedbackDialog[] = "openFeedbackDialog"; | 54 constexpr char kJsApiOpenFeedbackDialog[] = "openFeedbackDialog"; |
51 | 55 |
52 // UMA names. | 56 // UMA names. |
53 constexpr char kUmaNameFirstScreen[] = "Cryptohome.MigrationUI.FirstScreen"; | 57 constexpr char kUmaNameFirstScreen[] = "Cryptohome.MigrationUI.FirstScreen"; |
54 constexpr char kUmaNameUserChoice[] = "Cryptohome.MigrationUI.UserChoice"; | 58 constexpr char kUmaNameUserChoice[] = "Cryptohome.MigrationUI.UserChoice"; |
| 59 constexpr char kUmaNameMigrationResult[] = |
| 60 "Cryptohome.MigrationUI.MigrationResult"; |
| 61 constexpr char kUmaNameRemoveCryptohomeResult[] = |
| 62 "Cryptohome.MigrationUI.RemoveCryptohomeResult"; |
55 constexpr char kUmaNameConsumedBatteryPercent[] = | 63 constexpr char kUmaNameConsumedBatteryPercent[] = |
56 "Cryptohome.MigrationUI.ConsumedBatteryPercent"; | 64 "Cryptohome.MigrationUI.ConsumedBatteryPercent"; |
| 65 constexpr char kUmaNameVisibleScreen[] = "Cryptohome.MigrationUI.VisibleScreen"; |
57 | 66 |
58 // This enum must match the numbering for Cryptohome.MigrationUI.FirstScreen in | 67 // This enum must match the numbering for MigrationUIFirstScreen in |
59 // histograms.xml. Do not reorder or remove items, only add new items before | 68 // histograms/enums.xml. Do not reorder or remove items, only add new items |
60 // FIRST_SCREEN_MAX. | 69 // before FIRST_SCREEN_COUNT. |
61 enum class FirstScreen { | 70 enum class FirstScreen { |
62 FIRST_SCREEN_READY = 0, | 71 FIRST_SCREEN_READY = 0, |
63 FIRST_SCREEN_RESUME = 1, | 72 FIRST_SCREEN_RESUME = 1, |
64 FIRST_SCREEN_LOW_STORAGE = 2, | 73 FIRST_SCREEN_LOW_STORAGE = 2, |
65 FIRST_SCREEN_COUNT | 74 FIRST_SCREEN_COUNT |
66 }; | 75 }; |
67 | 76 |
68 // This enum must match the numbering for Cryptohome.MigrationUI.UserChoice in | 77 // This enum must match the numbering for MigrationUIUserChoice in |
69 // histograms.xml. Do not reorder or remove items, only add new items before | 78 // histograms/enums.xml. Do not reorder or remove items, only add new items |
70 // FIRST_SCREEN_MAX. | 79 // before USER_CHOICE_COUNT. |
71 enum class UserChoice { | 80 enum class UserChoice { |
72 USER_CHOICE_UPDATE = 0, | 81 USER_CHOICE_UPDATE = 0, |
73 USER_CHOICE_SKIP = 1, | 82 USER_CHOICE_SKIP = 1, |
| 83 USER_CHOICE_RESTART_ON_FAILURE = 2, |
| 84 USER_CHOICE_RESTART_ON_LOW_STORAGE = 3, |
| 85 USER_CHOICE_REPORT_AN_ISSUE = 4, |
74 USER_CHOICE_COUNT | 86 USER_CHOICE_COUNT |
75 }; | 87 }; |
76 | 88 |
| 89 // This enum must match the numbering for MigrationUIMigrationResult in |
| 90 // histograms/enums.xml. Do not reorder or remove items, only add new items |
| 91 // before COUNT. |
| 92 enum class MigrationResult { |
| 93 SUCCESS_IN_NEW_MIGRATION = 0, |
| 94 SUCCESS_IN_RESUMED_MIGRATION = 1, |
| 95 GENERAL_FAILURE_IN_NEW_MIGRATION = 2, |
| 96 GENERAL_FAILURE_IN_RESUMED_MIGRATION = 3, |
| 97 REQUEST_FAILURE_IN_NEW_MIGRATION = 4, |
| 98 REQUEST_FAILURE_IN_RESUMED_MIGRATION = 5, |
| 99 MOUNT_FAILURE_IN_NEW_MIGRATION = 6, |
| 100 MOUNT_FAILURE_IN_RESUMED_MIGRATION = 7, |
| 101 COUNT |
| 102 }; |
| 103 |
| 104 // This enum must match the numbering for MigrationUIRemoveCryptohomeResult in |
| 105 // histograms/enums.xml. Do not reorder or remove items, only add new items |
| 106 // before COUNT. |
| 107 enum class RemoveCryptohomeResult { |
| 108 SUCCESS_IN_NEW_MIGRATION = 0, |
| 109 SUCCESS_IN_RESUMED_MIGRATION = 1, |
| 110 FAILURE_IN_NEW_MIGRATION = 2, |
| 111 FAILURE_IN_RESUMED_MIGRATION = 3, |
| 112 COUNT |
| 113 }; |
| 114 |
77 bool IsTestingUI() { | 115 bool IsTestingUI() { |
78 return base::CommandLine::ForCurrentProcess()->HasSwitch( | 116 return base::CommandLine::ForCurrentProcess()->HasSwitch( |
79 chromeos::switches::kTestEncryptionMigrationUI); | 117 chromeos::switches::kTestEncryptionMigrationUI); |
80 } | 118 } |
81 | 119 |
82 // Wrapper functions for histogram macros to avoid duplication of expanded code. | 120 // Wrapper functions for histogram macros to avoid duplication of expanded code. |
83 void RecordFirstScreen(FirstScreen first_screen) { | 121 void RecordFirstScreen(FirstScreen first_screen) { |
84 UMA_HISTOGRAM_ENUMERATION(kUmaNameFirstScreen, static_cast<int>(first_screen), | 122 UMA_HISTOGRAM_ENUMERATION(kUmaNameFirstScreen, first_screen, |
85 static_cast<int>(FirstScreen::FIRST_SCREEN_COUNT)); | 123 FirstScreen::FIRST_SCREEN_COUNT); |
86 } | 124 } |
87 | 125 |
88 void RecordUserChoice(UserChoice user_choice) { | 126 void RecordUserChoice(UserChoice user_choice) { |
89 UMA_HISTOGRAM_ENUMERATION(kUmaNameUserChoice, static_cast<int>(user_choice), | 127 UMA_HISTOGRAM_ENUMERATION(kUmaNameUserChoice, user_choice, |
90 static_cast<int>(UserChoice::USER_CHOICE_COUNT)); | 128 UserChoice::USER_CHOICE_COUNT); |
| 129 } |
| 130 |
| 131 void RecordMigrationResult(MigrationResult migration_result) { |
| 132 UMA_HISTOGRAM_ENUMERATION(kUmaNameMigrationResult, migration_result, |
| 133 MigrationResult::COUNT); |
| 134 } |
| 135 |
| 136 void RecordRemoveCryptohomeResult(bool success, bool is_resumed_migration) { |
| 137 RemoveCryptohomeResult result = |
| 138 success ? (is_resumed_migration |
| 139 ? RemoveCryptohomeResult::SUCCESS_IN_RESUMED_MIGRATION |
| 140 : RemoveCryptohomeResult::SUCCESS_IN_NEW_MIGRATION) |
| 141 : (is_resumed_migration |
| 142 ? RemoveCryptohomeResult::FAILURE_IN_RESUMED_MIGRATION |
| 143 : RemoveCryptohomeResult::FAILURE_IN_NEW_MIGRATION); |
| 144 UMA_HISTOGRAM_ENUMERATION(kUmaNameRemoveCryptohomeResult, result, |
| 145 RemoveCryptohomeResult::COUNT); |
91 } | 146 } |
92 | 147 |
93 } // namespace | 148 } // namespace |
94 | 149 |
95 namespace chromeos { | 150 namespace chromeos { |
96 | 151 |
97 EncryptionMigrationScreenHandler::EncryptionMigrationScreenHandler() | 152 EncryptionMigrationScreenHandler::EncryptionMigrationScreenHandler() |
98 : BaseScreenHandler(kScreenId), weak_ptr_factory_(this) { | 153 : BaseScreenHandler(kScreenId), weak_ptr_factory_(this) { |
99 set_call_js_prefix(kJsScreenPath); | 154 set_call_js_prefix(kJsScreenPath); |
100 } | 155 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 Show(); | 252 Show(); |
198 show_on_init_ = false; | 253 show_on_init_ = false; |
199 } | 254 } |
200 } | 255 } |
201 | 256 |
202 void EncryptionMigrationScreenHandler::RegisterMessages() { | 257 void EncryptionMigrationScreenHandler::RegisterMessages() { |
203 AddCallback(kJsApiStartMigration, | 258 AddCallback(kJsApiStartMigration, |
204 &EncryptionMigrationScreenHandler::HandleStartMigration); | 259 &EncryptionMigrationScreenHandler::HandleStartMigration); |
205 AddCallback(kJsApiSkipMigration, | 260 AddCallback(kJsApiSkipMigration, |
206 &EncryptionMigrationScreenHandler::HandleSkipMigration); | 261 &EncryptionMigrationScreenHandler::HandleSkipMigration); |
207 AddCallback(kJsApiRequestRestart, | 262 AddCallback( |
208 &EncryptionMigrationScreenHandler::HandleRequestRestart); | 263 kJsApiRequestRestartOnLowStorage, |
| 264 &EncryptionMigrationScreenHandler::HandleRequestRestartOnLowStorage); |
| 265 AddCallback(kJsApiRequestRestartOnFailure, |
| 266 &EncryptionMigrationScreenHandler::HandleRequestRestartOnFailure); |
209 AddCallback(kJsApiOpenFeedbackDialog, | 267 AddCallback(kJsApiOpenFeedbackDialog, |
210 &EncryptionMigrationScreenHandler::HandleOpenFeedbackDialog); | 268 &EncryptionMigrationScreenHandler::HandleOpenFeedbackDialog); |
211 } | 269 } |
212 | 270 |
213 void EncryptionMigrationScreenHandler::PowerChanged( | 271 void EncryptionMigrationScreenHandler::PowerChanged( |
214 const power_manager::PowerSupplyProperties& proto) { | 272 const power_manager::PowerSupplyProperties& proto) { |
215 if (proto.has_battery_percent()) { | 273 if (proto.has_battery_percent()) { |
216 if (!current_battery_percent_) { | 274 if (!current_battery_percent_) { |
217 // If initial battery level is below the minimum, migration should start | 275 // If initial battery level is below the minimum, migration should start |
218 // automatically once the device is charged enough. | 276 // automatically once the device is charged enough. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // migration by reusing UserContext and LoginPerformer which were used in the | 309 // migration by reusing UserContext and LoginPerformer which were used in the |
252 // previous attempt and dropping |is_forcing_dircrypto| flag in UserContext. | 310 // previous attempt and dropping |is_forcing_dircrypto| flag in UserContext. |
253 // In this case, the user can not launch ARC apps in the session, and will be | 311 // In this case, the user can not launch ARC apps in the session, and will be |
254 // asked to do the migration again in the next log-in attempt. | 312 // asked to do the migration again in the next log-in attempt. |
255 if (!continue_login_callback_.is_null()) { | 313 if (!continue_login_callback_.is_null()) { |
256 user_context_.SetIsForcingDircrypto(false); | 314 user_context_.SetIsForcingDircrypto(false); |
257 std::move(continue_login_callback_).Run(user_context_); | 315 std::move(continue_login_callback_).Run(user_context_); |
258 } | 316 } |
259 } | 317 } |
260 | 318 |
261 void EncryptionMigrationScreenHandler::HandleRequestRestart() { | 319 void EncryptionMigrationScreenHandler::HandleRequestRestartOnLowStorage() { |
| 320 RecordUserChoice(UserChoice::USER_CHOICE_RESTART_ON_LOW_STORAGE); |
| 321 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 322 } |
| 323 |
| 324 void EncryptionMigrationScreenHandler::HandleRequestRestartOnFailure() { |
| 325 RecordUserChoice(UserChoice::USER_CHOICE_RESTART_ON_FAILURE); |
262 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 326 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
263 } | 327 } |
264 | 328 |
265 void EncryptionMigrationScreenHandler::HandleOpenFeedbackDialog() { | 329 void EncryptionMigrationScreenHandler::HandleOpenFeedbackDialog() { |
| 330 RecordUserChoice(UserChoice::USER_CHOICE_REPORT_AN_ISSUE); |
266 const std::string description = base::StringPrintf( | 331 const std::string description = base::StringPrintf( |
267 "Auto generated feedback for http://crbug.com/719266.\n" | 332 "Auto generated feedback for http://crbug.com/719266.\n" |
268 "(uniquifier:%s)", | 333 "(uniquifier:%s)", |
269 base::Int64ToString(base::Time::Now().ToInternalValue()).c_str()); | 334 base::Int64ToString(base::Time::Now().ToInternalValue()).c_str()); |
270 login_feedback_.reset(new LoginFeedback(Profile::FromWebUI(web_ui()))); | 335 login_feedback_.reset(new LoginFeedback(Profile::FromWebUI(web_ui()))); |
271 login_feedback_->Request(description, base::Closure()); | 336 login_feedback_->Request(description, base::Closure()); |
272 } | 337 } |
273 | 338 |
274 void EncryptionMigrationScreenHandler::UpdateUIState(UIState state) { | 339 void EncryptionMigrationScreenHandler::UpdateUIState(UIState state) { |
275 if (state == current_ui_state_) | 340 if (state == current_ui_state_) |
276 return; | 341 return; |
277 | 342 |
278 current_ui_state_ = state; | 343 current_ui_state_ = state; |
279 CallJS("setUIState", static_cast<int>(state)); | 344 CallJS("setUIState", static_cast<int>(state)); |
280 | 345 |
281 // When this handler is about to show the READY screen, we should get the | 346 // When this handler is about to show the READY screen, we should get the |
282 // latest battery status and show it on the screen. | 347 // latest battery status and show it on the screen. |
283 if (state == UIState::READY) | 348 if (state == UIState::READY) |
284 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(); | 349 DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(); |
285 | 350 |
286 // We should block power save and not shut down on lid close during migration. | 351 // We should block power save and not shut down on lid close during migration. |
287 if (state == UIState::MIGRATING) { | 352 if (state == UIState::MIGRATING) { |
288 StartBlockingPowerSave(); | 353 StartBlockingPowerSave(); |
289 PowerPolicyController::Get()->SetEncryptionMigrationActive(true); | 354 PowerPolicyController::Get()->SetEncryptionMigrationActive(true); |
290 } else { | 355 } else { |
291 StopBlockingPowerSave(); | 356 StopBlockingPowerSave(); |
292 PowerPolicyController::Get()->SetEncryptionMigrationActive(false); | 357 PowerPolicyController::Get()->SetEncryptionMigrationActive(false); |
293 } | 358 } |
| 359 |
| 360 // Record which screen is visible to the user. |
| 361 // We record it after delay to make sure that the user was actually able |
| 362 // to see the screen (i.e. the screen is not just a flash). |
| 363 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 364 FROM_HERE, |
| 365 base::BindOnce( |
| 366 &EncryptionMigrationScreenHandler::OnDelayedRecordVisibleScreen, |
| 367 weak_ptr_factory_.GetWeakPtr(), state), |
| 368 base::TimeDelta::FromSeconds(1)); |
294 } | 369 } |
295 | 370 |
296 void EncryptionMigrationScreenHandler::CheckAvailableStorage() { | 371 void EncryptionMigrationScreenHandler::CheckAvailableStorage() { |
297 base::PostTaskWithTraitsAndReplyWithResult( | 372 base::PostTaskWithTraitsAndReplyWithResult( |
298 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, | 373 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
299 base::Bind(&base::SysInfo::AmountOfFreeDiskSpace, | 374 base::Bind(&base::SysInfo::AmountOfFreeDiskSpace, |
300 base::FilePath(kCheckStoragePath)), | 375 base::FilePath(kCheckStoragePath)), |
301 base::Bind(&EncryptionMigrationScreenHandler::OnGetAvailableStorage, | 376 base::Bind(&EncryptionMigrationScreenHandler::OnGetAvailableStorage, |
302 weak_ptr_factory_.GetWeakPtr())); | 377 weak_ptr_factory_.GetWeakPtr())); |
303 } | 378 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 cryptohome::Authorization(GetAuthKey()), mount, | 419 cryptohome::Authorization(GetAuthKey()), mount, |
345 base::Bind(&EncryptionMigrationScreenHandler::OnMountExistingVault, | 420 base::Bind(&EncryptionMigrationScreenHandler::OnMountExistingVault, |
346 weak_ptr_factory_.GetWeakPtr())); | 421 weak_ptr_factory_.GetWeakPtr())); |
347 } | 422 } |
348 | 423 |
349 void EncryptionMigrationScreenHandler::OnMountExistingVault( | 424 void EncryptionMigrationScreenHandler::OnMountExistingVault( |
350 bool success, | 425 bool success, |
351 cryptohome::MountError return_code, | 426 cryptohome::MountError return_code, |
352 const std::string& mount_hash) { | 427 const std::string& mount_hash) { |
353 if (!success || return_code != cryptohome::MOUNT_ERROR_NONE) { | 428 if (!success || return_code != cryptohome::MOUNT_ERROR_NONE) { |
| 429 RecordMigrationResult( |
| 430 should_resume_ ? MigrationResult::MOUNT_FAILURE_IN_RESUMED_MIGRATION |
| 431 : MigrationResult::MOUNT_FAILURE_IN_NEW_MIGRATION); |
354 UpdateUIState(UIState::MIGRATION_FAILED); | 432 UpdateUIState(UIState::MIGRATION_FAILED); |
355 return; | 433 return; |
356 } | 434 } |
357 | 435 |
358 DBusThreadManager::Get() | 436 DBusThreadManager::Get() |
359 ->GetCryptohomeClient() | 437 ->GetCryptohomeClient() |
360 ->SetDircryptoMigrationProgressHandler( | 438 ->SetDircryptoMigrationProgressHandler( |
361 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationProgress, | 439 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationProgress, |
362 weak_ptr_factory_.GetWeakPtr())); | 440 weak_ptr_factory_.GetWeakPtr())); |
363 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto( | 441 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto( |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 cryptohome::Identification(user_context_.GetAccountId()), | 473 cryptohome::Identification(user_context_.GetAccountId()), |
396 base::Bind(&EncryptionMigrationScreenHandler::OnRemoveCryptohome, | 474 base::Bind(&EncryptionMigrationScreenHandler::OnRemoveCryptohome, |
397 weak_ptr_factory_.GetWeakPtr())); | 475 weak_ptr_factory_.GetWeakPtr())); |
398 } | 476 } |
399 | 477 |
400 void EncryptionMigrationScreenHandler::OnRemoveCryptohome( | 478 void EncryptionMigrationScreenHandler::OnRemoveCryptohome( |
401 bool success, | 479 bool success, |
402 cryptohome::MountError return_code) { | 480 cryptohome::MountError return_code) { |
403 LOG_IF(ERROR, !success) << "Removing cryptohome failed. return code: " | 481 LOG_IF(ERROR, !success) << "Removing cryptohome failed. return code: " |
404 << return_code; | 482 << return_code; |
| 483 RecordRemoveCryptohomeResult(success, should_resume_); |
405 UpdateUIState(UIState::MIGRATION_FAILED); | 484 UpdateUIState(UIState::MIGRATION_FAILED); |
406 } | 485 } |
407 | 486 |
408 cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() { | 487 cryptohome::KeyDefinition EncryptionMigrationScreenHandler::GetAuthKey() { |
409 // |auth_key| is created in the same manner as CryptohomeAuthenticator. | 488 // |auth_key| is created in the same manner as CryptohomeAuthenticator. |
410 const Key* key = user_context_.GetKey(); | 489 const Key* key = user_context_.GetKey(); |
411 // If the |key| is a plain text password, crash rather than attempting to | 490 // If the |key| is a plain text password, crash rather than attempting to |
412 // mount the cryptohome with a plain text password. | 491 // mount the cryptohome with a plain text password. |
413 CHECK_NE(Key::KEY_TYPE_PASSWORD_PLAIN, key->GetKeyType()); | 492 CHECK_NE(Key::KEY_TYPE_PASSWORD_PLAIN, key->GetKeyType()); |
414 // Set the authentication's key label to an empty string, which is a wildcard | 493 // Set the authentication's key label to an empty string, which is a wildcard |
(...skipping 11 matching lines...) Expand all Loading... |
426 uint64_t total) { | 505 uint64_t total) { |
427 switch (status) { | 506 switch (status) { |
428 case cryptohome::DIRCRYPTO_MIGRATION_INITIALIZING: | 507 case cryptohome::DIRCRYPTO_MIGRATION_INITIALIZING: |
429 UpdateUIState(UIState::MIGRATING); | 508 UpdateUIState(UIState::MIGRATING); |
430 break; | 509 break; |
431 case cryptohome::DIRCRYPTO_MIGRATION_IN_PROGRESS: | 510 case cryptohome::DIRCRYPTO_MIGRATION_IN_PROGRESS: |
432 UpdateUIState(UIState::MIGRATING); | 511 UpdateUIState(UIState::MIGRATING); |
433 CallJS("setMigrationProgress", static_cast<double>(current) / total); | 512 CallJS("setMigrationProgress", static_cast<double>(current) / total); |
434 break; | 513 break; |
435 case cryptohome::DIRCRYPTO_MIGRATION_SUCCESS: | 514 case cryptohome::DIRCRYPTO_MIGRATION_SUCCESS: |
| 515 RecordMigrationResult(should_resume_ |
| 516 ? MigrationResult::SUCCESS_IN_RESUMED_MIGRATION |
| 517 : MigrationResult::SUCCESS_IN_NEW_MIGRATION); |
436 // If the battery level decreased during migration, record the consumed | 518 // If the battery level decreased during migration, record the consumed |
437 // battery level. | 519 // battery level. |
438 if (*current_battery_percent_ < initial_battery_percent_) { | 520 if (*current_battery_percent_ < initial_battery_percent_) { |
439 UMA_HISTOGRAM_PERCENTAGE( | 521 UMA_HISTOGRAM_PERCENTAGE( |
440 kUmaNameConsumedBatteryPercent, | 522 kUmaNameConsumedBatteryPercent, |
441 static_cast<int>(std::round(initial_battery_percent_ - | 523 static_cast<int>(std::round(initial_battery_percent_ - |
442 *current_battery_percent_))); | 524 *current_battery_percent_))); |
443 } | 525 } |
444 // Restart immediately after successful migration. | 526 // Restart immediately after successful migration. |
445 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 527 DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
446 break; | 528 break; |
447 case cryptohome::DIRCRYPTO_MIGRATION_FAILED: | 529 case cryptohome::DIRCRYPTO_MIGRATION_FAILED: |
| 530 RecordMigrationResult( |
| 531 should_resume_ ? MigrationResult::GENERAL_FAILURE_IN_RESUMED_MIGRATION |
| 532 : MigrationResult::GENERAL_FAILURE_IN_NEW_MIGRATION); |
448 // Stop listening to the progress updates. | 533 // Stop listening to the progress updates. |
449 DBusThreadManager::Get() | 534 DBusThreadManager::Get() |
450 ->GetCryptohomeClient() | 535 ->GetCryptohomeClient() |
451 ->SetDircryptoMigrationProgressHandler( | 536 ->SetDircryptoMigrationProgressHandler( |
452 CryptohomeClient::DircryptoMigrationProgessHandler()); | 537 CryptohomeClient::DircryptoMigrationProgessHandler()); |
453 // Shows error screen after removing user directory is completed. | 538 // Shows error screen after removing user directory is completed. |
454 RemoveCryptohome(); | 539 RemoveCryptohome(); |
455 break; | 540 break; |
456 default: | 541 default: |
457 break; | 542 break; |
458 } | 543 } |
459 } | 544 } |
460 | 545 |
461 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { | 546 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { |
462 if (!success) { | 547 if (!success) { |
463 LOG(ERROR) << "Requesting MigrateToDircrypto failed."; | 548 LOG(ERROR) << "Requesting MigrateToDircrypto failed."; |
| 549 RecordMigrationResult( |
| 550 should_resume_ ? MigrationResult::REQUEST_FAILURE_IN_RESUMED_MIGRATION |
| 551 : MigrationResult::REQUEST_FAILURE_IN_NEW_MIGRATION); |
464 UpdateUIState(UIState::MIGRATION_FAILED); | 552 UpdateUIState(UIState::MIGRATION_FAILED); |
465 } | 553 } |
466 } | 554 } |
467 | 555 |
| 556 void EncryptionMigrationScreenHandler::OnDelayedRecordVisibleScreen( |
| 557 UIState ui_state) { |
| 558 if (current_ui_state_ != ui_state) |
| 559 return; |
| 560 |
| 561 // If |current_ui_state_| is not changed for a second, record the current |
| 562 // screen as a "visible" screen. |
| 563 UMA_HISTOGRAM_ENUMERATION(kUmaNameVisibleScreen, ui_state, UIState::COUNT); |
| 564 } |
| 565 |
468 } // namespace chromeos | 566 } // namespace chromeos |
OLD | NEW |