| 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> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "chrome/browser/extensions/api/media_galleries_private/gallery_watch_st
ate_tracker.h" | 13 #include "chrome/browser/extensions/api/media_galleries_private/gallery_watch_st
ate_tracker.h" |
| 14 #include "chrome/browser/extensions/api/profile_keyed_api_factory.h" | |
| 15 #include "chrome/browser/extensions/chrome_extension_function.h" | 14 #include "chrome/browser/extensions/chrome_extension_function.h" |
| 16 #include "chrome/browser/media_galleries/media_galleries_preferences.h" | 15 #include "chrome/browser/media_galleries/media_galleries_preferences.h" |
| 17 #include "chrome/common/extensions/api/media_galleries_private.h" | 16 #include "chrome/common/extensions/api/media_galleries_private.h" |
| 17 #include "extensions/browser/browser_context_keyed_api_factory.h" |
| 18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
| 19 | 19 |
| 20 class Profile; | 20 class Profile; |
| 21 | 21 |
| 22 namespace content { | 22 namespace content { |
| 23 class BrowserContext; | 23 class BrowserContext; |
| 24 } | 24 } |
| 25 | 25 |
| 26 namespace extensions { | 26 namespace extensions { |
| 27 | 27 |
| 28 class MediaGalleriesPrivateEventRouter; | 28 class MediaGalleriesPrivateEventRouter; |
| 29 | 29 |
| 30 // The profile-keyed service that manages the media galleries private extension | 30 // The profile-keyed service that manages the media galleries private extension |
| 31 // API. Created at the same time as the Profile. | 31 // API. Created at the same time as the Profile. |
| 32 class MediaGalleriesPrivateAPI : public ProfileKeyedAPI, | 32 class MediaGalleriesPrivateAPI : public BrowserContextKeyedAPI, |
| 33 public EventRouter::Observer { | 33 public EventRouter::Observer { |
| 34 public: | 34 public: |
| 35 explicit MediaGalleriesPrivateAPI(content::BrowserContext* context); | 35 explicit MediaGalleriesPrivateAPI(content::BrowserContext* context); |
| 36 virtual ~MediaGalleriesPrivateAPI(); | 36 virtual ~MediaGalleriesPrivateAPI(); |
| 37 | 37 |
| 38 // BrowserContextKeyedService implementation. | 38 // BrowserContextKeyedService implementation. |
| 39 virtual void Shutdown() OVERRIDE; | 39 virtual void Shutdown() OVERRIDE; |
| 40 | 40 |
| 41 // ProfileKeyedAPI implementation. | 41 // BrowserContextKeyedAPI implementation. |
| 42 static ProfileKeyedAPIFactory<MediaGalleriesPrivateAPI>* GetFactoryInstance(); | 42 static BrowserContextKeyedAPIFactory<MediaGalleriesPrivateAPI>* |
| 43 GetFactoryInstance(); |
| 43 | 44 |
| 44 // Convenience method to get the MediaGalleriesPrivateAPI for a profile. | 45 // Convenience method to get the MediaGalleriesPrivateAPI for a profile. |
| 45 static MediaGalleriesPrivateAPI* Get(content::BrowserContext* context); | 46 static MediaGalleriesPrivateAPI* Get(content::BrowserContext* context); |
| 46 | 47 |
| 47 // EventRouter::Observer implementation. | 48 // EventRouter::Observer implementation. |
| 48 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; | 49 virtual void OnListenerAdded(const EventListenerInfo& details) OVERRIDE; |
| 49 | 50 |
| 50 MediaGalleriesPrivateEventRouter* GetEventRouter(); | 51 MediaGalleriesPrivateEventRouter* GetEventRouter(); |
| 51 GalleryWatchStateTracker* GetGalleryWatchStateTracker(); | 52 GalleryWatchStateTracker* GetGalleryWatchStateTracker(); |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 friend class ProfileKeyedAPIFactory<MediaGalleriesPrivateAPI>; | 55 friend class BrowserContextKeyedAPIFactory<MediaGalleriesPrivateAPI>; |
| 55 | 56 |
| 56 void MaybeInitializeEventRouterAndTracker(); | 57 void MaybeInitializeEventRouterAndTracker(); |
| 57 | 58 |
| 58 // ProfileKeyedAPI implementation. | 59 // BrowserContextKeyedAPI implementation. |
| 59 static const char* service_name() { | 60 static const char* service_name() { |
| 60 return "MediaGalleriesPrivateAPI"; | 61 return "MediaGalleriesPrivateAPI"; |
| 61 } | 62 } |
| 62 static const bool kServiceIsNULLWhileTesting = true; | 63 static const bool kServiceIsNULLWhileTesting = true; |
| 63 | 64 |
| 64 // Current profile. | 65 // Current profile. |
| 65 Profile* profile_; | 66 Profile* profile_; |
| 66 | 67 |
| 67 // Created lazily on first access. | 68 // Created lazily on first access. |
| 68 scoped_ptr<GalleryWatchStateTracker> tracker_; | 69 scoped_ptr<GalleryWatchStateTracker> tracker_; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 protected: | 156 protected: |
| 156 virtual ~MediaGalleriesPrivateGetHandlersFunction(); | 157 virtual ~MediaGalleriesPrivateGetHandlersFunction(); |
| 157 | 158 |
| 158 // AsyncExtensionFunction overrides. | 159 // AsyncExtensionFunction overrides. |
| 159 virtual bool RunImpl() OVERRIDE; | 160 virtual bool RunImpl() OVERRIDE; |
| 160 }; | 161 }; |
| 161 | 162 |
| 162 } // namespace extensions | 163 } // namespace extensions |
| 163 | 164 |
| 164 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES
_PRIVATE_API_H_ | 165 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES
_PRIVATE_API_H_ |
| OLD | NEW |