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 { ...@@ -93,6 +93,7 @@ class HomeCardImpl : public HomeCard, public AcceleratorHandler {
void InstallAccelerators(); void InstallAccelerators();
// Overridden from HomeCard: // Overridden from HomeCard:
virtual void SetState(State state) OVERRIDE;
virtual void RegisterSearchProvider( virtual void RegisterSearchProvider(
app_list::SearchProvider* search_provider) OVERRIDE; app_list::SearchProvider* search_provider) OVERRIDE;
virtual void UpdateVirtualKeyboardBounds( virtual void UpdateVirtualKeyboardBounds(
...@@ -103,15 +104,17 @@ class HomeCardImpl : public HomeCard, public AcceleratorHandler { ...@@ -103,15 +104,17 @@ class HomeCardImpl : public HomeCard, public AcceleratorHandler {
virtual bool OnAcceleratorFired(int command_id, virtual bool OnAcceleratorFired(int command_id,
const ui::Accelerator& accelerator) OVERRIDE { const ui::Accelerator& accelerator) OVERRIDE {
DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id); DCHECK_EQ(COMMAND_SHOW_HOME_CARD, command_id);
if (home_card_widget_->IsVisible()) if (state_ == HIDDEN)
home_card_widget_->Hide(); SetState(VISIBLE_CENTERED);
else else
home_card_widget_->Show(); SetState(HIDDEN);
return true; return true;
} }
scoped_ptr<AppModelBuilder> model_builder_; scoped_ptr<AppModelBuilder> model_builder_;
HomeCard::State state_;
views::Widget* home_card_widget_; views::Widget* home_card_widget_;
AppListViewDelegate* view_delegate_; AppListViewDelegate* view_delegate_;
HomeCardLayoutManager* layout_manager_; HomeCardLayoutManager* layout_manager_;
...@@ -125,6 +128,7 @@ class HomeCardImpl : public HomeCard, public AcceleratorHandler { ...@@ -125,6 +128,7 @@ class HomeCardImpl : public HomeCard, public AcceleratorHandler {
HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder) HomeCardImpl::HomeCardImpl(AppModelBuilder* model_builder)
: model_builder_(model_builder), : model_builder_(model_builder),
state_(HIDDEN),
home_card_widget_(NULL), home_card_widget_(NULL),
layout_manager_(NULL) { layout_manager_(NULL) {
DCHECK(!instance); DCHECK(!instance);
...@@ -138,6 +142,14 @@ HomeCardImpl::~HomeCardImpl() { ...@@ -138,6 +142,14 @@ HomeCardImpl::~HomeCardImpl() {
instance = NULL; 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( void HomeCardImpl::RegisterSearchProvider(
app_list::SearchProvider* search_provider) { app_list::SearchProvider* search_provider) {
DCHECK(!search_provider_); DCHECK(!search_provider_);
...@@ -170,6 +182,8 @@ void HomeCardImpl::Init() { ...@@ -170,6 +182,8 @@ void HomeCardImpl::Init() {
views::BubbleBorder::FLOAT, views::BubbleBorder::FLOAT,
true /* border_accepts_events */); true /* border_accepts_events */);
home_card_widget_ = view->GetWidget(); home_card_widget_ = view->GetWidget();
// TODO: the initial value might not be visible.
state_ = VISIBLE_CENTERED;
view->ShowWhenReady(); view->ShowWhenReady();
} }
......
...@@ -20,6 +20,18 @@ class AppModelBuilder; ...@@ -20,6 +20,18 @@ class AppModelBuilder;
class ATHENA_EXPORT HomeCard { class ATHENA_EXPORT HomeCard {
public: 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 // Creates/deletes/gets the singleton object of the HomeCard
// implementation. Takes the ownership of |model_builder|. // implementation. Takes the ownership of |model_builder|.
static HomeCard* Create(AppModelBuilder* model_builder); static HomeCard* Create(AppModelBuilder* model_builder);
...@@ -28,6 +40,9 @@ class ATHENA_EXPORT HomeCard { ...@@ -28,6 +40,9 @@ class ATHENA_EXPORT HomeCard {
virtual ~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 // Registers a search_provider to the HomeCard. Receiver will take
// the ownership of the specified provider. // the ownership of the specified provider.
virtual void RegisterSearchProvider( 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