| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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_BACKGROUND_APPLICATION_LIST_MODEL_H_ | 5 #ifndef CHROME_BROWSER_BACKGROUND_BACKGROUND_APPLICATION_LIST_MODEL_H_ |
| 6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_APPLICATION_LIST_MODEL_H_ | 6 #define CHROME_BROWSER_BACKGROUND_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> |
| 11 | 11 |
| 12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 | 17 |
| 18 class Profile; | 18 class Profile; |
| 19 | 19 |
| 20 // Model for list of Background Applications, that is, Extensions with | 20 // Model for list of Background Applications associated with a Profile (i.e. |
| 21 // kBackgroundPermission set, associated with a Profile. | 21 // extensions with kBackgroundPermission set, or hosted apps with a |
| 22 // BackgroundContents). |
| 22 class BackgroundApplicationListModel : public content::NotificationObserver { | 23 class BackgroundApplicationListModel : public content::NotificationObserver { |
| 23 public: | 24 public: |
| 24 // Observer is informed of changes to the model. Users of the | 25 // Observer is informed of changes to the model. Users of the |
| 25 // BackgroundApplicationListModel should anticipate that associated data, | 26 // BackgroundApplicationListModel should anticipate that associated data, |
| 26 // e. g. the Icon, may exist and yet not be immediately available. When the | 27 // e. g. the Icon, may exist and yet not be immediately available. When the |
| 27 // data becomes available, OnApplicationDataChanged will be invoked for all | 28 // data becomes available, OnApplicationDataChanged will be invoked for all |
| 28 // Observers of the model. | 29 // Observers of the model. |
| 29 class Observer { | 30 class Observer { |
| 30 public: | 31 public: |
| 31 // Invoked when data that the model associates with the extension, such as | 32 // Invoked when data that the model associates with the extension, such as |
| (...skipping 27 matching lines...) Expand all Loading... |
| 59 // ExtensionIconSet::EXTENSION_ICON_BITTY. | 60 // ExtensionIconSet::EXTENSION_ICON_BITTY. |
| 60 const SkBitmap* GetIcon(const Extension* extension); | 61 const SkBitmap* GetIcon(const Extension* extension); |
| 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, |
| 71 Profile* profile); |
| 70 | 72 |
| 71 // Dissociate observer from this model. | 73 // Dissociate observer from this model. |
| 72 void RemoveObserver(Observer* observer); | 74 void RemoveObserver(Observer* observer); |
| 73 | 75 |
| 74 ExtensionList::const_iterator begin() const { | 76 ExtensionList::const_iterator begin() const { |
| 75 return extensions_.begin(); | 77 return extensions_.begin(); |
| 76 } | 78 } |
| 77 | 79 |
| 78 ExtensionList::const_iterator end() const { | 80 ExtensionList::const_iterator end() const { |
| 79 return extensions_.end(); | 81 return extensions_.end(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 ApplicationMap applications_; | 136 ApplicationMap applications_; |
| 135 ExtensionList extensions_; | 137 ExtensionList extensions_; |
| 136 ObserverList<Observer> observers_; | 138 ObserverList<Observer> observers_; |
| 137 Profile* profile_; | 139 Profile* profile_; |
| 138 content::NotificationRegistrar registrar_; | 140 content::NotificationRegistrar registrar_; |
| 139 | 141 |
| 140 DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationListModel); | 142 DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationListModel); |
| 141 }; | 143 }; |
| 142 | 144 |
| 143 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_APPLICATION_LIST_MODEL_H_ | 145 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_APPLICATION_LIST_MODEL_H_ |
| OLD | NEW |