Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / app_list / views / contents_view.h
index dbb74cf..ade7fdb 100644 (file)
 #include "base/compiler_specific.h"
 #include "base/memory/scoped_ptr.h"
 #include "ui/app_list/app_list_export.h"
+#include "ui/app_list/app_list_model.h"
 #include "ui/app_list/pagination_model.h"
 #include "ui/app_list/pagination_model_observer.h"
 #include "ui/views/view.h"
+#include "ui/views/view_model.h"
 
 namespace gfx {
 class Rect;
 }
 
-namespace views {
-class ViewModel;
-}
-
 namespace app_list {
 
 class AppsGridView;
@@ -45,21 +43,13 @@ class StartPageView;
 class APP_LIST_EXPORT ContentsView : public views::View,
                                      public PaginationModelObserver {
  public:
-  // Values of this enum denote special launcher pages that require hard-coding.
-  // Launcher pages are not required to have a NamedPage enum value.
-  enum NamedPage {
-    NAMED_PAGE_APPS,
-    NAMED_PAGE_SEARCH_RESULTS,
-    NAMED_PAGE_START,
-  };
-
   ContentsView(AppListMainView* app_list_main_view);
-  virtual ~ContentsView();
+  ~ContentsView() override;
 
-  // Initialize the named (special) pages of the launcher. In the experimental
-  // launcher, should be called after set_contents_switcher_view(), or switcher
-  // buttons will not be created.
-  void InitNamedPages(AppListModel* model, AppListViewDelegate* view_delegate);
+  // Initialize the pages of the launcher. In the experimental launcher, should
+  // be called after set_contents_switcher_view(), or switcher buttons will not
+  // be created.
+  void Init(AppListModel* model, AppListViewDelegate* view_delegate);
 
   // The app list gets closed and drag and drop operations need to be cancelled.
   void CancelDrag();
@@ -85,12 +75,12 @@ class APP_LIST_EXPORT ContentsView : public views::View,
   // The index of the currently active launcher page.
   int GetActivePageIndex() const;
 
-  // True if |named_page| is the current active laucher page.
-  bool IsNamedPageActive(NamedPage named_page) const;
+  // True if |state| is the current active laucher page.
+  bool IsStateActive(AppListModel::State state) const;
 
-  // Gets the index of a launcher page in |view_model_|, by NamedPage. Returns
-  // -1 if there is no view for |named_page|.
-  int GetPageIndexForNamedPage(NamedPage named_page) const;
+  // Gets the index of a launcher page in |view_model_|, by State. Returns
+  // -1 if there is no view for |state|.
+  int GetPageIndexForState(AppListModel::State state) const;
 
   int NumLauncherPages() const;
 
@@ -104,19 +94,27 @@ class APP_LIST_EXPORT ContentsView : public views::View,
   // Adds a blank launcher page. For use in tests only.
   void AddBlankPageForTesting();
 
+  // Returns the pagination model for the ContentsView.
+  const PaginationModel& pagination_model() { return pagination_model_; }
+
+  // Returns search box bounds to use for content views that do not specify
+  // their own custom layout.
+  gfx::Rect GetDefaultSearchBoxBounds() const;
+
+  // Returns the content area bounds to use for content views that do not
+  // specify their own custom layout.
+  gfx::Rect GetDefaultContentsBounds() const;
+
   // Overridden from views::View:
-  virtual gfx::Size GetPreferredSize() const OVERRIDE;
-  virtual void Layout() OVERRIDE;
-  virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE;
+  gfx::Size GetPreferredSize() const override;
+  void Layout() override;
+  bool OnKeyPressed(const ui::KeyEvent& event) override;
 
   // Overridden from PaginationModelObserver:
-  virtual void TotalPagesChanged() OVERRIDE;
-  virtual void SelectedPageChanged(int old_selected, int new_selected) OVERRIDE;
-  virtual void TransitionStarted() OVERRIDE;
-  virtual void TransitionChanged() OVERRIDE;
-
-  // Returns the pagination model for the ContentsView.
-  const PaginationModel& pagination_model() { return pagination_model_; }
+  void TotalPagesChanged() override;
+  void SelectedPageChanged(int old_selected, int new_selected) override;
+  void TransitionStarted() override;
+  void TransitionChanged() override;
 
  private:
   // Sets the active launcher page, accounting for whether the change is for
@@ -126,6 +124,9 @@ class APP_LIST_EXPORT ContentsView : public views::View,
   // Invoked when active view is changed.
   void ActivePageChanged(bool show_search_results);
 
+  // Returns the size of the default content area.
+  gfx::Size GetDefaultContentsSize() const;
+
   // Gets the origin (the off-screen resting place) for a given launcher page
   // with index |page_index|.
   gfx::Rect GetOffscreenPageBounds(int page_index) const;
@@ -143,8 +144,10 @@ class APP_LIST_EXPORT ContentsView : public views::View,
   // Adds |view| as a new page to the end of the list of launcher pages. The
   // view is inserted as a child of the ContentsView, and a button with
   // |resource_id| is added to the ContentsSwitcherView. The page is associated
-  // with the name |named_page|. Returns the index of the new page.
-  int AddLauncherPage(views::View* view, int resource_id, NamedPage named_page);
+  // with the name |state|. Returns the index of the new page.
+  int AddLauncherPage(views::View* view,
+                      int resource_id,
+                      AppListModel::State state);
 
   // Gets the PaginationModel owned by the AppsGridView.
   // Note: This is different to |pagination_model_|, which manages top-level
@@ -161,8 +164,12 @@ class APP_LIST_EXPORT ContentsView : public views::View,
   ContentsSwitcherView* contents_switcher_view_;
 
   scoped_ptr<views::ViewModel> view_model_;
-  // Maps NamedPage onto |view_model_| indices.
-  std::map<NamedPage, int> named_page_to_view_;
+
+  // Maps State onto |view_model_| indices.
+  std::map<AppListModel::State, int> state_to_view_;
+
+  // Maps |view_model_| indices onto State.
+  std::map<int, AppListModel::State> view_to_state_;
 
   // The page that was showing before ShowSearchResults(true) was invoked.
   int page_before_search_;