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

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

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.h
diff --git a/chrome/browser/printing/print_view_manager.h b/chrome/browser/printing/print_view_manager.h
index 7c6ddf2b397a8ecf48cd257b816b9926ccb51790..69a532bc2e9c1ad77c47c5bf7078c96da158b945 100644
--- a/chrome/browser/printing/print_view_manager.h
+++ b/chrome/browser/printing/print_view_manager.h
@@ -9,6 +9,7 @@
#include "chrome/browser/printing/print_view_manager_base.h"
#include "content/public/browser/web_contents_user_data.h"
#include "printing/features/features.h"
+#include "url/gurl.h"
namespace content {
class RenderFrameHost;
@@ -21,6 +22,17 @@ namespace printing {
class PrintViewManager : public PrintViewManagerBase,
public content::WebContentsUserData<PrintViewManager> {
public:
+ class TestDelegate {
+ public:
+ virtual ~TestDelegate() {}
+
+ // Called when the given RFH performs a JS window.print() call. Returns true
+ // to continue processing window.print() normally, or false to immediately
+ // issue an IPC reply.
+ virtual bool ScriptedPrint(
+ const content::RenderFrameHost* render_frame_host);
+ };
+
~PrintViewManager() override;
#if BUILDFLAG(ENABLE_BASIC_PRINTING)
@@ -57,6 +69,9 @@ class PrintViewManager : public PrintViewManagerBase,
content::RenderFrameHost* print_preview_rfh() { return print_preview_rfh_; }
+ // Used in tests to observe and/or override behavior.
+ void SetTestDelegate(TestDelegate* delegate);
+
private:
explicit PrintViewManager(content::WebContents* web_contents);
friend class content::WebContentsUserData<PrintViewManager>;
@@ -78,14 +93,16 @@ class PrintViewManager : public PrintViewManagerBase,
base::Closure on_print_dialog_shown_callback_;
// Current state of print preview for this view.
- PrintPreviewState print_preview_state_;
+ PrintPreviewState print_preview_state_ = NOT_PREVIEWING;
// The current RFH that is print previewing. It should be a nullptr when
// |print_preview_state_| is NOT_PREVIEWING.
- content::RenderFrameHost* print_preview_rfh_;
+ content::RenderFrameHost* print_preview_rfh_ = nullptr;
// Keeps track of the pending callback during scripted print preview.
- content::RenderProcessHost* scripted_print_preview_rph_;
+ content::RenderProcessHost* scripted_print_preview_rph_ = nullptr;
+
+ TestDelegate* test_delegate_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
};

Powered by Google App Engine
This is Rietveld 408576698