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

Side by Side Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.h

Issue 93643002: Media Galleries: Add chrome.mediaGalleries.addUserSelectedFolder(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 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 // 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 <vector> 11 #include <vector>
12 12
13 #include "chrome/browser/extensions/chrome_extension_function.h" 13 #include "chrome/browser/extensions/chrome_extension_function.h"
14 #include "chrome/browser/media_galleries/media_file_system_registry.h" 14 #include "chrome/browser/media_galleries/media_file_system_registry.h"
15 #include "chrome/browser/storage_monitor/media_storage_util.h" 15 #include "chrome/browser/storage_monitor/media_storage_util.h"
16 #include "chrome/common/extensions/api/media_galleries.h" 16 #include "chrome/common/extensions/api/media_galleries.h"
17 17
18 namespace MediaGalleries = extensions::api::media_galleries; 18 namespace MediaGalleries = extensions::api::media_galleries;
19 19
20 namespace base {
21 class FilePath;
22 }
23
20 namespace extensions { 24 namespace extensions {
21 25
26 // Common class for media gallery functions that create DOMFileSystems.
27 // Abstract due to the lack of a RunImpl() implementation.
28 class MediaGalleriesGetMediaFileSystemsBase
29 : public ChromeAsyncExtensionFunction {
30 protected:
31 virtual ~MediaGalleriesGetMediaFileSystemsBase();
32
33 // Always show the dialog. Forces MediaFileSystemRegistry to read its
34 // preferences.
35 void ReadPrefsAndShowDialog();
36
37 // Simply shows the configuration dialog to edit gallery preferences.
38 // Does not force MediaFileSystemRegistry to read its preferences.
39 void ShowDialog();
40
41 // Grabs galleries from the media file system registry and passes them to
42 // |ReturnGalleries|.
43 void GetAndReturnGalleries();
44
45 // Returns galleries to the caller.
46 void ReturnGalleries(const std::vector<MediaFileSystemInfo>& filesystems);
47
48 // Take an array of MediaFileSystemInfo and turn it into a ListValue
49 // suitable for use with JS.
50 // The custom JS binding can use this list to create DOMFileSystem objects.
51 base::ListValue* ConstructFileSystemList(
52 const std::vector<MediaFileSystemInfo>& filesystems);
53
54 // A helper method that calls
55 // MediaFileSystemRegistry::GetMediaFileSystemsForExtension().
56 void GetMediaFileSystemsForExtension(const MediaFileSystemsCallback& cb);
57
58 // Helper function to get the appropriate WebContents.
59 content::WebContents* GetWebContents();
60
61 // Helper function to get the MediaGalleriesPreferences.
62 MediaGalleriesPreferences* GetMediaGalleriesPreferences();
63
64 private:
65 // Callback adaptor that just shows the dialog.
66 void AlwaysShowDialog(const std::vector<MediaFileSystemInfo>& filesystems);
67 };
68
22 class MediaGalleriesGetMediaFileSystemsFunction 69 class MediaGalleriesGetMediaFileSystemsFunction
23 : public ChromeAsyncExtensionFunction { 70 : public MediaGalleriesGetMediaFileSystemsBase {
24 public: 71 public:
25 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMediaFileSystems", 72 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMediaFileSystems",
26 MEDIAGALLERIES_GETMEDIAFILESYSTEMS) 73 MEDIAGALLERIES_GETMEDIAFILESYSTEMS)
27 74
28 protected: 75 protected:
29 virtual ~MediaGalleriesGetMediaFileSystemsFunction(); 76 virtual ~MediaGalleriesGetMediaFileSystemsFunction();
30 virtual bool RunImpl() OVERRIDE; 77 virtual bool RunImpl() OVERRIDE;
31 78
32 private: 79 private:
33 // Bottom half for RunImpl, invoked after the preferences is initialized. 80 // Bottom half for RunImpl, invoked after the preferences is initialized.
34 void OnPreferencesInit( 81 void OnPreferencesInit(
35 MediaGalleries::GetMediaFileSystemsInteractivity interactive); 82 MediaGalleries::GetMediaFileSystemsInteractivity interactive);
36 83
37 // Always show the dialog.
38 void AlwaysShowDialog(const std::vector<MediaFileSystemInfo>& filesystems);
39
40 // If no galleries are found, show the dialog, otherwise return them. 84 // If no galleries are found, show the dialog, otherwise return them.
41 void ShowDialogIfNoGalleries( 85 void ShowDialogIfNoGalleries(
42 const std::vector<MediaFileSystemInfo>& filesystems); 86 const std::vector<MediaFileSystemInfo>& filesystems);
43
44 // Grabs galleries from the media file system registry and passes them to
45 // |ReturnGalleries|.
46 void GetAndReturnGalleries();
47
48 // Returns galleries to the caller.
49 void ReturnGalleries(const std::vector<MediaFileSystemInfo>& filesystems);
50
51 // Shows the configuration dialog to edit gallery preferences.
52 void ShowDialog();
53
54 // A helper method that calls
55 // MediaFileSystemRegistry::GetMediaFileSystemsForExtension().
56 void GetMediaFileSystemsForExtension(const MediaFileSystemsCallback& cb);
57 }; 87 };
58 88
59 class MediaGalleriesGetAllMediaFileSystemMetadataFunction 89 class MediaGalleriesGetAllMediaFileSystemMetadataFunction
60 : public ChromeAsyncExtensionFunction { 90 : public ChromeAsyncExtensionFunction {
61 public: 91 public:
62 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getAllMediaFileSystemMetadata", 92 DECLARE_EXTENSION_FUNCTION("mediaGalleries.getAllMediaFileSystemMetadata",
63 MEDIAGALLERIES_GETALLMEDIAFILESYSTEMMETADATA) 93 MEDIAGALLERIES_GETALLMEDIAFILESYSTEMMETADATA)
64 94
65 protected: 95 protected:
66 virtual ~MediaGalleriesGetAllMediaFileSystemMetadataFunction(); 96 virtual ~MediaGalleriesGetAllMediaFileSystemMetadataFunction();
67 virtual bool RunImpl() OVERRIDE; 97 virtual bool RunImpl() OVERRIDE;
68 98
69 private: 99 private:
70 // Bottom half for RunImpl, invoked after the preferences is initialized. 100 // Bottom half for RunImpl, invoked after the preferences is initialized.
71 // Gets the list of permitted galleries and checks if they are available. 101 // Gets the list of permitted galleries and checks if they are available.
72 void OnPreferencesInit(); 102 void OnPreferencesInit();
73 103
74 // Callback to run upon getting the list of available devices. 104 // Callback to run upon getting the list of available devices.
75 // Sends the list of media filesystem metadata back to the extension. 105 // Sends the list of media filesystem metadata back to the extension.
76 void OnGetGalleries(const MediaGalleryPrefIdSet& permitted_gallery_ids, 106 void OnGetGalleries(const MediaGalleryPrefIdSet& permitted_gallery_ids,
77 const MediaStorageUtil::DeviceIdSet* available_devices); 107 const MediaStorageUtil::DeviceIdSet* available_devices);
78 }; 108 };
79 109
110 class MediaGalleriesManageMediaLocationsFunction
111 : public MediaGalleriesGetMediaFileSystemsBase {
112 public:
113 DECLARE_EXTENSION_FUNCTION("mediaGalleries.manageMediaLocations",
114 MEDIAGALLERIES_MANAGEMEDIALOCATIONS)
115
116 protected:
117 virtual ~MediaGalleriesManageMediaLocationsFunction();
118 virtual bool RunImpl() OVERRIDE;
119
120 private:
121 // Bottom half for RunImpl, invoked after the preferences is initialized.
122 // Handle the |request_type| appropriately.
123 void OnPreferencesInit(MediaGalleries::ManageRequestType request_type);
124
125 // Callback for the directory prompt request, with the input from the user.
126 // If |selected_directory| is empty, then the user canceled.
127 // Either handle the user canceled case or check to see if
128 // |selected_directory| exists.
129 void OnDirectorySelected(const base::FilePath& selected_directory);
130
131 // Callback for the directory prompt request from OnDirectorySelected().
132 // If |selected_directory| exists, add it as a gallery.
133 void OnDirectoryChecked(const base::FilePath& selected_directory,
134 bool exists);
135
136 // Callback for the directory prompt request. Find the file system in
137 // |filesystems| with a pref id of |pref_id| and return that file system to
138 // the caller.
139 void FindGalleryWithPrefId(
140 MediaGalleryPrefId pref_id,
141 const std::vector<MediaFileSystemInfo>& filesystems);
142 };
143
80 } // namespace extensions 144 } // namespace extensions
81 145
82 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_ 146 #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698