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