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

Unified Diff: chrome/renderer/print_web_view_helper.cc

Issue 7038028: Initial support for cloudprint in print preview (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix bad merge Created 9 years, 7 months 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/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 fc34f7859e9563042c053c293afc0d7cc6986114..9f5be1bc9e0149e99789efcebbc5f3a484d1a47e 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -17,6 +17,7 @@
#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"
@@ -50,6 +51,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
@@ -580,7 +583,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;
@@ -593,15 +596,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,

Powered by Google App Engine
This is Rietveld 408576698