Commit 599e3512 authored by kcarattini's avatar kcarattini Committed by Commit bot

Adds a skeleton component app for Always-On Hotwording opt-in flow.

BUG=390086

Review URL: https://codereview.chromium.org/467113004

Cr-Commit-Position: refs/heads/master@{#292338}
parent c36aeae3
...@@ -156,6 +156,7 @@ ...@@ -156,6 +156,7 @@
</if> </if>
<include name="IDR_HOTWORD_HELPER_MANIFEST" file="resources\hotword_helper\manifest.json" type="BINDATA" /> <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" /> <include name="IDR_HOTWORD_MANIFEST" file="resources\hotword\manifest.json" type="BINDATA" />
<include name="IDR_HOTWORD_AUDIO_VERIFICATION_MANIFEST" file="resources\hotword_audio_verification\manifest.json" type="BINDATA" />
<if expr="not is_android"> <if expr="not is_android">
<include name="IDR_HELP_JS" file="resources\help\help.js" flattenhtml="true" type="BINDATA" /> <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" /> <include name="IDR_HELP_PAGE_JS" file="resources\help\help_page.js" flattenhtml="true" type="BINDATA" />
......
...@@ -301,6 +301,14 @@ void ComponentLoader::AddHangoutServicesExtension() { ...@@ -301,6 +301,14 @@ void ComponentLoader::AddHangoutServicesExtension() {
#endif #endif
} }
void ComponentLoader::AddHotwordAudioVerificationApp() {
CommandLine* command_line = CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(switches::kEnableExperimentalHotwording)) {
Add(IDR_HOTWORD_AUDIO_VERIFICATION_MANIFEST,
base::FilePath(FILE_PATH_LITERAL("hotword_audio_verification")));
}
}
void ComponentLoader::AddHotwordHelperExtension() { void ComponentLoader::AddHotwordHelperExtension() {
if (HotwordServiceFactory::IsHotwordAllowed(browser_context_)) { if (HotwordServiceFactory::IsHotwordAllowed(browser_context_)) {
CommandLine* command_line = CommandLine::ForCurrentProcess(); CommandLine* command_line = CommandLine::ForCurrentProcess();
...@@ -510,6 +518,7 @@ void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages( ...@@ -510,6 +518,7 @@ void ComponentLoader::AddDefaultComponentExtensionsWithBackgroundPages(
AddGalleryExtension(); AddGalleryExtension();
AddHangoutServicesExtension(); AddHangoutServicesExtension();
AddHotwordAudioVerificationApp();
AddHotwordHelperExtension(); AddHotwordHelperExtension();
AddImageLoaderExtension(); AddImageLoaderExtension();
......
...@@ -143,6 +143,7 @@ class ComponentLoader { ...@@ -143,6 +143,7 @@ class ComponentLoader {
int name_string_id, int name_string_id,
int description_string_id); int description_string_id);
void AddChromeApp(); void AddChromeApp();
void AddHotwordAudioVerificationApp();
void AddKeyboardApp(); void AddKeyboardApp();
void AddWebStoreApp(); void AddWebStoreApp();
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
<release seq="1"> <release seq="1">
<structures> <structures>
<structure name="IDR_BOOKMARK_MANAGER_MAIN" file="bookmark_manager/main.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" /> <structure name="IDR_BOOKMARK_MANAGER_MAIN" file="bookmark_manager/main.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<structure name="IDR_HOTWORD_AUDIO_VERIFICATION_MAIN" file="hotword_audio_verification/main.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<if expr="chromeos"> <if expr="chromeos">
<structure name="IDR_WALLPAPER_MANAGER_MAIN" file="chromeos/wallpaper_manager/main.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" /> <structure name="IDR_WALLPAPER_MANAGER_MAIN" file="chromeos/wallpaper_manager/main.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<if expr="not _google_chrome"> <if expr="not _google_chrome">
...@@ -59,6 +60,9 @@ ...@@ -59,6 +60,9 @@
<include name="IDR_HANGOUT_SERVICES_THUNK_JS" file="hangout_services/thunk.js" type="BINDATA" /> <include name="IDR_HANGOUT_SERVICES_THUNK_JS" file="hangout_services/thunk.js" type="BINDATA" />
</if> </if>
<if expr="enable_extensions"> <if expr="enable_extensions">
<!-- Hotword Audio Verification extension -->
<include name="IDR_HOTWORD_AUDIO_VERIFICATION_BACKGROUND_JS" file="hotword_audio_verification/event_page.js" type="BINDATA" />
<!-- Hotword Helper extension --> <!-- Hotword Helper extension -->
<include name="IDR_HOTWORD_HELPER_AUDIO_CLIENT_JS" file="hotword_helper/audio_client.js" type="BINDATA" /> <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" /> <include name="IDR_HOTWORD_HELPER_MANAGER_JS" file="hotword_helper/manager.js" type="BINDATA" />
......
// 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.
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('main.html', {
'frame': 'none',
'resizable': false,
'bounds': {
'width': 710,
'height': 535
}
});
});
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
{
// chrome-extension://abjokfonkihficiokmkfboogholifghn/
"key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtfVZc80kw93gaZwHGhOLpxGKil8n/x1IQ2L/Oj76YeICJk5w4YKw+0N2IYA0gJnwqJdTu3ijrWqO2oQTWoZ3lHmAv9NHsUXHdrWuoGRuVqo0dakLnS+AB3rLGPSerZZNExpdK0Yd3wR6GMOJAoAQM9H6Zpo7LNYjPebx31QJZ6OgdYZA+Eu4fGIJkWIPY1LMsVO1jzFJ4JSPyNWmhxL4fHfQXVM5p1cgJSVxTXsB1ZGaRc4HF2kwSYMOimIiWqfU0VInTXVU7IS3hJaKzm/LExW/ABTGejf2sGIa725EQTavGFsQ07jFZdVzKGAjHCU/0Jy8PxDIg2B+ixlM2QXP/wIDAQAB",
"name": "Hotword Audio Verification",
"version": "0.1",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["event_page.js"],
"persistent": false
}
}
}
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "chrome/browser/plugins/plugin_prefs.h" #include "chrome/browser/plugins/plugin_prefs.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/search/hotword_service_factory.h" #include "chrome/browser/search/hotword_service_factory.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_switches.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
...@@ -214,6 +215,11 @@ HotwordService::HotwordService(Profile* profile) ...@@ -214,6 +215,11 @@ HotwordService::HotwordService(Profile* profile)
base::Bind(&HotwordService::OnHotwordSearchEnabledChanged, base::Bind(&HotwordService::OnHotwordSearchEnabledChanged,
base::Unretained(this))); base::Unretained(this)));
pref_registrar_.Add(
prefs::kHotwordAlwaysOnSearchEnabled,
base::Bind(&HotwordService::OnHotwordAlwaysOnSearchEnabledChanged,
base::Unretained(this)));
registrar_.Add(this, registrar_.Add(this,
chrome::NOTIFICATION_BROWSER_WINDOW_READY, chrome::NOTIFICATION_BROWSER_WINDOW_READY,
content::NotificationService::AllSources()); content::NotificationService::AllSources());
...@@ -444,6 +450,25 @@ void HotwordService::DisableHotwordExtension( ...@@ -444,6 +450,25 @@ void HotwordService::DisableHotwordExtension(
} }
} }
void HotwordService::OnHotwordAlwaysOnSearchEnabledChanged(
const std::string& pref_name) {
DCHECK_EQ(pref_name, std::string(prefs::kHotwordAlwaysOnSearchEnabled));
ExtensionService* extension_service = GetExtensionService(profile_);
if (!extension_service)
return;
const extensions::Extension* extension = extension_service->GetExtensionById(
extension_misc::kHotwordAudioVerificationAppId, true);
if (!extension)
return;
if (profile_->GetPrefs()->GetBoolean(prefs::kHotwordAlwaysOnSearchEnabled)) {
OpenApplication(AppLaunchParams(
profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW));
}
}
void HotwordService::OnHotwordSearchEnabledChanged( void HotwordService::OnHotwordSearchEnabledChanged(
const std::string& pref_name) { const std::string& pref_name) {
DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled)); DCHECK_EQ(pref_name, std::string(prefs::kHotwordSearchEnabled));
......
...@@ -76,6 +76,10 @@ class HotwordService : public content::NotificationObserver, ...@@ -76,6 +76,10 @@ class HotwordService : public content::NotificationObserver,
void EnableHotwordExtension(ExtensionService* extension_service); void EnableHotwordExtension(ExtensionService* extension_service);
void DisableHotwordExtension(ExtensionService* extension_service); void DisableHotwordExtension(ExtensionService* extension_service);
// Handles launching the Hotword Audio Verification extension when the user
// turns it on via the settings menu.
void OnHotwordAlwaysOnSearchEnabledChanged(const std::string& pref_name);
// Handles enabling/disabling the hotword extension when the user // Handles enabling/disabling the hotword extension when the user
// turns it off via the settings menu. // turns it off via the settings menu.
void OnHotwordSearchEnabledChanged(const std::string& pref_name); void OnHotwordSearchEnabledChanged(const std::string& pref_name);
......
...@@ -116,6 +116,8 @@ const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo"; ...@@ -116,6 +116,8 @@ const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp"; const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon"; const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon";
const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl"; const char kCroshBuiltinAppId[] = "nkoccljplnhpfnfiajclkommnmllphnl";
const char kHotwordAudioVerificationAppId[] =
"abjokfonkihficiokmkfboogholifghn";
const char kHotwordExtensionId[] = "bepbmhgboaologfdajaanbcjmnhjmhfn"; const char kHotwordExtensionId[] = "bepbmhgboaologfdajaanbcjmnhjmhfn";
const char kPdfExtensionId[] = "mhjfbmdgcfjbbpaeojofohoefgiehjai"; const char kPdfExtensionId[] = "mhjfbmdgcfjbbpaeojofohoefgiehjai";
const char kQuickOfficeComponentExtensionId[] = const char kQuickOfficeComponentExtensionId[] =
......
...@@ -116,6 +116,9 @@ extern const char kIdentityApiUiAppId[]; ...@@ -116,6 +116,9 @@ extern const char kIdentityApiUiAppId[];
// The extension id of the Crosh component app for ChromeOS. // The extension id of the Crosh component app for ChromeOS.
extern const char kCroshBuiltinAppId[]; extern const char kCroshBuiltinAppId[];
// The extension id of the hotword audio verification dialogue app.
extern const char kHotwordAudioVerificationAppId[];
// The extension id of the hotword voice search trigger extension. // The extension id of the hotword voice search trigger extension.
extern const char kHotwordExtensionId[]; extern const char kHotwordExtensionId[];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment