Commit c4d726fd authored by David Black's avatar David Black Committed by Commit Bot

Don't show proactive suggestions if Assistant is not allowed.

Currently we only check if Assistant is settings enabled, so the
non-primary profile is able to see proactive suggestions despite being
unable to use Assistant.

Bug: b:143367826
Change-Id: I377b3c887ae9271dcf445866b65a45ddddc61f1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880540Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Reviewed-by: default avatarTao Wu <wutao@chromium.org>
Commit-Queue: David Black <dmblack@google.com>
Cr-Commit-Position: refs/heads/master@{#709669}
parent 5e233862
...@@ -118,6 +118,14 @@ void ProactiveSuggestionsClientImpl::DidStartNavigation( ...@@ -118,6 +118,14 @@ void ProactiveSuggestionsClientImpl::DidStartNavigation(
SetActiveUrl(active_contents_->GetURL()); SetActiveUrl(active_contents_->GetURL());
} }
void ProactiveSuggestionsClientImpl::OnAssistantFeatureAllowedChanged(
ash::mojom::AssistantAllowedState state) {
// When the Assistant feature is allowed/disallowed we may need to resume/
// pause observation of the browser. We accomplish this by updating active
// state.
UpdateActiveState();
}
void ProactiveSuggestionsClientImpl::OnAssistantSettingsEnabled(bool enabled) { void ProactiveSuggestionsClientImpl::OnAssistantSettingsEnabled(bool enabled) {
// When Assistant is enabled/disabled in settings we may need to resume/pause // When Assistant is enabled/disabled in settings we may need to resume/pause
// observation of the browser. We accomplish this by updating active state. // observation of the browser. We accomplish this by updating active state.
...@@ -209,10 +217,12 @@ void ProactiveSuggestionsClientImpl::UpdateActiveState() { ...@@ -209,10 +217,12 @@ void ProactiveSuggestionsClientImpl::UpdateActiveState() {
auto* tab_strip_model = active_browser_->tab_strip_model(); auto* tab_strip_model = active_browser_->tab_strip_model();
// We never observe browsers that are off the record and we never observe // We never observe browsers that are off the record and we never observe
// browsers when the user has disabled either Assistant or screen context. We // browsers when the Assistant feature is not allowed. We also don't observe
// also don't observe the browser when the user has disabled history sync or // the browser when the user has disabled either Assistant or screen context
// is using a sync passphrase. // or when the user has disabled history sync or is using a sync passphrase.
if (active_browser_->profile()->IsOffTheRecord() || if (active_browser_->profile()->IsOffTheRecord() ||
ash::AssistantState::Get()->allowed_state() !=
ash::mojom::AssistantAllowedState::ALLOWED ||
!ash::AssistantState::Get()->settings_enabled().value_or(false) || !ash::AssistantState::Get()->settings_enabled().value_or(false) ||
!ash::AssistantState::Get()->context_enabled().value_or(false) || !ash::AssistantState::Get()->context_enabled().value_or(false) ||
!IsHistorySyncEnabledWithoutPassphrase(profile_)) { !IsHistorySyncEnabledWithoutPassphrase(profile_)) {
......
...@@ -51,6 +51,8 @@ class ProactiveSuggestionsClientImpl : public ash::ProactiveSuggestionsClient, ...@@ -51,6 +51,8 @@ class ProactiveSuggestionsClientImpl : public ash::ProactiveSuggestionsClient,
content::NavigationHandle* navigation_handle) override; content::NavigationHandle* navigation_handle) override;
// AssistantStateObserver: // AssistantStateObserver:
void OnAssistantFeatureAllowedChanged(
ash::mojom::AssistantAllowedState state) override;
void OnAssistantSettingsEnabled(bool enabled) override; void OnAssistantSettingsEnabled(bool enabled) override;
void OnAssistantContextEnabled(bool enabled) override; void OnAssistantContextEnabled(bool enabled) override;
......
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