Chromium Code Reviews| Index: ui/app_list/views/start_page_view.cc | 
| diff --git a/ui/app_list/views/start_page_view.cc b/ui/app_list/views/start_page_view.cc | 
| index b41a9ffa2adf091ece93b7022b5e30577f9f7c79..67e920023e3a285aba1002d0fc0abf4a3d9557d8 100644 | 
| --- a/ui/app_list/views/start_page_view.cc | 
| +++ b/ui/app_list/views/start_page_view.cc | 
| @@ -13,8 +13,10 @@ | 
| #include "base/strings/utf_string_conversions.h" | 
| #include "ui/accessibility/ax_node_data.h" | 
| #include "ui/app_list/app_list_constants.h" | 
| +#include "ui/app_list/app_list_features.h" | 
| #include "ui/app_list/app_list_item.h" | 
| #include "ui/app_list/app_list_model.h" | 
| +#include "ui/app_list/app_list_switches.h" | 
| #include "ui/app_list/app_list_view_delegate.h" | 
| #include "ui/app_list/search_result.h" | 
| #include "ui/app_list/views/all_apps_tile_item_view.h" | 
| @@ -42,6 +44,7 @@ namespace { | 
| constexpr int kInstantContainerSpacing = 24; | 
| constexpr int kSearchBoxAndTilesSpacing = 35; | 
| constexpr int kStartPageSearchBoxWidth = 480; | 
| +constexpr int kStartPageSearchBoxWidthFullscreen = 544; | 
| // WebView constants. | 
| constexpr int kWebViewWidth = 700; | 
| @@ -51,9 +54,32 @@ constexpr int kWebViewHeight = 224; | 
| constexpr int kTileSpacing = 7; | 
| constexpr int kNumStartPageTilesCols = 5; | 
| constexpr int kTilesHorizontalMarginLeft = 145; | 
| +constexpr int kCenterColumnOfStartPageAppGrid = 3; | 
| constexpr int kLauncherPageBackgroundWidth = 400; | 
| +// An invisible placeholder view which fills the space for the search box view | 
| +// in a box layout. The search box view itself is a child of the AppListView | 
| +// (because it is visible on many different pages). | 
| +class SearchBoxSpacerView : public views::View { | 
| + public: | 
| + explicit SearchBoxSpacerView(const gfx::Size& search_box_size) | 
| + : size_(features::IsFullscreenAppListEnabled() | 
| + ? kStartPageSearchBoxWidthFullscreen | 
| + : kStartPageSearchBoxWidth, | 
| + search_box_size.height()) {} | 
| + | 
| + ~SearchBoxSpacerView() override {} | 
| + | 
| + // Overridden from views::View: | 
| + gfx::Size GetPreferredSize() const override { return size_; } | 
| + | 
| + private: | 
| + gfx::Size size_; | 
| + | 
| + DISALLOW_COPY_AND_ASSIGN(SearchBoxSpacerView); | 
| +}; | 
| + | 
| } // namespace | 
| class CustomLauncherPageBackgroundView : public views::View { | 
| @@ -137,7 +163,10 @@ StartPageView::StartPageTilesContainer::StartPageTilesContainer( | 
| views::Background::CreateSolidBackground(kLabelBackgroundColor)); | 
| all_apps_button_->SetHoverStyle(TileItemView::HOVER_STYLE_ANIMATE_SHADOW); | 
| all_apps_button_->SetParentBackgroundColor(kLabelBackgroundColor); | 
| - CreateAppsGrid(kNumStartPageTiles); | 
| + | 
| + CreateAppsGrid(features::IsFullscreenAppListEnabled() | 
| + ? fullscreen_constants::kNumStartPageTiles | 
| + : kNumStartPageTiles); | 
| } | 
| StartPageView::StartPageTilesContainer::~StartPageTilesContainer() { | 
| @@ -171,7 +200,11 @@ int StartPageView::StartPageTilesContainer::DoUpdate() { | 
| delete search_result_tile_views_[i]; | 
| search_result_tile_views_.clear(); | 
| RemoveChildView(all_apps_button_); | 
| - CreateAppsGrid(std::min(kNumStartPageTiles, display_results.size())); | 
| + | 
| + CreateAppsGrid( | 
| + features::IsFullscreenAppListEnabled() | 
| + ? fullscreen_constants::kNumStartPageTiles | 
| + : std::min<int>(kNumStartPageTiles, display_results.size())); | 
| 
 
vadimt
2017/05/26 17:58:55
It really doesn't work w/o <int>?
 
newcomer
2017/05/26 23:20:22
It works without <int>, I just left it in after de
 
 | 
| } | 
| // Update the tile item results. | 
| @@ -242,10 +275,19 @@ void StartPageView::StartPageTilesContainer::CreateAppsGrid(int apps_num) { | 
| search_result_tile_views_.emplace_back(tile_item); | 
| } | 
| - // Also add a special "all apps" button to the end of the container. | 
| all_apps_button_->UpdateIcon(); | 
| - if (i % kNumStartPageTilesCols == 0) | 
| + if (features::IsFullscreenAppListEnabled()) { | 
| + // Also add a special "all apps" button to the middle of the next row of the | 
| + // container. | 
| tiles_layout_manager->StartRow(0, 0); | 
| + tiles_layout_manager->SkipColumns(kCenterColumnOfStartPageAppGrid); | 
| + } else { | 
| + // Also add a special "all apps" button to the end of the next row of the | 
| + // container. | 
| + if (i % kNumStartPageTilesCols == 0) | 
| + tiles_layout_manager->StartRow(0, 0); | 
| + } | 
| + | 
| tiles_layout_manager->AddView(all_apps_button_); | 
| AddChildView(all_apps_button_); | 
| } | 
| @@ -253,7 +295,8 @@ void StartPageView::StartPageTilesContainer::CreateAppsGrid(int apps_num) { | 
| //////////////////////////////////////////////////////////////////////////////// | 
| // StartPageView implementation: | 
| StartPageView::StartPageView(AppListMainView* app_list_main_view, | 
| - AppListViewDelegate* view_delegate) | 
| + AppListViewDelegate* view_delegate, | 
| + AppListView* app_list_view) | 
| : app_list_main_view_(app_list_main_view), | 
| view_delegate_(view_delegate), | 
| search_box_spacer_view_(new View()), | 
| @@ -262,7 +305,8 @@ StartPageView::StartPageView(AppListMainView* app_list_main_view, | 
| view_delegate_->GetModel()->custom_launcher_page_name())), | 
| tiles_container_(new StartPageTilesContainer( | 
| app_list_main_view->contents_view(), | 
| - new AllAppsTileItemView(app_list_main_view_->contents_view()), | 
| + new AllAppsTileItemView(app_list_main_view_->contents_view(), | 
| + app_list_view), | 
| view_delegate)) { | 
| search_box_spacer_view_->SetPreferredSize(gfx::Size( | 
| kStartPageSearchBoxWidth, | 
| @@ -274,7 +318,6 @@ StartPageView::StartPageView(AppListMainView* app_list_main_view, | 
| // The view containing the start page tiles. | 
| AddChildView(tiles_container_); | 
| - | 
| AddChildView(custom_launcher_page_background_); | 
| tiles_container_->SetResults(view_delegate_->GetModel()->results()); | 
| @@ -294,11 +337,16 @@ void StartPageView::InitInstantContainer() { | 
| views::BoxLayout::CROSS_AXIS_ALIGNMENT_CENTER); | 
| instant_container_->SetLayoutManager(instant_layout_manager); | 
| - views::View* web_view = view_delegate_->CreateStartPageWebView( | 
| - gfx::Size(kWebViewWidth, kWebViewHeight)); | 
| - if (web_view) { | 
| - web_view->SetFocusBehavior(FocusBehavior::NEVER); | 
| - instant_container_->AddChildView(web_view); | 
| + // Create the view for the Google Doodle if the fullscreen launcher is not | 
| + // enabled. | 
| + if (!features::IsFullscreenAppListEnabled()) { | 
| + views::View* web_view = view_delegate_->CreateStartPageWebView( | 
| + gfx::Size(kWebViewWidth, kWebViewHeight)); | 
| + | 
| + if (web_view) { | 
| + web_view->SetFocusBehavior(FocusBehavior::NEVER); | 
| + instant_container_->AddChildView(web_view); | 
| + } | 
| } | 
| instant_container_->AddChildView(search_box_spacer_view_); |