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

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: fix 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
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..5ee2214be4007d1acfcae151ba4cbf26af4002a6 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,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);
@@ -131,11 +133,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

Powered by Google App Engine
This is Rietveld 408576698