| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "ios/chrome/browser/ui/sync/sync_util.h" | 5 #import "ios/chrome/browser/ui/sync/sync_util.h" |
| 6 | 6 |
| 7 #include "base/metrics/histogram_macros.h" | 7 #include "base/metrics/histogram_macros.h" |
| 8 #include "components/infobars/core/infobar_manager.h" | 8 #include "components/infobars/core/infobar_manager.h" |
| 9 #include "components/strings/grit/components_strings.h" | 9 #include "components/strings/grit/components_strings.h" |
| 10 #import "ios/chrome/browser/browser_state/chrome_browser_state.h" | 10 #import "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 11 #include "ios/chrome/browser/sync/sync_setup_service.h" | 11 #include "ios/chrome/browser/sync/sync_setup_service.h" |
| 12 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" | 12 #include "ios/chrome/browser/sync/sync_setup_service_factory.h" |
| 13 #import "ios/chrome/browser/tabs/tab.h" | 13 #import "ios/chrome/browser/tabs/tab.h" |
| 14 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" | 14 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h" |
| 15 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" | 15 #include "ios/chrome/browser/ui/commands/ios_command_ids.h" |
| 16 #import "ios/chrome/browser/ui/commands/show_signin_command.h" | 16 #import "ios/chrome/browser/ui/commands/show_signin_command.h" |
| 17 #include "ios/chrome/browser/ui/sync/sync_error_infobar_delegate.h" | 17 #include "ios/chrome/browser/ui/sync/sync_error_infobar_delegate.h" |
| 18 #include "ios/chrome/grit/ios_chromium_strings.h" | 18 #include "ios/chrome/grit/ios_chromium_strings.h" |
| 19 #include "ios/chrome/grit/ios_strings.h" | 19 #include "ios/chrome/grit/ios_strings.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 20 #include "ui/base/l10n/l10n_util.h" |
| 21 | 21 |
| 22 namespace { | 22 namespace { |
| 23 // Enumerated constants for logging when a sign-in error infobar was shown | 23 // Enumerated constants for logging when a sign-in error infobar was shown |
| 24 // to the user. This was added for crbug/265352 to quantify how often this | 24 // to the user. This was added for crbug/265352 to quantify how often this |
| 25 // bug shows up in the wild. The logged histogram count should be interpreted | 25 // bug shows up in the wild. The logged histogram count should be interpreted |
| 26 // as a ratio of the number of active sync users. | 26 // as a ratio of the number of active sync users. |
| 27 enum { | 27 enum ErrorState { |
| 28 SYNC_SIGN_IN_NEEDS_UPDATE = 1, | 28 SYNC_SIGN_IN_NEEDS_UPDATE = 1, |
| 29 SYNC_SERVICE_UNAVAILABLE, | 29 SYNC_SERVICE_UNAVAILABLE, |
| 30 SYNC_NEEDS_PASSPHRASE, | 30 SYNC_NEEDS_PASSPHRASE, |
| 31 SYNC_UNRECOVERABLE_ERROR, | 31 SYNC_UNRECOVERABLE_ERROR, |
| 32 SYNC_ERROR_COUNT | 32 SYNC_ERROR_COUNT |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 namespace ios_internal { | 37 namespace ios_internal { |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 SyncSetupService* syncSetupService = | 133 SyncSetupService* syncSetupService = |
| 134 SyncSetupServiceFactory::GetForBrowserState(browser_state); | 134 SyncSetupServiceFactory::GetForBrowserState(browser_state); |
| 135 if (!syncSetupService) | 135 if (!syncSetupService) |
| 136 return false; | 136 return false; |
| 137 SyncSetupService::SyncServiceState errorState = | 137 SyncSetupService::SyncServiceState errorState = |
| 138 syncSetupService->GetSyncServiceState(); | 138 syncSetupService->GetSyncServiceState(); |
| 139 if (IsTransientSyncError(errorState)) | 139 if (IsTransientSyncError(errorState)) |
| 140 return false; | 140 return false; |
| 141 | 141 |
| 142 // Logs when an infobar is shown to user. See crbug/265352. | 142 // Logs when an infobar is shown to user. See crbug/265352. |
| 143 int loggedErrorState = 0; | 143 ErrorState loggedErrorState = SYNC_ERROR_COUNT; |
| 144 switch (errorState) { | 144 switch (errorState) { |
| 145 case SyncSetupService::kNoSyncServiceError: | 145 case SyncSetupService::kNoSyncServiceError: |
| 146 case SyncSetupService::kSyncServiceCouldNotConnect: | 146 case SyncSetupService::kSyncServiceCouldNotConnect: |
| 147 case SyncSetupService::kSyncServiceServiceUnavailable: | 147 case SyncSetupService::kSyncServiceServiceUnavailable: |
| 148 NOTREACHED(); | 148 NOTREACHED(); |
| 149 break; | 149 break; |
| 150 case SyncSetupService::kSyncServiceSignInNeedsUpdate: | 150 case SyncSetupService::kSyncServiceSignInNeedsUpdate: |
| 151 loggedErrorState = SYNC_SIGN_IN_NEEDS_UPDATE; | 151 loggedErrorState = SYNC_SIGN_IN_NEEDS_UPDATE; |
| 152 break; | 152 break; |
| 153 case SyncSetupService::kSyncServiceNeedsPassphrase: | 153 case SyncSetupService::kSyncServiceNeedsPassphrase: |
| (...skipping 19 matching lines...) Expand all Loading... |
| 173 return true; | 173 return true; |
| 174 case SyncSetupService::kSyncServiceSignInNeedsUpdate: | 174 case SyncSetupService::kSyncServiceSignInNeedsUpdate: |
| 175 case SyncSetupService::kSyncServiceNeedsPassphrase: | 175 case SyncSetupService::kSyncServiceNeedsPassphrase: |
| 176 case SyncSetupService::kSyncServiceUnrecoverableError: | 176 case SyncSetupService::kSyncServiceUnrecoverableError: |
| 177 return false; | 177 return false; |
| 178 } | 178 } |
| 179 } | 179 } |
| 180 | 180 |
| 181 } // namespace sync | 181 } // namespace sync |
| 182 } // namespace ios_internal | 182 } // namespace ios_internal |
| OLD | NEW |