0

Hotword Private API: Add support for retrieving localized strings.

BUG=390086

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

Cr-Commit-Position: refs/heads/master@{#303948}
This commit is contained in:
kcarattini
2014-11-12 16:58:42 -08:00
committed by Commit bot
parent 3186d416ef
commit c486ecc954
6 changed files with 201 additions and 0 deletions
chrome
app
browser
common
extensions
extensions/browser
tools/metrics/histograms

@ -15076,6 +15076,92 @@ Do you accept?
<message name="IDS_FLAGS_DISABLE_CAST_STREAMING_HW_ENCODING_DESCRIPTION" desc="Description of chrome:flags option to turn off Cast Streaming hardware video encoding support.">
This option disables support in Cast Streaming for encoding video streams using platform hardware.
</message>
<!-- Hotword Audio Verification (opt-in) App strings. -->
<message name="IDS_HOTWORD_OPT_IN_CANCEL" desc="Text on the cancel button for the 'Ok Google' hotword opt-in dialog.">
CANCEL
</message>
<message name="IDS_HOTWORD_OPT_IN_INTRO_TITLE" desc="Title of the intro page of the 'Ok Google' hotword opt-in dialog.">
Voice search at any time
</message>
<message name="IDS_HOTWORD_OPT_IN_INTRO_SUBTITLE" desc="Sub-title of the intro page of the 'Ok Google' hotword opt-in dialog.">
Say "Ok Google" when your screen is on and unlocked
</message>
<message name="IDS_HOTWORD_OPT_IN_INTRO_DESCRIPTION" desc="Description explaining the steps required to continue through the hotword opt-in process.">
To make this happen, you'll need to enable Google Audio History and train your Chromebook in the following steps.
</message>
<message name="IDS_HOTWORD_OPT_IN_INTRO_DESCRIPTION_AUDIO_HISTORY_ENABLED" desc="Description explaining the steps required to continue through the hotword opt-in process.">
To make this happen, you'll need to train your Chromebook in the following step.
</message>
<message name="IDS_HOTWORD_OPT_IN_INTRO_START" desc="Text on the start button for the 'Ok Google' hotword opt-in dialog.">
GET STARTED
</message>
<message name="IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_TITLE" desc="Title of the Audio History page of the 'Ok Google' hotword opt-in dialog.">
Enable Audio History
</message>
<message name="IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_DESCRIPTION" desc="Description of the Audio History page of the 'Ok Google' hotword opt-in dialog.">
When you use voice activation commands, such as "Ok Google" or touching a microphone icon, a recording of the next thing you say, plus a few seconds before, may be used and stored by Google and associated with your Google Account to help recognize your voice and improve speech recognition.
</message>
<message name="IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_LEARN_MORE" desc="The text indicating where the user can learn more about Audio History.">
<ph name="BEGIN_LINK">&lt;a target="_blank" href="https://support.google.com/websearch?p=chromebook_audiohistory"&gt;</ph>LEARN MORE<ph name="END_LINK">&lt;/a&gt;<ex>&lt;/a&gt;</ex></ph>
</message>
<message name="IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_DECLINE" desc="Text on the decline button for the Audio History section of the 'Ok Google' hotword opt-in dialog.">
NO THANKS
</message>
<message name="IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_AGREE" desc="Text on the agree button for the Audio History section of the 'Ok Google' hotword opt-in dialog.">
I AGREE
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_TITLE" desc="Title of the voice model training page of the 'Ok Google' hotword opt-in dialog.">
Let's train your Chromebook
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_DESCRIPTION" desc="Description on the voice model training page of the 'Ok Google' hotword opt-in dialog.">
To help your Chromebook respond to you and for reliable and easy access to voice search, you need to teach Google the sound of your voice.
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_SPEAK" desc="The text describing the action the user should take on the voice model training page of the 'Ok Google' hotword opt-in dialog.">
Just say "Ok Google" three times
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_FIRST_PROMPT" desc="The first prompt text on the voice model training page of the 'Ok Google' hotword opt-in dialog.">
Say "Ok Google"
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_MIDDLE_PROMPT" desc="The middle prompt text on the voice model training page of the 'Ok Google' hotword opt-in dialog.">
Say "Ok Google" again
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_LAST_PROMPT" desc="The last prompt text on the voice model training page of the 'Ok Google' hotword opt-in dialog.">
Say "Ok Google" one last time
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_RECORDED" desc="The message displayed when an 'Ok Google' utterance has been recorded.">
Recorded
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_TIMEOUT" desc="The message displayed when an 'Ok Google' training has time out.">
Training timed out
</message>
<message name="IDS_HOTWORD_OPT_IN_TRAINING_RETRY" desc="Text on the retry button of the voice model training page of the 'Ok Google' hotword opt-in dialog.">
RETRY
</message>
<message name="IDS_HOTWORD_OPT_IN_FINISHED_TITLE" desc="Title of the finished page of the 'Ok Google' hotword opt-in dialog.">
You're all set!
</message>
<message name="IDS_HOTWORD_OPT_IN_FINISHED_LIST_INTRO" desc="The text at the beginning of the list describing the Chromebook's new abilities. ">
Your Chromebook can now:
</message>
<message name="IDS_HOTWORD_OPT_IN_FINISHED_LIST_ITEM_1" desc="The text of the first item in the list of Chromebook abilities. ">
Recognize your voice when you say "Ok Google"
</message>
<message name="IDS_HOTWORD_OPT_IN_FINISHED_LIST_ITEM_2" desc="The text of the second item in the list of Chromebook abilities. ">
Respond to "Ok Google" when the screen is on and unlocked
</message>
<message name="IDS_HOTWORD_OPT_IN_FINISHED_SETTINGS" desc="The text indicating where the user can change their Chrome settings. ">
You can change this at any time in <ph name="BEGIN_LINK">&lt;a target="_blank" href="#" id="settings-link"&gt;</ph>Chrome Settings<ph name="END_LINK">&lt;/a&gt;<ex>&lt;/a&gt;</ex></ph>
</message>
<message name="IDS_HOTWORD_OPT_IN_FINISHED_AUDIO_HISTORY" desc="The text indicating where the user can change their account history. ">
Search queries will be tied to your Google Account. You can view and delete them in your <ph name="BEGIN_LINK">&lt;a target="_blank" href="https://www.google.com/settings/accounthistory"&gt;</ph>Account History<ph name="END_LINK">&lt;/a&gt;<ex>&lt;/a&gt;</ex></ph>
</message>
<message name="IDS_HOTWORD_OPT_IN_FINISH" desc="Text on the finish button for the 'Ok Google' hotword opt-in dialog.">
FINISH
</message>
<message name="IDS_HOTWORD_OPT_IN_FINISHED_WAIT" desc="The text displayed when waiting for the voice model training to complete. ">
Please wait ...
</message>
</messages>
</release>
</grit>

@ -13,7 +13,9 @@
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/common/pref_names.h"
#include "chrome/grit/generated_resources.h"
#include "extensions/browser/event_router.h"
#include "ui/base/l10n/l10n_util.h"
namespace extensions {
@ -258,4 +260,98 @@ bool HotwordPrivateStopTrainingFunction::RunSync() {
return true;
}
bool HotwordPrivateGetLocalizedStringsFunction::RunSync() {
base::DictionaryValue* localized_strings = new base::DictionaryValue();
localized_strings->SetString(
"cancel",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_CANCEL));
localized_strings->SetString(
"introTitle",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_INTRO_TITLE));
localized_strings->SetString(
"introSubtitle",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_INTRO_SUBTITLE));
localized_strings->SetString(
"introDescription",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_INTRO_DESCRIPTION));
localized_strings->SetString(
"introDescriptionAudioHistoryEnabled",
l10n_util::GetStringUTF16(
IDS_HOTWORD_OPT_IN_INTRO_DESCRIPTION_AUDIO_HISTORY_ENABLED));
localized_strings->SetString(
"introStart",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_INTRO_START));
localized_strings->SetString(
"audioHistoryTitle",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_TITLE));
localized_strings->SetString(
"audioHistoryDescription",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_DESCRIPTION));
localized_strings->SetString(
"audioHistoryLearnMore",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_LEARN_MORE));
localized_strings->SetString(
"audioHistoryDecline",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_DECLINE));
localized_strings->SetString(
"audioHistoryAgree",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_AUDIO_HISTORY_AGREE));
localized_strings->SetString(
"trainingTitle",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_TITLE));
localized_strings->SetString(
"trainingDescription",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_DESCRIPTION));
localized_strings->SetString(
"trainingSpeak",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_SPEAK));
localized_strings->SetString(
"trainingFirstPrompt",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_FIRST_PROMPT));
localized_strings->SetString(
"trainingMiddlePrompt",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_MIDDLE_PROMPT));
localized_strings->SetString(
"trainingLastPrompt",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_LAST_PROMPT));
localized_strings->SetString(
"trainingRecorded",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_RECORDED));
localized_strings->SetString(
"trainingTimeout",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_TIMEOUT));
localized_strings->SetString(
"trainingRetry",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_TRAINING_RETRY));
localized_strings->SetString(
"finishedTitle",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISHED_TITLE));
localized_strings->SetString(
"finishedListIntro",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISHED_LIST_INTRO));
localized_strings->SetString(
"finishedListItem1",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISHED_LIST_ITEM_1));
localized_strings->SetString(
"finishedListItem2",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISHED_LIST_ITEM_2));
localized_strings->SetString(
"finishedSettings",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISHED_SETTINGS));
localized_strings->SetString(
"finishedAudioHistory",
l10n_util::GetStringUTF16(
IDS_HOTWORD_OPT_IN_FINISHED_AUDIO_HISTORY));
localized_strings->SetString(
"finish",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISH));
localized_strings->SetString(
"finishedWait",
l10n_util::GetStringUTF16(IDS_HOTWORD_OPT_IN_FINISHED_WAIT));
SetResult(localized_strings);
return true;
}
} // namespace extensions

