Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(411)

Side by Side Diff: chrome/browser/search/hotword_service_factory.cc

Issue 136693013: [Hotword] Remove unneeded preferences. Cleaning up look of settings. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: adding missing overlay files Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 ||
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
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698