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

Unified Diff: chrome/browser/printing/print_view_manager.cc

Issue 2496203003: Add printing tests to ensure window.print() works for subframes.
Patch Set: Created 4 years, 1 month 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/printing/print_view_manager.cc
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc
index 6afd07b443725b2bb3b55f195554bbb458a5b643..feb28ddb8b18249723bfcd7e0324647e5ecab714 100644
--- a/chrome/browser/printing/print_view_manager.cc
+++ b/chrome/browser/printing/print_view_manager.cc
@@ -54,11 +54,13 @@ void EnableInternalPDFPluginForContents(int render_process_id,
namespace printing {
+bool PrintViewManager::TestDelegate::ScriptedPrint(
+ const content::RenderFrameHost* render_frame_host) {
+ return true;
+}
+
PrintViewManager::PrintViewManager(content::WebContents* web_contents)
- : PrintViewManagerBase(web_contents),
- print_preview_state_(NOT_PREVIEWING),
- print_preview_rfh_(nullptr),
- scripted_print_preview_rph_(nullptr) {
+ : PrintViewManagerBase(web_contents) {
if (PrintPreviewDialogController::IsPrintPreviewDialog(web_contents)) {
EnableInternalPDFPluginForContents(
web_contents->GetRenderProcessHost()->GetID(),
@@ -200,6 +202,11 @@ void PrintViewManager::OnSetupScriptedPrintPreview(
return;
}
+ if (test_delegate_ && !test_delegate_->ScriptedPrint(rfh)) {
+ rfh->Send(reply_msg);
+ return;
+ }
+
DCHECK(!print_preview_rfh_);
print_preview_rfh_ = rfh;
print_preview_state_ = SCRIPTED_PREVIEW;
@@ -210,7 +217,6 @@ void PrintViewManager::OnSetupScriptedPrintPreview(
void PrintViewManager::OnShowScriptedPrintPreview(content::RenderFrameHost* rfh,
bool source_is_modifiable) {
- DCHECK(print_preview_rfh_);
if (rfh != print_preview_rfh_)
return;
@@ -250,4 +256,8 @@ bool PrintViewManager::OnMessageReceived(
PrintViewManagerBase::OnMessageReceived(message, render_frame_host);
}
+void PrintViewManager::SetTestDelegate(TestDelegate* delegate) {
+ test_delegate_ = delegate;
+}
+
} // namespace printing

Powered by Google App Engine
This is Rietveld 408576698