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

Unified Diff: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc

Issue 10826129: Media galleries: configuration dialog controller and GTK impl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: const Extension* -> const Extension& Created 8 years, 4 months 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.cc
diff --git a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
index f9ba21422adf22cac30a6079fc36d64d0d17b1d8..dbf957896941c090aacef4f06734d6f5d3b688b8 100644
--- a/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
+++ b/chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
@@ -12,15 +12,19 @@
#include "base/platform_file.h"
#include "base/values.h"
#include "chrome/browser/media_gallery/media_file_system_registry.h"
+#include "chrome/browser/ui/tab_contents/tab_contents.h"
#include "chrome/common/extensions/api/experimental_media_galleries.h"
#include "content/public/browser/child_process_security_policy.h"
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/web_contents.h"
#if defined(OS_WIN)
#include "base/sys_string_conversions.h"
#endif
+using content::WebContents;
+
namespace extensions {
namespace {
@@ -47,14 +51,20 @@ bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() {
interactive = *params->details->interactive;
if (interactive == "yes") {
- // TODO(estade): implement.
+ ShowDialog();
+ return true;
} else if (interactive == "if_needed") {
vandebo (ex-Chrome) 2012/08/08 19:24:21 nit: fall through to no for now.
// TODO(estade): implement.
- } else if (interactive != "no") {
- error_ = kInvalidInteractive;
- return false;
+ } else if (interactive == "no") {
+ ReturnGalleries();
+ return true;
}
+ error_ = kInvalidInteractive;
+ return false;
+}
+
+void MediaGalleriesGetMediaFileSystemsFunction::ReturnGalleries() {
const content::RenderProcessHost* rph = render_view_host()->GetProcess();
chrome::MediaFileSystemRegistry* media_fs_registry =
MediaFileSystemRegistry::GetInstance();
@@ -83,10 +93,39 @@ bool MediaGalleriesGetMediaFileSystemsFunction::RunImpl() {
// TODO(vandebo) Handle write permission.
}
- SetResult(list);
- return true;
+ SendResponse(list);
}
+void MediaGalleriesGetMediaFileSystemsFunction::ShowDialog() {
+ AddRef(); // Balanced in MediaGalleriesDialogFinished.
+
+ WebContents* contents = WebContents::FromRenderViewHost(render_view_host());
+ TabContents* tab_contents =
+ contents ? TabContents::FromWebContents(contents) : NULL;
+ if (!tab_contents) {
+ // TODO(estade): for now it just gives up, but it might be nice to first
+ // attempt to find the active window for this extension.
+ MediaGalleriesDialogFinished();
+ return;
+ }
+
+#if defined(TOOLKIT_GTK)
+ // Controller will delete itself.
+ new chrome::MediaGalleriesDialogController(
+ tab_contents, *GetExtension(), this);
+#else
+ // TODO(estade): implement dialog on Views and Cocoa.
+ MediaGalleriesDialogFinished();
+#endif
+}
+
+void MediaGalleriesGetMediaFileSystemsFunction::MediaGalleriesDialogFinished() {
+ ReturnGalleries();
+ Release();
+}
+
+// MediaGalleriesAssembleMediaFileFunction -------------------------------------
+
MediaGalleriesAssembleMediaFileFunction::
~MediaGalleriesAssembleMediaFileFunction() {}

Powered by Google App Engine
This is Rietveld 408576698