app_list_model.h revision 68043e1e95eeb07d5cae7aca370b26518b0867d6
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/base/models/list_model.h" 17 18namespace app_list { 19 20class AppListItemModel; 21class AppListModelObserver; 22class SearchBoxModel; 23class SearchResult; 24 25// Master model of app list that consists of three sub models: Apps, 26// SearchBoxModel and SearchResults. The Apps sub model owns a list of 27// AppListItemModel and is displayed in the grid view. SearchBoxModel is 28// the model for SearchBoxView. SearchResults owns a list of SearchResult. 29class APP_LIST_EXPORT AppListModel { 30 public: 31 // A user of the app list. 32 struct APP_LIST_EXPORT User { 33 User(); 34 ~User(); 35 36 // Whether or not this user is the current user of the app list. 37 bool active; 38 39 // The name of this user. 40 base::string16 name; 41 42 // The email address of this user. 43 base::string16 email; 44 45 // The path to this user's profile directory. 46 base::FilePath profile_path; 47 }; 48 49 enum Status { 50 STATUS_NORMAL, 51 STATUS_SYNCING, // Syncing apps or installing synced apps. 52 }; 53 54 typedef ui::ListModel<AppListItemModel> Apps; 55 typedef ui::ListModel<SearchResult> SearchResults; 56 typedef std::vector<User> Users; 57 58 AppListModel(); 59 ~AppListModel(); 60 61 void AddObserver(AppListModelObserver* observer); 62 void RemoveObserver(AppListModelObserver* observer); 63 64 void SetStatus(Status status); 65 void SetUsers(const Users& profile_menu_items); 66 void SetSignedIn(bool signed_in); 67 68 Apps* apps() { return apps_.get(); } 69 SearchBoxModel* search_box() { return search_box_.get(); } 70 SearchResults* results() { return results_.get(); } 71 Status status() const { return status_; } 72 bool signed_in() const { return signed_in_; } 73 74 const Users& users() const { 75 return users_; 76 } 77 78 private: 79 scoped_ptr<Apps> apps_; 80 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