Index: chrome/browser/download/download_ui_controller.cc |
diff --git a/chrome/browser/download/download_ui_controller.cc b/chrome/browser/download/download_ui_controller.cc |
index 2bf05709b85789eb46ca760b34a3ba1d1bc9ddea..5fee080392b41621172f06b917ae1c277643965e 100644 |
--- a/chrome/browser/download/download_ui_controller.cc |
+++ b/chrome/browser/download/download_ui_controller.cc |
@@ -9,6 +9,7 @@ |
#include "base/callback.h" |
#include "base/stl_util.h" |
#include "build/build_config.h" |
+#include "chrome/browser/devtools/devtools_window.h" |
#include "chrome/browser/download/download_item_model.h" |
#include "chrome/browser/download/download_shelf.h" |
#include "chrome/browser/ui/browser_finder.h" |
@@ -81,6 +82,17 @@ class DownloadShelfUIControllerDelegate |
void DownloadShelfUIControllerDelegate::OnNewDownloadReady( |
content::DownloadItem* item) { |
content::WebContents* web_contents = item->GetWebContents(); |
+ // For the case of DevTools web contents, we'd like to use target browser |
+ // shelf although saving from the DevTools web contents. |
+ if (web_contents && DevToolsWindow::IsDevToolsWindow(web_contents)) { |
+ DevToolsWindow* devtools_window = |
+ DevToolsWindow::AsDevToolsWindow(web_contents); |
+ content::WebContents* inspected = |
+ devtools_window->GetInspectedWebContents(); |
+ // Do not overwrite web contents for the case of remote debugging. |
+ if (inspected) |
+ web_contents = inspected; |
+ } |
Browser* browser = |
web_contents ? chrome::FindBrowserWithWebContents(web_contents) : NULL; |