Commit 687bb8f8 authored by Eleni Dimitriadis's avatar Eleni Dimitriadis Committed by Commit Bot

[Suggested Files] UI modifications for file chips

New result types have been created for the file and drive quick
access results to be displayed in the suggestion chips, with
required accompanying modifications.

Bug: 1034842
Tests: All cros tests pass
Change-Id: Ic694384133b64775ed6295c0e227c657e83db837
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1984780
Commit-Queue: Eleni Dimitriadis <edimitriadis@google.com>
Reviewed-by: default avatarJia Meng <jiameng@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarTony Yeoman <tby@chromium.org>
Cr-Commit-Position: refs/heads/master@{#733870}
parent a0f01150
......@@ -145,6 +145,8 @@ enum class AppListSearchResultType {
kArcAppShortcut, // ARC++ app shortcuts.
kZeroStateFile, // Zero state local file results.
kDriveQuickAccess, // Drive QuickAccess results.
kFileChip, // Local file results in suggestion chips.
kDriveQuickAccessChip, // Drive file results in suggestion chips.
// Add new values here.
};
......
......@@ -3712,10 +3712,14 @@ jumbo_static_library("ui") {
"app_list/search/common/url_icon_source.h",
"app_list/search/cros_action_history/cros_action_recorder.cc",
"app_list/search/cros_action_history/cros_action_recorder.h",
"app_list/search/drive_quick_access_chip_result.cc",
"app_list/search/drive_quick_access_chip_result.h",
"app_list/search/drive_quick_access_provider.cc",
"app_list/search/drive_quick_access_provider.h",
"app_list/search/drive_quick_access_result.cc",
"app_list/search/drive_quick_access_result.h",
"app_list/search/file_chip_result.cc",
"app_list/search/file_chip_result.h",
"app_list/search/mixer.cc",
"app_list/search/mixer.h",
"app_list/search/omnibox_provider.cc",
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/app_list/search/drive_quick_access_chip_result.h"
#include <utility>
#include "ash/public/cpp/app_list/app_list_metrics.h"
#include "chrome/browser/profiles/profile.h"
namespace app_list {
namespace {
const char kDriveQuickAccessChipResultPrefix[] = "quickaccesschip://";
}
DriveQuickAccessChipResult::DriveQuickAccessChipResult(
const base::FilePath& filepath,
const float relevance,
Profile* profile)
: DriveQuickAccessResult(filepath, relevance, profile) {
set_id(kDriveQuickAccessChipResultPrefix + filepath.value());
SetResultType(ResultType::kDriveQuickAccessChip);
// TODO(crbug.com/1034842) Add line:
// SetDisplayType(DisplayType::kChip);
// to replace DisplayType and DisplayLocation setting
// once CL:1980331 merged
SetDisplayType(DisplayType::kNone);
SetDisplayLocation(DisplayLocation::kSuggestionChipContainer);
}
} // namespace app_list
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_DRIVE_QUICK_ACCESS_CHIP_RESULT_H_
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_DRIVE_QUICK_ACCESS_CHIP_RESULT_H_
#include "chrome/browser/ui/app_list/search/drive_quick_access_result.h"
namespace app_list {
// A search result for a Drive QuickAccess file to be displayed in the
// suggestion chips. This inherits from DriveQuickAccessResult because
// most of its logic is identical, but it is important they are different
// types for ranking purposes.
class DriveQuickAccessChipResult : public DriveQuickAccessResult {
public:
DriveQuickAccessChipResult(const base::FilePath& filepath,
float relevance,
Profile* profile);
};
} // namespace app_list
#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_DRIVE_QUICK_ACCESS_CHIP_RESULT_H_
......@@ -7,6 +7,7 @@
#include <memory>
#include <utility>
#include "ash/public/cpp/app_list/app_list_features.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_macros.h"
......@@ -14,6 +15,7 @@
#include "base/task/task_traits.h"
#include "base/task_runner_util.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/ui/app_list/search/drive_quick_access_chip_result.h"
#include "chrome/browser/ui/app_list/search/drive_quick_access_result.h"
namespace app_list {
......@@ -129,9 +131,15 @@ void DriveQuickAccessProvider::Start(const base::string16& query) {
SearchProvider::Results results;
for (const auto& result : results_cache_) {
const auto& path = ReparentToDriveMount(result.path, drive_service_);
results.emplace_back(std::make_unique<DriveQuickAccessResult>(
ReparentToDriveMount(result.path, drive_service_), result.confidence,
profile_));
path, result.confidence, profile_));
// Add suggestion chip file results
if (app_list_features::IsSuggestedFilesEnabled()) {
results.emplace_back(std::make_unique<DriveQuickAccessChipResult>(
path, result.confidence, profile_));
}
}
UMA_HISTOGRAM_TIMES("Apps.AppList.DriveQuickAccessProvider.Latency",
base::TimeTicks::Now() - query_start_time_);
......
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/app_list/search/file_chip_result.h"
#include <utility>
#include "ash/public/cpp/app_list/app_list_metrics.h"
#include "chrome/browser/profiles/profile.h"
namespace app_list {
namespace {
const char kFileChipResultPrefix[] = "filechip://";
}
FileChipResult::FileChipResult(const base::FilePath& filepath,
const float relevance,
Profile* profile)
: ZeroStateFileResult(filepath, relevance, profile) {
set_id(kFileChipResultPrefix + filepath.value());
SetResultType(ResultType::kFileChip);
// TODO(crbug.com/1034842) Add line:
// SetDisplayType(DisplayType::kChip);
// to replace DisplayType and DisplayLocation setting
// once CL:1980331 merged
SetDisplayType(DisplayType::kNone);
SetDisplayLocation(DisplayLocation::kSuggestionChipContainer);
}
} // namespace app_list
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_APP_LIST_SEARCH_FILE_CHIP_RESULT_H_
#define CHROME_BROWSER_UI_APP_LIST_SEARCH_FILE_CHIP_RESULT_H_
#include "chrome/browser/ui/app_list/search/zero_state_file_result.h"
namespace app_list {
// A search result for a local file to be shown in the suggestion chips.
// This inherits from ZeroStateFileResult because most of its logic is
// identical, but it is important they are different types for ranking
// purposes.
class FileChipResult : public ZeroStateFileResult {
public:
FileChipResult(const base::FilePath& filepath,
float relevance,
Profile* profile);
};
} // namespace app_list
#endif // CHROME_BROWSER_UI_APP_LIST_SEARCH_FILE_CHIP_RESULT_H_
......@@ -33,8 +33,10 @@ RankingItemType RankingItemTypeFromSearchResult(
return RankingItemType::kIgnored;
case ash::AppListSearchResultType::kArcAppShortcut:
return RankingItemType::kArcAppShortcut;
case ash::AppListSearchResultType::kFileChip:
case ash::AppListSearchResultType::kZeroStateFile:
return RankingItemType::kZeroStateFile;
case ash::AppListSearchResultType::kDriveQuickAccessChip:
case ash::AppListSearchResultType::kDriveQuickAccess:
return RankingItemType::kDriveQuickAccess;
}
......
......@@ -6,6 +6,7 @@
#include <string>
#include "ash/public/cpp/app_list/app_list_features.h"
#include "base/bind.h"
#include "base/files/file_util.h"
#include "base/metrics/histogram_macros.h"
......@@ -15,6 +16,7 @@
#include "base/threading/scoped_blocking_call.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile.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/zero_state_file_result.h"
......@@ -104,7 +106,13 @@ void ZeroStateFileProvider::SetSearchResults(
for (const auto& filepath_score : results.first) {
new_results.emplace_back(std::make_unique<ZeroStateFileResult>(
filepath_score.first, filepath_score.second, profile_));
// Add suggestion chip file results
if (app_list_features::IsSuggestedFilesEnabled()) {
new_results.emplace_back(std::make_unique<FileChipResult>(
filepath_score.first, filepath_score.second, profile_));
}
}
UMA_HISTOGRAM_TIMES("Apps.AppList.ZeroStateFileProvider.Latency",
base::TimeTicks::Now() - query_start_time_);
SwapResults(&new_results);
......
......@@ -62,6 +62,7 @@ ZeroStateFileResult::ZeroStateFileResult(const base::FilePath& filepath,
base::i18n::SanitizeUserSuppliedString(&sanitized_name);
SetDetails(sanitized_name);
SetIcon(GetIconForLocalFilePath(filepath));
SetChipIcon(GetIconForLocalFilePath(filepath));
}
ZeroStateFileResult::~ZeroStateFileResult() = default;
......
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