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 <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback_forward.h" | 14 #include "base/callback_forward.h" |
15 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "chrome/browser/extensions/chrome_extension_function.h" | 17 #include "chrome/browser/extensions/chrome_extension_function.h" |
18 #include "chrome/browser/media_galleries/media_file_system_registry.h" | 18 #include "chrome/browser/media_galleries/media_file_system_registry.h" |
19 #include "chrome/browser/media_galleries/media_scan_manager_observer.h" | 19 #include "chrome/browser/media_galleries/media_scan_manager_observer.h" |
20 #include "chrome/common/extensions/api/media_galleries.h" | 20 #include "chrome/common/extensions/api/media_galleries.h" |
| 21 #include "chrome/common/media_galleries/metadata_types.h" |
21 #include "components/storage_monitor/media_storage_util.h" | 22 #include "components/storage_monitor/media_storage_util.h" |
22 #include "extensions/browser/browser_context_keyed_api_factory.h" | 23 #include "extensions/browser/browser_context_keyed_api_factory.h" |
23 | 24 |
24 namespace MediaGalleries = extensions::api::media_galleries; | 25 namespace MediaGalleries = extensions::api::media_galleries; |
25 | 26 |
26 class MediaGalleriesScanResultDialogController; | 27 class MediaGalleriesScanResultDialogController; |
27 | 28 |
28 namespace content { | 29 namespace content { |
29 class WebContents; | 30 class WebContents; |
30 } | 31 } |
31 | 32 |
32 namespace metadata { | 33 namespace metadata { |
33 class SafeMediaMetadataParser; | 34 class SafeMediaMetadataParser; |
34 } | 35 } |
35 | 36 |
| 37 namespace webkit_blob { |
| 38 class BlobDataHandle; |
| 39 } |
| 40 |
36 namespace extensions { | 41 namespace extensions { |
37 | 42 |
38 class Extension; | 43 class Extension; |
39 | 44 |
40 // The profile-keyed service that manages the media galleries extension API. | 45 // The profile-keyed service that manages the media galleries extension API. |
41 // Created at the same time as the Profile. This is also the event router. | 46 // Created at the same time as the Profile. This is also the event router. |
42 class MediaGalleriesEventRouter : public BrowserContextKeyedAPI, | 47 class MediaGalleriesEventRouter : public BrowserContextKeyedAPI, |
43 public MediaScanManagerObserver { | 48 public MediaScanManagerObserver { |
44 public: | 49 public: |
45 // KeyedService implementation. | 50 // KeyedService implementation. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 public: | 261 public: |
257 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMetadata", | 262 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMetadata", |
258 MEDIAGALLERIES_GETMETADATA) | 263 MEDIAGALLERIES_GETMETADATA) |
259 | 264 |
260 protected: | 265 protected: |
261 virtual ~MediaGalleriesGetMetadataFunction(); | 266 virtual ~MediaGalleriesGetMetadataFunction(); |
262 virtual bool RunAsync() OVERRIDE; | 267 virtual bool RunAsync() OVERRIDE; |
263 | 268 |
264 private: | 269 private: |
265 // Bottom half for RunAsync, invoked after the preferences is initialized. | 270 // Bottom half for RunAsync, invoked after the preferences is initialized. |
266 void OnPreferencesInit(bool mime_type_only, const std::string& blob_uuid); | 271 void OnPreferencesInit(bool mime_type_only, bool get_attached_images, |
| 272 const std::string& blob_uuid); |
267 | 273 |
268 void SniffMimeType(bool mime_type_only, | 274 void GetMetadata(bool mime_type_only, bool get_attached_images, |
269 const std::string& blob_uuid, | 275 const std::string& blob_uuid, |
270 scoped_ptr<std::string> blob_header, | 276 scoped_ptr<std::string> blob_header, |
271 int64 total_blob_length); | 277 int64 total_blob_length); |
272 | 278 |
273 void OnSafeMediaMetadataParserDone( | 279 void OnSafeMediaMetadataParserDone( |
274 bool parse_success, base::DictionaryValue* metadata_dictionary); | 280 bool parse_success, scoped_ptr<base::DictionaryValue> metadata_dictionary, |
| 281 scoped_ptr<std::vector<metadata::AttachedImage>> attached_images); |
| 282 |
| 283 void ConstructNextBlob( |
| 284 scoped_ptr<base::DictionaryValue> metadata_dictionary, |
| 285 scoped_ptr<std::vector<metadata::AttachedImage>> attached_images, |
| 286 scoped_ptr<std::vector<std::string>> blob_uuids, |
| 287 scoped_ptr<webkit_blob::BlobDataHandle> next_blob); |
| 288 |
| 289 void FinishRequest( |
| 290 scoped_ptr<base::DictionaryValue> metadata_dictionary, |
| 291 scoped_ptr<std::vector<metadata::AttachedImage>> attached_images, |
| 292 scoped_ptr<std::vector<std::string>> blob_uuids); |
275 }; | 293 }; |
276 | 294 |
277 } // namespace extensions | 295 } // namespace extensions |
278 | 296 |
279 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ | 297 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ |
OLD | NEW |