Make castv2 performance test work.
[chromium-blink-merge.git] / chrome / browser / google / google_url_tracker_factory.cc
blob1ba3e69666d75ad0dd30885b54a8e6d711494f28
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.
5 #include "chrome/browser/google/google_url_tracker_factory.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/google/chrome_google_url_tracker_client.h"
9 #include "chrome/browser/profiles/incognito_helpers.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "components/google/core/browser/google_pref_names.h"
12 #include "components/google/core/browser/google_url_tracker.h"
13 #include "components/keyed_service/content/browser_context_dependency_manager.h"
14 #include "components/pref_registry/pref_registry_syncable.h"
16 namespace {
18 const char kLastPromptedGoogleURL[] = "browser.last_prompted_google_url";
20 } // namespace
23 // static
24 GoogleURLTracker* GoogleURLTrackerFactory::GetForProfile(Profile* profile) {
25 return static_cast<GoogleURLTracker*>(
26 GetInstance()->GetServiceForBrowserContext(profile, true));
29 // static
30 GoogleURLTrackerFactory* GoogleURLTrackerFactory::GetInstance() {
31 return Singleton<GoogleURLTrackerFactory>::get();
34 GoogleURLTrackerFactory::GoogleURLTrackerFactory()
35 : BrowserContextKeyedServiceFactory(
36 "GoogleURLTracker",
37 BrowserContextDependencyManager::GetInstance()) {
40 GoogleURLTrackerFactory::~GoogleURLTrackerFactory() {
43 KeyedService* GoogleURLTrackerFactory::BuildServiceInstanceFor(
44 content::BrowserContext* context) const {
45 // Delete this now-unused pref.
46 // At some point in the future, this code can be removed entirely.
47 static_cast<Profile*>(context)->GetOriginalProfile()->GetPrefs()->ClearPref(
48 kLastPromptedGoogleURL);
50 scoped_ptr<GoogleURLTrackerClient> client(
51 new ChromeGoogleURLTrackerClient(Profile::FromBrowserContext(context)));
52 return new GoogleURLTracker(client.Pass(), GoogleURLTracker::NORMAL_MODE);
55 void GoogleURLTrackerFactory::RegisterProfilePrefs(
56 user_prefs::PrefRegistrySyncable* user_prefs) {
57 user_prefs->RegisterStringPref(
58 prefs::kLastKnownGoogleURL,
59 GoogleURLTracker::kDefaultGoogleHomepage,
60 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
61 user_prefs->RegisterStringPref(
62 kLastPromptedGoogleURL,
63 std::string(),
64 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
67 content::BrowserContext* GoogleURLTrackerFactory::GetBrowserContextToUse(
68 content::BrowserContext* context) const {
69 return chrome::GetBrowserContextRedirectedInIncognito(context);
72 bool GoogleURLTrackerFactory::ServiceIsCreatedWithBrowserContext() const {
73 return true;
76 bool GoogleURLTrackerFactory::ServiceIsNULLWhileTesting() const {
77 return true;