OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 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/feature_engagement_tracker/feature_engagement_tracker_f
actory.h" |
| 6 |
| 7 #include "base/files/file_path.h" |
| 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/singleton.h" |
| 10 #include "base/sequenced_task_runner.h" |
| 11 #include "base/threading/sequenced_worker_pool.h" |
| 12 #include "chrome/browser/profiles/incognito_helpers.h" |
| 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/common/chrome_constants.h" |
| 15 #include "components/feature_engagement_tracker/public/feature_engagement_tracke
r.h" |
| 16 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 17 #include "content/public/browser/browser_context.h" |
| 18 #include "content/public/browser/browser_thread.h" |
| 19 |
| 20 // static |
| 21 FeatureEngagementTrackerFactory* |
| 22 FeatureEngagementTrackerFactory::GetInstance() { |
| 23 return base::Singleton<FeatureEngagementTrackerFactory>::get(); |
| 24 } |
| 25 |
| 26 // static |
| 27 feature_engagement_tracker::FeatureEngagementTracker* |
| 28 FeatureEngagementTrackerFactory::GetForBrowserContext( |
| 29 content::BrowserContext* context) { |
| 30 return static_cast<feature_engagement_tracker::FeatureEngagementTracker*>( |
| 31 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 32 } |
| 33 |
| 34 FeatureEngagementTrackerFactory::FeatureEngagementTrackerFactory() |
| 35 : BrowserContextKeyedServiceFactory( |
| 36 "feature_engagement_tracker::FeatureEngagementTracker", |
| 37 BrowserContextDependencyManager::GetInstance()) {} |
| 38 |
| 39 FeatureEngagementTrackerFactory::~FeatureEngagementTrackerFactory() = default; |
| 40 |
| 41 KeyedService* FeatureEngagementTrackerFactory::BuildServiceInstanceFor( |
| 42 content::BrowserContext* context) const { |
| 43 Profile* profile = Profile::FromBrowserContext(context); |
| 44 |
| 45 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
| 46 content::BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
| 47 content::BrowserThread::GetBlockingPool()->GetSequenceToken()); |
| 48 |
| 49 base::FilePath storage_dir = profile->GetPath().Append( |
| 50 chrome::kFeatureEngagementTrackerStorageDirname); |
| 51 |
| 52 return feature_engagement_tracker::FeatureEngagementTracker::Create( |
| 53 storage_dir, background_task_runner); |
| 54 } |
| 55 |
| 56 content::BrowserContext* |
| 57 FeatureEngagementTrackerFactory::GetBrowserContextToUse( |
| 58 content::BrowserContext* context) const { |
| 59 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 60 } |
OLD | NEW |