| 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/signin/signin_manager_factory.h" | |
| 11 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
| 12 #include "chrome/browser/ui/chrome_pages.h" | 11 #include "chrome/browser/ui/chrome_pages.h" |
| 13 #include "chrome/browser/ui/global_error/global_error_service.h" | 12 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 14 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 13 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 15 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 14 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 16 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 15 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 17 #include "chrome/common/url_constants.h" | 16 #include "chrome/common/url_constants.h" |
| 18 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
| 19 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
| 21 | 20 |
| 22 SigninGlobalError::SigninGlobalError(Profile* profile) | 21 SigninGlobalError::SigninGlobalError(SigninManager* manager, Profile* profile) |
| 23 : auth_error_(GoogleServiceAuthError::None()), | 22 : auth_error_(GoogleServiceAuthError::None()), |
| 23 signin_manager_(manager), |
| 24 profile_(profile) { | 24 profile_(profile) { |
| 25 } | 25 } |
| 26 | 26 |
| 27 SigninGlobalError::~SigninGlobalError() { | 27 SigninGlobalError::~SigninGlobalError() { |
| 28 DCHECK(provider_set_.empty()) | 28 DCHECK(provider_set_.empty()) |
| 29 << "All AuthStatusProviders should be unregistered before" | 29 << "All AuthStatusProviders should be unregistered before" |
| 30 << " SigninManager::Shutdown() is called"; | 30 << " SigninManager::Shutdown() is called"; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void SigninGlobalError::AddProvider(const AuthStatusProvider* provider) { | 33 void SigninGlobalError::AddProvider(const AuthStatusProvider* provider) { |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 #else | 89 #else |
| 90 return false; | 90 return false; |
| 91 #endif | 91 #endif |
| 92 } | 92 } |
| 93 | 93 |
| 94 int SigninGlobalError::MenuItemCommandID() { | 94 int SigninGlobalError::MenuItemCommandID() { |
| 95 return IDC_SHOW_SIGNIN_ERROR; | 95 return IDC_SHOW_SIGNIN_ERROR; |
| 96 } | 96 } |
| 97 | 97 |
| 98 string16 SigninGlobalError::MenuItemLabel() { | 98 string16 SigninGlobalError::MenuItemLabel() { |
| 99 if (SigninManagerFactory::GetForProfile(profile_)-> | 99 if (signin_manager_->GetAuthenticatedUsername().empty() || |
| 100 GetAuthenticatedUsername().empty() || | |
| 101 auth_error_.state() == GoogleServiceAuthError::NONE || | 100 auth_error_.state() == GoogleServiceAuthError::NONE || |
| 102 auth_error_.state() == GoogleServiceAuthError::CONNECTION_FAILED) { | 101 auth_error_.state() == GoogleServiceAuthError::CONNECTION_FAILED) { |
| 103 // If the user isn't signed in, or there's no auth error worth elevating to | 102 // If the user isn't signed in, or there's no auth error worth elevating to |
| 104 // the user, don't display any menu item. | 103 // the user, don't display any menu item. |
| 105 return string16(); | 104 return string16(); |
| 106 } else { | 105 } else { |
| 107 // There's an auth error the user should know about - notify the user. | 106 // There's an auth error the user should know about - notify the user. |
| 108 return l10n_util::GetStringUTF16(IDS_SYNC_SIGN_IN_ERROR_WRENCH_MENU_ITEM); | 107 return l10n_util::GetStringUTF16(IDS_SYNC_SIGN_IN_ERROR_WRENCH_MENU_ITEM); |
| 109 } | 108 } |
| 110 } | 109 } |
| (...skipping 23 matching lines...) Expand all Loading... |
| 134 bool SigninGlobalError::HasBubbleView() { | 133 bool SigninGlobalError::HasBubbleView() { |
| 135 return !GetBubbleViewMessage().empty(); | 134 return !GetBubbleViewMessage().empty(); |
| 136 } | 135 } |
| 137 | 136 |
| 138 string16 SigninGlobalError::GetBubbleViewTitle() { | 137 string16 SigninGlobalError::GetBubbleViewTitle() { |
| 139 return l10n_util::GetStringUTF16(IDS_SIGNIN_ERROR_BUBBLE_VIEW_TITLE); | 138 return l10n_util::GetStringUTF16(IDS_SIGNIN_ERROR_BUBBLE_VIEW_TITLE); |
| 140 } | 139 } |
| 141 | 140 |
| 142 string16 SigninGlobalError::GetBubbleViewMessage() { | 141 string16 SigninGlobalError::GetBubbleViewMessage() { |
| 143 // If the user isn't signed in, no need to display an error bubble. | 142 // If the user isn't signed in, no need to display an error bubble. |
| 144 if (SigninManagerFactory::GetForProfile(profile_)-> | 143 if (signin_manager_->GetAuthenticatedUsername().empty()) { |
| 145 GetAuthenticatedUsername().empty()) { | |
| 146 return string16(); | 144 return string16(); |
| 147 } | 145 } |
| 148 | 146 |
| 149 switch (auth_error_.state()) { | 147 switch (auth_error_.state()) { |
| 150 // In the case of no error, or a simple network error, don't bother | 148 // In the case of no error, or a simple network error, don't bother |
| 151 // displaying a popup bubble. | 149 // displaying a popup bubble. |
| 152 case GoogleServiceAuthError::CONNECTION_FAILED: | 150 case GoogleServiceAuthError::CONNECTION_FAILED: |
| 153 case GoogleServiceAuthError::NONE: | 151 case GoogleServiceAuthError::NONE: |
| 154 return string16(); | 152 return string16(); |
| 155 | 153 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 void SigninGlobalError::OnBubbleViewDidClose(Browser* browser) { | 191 void SigninGlobalError::OnBubbleViewDidClose(Browser* browser) { |
| 194 } | 192 } |
| 195 | 193 |
| 196 void SigninGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { | 194 void SigninGlobalError::BubbleViewAcceptButtonPressed(Browser* browser) { |
| 197 ExecuteMenuItem(browser); | 195 ExecuteMenuItem(browser); |
| 198 } | 196 } |
| 199 | 197 |
| 200 void SigninGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { | 198 void SigninGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { |
| 201 NOTREACHED(); | 199 NOTREACHED(); |
| 202 } | 200 } |
| OLD | NEW |