OLD | NEW |
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 11 matching lines...) Expand all Loading... |
22 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
23 #include "chrome/common/net/gaia/google_service_auth_error.h" | 23 #include "chrome/common/net/gaia/google_service_auth_error.h" |
24 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
25 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 // Helper function to disable password sync. | 30 // Helper function to disable password sync. |
31 void DisablePasswordSync(ProfileSyncService* service) { | 31 void DisablePasswordSync(ProfileSyncService* service) { |
32 syncable::ModelTypeSet types; | 32 syncable::ModelEnumSet types = service->GetPreferredDataTypes(); |
33 service->GetPreferredDataTypes(&types); | 33 types.Remove(syncable::PASSWORDS); |
34 types.erase(syncable::PASSWORDS); | |
35 service->OnUserChoseDatatypes(false, types); | 34 service->OnUserChoseDatatypes(false, types); |
36 } | 35 } |
37 | 36 |
38 // Returns the next step for the non-fatal error case. | 37 // Returns the next step for the non-fatal error case. |
39 SyncSetupWizard::State GetStepForNonFatalError(ProfileSyncService* service) { | 38 SyncSetupWizard::State GetStepForNonFatalError(ProfileSyncService* service) { |
40 // TODO(sync): Update this error handling to allow different platforms to | 39 // TODO(sync): Update this error handling to allow different platforms to |
41 // display the error appropriately (http://crbug.com/92722) instead of | 40 // display the error appropriately (http://crbug.com/92722) instead of |
42 // navigating to a LOGIN state that is not supported on every platform. | 41 // navigating to a LOGIN state that is not supported on every platform. |
43 if (service->IsPassphraseRequired()) { | 42 if (service->IsPassphraseRequired()) { |
44 if (service->IsUsingSecondaryPassphrase()) | 43 if (service->IsUsingSecondaryPassphrase()) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 DictionaryValue* args) { | 116 DictionaryValue* args) { |
118 // The SYNC_EVERYTHING case will set this to true. | 117 // The SYNC_EVERYTHING case will set this to true. |
119 args->SetBoolean("showSyncEverythingPage", false); | 118 args->SetBoolean("showSyncEverythingPage", false); |
120 | 119 |
121 args->SetBoolean("syncAllDataTypes", | 120 args->SetBoolean("syncAllDataTypes", |
122 service->profile()->GetPrefs()->GetBoolean( | 121 service->profile()->GetPrefs()->GetBoolean( |
123 prefs::kSyncKeepEverythingSynced)); | 122 prefs::kSyncKeepEverythingSynced)); |
124 | 123 |
125 // Bookmarks, Preferences, and Themes are launched for good, there's no | 124 // Bookmarks, Preferences, and Themes are launched for good, there's no |
126 // going back now. Check if the other data types are registered though. | 125 // going back now. Check if the other data types are registered though. |
127 syncable::ModelTypeSet registered_types; | 126 const syncable::ModelEnumSet registered_types = |
128 service->GetRegisteredDataTypes(®istered_types); | 127 service->GetRegisteredDataTypes(); |
129 syncable::ModelTypeSet preferred_types; | 128 const syncable::ModelEnumSet preferred_types = |
130 service->GetPreferredDataTypes(&preferred_types); | 129 service->GetPreferredDataTypes(); |
131 args->SetBoolean("passwordsRegistered", | 130 args->SetBoolean("passwordsRegistered", |
132 registered_types.count(syncable::PASSWORDS) > 0); | 131 registered_types.Has(syncable::PASSWORDS)); |
133 args->SetBoolean("autofillRegistered", | 132 args->SetBoolean("autofillRegistered", |
134 registered_types.count(syncable::AUTOFILL) > 0); | 133 registered_types.Has(syncable::AUTOFILL)); |
135 args->SetBoolean("extensionsRegistered", | 134 args->SetBoolean("extensionsRegistered", |
136 registered_types.count(syncable::EXTENSIONS) > 0); | 135 registered_types.Has(syncable::EXTENSIONS)); |
137 args->SetBoolean("typedUrlsRegistered", | 136 args->SetBoolean("typedUrlsRegistered", |
138 registered_types.count(syncable::TYPED_URLS) > 0); | 137 registered_types.Has(syncable::TYPED_URLS)); |
139 args->SetBoolean("appsRegistered", | 138 args->SetBoolean("appsRegistered", |
140 registered_types.count(syncable::APPS) > 0); | 139 registered_types.Has(syncable::APPS)); |
141 args->SetBoolean("sessionsRegistered", | 140 args->SetBoolean("sessionsRegistered", |
142 registered_types.count(syncable::SESSIONS) > 0); | 141 registered_types.Has(syncable::SESSIONS)); |
143 args->SetBoolean("syncBookmarks", | 142 args->SetBoolean("syncBookmarks", |
144 preferred_types.count(syncable::BOOKMARKS) > 0); | 143 preferred_types.Has(syncable::BOOKMARKS)); |
145 args->SetBoolean("syncPreferences", | 144 args->SetBoolean("syncPreferences", |
146 preferred_types.count(syncable::PREFERENCES) > 0); | 145 preferred_types.Has(syncable::PREFERENCES)); |
147 args->SetBoolean("syncThemes", | 146 args->SetBoolean("syncThemes", |
148 preferred_types.count(syncable::THEMES) > 0); | 147 preferred_types.Has(syncable::THEMES)); |
149 args->SetBoolean("syncPasswords", | 148 args->SetBoolean("syncPasswords", |
150 preferred_types.count(syncable::PASSWORDS) > 0); | 149 preferred_types.Has(syncable::PASSWORDS)); |
151 args->SetBoolean("syncAutofill", | 150 args->SetBoolean("syncAutofill", |
152 preferred_types.count(syncable::AUTOFILL) > 0); | 151 preferred_types.Has(syncable::AUTOFILL)); |
153 args->SetBoolean("syncExtensions", | 152 args->SetBoolean("syncExtensions", |
154 preferred_types.count(syncable::EXTENSIONS) > 0); | 153 preferred_types.Has(syncable::EXTENSIONS)); |
155 args->SetBoolean("syncSessions", | 154 args->SetBoolean("syncSessions", |
156 preferred_types.count(syncable::SESSIONS) > 0); | 155 preferred_types.Has(syncable::SESSIONS)); |
157 args->SetBoolean("syncTypedUrls", | 156 args->SetBoolean("syncTypedUrls", |
158 preferred_types.count(syncable::TYPED_URLS) > 0); | 157 preferred_types.Has(syncable::TYPED_URLS)); |
159 args->SetBoolean("syncApps", | 158 args->SetBoolean("syncApps", |
160 preferred_types.count(syncable::APPS) > 0); | 159 preferred_types.Has(syncable::APPS)); |
161 | 160 |
162 args->SetBoolean("encryptionEnabled", | 161 args->SetBoolean("encryptionEnabled", |
163 !CommandLine::ForCurrentProcess()->HasSwitch( | 162 !CommandLine::ForCurrentProcess()->HasSwitch( |
164 switches::kDisableSyncEncryption)); | 163 switches::kDisableSyncEncryption)); |
165 | 164 |
166 bool encrypt_all = service->EncryptEverythingEnabled(); | 165 bool encrypt_all = service->EncryptEverythingEnabled(); |
167 if (service->encryption_pending()) | 166 if (service->encryption_pending()) |
168 encrypt_all = true; | 167 encrypt_all = true; |
169 args->SetBoolean("encryptAllData", encrypt_all); | 168 args->SetBoolean("encryptAllData", encrypt_all); |
170 | 169 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 case SyncSetupWizard::DONE: | 494 case SyncSetupWizard::DONE: |
496 case SyncSetupWizard::ABORT: | 495 case SyncSetupWizard::ABORT: |
497 flow_handler_->ShowSetupDone(UTF8ToUTF16( | 496 flow_handler_->ShowSetupDone(UTF8ToUTF16( |
498 service_->profile()->GetPrefs()->GetString( | 497 service_->profile()->GetPrefs()->GetString( |
499 prefs::kGoogleServicesUsername))); | 498 prefs::kGoogleServicesUsername))); |
500 break; | 499 break; |
501 default: | 500 default: |
502 NOTREACHED() << "Invalid advance state: " << state; | 501 NOTREACHED() << "Invalid advance state: " << state; |
503 } | 502 } |
504 } | 503 } |
OLD | NEW |