Commit 0a001f9c authored by rlp's avatar rlp Committed by Commit bot

[Hotword] Mark notification as shown if the user updates the always on pref.

If the user updates the pref (e.g., via chrome://settings) then they
presumably already know about always on hotwording so there's no reason to
annoy them with a notification. This CL adds a pref registrar observer
to the always on pref and when it's changed, marks the notification as seen
and then removes the observer.

This will only work for new users since once they have the always on pref,
this observer will get hit on switching between profiles, but presumably
once they have the always on pref, it means they enabled it or disabled it
at some point.

BUG=443805

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

Cr-Commit-Position: refs/heads/master@{#309516}
parent 662b3e43
......@@ -331,7 +331,11 @@ HotwordService::HotwordService(Profile* profile)
pref_registrar_.Add(
prefs::kHotwordSearchEnabled,
base::Bind(&HotwordService::OnHotwordSearchEnabledChanged,
base::Unretained(this)));
base::Unretained(this)));
pref_registrar_.Add(
prefs::kHotwordAlwaysOnSearchEnabled,
base::Bind(&HotwordService::OnHotwordAlwaysOnSearchEnabledChanged,
base::Unretained(this)));
extensions::ExtensionSystem::Get(profile_)->ready().Post(
FROM_HERE,
......@@ -772,6 +776,16 @@ void HotwordService::OnHotwordSearchEnabledChanged(
DisableHotwordExtension(extension_service);
}
void HotwordService::OnHotwordAlwaysOnSearchEnabledChanged(
const std::string& pref_name) {
// If the pref for always on has been changed in some way, that means that
// the user is aware of always on (either from settings or another source)
// so they don't need to be shown the notification.
profile_->GetPrefs()->SetBoolean(prefs::kHotwordAlwaysOnNotificationSeen,
true);
pref_registrar_.Remove(prefs::kHotwordAlwaysOnSearchEnabled);
}
void HotwordService::RequestHotwordSession(HotwordClient* client) {
if (!IsServiceAvailable() || (client_ && client_ != client))
return;
......
......@@ -84,6 +84,10 @@ class HotwordService : public extensions::ExtensionRegistryObserver,
// turns it off via the settings menu.
void OnHotwordSearchEnabledChanged(const std::string& pref_name);
// Handles enabling/disabling the hotword notification when the user
// changes the always on search settings.
void OnHotwordAlwaysOnSearchEnabledChanged(const std::string& pref_name);
// Called to handle the hotword session from |client|.
void RequestHotwordSession(HotwordClient* client);
void StopHotwordSession(HotwordClient* client);
......
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