@ -191,6 +191,19 @@ class HotwordPrivateStopTrainingFunction :
bool RunSync() override;
};
class HotwordPrivateGetLocalizedStringsFunction
: public ChromeSyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("hotwordPrivate.getLocalizedStrings",
HOTWORDPRIVATE_GETLOCALIZEDSTRINGS)
protected:
virtual ~HotwordPrivateGetLocalizedStringsFunction() {}
// ExtensionFunction:
virtual bool RunSync() override;
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_HOTWORD_PRIVATE_HOTWORD_PRIVATE_API_H_

@ -53,6 +53,7 @@
callback GenericDoneCallback = void ();
callback LaunchStateCallback = void(LaunchState result);
callback LocalizeStringsCallback = void(object result);
callback StatusDetailsCallback = void(StatusDetails result);
interface Functions {
@ -65,6 +66,9 @@
// The result is put into a StatusDetails object.
static void getStatus(StatusDetailsCallback callback);
// Retrieves a dictionary mapping names to localized resource strings.
static void getLocalizedStrings(LocalizeStringsCallback callback);
// Sets the current enabled state of audio logging in the extension.
// True: logging enabled. False: no logging.
static void setAudioLoggingEnabled(boolean state,

@ -982,6 +982,7 @@ enum HistogramValue {
DOCUMENT_SCAN_SCAN,
EASYUNLOCKPRIVATE_GETUSERIMAGE,
HOTWORDPRIVATE_NOTIFYSPEAKERMODELSAVED,
HOTWORDPRIVATE_GETLOCALIZEDSTRINGS,
// Last entry: Add new entries above and ensure to update
// tools/metrics/histograms/histograms.xml.
ENUM_BOUNDARY

@ -44751,6 +44751,7 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="921" label="DOCUMENT_SCAN_SCAN"/>
<int value="922" label="EASYUNLOCKPRIVATE_GETUSERIMAGE"/>
<int value="923" label="HOTWORDPRIVATE_NOTIFYSPEAKERMODELSAVED"/>
<int value="924" label="HOTWORDPRIVATE_GETLOCALIZEDSTRINGS"/>
</enum>
<enum name="ExtensionInstallCause" type="int">