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

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

Issue 809313009: Make the SigninErrorController a PKS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Copyrighted: 2015 Created 5 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/sync/sync_ui_util.h" 5 #include "chrome/browser/sync/sync_ui_util.h"
6 6
7 #include "base/i18n/number_formatting.h" 7 #include "base/i18n/number_formatting.h"
8 #include "base/i18n/time_formatting.h" 8 #include "base/i18n/time_formatting.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 14 #include "chrome/browser/signin/signin_error_controller_factory.h"
15 #include "chrome/browser/signin/signin_ui_util.h" 15 #include "chrome/browser/signin/signin_ui_util.h"
16 #include "chrome/browser/sync/profile_sync_service.h" 16 #include "chrome/browser/sync/profile_sync_service.h"
17 #include "chrome/browser/sync/profile_sync_service_factory.h" 17 #include "chrome/browser/sync/profile_sync_service_factory.h"
18 #include "chrome/browser/ui/browser.h" 18 #include "chrome/browser/ui/browser.h"
19 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
20 #include "chrome/browser/ui/webui/signin/login_ui_service.h" 20 #include "chrome/browser/ui/webui/signin/login_ui_service.h"
21 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 21 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
22 #include "chrome/common/chrome_switches.h" 22 #include "chrome/common/chrome_switches.h"
23 #include "chrome/common/url_constants.h" 23 #include "chrome/common/url_constants.h"
24 #include "chrome/grit/chromium_strings.h" 24 #include "chrome/grit/chromium_strings.h"
25 #include "chrome/grit/generated_resources.h" 25 #include "chrome/grit/generated_resources.h"
26 #include "chrome/grit/locale_settings.h" 26 #include "chrome/grit/locale_settings.h"
27 #include "components/signin/core/browser/profile_oauth2_token_service.h"
28 #include "components/signin/core/browser/signin_error_controller.h" 27 #include "components/signin/core/browser/signin_error_controller.h"
29 #include "components/signin/core/browser/signin_manager_base.h" 28 #include "components/signin/core/browser/signin_manager_base.h"
30 #include "google_apis/gaia/google_service_auth_error.h" 29 #include "google_apis/gaia/google_service_auth_error.h"
31 #include "sync/internal_api/public/base/model_type.h" 30 #include "sync/internal_api/public/base/model_type.h"
32 #include "sync/internal_api/public/sessions/sync_session_snapshot.h" 31 #include "sync/internal_api/public/sessions/sync_session_snapshot.h"
33 #include "sync/protocol/proto_enum_conversions.h" 32 #include "sync/protocol/proto_enum_conversions.h"
34 #include "sync/protocol/sync_protocol_error.h" 33 #include "sync/protocol/sync_protocol_error.h"
35 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
36 35
37 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 status_label->assign( 160 status_label->assign(
162 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); 161 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
163 } 162 }
164 return PRE_SYNCED; 163 return PRE_SYNCED;
165 } 164 }
166 165
167 // Check for sync errors if the sync service is enabled. 166 // Check for sync errors if the sync service is enabled.
168 if (service) { 167 if (service) {
169 // Since there is no auth in progress, check for an auth error first. 168 // Since there is no auth in progress, check for an auth error first.
170 AuthError auth_error = 169 AuthError auth_error =
171 ProfileOAuth2TokenServiceFactory::GetForProfile(service->profile())-> 170 SigninErrorControllerFactory::GetForProfile(service->profile())->
172 signin_error_controller()->auth_error(); 171 auth_error();
173 if (auth_error.state() != AuthError::NONE) { 172 if (auth_error.state() != AuthError::NONE) {
174 if (status_label && link_label) 173 if (status_label && link_label)
175 signin_ui_util::GetStatusLabelsForAuthError( 174 signin_ui_util::GetStatusLabelsForAuthError(
176 service->profile(), signin, status_label, link_label); 175 service->profile(), signin, status_label, link_label);
177 return SYNC_ERROR; 176 return SYNC_ERROR;
178 } 177 }
179 178
180 // We don't have an auth error. Check for an actionable error. 179 // We don't have an auth error. Check for an actionable error.
181 ProfileSyncService::Status status; 180 ProfileSyncService::Status status;
182 service->QueryDetailedSyncStatus(&status); 181 service->QueryDetailedSyncStatus(&status);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 status_label->assign(GetSyncedStateStatusLabel(service, signin, style)); 223 status_label->assign(GetSyncedStateStatusLabel(service, signin, style));
225 return SYNCED; 224 return SYNCED;
226 } else { 225 } else {
227 // Either show auth error information with a link to re-login, auth in prog, 226 // Either show auth error information with a link to re-login, auth in prog,
228 // or provide a link to continue with setup. 227 // or provide a link to continue with setup.
229 if (service->FirstSetupInProgress()) { 228 if (service->FirstSetupInProgress()) {
230 result_type = PRE_SYNCED; 229 result_type = PRE_SYNCED;
231 ProfileSyncService::Status status; 230 ProfileSyncService::Status status;
232 service->QueryDetailedSyncStatus(&status); 231 service->QueryDetailedSyncStatus(&status);
233 AuthError auth_error = 232 AuthError auth_error =
234 ProfileOAuth2TokenServiceFactory::GetForProfile(service->profile())-> 233 SigninErrorControllerFactory::GetForProfile(service->profile())->
235 signin_error_controller()->auth_error(); 234 auth_error();
236 if (status_label) { 235 if (status_label) {
237 status_label->assign( 236 status_label->assign(
238 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS)); 237 l10n_util::GetStringUTF16(IDS_SYNC_NTP_SETUP_IN_PROGRESS));
239 } 238 }
240 if (signin.AuthInProgress()) { 239 if (signin.AuthInProgress()) {
241 if (status_label) { 240 if (status_label) {
242 status_label->assign( 241 status_label->assign(
243 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL)); 242 l10n_util::GetStringUTF16(IDS_SYNC_AUTHENTICATING_LABEL));
244 } 243 }
245 } else if (auth_error.state() != AuthError::NONE && 244 } else if (auth_error.state() != AuthError::NONE &&
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 base::string16 ConstructTime(int64 time_in_int) { 376 base::string16 ConstructTime(int64 time_in_int) {
378 base::Time time = base::Time::FromInternalValue(time_in_int); 377 base::Time time = base::Time::FromInternalValue(time_in_int);
379 378
380 // If time is null the format function returns a time in 1969. 379 // If time is null the format function returns a time in 1969.
381 if (time.is_null()) 380 if (time.is_null())
382 return base::string16(); 381 return base::string16();
383 return base::TimeFormatFriendlyDateAndTime(time); 382 return base::TimeFormatFriendlyDateAndTime(time);
384 } 383 }
385 384
386 } // namespace sync_ui_util 385 } // namespace sync_ui_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698