app_list_model.h revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
1// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef UI_APP_LIST_APP_LIST_MODEL_H_
6#define UI_APP_LIST_APP_LIST_MODEL_H_
7
8#include "base/basictypes.h"
9#include "base/memory/scoped_ptr.h"
10#include "base/observer_list.h"
11#include "ui/app_list/app_list_export.h"
12#include "ui/app_list/app_list_item_list.h"
13#include "ui/base/models/list_model.h"
14
15namespace app_list {
16
17class AppListItemList;
18class AppListItemModel;
19class AppListModelObserver;
20class SearchBoxModel;
21class SearchResult;
22
23// Master model of app list that consists of three sub models: AppListItemList,
24// SearchBoxModel and SearchResults. The AppListItemList sub model owns a list
25// of AppListItemModel and is displayed in the grid view. SearchBoxModel is
26// the model for SearchBoxView. SearchResults owns a list of SearchResult.
27class APP_LIST_EXPORT AppListModel {
28 public:
29  enum Status {
30    STATUS_NORMAL,
31    STATUS_SYNCING,  // Syncing apps or installing synced apps.
32  };
33
34  typedef ui::ListModel<SearchResult> SearchResults;
35
36  AppListModel();
37  ~AppListModel();
38
39  void AddObserver(AppListModelObserver* observer);
40  void RemoveObserver(AppListModelObserver* observer);
41
42  void SetStatus(Status status);
43
44  AppListItemList* item_list() { return item_list_.get(); }
45  SearchBoxModel* search_box() { return search_box_.get(); }
46  SearchResults* results() { return results_.get(); }
47  Status status() const { return status_; }
48
49 private:
50  scoped_ptr<AppListItemList> item_list_;
51  scoped_ptr<SearchBoxModel> search_box_;
52  scoped_ptr<SearchResults> results_;
53
54  Status status_;
55  ObserverList<AppListModelObserver> observers_;
56
57  DISALLOW_COPY_AND_ASSIGN(AppListModel);
58};
59
60}  // namespace app_list
61
62#endif  // UI_APP_LIST_APP_LIST_MODEL_H_
63