Commit 3d271eed authored by mtomasz@chromium.org's avatar mtomasz@chromium.org

Method to get Media Galleries handlers in MediaGalleriesPrivateApi.

For the gatekeeper, we need list of media galleries handlers to know what to display in the action choice dialog. This patch adds a method whih returns such lists via a asynchronous call to chrome.mediaGalleriesPrivate.getHandlers.

TEST=Tested manually. Not in production, yet.
BUG=222565

Review URL: https://codereview.chromium.org/13063004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@190556 0039d316-1c4b-4281-b951-d872f2087c98
parent 6a9f85dd
...@@ -16,10 +16,12 @@ ...@@ -16,10 +16,12 @@
#include "chrome/browser/extensions/event_names.h" #include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h" #include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/extensions/extension_function.h" #include "chrome/browser/extensions/extension_function.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_system.h" #include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/media_galleries_handler.h" #include "chrome/browser/extensions/media_galleries_handler.h"
#include "chrome/browser/media_galleries/media_file_system_registry.h" #include "chrome/browser/media_galleries/media_file_system_registry.h"
#include "chrome/browser/media_galleries/media_galleries_preferences.h" #include "chrome/browser/media_galleries/media_galleries_preferences.h"
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/render_view_host.h" #include "content/public/browser/render_view_host.h"
...@@ -350,4 +352,54 @@ void MediaGalleriesPrivateEjectDeviceFunction::HandleResponse( ...@@ -350,4 +352,54 @@ void MediaGalleriesPrivateEjectDeviceFunction::HandleResponse(
SendResponse(true); SendResponse(true);
} }
///////////////////////////////////////////////////////////////////////////////
// MediaGalleriesPrivateGetHandlersFunction //
///////////////////////////////////////////////////////////////////////////////
MediaGalleriesPrivateGetHandlersFunction::
~MediaGalleriesPrivateGetHandlersFunction() {
}
bool MediaGalleriesPrivateGetHandlersFunction::RunImpl() {
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
ExtensionService* service =
extensions::ExtensionSystem::Get(profile_)->extension_service();
DCHECK(service);
ListValue* result_list = new ListValue();
for (ExtensionSet::const_iterator iter = service->extensions()->begin();
iter != service->extensions()->end();
++iter) {
const Extension* extension = *iter;
if (profile_->IsOffTheRecord() &&
!service->IsIncognitoEnabled(extension->id()))
continue;
MediaGalleriesHandler::List* handler_list =
MediaGalleriesHandler::GetHandlers(extension);
if (!handler_list)
continue;
for (MediaGalleriesHandler::List::const_iterator action_iter =
handler_list->begin();
action_iter != handler_list->end();
++action_iter) {
const MediaGalleriesHandler* action = action_iter->get();
DictionaryValue* handler = new DictionaryValue();
handler->SetString("extensionId", action->extension_id());
handler->SetString("id", action->id());
handler->SetString("title", action->title());
handler->SetString("iconUrl", action->icon_path());
result_list->Append(handler);
}
}
SetResult(result_list);
SendResponse(true);
return true;
}
} // namespace extensions } // namespace extensions
...@@ -145,6 +145,20 @@ class MediaGalleriesPrivateEjectDeviceFunction ...@@ -145,6 +145,20 @@ class MediaGalleriesPrivateEjectDeviceFunction
void HandleResponse(chrome::StorageMonitor::EjectStatus status); void HandleResponse(chrome::StorageMonitor::EjectStatus status);
}; };
// Implements the chrome.mediaGalleriesPrivate.getHandlers method.
class MediaGalleriesPrivateGetHandlersFunction
: public AsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("mediaGalleriesPrivate.getHandlers",
MEDIAGALLERIESPRIVATE_GETHANDLERS);
protected:
virtual ~MediaGalleriesPrivateGetHandlersFunction();
// AsyncExtensionFunction overrides.
virtual bool RunImpl() OVERRIDE;
};
} // namespace extensions } // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PRIVATE_API_H_ #endif // CHROME_BROWSER_EXTENSIONS_API_MEDIA_GALLERIES_PRIVATE_MEDIA_GALLERIES_PRIVATE_API_H_
...@@ -497,6 +497,7 @@ enum HistogramValue { ...@@ -497,6 +497,7 @@ enum HistogramValue {
WALLPAPERPRIVATE_SETCUSTOMWALLPAPERLAYOUT, WALLPAPERPRIVATE_SETCUSTOMWALLPAPERLAYOUT,
DOWNLOADSINTERNAL_DETERMINEFILENAME, DOWNLOADSINTERNAL_DETERMINEFILENAME,
SYNCFILESYSTEM_GETFILESYNCSTATUSES, SYNCFILESYSTEM_GETFILESYNCSTATUSES,
MEDIAGALLERIESPRIVATE_GETHANDLERS,
ENUM_BOUNDARY // Last entry: Add new entries above. ENUM_BOUNDARY // Last entry: Add new entries above.
}; };
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
// systeminfo.storage API in M24. // systeminfo.storage API in M24.
namespace mediaGalleriesPrivate { namespace mediaGalleriesPrivate {
// A dictionary that describes an attached device. // A dictionary that describes an attached device.
[inline_doc] dictionary DeviceAttachmentDetails { [inline_doc] dictionary DeviceAttachmentDetails {
// The name of the device. // The name of the device.
DOMString deviceName; DOMString deviceName;
...@@ -63,6 +63,23 @@ namespace mediaGalleriesPrivate { ...@@ -63,6 +63,23 @@ namespace mediaGalleriesPrivate {
callback EjectDeviceCallback = void (EjectDeviceResultCode result); callback EjectDeviceCallback = void (EjectDeviceResultCode result);
// A dictionary that describes a media galleries handler.
[inline_doc] dictionary MediaGalleriesHandler {
// Unique action id per extension.
DOMString id;
// ID of the extension handling this handler.
DOMString extensionId;
// Localized title describing the action.
DOMString title;
// Url of the icon.
DOMString iconUrl;
};
callback GetHandlersCallback = void (MediaGalleriesHandler[] handlers);
interface Functions { interface Functions {
static void addGalleryWatch(DOMString galleryId, static void addGalleryWatch(DOMString galleryId,
AddGalleryWatchCallback callback); AddGalleryWatchCallback callback);
...@@ -70,5 +87,6 @@ namespace mediaGalleriesPrivate { ...@@ -70,5 +87,6 @@ namespace mediaGalleriesPrivate {
static void getAllGalleryWatch(GetAllGalleryWatchCallback callback); static void getAllGalleryWatch(GetAllGalleryWatchCallback callback);
static void removeAllGalleryWatch(); static void removeAllGalleryWatch();
static void ejectDevice(DOMString deviceId, EjectDeviceCallback callback); static void ejectDevice(DOMString deviceId, EjectDeviceCallback callback);
static void getHandlers(GetHandlersCallback callback);
}; };
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment