| Index: chrome/browser/extensions/api/media_galleries/media_galleries_api.cc
|
| ===================================================================
|
| --- chrome/browser/extensions/api/media_galleries/media_galleries_api.cc (revision 246091)
|
| +++ chrome/browser/extensions/api/media_galleries/media_galleries_api.cc (working copy)
|
| @@ -21,6 +21,7 @@
|
| #include "chrome/browser/extensions/api/file_system/file_system_api.h"
|
| #include "chrome/browser/extensions/blob_reader.h"
|
| #include "chrome/browser/extensions/extension_prefs.h"
|
| +#include "chrome/browser/extensions/extension_tab_util.h"
|
| #include "chrome/browser/media_galleries/media_file_system_registry.h"
|
| #include "chrome/browser/media_galleries/media_galleries_dialog_controller.h"
|
| #include "chrome/browser/media_galleries/media_galleries_histograms.h"
|
| @@ -412,8 +413,16 @@
|
| const std::string& app_id = GetExtension()->id();
|
| WebContents* contents = GetWebContents(render_view_host(), profile, app_id);
|
| if (!contents) {
|
| - SendResponse(false);
|
| - return;
|
| + // When the request originated from a background page, but there is no app
|
| + // window open, check to see if it originated from a tab and display the
|
| + // dialog in that tab.
|
| + bool found_tab = extensions::ExtensionTabUtil::GetTabById(
|
| + source_tab_id(), profile, profile->IsOffTheRecord(),
|
| + NULL, NULL, &contents, NULL);
|
| + if (!found_tab || !contents) {
|
| + SendResponse(false);
|
| + return;
|
| + }
|
| }
|
|
|
| if (!user_gesture()) {
|
|
|