Index: chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h |
diff --git a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h |
index 454bf4f6122ec15a17f73ffb5f90ceb7a82c0d45..a27fa95a1910124a128003f2a6913ddeb6f18496 100644 |
--- a/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h |
+++ b/chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h |
@@ -5,15 +5,25 @@ |
#ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PRIVATE_API_H_ |
#define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PRIVATE_API_H_ |
+#include <string> |
+ |
#include "base/memory/scoped_ptr.h" |
#include "chrome/browser/extensions/event_router.h" |
+#include "chrome/browser/extensions/extension_function.h" |
#include "chrome/browser/profiles/profile_keyed_service.h" |
+class FilePath; |
+class Profile; |
+ |
namespace extensions { |
+ |
+class MediaGalleryExtensionNotificationObserver; |
class MediaGalleriesPrivateEventRouter; |
+// The profile-keyed service that manages the media galleries private extension |
+// API. |
class MediaGalleriesPrivateAPI : public ProfileKeyedService, |
- public extensions::EventRouter::Observer { |
+ public EventRouter::Observer { |
public: |
explicit MediaGalleriesPrivateAPI(Profile* profile); |
virtual ~MediaGalleriesPrivateAPI(); |
@@ -22,14 +32,73 @@ class MediaGalleriesPrivateAPI : public ProfileKeyedService, |
virtual void Shutdown() OVERRIDE; |
// EventRouter::Observer implementation. |
- virtual void OnListenerAdded(const extensions::EventListenerInfo& details) |
- OVERRIDE; |
+ virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
+ |
+ MediaGalleriesPrivateEventRouter* event_router() const { |
+ return media_galleries_private_event_router_.get(); |
+ } |
private: |
+ // Current profile. |
Profile* profile_; |
+ scoped_ptr<MediaGalleryExtensionNotificationObserver> |
Lei Zhang
2012/12/15 04:13:21
Why both with a separate observer? Composition isn
kmadhusu
2012/12/17 23:58:05
GalleryWatchManager needs to perform some clean up
|
+ extension_notification_observer_; |
+ |
+ // Created lazily on first access. |
scoped_ptr<MediaGalleriesPrivateEventRouter> |
media_galleries_private_event_router_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateAPI); |
+}; |
+ |
+class MediaGalleryWatchFunctionBase : public AsyncExtensionFunction { |
+ protected: |
+ MediaGalleryWatchFunctionBase(); |
+ virtual ~MediaGalleryWatchFunctionBase() {} |
+ |
+ virtual void PerformGalleryWatchOperation( |
+ const std::string& gallery_id, |
+ const FilePath& gallery_watch_path) = 0; |
+ |
+ // Gallery watch request handler. |
+ virtual void HandleResponse(const std::string& gallery_id, |
+ bool success) = 0; |
+ |
+ // AsyncExtensionFunction overrides. |
+ virtual bool RunImpl() OVERRIDE; |
+}; |
+ |
+// Implements the chrome.mediaGalleriesPrivate.addGalleryWatch method. |
+class MediaGalleriesPrivateAddGalleryWatchFunction |
+ : public MediaGalleryWatchFunctionBase { |
+ public: |
+ DECLARE_EXTENSION_FUNCTION_NAME("mediaGalleriesPrivate.addGalleryWatch"); |
+ |
+ protected: |
+ virtual ~MediaGalleriesPrivateAddGalleryWatchFunction() {} |
+ |
+ virtual void PerformGalleryWatchOperation( |
+ const std::string& gallery_id, |
+ const FilePath& gallery_watch_path) OVERRIDE; |
+ virtual void HandleResponse(const std::string& gallery_id, |
+ bool success) OVERRIDE; |
+}; |
+ |
+// Implements the chrome.mediaGalleriesPrivate.removeGalleryWatch method. |
+class MediaGalleriesPrivateRemoveGalleryWatchFunction |
Lei Zhang
2012/12/15 02:00:29
I don't think the two Function classes should shar
kmadhusu
2012/12/17 23:58:05
Good catch. Fixed.
|
+ : public MediaGalleryWatchFunctionBase { |
+ public: |
+ DECLARE_EXTENSION_FUNCTION_NAME("mediaGalleriesPrivate.removeGalleryWatch"); |
+ |
+ protected: |
+ virtual ~MediaGalleriesPrivateRemoveGalleryWatchFunction() {} |
+ |
+ virtual void PerformGalleryWatchOperation( |
+ const std::string& gallery_id, |
+ const FilePath& gallery_watch_path) OVERRIDE; |
+ virtual void HandleResponse(const std::string& gallery_id, |
+ bool success) OVERRIDE; |
}; |
} // namespace extensions |