| 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/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/signin_manager_factory.h" | 10 #include "chrome/browser/signin/signin_manager_factory.h" |
| 11 #include "chrome/browser/signin/signin_promo.h" | 11 #include "chrome/browser/signin/signin_promo.h" |
| 12 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
| 13 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/chrome_pages.h" | 14 #include "chrome/browser/ui/chrome_pages.h" |
| 14 #include "chrome/browser/ui/global_error/global_error_service.h" | 15 #include "chrome/browser/ui/global_error/global_error_service.h" |
| 15 #include "chrome/browser/ui/global_error/global_error_service_factory.h" | 16 #include "chrome/browser/ui/global_error/global_error_service_factory.h" |
| 16 #include "chrome/browser/ui/singleton_tabs.h" | 17 #include "chrome/browser/ui/singleton_tabs.h" |
| 17 #include "chrome/browser/ui/webui/signin/login_ui_service.h" | 18 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 18 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 19 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 19 #include "chrome/common/url_constants.h" | 20 #include "chrome/common/url_constants.h" |
| 20 #include "components/signin/core/browser/signin_manager.h" | 21 #include "components/signin/core/browser/signin_manager.h" |
| 22 #include "components/signin/core/common/profile_management_switches.h" |
| 21 #include "grit/chromium_strings.h" | 23 #include "grit/chromium_strings.h" |
| 22 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
| 23 #include "net/base/url_util.h" | 25 #include "net/base/url_util.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 25 | 27 |
| 26 SigninGlobalError::SigninGlobalError( | 28 SigninGlobalError::SigninGlobalError( |
| 27 SigninErrorController* error_controller, | 29 SigninErrorController* error_controller, |
| 28 Profile* profile) | 30 Profile* profile) |
| 29 : profile_(profile), | 31 : profile_(profile), |
| 30 error_controller_(error_controller) { | 32 error_controller_(error_controller) { |
| 31 error_controller_->AddObserver(this); | 33 error_controller_->AddObserver(this); |
| 32 GlobalErrorServiceFactory::GetForProfile(profile_)->AddGlobalError(this); | |
| 33 } | 34 } |
| 34 | 35 |
| 35 SigninGlobalError::~SigninGlobalError() { | 36 SigninGlobalError::~SigninGlobalError() { |
| 36 DCHECK(!error_controller_) | 37 DCHECK(!error_controller_) |
| 37 << "SigninGlobalError::Shutdown() was not called"; | 38 << "SigninGlobalError::Shutdown() was not called"; |
| 38 } | 39 } |
| 39 | 40 |
| 41 bool SigninGlobalError::HasError() { |
| 42 return HasMenuItem(); |
| 43 } |
| 44 |
| 45 void SigninGlobalError::AttemptToFixError(Browser* browser) { |
| 46 if (!HasError()) |
| 47 return; |
| 48 |
| 49 ExecuteMenuItem(browser); |
| 50 } |
| 51 |
| 40 void SigninGlobalError::Shutdown() { | 52 void SigninGlobalError::Shutdown() { |
| 41 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); | 53 GlobalErrorServiceFactory::GetForProfile(profile_)->RemoveGlobalError(this); |
| 42 error_controller_->RemoveObserver(this); | 54 error_controller_->RemoveObserver(this); |
| 43 error_controller_ = NULL; | 55 error_controller_ = NULL; |
| 44 } | 56 } |
| 45 | 57 |
| 46 bool SigninGlobalError::HasMenuItem() { | 58 bool SigninGlobalError::HasMenuItem() { |
| 47 return error_controller_->HasError(); | 59 return error_controller_->HasError(); |
| 48 } | 60 } |
| 49 | 61 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 70 #endif | 82 #endif |
| 71 | 83 |
| 72 // Global errors don't show up in the wrench menu on android. | 84 // Global errors don't show up in the wrench menu on android. |
| 73 #if !defined(OS_ANDROID) | 85 #if !defined(OS_ANDROID) |
| 74 LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_); | 86 LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_); |
| 75 if (login_ui->current_login_ui()) { | 87 if (login_ui->current_login_ui()) { |
| 76 login_ui->current_login_ui()->FocusUI(); | 88 login_ui->current_login_ui()->FocusUI(); |
| 77 return; | 89 return; |
| 78 } | 90 } |
| 79 | 91 |
| 80 chrome::ShowSingletonTab( | 92 if (switches::IsNewProfileManagement()) { |
| 81 browser, | 93 browser->window()->ShowAvatarBubbleFromAvatarButton( |
| 82 signin::GetReauthURL(profile_, error_controller_->error_account_id())); | 94 BrowserWindow::AVATAR_BUBBLE_MODE_REAUTH); |
| 95 } else { |
| 96 chrome::ShowSingletonTab( |
| 97 browser, |
| 98 signin::GetReauthURL(profile_, error_controller_->error_account_id())); |
| 99 } |
| 83 #endif | 100 #endif |
| 84 } | 101 } |
| 85 | 102 |
| 86 bool SigninGlobalError::HasBubbleView() { | 103 bool SigninGlobalError::HasBubbleView() { |
| 87 return !GetBubbleViewMessages().empty(); | 104 return !GetBubbleViewMessages().empty(); |
| 88 } | 105 } |
| 89 | 106 |
| 90 base::string16 SigninGlobalError::GetBubbleViewTitle() { | 107 base::string16 SigninGlobalError::GetBubbleViewTitle() { |
| 91 return l10n_util::GetStringUTF16(IDS_SIGNIN_ERROR_BUBBLE_VIEW_TITLE); | 108 return l10n_util::GetStringUTF16(IDS_SIGNIN_ERROR_BUBBLE_VIEW_TITLE); |
| 92 } | 109 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 ExecuteMenuItem(browser); | 172 ExecuteMenuItem(browser); |
| 156 } | 173 } |
| 157 | 174 |
| 158 void SigninGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { | 175 void SigninGlobalError::BubbleViewCancelButtonPressed(Browser* browser) { |
| 159 NOTREACHED(); | 176 NOTREACHED(); |
| 160 } | 177 } |
| 161 | 178 |
| 162 void SigninGlobalError::OnErrorChanged() { | 179 void SigninGlobalError::OnErrorChanged() { |
| 163 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(this); | 180 GlobalErrorServiceFactory::GetForProfile(profile_)->NotifyErrorsChanged(this); |
| 164 } | 181 } |
| OLD | NEW |