| 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 namespace gfx { |
| 21 class ImageSkia; |
| 22 } |
| 23 |
| 20 // Model for list of Background Applications associated with a Profile (i.e. | 24 // Model for list of Background Applications associated with a Profile (i.e. |
| 21 // extensions with kBackgroundPermission set, or hosted apps with a | 25 // extensions with kBackgroundPermission set, or hosted apps with a |
| 22 // BackgroundContents). | 26 // BackgroundContents). |
| 23 class BackgroundApplicationListModel : public content::NotificationObserver { | 27 class BackgroundApplicationListModel : public content::NotificationObserver { |
| 24 public: | 28 public: |
| 25 // Observer is informed of changes to the model. Users of the | 29 // Observer is informed of changes to the model. Users of the |
| 26 // BackgroundApplicationListModel should anticipate that associated data, | 30 // BackgroundApplicationListModel should anticipate that associated data, |
| 27 // e. g. the Icon, may exist and yet not be immediately available. When the | 31 // e. g. the Icon, may exist and yet not be immediately available. When the |
| 28 // data becomes available, OnApplicationDataChanged will be invoked for all | 32 // data becomes available, OnApplicationDataChanged will be invoked for all |
| 29 // Observers of the model. | 33 // Observers of the model. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 48 | 52 |
| 49 virtual ~BackgroundApplicationListModel(); | 53 virtual ~BackgroundApplicationListModel(); |
| 50 | 54 |
| 51 // Associate observer with this model. | 55 // Associate observer with this model. |
| 52 void AddObserver(Observer* observer); | 56 void AddObserver(Observer* observer); |
| 53 | 57 |
| 54 // Return the icon associated with |extension| or NULL. NULL indicates either | 58 // Return the icon associated with |extension| or NULL. NULL indicates either |
| 55 // that there is no icon associated with the extension, or that a pending | 59 // that there is no icon associated with the extension, or that a pending |
| 56 // task to retrieve the icon has not completed. See the Observer class above. | 60 // task to retrieve the icon has not completed. See the Observer class above. |
| 57 // | 61 // |
| 58 // NOTE: The model manages the SkBitmap result, that is it "owns" the memory, | 62 // NOTE: The model manages the ImageSkia result, that is it "owns" the memory, |
| 59 // releasing it if the associated background application is unloaded. | 63 // releasing it if the associated background application is unloaded. |
| 60 // NOTE: All icons are currently sized as | 64 // NOTE: All icons are currently sized as |
| 61 // ExtensionIconSet::EXTENSION_ICON_BITTY. | 65 // ExtensionIconSet::EXTENSION_ICON_BITTY. |
| 62 const SkBitmap* GetIcon(const extensions::Extension* extension); | 66 const gfx::ImageSkia* GetIcon(const extensions::Extension* extension); |
| 63 | 67 |
| 64 // Return the position of |extension| within this list model. | 68 // Return the position of |extension| within this list model. |
| 65 int GetPosition(const extensions::Extension* extension) const; | 69 int GetPosition(const extensions::Extension* extension) const; |
| 66 | 70 |
| 67 // Return the extension at the specified |position| in this list model. | 71 // Return the extension at the specified |position| in this list model. |
| 68 const extensions::Extension* GetExtension(int position) const; | 72 const extensions::Extension* GetExtension(int position) const; |
| 69 | 73 |
| 70 // Returns true if the passed extension is a background app. | 74 // Returns true if the passed extension is a background app. |
| 71 static bool IsBackgroundApp(const extensions::Extension& extension, | 75 static bool IsBackgroundApp(const extensions::Extension& extension, |
| 72 Profile* profile); | 76 Profile* profile); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 ApplicationMap applications_; | 143 ApplicationMap applications_; |
| 140 extensions::ExtensionList extensions_; | 144 extensions::ExtensionList extensions_; |
| 141 ObserverList<Observer> observers_; | 145 ObserverList<Observer> observers_; |
| 142 Profile* profile_; | 146 Profile* profile_; |
| 143 content::NotificationRegistrar registrar_; | 147 content::NotificationRegistrar registrar_; |
| 144 | 148 |
| 145 DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationListModel); | 149 DISALLOW_COPY_AND_ASSIGN(BackgroundApplicationListModel); |
| 146 }; | 150 }; |
| 147 | 151 |
| 148 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_APPLICATION_LIST_MODEL_H_ | 152 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_APPLICATION_LIST_MODEL_H_ |
| OLD | NEW |