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

Side by Side Diff: chrome/browser/download/download_ui_controller.cc

Issue 1840533002: Devtools: Add screenshot button to device mode toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebaselined again Created 4 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/download/download_ui_controller.h" 5 #include "chrome/browser/download/download_ui_controller.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/devtools/devtools_window.h"
12 #include "chrome/browser/download/download_item_model.h" 13 #include "chrome/browser/download/download_item_model.h"
13 #include "chrome/browser/download/download_shelf.h" 14 #include "chrome/browser/download/download_shelf.h"
14 #include "chrome/browser/ui/browser_finder.h" 15 #include "chrome/browser/ui/browser_finder.h"
15 #include "chrome/browser/ui/browser_tabstrip.h" 16 #include "chrome/browser/ui/browser_tabstrip.h"
16 #include "chrome/browser/ui/browser_window.h" 17 #include "chrome/browser/ui/browser_window.h"
17 #include "chrome/browser/ui/tabs/tab_strip_model.h" 18 #include "chrome/browser/ui/tabs/tab_strip_model.h"
18 #include "content/public/browser/download_item.h" 19 #include "content/public/browser/download_item.h"
19 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.h"
20 #include "content/public/browser/web_contents_delegate.h" 21 #include "content/public/browser/web_contents_delegate.h"
21 22
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 private: 75 private:
75 // DownloadUIController::Delegate 76 // DownloadUIController::Delegate
76 void OnNewDownloadReady(content::DownloadItem* item) override; 77 void OnNewDownloadReady(content::DownloadItem* item) override;
77 78
78 Profile* profile_; 79 Profile* profile_;
79 }; 80 };
80 81
81 void DownloadShelfUIControllerDelegate::OnNewDownloadReady( 82 void DownloadShelfUIControllerDelegate::OnNewDownloadReady(
82 content::DownloadItem* item) { 83 content::DownloadItem* item) {
83 content::WebContents* web_contents = item->GetWebContents(); 84 content::WebContents* web_contents = item->GetWebContents();
85 // For the case of DevTools web contents, we'd like to use target browser
86 // shelf although saving from the DevTools web contents.
87 if (web_contents && DevToolsWindow::IsDevToolsWindow(web_contents)) {
88 DevToolsWindow* devtools_window =
89 DevToolsWindow::AsDevToolsWindow(web_contents);
90 content::WebContents* inspected =
91 devtools_window->GetInspectedWebContents();
92 // Do not overwrite web contents for the case of remote debugging.
93 if (inspected)
94 web_contents = inspected;
95 }
84 Browser* browser = 96 Browser* browser =
85 web_contents ? chrome::FindBrowserWithWebContents(web_contents) : NULL; 97 web_contents ? chrome::FindBrowserWithWebContents(web_contents) : NULL;
86 98
87 // As a last resort, use the last active browser for this profile. Not ideal, 99 // As a last resort, use the last active browser for this profile. Not ideal,
88 // but better than not showing the download at all. 100 // but better than not showing the download at all.
89 if (browser == nullptr) 101 if (browser == nullptr)
90 browser = chrome::FindLastActiveWithProfile(profile_); 102 browser = chrome::FindLastActiveWithProfile(profile_);
91 103
92 if (browser && browser->window() && 104 if (browser && browser->window() &&
93 DownloadItemModel(item).ShouldShowInShelf()) { 105 DownloadItemModel(item).ShouldShowInShelf()) {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 179 }
168 } 180 }
169 #endif 181 #endif
170 182
171 if (item->GetState() == content::DownloadItem::CANCELLED) 183 if (item->GetState() == content::DownloadItem::CANCELLED)
172 return; 184 return;
173 185
174 DownloadItemModel(item).SetWasUINotified(true); 186 DownloadItemModel(item).SetWasUINotified(true);
175 delegate_->OnNewDownloadReady(item); 187 delegate_->OnNewDownloadReady(item);
176 } 188 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/devtools_window.h ('k') | third_party/WebKit/Source/devtools/front_end/emulation/DeviceModeView.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698