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

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: Created 7 years, 1 month 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 237402)
+++ chrome/browser/extensions/api/media_galleries/media_galleries_api.h (working copy)
@@ -17,10 +17,57 @@
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 RunImpl() implementation.
+class MediaGalleriesGetMediaFileSystemsBase
+ : public ChromeAsyncExtensionFunction {
+ protected:
+ virtual ~MediaGalleriesGetMediaFileSystemsBase();
+
+ // Always show the dialog. Forces MediaFileSystemRegistry to read its
+ // preferences.
+ void ReadPrefsAndShowDialog();
+
+ // Simply shows the configuration dialog to edit gallery preferences.
+ // Does not force MediaFileSystemRegistry to read its preferences.
+ 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.
+ // 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);
+};
+
class MediaGalleriesGetMediaFileSystemsFunction
- : public ChromeAsyncExtensionFunction {
+ : public MediaGalleriesGetMediaFileSystemsBase {
public:
DECLARE_EXTENSION_FUNCTION("mediaGalleries.getMediaFileSystems",
MEDIAGALLERIES_GETMEDIAFILESYSTEMS)
@@ -34,26 +81,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 +107,40 @@
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 check to see if
+ // |selected_directory| exists.
+ void OnDirectorySelected(const base::FilePath& selected_directory);
+
+ // Callback for the directory prompt request from OnDirectorySelected().
+ // If |selected_directory| exists, add it as a gallery.
+ void OnDirectoryChecked(const base::FilePath& selected_directory,
+ bool exists);
+
+ // Callback for the directory prompt request. Find the file system in
+ // |filesystems| with a pref id of |pref_id| and return that file system to
+ // the caller.
+ void FindGalleryWithPrefId(
+ 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