| 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 ~BackgroundApplicationListModel(); | 49 ~BackgroundApplicationListModel(); |
| 49 | 50 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 61 | 62 |
| 62 // Return the position of |extension| within this list model. | 63 // Return the position of |extension| within this list model. |
| 63 int GetPosition(const Extension* extension) const; | 64 int GetPosition(const Extension* extension) const; |
| 64 | 65 |
| 65 // Return the extension at the specified |position| in this list model. | 66 // Return the extension at the specified |position| in this list model. |
| 66 const Extension* GetExtension(int position) const; | 67 const Extension* GetExtension(int position) const; |
| 67 | 68 |
| 68 // Returns true if the passed extension is a background app. | 69 // Returns true if the passed extension is a background app. |
| 69 static bool IsBackgroundApp(const Extension& extension); | 70 static bool IsBackgroundApp(const Extension& extension); |
| 70 | 71 |
| 72 // Returns whether any of the extensions are background apps. |
| 73 bool HasBackgroundApp(); |
| 74 |
| 71 // Dissociate observer from this model. | 75 // Dissociate observer from this model. |
| 72 void RemoveObserver(Observer* observer); | 76 void RemoveObserver(Observer* observer); |
| 73 | 77 |
| 74 ExtensionList::const_iterator begin() const { | 78 ExtensionList::const_iterator begin() const { |
| 75 return extensions_.begin(); | 79 return extensions_.begin(); |
| 76 } | 80 } |
| 77 | 81 |
| 78 ExtensionList::const_iterator end() const { | 82 ExtensionList::const_iterator end() const { |
| 79 return extensions_.end(); | 83 return extensions_.end(); |
| 80 } | 84 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 103 // Returns the Application associated with |extension| or NULL. | 107 // Returns the Application associated with |extension| or NULL. |
| 104 Application* FindApplication(const Extension* extension); | 108 Application* FindApplication(const Extension* extension); |
| 105 | 109 |
| 106 // NotificationObserver implementation. | 110 // NotificationObserver implementation. |
| 107 virtual void Observe(NotificationType type, | 111 virtual void Observe(NotificationType type, |
| 108 const NotificationSource& source, | 112 const NotificationSource& source, |
| 109 const NotificationDetails& details); | 113 const NotificationDetails& details); |
| 110 | 114 |
| 111 // Notifies observers that some of the data associated with this background | 115 // Notifies observers that some of the data associated with this background |
| 112 // application, e. g. the Icon, has changed. | 116 // application, e. g. the Icon, has changed. |
| 113 void OnApplicationDataChanged(const Extension* extension); | 117 void OnApplicationDataChanged(const Extension* extension, Profile* profile); |
| 114 | 118 |
| 115 // Notifies observers that at least one background application has been added | 119 // Notifies observers that at least one background application has been added |
| 116 // or removed. | 120 // or removed. |
| 117 void OnApplicationListChanged(); | 121 void OnApplicationListChanged(Profile* profile); |
| 118 | 122 |
| 119 // Invoked by Observe for EXTENSION_LOADED notifications. | 123 // Invoked by Observe for EXTENSION_LOADED notifications. |
| 120 void OnExtensionLoaded(Extension* extension); | 124 void OnExtensionLoaded(Extension* extension); |
| 121 | 125 |
| 122 // Invoked by Observe for EXTENSION_UNLOADED notifications. | 126 // Invoked by Observe for EXTENSION_UNLOADED notifications. |
| 123 void OnExtensionUnloaded(const Extension* extension); | 127 void OnExtensionUnloaded(const Extension* extension); |
| 124 | 128 |
| 125 // Refresh the list of background applications and generate notifications. | 129 // Refresh the list of background applications and generate notifications. |
| 126 void Update(); | 130 void Update(); |
| 127 | 131 |
| 128 ApplicationMap applications_; | 132 ApplicationMap applications_; |
| 129 ExtensionList extensions_; | 133 ExtensionList extensions_; |
| 130 ObserverList<Observer> observers_; | 134 ObserverList<Observer> observers_; |
| 131 Profile* profile_; | 135 Profile* profile_; |
| 132 NotificationRegistrar registrar_; | 136 NotificationRegistrar registrar_; |
| 133 | 137 |
| 134 DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationListModel); | 138 DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationListModel); |
| 135 }; | 139 }; |
| 136 | 140 |
| 137 #endif // CHROME_BROWSER_BACKGROUND_APPLICATION_LIST_MODEL_H_ | 141 #endif // CHROME_BROWSER_BACKGROUND_APPLICATION_LIST_MODEL_H_ |
| OLD | NEW |