OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/invalidation/profile_invalidation_auth_provider.h" |
| 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/signin/profile_oauth2_token_service.h" |
| 10 #include "chrome/browser/signin/signin_manager.h" |
| 11 #include "chrome/browser/ui/webui/signin/login_ui_service.h" |
| 12 #include "content/public/browser/notification_service.h" |
| 13 |
| 14 namespace invalidation { |
| 15 |
| 16 ProfileInvalidationAuthProvider::ProfileInvalidationAuthProvider( |
| 17 SigninManagerBase* signin_manager, |
| 18 ProfileOAuth2TokenService* token_service, |
| 19 LoginUIService* login_ui_service, |
| 20 Profile* profile) |
| 21 : signin_manager_(signin_manager), |
| 22 token_service_(token_service), |
| 23 login_ui_service_(login_ui_service), |
| 24 profile_(profile) { |
| 25 notification_registrar_.Add(this, |
| 26 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, |
| 27 content::Source<Profile>(profile_)); |
| 28 } |
| 29 |
| 30 ProfileInvalidationAuthProvider:: |
| 31 ~ProfileInvalidationAuthProvider() { |
| 32 notification_registrar_.RemoveAll(); |
| 33 } |
| 34 |
| 35 std::string ProfileInvalidationAuthProvider::GetAccountId() { |
| 36 return signin_manager_->GetAuthenticatedUsername(); |
| 37 } |
| 38 |
| 39 OAuth2TokenService* ProfileInvalidationAuthProvider::GetTokenService() { |
| 40 return token_service_; |
| 41 } |
| 42 |
| 43 bool ProfileInvalidationAuthProvider::ShowLoginUI() { |
| 44 login_ui_service_->ShowLoginPopup(); |
| 45 return true; |
| 46 } |
| 47 |
| 48 void ProfileInvalidationAuthProvider::Observe( |
| 49 int type, |
| 50 const content::NotificationSource& source, |
| 51 const content::NotificationDetails& details) { |
| 52 DCHECK_EQ(type, chrome::NOTIFICATION_GOOGLE_SIGNED_OUT); |
| 53 FireInvalidationAuthLogout(); |
| 54 } |
| 55 |
| 56 } // namespace invalidation |
OLD | NEW |