Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.h

Issue 2811713002: Check the available storage size before starting encryption migration. (Closed)
Patch Set: Always check the available storage. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/login/auth/user_context.h" 11 #include "chromeos/login/auth/user_context.h"
12 #include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h" 12 #include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h"
13 13
14 namespace chromeos { 14 namespace chromeos {
15 15
16 // WebUI implementation of EncryptionMigrationScreenView 16 // WebUI implementation of EncryptionMigrationScreenView
17 class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView, 17 class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView,
18 public BaseScreenHandler { 18 public BaseScreenHandler {
19 public: 19 public:
20 EncryptionMigrationScreenHandler(); 20 EncryptionMigrationScreenHandler();
21 ~EncryptionMigrationScreenHandler() override; 21 ~EncryptionMigrationScreenHandler() override;
22 22
23 // EncryptionMigrationScreenView implementation: 23 // EncryptionMigrationScreenView implementation:
24 void Show() override; 24 void Show() override;
25 void Hide() override; 25 void Hide() override;
26 void SetDelegate(Delegate* delegate) override; 26 void SetDelegate(Delegate* delegate) override;
27 void SetUserContext(const UserContext& user_context) override; 27 void SetUserContext(const UserContext& user_context) override;
28 void SetShouldResume(bool should_resume) override; 28 void SetShouldResume(bool should_resume) override;
29 void SetContinueLoginCallback(ContinueLoginCallback callback) override; 29 void SetContinueLoginCallback(ContinueLoginCallback callback) override;
30 void SetupInitialView() override;
30 31
31 // BaseScreenHandler implementation: 32 // BaseScreenHandler implementation:
32 void DeclareLocalizedValues( 33 void DeclareLocalizedValues(
33 ::login::LocalizedValuesBuilder* builder) override; 34 ::login::LocalizedValuesBuilder* builder) override;
34 void Initialize() override; 35 void Initialize() override;
35 36
36 private: 37 private:
37 // Enumeration for the migration state. These values must be kept in sync with 38 // Enumeration for the migration state. These values must be kept in sync with
38 // EncryptionMigrationUIState in JS code. 39 // EncryptionMigrationUIState in JS code.
39 enum UIState { 40 enum UIState {
40 INITIAL = 0, 41 INITIAL = 0,
41 MIGRATING = 1, 42 READY = 1,
42 MIGRATION_SUCCEEDED = 2, 43 MIGRATING = 2,
43 MIGRATION_FAILED = 3 44 MIGRATION_SUCCEEDED = 3,
45 MIGRATION_FAILED = 4,
46 NOT_ENOUGH_STORAGE = 5,
44 }; 47 };
45 48
46 // WebUIMessageHandler implementation: 49 // WebUIMessageHandler implementation:
47 void RegisterMessages() override; 50 void RegisterMessages() override;
48 51
49 // Handlers for JS API callbacks. 52 // Handlers for JS API callbacks.
50 void HandleStartMigration(); 53 void HandleStartMigration();
51 void HandleSkipMigration(); 54 void HandleSkipMigration();
52 void HandleRequestRestart(); 55 void HandleRequestRestart();
53 56
54 // Updates UI state. 57 // Updates UI state.
55 void UpdateUIState(UIState state); 58 void UpdateUIState(UIState state);
56 59
57 // Requests cryptohome to start encryption migration. 60 // Requests cryptohome to start encryption migration.
61 void CheckAvailableStorage();
62 void OnGetAvailableStorage(int64_t size);
58 void StartMigration(); 63 void StartMigration();
59 64
60 // Handlers for cryptohome API callbacks. 65 // Handlers for cryptohome API callbacks.
61 void OnMigrationProgress(cryptohome::DircryptoMigrationStatus status, 66 void OnMigrationProgress(cryptohome::DircryptoMigrationStatus status,
62 uint64_t current, 67 uint64_t current,
63 uint64_t total); 68 uint64_t total);
64 void OnMigrationRequested(bool success); 69 void OnMigrationRequested(bool success);
65 70
66 Delegate* delegate_ = nullptr; 71 Delegate* delegate_ = nullptr;
67 bool show_on_init_ = false; 72 bool show_on_init_ = false;
68 73
69 // The current UI state which should be refrected in the web UI. 74 // The current UI state which should be refrected in the web UI.
70 UIState current_ui_state_ = INITIAL; 75 UIState current_ui_state_ = INITIAL;
71 76
72 // The current user's UserContext, which is used to request the migration to 77 // The current user's UserContext, which is used to request the migration to
73 // cryptohome. 78 // cryptohome.
74 UserContext user_context_; 79 UserContext user_context_;
75 80
76 // The callback which is used to log in to the session from the migration UI. 81 // The callback which is used to log in to the session from the migration UI.
77 ContinueLoginCallback continue_login_callback_; 82 ContinueLoginCallback continue_login_callback_;
78 83
84 // True if the system should resume the previous incomplete migration.
85 bool should_resume_ = false;
86
79 base::WeakPtrFactory<EncryptionMigrationScreenHandler> weak_ptr_factory_; 87 base::WeakPtrFactory<EncryptionMigrationScreenHandler> weak_ptr_factory_;
80 88
81 DISALLOW_COPY_AND_ASSIGN(EncryptionMigrationScreenHandler); 89 DISALLOW_COPY_AND_ASSIGN(EncryptionMigrationScreenHandler);
82 }; 90 };
83 91
84 } // namespace chromeos 92 } // namespace chromeos
85 93
86 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HA NDLER_H_ 94 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HA NDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698