Commit 72bac5ab authored by tby's avatar tby Committed by Chromium LUCI CQ

[Suggested files] Change suggested content toggle gating

This CL does two things.

1. The previous CL only checked the value of the content toggle at
initialization, meaning a user wouldn't immediately stop seeing
suggestions after disabling, or start seeing them after reenabling.
This CL moves the check to just before display time instead.

2. This also adds a content toggle check to the local file provider,
rather than just Drive in the previous CL. The UX of having one but
not the other wasn't very good.

Bug: 1034842
Change-Id: I4f408d8d1e40ef44e4a80906aa10ad7333a49eb6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2628709Reviewed-by: default avatarRachel Wong <wrong@chromium.org>
Reviewed-by: default avatarTony Yeoman <tby@chromium.org>
Commit-Queue: Tony Yeoman <tby@chromium.org>
Cr-Commit-Position: refs/heads/master@{#843856}
parent cd98fac3
...@@ -53,6 +53,11 @@ void LogStatus(Status status) { ...@@ -53,6 +53,11 @@ void LogStatus(Status status) {
status); status);
} }
bool IsSuggestedContentEnabled(Profile* profile) {
return profile->GetPrefs()->GetBoolean(
chromeos::prefs::kSuggestedContentEnabled);
}
// Given an absolute path representing a file in the user's Drive, returns a // Given an absolute path representing a file in the user's Drive, returns a
// reparented version of the path within the user's drive fs mount. // reparented version of the path within the user's drive fs mount.
base::FilePath ReparentToDriveMount( base::FilePath ReparentToDriveMount(
...@@ -72,9 +77,7 @@ DriveZeroStateProvider::DriveZeroStateProvider( ...@@ -72,9 +77,7 @@ DriveZeroStateProvider::DriveZeroStateProvider(
drive_service_( drive_service_(
drive::DriveIntegrationServiceFactory::GetForProfile(profile)), drive::DriveIntegrationServiceFactory::GetForProfile(profile)),
item_suggest_cache_(profile, std::move(url_loader_factory)), item_suggest_cache_(profile, std::move(url_loader_factory)),
suggested_files_enabled_(app_list_features::IsSuggestedFilesEnabled() && suggested_files_enabled_(app_list_features::IsSuggestedFilesEnabled()) {
profile->GetPrefs()->GetBoolean(
chromeos::prefs::kSuggestedContentEnabled)) {
DCHECK(profile_); DCHECK(profile_);
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
task_runner_ = base::ThreadPool::CreateSequencedTaskRunner( task_runner_ = base::ThreadPool::CreateSequencedTaskRunner(
...@@ -205,7 +208,7 @@ void DriveZeroStateProvider::OnFilePathsLocated( ...@@ -205,7 +208,7 @@ void DriveZeroStateProvider::OnFilePathsLocated(
provider_results.emplace_back( provider_results.emplace_back(
MakeListResult(path_or_error->get_path(), score)); MakeListResult(path_or_error->get_path(), score));
if (suggested_files_enabled_) { if (suggested_files_enabled_ && IsSuggestedContentEnabled(profile_)) {
provider_results.emplace_back( provider_results.emplace_back(
MakeChipResult(path_or_error->get_path(), score)); MakeChipResult(path_or_error->get_path(), score));
} }
......
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
#include "chrome/browser/ui/app_list/search/file_chip_result.h" #include "chrome/browser/ui/app_list/search/file_chip_result.h"
#include "chrome/browser/ui/app_list/search/search_result_ranker/recurrence_ranker.h" #include "chrome/browser/ui/app_list/search/search_result_ranker/recurrence_ranker.h"
#include "chrome/browser/ui/app_list/search/zero_state_file_result.h" #include "chrome/browser/ui/app_list/search/zero_state_file_result.h"
#include "chromeos/constants/chromeos_pref_names.h"
#include "components/prefs/pref_service.h"
using file_manager::file_tasks::FileTasksObserver; using file_manager::file_tasks::FileTasksObserver;
...@@ -48,6 +50,11 @@ internal::ValidAndInvalidResults ValidateFiles( ...@@ -48,6 +50,11 @@ internal::ValidAndInvalidResults ValidateFiles(
return {valid, invalid}; return {valid, invalid};
} }
bool IsSuggestedContentEnabled(Profile* profile) {
return profile->GetPrefs()->GetBoolean(
chromeos::prefs::kSuggestedContentEnabled);
}
} // namespace } // namespace
ZeroStateFileProvider::ZeroStateFileProvider(Profile* profile) ZeroStateFileProvider::ZeroStateFileProvider(Profile* profile)
...@@ -113,7 +120,8 @@ void ZeroStateFileProvider::SetSearchResults( ...@@ -113,7 +120,8 @@ void ZeroStateFileProvider::SetSearchResults(
new_results.emplace_back(std::make_unique<ZeroStateFileResult>( new_results.emplace_back(std::make_unique<ZeroStateFileResult>(
filepath_score.first, filepath_score.second, profile_)); filepath_score.first, filepath_score.second, profile_));
// Add suggestion chip file results // Add suggestion chip file results
if (app_list_features::IsSuggestedFilesEnabled()) { if (app_list_features::IsSuggestedFilesEnabled() &&
IsSuggestedContentEnabled(profile_)) {
new_results.emplace_back(std::make_unique<FileChipResult>( new_results.emplace_back(std::make_unique<FileChipResult>(
filepath_score.first, filepath_score.second, profile_)); filepath_score.first, filepath_score.second, profile_));
} }
......
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