Commit 3dafa94b authored by mukai@chromium.org's avatar mukai@chromium.org

Introduce state to home card.

This is a preparation of crbug.com/387227.

BUG=387227
R=oshima@chromium.org
TEST=manually check for no regression

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282686 0039d316-1c4b-4281-b951-d872f2087c98
parent 86ee045d
......@@ -93,6 +93,7 @@ class HomeCardImpl : public HomeCard, public AcceleratorHandler {
void InstallAccelerators();
// Overridden from HomeCard:
virtual void SetState(State state) OVERRIDE;
virtual void RegisterSearchProvider(
app_list::SearchProvider* search_provider) OVERRIDE;
virtual void UpdateVirtualKeyboardBounds(
......@@ -103,15 +104,17 @@ class HomeCardImpl : public HomeCard, public AcceleratorHandler {
virtual bool OnAcceleratorFired(int command_id,
const ui::Accelerator& accelerator) OVERRIDE {
DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id);
if (home_card_widget_->IsVisible())
home_card_widget_->Hide();
if (state_ == HIDDEN)
SetState(VISIBLE_CENTERED);
else
home_card_widget_->Show();
SetState(HIDDEN);
return true;
}
scoped_ptr<AppModelBuilder> model_builder_;
HomeCard::State state_;
views::Widget* home_card_widget_;
AppListViewDelegate* view_delegate_;
HomeCardLayoutManager* layout_manager_;
......@@ -125,6 +128,7 @@ class HomeCardImpl : public HomeCard, public AcceleratorHandler {
HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder)
: model_builder_(model_builder),
state_(HIDDEN),
home_card_widget_(NULL),
layout_manager_(NULL) {
DCHECK(!instance);
......@@ -138,6 +142,14 @@ HomeCardImpl::~HomeCardImpl() {
instance = NULL;
}
void HomeCardImpl::SetState(HomeCard::State state) {
if (state == HIDDEN)
home_card_widget_->Hide();
else
home_card_widget_->Show();
state_ = state;
}
void HomeCardImpl::RegisterSearchProvider(
app_list::SearchProvider* search_provider) {
DCHECK(!search_provider_);
......@@ -170,6 +182,8 @@ void HomeCardImpl::Init() {
views::BubbleBorder::FLOAT,
true /* border_accepts_events */);
home_card_widget_ = view->GetWidget();
// TODO: the initial value might not be visible.
state_ = VISIBLE_CENTERED;
view->ShowWhenReady();
}
......
......@@ -20,6 +20,18 @@ class AppModelBuilder;
class ATHENA_EXPORT HomeCard {
public:
enum State {
// HomeCard is not visible.
HIDDEN,
// HomeCard is visible in the center of the screen as a normal mode.
VISIBLE_CENTERED,
// HomeCard is visible smaller at the bottom of the screen as a supplemental
// widget.
VISIBLE_BOTTOM,
};
// Creates/deletes/gets the singleton object of the HomeCard
// implementation. Takes the ownership of |model_builder|.
static HomeCard* Create(AppModelBuilder* model_builder);
......@@ -28,6 +40,9 @@ class ATHENA_EXPORT HomeCard {
virtual ~HomeCard() {}
// Update the current state of the home card to |state|.
virtual void SetState(State state) = 0;
// Registers a search_provider to the HomeCard. Receiver will take
// the ownership of the specified provider.
virtual void RegisterSearchProvider(
......
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