| 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 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HANDL
ER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HANDL
ER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HANDL
ER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HANDL
ER_H_ |
| 7 | 7 |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "chrome/browser/chromeos/login/screens/encryption_migration_screen_view
.h" | 9 #include "chrome/browser/chromeos/login/screens/encryption_migration_screen_view
.h" |
| 10 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" | 10 #include "chrome/browser/ui/webui/chromeos/login/base_screen_handler.h" |
| 11 #include "chromeos/dbus/power_manager_client.h" |
| 11 #include "chromeos/login/auth/user_context.h" | 12 #include "chromeos/login/auth/user_context.h" |
| 12 #include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h" | 13 #include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h" |
| 13 | 14 |
| 14 namespace chromeos { | 15 namespace chromeos { |
| 15 | 16 |
| 16 // WebUI implementation of EncryptionMigrationScreenView | 17 // WebUI implementation of EncryptionMigrationScreenView |
| 17 class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView, | 18 class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView, |
| 18 public BaseScreenHandler { | 19 public BaseScreenHandler, |
| 20 public PowerManagerClient::Observer { |
| 19 public: | 21 public: |
| 20 EncryptionMigrationScreenHandler(); | 22 EncryptionMigrationScreenHandler(); |
| 21 ~EncryptionMigrationScreenHandler() override; | 23 ~EncryptionMigrationScreenHandler() override; |
| 22 | 24 |
| 23 // EncryptionMigrationScreenView implementation: | 25 // EncryptionMigrationScreenView implementation: |
| 24 void Show() override; | 26 void Show() override; |
| 25 void Hide() override; | 27 void Hide() override; |
| 26 void SetDelegate(Delegate* delegate) override; | 28 void SetDelegate(Delegate* delegate) override; |
| 27 void SetUserContext(const UserContext& user_context) override; | 29 void SetUserContext(const UserContext& user_context) override; |
| 28 void SetShouldResume(bool should_resume) override; | 30 void SetShouldResume(bool should_resume) override; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 42 READY = 1, | 44 READY = 1, |
| 43 MIGRATING = 2, | 45 MIGRATING = 2, |
| 44 MIGRATION_SUCCEEDED = 3, | 46 MIGRATION_SUCCEEDED = 3, |
| 45 MIGRATION_FAILED = 4, | 47 MIGRATION_FAILED = 4, |
| 46 NOT_ENOUGH_STORAGE = 5, | 48 NOT_ENOUGH_STORAGE = 5, |
| 47 }; | 49 }; |
| 48 | 50 |
| 49 // WebUIMessageHandler implementation: | 51 // WebUIMessageHandler implementation: |
| 50 void RegisterMessages() override; | 52 void RegisterMessages() override; |
| 51 | 53 |
| 54 // PowerManagerClient::Observer implementation: |
| 55 void PowerChanged(const power_manager::PowerSupplyProperties& proto) override; |
| 56 |
| 52 // Handlers for JS API callbacks. | 57 // Handlers for JS API callbacks. |
| 53 void HandleStartMigration(); | 58 void HandleStartMigration(); |
| 54 void HandleSkipMigration(); | 59 void HandleSkipMigration(); |
| 55 void HandleRequestRestart(); | 60 void HandleRequestRestart(); |
| 56 | 61 |
| 57 // Updates UI state. | 62 // Updates UI state. |
| 58 void UpdateUIState(UIState state); | 63 void UpdateUIState(UIState state); |
| 59 | 64 |
| 60 // Requests cryptohome to start encryption migration. | 65 // Requests cryptohome to start encryption migration. |
| 61 void CheckAvailableStorage(); | 66 void CheckAvailableStorage(); |
| 62 void OnGetAvailableStorage(int64_t size); | 67 void OnGetAvailableStorage(int64_t size); |
| 68 void WaitBatteryAndMigrate(); |
| 63 void StartMigration(); | 69 void StartMigration(); |
| 64 | 70 |
| 65 // Handlers for cryptohome API callbacks. | 71 // Handlers for cryptohome API callbacks. |
| 66 void OnMigrationProgress(cryptohome::DircryptoMigrationStatus status, | 72 void OnMigrationProgress(cryptohome::DircryptoMigrationStatus status, |
| 67 uint64_t current, | 73 uint64_t current, |
| 68 uint64_t total); | 74 uint64_t total); |
| 69 void OnMigrationRequested(bool success); | 75 void OnMigrationRequested(bool success); |
| 70 | 76 |
| 71 Delegate* delegate_ = nullptr; | 77 Delegate* delegate_ = nullptr; |
| 72 bool show_on_init_ = false; | 78 bool show_on_init_ = false; |
| 73 | 79 |
| 74 // The current UI state which should be refrected in the web UI. | 80 // The current UI state which should be refrected in the web UI. |
| 75 UIState current_ui_state_ = INITIAL; | 81 UIState current_ui_state_ = INITIAL; |
| 76 | 82 |
| 77 // The current user's UserContext, which is used to request the migration to | 83 // The current user's UserContext, which is used to request the migration to |
| 78 // cryptohome. | 84 // cryptohome. |
| 79 UserContext user_context_; | 85 UserContext user_context_; |
| 80 | 86 |
| 81 // The callback which is used to log in to the session from the migration UI. | 87 // The callback which is used to log in to the session from the migration UI. |
| 82 ContinueLoginCallback continue_login_callback_; | 88 ContinueLoginCallback continue_login_callback_; |
| 83 | 89 |
| 84 // True if the system should resume the previous incomplete migration. | 90 // True if the system should resume the previous incomplete migration. |
| 85 bool should_resume_ = false; | 91 bool should_resume_ = false; |
| 86 | 92 |
| 93 // The current battery level. |
| 94 double current_battery_percent_ = 0.0; |
| 95 |
| 96 // True if the migration should start immediately once the battery level gets |
| 97 // sufficient. |
| 98 bool should_migrate_on_enough_battery_ = false; |
| 99 |
| 87 base::WeakPtrFactory<EncryptionMigrationScreenHandler> weak_ptr_factory_; | 100 base::WeakPtrFactory<EncryptionMigrationScreenHandler> weak_ptr_factory_; |
| 88 | 101 |
| 89 DISALLOW_COPY_AND_ASSIGN(EncryptionMigrationScreenHandler); | 102 DISALLOW_COPY_AND_ASSIGN(EncryptionMigrationScreenHandler); |
| 90 }; | 103 }; |
| 91 | 104 |
| 92 } // namespace chromeos | 105 } // namespace chromeos |
| 93 | 106 |
| 94 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HA
NDLER_H_ | 107 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HA
NDLER_H_ |
| OLD | NEW |