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

Unified 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: rebase 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/media_galleries/media_galleries_api.h
===================================================================
--- chrome/browser/extensions/api/media_galleries/media_galleries_api.h (revision 239032)
+++ chrome/browser/extensions/api/media_galleries/media_galleries_api.h (working copy)
@@ -17,10 +17,59 @@
namespace MediaGalleries = extensions::api::media_galleries;
+namespace base {
+class FilePath;
+}
+
namespace extensions {
+// Common class for media gallery functions that create DOMFileSystems.
+// Abstract due to the lack of a ChromeAsyncExtensionFunction::RunImpl()
+// implementation.
+class MediaGalleriesGetMediaFileSystemsBase
vandebo (ex-Chrome) 2013/12/18 20:15:53 nit: Maybe name this just GetMediaFileSystemsBase
Lei Zhang 2014/01/08 23:49:54 With the IDL changes, there's less of a need for a
+ : public ChromeAsyncExtensionFunction {
+ protected:
+ virtual ~MediaGalleriesGetMediaFileSystemsBase();
+
+ // Always show the dialog. Forces MediaFileSystemRegistry to read its
+ // preferences.
+ void ReadPrefsAndShowDialog();
vandebo (ex-Chrome) 2013/12/18 20:15:53 Is this needed? It looks like all callers may have
+
+ // Simply shows the configuration dialog to edit gallery preferences.
+ // Does not force MediaFileSystemRegistry to read its preferences.
vandebo (ex-Chrome) 2013/12/18 20:15:53 nit: Maybe change the code and comment to assert t
+ void ShowDialog();
+
+ // Grabs galleries from the media file system registry and passes them to
+ // |ReturnGalleries|.
+ void GetAndReturnGalleries();
+
+ // Returns galleries to the caller.
+ void ReturnGalleries(const std::vector<MediaFileSystemInfo>& filesystems);
+
+ // Take an array of MediaFileSystemInfo and turn it into a ListValue
+ // suitable for use with JS.
+ // Returns NULL on failure. Callers owns the returned value.
+ // The custom JS binding can use this list to create DOMFileSystem objects.
+ base::ListValue* ConstructFileSystemList(
+ const std::vector<MediaFileSystemInfo>& filesystems);
+
+ // A helper method that calls
+ // MediaFileSystemRegistry::GetMediaFileSystemsForExtension().
+ void GetMediaFileSystemsForExtension(const MediaFileSystemsCallback& cb);
+
+ // Helper function to get the appropriate WebContents.
+ content::WebContents* GetWebContents();
+
+ // Helper function to get the MediaGalleriesPreferences.
+ MediaGalleriesPreferences* GetMediaGalleriesPreferences();
+
+ private:
+ // Callback adaptor that just shows the dialog.
+ void AlwaysShowDialog(const std::vector<MediaFileSystemInfo>& filesystems);
vandebo (ex-Chrome) 2013/12/18 20:15:53 Having ReadPrefsAndShowDialog, ShowDialog, and Alw
+};
+
class MediaGalleriesGetMediaFileSystemsFunction
- : public ChromeAsyncExtensionFunction {
+ : public MediaGalleriesGetMediaFileSystemsBase {
public:
DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMediaFileSystems",
MEDIAGALLERIES_GETMEDIAFILESYSTEMS)
@@ -34,26 +83,9 @@
void OnPreferencesInit(
MediaGalleries::GetMediaFileSystemsInteractivity interactive);
- // Always show the dialog.
- void AlwaysShowDialog(const std::vector<MediaFileSystemInfo>& filesystems);
-
// If no galleries are found, show the dialog, otherwise return them.
void ShowDialogIfNoGalleries(
const std::vector<MediaFileSystemInfo>& filesystems);
-
- // Grabs galleries from the media file system registry and passes them to
- // |ReturnGalleries|.
- void GetAndReturnGalleries();
-
- // Returns galleries to the caller.
- void ReturnGalleries(const std::vector<MediaFileSystemInfo>& filesystems);
-
- // Shows the configuration dialog to edit gallery preferences.
- void ShowDialog();
-
- // A helper method that calls
- // MediaFileSystemRegistry::GetMediaFileSystemsForExtension().
- void GetMediaFileSystemsForExtension(const MediaFileSystemsCallback& cb);
};
class MediaGalleriesGetAllMediaFileSystemMetadataFunction
@@ -77,6 +109,36 @@
const MediaStorageUtil::DeviceIdSet* available_devices);
};
+class MediaGalleriesManageMediaLocationsFunction
+ : public MediaGalleriesGetMediaFileSystemsBase {
+ public:
+ DECLARE_EXTENSION_FUNCTION("mediaGalleries.manageMediaLocations",
+ MEDIAGALLERIES_MANAGEMEDIALOCATIONS)
+
+ protected:
+ virtual ~MediaGalleriesManageMediaLocationsFunction();
+ virtual bool RunImpl() OVERRIDE;
+
+ private:
+ // Bottom half for RunImpl, invoked after the preferences is initialized.
+ // Handle the |request_type| appropriately.
+ void OnPreferencesInit(MediaGalleries::ManageRequestType request_type);
+
+ // Callback for the directory prompt request, with the input from the user.
+ // If |selected_directory| is empty, then the user canceled.
+ // Either handle the user canceled case or add the selected gallery.
+ void OnDirectorySelected(const base::FilePath& selected_directory);
+
+ // Callback for the directory prompt request. |pref_id| is for the gallery
+ // the user just added. |filesystems| is the entire list of file systems.
+ // The fsid for the file system that corresponds to |pref_id| will be
+ // appended to the list of file systems returned to the caller. The
+ // Javascript binding for this API will interpret the list appropriately.
+ void ReturnGalleriesAndId(
+ MediaGalleryPrefId pref_id,
+ const std::vector<MediaFileSystemInfo>& filesystems);
+};
+
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_MEDIA_GALLERIES_API_H_

Powered by Google App Engine
This is Rietveld 408576698