| 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/extensions/token_cache/token_cache_service.h" | 5 #include "chrome/browser/extensions/token_cache/token_cache_service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/signin/signin_manager.h" |
| 9 #include "content/public/browser/notification_source.h" | 9 #include "chrome/browser/signin/signin_manager_factory.h" |
| 10 | 10 |
| 11 using base::Time; | 11 using base::Time; |
| 12 using base::TimeDelta; | 12 using base::TimeDelta; |
| 13 | 13 |
| 14 namespace extensions { | 14 namespace extensions { |
| 15 | 15 |
| 16 TokenCacheService::TokenCacheService(Profile* profile) : profile_(profile) { | 16 TokenCacheService::TokenCacheService(Profile* profile) : profile_(profile) { |
| 17 registrar_.Add(this, | 17 SigninManagerFactory::GetForProfile(profile)->AddObserver(this); |
| 18 chrome::NOTIFICATION_GOOGLE_SIGNED_OUT, | |
| 19 content::Source<Profile>(profile_)); | |
| 20 } | 18 } |
| 21 | 19 |
| 22 TokenCacheService::~TokenCacheService() { | 20 TokenCacheService::~TokenCacheService() { |
| 23 } | 21 } |
| 24 | 22 |
| 25 void TokenCacheService::StoreToken(const std::string& token_name, | 23 void TokenCacheService::StoreToken(const std::string& token_name, |
| 26 const std::string& token_value, | 24 const std::string& token_value, |
| 27 base::TimeDelta time_to_live) { | 25 base::TimeDelta time_to_live) { |
| 28 TokenCacheData token_data; | 26 TokenCacheData token_data; |
| 29 | 27 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 60 } else { | 58 } else { |
| 61 // Remove this entry if it is expired. | 59 // Remove this entry if it is expired. |
| 62 token_cache_.erase(it); | 60 token_cache_.erase(it); |
| 63 return std::string(); | 61 return std::string(); |
| 64 } | 62 } |
| 65 } | 63 } |
| 66 | 64 |
| 67 return std::string(); | 65 return std::string(); |
| 68 } | 66 } |
| 69 | 67 |
| 70 // Inherited from NotificationObserver. | 68 void TokenCacheService::Shutdown() { |
| 71 void TokenCacheService::Observe(int type, | 69 SigninManagerFactory::GetForProfile(const_cast<Profile*>(profile_)) |
| 72 const content::NotificationSource& source, | 70 ->RemoveObserver(this); |
| 73 const content::NotificationDetails& details) { | 71 } |
| 74 DCHECK(chrome::NOTIFICATION_GOOGLE_SIGNED_OUT == type); | 72 |
| 73 void TokenCacheService::GoogleSignedOut(const std::string& username) { |
| 75 token_cache_.clear(); | 74 token_cache_.clear(); |
| 76 } | 75 } |
| 77 | 76 |
| 78 } // namespace extensions | 77 } // namespace extensions |
| OLD | NEW |