Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/signin/signin_ui_util.h" | 5 #include "chrome/browser/signin/signin_ui_util.h" |
| 6 | 6 |
| 7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/signin_global_error.h" | 10 #include "chrome/browser/signin/signin_global_error.h" |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 31 // Auth errors have the highest priority - after that, individual service | 31 // Auth errors have the highest priority - after that, individual service |
| 32 // errors. | 32 // errors. |
| 33 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); | 33 SigninManager* signin_manager = SigninManagerFactory::GetForProfile(profile); |
| 34 SigninGlobalError* signin_error = signin_manager->signin_global_error(); | 34 SigninGlobalError* signin_error = signin_manager->signin_global_error(); |
| 35 if (signin_error && signin_error->HasBadge()) | 35 if (signin_error && signin_error->HasBadge()) |
| 36 return signin_error; | 36 return signin_error; |
| 37 | 37 |
| 38 // No auth error - now try other services. Currently the list is just hard- | 38 // No auth error - now try other services. Currently the list is just hard- |
| 39 // coded but in the future if we add more we can create some kind of | 39 // coded but in the future if we add more we can create some kind of |
| 40 // registration framework. | 40 // registration framework. |
| 41 if (profile->IsSyncAccessible()) { | 41 if (profile->IsSyncAccessible() && profile->IsSigninAllowed()) { |
|
Andrew T Wilson (Slow)
2013/02/04 15:41:48
Don't check IsSigninAllowed() here.
Adrian Kuegel
2013/02/05 10:55:15
Done.
| |
| 42 ProfileSyncService* service = | 42 ProfileSyncService* service = |
| 43 ProfileSyncServiceFactory::GetForProfile(profile); | 43 ProfileSyncServiceFactory::GetForProfile(profile); |
| 44 SyncGlobalError* error = service->sync_global_error(); | 44 SyncGlobalError* error = service->sync_global_error(); |
| 45 if (error && error->HasBadge()) | 45 if (error && error->HasBadge()) |
| 46 return error; | 46 return error; |
| 47 } | 47 } |
| 48 return NULL; | 48 return NULL; |
| 49 } | 49 } |
| 50 | 50 |
| 51 string16 GetSigninMenuLabel(Profile* profile) { | 51 string16 GetSigninMenuLabel(Profile* profile) { |
| 52 GlobalError* error = signin_ui_util::GetSignedInServiceError(profile); | 52 GlobalError* error = signin_ui_util::GetSignedInServiceError(profile); |
| 53 if (error) | 53 if (error) |
| 54 return error->MenuItemLabel(); | 54 return error->MenuItemLabel(); |
| 55 | 55 |
| 56 // No errors, so just display the signed in user, if any. | 56 // No errors, so just display the signed in user, if any. |
| 57 ProfileSyncService* service = profile->IsSyncAccessible() ? | 57 ProfileSyncService* service = |
| 58 ProfileSyncServiceFactory::GetForProfile(profile) : NULL; | 58 profile->IsSyncAccessible() && profile->IsSigninAllowed() ? |
|
Andrew T Wilson (Slow)
2013/02/04 15:41:48
Don't check IsSigninAllowed() here.
Adrian Kuegel
2013/02/05 10:55:15
Done.
| |
| 59 ProfileSyncServiceFactory::GetForProfile(profile) : NULL; | |
| 59 | 60 |
| 60 // Even if the user is signed in, don't display the "signed in as..." | 61 // Even if the user is signed in, don't display the "signed in as..." |
| 61 // label if we're still setting up sync. | 62 // label if we're still setting up sync. |
| 62 if (!service || !service->FirstSetupInProgress()) { | 63 if (!service || !service->FirstSetupInProgress()) { |
| 63 std::string username; | 64 std::string username; |
| 64 SigninManager* signin_manager = | 65 SigninManager* signin_manager = |
| 65 SigninManagerFactory::GetForProfileIfExists(profile); | 66 SigninManagerFactory::GetForProfileIfExists(profile); |
| 66 if (signin_manager) | 67 if (signin_manager) |
| 67 username = signin_manager->GetAuthenticatedUsername(); | 68 username = signin_manager->GetAuthenticatedUsername(); |
| 68 if (!username.empty() && !signin_manager->AuthInProgress()) { | 69 if (!username.empty() && !signin_manager->AuthInProgress()) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 127 if (status_label) { | 128 if (status_label) { |
| 128 status_label->assign(l10n_util::GetStringUTF16( | 129 status_label->assign(l10n_util::GetStringUTF16( |
| 129 IDS_SYNC_ERROR_SIGNING_IN)); | 130 IDS_SYNC_ERROR_SIGNING_IN)); |
| 130 } | 131 } |
| 131 break; | 132 break; |
| 132 } | 133 } |
| 133 } | 134 } |
| 134 | 135 |
| 135 | 136 |
| 136 } // namespace signin_ui_util | 137 } // namespace signin_ui_util |
| OLD | NEW |