summaryrefslogtreecommitdiffstats
path: root/athena/home/home_card_impl.h
blob: 98ea3a63b206e970f597ae0d236e7c4e4cd4018b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
// 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 ATHENA_HOME_HOME_CARD_IMPL_H_
#define ATHENA_HOME_HOME_CARD_IMPL_H_

#include "athena/athena_export.h"
#include "athena/home/home_card_gesture_manager.h"
#include "athena/home/public/home_card.h"
#include "athena/home/public/search_controller_factory.h"
#include "athena/input/public/accelerator_manager.h"
#include "athena/wm/public/window_manager_observer.h"
#include "ui/wm/public/activation_change_observer.h"

namespace aura {
class Window;

namespace client {
class ActivationClient;
}
}

namespace gfx {
class Rect;
}

namespace ui {
class LayerOwner;
}

namespace views {
class Widget;
}

namespace athena {
class AppModelBuilder;
class AppListViewDelegate;
class HomeCardLayoutManager;
class HomeCardView;

class ATHENA_EXPORT HomeCardImpl
    : public HomeCard,
      public AcceleratorHandler,
      public HomeCardGestureManager::Delegate,
      public WindowManagerObserver,
      public aura::client::ActivationChangeObserver {
 public:
  HomeCardImpl(scoped_ptr<AppModelBuilder> model_builder,
               scoped_ptr<SearchControllerFactory> search_factory);
  virtual ~HomeCardImpl();

  void Init();

  aura::Window* GetHomeCardWindowForTest() const;

 private:
  enum Command {
    COMMAND_SHOW_HOME_CARD,
  };
  void InstallAccelerators();

  // Overridden from HomeCard:
  virtual void SetState(HomeCard::State state) override;
  virtual State GetState() override;
  virtual void UpdateVirtualKeyboardBounds(
      const gfx::Rect& bounds) override;

  // AcceleratorHandler:
  virtual bool IsCommandEnabled(int command_id) const override;
  virtual bool OnAcceleratorFired(int command_id,
                                  const ui::Accelerator& accelerator) override;

  // HomeCardGestureManager::Delegate:
  virtual void OnGestureEnded(HomeCard::State final_state,
                              bool is_fling) override;
  virtual void OnGestureProgressed(
      HomeCard::State from_state,
      HomeCard::State to_state,
      float progress) override;

  // WindowManagerObserver:
  virtual void OnOverviewModeEnter() override;
  virtual void OnOverviewModeExit() override;
  virtual void OnSplitViewModeEnter() override;
  virtual void OnSplitViewModeExit() override;

  // aura::client::ActivationChangeObserver:
  virtual void OnWindowActivated(aura::Window* gained_active,
                                 aura::Window* lost_active) override;

  scoped_ptr<AppModelBuilder> model_builder_;
  scoped_ptr<SearchControllerFactory> search_factory_;

  HomeCard::State state_;

  // original_state_ is the state which the home card should go back to after
  // the virtual keyboard is hidden.
  HomeCard::State original_state_;

  views::Widget* home_card_widget_;
  HomeCardView* home_card_view_;
  scoped_ptr<AppListViewDelegate> view_delegate_;
  HomeCardLayoutManager* layout_manager_;
  aura::client::ActivationClient* activation_client_;  // Not owned
  scoped_ptr<ui::LayerOwner> minimized_home_;

  DISALLOW_COPY_AND_ASSIGN(HomeCardImpl);
};

}  // namespace athena

#endif  // ATHENA_HOME_HOME_CARD_IMPL_H_