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