Commit 055d6ed0 authored by vitalybuka's avatar vitalybuka Committed by Commit bot

More System Dialog printing code disabled on Windows.

BUG=374321

Review URL: https://codereview.chromium.org/517193003

Cr-Commit-Position: refs/heads/master@{#292747}
parent 3498e512
...@@ -46,10 +46,8 @@ PrintViewManager::~PrintViewManager() { ...@@ -46,10 +46,8 @@ PrintViewManager::~PrintViewManager() {
DCHECK_EQ(NOT_PREVIEWING, print_preview_state_); DCHECK_EQ(NOT_PREVIEWING, print_preview_state_);
} }
#if !defined(OS_WIN)
bool PrintViewManager::PrintForSystemDialogNow() { bool PrintViewManager::PrintForSystemDialogNow() {
#if defined(OS_WIN)
NOTREACHED();
#endif
return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id())); return PrintNowInternal(new PrintMsg_PrintForSystemDialog(routing_id()));
} }
...@@ -71,7 +69,7 @@ bool PrintViewManager::AdvancedPrintNow() { ...@@ -71,7 +69,7 @@ bool PrintViewManager::AdvancedPrintNow() {
return PrintNow(); return PrintNow();
} }
} }
#endif // !OS_WIN
bool PrintViewManager::PrintPreviewNow(bool selection_only) { bool PrintViewManager::PrintPreviewNow(bool selection_only) {
// Users can send print commands all they want and it is beyond // Users can send print commands all they want and it is beyond
// PrintViewManager's control. Just ignore the extra commands. // PrintViewManager's control. Just ignore the extra commands.
......
...@@ -22,6 +22,7 @@ class PrintViewManager : public PrintViewManagerBase, ...@@ -22,6 +22,7 @@ class PrintViewManager : public PrintViewManagerBase,
public: public:
virtual ~PrintViewManager(); virtual ~PrintViewManager();
#if !defined(OS_WIN)
// Same as PrintNow(), but for the case where a user prints with the system // Same as PrintNow(), but for the case where a user prints with the system
// dialog from print preview. // dialog from print preview.
bool PrintForSystemDialogNow(); bool PrintForSystemDialogNow();
...@@ -30,6 +31,7 @@ class PrintViewManager : public PrintViewManagerBase, ...@@ -30,6 +31,7 @@ class PrintViewManager : public PrintViewManagerBase,
// show the native system dialog. This can happen from both initiator and // show the native system dialog. This can happen from both initiator and
// preview dialog. // preview dialog.
bool AdvancedPrintNow(); bool AdvancedPrintNow();
#endif // !OS_WIN
// Initiate print preview of the current document by first notifying the // Initiate print preview of the current document by first notifying the
// renderer. Since this happens asynchronous, the print preview dialog // renderer. Since this happens asynchronous, the print preview dialog
......
...@@ -75,9 +75,11 @@ PrintViewManagerBase::~PrintViewManagerBase() { ...@@ -75,9 +75,11 @@ PrintViewManagerBase::~PrintViewManagerBase() {
DisconnectFromCurrentPrintJob(); DisconnectFromCurrentPrintJob();
} }
#if !defined(OS_WIN)
bool PrintViewManagerBase::PrintNow() { bool PrintViewManagerBase::PrintNow() {
return PrintNowInternal(new PrintMsg_PrintPages(routing_id())); return PrintNowInternal(new PrintMsg_PrintPages(routing_id()));
} }
#endif // !OS_WIN
void PrintViewManagerBase::UpdateScriptedPrintingBlocked() { void PrintViewManagerBase::UpdateScriptedPrintingBlocked() {
Send(new PrintMsg_SetScriptedPrintingBlocked( Send(new PrintMsg_SetScriptedPrintingBlocked(
......
...@@ -35,10 +35,12 @@ class PrintViewManagerBase : public content::NotificationObserver, ...@@ -35,10 +35,12 @@ class PrintViewManagerBase : public content::NotificationObserver,
public: public:
virtual ~PrintViewManagerBase(); virtual ~PrintViewManagerBase();
#if !defined(OS_WIN)
// Prints the current document immediately. Since the rendering is // Prints the current document immediately. Since the rendering is
// asynchronous, the actual printing will not be completed on the return of // asynchronous, the actual printing will not be completed on the return of
// this function. Returns false if printing is impossible at the moment. // this function. Returns false if printing is impossible at the moment.
virtual bool PrintNow(); virtual bool PrintNow();
#endif // !OS_WIN
// Whether to block scripted printing for our tab or not. // Whether to block scripted printing for our tab or not.
void UpdateScriptedPrintingBlocked(); void UpdateScriptedPrintingBlocked();
......
...@@ -566,9 +566,11 @@ void PrintPreviewHandler::RegisterMessages() { ...@@ -566,9 +566,11 @@ void PrintPreviewHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("getPrinterCapabilities", web_ui()->RegisterMessageCallback("getPrinterCapabilities",
base::Bind(&PrintPreviewHandler::HandleGetPrinterCapabilities, base::Bind(&PrintPreviewHandler::HandleGetPrinterCapabilities,
base::Unretained(this))); base::Unretained(this)));
#if !defined(OS_WIN)
web_ui()->RegisterMessageCallback("showSystemDialog", web_ui()->RegisterMessageCallback("showSystemDialog",
base::Bind(&PrintPreviewHandler::HandleShowSystemDialog, base::Bind(&PrintPreviewHandler::HandleShowSystemDialog,
base::Unretained(this))); base::Unretained(this)));
#endif // !OS_WIN
web_ui()->RegisterMessageCallback("signIn", web_ui()->RegisterMessageCallback("signIn",
base::Bind(&PrintPreviewHandler::HandleSignin, base::Bind(&PrintPreviewHandler::HandleSignin,
base::Unretained(this))); base::Unretained(this)));
...@@ -1022,6 +1024,7 @@ void PrintPreviewHandler::HandleManageCloudPrint( ...@@ -1022,6 +1024,7 @@ void PrintPreviewHandler::HandleManageCloudPrint(
false)); false));
} }
#if !defined(OS_WIN)
void PrintPreviewHandler::HandleShowSystemDialog( void PrintPreviewHandler::HandleShowSystemDialog(
const base::ListValue* /*args*/) { const base::ListValue* /*args*/) {
ReportStats(); ReportStats();
...@@ -1041,6 +1044,7 @@ void PrintPreviewHandler::HandleShowSystemDialog( ...@@ -1041,6 +1044,7 @@ void PrintPreviewHandler::HandleShowSystemDialog(
static_cast<PrintPreviewUI*>(web_ui()->GetController()); static_cast<PrintPreviewUI*>(web_ui()->GetController());
print_preview_ui->OnCancelPendingPreviewRequest(); print_preview_ui->OnCancelPendingPreviewRequest();
} }
#endif // !OS_WIN
void PrintPreviewHandler::HandleManagePrinters( void PrintPreviewHandler::HandleManagePrinters(
const base::ListValue* /*args*/) { const base::ListValue* /*args*/) {
...@@ -1286,9 +1290,11 @@ void PrintPreviewHandler::OnPrintPreviewFailed() { ...@@ -1286,9 +1290,11 @@ void PrintPreviewHandler::OnPrintPreviewFailed() {
ReportUserActionHistogram(PREVIEW_FAILED); ReportUserActionHistogram(PREVIEW_FAILED);
} }
#if !defined(OS_WIN)
void PrintPreviewHandler::ShowSystemDialog() { void PrintPreviewHandler::ShowSystemDialog() {
HandleShowSystemDialog(NULL); HandleShowSystemDialog(NULL);
} }
#endif // !OS_WIN
void PrintPreviewHandler::FileSelected(const base::FilePath& path, void PrintPreviewHandler::FileSelected(const base::FilePath& path,
int index, void* params) { int index, void* params) {
......
...@@ -79,9 +79,11 @@ class PrintPreviewHandler ...@@ -79,9 +79,11 @@ class PrintPreviewHandler
// Called when print preview failed. // Called when print preview failed.
void OnPrintPreviewFailed(); void OnPrintPreviewFailed();
#if !defined(OS_WIN)
// Called when the user press ctrl+shift+p to display the native system // Called when the user press ctrl+shift+p to display the native system
// dialog. // dialog.
void ShowSystemDialog(); void ShowSystemDialog();
#endif // !OS_WIN
#if defined(ENABLE_SERVICE_DISCOVERY) #if defined(ENABLE_SERVICE_DISCOVERY)
// PrivetLocalPrinterLister::Delegate implementation. // PrivetLocalPrinterLister::Delegate implementation.
...@@ -149,9 +151,11 @@ class PrintPreviewHandler ...@@ -149,9 +151,11 @@ class PrintPreviewHandler
// Gets the printer capabilities. First element of |args| is the printer name. // Gets the printer capabilities. First element of |args| is the printer name.
void HandleGetPrinterCapabilities(const base::ListValue* args); void HandleGetPrinterCapabilities(const base::ListValue* args);
#if !defined(OS_WIN)
// Asks the initiator renderer to show the native print system dialog. |args| // Asks the initiator renderer to show the native print system dialog. |args|
// is unused. // is unused.
void HandleShowSystemDialog(const base::ListValue* args); void HandleShowSystemDialog(const base::ListValue* args);
#endif // !OS_WIN
// Callback for the signin dialog to call once signin is complete. // Callback for the signin dialog to call once signin is complete.
void OnSigninComplete(); void OnSigninComplete();
......
...@@ -483,9 +483,11 @@ void PrintPreviewUI::OnPrintPreviewRequest(int request_id) { ...@@ -483,9 +483,11 @@ void PrintPreviewUI::OnPrintPreviewRequest(int request_id) {
g_print_preview_request_id_map.Get().Set(id_, request_id); g_print_preview_request_id_map.Get().Set(id_, request_id);
} }
#if !defined(OS_WIN)
void PrintPreviewUI::OnShowSystemDialog() { void PrintPreviewUI::OnShowSystemDialog() {
web_ui()->CallJavascriptFunction("onSystemDialogLinkClicked"); web_ui()->CallJavascriptFunction("onSystemDialogLinkClicked");
} }
#endif // !OS_WIN
void PrintPreviewUI::OnDidGetPreviewPageCount( void PrintPreviewUI::OnDidGetPreviewPageCount(
const PrintHostMsg_DidGetPreviewPageCount_Params& params) { const PrintHostMsg_DidGetPreviewPageCount_Params& params) {
......
...@@ -84,8 +84,10 @@ class PrintPreviewUI : public ConstrainedWebDialogUI { ...@@ -84,8 +84,10 @@ class PrintPreviewUI : public ConstrainedWebDialogUI {
// Notifies the Web UI of a print preview request with |request_id|. // Notifies the Web UI of a print preview request with |request_id|.
void OnPrintPreviewRequest(int request_id); void OnPrintPreviewRequest(int request_id);
#if !defined(OS_WIN)
// Notifies the Web UI to show the system dialog. // Notifies the Web UI to show the system dialog.
void OnShowSystemDialog(); void OnShowSystemDialog();
#endif // !OS_WIN
// Notifies the Web UI about the page count of the request preview. // Notifies the Web UI about the page count of the request preview.
void OnDidGetPreviewPageCount( void OnDidGetPreviewPageCount(
......
...@@ -318,10 +318,15 @@ IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu) ...@@ -318,10 +318,15 @@ IPC_MESSAGE_ROUTED0(PrintMsg_PrintNodeUnderContextMenu)
IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview, IPC_MESSAGE_ROUTED1(PrintMsg_PrintForPrintPreview,
base::DictionaryValue /* settings */) base::DictionaryValue /* settings */)
#if !defined(OS_WIN)
// Tells the render view to switch the CSS to print media type, renders every // Tells the render view to switch the CSS to print media type, renders every
// requested pages and switch back the CSS to display media type. // requested pages and switch back the CSS to display media type.
IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages) IPC_MESSAGE_ROUTED0(PrintMsg_PrintPages)
// Like PrintMsg_PrintPages, but using the print preview document's frame/node.
IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
#endif // !OS_WIN
// Tells the render view that printing is done so it can clean up. // Tells the render view that printing is done so it can clean up.
IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone, IPC_MESSAGE_ROUTED1(PrintMsg_PrintingDone,
bool /* success */) bool /* success */)
...@@ -336,9 +341,6 @@ IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked, ...@@ -336,9 +341,6 @@ IPC_MESSAGE_ROUTED1(PrintMsg_SetScriptedPrintingBlocked,
IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview, IPC_MESSAGE_ROUTED1(PrintMsg_PrintPreview,
base::DictionaryValue /* settings */) base::DictionaryValue /* settings */)
// Like PrintMsg_PrintPages, but using the print preview document's frame/node.
IPC_MESSAGE_ROUTED0(PrintMsg_PrintForSystemDialog)
// Messages sent from the renderer to the browser. // Messages sent from the renderer to the browser.
#if defined(OS_WIN) #if defined(OS_WIN)
......
...@@ -834,8 +834,10 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame, ...@@ -834,8 +834,10 @@ void PrintWebViewHelper::PrintPage(blink::WebLocalFrame* frame,
bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) {
bool handled = true; bool handled = true;
IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message) IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message)
#if !defined(OS_WIN)
IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages) IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages)
IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog) IPC_MESSAGE_HANDLER(PrintMsg_PrintForSystemDialog, OnPrintForSystemDialog)
#endif // !OS_WIN
IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview) IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, OnInitiatePrintPreview)
IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview)
IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview) IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, OnPrintForPrintPreview)
...@@ -932,6 +934,7 @@ bool PrintWebViewHelper::GetPrintFrame(blink::WebLocalFrame** frame) { ...@@ -932,6 +934,7 @@ bool PrintWebViewHelper::GetPrintFrame(blink::WebLocalFrame** frame) {
return true; return true;
} }
#if !defined(OS_WIN)
void PrintWebViewHelper::OnPrintPages() { void PrintWebViewHelper::OnPrintPages() {
blink::WebLocalFrame* frame; blink::WebLocalFrame* frame;
if (GetPrintFrame(&frame)) if (GetPrintFrame(&frame))
...@@ -944,9 +947,9 @@ void PrintWebViewHelper::OnPrintForSystemDialog() { ...@@ -944,9 +947,9 @@ void PrintWebViewHelper::OnPrintForSystemDialog() {
NOTREACHED(); NOTREACHED();
return; return;
} }
Print(frame, print_preview_context_.source_node()); Print(frame, print_preview_context_.source_node());
} }
#endif // !OS_WIN
void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout( void PrintWebViewHelper::GetPageSizeAndContentAreaFromPageLayout(
const PageSizeMargins& page_layout_in_points, const PageSizeMargins& page_layout_in_points,
...@@ -1223,6 +1226,7 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) { ...@@ -1223,6 +1226,7 @@ void PrintWebViewHelper::PrintNode(const blink::WebNode& node) {
print_node_in_progress_ = false; print_node_in_progress_ = false;
} }
#if !defined(OS_WIN)
void PrintWebViewHelper::Print(blink::WebLocalFrame* frame, void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
const blink::WebNode& node) { const blink::WebNode& node) {
// If still not finished with earlier print request simply ignore. // If still not finished with earlier print request simply ignore.
...@@ -1256,6 +1260,7 @@ void PrintWebViewHelper::Print(blink::WebLocalFrame* frame, ...@@ -1256,6 +1260,7 @@ void PrintWebViewHelper::Print(blink::WebLocalFrame* frame,
DidFinishPrinting(FAIL_PRINT); DidFinishPrinting(FAIL_PRINT);
} }
} }
#endif // !OS_WIN
void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) { void PrintWebViewHelper::DidFinishPrinting(PrintingResult result) {
switch (result) { switch (result) {
......
...@@ -118,8 +118,10 @@ class PrintWebViewHelper ...@@ -118,8 +118,10 @@ class PrintWebViewHelper
virtual void DidStopLoading() OVERRIDE; virtual void DidStopLoading() OVERRIDE;
// Message handlers --------------------------------------------------------- // Message handlers ---------------------------------------------------------
#if !defined(OS_WIN)
void OnPrintPages(); void OnPrintPages();
void OnPrintForSystemDialog(); void OnPrintForSystemDialog();
#endif // !OS_WIN
void OnInitiatePrintPreview(bool selection_only); void OnInitiatePrintPreview(bool selection_only);
void OnPrintPreview(const base::DictionaryValue& settings); void OnPrintPreview(const base::DictionaryValue& settings);
void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
......
...@@ -188,10 +188,13 @@ class PrintWebViewHelperTestBase : public ChromeRenderViewTest { ...@@ -188,10 +188,13 @@ class PrintWebViewHelperTestBase : public ChromeRenderViewTest {
} }
#endif // defined(OS_CHROMEOS) #endif // defined(OS_CHROMEOS)
} }
#if !defined(OS_WIN)
void OnPrintPages() { void OnPrintPages() {
PrintWebViewHelper::Get(view_)->OnPrintPages(); PrintWebViewHelper::Get(view_)->OnPrintPages();
ProcessPendingMessages(); ProcessPendingMessages();
} }
#endif // !OS_WIN
void VerifyPreviewRequest(bool requested) { void VerifyPreviewRequest(bool requested) {
const IPC::Message* print_msg = const IPC::Message* print_msg =
...@@ -233,6 +236,7 @@ class PrintWebViewHelperTest : public PrintWebViewHelperTestBase { ...@@ -233,6 +236,7 @@ class PrintWebViewHelperTest : public PrintWebViewHelperTestBase {
DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest); DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelperTest);
}; };
#if !defined(OS_WIN)
// Tests that printing pages work and sending and receiving messages through // Tests that printing pages work and sending and receiving messages through
// that channel all works. // that channel all works.
TEST_F(PrintWebViewHelperTest, OnPrintPages) { TEST_F(PrintWebViewHelperTest, OnPrintPages) {
...@@ -242,8 +246,9 @@ TEST_F(PrintWebViewHelperTest, OnPrintPages) { ...@@ -242,8 +246,9 @@ TEST_F(PrintWebViewHelperTest, OnPrintPages) {
VerifyPageCount(1); VerifyPageCount(1);
VerifyPagesPrinted(true); VerifyPagesPrinted(true);
} }
#endif // !OS_WIN
#if defined(OS_MACOSX) #if defined(OS_MACOSX) && !defined(OS_WIN)
// TODO(estade): I don't think this test is worth porting to Linux. We will have // TODO(estade): I don't think this test is worth porting to Linux. We will have
// to rip out and replace most of the IPC code if we ever plan to improve // to rip out and replace most of the IPC code if we ever plan to improve
// printing, and the comment below by sverrir suggests that it doesn't do much // printing, and the comment below by sverrir suggests that it doesn't do much
...@@ -284,7 +289,7 @@ TEST_F(PrintWebViewHelperTest, PrintWithIframe) { ...@@ -284,7 +289,7 @@ TEST_F(PrintWebViewHelperTest, PrintWithIframe) {
EXPECT_NE(0, image1.size().width()); EXPECT_NE(0, image1.size().width());
EXPECT_NE(0, image1.size().height()); EXPECT_NE(0, image1.size().height());
} }
#endif // OS_MACOSX #endif // OS_MACOSX && !OS_WIN
// Tests if we can print a page and verify its results. // Tests if we can print a page and verify its results.
// This test prints HTML pages into a pseudo printer and check their outputs, // This test prints HTML pages into a pseudo printer and check their outputs,
...@@ -330,7 +335,7 @@ const TestPageData kTestPages[] = { ...@@ -330,7 +335,7 @@ const TestPageData kTestPages[] = {
// hooking up Cairo to read a pdf stream, or accessing the cairo surface in the // hooking up Cairo to read a pdf stream, or accessing the cairo surface in the
// metafile directly. // metafile directly.
// Same for printing via PDF on Windows. // Same for printing via PDF on Windows.
#if defined(OS_MACOSX) #if defined(OS_MACOSX) && !defined(OS_WIN)
TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { TEST_F(PrintWebViewHelperTest, PrintLayoutTest) {
bool baseline = false; bool baseline = false;
...@@ -383,7 +388,7 @@ TEST_F(PrintWebViewHelperTest, PrintLayoutTest) { ...@@ -383,7 +388,7 @@ TEST_F(PrintWebViewHelperTest, PrintLayoutTest) {
} }
} }
} }
#endif // OS_MACOSX #endif // OS_MACOSX && !OS_WIN
// These print preview tests do not work on Chrome OS yet. // These print preview tests do not work on Chrome OS yet.
#if !defined(OS_CHROMEOS) #if !defined(OS_CHROMEOS)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment