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