| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_error_notifier_ash.h" | 5 #include "chrome/browser/signin/signin_error_notifier_ash.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
| 9 #include "ash/system/system_notifier.h" | 9 #include "ash/system/system_notifier.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 virtual bool HasClickedListener() OVERRIDE; | 55 virtual bool HasClickedListener() OVERRIDE; |
| 56 virtual void Click() OVERRIDE; | 56 virtual void Click() OVERRIDE; |
| 57 virtual void ButtonClick(int button_index) OVERRIDE; | 57 virtual void ButtonClick(int button_index) OVERRIDE; |
| 58 virtual std::string id() const OVERRIDE; | 58 virtual std::string id() const OVERRIDE; |
| 59 virtual content::WebContents* GetWebContents() const OVERRIDE; | 59 virtual content::WebContents* GetWebContents() const OVERRIDE; |
| 60 | 60 |
| 61 protected: | 61 protected: |
| 62 virtual ~SigninNotificationDelegate(); | 62 virtual ~SigninNotificationDelegate(); |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 void FixSignIn(); |
| 66 |
| 65 // Unique id of the notification. | 67 // Unique id of the notification. |
| 66 const std::string id_; | 68 const std::string id_; |
| 67 | 69 |
| 68 Profile* profile_; | 70 Profile* profile_; |
| 69 | 71 |
| 70 DISALLOW_COPY_AND_ASSIGN(SigninNotificationDelegate); | 72 DISALLOW_COPY_AND_ASSIGN(SigninNotificationDelegate); |
| 71 }; | 73 }; |
| 72 | 74 |
| 73 SigninNotificationDelegate::SigninNotificationDelegate( | 75 SigninNotificationDelegate::SigninNotificationDelegate( |
| 74 const std::string& id, | 76 const std::string& id, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 87 } | 89 } |
| 88 | 90 |
| 89 void SigninNotificationDelegate::Close(bool by_user) { | 91 void SigninNotificationDelegate::Close(bool by_user) { |
| 90 } | 92 } |
| 91 | 93 |
| 92 bool SigninNotificationDelegate::HasClickedListener() { | 94 bool SigninNotificationDelegate::HasClickedListener() { |
| 93 return false; | 95 return false; |
| 94 } | 96 } |
| 95 | 97 |
| 96 void SigninNotificationDelegate::Click() { | 98 void SigninNotificationDelegate::Click() { |
| 99 FixSignIn(); |
| 97 } | 100 } |
| 98 | 101 |
| 99 void SigninNotificationDelegate::ButtonClick(int button_index) { | 102 void SigninNotificationDelegate::ButtonClick(int button_index) { |
| 103 FixSignIn(); |
| 104 } |
| 105 |
| 106 std::string SigninNotificationDelegate::id() const { |
| 107 return id_; |
| 108 } |
| 109 |
| 110 content::WebContents* SigninNotificationDelegate::GetWebContents() const { |
| 111 return NULL; |
| 112 } |
| 113 |
| 114 void SigninNotificationDelegate::FixSignIn() { |
| 100 #if defined(OS_CHROMEOS) | 115 #if defined(OS_CHROMEOS) |
| 101 chrome::AttemptUserExit(); | 116 chrome::AttemptUserExit(); |
| 102 #else | 117 #else |
| 103 LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_); | 118 LoginUIService* login_ui = LoginUIServiceFactory::GetForProfile(profile_); |
| 104 if (login_ui->current_login_ui()) { | 119 if (login_ui->current_login_ui()) { |
| 105 login_ui->current_login_ui()->FocusUI(); | 120 login_ui->current_login_ui()->FocusUI(); |
| 106 return; | 121 return; |
| 107 } | 122 } |
| 108 | 123 |
| 109 // Find a browser instance or create one. | 124 // Find a browser instance or create one. |
| 110 chrome::ScopedTabbedBrowserDisplayer browser_displayer( | 125 chrome::ScopedTabbedBrowserDisplayer browser_displayer( |
| 111 profile_, chrome::HOST_DESKTOP_TYPE_ASH); | 126 profile_, chrome::HOST_DESKTOP_TYPE_ASH); |
| 112 | 127 |
| 113 // Navigate to the sync setup subpage, which will launch a login page. | 128 // Navigate to the sync setup subpage, which will launch a login page. |
| 114 chrome::ShowSettingsSubPage(browser_displayer.browser(), | 129 chrome::ShowSettingsSubPage(browser_displayer.browser(), |
| 115 chrome::kSyncSetupSubPage); | 130 chrome::kSyncSetupSubPage); |
| 116 #endif | 131 #endif |
| 117 } | 132 } |
| 118 | 133 |
| 119 std::string SigninNotificationDelegate::id() const { | |
| 120 return id_; | |
| 121 } | |
| 122 | |
| 123 content::WebContents* SigninNotificationDelegate::GetWebContents() const { | |
| 124 return NULL; | |
| 125 } | |
| 126 | |
| 127 } // namespace | 134 } // namespace |
| 128 | 135 |
| 129 SigninErrorNotifier::SigninErrorNotifier(SigninErrorController* controller, | 136 SigninErrorNotifier::SigninErrorNotifier(SigninErrorController* controller, |
| 130 Profile* profile) | 137 Profile* profile) |
| 131 : error_controller_(controller), | 138 : error_controller_(controller), |
| 132 profile_(profile) { | 139 profile_(profile) { |
| 133 // Create a unique notification ID for this profile. | 140 // Create a unique notification ID for this profile. |
| 134 notification_id_ = kProfileSigninNotificationId + profile->GetProfileName(); | 141 notification_id_ = kProfileSigninNotificationId + profile->GetProfileName(); |
| 135 | 142 |
| 136 error_controller_->AddObserver(this); | 143 error_controller_->AddObserver(this); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 return l10n_util::GetStringUTF16( | 235 return l10n_util::GetStringUTF16( |
| 229 IDS_SYNC_UNAVAILABLE_ERROR_BUBBLE_VIEW_MESSAGE); | 236 IDS_SYNC_UNAVAILABLE_ERROR_BUBBLE_VIEW_MESSAGE); |
| 230 break; | 237 break; |
| 231 | 238 |
| 232 // Generic message for "other" errors. | 239 // Generic message for "other" errors. |
| 233 default: | 240 default: |
| 234 return l10n_util::GetStringUTF16( | 241 return l10n_util::GetStringUTF16( |
| 235 IDS_SYNC_OTHER_SIGN_IN_ERROR_BUBBLE_VIEW_MESSAGE); | 242 IDS_SYNC_OTHER_SIGN_IN_ERROR_BUBBLE_VIEW_MESSAGE); |
| 236 } | 243 } |
| 237 } | 244 } |
| OLD | NEW |