Index: chrome/renderer/print_web_view_helper.cc |
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc |
index 079d666402e39f4bdb95d84cf13fcf3b880c1e69..f8ed1bb4e3981c0a204a2e6da491da43db367528 100644 |
--- a/chrome/renderer/print_web_view_helper.cc |
+++ b/chrome/renderer/print_web_view_helper.cc |
@@ -14,10 +14,12 @@ |
#include "chrome/common/chrome_switches.h" |
#include "chrome/common/print_messages.h" |
#include "chrome/common/render_messages.h" |
+#include "chrome/common/url_constants.h" |
#include "chrome/renderer/prerender/prerender_helper.h" |
#include "content/renderer/render_view.h" |
#include "grit/generated_resources.h" |
#include "printing/metafile.h" |
+#include "printing/print_job_constants.h" |
#include "printing/units.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebConsoleMessage.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
@@ -25,9 +27,11 @@ |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" |
-#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
Lei Zhang
2011/06/14 01:08:08
no longer needed for this CL
Albert Bodenhamer
2011/06/14 19:43:54
Done.
|
#include "third_party/WebKit/Source/WebKit/chromium/public/WebSize.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLRequest.h" |
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebURLResponse.h" |
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
#include "ui/base/l10n/l10n_util.h" |
@@ -51,6 +55,8 @@ using WebKit::WebView; |
namespace { |
+const double kMinDpi = 1.0; |
+ |
int GetDPI(const PrintMsg_Print_Params* print_params) { |
#if defined(OS_MACOSX) |
// On the Mac, the printable area is in points, don't do any scaling based |
@@ -166,14 +172,14 @@ void PrintWebViewHelper::PrintPage(WebKit::WebFrame* frame) { |
bool PrintWebViewHelper::OnMessageReceived(const IPC::Message& message) { |
bool handled = true; |
IPC_BEGIN_MESSAGE_MAP(PrintWebViewHelper, message) |
+ IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, |
+ OnPrintForPrintPreview) |
IPC_MESSAGE_HANDLER(PrintMsg_PrintPages, OnPrintPages) |
IPC_MESSAGE_HANDLER(PrintMsg_InitiatePrintPreview, |
OnInitiatePrintPreview) |
IPC_MESSAGE_HANDLER(PrintMsg_PrintNodeUnderContextMenu, |
OnPrintNodeUnderContextMenu) |
IPC_MESSAGE_HANDLER(PrintMsg_PrintPreview, OnPrintPreview) |
- IPC_MESSAGE_HANDLER(PrintMsg_PrintForPrintPreview, |
- OnPrintForPrintPreview) |
IPC_MESSAGE_HANDLER(PrintMsg_PrintingDone, OnPrintingDone) |
IPC_MESSAGE_HANDLER(PrintMsg_ResetScriptedPrintCount, |
ResetScriptedPrintCount) |
@@ -211,7 +217,6 @@ void PrintWebViewHelper::OnPrintForPrintPreview( |
NOTREACHED() << "Failed to initialize print page settings"; |
return; |
} |
- |
if (!UpdatePrintSettings(job_settings)) { |
DidFinishPrinting(FAIL_PRINT); |
return; |
@@ -585,7 +590,7 @@ bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, |
l10n_util::GetStringUTF16(IDS_DEFAULT_PRINTER_NOT_FOUND_WARNING)); |
return false; |
} |
- if (!settings.params.dpi || !settings.params.document_cookie) { |
+ if (settings.params.dpi < kMinDpi || settings.params.document_cookie == 0) { |
// Invalid print page settings. |
NOTREACHED(); |
return false; |
@@ -598,15 +603,22 @@ bool PrintWebViewHelper::InitPrintSettings(WebKit::WebFrame* frame, |
bool PrintWebViewHelper::UpdatePrintSettings( |
const DictionaryValue& job_settings) { |
- PrintMsg_PrintPages_Params settings; |
- Send(new PrintHostMsg_UpdatePrintSettings(routing_id(), |
- print_pages_params_->params.document_cookie, job_settings, &settings)); |
+ bool print_to_cloud = job_settings.HasKey(printing::kSettingCloudPrintId); |
+ if (print_to_cloud) { |
+ // TODO(abodenha@chromium.org) Really update the settings for a cloud |
+ // printer. |
+ return true; |
+ } else { |
+ PrintMsg_PrintPages_Params settings; |
+ Send(new PrintHostMsg_UpdatePrintSettings(routing_id(), |
+ print_pages_params_->params.document_cookie, job_settings, &settings)); |
- if (!settings.params.dpi) |
- return false; |
+ if (settings.params.dpi < kMinDpi) |
+ return false; |
- print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); |
- return true; |
+ print_pages_params_.reset(new PrintMsg_PrintPages_Params(settings)); |
+ return true; |
+ } |
} |
bool PrintWebViewHelper::GetPrintSettingsFromUser(WebKit::WebFrame* frame, |