Commit cc6e6473 authored by calamity@chromium.org's avatar calamity@chromium.org

Add a skeleton Start Page to the experimental app list.

This CL adds a basic version of a start page to the experimental app list.
This page contains a WebView that displays the Google Logo and a grey bar
which are currently only placeholders.

This CL also modifies the StartPage WebUI to have the google logo.

BUG=349727

Review URL: https://codereview.chromium.org/186483004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269752 0039d316-1c4b-4281-b951-d872f2087c98
parent 71d3e7cb
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
html, html,
body, body,
#start-page { #start-page {
background-color: rgb(245, 245, 245); background-color: rgb(251, 251, 251);
height: 100%; height: 100%;
margin: 0; margin: 0;
overflow: hidden; overflow: hidden;
...@@ -23,4 +23,13 @@ body, ...@@ -23,4 +23,13 @@ body,
padding: 10px; padding: 10px;
} }
#logo {
background-image: -webkit-image-set(
url('chrome://theme/IDR_LOCAL_NTP_IMAGES_LOGO_PNG') 1x,
url('chrome://theme/IDR_LOCAL_NTP_IMAGES_LOGO_PNG@2x') 2x);
height: 95px;
margin: auto;
width: 269px;
}
<include src="recommended_apps.css"/> <include src="recommended_apps.css"/>
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
</head> </head>
<body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize"> <body i18n-values=".style.fontFamily:fontfamily;.style.fontSize:fontsize">
<div id="logo"></div>
<div id="start-page"></div> <div id="start-page"></div>
<script src="chrome://resources/js/i18n_template2.js"></script> <script src="chrome://resources/js/i18n_template2.js"></script>
</body> </body>
......
...@@ -20,8 +20,8 @@ namespace app_list { ...@@ -20,8 +20,8 @@ namespace app_list {
StartPageService* StartPageServiceFactory::GetForProfile(Profile* profile) { StartPageService* StartPageServiceFactory::GetForProfile(Profile* profile) {
if (!app_list::switches::IsExperimentalAppListEnabled() && if (!app_list::switches::IsExperimentalAppListEnabled() &&
!app_list::switches::IsVoiceSearchEnabled()) { !app_list::switches::IsVoiceSearchEnabled()) {
return NULL; return NULL;
} }
return static_cast<StartPageService*>( return static_cast<StartPageService*>(
GetInstance()->GetServiceForBrowserContext(profile, true)); GetInstance()->GetServiceForBrowserContext(profile, true));
......
...@@ -136,6 +136,8 @@ ...@@ -136,6 +136,8 @@
'views/signin_view.h', 'views/signin_view.h',
'views/speech_view.cc', 'views/speech_view.cc',
'views/speech_view.h', 'views/speech_view.h',
'views/start_page_view.cc',
'views/start_page_view.h',
'views/top_icon_animation_view.cc', 'views/top_icon_animation_view.cc',
'views/top_icon_animation_view.h', 'views/top_icon_animation_view.h',
], ],
......
...@@ -167,6 +167,17 @@ void AppListMainView::ModelChanged() { ...@@ -167,6 +167,17 @@ void AppListMainView::ModelChanged() {
Layout(); Layout();
} }
void AppListMainView::OnContentsViewShowStateChanged() {
search_box_view_->SetVisible(contents_view_->show_state() !=
ContentsView::SHOW_START_PAGE);
}
void AppListMainView::OnStartPageSearchButtonPressed() {
search_box_view_->SetVisible(true);
search_box_view_->search_box()->SetText(base::string16());
search_box_view_->RequestFocus();
}
void AppListMainView::SetDragAndDropHostOfCurrentAppList( void AppListMainView::SetDragAndDropHostOfCurrentAppList(
ApplicationDragAndDropHost* drag_and_drop_host) { ApplicationDragAndDropHost* drag_and_drop_host) {
contents_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host); contents_view_->SetDragAndDropHostOfCurrentAppList(drag_and_drop_host);
......
...@@ -53,6 +53,10 @@ class APP_LIST_EXPORT AppListMainView : public views::View, ...@@ -53,6 +53,10 @@ class APP_LIST_EXPORT AppListMainView : public views::View,
void ModelChanged(); void ModelChanged();
void OnContentsViewShowStateChanged();
void OnStartPageSearchButtonPressed();
SearchBoxView* search_box_view() const { return search_box_view_; } SearchBoxView* search_box_view() const { return search_box_view_; }
// If |drag_and_drop_host| is not NULL it will be called upon drag and drop // If |drag_and_drop_host| is not NULL it will be called upon drag and drop
......
...@@ -27,8 +27,7 @@ ContentsSwitcherView::ContentsSwitcherView(ContentsView* contents_view) ...@@ -27,8 +27,7 @@ ContentsSwitcherView::ContentsSwitcherView(ContentsView* contents_view)
buttons_->SetLayoutManager(new views::BoxLayout( buttons_->SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing)); views::BoxLayout::kHorizontal, 0, 0, kButtonSpacing));
AddSwitcherButton(IDR_APP_LIST_SEARCH_ICON, AddSwitcherButton(IDR_APP_LIST_SEARCH_ICON, ContentsView::SHOW_START_PAGE);
ContentsView::SHOW_SEARCH_RESULTS);
AddSwitcherButton(IDR_APP_LIST_APPS_ICON, ContentsView::SHOW_APPS); AddSwitcherButton(IDR_APP_LIST_APPS_ICON, ContentsView::SHOW_APPS);
} }
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include "ui/app_list/views/apps_container_view.h" #include "ui/app_list/views/apps_container_view.h"
#include "ui/app_list/views/apps_grid_view.h" #include "ui/app_list/views/apps_grid_view.h"
#include "ui/app_list/views/search_result_list_view.h" #include "ui/app_list/views/search_result_list_view.h"
#include "ui/app_list/views/start_page_view.h"
#include "ui/events/event.h" #include "ui/events/event.h"
#include "ui/views/animation/bounds_animator.h" #include "ui/views/animation/bounds_animator.h"
#include "ui/views/view_model.h" #include "ui/views/view_model.h"
...@@ -28,6 +29,7 @@ namespace { ...@@ -28,6 +29,7 @@ namespace {
// Indexes of interesting views in ViewModel of ContentsView. // Indexes of interesting views in ViewModel of ContentsView.
const int kIndexAppsContainer = 0; const int kIndexAppsContainer = 0;
const int kIndexSearchResults = 1; const int kIndexSearchResults = 1;
const int kIndexStartPage = 2;
const int kMinMouseWheelToSwitchPage = 20; const int kMinMouseWheelToSwitchPage = 20;
const int kMinScrollToSwitchPage = 20; const int kMinScrollToSwitchPage = 20;
...@@ -44,6 +46,10 @@ SearchResultListView* GetSearchResultListView(views::ViewModel* model) { ...@@ -44,6 +46,10 @@ SearchResultListView* GetSearchResultListView(views::ViewModel* model) {
model->view_at(kIndexSearchResults)); model->view_at(kIndexSearchResults));
} }
StartPageView* GetStartPageView(views::ViewModel* model) {
return static_cast<StartPageView*>(model->view_at(kIndexStartPage));
}
} // namespace } // namespace
ContentsView::ContentsView(AppListMainView* app_list_main_view, ContentsView::ContentsView(AppListMainView* app_list_main_view,
...@@ -52,6 +58,7 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view, ...@@ -52,6 +58,7 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view,
AppListViewDelegate* view_delegate) AppListViewDelegate* view_delegate)
: show_state_(SHOW_APPS), : show_state_(SHOW_APPS),
pagination_model_(pagination_model), pagination_model_(pagination_model),
app_list_main_view_(app_list_main_view),
view_model_(new views::ViewModel), view_model_(new views::ViewModel),
bounds_animator_(new views::BoundsAnimator(this)) { bounds_animator_(new views::BoundsAnimator(this)) {
DCHECK(model); DCHECK(model);
...@@ -69,6 +76,15 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view, ...@@ -69,6 +76,15 @@ ContentsView::ContentsView(AppListMainView* app_list_main_view,
AddChildView(search_results_view); AddChildView(search_results_view);
view_model_->Add(search_results_view, kIndexSearchResults); view_model_->Add(search_results_view, kIndexSearchResults);
if (app_list::switches::IsExperimentalAppListEnabled()) {
content::WebContents* start_page_contents =
view_delegate->GetStartPageContents();
StartPageView* start_page_view =
new StartPageView(app_list_main_view, start_page_contents);
AddChildView(start_page_view);
view_model_->Add(start_page_view, kIndexStartPage);
}
GetSearchResultListView(view_model_.get())->SetResults(model->results()); GetSearchResultListView(view_model_.get())->SetResults(model->results());
} }
...@@ -107,6 +123,12 @@ void ContentsView::ShowStateChanged() { ...@@ -107,6 +123,12 @@ void ContentsView::ShowStateChanged() {
results_view->SetSelectedIndex(0); results_view->SetSelectedIndex(0);
results_view->UpdateAutoLaunchState(); results_view->UpdateAutoLaunchState();
// Notify parent AppListMainView of show state change.
app_list_main_view_->OnContentsViewShowStateChanged();
if (show_state_ == SHOW_START_PAGE)
GetStartPageView(view_model_.get())->Reset();
AnimateToIdealBounds(); AnimateToIdealBounds();
} }
...@@ -124,6 +146,9 @@ void ContentsView::CalculateIdealBounds() { ...@@ -124,6 +146,9 @@ void ContentsView::CalculateIdealBounds() {
case SHOW_SEARCH_RESULTS: case SHOW_SEARCH_RESULTS:
incoming_view_index = kIndexSearchResults; incoming_view_index = kIndexSearchResults;
break; break;
case SHOW_START_PAGE:
incoming_view_index = kIndexStartPage;
break;
default: default:
NOTREACHED(); NOTREACHED();
} }
...@@ -206,6 +231,8 @@ bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) { ...@@ -206,6 +231,8 @@ bool ContentsView::OnKeyPressed(const ui::KeyEvent& event) {
return GetAppsContainerView(view_model_.get())->OnKeyPressed(event); return GetAppsContainerView(view_model_.get())->OnKeyPressed(event);
case SHOW_SEARCH_RESULTS: case SHOW_SEARCH_RESULTS:
return GetSearchResultListView(view_model_.get())->OnKeyPressed(event); return GetSearchResultListView(view_model_.get())->OnKeyPressed(event);
case SHOW_START_PAGE:
return GetStartPageView(view_model_.get())->OnKeyPressed(event);
default: default:
NOTREACHED() << "Unknown show state " << show_state_; NOTREACHED() << "Unknown show state " << show_state_;
} }
......
...@@ -29,6 +29,7 @@ class AppListModel; ...@@ -29,6 +29,7 @@ class AppListModel;
class AppListViewDelegate; class AppListViewDelegate;
class AppsContainerView; class AppsContainerView;
class PaginationModel; class PaginationModel;
class StartPageView;
// A view to manage sub views under the search box (apps grid view + page // A view to manage sub views under the search box (apps grid view + page
// switcher and search results). The two sets of sub views are mutually // switcher and search results). The two sets of sub views are mutually
...@@ -36,7 +37,11 @@ class PaginationModel; ...@@ -36,7 +37,11 @@ class PaginationModel;
// and animates the transition between show states. // and animates the transition between show states.
class ContentsView : public views::View { class ContentsView : public views::View {
public: public:
enum ShowState { SHOW_APPS, SHOW_SEARCH_RESULTS, }; enum ShowState {
SHOW_APPS,
SHOW_SEARCH_RESULTS,
SHOW_START_PAGE,
};
ContentsView(AppListMainView* app_list_main_view, ContentsView(AppListMainView* app_list_main_view,
PaginationModel* pagination_model, PaginationModel* pagination_model,
...@@ -62,6 +67,8 @@ class ContentsView : public views::View { ...@@ -62,6 +67,8 @@ class ContentsView : public views::View {
AppsContainerView* apps_container_view() { return apps_container_view_; } AppsContainerView* apps_container_view() { return apps_container_view_; }
ShowState show_state() const { return show_state_; }
// Overridden from views::View: // Overridden from views::View:
virtual gfx::Size GetPreferredSize() OVERRIDE; virtual gfx::Size GetPreferredSize() OVERRIDE;
virtual void Layout() OVERRIDE; virtual void Layout() OVERRIDE;
...@@ -83,6 +90,7 @@ class ContentsView : public views::View { ...@@ -83,6 +90,7 @@ class ContentsView : public views::View {
PaginationModel* pagination_model_; // Owned by AppListController. PaginationModel* pagination_model_; // Owned by AppListController.
AppsContainerView* apps_container_view_; // Owned by the views hierarchy. AppsContainerView* apps_container_view_; // Owned by the views hierarchy.
AppListMainView* app_list_main_view_; // Parent view, owns this.
scoped_ptr<views::ViewModel> view_model_; scoped_ptr<views::ViewModel> view_model_;
scoped_ptr<views::BoundsAnimator> bounds_animator_; scoped_ptr<views::BoundsAnimator> bounds_animator_;
......
// Copyright 2014 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 "ui/app_list/views/start_page_view.h"
#include "content/public/browser/web_contents.h"
#include "ui/app_list/app_list_constants.h"
#include "ui/app_list/views/app_list_main_view.h"
#include "ui/gfx/canvas.h"
#include "ui/views/controls/button/custom_button.h"
#include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/box_layout.h"
namespace app_list {
namespace {
const int kTopMargin = 20;
const int kWebViewWidth = 200;
const int kWebViewHeight = 95;
const int kInstantContainerSpacing = 15;
const int kBarPlaceholderWidth = 350;
const int kBarPlaceholderHeight = 30;
// A button that is the placeholder for the search bar in the start page view.
class BarPlaceholderButton : public views::CustomButton {
public:
explicit BarPlaceholderButton(views::ButtonListener* listener)
: views::CustomButton(listener) {}
virtual ~BarPlaceholderButton() {}
// Overridden from views::View:
virtual gfx::Size GetPreferredSize() OVERRIDE {
return gfx::Size(kBarPlaceholderWidth, kBarPlaceholderHeight);
}
virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
PaintButton(
canvas,
state() == STATE_HOVERED ? kPagerHoverColor : kPagerNormalColor);
}
private:
// Paints a rectangular button.
void PaintButton(gfx::Canvas* canvas, SkColor base_color) {
gfx::Rect rect(GetContentsBounds());
rect.ClampToCenteredSize(
gfx::Size(kBarPlaceholderWidth, kBarPlaceholderHeight));
SkPaint paint;
paint.setAntiAlias(true);
paint.setStyle(SkPaint::kFill_Style);
paint.setColor(base_color);
canvas->DrawRect(rect, paint);
}
DISALLOW_COPY_AND_ASSIGN(BarPlaceholderButton);
};
} // namespace
StartPageView::StartPageView(AppListMainView* app_list_main_view,
content::WebContents* start_page_web_contents)
: app_list_main_view_(app_list_main_view),
instant_container_(new views::View) {
AddChildView(instant_container_);
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
instant_container_->SetLayoutManager(new views::BoxLayout(
views::BoxLayout::kVertical, 0, kTopMargin, kInstantContainerSpacing));
views::WebView* web_view =
new views::WebView(start_page_web_contents->GetBrowserContext());
web_view->SetPreferredSize(gfx::Size(kWebViewWidth, kWebViewHeight));
web_view->SetWebContents(start_page_web_contents);
instant_container_->AddChildView(web_view);
instant_container_->AddChildView(new BarPlaceholderButton(this));
}
StartPageView::~StartPageView() {
}
void StartPageView::Reset() {
instant_container_->SetVisible(true);
}
void StartPageView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
app_list_main_view_->OnStartPageSearchButtonPressed();
instant_container_->SetVisible(false);
}
} // namespace app_list
// Copyright 2014 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 UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_
#define UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_
#include "base/basictypes.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/view.h"
namespace content {
class WebContents;
}
namespace app_list {
class AppListMainView;
// The start page for the experimental app list.
class StartPageView : public views::View, public views::ButtonListener {
public:
StartPageView(AppListMainView* app_list_main_view,
content::WebContents* start_page_web_contents);
virtual ~StartPageView();
void Reset();
private:
// Overridden from views::ButtonListener:
virtual void ButtonPressed(views::Button* sender,
const ui::Event& event) OVERRIDE;
// The parent view of ContentsView which is the parent of this view.
AppListMainView* app_list_main_view_;
views::View* instant_container_; // Owned by views hierarchy.
DISALLOW_COPY_AND_ASSIGN(StartPageView);
};
} // namespace app_list
#endif // UI_APP_LIST_VIEWS_START_PAGE_VIEW_H_
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