Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: chrome/browser/extensions/api/media_galleries_private/media_galleries_private_api.h

Issue 11535008: Implement mediaGalleriesPrivate api to notify extensions about gallery changed events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: '' Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
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
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 class MediaGalleryWatchFunctionBase : public AsyncExtensionFunction {
56 protected:
57 MediaGalleryWatchFunctionBase();
58 virtual ~MediaGalleryWatchFunctionBase() {}
59
60 virtual void PerformGalleryWatchOperation(
61 const std::string& gallery_id,
62 const FilePath& gallery_watch_path) = 0;
63
64 // Gallery watch request handler.
65 virtual void HandleResponse(const std::string& gallery_id,
66 bool success) = 0;
67
68 // AsyncExtensionFunction overrides.
69 virtual bool RunImpl() OVERRIDE;
70 };
71
72 // Implements the chrome.mediaGalleriesPrivate.addGalleryWatch method.
73 class MediaGalleriesPrivateAddGalleryWatchFunction
74 : public MediaGalleryWatchFunctionBase {
75 public:
76 DECLARE_EXTENSION_FUNCTION_NAME("mediaGalleriesPrivate.addGalleryWatch");
77
78 protected:
79 virtual ~MediaGalleriesPrivateAddGalleryWatchFunction() {}
80
81 virtual void PerformGalleryWatchOperation(
82 const std::string& gallery_id,
83 const FilePath& gallery_watch_path) OVERRIDE;
84 virtual void HandleResponse(const std::string& gallery_id,
85 bool success) OVERRIDE;
86 };
87
88 // Implements the chrome.mediaGalleriesPrivate.removeGalleryWatch method.
89 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.
90 : public MediaGalleryWatchFunctionBase {
91 public:
92 DECLARE_EXTENSION_FUNCTION_NAME("mediaGalleriesPrivate.removeGalleryWatch");
93
94 protected:
95 virtual ~MediaGalleriesPrivateRemoveGalleryWatchFunction() {}
96
97 virtual void PerformGalleryWatchOperation(
98 const std::string& gallery_id,
99 const FilePath& gallery_watch_path) OVERRIDE;
100 virtual void HandleResponse(const std::string& gallery_id,
101 bool success) OVERRIDE;
33 }; 102 };
34 103
35 } // namespace extensions 104 } // namespace extensions
36 105
37 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES _PRIVATE_API_H_ 106 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES _PRIVATE_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698