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 8987645e9ff64c67fcd34912c13d4d77f0016320..5e7c36a3bf1370bafb7e44caa88960482cd8497a 100644 |
--- a/chrome/browser/ui/webui/app_list/start_page_handler.cc |
+++ b/chrome/browser/ui/webui/app_list/start_page_handler.cc |
@@ -36,6 +36,8 @@ namespace app_list { |
namespace { |
+const char kOldHotwordExtensionVersionString[] = "0.1.1.5014_0"; |
+ |
scoped_ptr<base::DictionaryValue> CreateAppInfo( |
const extensions::Extension* app) { |
scoped_ptr<base::DictionaryValue> dict(new base::DictionaryValue); |
@@ -132,11 +134,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 |