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

Side by Side Diff: chrome/browser/sync/sync_setup_flow.cc

Issue 7583032: Merge 95693 - [Sync] Fix encryption/passphrase handling. (Closed) Base URL: svn://svn.chromium.org/chrome/branches/835/src/
Patch Set: Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/profile_sync_service_harness.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sync/sync_setup_flow.h" 5 #include "chrome/browser/sync/sync_setup_flow.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 args->SetBoolean("syncApps", 169 args->SetBoolean("syncApps",
170 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncApps)); 170 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncApps));
171 args->SetBoolean("encryptionEnabled", 171 args->SetBoolean("encryptionEnabled",
172 !CommandLine::ForCurrentProcess()->HasSwitch( 172 !CommandLine::ForCurrentProcess()->HasSwitch(
173 switches::kDisableSyncEncryption)); 173 switches::kDisableSyncEncryption));
174 174
175 syncable::ModelTypeSet encrypted_types; 175 syncable::ModelTypeSet encrypted_types;
176 service->GetEncryptedDataTypes(&encrypted_types); 176 service->GetEncryptedDataTypes(&encrypted_types);
177 bool encrypt_all = 177 bool encrypt_all =
178 encrypted_types.upper_bound(syncable::PASSWORDS) != encrypted_types.end(); 178 encrypted_types.upper_bound(syncable::PASSWORDS) != encrypted_types.end();
179 if (service->HasPendingEncryptedTypes())
180 encrypt_all = true;
179 args->SetBoolean("encryptAllData", encrypt_all); 181 args->SetBoolean("encryptAllData", encrypt_all);
180 182
181 // Load the parameters for the encryption tab. 183 // Load the parameters for the encryption tab.
182 args->SetBoolean("usePassphrase", service->IsUsingSecondaryPassphrase()); 184 args->SetBoolean("usePassphrase", service->IsUsingSecondaryPassphrase());
183 } 185 }
184 186
185 bool SyncSetupFlow::AttachSyncSetupHandler(SyncSetupFlowHandler* handler) { 187 bool SyncSetupFlow::AttachSyncSetupHandler(SyncSetupFlowHandler* handler) {
186 if (flow_handler_) 188 if (flow_handler_)
187 return false; 189 return false;
188 190
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 const std::string& password, 262 const std::string& password,
261 const std::string& captcha, 263 const std::string& captcha,
262 const std::string& access_code) { 264 const std::string& access_code) {
263 service_->OnUserSubmittedAuth(username, password, captcha, access_code); 265 service_->OnUserSubmittedAuth(username, password, captcha, access_code);
264 } 266 }
265 267
266 void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) { 268 void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) {
267 // Go to the "loading..." screen. 269 // Go to the "loading..." screen.
268 Advance(SyncSetupWizard::SETTING_UP); 270 Advance(SyncSetupWizard::SETTING_UP);
269 271
272 // Note: encryption will not occur until OnUserChoseDatatypes is called.
273 syncable::ModelTypeSet encrypted_types;
270 if (configuration.encrypt_all) { 274 if (configuration.encrypt_all) {
271 syncable::ModelTypeSet data_types; 275 // Encrypt all registered types.
272 service_->GetRegisteredDataTypes(&data_types); 276 service_->GetRegisteredDataTypes(&encrypted_types);
273 service_->EncryptDataTypes(data_types); 277 } // Else we clear the pending types for encryption.
274 } 278 service_->set_pending_types_for_encryption(encrypted_types);
275 279
276 // If we are activating the passphrase, we need to have one supplied. 280 // It's possible the user has to provide a secondary passphrase even when
277 DCHECK(service_->IsUsingSecondaryPassphrase() || 281 // they have not set one previously. This occurs when the user has changed
278 !configuration.use_secondary_passphrase || 282 // their gaia password and then sign in to a new machine for the first time.
279 configuration.secondary_passphrase.length() > 0); 283 // The new machine will download data encrypted with their old gaia password,
280 284 // which their current gaia password will not be able to decrypt, triggering
285 // a prompt for a passphrase. At this point, the user must enter their old
286 // password, which we store as a new secondary passphrase.
287 // TODO(zea): eventually use the above gaia_passphrase instead of the
288 // secondary passphrase in this case.
281 if (configuration.use_secondary_passphrase) { 289 if (configuration.use_secondary_passphrase) {
282 if (!service_->IsUsingSecondaryPassphrase()) { 290 if (!service_->IsUsingSecondaryPassphrase()) {
283 service_->SetPassphrase(configuration.secondary_passphrase, true, true); 291 service_->SetPassphrase(configuration.secondary_passphrase, true, true);
284 tried_creating_explicit_passphrase_ = true; 292 tried_creating_explicit_passphrase_ = true;
285 } else { 293 } else {
286 service_->SetPassphrase(configuration.secondary_passphrase, true, false); 294 service_->SetPassphrase(configuration.secondary_passphrase, true, false);
287 tried_setting_explicit_passphrase_ = true; 295 tried_setting_explicit_passphrase_ = true;
288 } 296 }
289 } 297 }
290 298
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 break; 431 break;
424 } 432 }
425 case SyncSetupWizard::DONE: 433 case SyncSetupWizard::DONE:
426 flow_handler_->ShowSetupDone( 434 flow_handler_->ShowSetupDone(
427 UTF16ToWide(service_->GetAuthenticatedUsername())); 435 UTF16ToWide(service_->GetAuthenticatedUsername()));
428 break; 436 break;
429 default: 437 default:
430 NOTREACHED() << "Invalid advance state: " << state; 438 NOTREACHED() << "Invalid advance state: " << state;
431 } 439 }
432 } 440 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_harness.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698