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); |
}; |