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

Unified Diff: chrome/browser/ui/webui/app_list/start_page_handler.cc

Issue 267653005: Adds HotwordPrivate API for integrating the hotword feature to AppLauncher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698