blob: 0a5abeb533b743df2a1b852b99619d5bfa5c6056 (
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
|
// Copyright (c) 2012 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 ASH_LAUNCHER_LAUNCHER_MODEL_H_
#define ASH_LAUNCHER_LAUNCHER_MODEL_H_
#pragma once
#include <vector>
#include "ash/launcher/launcher_types.h"
#include "base/observer_list.h"
#include "ash/ash_export.h"
namespace aura {
class Window;
}
namespace ash {
class LauncherModelObserver;
// Model used by LauncherView.
class ASH_EXPORT LauncherModel {
public:
LauncherModel();
~LauncherModel();
// Adds a new item to the model.
void Add(int index, const LauncherItem& item);
// Removes the item at |index|.
void RemoveItemAt(int index);
// Moves the item at |index| to |target_index|. |target_index| is in terms
// of the model *after* the item at |index| is removed.
void Move(int index, int target_index);
// Reset everything but the type and window of the item at the specified
// index.
void Set(int index, const LauncherItem& item);
// Sends LauncherItemWillChange() to the observers. Used when the images are
// going to change for an item, but not for a while.
void SetPendingUpdate(int index);
// Returns the index of the item with the specified window.
int ItemIndexByWindow(aura::Window* window);
LauncherItems::const_iterator ItemByWindow(aura::Window* window) const;
const LauncherItems& items() const { return items_; }
int item_count() const { return static_cast<int>(items_.size()); }
void AddObserver(LauncherModelObserver* observer);
void RemoveObserver(LauncherModelObserver* observer);
private:
LauncherItems items_;
ObserverList<LauncherModelObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(LauncherModel);
};
} // namespace ash
#endif // ASH_LAUNCHER_LAUNCHER_MODEL_H_
|