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

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

Issue 298883006: Rename NOTIFICATION_EXTENSION_INSTALLED to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 6 years, 7 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.h" 5 #include "chrome/browser/search/hotword_service.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/metrics/field_trial.h" 8 #include "base/metrics/field_trial.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/prefs/pref_service.h" 10 #include "base/prefs/pref_service.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 UMA_HISTOGRAM_ENUMERATION("Hotword.Enabled", enabled_state, 155 UMA_HISTOGRAM_ENUMERATION("Hotword.Enabled", enabled_state,
156 NUM_HOTWORD_ENABLED_METRICS); 156 NUM_HOTWORD_ENABLED_METRICS);
157 157
158 pref_registrar_.Init(profile_->GetPrefs()); 158 pref_registrar_.Init(profile_->GetPrefs());
159 pref_registrar_.Add( 159 pref_registrar_.Add(
160 prefs::kHotwordSearchEnabled, 160 prefs::kHotwordSearchEnabled,
161 base::Bind(&HotwordService::OnHotwordSearchEnabledChanged, 161 base::Bind(&HotwordService::OnHotwordSearchEnabledChanged,
162 base::Unretained(this))); 162 base::Unretained(this)));
163 163
164 registrar_.Add(this, 164 registrar_.Add(this,
165 chrome::NOTIFICATION_EXTENSION_INSTALLED, 165 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED,
166 content::Source<Profile>(profile_)); 166 content::Source<Profile>(profile_));
167 167
168 // Clear the old user pref because it became unusable. 168 // Clear the old user pref because it became unusable.
169 // TODO(rlp): Remove this code per crbug.com/358789. 169 // TODO(rlp): Remove this code per crbug.com/358789.
170 if (profile_->GetPrefs()->HasPrefPath( 170 if (profile_->GetPrefs()->HasPrefPath(
171 hotword_internal::kHotwordUnusablePrefName)) { 171 hotword_internal::kHotwordUnusablePrefName)) {
172 profile_->GetPrefs()->ClearPref(hotword_internal::kHotwordUnusablePrefName); 172 profile_->GetPrefs()->ClearPref(hotword_internal::kHotwordUnusablePrefName);
173 } 173 }
174 } 174 }
175 175
176 HotwordService::~HotwordService() { 176 HotwordService::~HotwordService() {
177 } 177 }
178 178
179 void HotwordService::Observe(int type, 179 void HotwordService::Observe(int type,
180 const content::NotificationSource& source, 180 const content::NotificationSource& source,
181 const content::NotificationDetails& details) { 181 const content::NotificationDetails& details) {
182 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED) { 182 if (type == chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED) {
183 const extensions::Extension* extension = 183 const extensions::Extension* extension =
184 content::Details<const extensions::InstalledExtensionInfo>(details) 184 content::Details<const extensions::InstalledExtensionInfo>(details)
185 ->extension; 185 ->extension;
186 // Disabling the extension automatically on install should only occur 186 // Disabling the extension automatically on install should only occur
187 // if the user is in the field trial for auto-install which is gated 187 // if the user is in the field trial for auto-install which is gated
188 // by the IsHotwordAllowed check. 188 // by the IsHotwordAllowed check.
189 if (IsHotwordAllowed() && 189 if (IsHotwordAllowed() &&
190 extension->id() == extension_misc::kHotwordExtensionId && 190 extension->id() == extension_misc::kHotwordExtensionId &&
191 !profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) { 191 !profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) {
192 DisableHotwordExtension(GetExtensionService(profile_)); 192 DisableHotwordExtension(GetExtensionService(profile_));
193 // Once the extension is disabled, it will not be enabled until the 193 // Once the extension is disabled, it will not be enabled until the
194 // user opts in at which point the pref registrar will take over 194 // user opts in at which point the pref registrar will take over
195 // enabling and disabling. 195 // enabling and disabling.
196 registrar_.Remove(this, 196 registrar_.Remove(this,
197 chrome::NOTIFICATION_EXTENSION_INSTALLED, 197 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED,
198 content::Source<Profile>(profile_)); 198 content::Source<Profile>(profile_));
199 } 199 }
200 } 200 }
201 } 201 }
202 202
203 bool HotwordService::ShouldShowOptInPopup() { 203 bool HotwordService::ShouldShowOptInPopup() {
204 if (profile_->IsOffTheRecord()) 204 if (profile_->IsOffTheRecord())
205 return false; 205 return false;
206 206
207 // Profile is not off the record. 207 // Profile is not off the record.
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 311
312 DCHECK(client_ == client); 312 DCHECK(client_ == client);
313 313
314 client_ = NULL; 314 client_ = NULL;
315 HotwordPrivateEventService* event_service = 315 HotwordPrivateEventService* event_service =
316 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_); 316 BrowserContextKeyedAPIFactory<HotwordPrivateEventService>::Get(profile_);
317 if (event_service) 317 if (event_service)
318 event_service->OnHotwordSessionStopped(); 318 event_service->OnHotwordSessionStopped();
319 #endif 319 #endif
320 } 320 }
OLDNEW
« no previous file with comments | « chrome/browser/policy/policy_browsertest.cc ('k') | chrome/browser/sync_file_system/sync_file_system_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698