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

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

Issue 2784273003: Implement a basic UI flow for cryptohome encryption migration. (Closed)
Patch Set: Address review comments. 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"
12 #include "third_party/cros_system_api/dbus/cryptohome/dbus-constants.h"
11 13
12 namespace chromeos { 14 namespace chromeos {
13 15
14 // WebUI implementation of EncryptionMigrationScreenView 16 // WebUI implementation of EncryptionMigrationScreenView
15 class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView, 17 class EncryptionMigrationScreenHandler : public EncryptionMigrationScreenView,
16 public BaseScreenHandler { 18 public BaseScreenHandler {
17 public: 19 public:
18 EncryptionMigrationScreenHandler(); 20 EncryptionMigrationScreenHandler();
19 ~EncryptionMigrationScreenHandler() override; 21 ~EncryptionMigrationScreenHandler() override;
20 22
21 // EncryptionMigrationScreenView: 23 // EncryptionMigrationScreenView implementation:
22 void Show() override; 24 void Show() override;
23 void Hide() override; 25 void Hide() override;
24 void SetDelegate(Delegate* delegate) override; 26 void SetDelegate(Delegate* delegate) override;
27 void SetUserContext(const UserContext& user_context) override;
25 28
26 // BaseScreenHandler: 29 // BaseScreenHandler implementation:
27 void DeclareLocalizedValues( 30 void DeclareLocalizedValues(
28 ::login::LocalizedValuesBuilder* builder) override; 31 ::login::LocalizedValuesBuilder* builder) override;
29 void Initialize() override; 32 void Initialize() override;
30 33
31 private: 34 private:
35 // Enumeration for the migration state. These values must be kept in sync with
36 // EncryptionMigrationUIState in JS code.
37 enum UIState {
38 INITIAL = 0,
39 MIGRATING = 1,
40 MIGRATION_SUCCEEDED = 2,
41 MIGRATION_FAILED = 3
42 };
43
44 // WebUIMessageHandler implementation:
45 void RegisterMessages() override;
46
47 // Handlers for JS API callbacks.
48 void HandleStartMigration();
49 void HandleRequestRestart();
50
51 // Updates UI state.
52 void UpdateUIState(UIState state);
53
54 // Requests cryptohome to start encryption migration.
55 void StartMigration();
56
57 // Handlers for cryptohome API callbacks.
58 void OnMigrationProgress(cryptohome::DircryptoMigrationStatus status,
59 uint64_t current,
60 uint64_t total);
61 void OnMigrationRequested(bool success);
62
32 Delegate* delegate_ = nullptr; 63 Delegate* delegate_ = nullptr;
33 bool show_on_init_ = false; 64 bool show_on_init_ = false;
34 65
66 // The current UI state which should be refrected in the web UI.
67 UIState current_ui_state_ = INITIAL;
68
69 // The current user's UserContext, which is used to request the migration to
70 // cryptohome.
71 UserContext user_context_;
72
73 base::WeakPtrFactory<EncryptionMigrationScreenHandler> weak_ptr_factory_;
74
35 DISALLOW_COPY_AND_ASSIGN(EncryptionMigrationScreenHandler); 75 DISALLOW_COPY_AND_ASSIGN(EncryptionMigrationScreenHandler);
36 }; 76 };
37 77
38 } // namespace chromeos 78 } // namespace chromeos
39 79
40 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HA NDLER_H_ 80 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_LOGIN_ENCRYPTION_MIGRATION_SCREEN_HA NDLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698