OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_BACKGROUND_APPLICATION_LIST_MODEL_H_ | 5 #ifndef CHROME_BROWSER_BACKGROUND_APPLICATION_LIST_MODEL_H_ |
6 #define CHROME_BROWSER_BACKGROUND_APPLICATION_LIST_MODEL_H_ | 6 #define CHROME_BROWSER_BACKGROUND_APPLICATION_LIST_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 14 matching lines...) Expand all Loading... |
25 public: | 25 public: |
26 // Observer is informed of changes to the model. Users of the | 26 // Observer is informed of changes to the model. Users of the |
27 // BackgroundApplicationListModel should anticipate that associated data, | 27 // BackgroundApplicationListModel should anticipate that associated data, |
28 // e. g. the Icon, may exist and yet not be immediately available. When the | 28 // e. g. the Icon, may exist and yet not be immediately available. When the |
29 // data becomes available, OnApplicationDataChanged will be invoked for all | 29 // data becomes available, OnApplicationDataChanged will be invoked for all |
30 // Observers of the model. | 30 // Observers of the model. |
31 class Observer { | 31 class Observer { |
32 public: | 32 public: |
33 // Invoked when data that the model associates with the extension, such as | 33 // Invoked when data that the model associates with the extension, such as |
34 // the Icon, has changed. | 34 // the Icon, has changed. |
35 virtual void OnApplicationDataChanged(const Extension* extension); | 35 virtual void OnApplicationDataChanged(const Extension* extension, |
| 36 Profile* profile); |
36 | 37 |
37 // Invoked when the model detects a previously unknown extension and/or when | 38 // Invoked when the model detects a previously unknown extension and/or when |
38 // it no longer detects a previously known extension. | 39 // it no longer detects a previously known extension. |
39 virtual void OnApplicationListChanged(); | 40 virtual void OnApplicationListChanged(Profile* profile); |
40 | 41 |
41 protected: | 42 protected: |
42 virtual ~Observer(); | 43 virtual ~Observer(); |
43 }; | 44 }; |
44 | 45 |
45 // Create a new model associated with profile. | 46 // Create a new model associated with profile. |
46 explicit BackgroundApplicationListModel(Profile* profile); | 47 explicit BackgroundApplicationListModel(Profile* profile); |
47 | 48 |
48 virtual ~BackgroundApplicationListModel(); | 49 virtual ~BackgroundApplicationListModel(); |
49 | 50 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 // Returns the Application associated with |extension| or NULL. | 104 // Returns the Application associated with |extension| or NULL. |
104 Application* FindApplication(const Extension* extension); | 105 Application* FindApplication(const Extension* extension); |
105 | 106 |
106 // NotificationObserver implementation. | 107 // NotificationObserver implementation. |
107 virtual void Observe(NotificationType type, | 108 virtual void Observe(NotificationType type, |
108 const NotificationSource& source, | 109 const NotificationSource& source, |
109 const NotificationDetails& details); | 110 const NotificationDetails& details); |
110 | 111 |
111 // Notifies observers that some of the data associated with this background | 112 // Notifies observers that some of the data associated with this background |
112 // application, e. g. the Icon, has changed. | 113 // application, e. g. the Icon, has changed. |
113 void OnApplicationDataChanged(const Extension* extension); | 114 void SendApplicationDataChangedNotifications(const Extension* extension); |
114 | 115 |
115 // Notifies observers that at least one background application has been added | 116 // Notifies observers that at least one background application has been added |
116 // or removed. | 117 // or removed. |
117 void OnApplicationListChanged(); | 118 void SendApplicationListChangedNotifications(); |
118 | 119 |
119 // Invoked by Observe for EXTENSION_LOADED notifications. | 120 // Invoked by Observe for EXTENSION_LOADED notifications. |
120 void OnExtensionLoaded(Extension* extension); | 121 void OnExtensionLoaded(Extension* extension); |
121 | 122 |
122 // Invoked by Observe for EXTENSION_UNLOADED notifications. | 123 // Invoked by Observe for EXTENSION_UNLOADED notifications. |
123 void OnExtensionUnloaded(const Extension* extension); | 124 void OnExtensionUnloaded(const Extension* extension); |
124 | 125 |
125 // Refresh the list of background applications and generate notifications. | 126 // Refresh the list of background applications and generate notifications. |
126 void Update(); | 127 void Update(); |
127 | 128 |
128 ApplicationMap applications_; | 129 ApplicationMap applications_; |
129 ExtensionList extensions_; | 130 ExtensionList extensions_; |
130 ObserverList<Observer> observers_; | 131 ObserverList<Observer> observers_; |
131 Profile* profile_; | 132 Profile* profile_; |
132 NotificationRegistrar registrar_; | 133 NotificationRegistrar registrar_; |
133 | 134 |
134 DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationListModel); | 135 DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationListModel); |
135 }; | 136 }; |
136 | 137 |
137 #endif // CHROME_BROWSER_BACKGROUND_APPLICATION_LIST_MODEL_H_ | 138 #endif // CHROME_BROWSER_BACKGROUND_APPLICATION_LIST_MODEL_H_ |
OLD | NEW |