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 // Defines the Chrome Extensions Media Galleries API functions for accessing | 5 // Defines the Chrome Extensions Media Galleries API functions for accessing |
6 // user's media files, as specified in the extension API IDL. | 6 // user's media files, as specified in the extension API IDL. |
7 | 7 |
8 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ | 8 #ifndef CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ |
9 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ | 9 #define CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ |
10 | 10 |
11 #include <stdint.h> | 11 #include <stdint.h> |
12 | 12 |
| 13 #include <memory> |
13 #include <string> | 14 #include <string> |
14 #include <vector> | 15 #include <vector> |
15 | 16 |
16 #include "base/callback_forward.h" | 17 #include "base/callback_forward.h" |
17 #include "base/macros.h" | 18 #include "base/macros.h" |
18 #include "base/memory/scoped_ptr.h" | |
19 #include "base/memory/weak_ptr.h" | 19 #include "base/memory/weak_ptr.h" |
20 #include "chrome/browser/extensions/chrome_extension_function.h" | 20 #include "chrome/browser/extensions/chrome_extension_function.h" |
21 #include "chrome/browser/media_galleries/gallery_watch_manager_observer.h" | 21 #include "chrome/browser/media_galleries/gallery_watch_manager_observer.h" |
22 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 22 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
23 #include "chrome/common/extensions/api/media_galleries.h" | 23 #include "chrome/common/extensions/api/media_galleries.h" |
24 #include "chrome/common/media_galleries/metadata_types.h" | 24 #include "chrome/common/media_galleries/metadata_types.h" |
25 #include "components/storage_monitor/media_storage_util.h" | 25 #include "components/storage_monitor/media_storage_util.h" |
26 #include "extensions/browser/browser_context_keyed_api_factory.h" | 26 #include "extensions/browser/browser_context_keyed_api_factory.h" |
27 #include "extensions/browser/event_router.h" | 27 #include "extensions/browser/event_router.h" |
28 #include "extensions/browser/extension_event_histogram_value.h" | 28 #include "extensions/browser/extension_event_histogram_value.h" |
(...skipping 30 matching lines...) Expand all Loading... |
59 static MediaGalleriesEventRouter* Get(content::BrowserContext* context); | 59 static MediaGalleriesEventRouter* Get(content::BrowserContext* context); |
60 | 60 |
61 bool ExtensionHasGalleryChangeListener(const std::string& extension_id) const; | 61 bool ExtensionHasGalleryChangeListener(const std::string& extension_id) const; |
62 | 62 |
63 private: | 63 private: |
64 friend class BrowserContextKeyedAPIFactory<MediaGalleriesEventRouter>; | 64 friend class BrowserContextKeyedAPIFactory<MediaGalleriesEventRouter>; |
65 | 65 |
66 void DispatchEventToExtension(const std::string& extension_id, | 66 void DispatchEventToExtension(const std::string& extension_id, |
67 events::HistogramValue histogram_value, | 67 events::HistogramValue histogram_value, |
68 const std::string& event_name, | 68 const std::string& event_name, |
69 scoped_ptr<base::ListValue> event_args); | 69 std::unique_ptr<base::ListValue> event_args); |
70 | 70 |
71 explicit MediaGalleriesEventRouter(content::BrowserContext* context); | 71 explicit MediaGalleriesEventRouter(content::BrowserContext* context); |
72 ~MediaGalleriesEventRouter() override; | 72 ~MediaGalleriesEventRouter() override; |
73 | 73 |
74 // BrowserContextKeyedAPI implementation. | 74 // BrowserContextKeyedAPI implementation. |
75 static const char* service_name() { | 75 static const char* service_name() { |
76 return "MediaGalleriesAPI"; | 76 return "MediaGalleriesAPI"; |
77 } | 77 } |
78 static const bool kServiceIsNULLWhileTesting = true; | 78 static const bool kServiceIsNULLWhileTesting = true; |
79 | 79 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 ~MediaGalleriesGetMetadataFunction() override; | 173 ~MediaGalleriesGetMetadataFunction() override; |
174 bool RunAsync() override; | 174 bool RunAsync() override; |
175 | 175 |
176 private: | 176 private: |
177 // Bottom half for RunAsync, invoked after the preferences is initialized. | 177 // Bottom half for RunAsync, invoked after the preferences is initialized. |
178 void OnPreferencesInit(MediaGalleries::GetMetadataType metadata_type, | 178 void OnPreferencesInit(MediaGalleries::GetMetadataType metadata_type, |
179 const std::string& blob_uuid); | 179 const std::string& blob_uuid); |
180 | 180 |
181 void GetMetadata(MediaGalleries::GetMetadataType metadata_type, | 181 void GetMetadata(MediaGalleries::GetMetadataType metadata_type, |
182 const std::string& blob_uuid, | 182 const std::string& blob_uuid, |
183 scoped_ptr<std::string> blob_header, | 183 std::unique_ptr<std::string> blob_header, |
184 int64_t total_blob_length); | 184 int64_t total_blob_length); |
185 | 185 |
186 void OnSafeMediaMetadataParserDone( | 186 void OnSafeMediaMetadataParserDone( |
187 bool parse_success, scoped_ptr<base::DictionaryValue> result_dictionary, | 187 bool parse_success, |
188 scoped_ptr<std::vector<metadata::AttachedImage> > attached_images); | 188 std::unique_ptr<base::DictionaryValue> result_dictionary, |
| 189 std::unique_ptr<std::vector<metadata::AttachedImage>> attached_images); |
189 | 190 |
190 void ConstructNextBlob( | 191 void ConstructNextBlob( |
191 scoped_ptr<base::DictionaryValue> result_dictionary, | 192 std::unique_ptr<base::DictionaryValue> result_dictionary, |
192 scoped_ptr<std::vector<metadata::AttachedImage> > attached_images, | 193 std::unique_ptr<std::vector<metadata::AttachedImage>> attached_images, |
193 scoped_ptr<std::vector<std::string> > blob_uuids, | 194 std::unique_ptr<std::vector<std::string>> blob_uuids, |
194 scoped_ptr<content::BlobHandle> current_blob); | 195 std::unique_ptr<content::BlobHandle> current_blob); |
195 }; | 196 }; |
196 | 197 |
197 class MediaGalleriesAddGalleryWatchFunction | 198 class MediaGalleriesAddGalleryWatchFunction |
198 : public ChromeAsyncExtensionFunction { | 199 : public ChromeAsyncExtensionFunction { |
199 public: | 200 public: |
200 DECLARE_EXTENSION_FUNCTION("mediaGalleries.addGalleryWatch", | 201 DECLARE_EXTENSION_FUNCTION("mediaGalleries.addGalleryWatch", |
201 MEDIAGALLERIES_ADDGALLERYWATCH); | 202 MEDIAGALLERIES_ADDGALLERYWATCH); |
202 | 203 |
203 protected: | 204 protected: |
204 ~MediaGalleriesAddGalleryWatchFunction() override; | 205 ~MediaGalleriesAddGalleryWatchFunction() override; |
(...skipping 16 matching lines...) Expand all Loading... |
221 ~MediaGalleriesRemoveGalleryWatchFunction() override; | 222 ~MediaGalleriesRemoveGalleryWatchFunction() override; |
222 bool RunAsync() override; | 223 bool RunAsync() override; |
223 | 224 |
224 private: | 225 private: |
225 void OnPreferencesInit(const std::string& pref_id); | 226 void OnPreferencesInit(const std::string& pref_id); |
226 }; | 227 }; |
227 | 228 |
228 } // namespace extensions | 229 } // namespace extensions |
229 | 230 |
230 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ | 231 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ |
OLD | NEW |