summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcalamity <calamity@chromium.org>2014-12-14 21:26:12 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-15 05:26:27 +0000
commitc2a0964bf58348edcbd4cbb074336e807ba22a51 (patch)
treed0935e1957a9fec25e8264c1fbcd97c9bff30e09
parentc81147dfd02bfd04282dbbba5af8fc5918dc9380 (diff)
downloadchromium_src-c2a0964bf58348edcbd4cbb074336e807ba22a51.zip
chromium_src-c2a0964bf58348edcbd4cbb074336e807ba22a51.tar.gz
chromium_src-c2a0964bf58348edcbd4cbb074336e807ba22a51.tar.bz2
Make app list recommendations into their own DisplayType.
This CL makes the app list recommendations their own SearchResult::DisplayType. This prevents recommendations from flashing up for an instant when the search query is deleted. BUG=440051 Review URL: https://codereview.chromium.org/796793002 Cr-Commit-Position: refs/heads/master@{#308316}
-rw-r--r--chrome/browser/ui/app_list/search/app_result.cc9
-rw-r--r--chrome/browser/ui/app_list/search/app_result.h3
-rw-r--r--chrome/browser/ui/app_list/search/app_search_provider.cc4
-rw-r--r--chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc2
-rw-r--r--ui/app_list/search_result.cc1
-rw-r--r--ui/app_list/search_result.h1
-rw-r--r--ui/app_list/views/app_list_view_unittest.cc16
-rw-r--r--ui/app_list/views/start_page_view.cc2
8 files changed, 22 insertions, 16 deletions
diff --git a/chrome/browser/ui/app_list/search/app_result.cc b/chrome/browser/ui/app_list/search/app_result.cc
index 435dcf6..21f31c0 100644
--- a/chrome/browser/ui/app_list/search/app_result.cc
+++ b/chrome/browser/ui/app_list/search/app_result.cc
@@ -32,14 +32,15 @@ namespace app_list {
AppResult::AppResult(Profile* profile,
const std::string& app_id,
- AppListControllerDelegate* controller)
+ AppListControllerDelegate* controller,
+ bool is_recommendation)
: profile_(profile),
app_id_(app_id),
controller_(controller),
extension_registry_(NULL) {
set_id(extensions::Extension::GetBaseURLFromExtensionId(app_id_).spec());
if (app_list::switches::IsExperimentalAppListEnabled())
- set_display_type(DISPLAY_TILE);
+ set_display_type(is_recommendation ? DISPLAY_RECOMMENDATION : DISPLAY_TILE);
const extensions::Extension* extension =
extensions::ExtensionSystem::Get(profile_)->extension_service()
@@ -123,7 +124,9 @@ void AppResult::Open(int event_flags) {
}
scoped_ptr<SearchResult> AppResult::Duplicate() {
- scoped_ptr<SearchResult> copy(new AppResult(profile_, app_id_, controller_));
+ scoped_ptr<SearchResult> copy(
+ new AppResult(profile_, app_id_, controller_,
+ display_type() == DISPLAY_RECOMMENDATION));
copy->set_title(title());
copy->set_title_tags(title_tags());
diff --git a/chrome/browser/ui/app_list/search/app_result.h b/chrome/browser/ui/app_list/search/app_result.h
index 17c9e63..5e05afb 100644
--- a/chrome/browser/ui/app_list/search/app_result.h
+++ b/chrome/browser/ui/app_list/search/app_result.h
@@ -40,7 +40,8 @@ class AppResult : public SearchResult,
public:
AppResult(Profile* profile,
const std::string& app_id,
- AppListControllerDelegate* controller);
+ AppListControllerDelegate* controller,
+ bool is_recommendation);
~AppResult() override;
void UpdateFromMatch(const TokenizedString& title,
diff --git a/chrome/browser/ui/app_list/search/app_search_provider.cc b/chrome/browser/ui/app_list/search/app_search_provider.cc
index 02f2667..a7d7fa8 100644
--- a/chrome/browser/ui/app_list/search/app_search_provider.cc
+++ b/chrome/browser/ui/app_list/search/app_search_provider.cc
@@ -85,8 +85,8 @@ void AppSearchProvider::UpdateResults() {
for (Apps::const_iterator app_it = apps_.begin();
app_it != apps_.end();
++app_it) {
- scoped_ptr<AppResult> result(
- new AppResult(profile_, (*app_it)->app_id(), list_controller_));
+ scoped_ptr<AppResult> result(new AppResult(
+ profile_, (*app_it)->app_id(), list_controller_, show_recommendations));
if (show_recommendations) {
result->set_title((*app_it)->indexed_name().text());
result->UpdateFromLastLaunched(clock_->Now(),
diff --git a/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc b/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc
index c4edc11..d7f862f 100644
--- a/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc
+++ b/chrome/browser/ui/app_list/search/suggestions/url_suggestion_result.cc
@@ -35,7 +35,7 @@ URLSuggestionResult::URLSuggestionResult(
weak_ptr_factory_(this) {
set_id(suggestion_.url());
set_title(base::UTF8ToUTF16(suggestion_.title()));
- set_display_type(DISPLAY_TILE);
+ set_display_type(DISPLAY_RECOMMENDATION);
UpdateIcon();
}
diff --git a/ui/app_list/search_result.cc b/ui/app_list/search_result.cc
index 8c7b66e..9f0870c 100644
--- a/ui/app_list/search_result.cc
+++ b/ui/app_list/search_result.cc
@@ -72,6 +72,7 @@ void SearchResult::SetPercentDownloaded(int percent_downloaded) {
int SearchResult::GetPreferredIconDimension() const {
switch (display_type_) {
+ case DISPLAY_RECOMMENDATION: // Falls through.
case DISPLAY_TILE:
return kTileIconSize;
case DISPLAY_LIST:
diff --git a/ui/app_list/search_result.h b/ui/app_list/search_result.h
index f2894bb..95bc5e5 100644
--- a/ui/app_list/search_result.h
+++ b/ui/app_list/search_result.h
@@ -32,6 +32,7 @@ class APP_LIST_EXPORT SearchResult {
enum DisplayType {
DISPLAY_LIST,
DISPLAY_TILE,
+ DISPLAY_RECOMMENDATION,
DISPLAY_NONE,
};
diff --git a/ui/app_list/views/app_list_view_unittest.cc b/ui/app_list/views/app_list_view_unittest.cc
index 03f81d0..4fc6595 100644
--- a/ui/app_list/views/app_list_view_unittest.cc
+++ b/ui/app_list/views/app_list_view_unittest.cc
@@ -75,13 +75,13 @@ void SimulateClick(views::View* view) {
// Choose a set that is 3 regular app list pages and 2 landscape app list pages.
const int kInitialItems = 34;
-class TestTileSearchResult : public TestSearchResult {
+class TestStartPageSearchResult : public TestSearchResult {
public:
- TestTileSearchResult() { set_display_type(DISPLAY_TILE); }
- ~TestTileSearchResult() override {}
+ TestStartPageSearchResult() { set_display_type(DISPLAY_RECOMMENDATION); }
+ ~TestStartPageSearchResult() override {}
private:
- DISALLOW_COPY_AND_ASSIGN(TestTileSearchResult);
+ DISALLOW_COPY_AND_ASSIGN(TestStartPageSearchResult);
};
// Allows the same tests to run with different contexts: either an Ash-style
@@ -466,7 +466,7 @@ void AppListViewTestContext::RunStartPageTest() {
EXPECT_EQ(view_size.ToString(), view_->GetPreferredSize().ToString());
// Check tiles hide and show on deletion and addition.
- model->results()->Add(new TestTileSearchResult());
+ model->results()->Add(new TestStartPageSearchResult());
start_page_view->UpdateForTesting();
EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views()));
model->results()->DeleteAll();
@@ -555,15 +555,15 @@ void AppListViewTestContext::RunProfileChangeTest() {
EXPECT_EQ(NULL, start_page_view);
// New model updates should be processed by the start page view.
- delegate_->GetTestModel()->results()->Add(new TestTileSearchResult());
+ delegate_->GetTestModel()->results()->Add(new TestStartPageSearchResult());
if (test_type_ == EXPERIMENTAL) {
start_page_view->UpdateForTesting();
EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views()));
}
// Old model updates should be ignored.
- original_test_model->results()->Add(new TestTileSearchResult());
- original_test_model->results()->Add(new TestTileSearchResult());
+ original_test_model->results()->Add(new TestStartPageSearchResult());
+ original_test_model->results()->Add(new TestStartPageSearchResult());
if (test_type_ == EXPERIMENTAL) {
start_page_view->UpdateForTesting();
EXPECT_EQ(1u, GetVisibleViews(start_page_view->tile_views()));
diff --git a/ui/app_list/views/start_page_view.cc b/ui/app_list/views/start_page_view.cc
index e9ab1de..26656b8 100644
--- a/ui/app_list/views/start_page_view.cc
+++ b/ui/app_list/views/start_page_view.cc
@@ -235,7 +235,7 @@ void StartPageView::UpdateCustomPageClickzoneVisibility() {
int StartPageView::Update() {
std::vector<SearchResult*> display_results =
AppListModel::FilterSearchResultsByDisplayType(
- results(), SearchResult::DISPLAY_TILE, kNumStartPageTiles);
+ results(), SearchResult::DISPLAY_RECOMMENDATION, kNumStartPageTiles);
// Update the tile item results.
for (size_t i = 0; i < search_result_tile_views_.size(); ++i) {