Chromium Code Reviews| Index: chrome/browser/search/hotword_service.cc |
| diff --git a/chrome/browser/search/hotword_service.cc b/chrome/browser/search/hotword_service.cc |
| index c8bf7052843e9341eb97979ae99b4535468377eb..86912083f9a7cbeff6bf66b3c68da57a80639f75 100644 |
| --- a/chrome/browser/search/hotword_service.cc |
| +++ b/chrome/browser/search/hotword_service.cc |
| @@ -261,8 +261,9 @@ void HotwordService::OnExtensionUninstalled( |
| extensions::UninstallReason reason) { |
| CHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| - if (extension->id() != extension_misc::kHotwordExtensionId || |
| - profile_ != Profile::FromBrowserContext(browser_context) || |
| + if ((extension->id() != extension_misc::kHotwordExtensionId && |
| + extension->id() != extension_misc::kHotwordSharedModuleId) || |
| + profile_ != Profile::FromBrowserContext(browser_context) || |
| !GetExtensionService(profile_)) |
| return; |
| @@ -276,8 +277,13 @@ void HotwordService::OnExtensionUninstalled( |
| } |
| void HotwordService::InstallHotwordExtensionFromWebstore() { |
| + std::string extension_id; |
| + if (IsExperimentalHotwordingEnabled()) |
| + extension_id = extension_misc::kHotwordSharedModuleId; |
| + else |
| + extension_id = extension_misc::kHotwordExtensionId; |
|
rpetterson
2014/10/20 06:31:21
You're repeating this code a lot in here. Helper f
Anand Mistry (off Chromium)
2014/10/20 10:04:49
Done.
|
| installer_ = new extensions::WebstoreStartupInstaller( |
| - extension_misc::kHotwordExtensionId, |
| + extension_id, |
| profile_, |
| false, |
| extensions::WebstoreStandaloneInstaller::Callback()); |
| @@ -289,8 +295,9 @@ void HotwordService::OnExtensionInstalled( |
| const extensions::Extension* extension, |
| bool is_update) { |
| - if (extension->id() != extension_misc::kHotwordExtensionId || |
| - profile_ != Profile::FromBrowserContext(browser_context)) |
| + if ((extension->id() != extension_misc::kHotwordExtensionId && |
| + extension->id() != extension_misc::kHotwordSharedModuleId) || |
| + profile_ != Profile::FromBrowserContext(browser_context)) |
| return; |
| // If the previous locale pref has never been set, set it now since |
| @@ -329,8 +336,13 @@ bool HotwordService::MaybeReinstallHotwordExtension() { |
| if (!extension_service) |
| return false; |
| + std::string extension_id; |
| + if (IsExperimentalHotwordingEnabled()) |
| + extension_id = extension_misc::kHotwordSharedModuleId; |
| + else |
| + extension_id = extension_misc::kHotwordExtensionId; |
| const extensions::Extension* extension = extension_service->GetExtensionById( |
| - extension_misc::kHotwordExtensionId, true); |
| + extension_id, true); |
| if (!extension) |
| return false; |
| @@ -361,13 +373,18 @@ bool HotwordService::MaybeReinstallHotwordExtension() { |
| bool HotwordService::UninstallHotwordExtension( |
| ExtensionService* extension_service) { |
| base::string16 error; |
| + std::string extension_id; |
| + if (IsExperimentalHotwordingEnabled()) |
| + extension_id = extension_misc::kHotwordSharedModuleId; |
| + else |
| + extension_id = extension_misc::kHotwordExtensionId; |
| if (!extension_service->UninstallExtension( |
| - extension_misc::kHotwordExtensionId, |
| + extension_id, |
| extensions::UNINSTALL_REASON_INTERNAL_MANAGEMENT, |
| base::Bind(&base::DoNothing), |
| &error)) { |
| LOG(WARNING) << "Cannot uninstall extension with id " |
| - << extension_misc::kHotwordExtensionId |
| + << extension_id |
| << ": " << error; |
| reinstall_pending_ = false; |
| return false; |
| @@ -386,8 +403,6 @@ bool HotwordService::IsServiceAvailable() { |
| // if the user opted out. |
| std::string extensionId; |
| if (IsExperimentalHotwordingEnabled()) { |
| - // TODO(amistry): Handle reloading on language change as the old extension |
| - // does. |
| extensionId = extension_misc::kHotwordSharedModuleId; |
| } else { |
| extensionId = extension_misc::kHotwordExtensionId; |