| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/user_style_sheet_watcher_factory.h" | 5 #include "chrome/browser/user_style_sheet_watcher_factory.h" |
| 6 | 6 |
| 7 #include "chrome/browser/profiles/incognito_helpers.h" | 7 #include "chrome/browser/profiles/incognito_helpers.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/user_style_sheet_watcher.h" | 9 #include "chrome/browser/user_style_sheet_watcher.h" |
| 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" | 10 #include "components/browser_context_keyed_service/browser_context_dependency_ma
nager.h" |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 scoped_refptr<UserStyleSheetWatcher> | 13 scoped_refptr<UserStyleSheetWatcher> |
| 14 UserStyleSheetWatcherFactory::GetForProfile( | 14 UserStyleSheetWatcherFactory::GetForProfile( |
| 15 Profile* profile) { | 15 Profile* profile) { |
| 16 return static_cast<UserStyleSheetWatcher*>( | 16 return static_cast<UserStyleSheetWatcher*>( |
| 17 GetInstance()->GetServiceForProfile(profile, true).get()); | 17 GetInstance()->GetServiceForBrowserContext(profile, true).get()); |
| 18 } | 18 } |
| 19 | 19 |
| 20 // static | 20 // static |
| 21 UserStyleSheetWatcherFactory* UserStyleSheetWatcherFactory::GetInstance() { | 21 UserStyleSheetWatcherFactory* UserStyleSheetWatcherFactory::GetInstance() { |
| 22 return Singleton<UserStyleSheetWatcherFactory>::get(); | 22 return Singleton<UserStyleSheetWatcherFactory>::get(); |
| 23 } | 23 } |
| 24 | 24 |
| 25 UserStyleSheetWatcherFactory::UserStyleSheetWatcherFactory() | 25 UserStyleSheetWatcherFactory::UserStyleSheetWatcherFactory() |
| 26 : RefcountedProfileKeyedServiceFactory( | 26 : RefcountedBrowserContextKeyedServiceFactory( |
| 27 "UserStyleSheetWatcher", ProfileDependencyManager::GetInstance()) { | 27 "UserStyleSheetWatcher", BrowserContextDependencyManager::GetInstance(
)) { |
| 28 } | 28 } |
| 29 | 29 |
| 30 UserStyleSheetWatcherFactory::~UserStyleSheetWatcherFactory() { | 30 UserStyleSheetWatcherFactory::~UserStyleSheetWatcherFactory() { |
| 31 } | 31 } |
| 32 | 32 |
| 33 scoped_refptr<RefcountedProfileKeyedService> | 33 scoped_refptr<RefcountedBrowserContextKeyedService> |
| 34 UserStyleSheetWatcherFactory::BuildServiceInstanceFor( | 34 UserStyleSheetWatcherFactory::BuildServiceInstanceFor( |
| 35 content::BrowserContext* context) const { | 35 content::BrowserContext* context) const { |
| 36 Profile* profile = static_cast<Profile*>(context); | 36 Profile* profile = static_cast<Profile*>(context); |
| 37 scoped_refptr<UserStyleSheetWatcher> user_style_sheet_watcher( | 37 scoped_refptr<UserStyleSheetWatcher> user_style_sheet_watcher( |
| 38 new UserStyleSheetWatcher(profile, profile->GetPath())); | 38 new UserStyleSheetWatcher(profile, profile->GetPath())); |
| 39 user_style_sheet_watcher->Init(); | 39 user_style_sheet_watcher->Init(); |
| 40 return user_style_sheet_watcher; | 40 return user_style_sheet_watcher; |
| 41 } | 41 } |
| 42 | 42 |
| 43 content::BrowserContext* UserStyleSheetWatcherFactory::GetBrowserContextToUse( | 43 content::BrowserContext* UserStyleSheetWatcherFactory::GetBrowserContextToUse( |
| 44 content::BrowserContext* context) const { | 44 content::BrowserContext* context) const { |
| 45 return chrome::GetBrowserContextRedirectedInIncognito(context); | 45 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool UserStyleSheetWatcherFactory::ServiceIsNULLWhileTesting() const { | 48 bool UserStyleSheetWatcherFactory::ServiceIsNULLWhileTesting() const { |
| 49 return true; | 49 return true; |
| 50 } | 50 } |
| OLD | NEW |