Index: chrome/browser/search/hotword_service.cc |
diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc |
index 3b80c186016f10bee5277be7af797c62ab861a58..6edd8acea21d35ec44a365a8fc64bed6b7f59e5d 100644 |
--- a/chrome/browser/search/hotword_service.cc |
+++ b/chrome/browser/search/hotword_service.cc |
@@ -136,11 +136,8 @@ void RecordExtensionAvailabilityMetrics( |
availability_state = AVAILABLE; |
} else if (service->pending_extension_manager() && |
service->pending_extension_manager()->IsIdPending( |
- extension_misc::kHotwordExtensionId)) { |
+ extension_misc::kHotwordSharedModuleId)) { |
kcarattini
2015/03/17 00:41:13
If you are changing the meaning of the stat, I thi
Anand Mistry (off Chromium)
2015/03/17 03:00:46
Hmm. I don't think we should be changing the meani
|
availability_state = PENDING_DOWNLOAD; |
- } else if (!service->IsExtensionEnabled( |
- extension_misc::kHotwordExtensionId)) { |
- availability_state = DISABLED_EXTENSION; |
} |
UMA_HISTOGRAM_ENUMERATION("Hotword.HotwordExtensionAvailability", |
availability_state, |
@@ -185,8 +182,7 @@ void RecordHotwordEnabledMetric(HotwordService *service, Profile* profile) { |
if (!prefs->HasPrefPath(prefs::kHotwordSearchEnabled) && |
!prefs->HasPrefPath(prefs::kHotwordAlwaysOnSearchEnabled)) { |
enabled_state = UNSET; |
- } else if (service->IsExperimentalHotwordingEnabled() && |
- service->IsAlwaysOnEnabled()) { |
+ } else if (service->IsAlwaysOnEnabled()) { |
enabled_state = ALWAYS_ON_ENABLED; |
} else if (prefs->GetBoolean(prefs::kHotwordSearchEnabled)) { |
enabled_state = ENABLED; |
@@ -293,11 +289,6 @@ bool HotwordService::DoesHotwordSupportLanguage(Profile* profile) { |
return false; |
} |
-// static |
-bool HotwordService::IsExperimentalHotwordingEnabled() { |
- return true; |
-} |
- |
#if defined(OS_CHROMEOS) |
class HotwordService::HotwordUserSessionStateObserver |
: public user_manager::UserManager::UserSessionStateObserver { |
@@ -332,28 +323,21 @@ HotwordService::HotwordService(Profile* profile) |
training_(false), |
weak_factory_(this) { |
extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile)); |
- if (IsExperimentalHotwordingEnabled()) { |
- // Disable the old extension so it doesn't interfere with the new stuff. |
- DisableHotwordExtension(GetExtensionService(profile_)); |
- } else { |
- if (!profile_->GetPrefs()->HasPrefPath(prefs::kHotwordSearchEnabled) && |
- IsHotwordAllowed()) { |
- // If the preference has not been set the hotword extension should |
- // not be running. However, this should only be done if auto-install |
- // is enabled which is gated through the IsHotwordAllowed check. |
- DisableHotwordExtension(GetExtensionService(profile_)); |
- } |
+ |
+ // Disable the old extension so it doesn't interfere with the new stuff. |
kcarattini
2015/03/17 00:41:13
Do we need to disable the hotword helper here as w
Anand Mistry (off Chromium)
2015/03/17 03:00:46
hotword_helper is a component that's being deleted
|
+ ExtensionService* extension_service = GetExtensionService(profile_); |
+ if (extension_service) { |
+ extension_service->DisableExtension( |
+ extension_misc::kHotwordOldExtensionId, |
+ extensions::Extension::DISABLE_USER_ACTION); |
} |
+ |
// This will be called during profile initialization which is a good time |
// to check the user's hotword state. |
RecordHotwordEnabledMetric(this, profile_); |
pref_registrar_.Init(profile_->GetPrefs()); |
pref_registrar_.Add( |
- prefs::kHotwordSearchEnabled, |
- base::Bind(&HotwordService::OnHotwordSearchEnabledChanged, |
- base::Unretained(this))); |
- pref_registrar_.Add( |
prefs::kHotwordAlwaysOnSearchEnabled, |
base::Bind(&HotwordService::OnHotwordAlwaysOnSearchEnabledChanged, |
base::Unretained(this))); |
@@ -375,8 +359,7 @@ HotwordService::HotwordService(Profile* profile) |
profile_, base::MessageLoop::current()->task_runner())); |
if (HotwordServiceFactory::IsAlwaysOnAvailable() && |
- IsHotwordAllowed() && |
- IsExperimentalHotwordingEnabled()) { |
+ IsHotwordAllowed()) { |
// Show the hotword notification in 5 seconds if the experimental flag is |
// on, or in 30 minutes if not. We need to wait at least a few seconds |
// for the hotword extension to be installed. |
@@ -456,9 +439,8 @@ void HotwordService::OnExtensionUninstalled( |
extensions::UninstallReason reason) { |
CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
- if ((extension->id() != extension_misc::kHotwordExtensionId && |
- extension->id() != extension_misc::kHotwordSharedModuleId) || |
- profile_ != Profile::FromBrowserContext(browser_context) || |
+ if (extension->id() != extension_misc::kHotwordSharedModuleId || |
+ profile_ != Profile::FromBrowserContext(browser_context) || |
!GetExtensionService(profile_)) |
return; |
@@ -472,10 +454,7 @@ void HotwordService::OnExtensionUninstalled( |
} |
std::string HotwordService::ReinstalledExtensionId() { |
- if (IsExperimentalHotwordingEnabled()) |
- return extension_misc::kHotwordSharedModuleId; |
- |
- return extension_misc::kHotwordExtensionId; |
+ return extension_misc::kHotwordSharedModuleId; |
} |
void HotwordService::InstalledFromWebstoreCallback( |
@@ -510,9 +489,8 @@ void HotwordService::OnExtensionInstalled( |
const extensions::Extension* extension, |
bool is_update) { |
- if ((extension->id() != extension_misc::kHotwordExtensionId && |
- extension->id() != extension_misc::kHotwordSharedModuleId) || |
- profile_ != Profile::FromBrowserContext(browser_context)) |
+ if (extension->id() != extension_misc::kHotwordSharedModuleId || |
+ profile_ != Profile::FromBrowserContext(browser_context)) |
return; |
// If the previous locale pref has never been set, set it now since |
@@ -529,17 +507,6 @@ void HotwordService::OnExtensionInstalled( |
MaybeReinstallHotwordExtension(); |
else |
reinstall_pending_ = false; |
- |
- // Now that the extension is installed, if the user has not selected |
- // the preference on, make sure it is turned off. |
- // |
- // Disabling the extension automatically on install should only occur |
- // if the user is in the field trial for auto-install which is gated |
- // by the IsHotwordAllowed check. The check for IsHotwordAllowed() here |
- // can be removed once it's known that few people have manually |
- // installed extension. |
- if (IsHotwordAllowed() && !IsSometimesOnEnabled()) |
- DisableHotwordExtension(GetExtensionService(profile_)); |
} |
bool HotwordService::MaybeReinstallHotwordExtension() { |
@@ -689,21 +656,6 @@ bool HotwordService::IsSometimesOnEnabled() { |
!HotwordServiceFactory::IsAlwaysOnAvailable(); |
} |
-void HotwordService::EnableHotwordExtension( |
- ExtensionService* extension_service) { |
- if (extension_service && !IsExperimentalHotwordingEnabled()) |
- extension_service->EnableExtension(extension_misc::kHotwordExtensionId); |
-} |
- |
-void HotwordService::DisableHotwordExtension( |
- ExtensionService* extension_service) { |
- if (extension_service) { |
- extension_service->DisableExtension( |
- extension_misc::kHotwordExtensionId, |
- extensions::Extension::DISABLE_USER_ACTION); |
- } |
-} |
- |
void HotwordService::LaunchHotwordAudioVerificationApp( |
const LaunchMode& launch_mode) { |
hotword_audio_verification_launch_mode_ = launch_mode; |
@@ -797,17 +749,6 @@ void HotwordService::DisableHotwordPreferences() { |
} |
} |
-void HotwordService::OnHotwordSearchEnabledChanged( |
- const std::string& pref_name) { |
- DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); |
- |
- ExtensionService* extension_service = GetExtensionService(profile_); |
- if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordSearchEnabled)) |
- EnableHotwordExtension(extension_service); |
- else |
- DisableHotwordExtension(extension_service); |
-} |
- |
void HotwordService::OnHotwordAlwaysOnSearchEnabledChanged( |
const std::string& pref_name) { |
// If the pref for always on has been changed in some way, that means that |
@@ -867,10 +808,6 @@ bool HotwordService::ShouldReinstallHotwordExtension() { |
} |
void HotwordService::ActiveUserChanged() { |
- // Do nothing for old hotwording. |
- if (!IsExperimentalHotwordingEnabled()) |
- return; |
- |
// Don't bother notifying the extension if hotwording is completely off. |
if (!IsSometimesOnEnabled() && !IsAlwaysOnEnabled() && !IsTraining()) |
return; |