Index: chrome/browser/ui/webui/app_list/start_page_handler.cc |
diff --git a/chrome/browser/ui/webui/app_list/start_page_handler.cc b/chrome/browser/ui/webui/app_list/start_page_handler.cc |
index 930b75b2d099d6e2ac7386cb394be20c1cb4df31..604797357880b2729621a8b9ab7a29347ec499ac 100644 |
--- a/chrome/browser/ui/webui/app_list/start_page_handler.cc |
+++ b/chrome/browser/ui/webui/app_list/start_page_handler.cc |
@@ -35,6 +35,10 @@ namespace app_list { |
namespace { |
+#if defined(OS_CHROMEOS) |
+const char kOldHotwordExtensionVersionString[] = "0.1.1.5014_0"; |
+#endif |
+ |
scoped_ptr<base::DictionaryValue> CreateAppInfo( |
const extensions::Extension* app) { |
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
@@ -131,11 +135,25 @@ void StartPageHandler::SendRecommendedApps() { |
#if defined(OS_CHROMEOS) |
void StartPageHandler::OnHotwordEnabledChanged() { |
- StartPageService* service = StartPageService::Get( |
- Profile::FromWebUI(web_ui())); |
- web_ui()->CallJavascriptFunction( |
- "appList.startPage.setHotwordEnabled", |
- base::FundamentalValue(service->HotwordEnabled())); |
+ // If the hotword extension is new enough, we should use the new |
+ // hotwordPrivate API to provide the feature. |
+ // TODO(mukai): remove this after everything gets stable. |
+ Profile* profile = Profile::FromWebUI(web_ui()); |
+ ExtensionService* extension_service = |
+ extensions::ExtensionSystem::Get(profile)->extension_service(); |
+ if (!extension_service) |
+ return; |
+ |
+ const extensions::Extension* hotword_extension = |
+ extension_service->GetExtensionById( |
+ extension_misc::kHotwordExtensionId, false /* include_disabled */); |
+ if (hotword_extension && hotword_extension->version()->CompareTo( |
+ base::Version(kOldHotwordExtensionVersionString)) <= 0) { |
+ StartPageService* service = StartPageService::Get(profile); |
+ web_ui()->CallJavascriptFunction( |
+ "appList.startPage.setHotwordEnabled", |
+ base::FundamentalValue(service->HotwordEnabled())); |
+ } |
} |
#endif |