| 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_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PR
IVATE_API_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PR
IVATE_API_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PR
IVATE_API_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PR
IVATE_API_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 8 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 9 #include "chrome/browser/extensions/event_router.h" | 11 #include "chrome/browser/extensions/event_router.h" |
| 12 #include "chrome/browser/extensions/extension_function.h" |
| 10 #include "chrome/browser/profiles/profile_keyed_service.h" | 13 #include "chrome/browser/profiles/profile_keyed_service.h" |
| 11 | 14 |
| 15 class FilePath; |
| 16 class Profile; |
| 17 |
| 12 namespace extensions { | 18 namespace extensions { |
| 19 |
| 20 class MediaGalleryExtensionNotificationObserver; |
| 13 class MediaGalleriesPrivateEventRouter; | 21 class MediaGalleriesPrivateEventRouter; |
| 14 | 22 |
| 23 // The profile-keyed service that manages the media galleries private extension |
| 24 // API. |
| 15 class MediaGalleriesPrivateAPI : public ProfileKeyedService, | 25 class MediaGalleriesPrivateAPI : public ProfileKeyedService, |
| 16 public extensions::EventRouter::Observer { | 26 public EventRouter::Observer { |
| 17 public: | 27 public: |
| 18 explicit MediaGalleriesPrivateAPI(Profile* profile); | 28 explicit MediaGalleriesPrivateAPI(Profile* profile); |
| 19 virtual ~MediaGalleriesPrivateAPI(); | 29 virtual ~MediaGalleriesPrivateAPI(); |
| 20 | 30 |
| 21 // ProfileKeyedService implementation. | 31 // ProfileKeyedService implementation. |
| 22 virtual void Shutdown() OVERRIDE; | 32 virtual void Shutdown() OVERRIDE; |
| 23 | 33 |
| 24 // EventRouter::Observer implementation. | 34 // EventRouter::Observer implementation. |
| 25 virtual void OnListenerAdded(const extensions::EventListenerInfo& details) | 35 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
| 26 OVERRIDE; | 36 |
| 37 MediaGalleriesPrivateEventRouter* event_router() const { |
| 38 return media_galleries_private_event_router_.get(); |
| 39 } |
| 27 | 40 |
| 28 private: | 41 private: |
| 42 // Current profile. |
| 29 Profile* profile_; | 43 Profile* profile_; |
| 30 | 44 |
| 45 scoped_ptr<MediaGalleryExtensionNotificationObserver> |
| 46 extension_notification_observer_; |
| 47 |
| 48 // Created lazily on first access. |
| 31 scoped_ptr<MediaGalleriesPrivateEventRouter> | 49 scoped_ptr<MediaGalleriesPrivateEventRouter> |
| 32 media_galleries_private_event_router_; | 50 media_galleries_private_event_router_; |
| 51 |
| 52 DISALLOW_COPY_AND_ASSIGN(MediaGalleriesPrivateAPI); |
| 53 }; |
| 54 |
| 55 // Implements the chrome.mediaGalleriesPrivate.addGalleryWatch method. |
| 56 class MediaGalleriesPrivateAddGalleryWatchFunction |
| 57 : public AsyncExtensionFunction { |
| 58 public: |
| 59 DECLARE_EXTENSION_FUNCTION_NAME("mediaGalleriesPrivate.addGalleryWatch"); |
| 60 |
| 61 protected: |
| 62 virtual ~MediaGalleriesPrivateAddGalleryWatchFunction(); |
| 63 |
| 64 // AsyncExtensionFunction overrides. |
| 65 virtual bool RunImpl() OVERRIDE; |
| 66 |
| 67 private: |
| 68 // Gallery watch request handler. |
| 69 void HandleResponse(uint64 gallery_id, |
| 70 bool success); |
| 71 }; |
| 72 |
| 73 // Implements the chrome.mediaGalleriesPrivate.removeGalleryWatch method. |
| 74 class MediaGalleriesPrivateRemoveGalleryWatchFunction |
| 75 : public SyncExtensionFunction { |
| 76 public: |
| 77 DECLARE_EXTENSION_FUNCTION_NAME("mediaGalleriesPrivate.removeGalleryWatch"); |
| 78 |
| 79 protected: |
| 80 virtual ~MediaGalleriesPrivateRemoveGalleryWatchFunction(); |
| 81 |
| 82 // SyncExtensionFunction overrides. |
| 83 virtual bool RunImpl() OVERRIDE; |
| 33 }; | 84 }; |
| 34 | 85 |
| 35 } // namespace extensions | 86 } // namespace extensions |
| 36 | 87 |
| 37 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES
_PRIVATE_API_H_ | 88 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES
_PRIVATE_API_H_ |
| OLD | NEW |