Skip to content

Commit

Permalink
Add new hotword extension for built-in hotword triggering.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
amistry@chromium.org committed Aug 12, 2014
1 parent e40547e commit 535980d
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 6 deletions.
1 change: 1 addition & 0 deletions WATCHLISTS
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
},
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/browser_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
<include name="IDR_HANGOUT_SERVICES_MANIFEST" file="resources\hangout_services\manifest.json" type="BINDATA" />
</if>
<include name="IDR_HOTWORD_HELPER_MANIFEST" file="resources\hotword_helper\manifest.json" type="BINDATA" />
<include name="IDR_HOTWORD_MANIFEST" file="resources\hotword\manifest.json" type="BINDATA" />
<if expr="not is_android">
<include name="IDR_HELP_JS" file="resources\help\help.js" flattenhtml="true" type="BINDATA" />
<include name="IDR_HELP_PAGE_JS" file="resources\help\help_page.js" flattenhtml="true" type="BINDATA" />
Expand Down
10 changes: 8 additions & 2 deletions chrome/browser/extensions/component_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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")));
}
}
}

Expand Down
19 changes: 16 additions & 3 deletions chrome/browser/extensions/external_component_loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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(),
Expand Down
5 changes: 4 additions & 1 deletion chrome/browser/resources/component_extension_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,13 @@
<include name="IDR_HANGOUT_SERVICES_BACKGROUND_HTML" file="hangout_services/background.html" type="BINDATA" />
<include name="IDR_HANGOUT_SERVICES_THUNK_JS" file="hangout_services/thunk.js" type="BINDATA" />
</if>
<!-- Hotword Helper extension -->
<if expr="enable_extensions">
<!-- Hotword Helper extension -->
<include name="IDR_HOTWORD_HELPER_AUDIO_CLIENT_JS" file="hotword_helper/audio_client.js" type="BINDATA" />
<include name="IDR_HOTWORD_HELPER_MANAGER_JS" file="hotword_helper/manager.js" type="BINDATA" />

<!-- (Experimental) hotword triggering extension -->
<include name="IDR_HOTWORD_MANAGER_JS" file="hotword/manager.js" type="BINDATA" />
</if>
<if expr="not is_android">
<include name="IDR_FEEDBACK_DEFAULT_HTML" file="feedback/html/default.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
Expand Down
15 changes: 15 additions & 0 deletions chrome/browser/resources/hotword/manager.js
Original file line number Diff line number Diff line change
@@ -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.
*/

38 changes: 38 additions & 0 deletions chrome/browser/resources/hotword/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit 535980d

Please sign in to comment.