app_list_model.h revision 1e9bf3e0803691d0a228da41fc608347b6db4340
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 <vector>
9
10#include "base/basictypes.h"
11#include "base/files/file_path.h"
12#include "base/memory/scoped_ptr.h"
13#include "base/observer_list.h"
14#include "base/strings/string16.h"
15#include "ui/app_list/app_list_export.h"
16#include "ui/app_list/app_list_item_list.h"
17#include "ui/base/models/list_model.h"
18
19namespace app_list {
20
21class AppListItemList;
22class AppListItemModel;
23class AppListModelObserver;
24class SearchBoxModel;
25class SearchResult;
26
27// Master model of app list that consists of three sub models: AppListItemList,
28// SearchBoxModel and SearchResults. The AppListItemList sub model owns a list
29// of AppListItemModel and is displayed in the grid view. SearchBoxModel is
30// the model for SearchBoxView. SearchResults owns a list of SearchResult.
31class APP_LIST_EXPORT AppListModel {
32 public:
33  // A user of the app list.
34  struct APP_LIST_EXPORT User {
35    User();
36    ~User();
37
38    // Whether or not this user is the current user of the app list.
39    bool active;
40
41    // The name of this user.
42    base::string16 name;
43
44    // The email address of this user.
45    base::string16 email;
46
47    // The path to this user's profile directory.
48    base::FilePath profile_path;
49  };
50
51  enum Status {
52    STATUS_NORMAL,
53    STATUS_SYNCING,  // Syncing apps or installing synced apps.
54  };
55
56  typedef ui::ListModel<SearchResult> SearchResults;
57  typedef std::vector<User> Users;
58
59  AppListModel();
60  ~AppListModel();
61
62  void AddObserver(AppListModelObserver* observer);
63  void RemoveObserver(AppListModelObserver* observer);
64
65  void SetStatus(Status status);
66  void SetUsers(const Users& profile_menu_items);
67  void SetSignedIn(bool signed_in);
68
69  AppListItemList* item_list() { return item_list_.get(); }
70  SearchBoxModel* search_box() { return search_box_.get(); }
71  SearchResults* results() { return results_.get(); }
72  Status status() const { return status_; }
73  bool signed_in() const { return signed_in_; }
74
75  const Users& users() const {
76    return users_;
77  }
78
79 private:
80  scoped_ptr<AppListItemList> item_list_;
81  scoped_ptr<SearchBoxModel> search_box_;
82  scoped_ptr<SearchResults> results_;
83
84  Users users_;
85
86  bool signed_in_;
87  Status status_;
88  ObserverList<AppListModelObserver> observers_;
89
90  DISALLOW_COPY_AND_ASSIGN(AppListModel);
91};
92
93}  // namespace app_list
94
95#endif  // UI_APP_LIST_APP_LIST_MODEL_H_
96