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

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

Issue 2798023005: Force encryption migration if the device supports ARC. (Closed)
Patch Set: 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 #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 "chrome/browser/lifetime/application_lifetime.h" 7 #include "chrome/browser/lifetime/application_lifetime.h"
8 #include "chromeos/cryptohome/homedir_methods.h" 8 #include "chromeos/cryptohome/homedir_methods.h"
9 #include "chromeos/dbus/cryptohome_client.h" 9 #include "chromeos/dbus/cryptohome_client.h"
10 #include "chromeos/dbus/dbus_thread_manager.h" 10 #include "chromeos/dbus/dbus_thread_manager.h"
11 #include "chromeos/login/auth/login_performer.h"
11 12
12 namespace { 13 namespace {
13 14
14 constexpr char kJsScreenPath[] = "login.EncryptionMigrationScreen"; 15 constexpr char kJsScreenPath[] = "login.EncryptionMigrationScreen";
15 16
16 // JS API callbacks names. 17 // JS API callbacks names.
17 constexpr char kJsApiStartMigration[] = "startMigration"; 18 constexpr char kJsApiStartMigration[] = "startMigration";
19 constexpr char kJsApiSkipMigration[] = "skipMigration";
18 constexpr char kJsApiRequestRestart[] = "requestRestart"; 20 constexpr char kJsApiRequestRestart[] = "requestRestart";
19 21
20 } // namespace 22 } // namespace
21 23
22 namespace chromeos { 24 namespace chromeos {
23 25
24 EncryptionMigrationScreenHandler::EncryptionMigrationScreenHandler() 26 EncryptionMigrationScreenHandler::EncryptionMigrationScreenHandler()
25 : BaseScreenHandler(kScreenId), weak_ptr_factory_(this) { 27 : BaseScreenHandler(kScreenId), weak_ptr_factory_(this) {
26 set_call_js_prefix(kJsScreenPath); 28 set_call_js_prefix(kJsScreenPath);
27 } 29 }
(...skipping 19 matching lines...) Expand all
47 delegate_ = delegate; 49 delegate_ = delegate;
48 if (page_is_ready()) 50 if (page_is_ready())
49 Initialize(); 51 Initialize();
50 } 52 }
51 53
52 void EncryptionMigrationScreenHandler::SetUserContext( 54 void EncryptionMigrationScreenHandler::SetUserContext(
53 const UserContext& user_context) { 55 const UserContext& user_context) {
54 user_context_ = user_context; 56 user_context_ = user_context;
55 } 57 }
56 58
59 void EncryptionMigrationScreenHandler::SetLoginPerformer(
60 LoginPerformer* login_performer) {
61 login_performer_ = login_performer;
62 }
63
57 void EncryptionMigrationScreenHandler::DeclareLocalizedValues( 64 void EncryptionMigrationScreenHandler::DeclareLocalizedValues(
58 ::login::LocalizedValuesBuilder* builder) {} 65 ::login::LocalizedValuesBuilder* builder) {}
59 66
60 void EncryptionMigrationScreenHandler::Initialize() { 67 void EncryptionMigrationScreenHandler::Initialize() {
61 if (!page_is_ready() || !delegate_) 68 if (!page_is_ready() || !delegate_)
62 return; 69 return;
63 70
64 if (show_on_init_) { 71 if (show_on_init_) {
65 Show(); 72 Show();
66 show_on_init_ = false; 73 show_on_init_ = false;
67 } 74 }
68 } 75 }
69 76
70 void EncryptionMigrationScreenHandler::RegisterMessages() { 77 void EncryptionMigrationScreenHandler::RegisterMessages() {
71 AddCallback(kJsApiStartMigration, 78 AddCallback(kJsApiStartMigration,
72 &EncryptionMigrationScreenHandler::HandleStartMigration); 79 &EncryptionMigrationScreenHandler::HandleStartMigration);
80 AddCallback(kJsApiSkipMigration,
81 &EncryptionMigrationScreenHandler::HandleSkipMigration);
73 AddCallback(kJsApiRequestRestart, 82 AddCallback(kJsApiRequestRestart,
74 &EncryptionMigrationScreenHandler::HandleRequestRestart); 83 &EncryptionMigrationScreenHandler::HandleRequestRestart);
75 } 84 }
76 85
77 void EncryptionMigrationScreenHandler::HandleStartMigration() { 86 void EncryptionMigrationScreenHandler::HandleStartMigration() {
78 StartMigration(); 87 StartMigration();
79 } 88 }
80 89
90 void EncryptionMigrationScreenHandler::HandleSkipMigration() {
91 // If the user skips migration, we mount the cryptohome without performing the
92 // migration by reusing UserContext and LoginPerformer which were used in the
93 // previous attempt and dropping |is_forcing_dircrypto| flag in UserContext.
94 // In this case, the user can not launch ARC apps in the session, and will be
95 // asked to do the migration again in the next log-in attempt.
96 user_context_.SetIsForcingDircrypto(false);
97 login_performer_->PerformLogin(user_context_, login_performer_->auth_mode());
98 }
99
81 void EncryptionMigrationScreenHandler::HandleRequestRestart() { 100 void EncryptionMigrationScreenHandler::HandleRequestRestart() {
82 // TODO(fukino): If the migration finished successfully, we don't need to 101 // TODO(fukino): If the migration finished successfully, we don't need to
83 // restart the device. Let's sign in to the desktop using the already-provided 102 // restart the device. Let's sign in to the desktop using the already-provided
84 // user credential. 103 // user credential.
85 chrome::AttemptRestart(); 104 chrome::AttemptRestart();
86 } 105 }
87 106
88 void EncryptionMigrationScreenHandler::UpdateUIState(UIState state) { 107 void EncryptionMigrationScreenHandler::UpdateUIState(UIState state) {
89 if (state == current_ui_state_) 108 if (state == current_ui_state_)
90 return; 109 return;
(...skipping 19 matching lines...) Expand all
110 // Chrome OS M38 and older will have a legacy key with no label while those 129 // Chrome OS M38 and older will have a legacy key with no label while those
111 // created by Chrome OS M39 and newer will have a key with the label 130 // created by Chrome OS M39 and newer will have a key with the label
112 // kCryptohomeGAIAKeyLabel. 131 // kCryptohomeGAIAKeyLabel.
113 const cryptohome::KeyDefinition auth_key(key->GetSecret(), std::string(), 132 const cryptohome::KeyDefinition auth_key(key->GetSecret(), std::string(),
114 cryptohome::PRIV_DEFAULT); 133 cryptohome::PRIV_DEFAULT);
115 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto( 134 cryptohome::HomedirMethods::GetInstance()->MigrateToDircrypto(
116 cryptohome::Identification(user_context_.GetAccountId()), 135 cryptohome::Identification(user_context_.GetAccountId()),
117 cryptohome::Authorization(auth_key), 136 cryptohome::Authorization(auth_key),
118 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationRequested, 137 base::Bind(&EncryptionMigrationScreenHandler::OnMigrationRequested,
119 weak_ptr_factory_.GetWeakPtr())); 138 weak_ptr_factory_.GetWeakPtr()));
139 UpdateUIState(UIState::MIGRATING);
120 } 140 }
121 141
122 void EncryptionMigrationScreenHandler::OnMigrationProgress( 142 void EncryptionMigrationScreenHandler::OnMigrationProgress(
123 cryptohome::DircryptoMigrationStatus status, 143 cryptohome::DircryptoMigrationStatus status,
124 uint64_t current, 144 uint64_t current,
125 uint64_t total) { 145 uint64_t total) {
126 switch (status) { 146 switch (status) {
127 case cryptohome::DIRCRYPTO_MIGRATION_INITIALIZING: 147 case cryptohome::DIRCRYPTO_MIGRATION_INITIALIZING:
128 UpdateUIState(UIState::MIGRATING); 148 UpdateUIState(UIState::MIGRATING);
129 break; 149 break;
(...skipping 20 matching lines...) Expand all
150 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) { 170 void EncryptionMigrationScreenHandler::OnMigrationRequested(bool success) {
151 // This function is called when MigrateToDircrypto is correctly requested. 171 // This function is called when MigrateToDircrypto is correctly requested.
152 // It does not mean that the migration is completed. We should know the 172 // It does not mean that the migration is completed. We should know the
153 // completion by DircryptoMigrationProgressHandler. success == false means a 173 // completion by DircryptoMigrationProgressHandler. success == false means a
154 // failure in DBus communication. 174 // failure in DBus communication.
155 // TODO(fukino): Handle this case. Should we retry or restart? 175 // TODO(fukino): Handle this case. Should we retry or restart?
156 DCHECK(success); 176 DCHECK(success);
157 } 177 }
158 178
159 } // namespace chromeos 179 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698