From 535980d49413e42f0f9a3deb8e6e3e13a59b61d7 Mon Sep 17 00:00:00 2001 From: "amistry@chromium.org" Date: Tue, 12 Aug 2014 14:31:28 +0000 Subject: [PATCH] Add new hotword extension for built-in hotword triggering. This is just a skeleton of the extension and doesn't have any functionality. Can't use the existing hotword_helper since this has a hard dependency on a shared module (which doesn't yet exist). BUG=397019 Review URL: https://codereview.chromium.org/423083002 Cr-Commit-Position: refs/heads/master@{#288956} git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288956 0039d316-1c4b-4281-b951-d872f2087c98 --- WATCHLISTS | 1 + chrome/browser/browser_resources.grd | 1 + chrome/browser/extensions/component_loader.cc | 10 ++++- .../extensions/external_component_loader.cc | 19 ++++++++-- .../component_extension_resources.grd | 5 ++- chrome/browser/resources/hotword/manager.js | 15 ++++++++ .../browser/resources/hotword/manifest.json | 38 +++++++++++++++++++ 7 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 chrome/browser/resources/hotword/manager.js create mode 100644 chrome/browser/resources/hotword/manifest.json diff --git a/WATCHLISTS b/WATCHLISTS index a954f01c9bf5..22a7d55d36f6 100644 --- a/WATCHLISTS +++ b/WATCHLISTS @@ -358,6 +358,7 @@ 'hotword': { 'filepath': 'chrome/browser/extensions/api/hotword_private/'\ '|chrome/browser/resources/hotword_helper/'\ + '|chrome/browser/resources/hotword/'\ '|chrome/browser/search/hotword*'\ '|chrome/test/data/extensions/api_test/hotword_private/', }, diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd index bda10aa00788..695025370e1b 100644 --- a/chrome/browser/browser_resources.grd +++ b/chrome/browser/browser_resources.grd @@ -155,6 +155,7 @@ + diff --git a/chrome/browser/extensions/component_loader.cc b/chrome/browser/extensions/component_loader.cc index fb8adeb80143..c29cad3e2174 100644 --- a/chrome/browser/extensions/component_loader.cc +++ b/chrome/browser/extensions/component_loader.cc @@ -304,8 +304,14 @@ void ComponentLoader::AddHangoutServicesExtension() { void ComponentLoader::AddHotwordHelperExtension() { if (HotwordServiceFactory::IsHotwordAllowed(browser_context_)) { - Add(IDR_HOTWORD_HELPER_MANIFEST, - base::FilePath(FILE_PATH_LITERAL("hotword_helper"))); + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kEnableExperimentalHotwording)) { + Add(IDR_HOTWORD_MANIFEST, + base::FilePath(FILE_PATH_LITERAL("hotword"))); + } else { + Add(IDR_HOTWORD_HELPER_MANIFEST, + base::FilePath(FILE_PATH_LITERAL("hotword_helper"))); + } } } diff --git a/chrome/browser/extensions/external_component_loader.cc b/chrome/browser/extensions/external_component_loader.cc index 10eb0ec145c2..7b66afe41c43 100644 --- a/chrome/browser/extensions/external_component_loader.cc +++ b/chrome/browser/extensions/external_component_loader.cc @@ -4,13 +4,19 @@ #include "chrome/browser/extensions/external_component_loader.h" +#include "base/command_line.h" #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" #include "chrome/browser/browser_process.h" -#include "chrome/browser/search/hotword_service_factory.h" #include "chrome/browser/signin/signin_manager_factory.h" +#include "chrome/common/chrome_switches.h" #include "chrome/common/extensions/extension_constants.h" #include "components/signin/core/browser/signin_manager.h" +// TODO(thestig): Remove after extensions are disabled on mobile. +#if defined(ENABLE_EXTENSIONS) +#include "chrome/browser/search/hotword_service_factory.h" +#endif + namespace { bool IsUserSignedin(Profile* profile) { @@ -34,11 +40,18 @@ void ExternalComponentLoader::StartLoading() { prefs_->SetString(appId + ".external_update_url", extension_urls::GetWebstoreUpdateUrl().spec()); +#if defined(ENABLE_EXTENSIONS) if (HotwordServiceFactory::IsHotwordAllowed(profile_)) { std::string hotwordId = extension_misc::kHotwordExtensionId; - prefs_->SetString(hotwordId + ".external_update_url", - extension_urls::GetWebstoreUpdateUrl().spec()); + CommandLine* command_line = CommandLine::ForCurrentProcess(); + // TODO(amistry): Load the hotword shared module when enabling built-in + // hotword detection. + if (!command_line->HasSwitch(switches::kEnableExperimentalHotwording)) { + prefs_->SetString(hotwordId + ".external_update_url", + extension_urls::GetWebstoreUpdateUrl().spec()); + } } +#endif UpdateBookmarksExperimentState( profile_->GetPrefs(), diff --git a/chrome/browser/resources/component_extension_resources.grd b/chrome/browser/resources/component_extension_resources.grd index 6556b04dd9ea..5d21e329370b 100644 --- a/chrome/browser/resources/component_extension_resources.grd +++ b/chrome/browser/resources/component_extension_resources.grd @@ -58,10 +58,13 @@ - + + + + diff --git a/chrome/browser/resources/hotword/manager.js b/chrome/browser/resources/hotword/manager.js new file mode 100644 index 000000000000..7315bbe7af58 --- /dev/null +++ b/chrome/browser/resources/hotword/manager.js @@ -0,0 +1,15 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +'use strict'; + +/** + * @fileoverview This extension provides hotword triggering capabilites to + * Chrome. + * + * This extension contains all the JavaScript for loading and managing the + * hotword detector. The hotword detector and language model data will be + * provided by a shared module loaded from the web store. + */ + diff --git a/chrome/browser/resources/hotword/manifest.json b/chrome/browser/resources/hotword/manifest.json new file mode 100644 index 000000000000..3225a6814579 --- /dev/null +++ b/chrome/browser/resources/hotword/manifest.json @@ -0,0 +1,38 @@ +{ + // Extension ID: nbpagnldghgfoolbancepceaanlmhfmd + "key": "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDbHXRPiq2De9EJ+4pvNN6uE/D2avxrqyLSpA/Hq3II+btkPl1gboY3oUPTfevpVOFa90Y1c1b3/W682dXqybT0klIvFLKhdQx0LiVqSUQyIaDrwOCSo/ZcukbEwDRojegWymCjHvX6WZk4kKZzTJYzY1vrp0TWKLhttEMN9KFmowIDAQAB", + + "name": "Hotword triggering", + "version": "0.0.1.0", + "manifest_version": 2, + + "background": { + "scripts": ["manager.js"], + "persistent": false + }, + + "permissions": [ + "*://*.google.com/*", + "chrome://newtab/", + "hotwordPrivate", + "tabs" + ], + + "externally_connectable": { + "matches": [ + "*://*.google.com/*", + "chrome://newtab/" + ] + }, + + "import": [ + { + // TODO(amistry): For now, use a locally modified version of the external + // hotword extension. Replace with the ID of the new shared module + // containing the hotword detector. + "id": "bepbmhgboaologfdajaanbcjmnhjmhfn" + } + ], + + "minimum_chrome_version": "38" +}