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

Side by Side Diff: chrome/browser/ui/webui/options/sync_setup_handler.cc

Issue 1578173005: Move Autofill Payments integration checkbox to the sync settings page. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace bool with enum in tests Created 4 years, 11 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/options/sync_setup_handler.h" 5 #include "chrome/browser/ui/webui/options/sync_setup_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/ui/browser_window.h" 32 #include "chrome/browser/ui/browser_window.h"
33 #include "chrome/browser/ui/singleton_tabs.h" 33 #include "chrome/browser/ui/singleton_tabs.h"
34 #include "chrome/browser/ui/webui/options/options_handlers_helper.h" 34 #include "chrome/browser/ui/webui/options/options_handlers_helper.h"
35 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 35 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
36 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 36 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
37 #include "chrome/common/chrome_switches.h" 37 #include "chrome/common/chrome_switches.h"
38 #include "chrome/common/url_constants.h" 38 #include "chrome/common/url_constants.h"
39 #include "chrome/grit/chromium_strings.h" 39 #include "chrome/grit/chromium_strings.h"
40 #include "chrome/grit/generated_resources.h" 40 #include "chrome/grit/generated_resources.h"
41 #include "chrome/grit/locale_settings.h" 41 #include "chrome/grit/locale_settings.h"
42 #include "components/autofill/core/common/autofill_constants.h"
43 #include "components/autofill/core/common/autofill_pref_names.h"
42 #include "components/browser_sync/browser/profile_sync_service.h" 44 #include "components/browser_sync/browser/profile_sync_service.h"
43 #include "components/google/core/browser/google_util.h" 45 #include "components/google/core/browser/google_util.h"
44 #include "components/signin/core/browser/signin_error_controller.h" 46 #include "components/signin/core/browser/signin_error_controller.h"
45 #include "components/signin/core/browser/signin_header_helper.h" 47 #include "components/signin/core/browser/signin_header_helper.h"
46 #include "components/signin/core/browser/signin_metrics.h" 48 #include "components/signin/core/browser/signin_metrics.h"
47 #include "components/signin/core/common/profile_management_switches.h" 49 #include "components/signin/core/common/profile_management_switches.h"
48 #include "components/sync_driver/sync_prefs.h" 50 #include "components/sync_driver/sync_prefs.h"
49 #include "content/public/browser/render_view_host.h" 51 #include "content/public/browser/render_view_host.h"
50 #include "content/public/browser/web_contents.h" 52 #include "content/public/browser/web_contents.h"
51 #include "content/public/browser/web_contents_delegate.h" 53 #include "content/public/browser/web_contents_delegate.h"
(...skipping 17 matching lines...) Expand all
69 71
70 // A structure which contains all the configuration information for sync. 72 // A structure which contains all the configuration information for sync.
71 struct SyncConfigInfo { 73 struct SyncConfigInfo {
72 SyncConfigInfo(); 74 SyncConfigInfo();
73 ~SyncConfigInfo(); 75 ~SyncConfigInfo();
74 76
75 bool encrypt_all; 77 bool encrypt_all;
76 bool sync_everything; 78 bool sync_everything;
77 bool sync_nothing; 79 bool sync_nothing;
78 syncer::ModelTypeSet data_types; 80 syncer::ModelTypeSet data_types;
81 bool payments_integration_enabled;
79 std::string passphrase; 82 std::string passphrase;
80 bool passphrase_is_gaia; 83 bool passphrase_is_gaia;
81 }; 84 };
82 85
83 SyncConfigInfo::SyncConfigInfo() 86 SyncConfigInfo::SyncConfigInfo()
84 : encrypt_all(false), 87 : encrypt_all(false),
85 sync_everything(false), 88 sync_everything(false),
86 sync_nothing(false), 89 sync_nothing(false),
87 passphrase_is_gaia(false) { 90 payments_integration_enabled(false),
88 } 91 passphrase_is_gaia(false) {}
89 92
90 SyncConfigInfo::~SyncConfigInfo() {} 93 SyncConfigInfo::~SyncConfigInfo() {}
91 94
92 bool GetConfiguration(const std::string& json, SyncConfigInfo* config) { 95 bool GetConfiguration(const std::string& json, SyncConfigInfo* config) {
93 scoped_ptr<base::Value> parsed_value = base::JSONReader::Read(json); 96 scoped_ptr<base::Value> parsed_value = base::JSONReader::Read(json);
94 base::DictionaryValue* result; 97 base::DictionaryValue* result;
95 if (!parsed_value || !parsed_value->GetAsDictionary(&result)) { 98 if (!parsed_value || !parsed_value->GetAsDictionary(&result)) {
96 DLOG(ERROR) << "GetConfiguration() not passed a Dictionary"; 99 DLOG(ERROR) << "GetConfiguration() not passed a Dictionary";
97 return false; 100 return false;
98 } 101 }
99 102
100 if (!result->GetBoolean("syncAllDataTypes", &config->sync_everything)) { 103 if (!result->GetBoolean("syncAllDataTypes", &config->sync_everything)) {
101 DLOG(ERROR) << "GetConfiguration() not passed a syncAllDataTypes value"; 104 DLOG(ERROR) << "GetConfiguration() not passed a syncAllDataTypes value";
102 return false; 105 return false;
103 } 106 }
104 107
105 if (!result->GetBoolean("syncNothing", &config->sync_nothing)) { 108 if (!result->GetBoolean("syncNothing", &config->sync_nothing)) {
106 DLOG(ERROR) << "GetConfiguration() not passed a syncNothing value"; 109 DLOG(ERROR) << "GetConfiguration() not passed a syncNothing value";
107 return false; 110 return false;
108 } 111 }
109 112
110 DCHECK(!(config->sync_everything && config->sync_nothing)) 113 DCHECK(!(config->sync_everything && config->sync_nothing))
111 << "syncAllDataTypes and syncNothing cannot both be true"; 114 << "syncAllDataTypes and syncNothing cannot both be true";
112 115
116 if (!result->GetBoolean("paymentsIntegrationEnabled",
117 &config->payments_integration_enabled)) {
118 DLOG(ERROR) << "GetConfiguration() not passed a paymentsIntegrationEnabled "
119 << "value";
120 return false;
121 }
122
113 syncer::ModelTypeNameMap type_names = syncer::GetUserSelectableTypeNameMap(); 123 syncer::ModelTypeNameMap type_names = syncer::GetUserSelectableTypeNameMap();
114 124
115 for (syncer::ModelTypeNameMap::const_iterator it = type_names.begin(); 125 for (syncer::ModelTypeNameMap::const_iterator it = type_names.begin();
116 it != type_names.end(); ++it) { 126 it != type_names.end(); ++it) {
117 std::string key_name = it->second + std::string("Synced"); 127 std::string key_name = it->second + std::string("Synced");
118 bool sync_value; 128 bool sync_value;
119 if (!result->GetBoolean(key_name, &sync_value)) { 129 if (!result->GetBoolean(key_name, &sync_value)) {
120 DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name; 130 DLOG(ERROR) << "GetConfiguration() not passed a value for " << key_name;
121 return false; 131 return false;
122 } 132 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 183
174 void SyncSetupHandler::GetStaticLocalizedValues( 184 void SyncSetupHandler::GetStaticLocalizedValues(
175 base::DictionaryValue* localized_strings, 185 base::DictionaryValue* localized_strings,
176 content::WebUI* web_ui) { 186 content::WebUI* web_ui) {
177 DCHECK(localized_strings); 187 DCHECK(localized_strings);
178 188
179 base::string16 product_name(GetStringUTF16(IDS_PRODUCT_NAME)); 189 base::string16 product_name(GetStringUTF16(IDS_PRODUCT_NAME));
180 localized_strings->SetString( 190 localized_strings->SetString(
181 "chooseDataTypesInstructions", 191 "chooseDataTypesInstructions",
182 GetStringFUTF16(IDS_SYNC_CHOOSE_DATATYPES_INSTRUCTIONS, product_name)); 192 GetStringFUTF16(IDS_SYNC_CHOOSE_DATATYPES_INSTRUCTIONS, product_name));
193 localized_strings->SetString("autofillHelpURL", autofill::kHelpURL);
183 localized_strings->SetString( 194 localized_strings->SetString(
184 "encryptionInstructions", 195 "encryptionInstructions",
185 GetStringFUTF16(IDS_SYNC_ENCRYPTION_INSTRUCTIONS, product_name)); 196 GetStringFUTF16(IDS_SYNC_ENCRYPTION_INSTRUCTIONS, product_name));
186 localized_strings->SetString( 197 localized_strings->SetString(
187 "encryptionHelpURL", chrome::kSyncEncryptionHelpURL); 198 "encryptionHelpURL", chrome::kSyncEncryptionHelpURL);
188 localized_strings->SetString( 199 localized_strings->SetString(
189 "encryptionSectionMessage", 200 "encryptionSectionMessage",
190 GetStringFUTF16(IDS_SYNC_ENCRYPTION_SECTION_MESSAGE, product_name)); 201 GetStringFUTF16(IDS_SYNC_ENCRYPTION_SECTION_MESSAGE, product_name));
191 localized_strings->SetString( 202 localized_strings->SetString(
192 "passphraseRecover", 203 "passphraseRecover",
(...skipping 18 matching lines...) Expand all
211 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE)); 222 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_DIALOG_TITLE));
212 localized_strings->SetString("stopSyncingConfirm", 223 localized_strings->SetString("stopSyncingConfirm",
213 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL)); 224 l10n_util::GetStringUTF16(IDS_SYNC_STOP_SYNCING_CONFIRM_BUTTON_LABEL));
214 225
215 localized_strings->SetString( 226 localized_strings->SetString(
216 "syncEverythingHelpURL", chrome::kSyncEverythingLearnMoreURL); 227 "syncEverythingHelpURL", chrome::kSyncEverythingLearnMoreURL);
217 localized_strings->SetString( 228 localized_strings->SetString(
218 "syncErrorHelpURL", chrome::kSyncErrorsHelpURL); 229 "syncErrorHelpURL", chrome::kSyncErrorsHelpURL);
219 230
220 static OptionsStringResource resources[] = { 231 static OptionsStringResource resources[] = {
221 { "syncSetupConfigureTitle", IDS_SYNC_SETUP_CONFIGURE_TITLE }, 232 {"syncSetupConfigureTitle", IDS_SYNC_SETUP_CONFIGURE_TITLE},
222 { "syncSetupSpinnerTitle", IDS_SYNC_SETUP_SPINNER_TITLE }, 233 {"syncSetupSpinnerTitle", IDS_SYNC_SETUP_SPINNER_TITLE},
223 { "syncSetupTimeoutTitle", IDS_SYNC_SETUP_TIME_OUT_TITLE }, 234 {"syncSetupTimeoutTitle", IDS_SYNC_SETUP_TIME_OUT_TITLE},
224 { "syncSetupTimeoutContent", IDS_SYNC_SETUP_TIME_OUT_CONTENT }, 235 {"syncSetupTimeoutContent", IDS_SYNC_SETUP_TIME_OUT_CONTENT},
225 { "errorLearnMore", IDS_LEARN_MORE }, 236 {"errorLearnMore", IDS_LEARN_MORE},
226 { "cancel", IDS_CANCEL }, 237 {"cancel", IDS_CANCEL},
227 { "loginSuccess", IDS_SYNC_SUCCESS }, 238 {"loginSuccess", IDS_SYNC_SUCCESS},
228 { "settingUp", IDS_SYNC_LOGIN_SETTING_UP }, 239 {"settingUp", IDS_SYNC_LOGIN_SETTING_UP},
229 { "syncAllDataTypes", IDS_SYNC_EVERYTHING }, 240 {"syncAllDataTypes", IDS_SYNC_EVERYTHING},
230 { "chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES }, 241 {"chooseDataTypes", IDS_SYNC_CHOOSE_DATATYPES},
231 { "syncNothing", IDS_SYNC_NOTHING }, 242 {"syncNothing", IDS_SYNC_NOTHING},
232 { "bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS }, 243 {"bookmarks", IDS_SYNC_DATATYPE_BOOKMARKS},
233 { "preferences", IDS_SYNC_DATATYPE_PREFERENCES }, 244 {"preferences", IDS_SYNC_DATATYPE_PREFERENCES},
234 { "autofill", IDS_SYNC_DATATYPE_AUTOFILL }, 245 {"autofill", IDS_SYNC_DATATYPE_AUTOFILL},
235 { "themes", IDS_SYNC_DATATYPE_THEMES }, 246 {"themes", IDS_SYNC_DATATYPE_THEMES},
236 { "passwords", IDS_SYNC_DATATYPE_PASSWORDS }, 247 {"passwords", IDS_SYNC_DATATYPE_PASSWORDS},
237 { "extensions", IDS_SYNC_DATATYPE_EXTENSIONS }, 248 {"extensions", IDS_SYNC_DATATYPE_EXTENSIONS},
238 { "typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS }, 249 {"typedURLs", IDS_SYNC_DATATYPE_TYPED_URLS},
239 { "apps", IDS_SYNC_DATATYPE_APPS }, 250 {"apps", IDS_SYNC_DATATYPE_APPS},
240 { "wifiCredentials", IDS_SYNC_DATATYPE_WIFI_CREDENTIALS }, 251 {"wifiCredentials", IDS_SYNC_DATATYPE_WIFI_CREDENTIALS},
241 { "openTabs", IDS_SYNC_DATATYPE_TABS }, 252 {"openTabs", IDS_SYNC_DATATYPE_TABS},
242 { "serviceUnavailableError", IDS_SYNC_SETUP_ABORTED_BY_PENDING_CLEAR }, 253 {"enablePaymentsIntegration", IDS_AUTOFILL_USE_PAYMENTS_DATA},
243 { "confirmLabel", IDS_SYNC_CONFIRM_PASSPHRASE_LABEL }, 254 {"serviceUnavailableError", IDS_SYNC_SETUP_ABORTED_BY_PENDING_CLEAR},
244 { "emptyErrorMessage", IDS_SYNC_EMPTY_PASSPHRASE_ERROR }, 255 {"confirmLabel", IDS_SYNC_CONFIRM_PASSPHRASE_LABEL},
245 { "mismatchErrorMessage", IDS_SYNC_PASSPHRASE_MISMATCH_ERROR }, 256 {"emptyErrorMessage", IDS_SYNC_EMPTY_PASSPHRASE_ERROR},
246 { "customizeLinkLabel", IDS_SYNC_CUSTOMIZE_LINK_LABEL }, 257 {"mismatchErrorMessage", IDS_SYNC_PASSPHRASE_MISMATCH_ERROR},
247 { "confirmSyncPreferences", IDS_SYNC_CONFIRM_SYNC_PREFERENCES }, 258 {"customizeLinkLabel", IDS_SYNC_CUSTOMIZE_LINK_LABEL},
248 { "syncEverything", IDS_SYNC_SYNC_EVERYTHING }, 259 {"confirmSyncPreferences", IDS_SYNC_CONFIRM_SYNC_PREFERENCES},
249 { "useDefaultSettings", IDS_SYNC_USE_DEFAULT_SETTINGS }, 260 {"syncEverything", IDS_SYNC_SYNC_EVERYTHING},
250 { "enterPassphraseBody", IDS_SYNC_ENTER_PASSPHRASE_BODY }, 261 {"useDefaultSettings", IDS_SYNC_USE_DEFAULT_SETTINGS},
251 { "enterGooglePassphraseBody", IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY }, 262 {"enterPassphraseBody", IDS_SYNC_ENTER_PASSPHRASE_BODY},
252 { "passphraseLabel", IDS_SYNC_PASSPHRASE_LABEL }, 263 {"enterGooglePassphraseBody", IDS_SYNC_ENTER_GOOGLE_PASSPHRASE_BODY},
253 { "incorrectPassphrase", IDS_SYNC_INCORRECT_PASSPHRASE }, 264 {"passphraseLabel", IDS_SYNC_PASSPHRASE_LABEL},
254 { "passphraseWarning", IDS_SYNC_PASSPHRASE_WARNING }, 265 {"incorrectPassphrase", IDS_SYNC_INCORRECT_PASSPHRASE},
255 { "yes", IDS_SYNC_PASSPHRASE_CANCEL_YES }, 266 {"passphraseWarning", IDS_SYNC_PASSPHRASE_WARNING},
256 { "no", IDS_SYNC_PASSPHRASE_CANCEL_NO }, 267 {"yes", IDS_SYNC_PASSPHRASE_CANCEL_YES},
257 { "sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX }, 268 {"no", IDS_SYNC_PASSPHRASE_CANCEL_NO},
258 { "sectionExplicitMessagePostfix", 269 {"sectionExplicitMessagePrefix", IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_PREFIX},
259 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX }, 270 {"sectionExplicitMessagePostfix",
260 // TODO(rogerta): browser/resource/sync_promo/sync_promo.html and related 271 IDS_SYNC_PASSPHRASE_MSG_EXPLICIT_POSTFIX},
261 // file may not be needed any more. If not, then the following promo 272 // TODO(rogerta): browser/resource/sync_promo/sync_promo.html and related
262 // strings can also be removed. 273 // file may not be needed any more. If not, then the following promo
263 { "promoPageTitle", IDS_SYNC_PROMO_TAB_TITLE }, 274 // strings can also be removed.
264 { "promoSkipButton", IDS_SYNC_PROMO_SKIP_BUTTON }, 275 {"promoPageTitle", IDS_SYNC_PROMO_TAB_TITLE},
265 { "promoAdvanced", IDS_SYNC_PROMO_ADVANCED }, 276 {"promoSkipButton", IDS_SYNC_PROMO_SKIP_BUTTON},
266 { "promoLearnMore", IDS_LEARN_MORE }, 277 {"promoAdvanced", IDS_SYNC_PROMO_ADVANCED},
267 { "promoTitleShort", IDS_SYNC_PROMO_MESSAGE_TITLE_SHORT }, 278 {"promoLearnMore", IDS_LEARN_MORE},
268 { "encryptionSectionTitle", IDS_SYNC_ENCRYPTION_SECTION_TITLE }, 279 {"promoTitleShort", IDS_SYNC_PROMO_MESSAGE_TITLE_SHORT},
269 { "basicEncryptionOption", IDS_SYNC_BASIC_ENCRYPTION_DATA }, 280 {"encryptionSectionTitle", IDS_SYNC_ENCRYPTION_SECTION_TITLE},
270 { "fullEncryptionOption", IDS_SYNC_FULL_ENCRYPTION_DATA }, 281 {"basicEncryptionOption", IDS_SYNC_BASIC_ENCRYPTION_DATA},
282 {"fullEncryptionOption", IDS_SYNC_FULL_ENCRYPTION_DATA},
271 }; 283 };
272 284
273 RegisterStrings(localized_strings, resources, arraysize(resources)); 285 RegisterStrings(localized_strings, resources, arraysize(resources));
274 RegisterTitle(localized_strings, "syncSetupOverlay", IDS_SYNC_SETUP_TITLE); 286 RegisterTitle(localized_strings, "syncSetupOverlay", IDS_SYNC_SETUP_TITLE);
275 } 287 }
276 288
277 void SyncSetupHandler::ConfigureSyncDone() { 289 void SyncSetupHandler::ConfigureSyncDone() {
278 base::StringValue page("done"); 290 base::StringValue page("done");
279 web_ui()->CallJavascriptFunction( 291 web_ui()->CallJavascriptFunction(
280 "SyncSetupOverlay.showSyncSetupPage", page); 292 "SyncSetupOverlay.showSyncSetupPage", page);
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 ProfileSyncService::EXPLICIT); 573 ProfileSyncService::EXPLICIT);
562 } 574 }
563 } 575 }
564 } 576 }
565 577
566 bool user_was_prompted_for_passphrase = 578 bool user_was_prompted_for_passphrase =
567 service->IsPassphraseRequiredForDecryption(); 579 service->IsPassphraseRequiredForDecryption();
568 service->OnUserChoseDatatypes(configuration.sync_everything, 580 service->OnUserChoseDatatypes(configuration.sync_everything,
569 configuration.data_types); 581 configuration.data_types);
570 582
583 PrefService* pref_service = GetProfile()->GetPrefs();
584 pref_service->SetBoolean(autofill::prefs::kAutofillWalletImportEnabled,
585 configuration.payments_integration_enabled);
586
571 // Need to call IsPassphraseRequiredForDecryption() *after* calling 587 // Need to call IsPassphraseRequiredForDecryption() *after* calling
572 // OnUserChoseDatatypes() because the user may have just disabled the 588 // OnUserChoseDatatypes() because the user may have just disabled the
573 // encrypted datatypes (in which case we just want to exit, not prompt the 589 // encrypted datatypes (in which case we just want to exit, not prompt the
574 // user for a passphrase). 590 // user for a passphrase).
575 if (passphrase_failed || service->IsPassphraseRequiredForDecryption()) { 591 if (passphrase_failed || service->IsPassphraseRequiredForDecryption()) {
576 // We need a passphrase, or the user's attempt to set a passphrase failed - 592 // We need a passphrase, or the user's attempt to set a passphrase failed -
577 // prompt them again. This covers a few subtle cases: 593 // prompt them again. This covers a few subtle cases:
578 // 1) The user enters an incorrect passphrase *and* disabled the encrypted 594 // 1) The user enters an incorrect passphrase *and* disabled the encrypted
579 // data types. In that case we want to notify the user that the 595 // data types. In that case we want to notify the user that the
580 // passphrase was incorrect even though there are no longer any encrypted 596 // passphrase was incorrect even though there are no longer any encrypted
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
838 sync_startup_tracker_.reset(); 854 sync_startup_tracker_.reset();
839 configuring_sync_ = true; 855 configuring_sync_ = true;
840 DCHECK(service->IsBackendInitialized()) 856 DCHECK(service->IsBackendInitialized())
841 << "Cannot configure sync until the sync backend is initialized"; 857 << "Cannot configure sync until the sync backend is initialized";
842 858
843 // Setup args for the sync configure screen: 859 // Setup args for the sync configure screen:
844 // syncAllDataTypes: true if the user wants to sync everything 860 // syncAllDataTypes: true if the user wants to sync everything
845 // syncNothing: true if the user wants to sync nothing 861 // syncNothing: true if the user wants to sync nothing
846 // <data_type>Registered: true if the associated data type is supported 862 // <data_type>Registered: true if the associated data type is supported
847 // <data_type>Synced: true if the user wants to sync that specific data type 863 // <data_type>Synced: true if the user wants to sync that specific data type
864 // paymentsIntegrationEnabled: true if the user wants Payments integration
848 // encryptionEnabled: true if sync supports encryption 865 // encryptionEnabled: true if sync supports encryption
849 // encryptAllData: true if user wants to encrypt all data (not just 866 // encryptAllData: true if user wants to encrypt all data (not just
850 // passwords) 867 // passwords)
851 // usePassphrase: true if the data is encrypted with a secondary passphrase 868 // usePassphrase: true if the data is encrypted with a secondary passphrase
852 // show_passphrase: true if a passphrase is needed to decrypt the sync data 869 // show_passphrase: true if a passphrase is needed to decrypt the sync data
853 base::DictionaryValue args; 870 base::DictionaryValue args;
854 871
855 // Tell the UI layer which data types are registered/enabled by the user. 872 // Tell the UI layer which data types are registered/enabled by the user.
856 const syncer::ModelTypeSet registered_types = 873 const syncer::ModelTypeSet registered_types =
857 service->GetRegisteredDataTypes(); 874 service->GetRegisteredDataTypes();
858 const syncer::ModelTypeSet preferred_types = service->GetPreferredDataTypes(); 875 const syncer::ModelTypeSet preferred_types = service->GetPreferredDataTypes();
859 const syncer::ModelTypeSet enforced_types = service->GetForcedDataTypes(); 876 const syncer::ModelTypeSet enforced_types = service->GetForcedDataTypes();
860 syncer::ModelTypeNameMap type_names = syncer::GetUserSelectableTypeNameMap(); 877 syncer::ModelTypeNameMap type_names = syncer::GetUserSelectableTypeNameMap();
861 for (syncer::ModelTypeNameMap::const_iterator it = type_names.begin(); 878 for (syncer::ModelTypeNameMap::const_iterator it = type_names.begin();
862 it != type_names.end(); ++it) { 879 it != type_names.end(); ++it) {
863 syncer::ModelType sync_type = it->first; 880 syncer::ModelType sync_type = it->first;
864 const std::string key_name = it->second; 881 const std::string key_name = it->second;
865 args.SetBoolean(key_name + "Registered", registered_types.Has(sync_type)); 882 args.SetBoolean(key_name + "Registered", registered_types.Has(sync_type));
866 args.SetBoolean(key_name + "Synced", preferred_types.Has(sync_type)); 883 args.SetBoolean(key_name + "Synced", preferred_types.Has(sync_type));
867 args.SetBoolean(key_name + "Enforced", enforced_types.Has(sync_type)); 884 args.SetBoolean(key_name + "Enforced", enforced_types.Has(sync_type));
868 // TODO(treib): How do we want to handle pref groups, i.e. when only some of 885 // TODO(treib): How do we want to handle pref groups, i.e. when only some of
869 // the sync types behind a checkbox are force-enabled? crbug.com/403326 886 // the sync types behind a checkbox are force-enabled? crbug.com/403326
870 } 887 }
871 sync_driver::SyncPrefs sync_prefs(GetProfile()->GetPrefs()); 888 PrefService* pref_service = GetProfile()->GetPrefs();
889 sync_driver::SyncPrefs sync_prefs(pref_service);
872 args.SetBoolean("passphraseFailed", passphrase_failed); 890 args.SetBoolean("passphraseFailed", passphrase_failed);
873 args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced()); 891 args.SetBoolean("syncAllDataTypes", sync_prefs.HasKeepEverythingSynced());
874 args.SetBoolean("syncNothing", false); // Always false during initial setup. 892 args.SetBoolean("syncNothing", false); // Always false during initial setup.
893 args.SetBoolean(
894 "paymentsIntegrationEnabled",
895 pref_service->GetBoolean(autofill::prefs::kAutofillWalletImportEnabled));
875 args.SetBoolean("encryptAllData", service->IsEncryptEverythingEnabled()); 896 args.SetBoolean("encryptAllData", service->IsEncryptEverythingEnabled());
876 args.SetBoolean("encryptAllDataAllowed", 897 args.SetBoolean("encryptAllDataAllowed",
877 service->IsEncryptEverythingAllowed()); 898 service->IsEncryptEverythingAllowed());
878 899
879 // We call IsPassphraseRequired() here, instead of calling 900 // We call IsPassphraseRequired() here, instead of calling
880 // IsPassphraseRequiredForDecryption(), because we want to show the passphrase 901 // IsPassphraseRequiredForDecryption(), because we want to show the passphrase
881 // UI even if no encrypted data types are enabled. 902 // UI even if no encrypted data types are enabled.
882 args.SetBoolean("showPassphrase", service->IsPassphraseRequired()); 903 args.SetBoolean("showPassphrase", service->IsPassphraseRequired());
883 904
884 // To distinguish between FROZEN_IMPLICIT_PASSPHRASE and CUSTOM_PASSPHRASE 905 // To distinguish between FROZEN_IMPLICIT_PASSPHRASE and CUSTOM_PASSPHRASE
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 "SyncSetupOverlay.showSyncSetupPage", page, args); 953 "SyncSetupOverlay.showSyncSetupPage", page, args);
933 954
934 // Make sure the tab used for the Gaia sign in does not cover the settings 955 // Make sure the tab used for the Gaia sign in does not cover the settings
935 // tab. 956 // tab.
936 FocusUI(); 957 FocusUI();
937 } 958 }
938 959
939 LoginUIService* SyncSetupHandler::GetLoginUIService() const { 960 LoginUIService* SyncSetupHandler::GetLoginUIService() const {
940 return LoginUIServiceFactory::GetForProfile(GetProfile()); 961 return LoginUIServiceFactory::GetForProfile(GetProfile());
941 } 962 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698