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

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

Issue 6902101: Refactor sync passphrase setup flow and fix passphrase tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: de Morgan's law simplification. 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_ui_util.h" 5 #include "chrome/browser/sync/sync_ui_util.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/i18n/number_formatting.h" 8 #include "base/i18n/number_formatting.h"
9 #include "base/i18n/time_formatting.h" 9 #include "base/i18n/time_formatting.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 if (!service) { 96 if (!service) {
97 return PRE_SYNCED; 97 return PRE_SYNCED;
98 } 98 }
99 99
100 if (service->HasSyncSetupCompleted()) { 100 if (service->HasSyncSetupCompleted()) {
101 ProfileSyncService::Status status(service->QueryDetailedSyncStatus()); 101 ProfileSyncService::Status status(service->QueryDetailedSyncStatus());
102 const AuthError& auth_error = service->GetAuthError(); 102 const AuthError& auth_error = service->GetAuthError();
103 103
104 // Either show auth error information with a link to re-login, auth in prog, 104 // Either show auth error information with a link to re-login, auth in prog,
105 // or note that everything is OK with the last synced time. 105 // or note that everything is OK with the last synced time.
106 if (status.authenticated && !service->observed_passphrase_required()) { 106 if (status.authenticated && !service->ObservedPassphraseRequired()) {
107 // Everything is peachy. 107 // Everything is peachy.
108 if (status_label) { 108 if (status_label) {
109 status_label->assign(GetSyncedStateStatusLabel(service)); 109 status_label->assign(GetSyncedStateStatusLabel(service));
110 } 110 }
111 DCHECK_EQ(auth_error.state(), AuthError::NONE); 111 DCHECK_EQ(auth_error.state(), AuthError::NONE);
112 } else if (service->UIShouldDepictAuthInProgress()) { 112 } else if (service->UIShouldDepictAuthInProgress()) {
113 if (status_label) { 113 if (status_label) {
114 status_label->assign( 114 status_label->assign(
115 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); 115 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
116 } 116 }
117 result_type = PRE_SYNCED; 117 result_type = PRE_SYNCED;
118 } else if (service->observed_passphrase_required()) { 118 } else if (service->ObservedPassphraseRequired()) {
119 if (service->passphrase_required_for_decryption()) { 119 if (service->passphrase_required_reason() ==
120 sync_api::REASON_DECRYPTION ||
121 service->passphrase_required_reason() ==
122 sync_api::REASON_SET_PASSPHRASE_FAILED) {
120 // NOT first machine. 123 // NOT first machine.
121 // Show a link ("needs attention"), but still indicate the 124 // Show a link ("needs attention"), but still indicate the
122 // current synced status. Return SYNC_PROMO so that 125 // current synced status. Return SYNC_PROMO so that
123 // the configure link will still be shown. 126 // the configure link will still be shown.
124 if (status_label && link_label) { 127 if (status_label && link_label) {
125 status_label->assign(GetSyncedStateStatusLabel(service)); 128 status_label->assign(GetSyncedStateStatusLabel(service));
126 link_label->assign( 129 link_label->assign(
127 l10n_util::GetStringUTF16(IDS_SYNC_PASSWORD_SYNC_ATTENTION)); 130 l10n_util::GetStringUTF16(IDS_SYNC_PASSWORD_SYNC_ATTENTION));
128 } 131 }
129 result_type = SYNC_PROMO; 132 result_type = SYNC_PROMO;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 183
181 // Returns the status info for use on the new tab page, where we want slightly 184 // Returns the status info for use on the new tab page, where we want slightly
182 // different information than in the settings panel. 185 // different information than in the settings panel.
183 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service, 186 MessageType GetStatusInfoForNewTabPage(ProfileSyncService* service,
184 string16* status_label, 187 string16* status_label,
185 string16* link_label) { 188 string16* link_label) {
186 DCHECK(status_label); 189 DCHECK(status_label);
187 DCHECK(link_label); 190 DCHECK(link_label);
188 191
189 if (service->HasSyncSetupCompleted() && 192 if (service->HasSyncSetupCompleted() &&
190 service->observed_passphrase_required()) { 193 service->ObservedPassphraseRequired()) {
191 if (!service->passphrase_required_for_decryption()) { 194 if (service->passphrase_required_reason() == sync_api::REASON_ENCRYPTION) {
192 // First machine migrating to passwords. Show as a promotion. 195 // First machine migrating to passwords. Show as a promotion.
193 if (status_label && link_label) { 196 if (status_label && link_label) {
194 status_label->assign( 197 status_label->assign(
195 l10n_util::GetStringFUTF16( 198 l10n_util::GetStringFUTF16(
196 IDS_SYNC_NTP_PASSWORD_PROMO, 199 IDS_SYNC_NTP_PASSWORD_PROMO,
197 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); 200 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)));
198 link_label->assign( 201 link_label->assign(
199 l10n_util::GetStringUTF16(IDS_SYNC_NTP_PASSWORD_ENABLE)); 202 l10n_util::GetStringUTF16(IDS_SYNC_NTP_PASSWORD_ENABLE));
200 } 203 }
201 return SYNC_PROMO; 204 return SYNC_PROMO;
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 436
434 DictionaryValue* val = new DictionaryValue; 437 DictionaryValue* val = new DictionaryValue;
435 val->SetString("stat_name", "Autofill Migration Time"); 438 val->SetString("stat_name", "Autofill Migration Time");
436 val->SetString("stat_value", ConstructTime(info.autofill_migration_time)); 439 val->SetString("stat_value", ConstructTime(info.autofill_migration_time));
437 details->Append(val); 440 details->Append(val);
438 } 441 }
439 } 442 }
440 } 443 }
441 444
442 } // namespace sync_ui_util 445 } // namespace sync_ui_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698