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

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

Issue 7056021: Sync: Add encryption customization radio. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix. Created 9 years, 7 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
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/json/json_reader.h" 9 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
10 #include "base/metrics/histogram.h" 11 #include "base/metrics/histogram.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/browser/platform_util.h" 15 #include "chrome/browser/platform_util.h"
15 #include "chrome/browser/prefs/pref_service.h" 16 #include "chrome/browser/prefs/pref_service.h"
16 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/sync/profile_sync_service.h" 18 #include "chrome/browser/sync/profile_sync_service.h"
19 #include "chrome/browser/sync/syncable/model_type.h"
18 #include "chrome/browser/sync/sync_setup_flow_handler.h" 20 #include "chrome/browser/sync/sync_setup_flow_handler.h"
19 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
20 #include "chrome/browser/ui/browser_dialogs.h" 22 #include "chrome/browser/ui/browser_dialogs.h"
21 #include "chrome/browser/ui/browser_list.h" 23 #include "chrome/browser/ui/browser_list.h"
24 #include "chrome/common/chrome_switches.h"
22 #include "chrome/common/net/gaia/google_service_auth_error.h" 25 #include "chrome/common/net/gaia/google_service_auth_error.h"
23 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 27 #include "chrome/common/url_constants.h"
25 #include "content/browser/renderer_host/render_view_host.h" 28 #include "content/browser/renderer_host/render_view_host.h"
26 #include "content/browser/tab_contents/tab_contents.h" 29 #include "content/browser/tab_contents/tab_contents.h"
27 #include "grit/generated_resources.h" 30 #include "grit/generated_resources.h"
28 #include "grit/locale_settings.h" 31 #include "grit/locale_settings.h"
29 #include "ui/base/l10n/l10n_font_util.h" 32 #include "ui/base/l10n/l10n_font_util.h"
30 #include "ui/gfx/font.h" 33 #include "ui/gfx/font.h"
31 34
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 args->SetBoolean("syncAutofill", 137 args->SetBoolean("syncAutofill",
135 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncAutofill)); 138 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncAutofill));
136 args->SetBoolean("syncExtensions", 139 args->SetBoolean("syncExtensions",
137 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncExtensions)); 140 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncExtensions));
138 args->SetBoolean("syncSessions", 141 args->SetBoolean("syncSessions",
139 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncSessions)); 142 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncSessions));
140 args->SetBoolean("syncTypedUrls", 143 args->SetBoolean("syncTypedUrls",
141 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncTypedUrls)); 144 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncTypedUrls));
142 args->SetBoolean("syncApps", 145 args->SetBoolean("syncApps",
143 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncApps)); 146 service->profile()->GetPrefs()->GetBoolean(prefs::kSyncApps));
147 args->SetBoolean("encryptionEnabled",
148 CommandLine::ForCurrentProcess()->HasSwitch(
149 switches::kEnableSyncEncryption));
150
151 syncable::ModelTypeSet encrypted_types;
152 service->GetEncryptedDataTypes(&encrypted_types);
153 bool encrypt_all =
154 encrypted_types.upper_bound(syncable::PASSWORDS) != encrypted_types.end();
155 args->SetBoolean("encryptAllData", encrypt_all);
144 156
145 // Load the parameters for the encryption tab. 157 // Load the parameters for the encryption tab.
146 args->SetBoolean("usePassphrase", service->IsUsingSecondaryPassphrase()); 158 args->SetBoolean("usePassphrase", service->IsUsingSecondaryPassphrase());
147 } 159 }
148 160
149 // static 161 // static
150 void SyncSetupFlow::GetArgsForEnterPassphrase( 162 void SyncSetupFlow::GetArgsForEnterPassphrase(
151 bool tried_creating_explicit_passphrase, 163 bool tried_creating_explicit_passphrase,
152 bool tried_setting_explicit_passphrase, 164 bool tried_setting_explicit_passphrase,
153 DictionaryValue* args) { 165 DictionaryValue* args) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 const std::string& password, 232 const std::string& password,
221 const std::string& captcha, 233 const std::string& captcha,
222 const std::string& access_code) { 234 const std::string& access_code) {
223 service_->OnUserSubmittedAuth(username, password, captcha, access_code); 235 service_->OnUserSubmittedAuth(username, password, captcha, access_code);
224 } 236 }
225 237
226 void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) { 238 void SyncSetupFlow::OnUserConfigured(const SyncConfiguration& configuration) {
227 // Go to the "loading..." screen. 239 // Go to the "loading..." screen.
228 Advance(SyncSetupWizard::SETTING_UP); 240 Advance(SyncSetupWizard::SETTING_UP);
229 241
242 if (configuration.encrypt_all) {
243 syncable::ModelTypeSet data_types;
244 service_->GetRegisteredDataTypes(&data_types);
245 service_->EncryptDataTypes(data_types);
246 }
247
230 // If we are activating the passphrase, we need to have one supplied. 248 // If we are activating the passphrase, we need to have one supplied.
231 DCHECK(service_->IsUsingSecondaryPassphrase() || 249 DCHECK(service_->IsUsingSecondaryPassphrase() ||
232 !configuration.use_secondary_passphrase || 250 !configuration.use_secondary_passphrase ||
233 configuration.secondary_passphrase.length() > 0); 251 configuration.secondary_passphrase.length() > 0);
234 252
235 if (configuration.use_secondary_passphrase && 253 if (configuration.use_secondary_passphrase &&
236 !service_->IsUsingSecondaryPassphrase()) { 254 !service_->IsUsingSecondaryPassphrase()) {
237 service_->SetPassphrase(configuration.secondary_passphrase, true, true); 255 service_->SetPassphrase(configuration.secondary_passphrase, true, true);
238 tried_creating_explicit_passphrase_ = true; 256 tried_creating_explicit_passphrase_ = true;
239 } 257 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 } 391 }
374 case SyncSetupWizard::DONE: 392 case SyncSetupWizard::DONE:
375 flow_handler_->ShowSetupDone( 393 flow_handler_->ShowSetupDone(
376 UTF16ToWide(service_->GetAuthenticatedUsername())); 394 UTF16ToWide(service_->GetAuthenticatedUsername()));
377 break; 395 break;
378 default: 396 default:
379 NOTREACHED() << "Invalid advance state: " << state; 397 NOTREACHED() << "Invalid advance state: " << state;
380 } 398 }
381 current_state_ = state; 399 current_state_ = state;
382 } 400 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_setup_flow.h ('k') | chrome/browser/ui/webui/options/sync_setup_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698