Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/search/hotword_service_factory.h" | 5 #include "chrome/browser/search/hotword_service_factory.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/search/hotword_service.h" | 10 #include "chrome/browser/search/hotword_service.h" |
| 11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
| 12 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" | 12 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" |
| 13 #include "components/user_prefs/pref_registry_syncable.h" | 13 #include "components/user_prefs/pref_registry_syncable.h" |
| 14 | 14 |
| 15 // static | 15 // static |
| 16 HotwordService* HotwordServiceFactory::GetForProfile(Profile* profile) { | 16 HotwordService* HotwordServiceFactory::GetForProfile(Profile* profile) { |
| 17 if (!profile || | 17 if (!profile || profile->IsOffTheRecord() || |
|
James Hawkins
2014/01/24 22:50:49
Is this right? It seems like the IsOffTheRecord s
rpetterson
2014/01/25 00:29:22
Technically speaking GetServiceForBrowserContext s
James Hawkins
2014/01/27 18:14:37
Yeah, I think it may be safer to let GetServiceFor
samarth
2014/01/27 18:24:53
Just so I understand correctly, this change is int
rpetterson
2014/01/27 19:28:13
I've pulled out this check.
And yes, this change
samarth
2014/01/27 19:50:16
Oh, that's different from what I thought.
I thoug
| |
| 18 (profile->GetPrefs()->HasPrefPath(prefs::kHotwordSearchEnabled) && | 18 (profile->GetPrefs()->HasPrefPath(prefs::kHotwordSearchEnabled) && |
| 19 !profile->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) || | 19 !profile->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled))) |
| 20 (profile->IsOffTheRecord() && | |
| 21 !profile->GetPrefs()->GetBoolean(prefs::kHotwordSearchIncognitoEnabled))) | |
| 22 return NULL; | 20 return NULL; |
| 23 | 21 |
| 24 return static_cast<HotwordService*>( | 22 return static_cast<HotwordService*>( |
| 25 GetInstance()->GetServiceForBrowserContext(profile, true)); | 23 GetInstance()->GetServiceForBrowserContext(profile, true)); |
| 26 } | 24 } |
| 27 | 25 |
| 28 // static | 26 // static |
| 29 HotwordServiceFactory* HotwordServiceFactory::GetInstance() { | 27 HotwordServiceFactory* HotwordServiceFactory::GetInstance() { |
| 30 return Singleton<HotwordServiceFactory>::get(); | 28 return Singleton<HotwordServiceFactory>::get(); |
| 31 } | 29 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 44 } | 42 } |
| 45 | 43 |
| 46 HotwordServiceFactory::~HotwordServiceFactory() { | 44 HotwordServiceFactory::~HotwordServiceFactory() { |
| 47 } | 45 } |
| 48 | 46 |
| 49 void HotwordServiceFactory::RegisterProfilePrefs( | 47 void HotwordServiceFactory::RegisterProfilePrefs( |
| 50 user_prefs::PrefRegistrySyncable* prefs) { | 48 user_prefs::PrefRegistrySyncable* prefs) { |
| 51 prefs->RegisterBooleanPref(prefs::kHotwordSearchEnabled, | 49 prefs->RegisterBooleanPref(prefs::kHotwordSearchEnabled, |
| 52 false, | 50 false, |
| 53 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 51 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 54 prefs->RegisterBooleanPref(prefs::kHotwordSearchIncognitoEnabled, | |
| 55 false, | |
| 56 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 57 prefs->RegisterIntegerPref(prefs::kHotwordOptInPopupTimesShown, | 52 prefs->RegisterIntegerPref(prefs::kHotwordOptInPopupTimesShown, |
| 58 0, | 53 0, |
| 59 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 54 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 60 prefs->RegisterBooleanPref(prefs::kHotwordSearchTimeoutEnabled, | |
| 61 true, | |
| 62 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | |
| 63 } | |
| 64 | |
| 65 content::BrowserContext* HotwordServiceFactory::GetBrowserContextToUse( | |
| 66 content::BrowserContext* context) const { | |
| 67 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | |
| 68 } | 55 } |
| 69 | 56 |
| 70 BrowserContextKeyedService* HotwordServiceFactory::BuildServiceInstanceFor( | 57 BrowserContextKeyedService* HotwordServiceFactory::BuildServiceInstanceFor( |
| 71 content::BrowserContext* profile) const { | 58 content::BrowserContext* profile) const { |
| 72 return new HotwordService(static_cast<Profile*>(profile)); | 59 return new HotwordService(static_cast<Profile*>(profile)); |
| 73 } | 60 } |
| OLD | NEW |