| Index: chrome/browser/ui/webui/options/browser_options_handler.cc
|
| diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| index 6cd7245380864daf316a1121434b3a04fa3fa538..cbf030da8d9bc2a2ed7fea55ab716a3270d60296 100644
|
| --- a/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| +++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| @@ -539,12 +539,12 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) {
|
| values->SetString("hotwordManageAudioHistoryURL",
|
| chrome::kManageAudioHistoryURL);
|
|
|
| - Profile* profile = Profile::FromWebUI(web_ui());
|
| #if defined(OS_CHROMEOS)
|
| + Profile* profile = Profile::FromWebUI(web_ui());
|
| std::string username = profile->GetProfileName();
|
| if (username.empty()) {
|
| user_manager::User* user =
|
| - chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
|
| + chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
|
| if (user && (user->GetType() != user_manager::USER_TYPE_GUEST))
|
| username = user->email();
|
| }
|
| @@ -554,21 +554,6 @@ void BrowserOptionsHandler::GetLocalizedValues(base::DictionaryValue* values) {
|
| values->SetString("username", username);
|
| #endif
|
|
|
| - base::string16 user_email;
|
| - // If the profile is a guest session, it will not be found in the cache.
|
| - // In that case, just set the value with an empty string for the email since
|
| - // it won't be displayed anyways for a guest profile.
|
| - if (!profile->IsGuestSession()) {
|
| - ProfileInfoCache& cache =
|
| - g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - user_email = cache.GetUserNameOfProfileAtIndex(
|
| - cache.GetIndexOfProfileWithPath(profile->GetPath()));
|
| - }
|
| - values->SetString(
|
| - "hotwordAudioHistoryEnabled",
|
| - l10n_util::GetStringFUTF16(IDS_HOTWORD_AUDIO_HISTORY_ENABLED,
|
| - user_email));
|
| -
|
| // Pass along sync status early so it will be available during page init.
|
| values->Set("syncData", GetSyncStateDictionary().release());
|
|
|
| @@ -1214,8 +1199,9 @@ void BrowserOptionsHandler::OnTemplateURLServiceChanged() {
|
| } else {
|
| // If the user has chosen a default search provide other than Google, turn
|
| // off hotwording since other providers don't provide that functionality.
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setHotwordSectionVisible",
|
| - base::FundamentalValue(false));
|
| + web_ui()->CallJavascriptFunction(
|
| + "BrowserOptions.setAllHotwordSectionsVisible",
|
| + base::FundamentalValue(false));
|
| HotwordService* hotword_service =
|
| HotwordServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
|
| if (hotword_service)
|
| @@ -1566,6 +1552,13 @@ void BrowserOptionsHandler::OnConsumerManagementStatusChanged() {
|
| void BrowserOptionsHandler::UpdateSyncState() {
|
| web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState",
|
| *GetSyncStateDictionary());
|
| +
|
| + // A change in sign-in state also affects how hotwording and audio history are
|
| + // displayed. Hide all hotwording and re-display properly.
|
| + web_ui()->CallJavascriptFunction(
|
| + "BrowserOptions.setAllHotwordSectionsVisible",
|
| + base::FundamentalValue(false));
|
| + HandleRequestHotwordAvailable(nullptr);
|
| }
|
|
|
| void BrowserOptionsHandler::OnSigninAllowedPrefChange() {
|
| @@ -1686,8 +1679,11 @@ void BrowserOptionsHandler::HandleRequestHotwordAvailable(
|
|
|
| std::string function_name;
|
| bool always_on = false;
|
| + SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile);
|
| + bool authenticated = signin && signin->IsAuthenticated();
|
| if (HotwordService::IsExperimentalHotwordingEnabled()) {
|
| - if (HotwordServiceFactory::IsHotwordHardwareAvailable()) {
|
| + if (HotwordServiceFactory::IsHotwordHardwareAvailable() &&
|
| + authenticated) {
|
| function_name = "BrowserOptions.showHotwordAlwaysOnSection";
|
| always_on = true;
|
| // Show the retrain link if always-on is enabled.
|
| @@ -1705,12 +1701,21 @@ void BrowserOptionsHandler::HandleRequestHotwordAvailable(
|
| }
|
|
|
| // Audio history should be displayed if it's enabled regardless of the
|
| - // hotword error state. An additional message is displayed if always-on
|
| - // hotwording is enabled.
|
| + // hotword error state if the user is signed in. If the user is not signed
|
| + // in, audio history is meaningless. An additional message is displayed if
|
| + // always-on hotwording is enabled.
|
| if (profile->GetPrefs()->GetBoolean(prefs::kHotwordAudioLoggingEnabled) &&
|
| - HotwordService::IsExperimentalHotwordingEnabled()) {
|
| + HotwordService::IsExperimentalHotwordingEnabled() &&
|
| + authenticated) {
|
| + std::string user_display_name = signin->GetAuthenticatedUsername();
|
| + DCHECK(!user_display_name.empty());
|
| +
|
| + base::string16 audio_history_state =
|
| + l10n_util::GetStringFUTF16(IDS_HOTWORD_AUDIO_HISTORY_ENABLED,
|
| + base::ASCIIToUTF16(user_display_name));
|
| web_ui()->CallJavascriptFunction("BrowserOptions.showAudioHistorySection",
|
| - base::FundamentalValue(always_on));
|
| + base::FundamentalValue(always_on),
|
| + base::StringValue(audio_history_state));
|
| }
|
|
|
| if (!error) {
|
|
|