| 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_global_error.h" | 5 #include "chrome/browser/signin/signin_global_error.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/app/chrome_command_ids.h" | 8 #include "chrome/app/chrome_command_ids.h" |
| 9 #include "chrome/browser/signin/signin_manager.h" | 9 #include "chrome/browser/signin/signin_manager.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (login_ui->current_login_ui()) { | 111 if (login_ui->current_login_ui()) { |
| 112 login_ui->current_login_ui()->FocusUI(); | 112 login_ui->current_login_ui()->FocusUI(); |
| 113 return; | 113 return; |
| 114 } | 114 } |
| 115 // Need to navigate to the settings page and display the UI. | 115 // Need to navigate to the settings page and display the UI. |
| 116 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); | 116 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupSubPage); |
| 117 #endif | 117 #endif |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool SigninGlobalError::HasBubbleView() { | 120 bool SigninGlobalError::HasBubbleView() { |
| 121 return !GetBubbleViewMessage().empty(); | 121 return !GetBubbleViewMessages().empty(); |
| 122 } | 122 } |
| 123 | 123 |
| 124 string16 SigninGlobalError::GetBubbleViewTitle() { | 124 string16 SigninGlobalError::GetBubbleViewTitle() { |
| 125 return l10n_util::GetStringUTF16(IDS_SIGNIN_ERROR_BUBBLE_VIEW_TITLE); | 125 return l10n_util::GetStringUTF16(IDS_SIGNIN_ERROR_BUBBLE_VIEW_TITLE); |
| 126 } | 126 } |
| 127 | 127 |
| 128 string16 SigninGlobalError::GetBubbleViewMessage() { | 128 std::vector<string16> SigninGlobalError::GetBubbleViewMessages() { |
| 129 std::vector<string16> messages; |
| 129 // If the user isn't signed in, no need to display an error bubble. | 130 // If the user isn't signed in, no need to display an error bubble. |
| 130 if (signin_manager_->GetAuthenticatedUsername().empty()) { | 131 if (signin_manager_->GetAuthenticatedUsername().empty()) { |
| 131 return string16(); | 132 return messages; |
| 132 } | 133 } |
| 133 | 134 |
| 134 switch (auth_error_.state()) { | 135 switch (auth_error_.state()) { |
| 135 // In the case of no error, or a simple network error, don't bother | 136 // In the case of no error, or a simple network error, don't bother |
| 136 // displaying a popup bubble. | 137 // displaying a popup bubble. |
| 137 case GoogleServiceAuthError::CONNECTION_FAILED: | 138 case GoogleServiceAuthError::CONNECTION_FAILED: |
| 138 case GoogleServiceAuthError::NONE: | 139 case GoogleServiceAuthError::NONE: |
| 139 return string16(); | 140 return messages; |
| 140 | 141 |
| 141 // User credentials are invalid (bad acct, etc). | 142 // User credentials are invalid (bad acct, etc). |
| 142 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: | 143 case GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS: |
| 143 case GoogleServiceAuthError::ACCOUNT_DELETED: | 144 case GoogleServiceAuthError::ACCOUNT_DELETED: |
| 144 case GoogleServiceAuthError::ACCOUNT_DISABLED: | 145 case GoogleServiceAuthError::ACCOUNT_DISABLED: |
| 145 return l10n_util::GetStringFUTF16( | 146 messages.push_back(l10n_util::GetStringFUTF16( |
| 146 IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_MESSAGE, | 147 IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_MESSAGE, |
| 147 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 148 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 149 break; |
| 148 | 150 |
| 149 // Sync service is not available for this account's domain. | 151 // Sync service is not available for this account's domain. |
| 150 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: | 152 case GoogleServiceAuthError::SERVICE_UNAVAILABLE: |
| 151 return l10n_util::GetStringFUTF16( | 153 messages.push_back(l10n_util::GetStringFUTF16( |
| 152 IDS_SYNC_UNAVAILABLE_ERROR_BUBBLE_VIEW_MESSAGE, | 154 IDS_SYNC_UNAVAILABLE_ERROR_BUBBLE_VIEW_MESSAGE, |
| 153 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 155 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 156 break; |
| 154 | 157 |
| 155 // Generic message for "other" errors. | 158 // Generic message for "other" errors. |
| 156 default: | 159 default: |
| 157 return l10n_util::GetStringFUTF16( | 160 messages.push_back(l10n_util::GetStringFUTF16( |
| 158 IDS_SYNC_OTHER_SIGN_IN_ERROR_BUBBLE_VIEW_MESSAGE, | 161 IDS_SYNC_OTHER_SIGN_IN_ERROR_BUBBLE_VIEW_MESSAGE, |
| 159 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 162 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 160 } | 163 } |
| 164 return messages; |
| 161 } | 165 } |
| 162 | 166 |
| 163 string16 SigninGlobalError::GetBubbleViewAcceptButtonLabel() { | 167 string16 SigninGlobalError::GetBubbleViewAcceptButtonLabel() { |
| 164 // If the service is unavailable, don't give the user the option to try | 168 // If the service is unavailable, don't give the user the option to try |
| 165 // signing in again. | 169 // signing in again. |
| 166 if (auth_error_.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) { | 170 if (auth_error_.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) { |
| 167 return l10n_util::GetStringUTF16( | 171 return l10n_util::GetStringUTF16( |
| 168 IDS_SYNC_UNAVAILABLE_ERROR_BUBBLE_VIEW_ACCEPT); | 172 IDS_SYNC_UNAVAILABLE_ERROR_BUBBLE_VIEW_ACCEPT); |
| 169 } else { | 173 } else { |
| 170 return l10n_util::GetStringUTF16(IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_ACCEPT); | 174 return l10n_util::GetStringUTF16(IDS_SYNC_SIGN_IN_ERROR_BUBBLE_VIEW_ACCEPT); |
| 171 } | 175 } |
| 172 } | 176 } |
| 173 | 177 |
| 174 string16 SigninGlobalError::GetBubbleViewCancelButtonLabel() { | 178 string16 SigninGlobalError::GetBubbleViewCancelButtonLabel() { |
| 175 return string16(); | 179 return string16(); |
| 176 } | 180 } |
| 177 | 181 |
| 178 void SigninGlobalError::OnBubbleViewDidClose(Browser* browser) { | 182 void SigninGlobalError::OnBubbleViewDidClose(Browser* browser) { |
| 179 } | 183 } |
| 180 | 184 |
| 181 void SigninGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { | 185 void SigninGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { |
| 182 ExecuteMenuItem(browser); | 186 ExecuteMenuItem(browser); |
| 183 } | 187 } |
| 184 | 188 |
| 185 void SigninGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { | 189 void SigninGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { |
| 186 NOTREACHED(); | 190 NOTREACHED(); |
| 187 } | 191 } |
| OLD | NEW |