summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/printing/print_job_worker.cc6
-rw-r--r--chrome/browser/printing/print_job_worker.h3
-rw-r--r--chrome/browser/printing/print_settings.cc7
-rw-r--r--chrome/browser/printing/print_settings.h6
-rw-r--r--chrome/browser/printing/printer_query.cc4
-rw-r--r--chrome/browser/printing/printer_query.h1
-rw-r--r--chrome/browser/printing/win_printing_context.cc65
-rw-r--r--chrome/browser/printing/win_printing_context.h11
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.cc3
-rw-r--r--chrome/browser/renderer_host/resource_message_filter.h1
-rw-r--r--chrome/common/render_messages.h12
-rw-r--r--chrome/common/render_messages_internal.h3
-rw-r--r--chrome/common/temp_scaffolding_stubs.h1
-rw-r--r--chrome/renderer/mock_printer.cc5
-rw-r--r--chrome/renderer/mock_printer.h4
-rw-r--r--chrome/renderer/mock_render_thread.cc9
-rw-r--r--chrome/renderer/mock_render_thread.h1
-rw-r--r--chrome/renderer/print_web_view_helper.cc6
18 files changed, 106 insertions, 42 deletions
diff --git a/chrome/browser/printing/print_job_worker.cc b/chrome/browser/printing/print_job_worker.cc
index d325bb9..19c2add 100644
--- a/chrome/browser/printing/print_job_worker.cc
+++ b/chrome/browser/printing/print_job_worker.cc
@@ -66,7 +66,8 @@ void PrintJobWorker::SetNewOwner(PrintJobWorkerOwner* new_owner) {
void PrintJobWorker::GetSettings(bool ask_user_for_settings,
HWND parent_window,
- int document_page_count) {
+ int document_page_count,
+ bool has_selection) {
DCHECK_EQ(message_loop(), MessageLoop::current());
DCHECK_EQ(page_number_, PageNumber::npos());
@@ -77,7 +78,8 @@ void PrintJobWorker::GetSettings(bool ask_user_for_settings,
PrintingContext::Result result;
if (ask_user_for_settings) {
result = printing_context_.AskUserForSettings(parent_window,
- document_page_count);
+ document_page_count,
+ has_selection);
} else {
result = printing_context_.UseDefaultSettings();
}
diff --git a/chrome/browser/printing/print_job_worker.h b/chrome/browser/printing/print_job_worker.h
index 3142567..cc1bde1 100644
--- a/chrome/browser/printing/print_job_worker.h
+++ b/chrome/browser/printing/print_job_worker.h
@@ -34,7 +34,8 @@ class PrintJobWorker : public base::Thread {
// Print... dialog box will be shown to ask the user his preference.
void GetSettings(bool ask_user_for_settings,
HWND parent_window,
- int document_page_count);
+ int document_page_count,
+ bool has_selection);
// Starts the printing loop. Every pages are printed as soon as the data is
// available. Makes sure the new_document is the right one.
diff --git a/chrome/browser/printing/print_settings.cc b/chrome/browser/printing/print_settings.cc
index 8c33acd..e25a937 100644
--- a/chrome/browser/printing/print_settings.cc
+++ b/chrome/browser/printing/print_settings.cc
@@ -18,6 +18,7 @@ PrintSettings::PrintSettings()
: min_shrink(1.25),
max_shrink(2.0),
desired_dpi(72),
+ selection_only(false),
dpi_(0),
landscape_(false) {
}
@@ -27,6 +28,7 @@ void PrintSettings::Clear() {
min_shrink = 1.25;
max_shrink = 2.;
desired_dpi = 72;
+ selection_only = false;
printer_name_.clear();
device_name_.clear();
page_setup_pixels_.Clear();
@@ -38,12 +40,14 @@ void PrintSettings::Clear() {
void PrintSettings::Init(HDC hdc,
const DEVMODE& dev_mode,
const PageRanges& new_ranges,
- const std::wstring& new_device_name) {
+ const std::wstring& new_device_name,
+ bool print_selection_only) {
DCHECK(hdc);
printer_name_ = dev_mode.dmDeviceName;
device_name_ = new_device_name;
ranges = new_ranges;
landscape_ = dev_mode.dmOrientation == DMORIENT_LANDSCAPE;
+ selection_only = print_selection_only;
dpi_ = GetDeviceCaps(hdc, LOGPIXELSX);
// No printer device is known to advertise different dpi in X and Y axis; even
@@ -101,6 +105,7 @@ void PrintSettings::RenderParams(ViewMsg_Print_Params* params) const {
params->desired_dpi = desired_dpi;
// Always use an invalid cookie.
params->document_cookie = 0;
+ params->selection_only = selection_only;
}
bool PrintSettings::Equals(const PrintSettings& rhs) const {
diff --git a/chrome/browser/printing/print_settings.h b/chrome/browser/printing/print_settings.h
index da65cb3..a82af96 100644
--- a/chrome/browser/printing/print_settings.h
+++ b/chrome/browser/printing/print_settings.h
@@ -30,7 +30,8 @@ class PrintSettings {
void Init(HDC hdc,
const DEVMODE& dev_mode,
const PageRanges& new_ranges,
- const std::wstring& new_device_name);
+ const std::wstring& new_device_name,
+ bool selection_only);
#endif
// Set printer printable area in in pixels.
@@ -78,6 +79,9 @@ class PrintSettings {
// The various overlays (headers and footers).
PageOverlays overlays;
+ // Indicates if the user only wants to print the current selection.
+ bool selection_only;
+
// Cookie generator. It is used to initialize PrintedDocument with its
// associated PrintSettings, to be sure that each generated PrintedPage is
// correctly associated with its corresponding PrintedDocument.
diff --git a/chrome/browser/printing/printer_query.cc b/chrome/browser/printing/printer_query.cc
index f5ca6a5..3bcee7a 100644
--- a/chrome/browser/printing/printer_query.cc
+++ b/chrome/browser/printing/printer_query.cc
@@ -64,6 +64,7 @@ PrintJobWorker* PrinterQuery::DetachWorker(PrintJobWorkerOwner* new_owner) {
void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings,
HWND parent_window,
int expected_page_count,
+ bool has_selection,
CancelableTask* callback) {
DCHECK_EQ(ui_message_loop_, MessageLoop::current());
DCHECK(!is_print_dialog_box_shown_);
@@ -91,7 +92,8 @@ void PrinterQuery::GetSettings(GetSettingsAskParam ask_user_for_settings,
&PrintJobWorker::GetSettings,
is_print_dialog_box_shown_,
parent_window,
- expected_page_count));
+ expected_page_count,
+ has_selection));
}
void PrinterQuery::StopWorker() {
diff --git a/chrome/browser/printing/printer_query.h b/chrome/browser/printing/printer_query.h
index 3d389db..6d6fd88 100644
--- a/chrome/browser/printing/printer_query.h
+++ b/chrome/browser/printing/printer_query.h
@@ -57,6 +57,7 @@ class PrinterQuery : public base::RefCountedThreadSafe<PrinterQuery>,
void GetSettings(GetSettingsAskParam ask_user_for_settings,
HWND parent_window,
int expected_page_count,
+ bool has_selection,
CancelableTask* callback);
// Stops the worker thread since the client is done with this object.
diff --git a/chrome/browser/printing/win_printing_context.cc b/chrome/browser/printing/win_printing_context.cc
index 7a43b4d..7aaaf8e 100644
--- a/chrome/browser/printing/win_printing_context.cc
+++ b/chrome/browser/printing/win_printing_context.cc
@@ -152,8 +152,10 @@ PrintingContext::~PrintingContext() {
ResetSettings();
}
-PrintingContext::Result PrintingContext::AskUserForSettings(HWND window,
- int max_pages) {
+PrintingContext::Result PrintingContext::AskUserForSettings(
+ HWND window,
+ int max_pages,
+ bool has_selection) {
DCHECK(window);
DCHECK(!in_print_job_);
dialog_box_dismissed_ = false;
@@ -168,12 +170,13 @@ PrintingContext::Result PrintingContext::AskUserForSettings(HWND window,
// On failure, the settings are reset and FAILED is returned.
PRINTDLGEX dialog_options = { sizeof(PRINTDLGEX) };
dialog_options.hwndOwner = window;
- // Disables the Current Page and Selection radio buttons since WebKit can't
- // print a part of the webpage and we don't know which page is the current
- // one.
+ // Disable options we don't support currently.
// TODO(maruel): Reuse the previously loaded settings!
dialog_options.Flags = PD_RETURNDC | PD_USEDEVMODECOPIESANDCOLLATE |
- PD_NOSELECTION | PD_NOCURRENTPAGE | PD_HIDEPRINTTOFILE;
+ PD_NOCURRENTPAGE | PD_HIDEPRINTTOFILE;
+ if (!has_selection)
+ dialog_options.Flags |= PD_NOSELECTION;
+
PRINTPAGERANGE ranges[32];
dialog_options.nStartPage = START_PAGE_GENERAL;
if (max_pages) {
@@ -253,7 +256,7 @@ PrintingContext::Result PrintingContext::NewDocument(
const std::wstring& document_name) {
DCHECK(!in_print_job_);
if (!hdc_)
- return OnErrror();
+ return OnError();
// Set the flag used by the AbortPrintJob dialog procedure.
abort_printing_ = false;
@@ -262,7 +265,7 @@ PrintingContext::Result PrintingContext::NewDocument(
// Register the application's AbortProc function with GDI.
if (SP_ERROR == SetAbortProc(hdc_, &AbortProc))
- return OnErrror();
+ return OnError();
DOCINFO di = { sizeof(DOCINFO) };
di.lpszDocName = document_name.c_str();
@@ -297,7 +300,7 @@ PrintingContext::Result PrintingContext::NewDocument(
// NOTE: StartDoc() starts a message loop. That causes a lot of problems with
// IPC. Make sure recursive task processing is disabled.
if (StartDoc(hdc_, &di) <= 0)
- return OnErrror();
+ return OnError();
#ifndef NDEBUG
page_number_ = 0;
@@ -312,7 +315,7 @@ PrintingContext::Result PrintingContext::NewPage() {
// Inform the driver that the application is about to begin sending data.
if (StartPage(hdc_) <= 0)
- return OnErrror();
+ return OnError();
#ifndef NDEBUG
++page_number_;
@@ -327,7 +330,7 @@ PrintingContext::Result PrintingContext::PageDone() {
DCHECK(in_print_job_);
if (EndPage(hdc_) <= 0)
- return OnErrror();
+ return OnError();
return OK;
}
@@ -338,7 +341,7 @@ PrintingContext::Result PrintingContext::DocumentDone() {
// Inform the driver that document has ended.
if (EndDoc(hdc_) <= 0)
- return OnErrror();
+ return OnError();
ResetSettings();
return OK;
@@ -359,7 +362,7 @@ void PrintingContext::DismissDialog() {
}
}
-PrintingContext::Result PrintingContext::OnErrror() {
+PrintingContext::Result PrintingContext::OnError() {
// This will close hdc_ and clear settings_.
ResetSettings();
return abort_printing_ ? CANCEL : FAILED;
@@ -378,7 +381,8 @@ BOOL PrintingContext::AbortProc(HDC hdc, int nCode) {
bool PrintingContext::InitializeSettings(const DEVMODE& dev_mode,
const std::wstring& new_device_name,
const PRINTPAGERANGE* ranges,
- int number_ranges) {
+ int number_ranges,
+ bool selection_only) {
skia::PlatformDeviceWin::InitializeDC(hdc_);
DCHECK(GetDeviceCaps(hdc_, CLIPCAPS));
DCHECK(GetDeviceCaps(hdc_, RASTERCAPS) & RC_STRETCHDIB);
@@ -408,7 +412,11 @@ bool PrintingContext::InitializeSettings(const DEVMODE& dev_mode,
range.to = ranges[i].nToPage - 1;
ranges_vector.push_back(range);
}
- settings_.Init(hdc_, dev_mode, ranges_vector, new_device_name);
+ settings_.Init(hdc_,
+ dev_mode,
+ ranges_vector,
+ new_device_name,
+ selection_only);
return true;
}
@@ -427,7 +435,7 @@ bool PrintingContext::GetPrinterSettings(HANDLE printer,
ResetSettings();
return false;
}
- return InitializeSettings(*info_9->pDevMode, device_name, NULL, 0);
+ return InitializeSettings(*info_9->pDevMode, device_name, NULL, 0, false);
}
buffer.reset();
}
@@ -441,7 +449,7 @@ bool PrintingContext::GetPrinterSettings(HANDLE printer,
ResetSettings();
return false;
}
- return InitializeSettings(*info_8->pDevMode, device_name, NULL, 0);
+ return InitializeSettings(*info_8->pDevMode, device_name, NULL, 0, false);
}
buffer.reset();
}
@@ -456,7 +464,7 @@ bool PrintingContext::GetPrinterSettings(HANDLE printer,
ResetSettings();
return false;
}
- return InitializeSettings(*info_2->pDevMode, device_name, NULL, 0);
+ return InitializeSettings(*info_2->pDevMode, device_name, NULL, 0, false);
}
buffer.reset();
}
@@ -503,14 +511,21 @@ PrintingContext::Result PrintingContext::ParseDialogResultEx(
bool success = false;
if (dev_mode && !device_name.empty()) {
hdc_ = dialog_options.hDC;
+ PRINTPAGERANGE* page_ranges = NULL;
+ DWORD num_page_ranges = 0;
+ bool print_selection_only = false;
if (dialog_options.Flags & PD_PAGENUMS) {
- success = InitializeSettings(*dev_mode,
- device_name,
- dialog_options.lpPageRanges,
- dialog_options.nPageRanges);
- } else {
- success = InitializeSettings(*dev_mode, device_name, NULL, 0);
+ page_ranges = dialog_options.lpPageRanges;
+ num_page_ranges = dialog_options.nPageRanges;
+ }
+ if (dialog_options.Flags & PD_SELECTION) {
+ print_selection_only = true;
}
+ success = InitializeSettings(*dev_mode,
+ device_name,
+ dialog_options.lpPageRanges,
+ dialog_options.nPageRanges,
+ print_selection_only);
}
if (!success && dialog_options.hDC) {
@@ -574,7 +589,7 @@ PrintingContext::Result PrintingContext::ParseDialogResult(
bool success = false;
if (dev_mode && !device_name.empty()) {
hdc_ = dialog_options.hDC;
- success = InitializeSettings(*dev_mode, device_name, NULL, 0);
+ success = InitializeSettings(*dev_mode, device_name, NULL, 0, false);
}
if (!success && dialog_options.hDC) {
diff --git a/chrome/browser/printing/win_printing_context.h b/chrome/browser/printing/win_printing_context.h
index eaacc02..320a512 100644
--- a/chrome/browser/printing/win_printing_context.h
+++ b/chrome/browser/printing/win_printing_context.h
@@ -31,7 +31,7 @@ class PrintingContext {
// Asks the user what printer and format should be used to print. Updates the
// context with the select device settings.
- Result AskUserForSettings(HWND window, int max_pages);
+ Result AskUserForSettings(HWND window, int max_pages, bool has_selection);
// Selects the user's default printer and format. Updates the context with the
// default device settings.
@@ -81,10 +81,10 @@ class PrintingContext {
// temporary object used during the Print... dialog display.
class CallbackHandler;
- // Does bookeeping when an error occurs.
- PrintingContext::Result OnErrror();
+ // Does bookkeeping when an error occurs.
+ PrintingContext::Result OnError();
- // Used in response to the user cancelling the printing.
+ // Used in response to the user canceling the printing.
static BOOL CALLBACK AbortProc(HDC hdc, int nCode);
// Reads the settings from the selected device context. Updates settings_ and
@@ -92,7 +92,8 @@ class PrintingContext {
bool InitializeSettings(const DEVMODE& dev_mode,
const std::wstring& new_device_name,
const PRINTPAGERANGE* ranges,
- int number_ranges);
+ int number_ranges,
+ bool selection_only);
// Retrieves the printer's default low-level settings. hdc_ is allocated with
// this call.
diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc
index c9d6a04..4db2831 100644
--- a/chrome/browser/renderer_host/resource_message_filter.cc
+++ b/chrome/browser/renderer_host/resource_message_filter.cc
@@ -692,6 +692,7 @@ void ResourceMessageFilter::OnGetDefaultPrintSettings(IPC::Message* reply_msg) {
printer_query->GetSettings(printing::PrinterQuery::DEFAULTS,
NULL,
0,
+ false,
task);
}
@@ -720,6 +721,7 @@ void ResourceMessageFilter::OnGetDefaultPrintSettingsReply(
void ResourceMessageFilter::OnScriptedPrint(gfx::NativeViewId host_window_id,
int cookie,
int expected_pages_count,
+ bool has_selection,
IPC::Message* reply_msg) {
HWND host_window = gfx::NativeViewFromId(host_window_id);
@@ -746,6 +748,7 @@ void ResourceMessageFilter::OnScriptedPrint(gfx::NativeViewId host_window_id,
printer_query->GetSettings(printing::PrinterQuery::ASK_USER,
host_window,
expected_pages_count,
+ has_selection,
task);
}
diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h
index e5c7f96..d825dd2b 100644
--- a/chrome/browser/renderer_host/resource_message_filter.h
+++ b/chrome/browser/renderer_host/resource_message_filter.h
@@ -199,6 +199,7 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter,
void OnScriptedPrint(gfx::NativeViewId host_window,
int cookie,
int expected_pages_count,
+ bool has_selection,
IPC::Message* reply_msg);
void OnScriptedPrintReply(
scoped_refptr<printing::PrinterQuery> printer_query,
diff --git a/chrome/common/render_messages.h b/chrome/common/render_messages.h
index 76341c5..4f10abf 100644
--- a/chrome/common/render_messages.h
+++ b/chrome/common/render_messages.h
@@ -291,19 +291,23 @@ struct ViewMsg_Print_Params {
// Cookie for the document to ensure correctness.
int document_cookie;
+ // Should only print currently selected text.
+ bool selection_only;
+
// Warning: do not compare document_cookie.
bool Equals(const ViewMsg_Print_Params& rhs) const {
return printable_size == rhs.printable_size &&
dpi == rhs.dpi &&
min_shrink == rhs.min_shrink &&
max_shrink == rhs.max_shrink &&
- desired_dpi == rhs.desired_dpi;
+ desired_dpi == rhs.desired_dpi &&
+ selection_only == rhs.selection_only;
}
// Checking if the current params is empty. Just initialized after a memset.
bool IsEmpty() const {
return !document_cookie && !desired_dpi && !max_shrink && !min_shrink &&
- !dpi && printable_size.IsEmpty();
+ !dpi && printable_size.IsEmpty() && !selection_only;
}
};
@@ -1426,6 +1430,7 @@ struct ParamTraits<ViewMsg_Print_Params> {
WriteParam(m, p.max_shrink);
WriteParam(m, p.desired_dpi);
WriteParam(m, p.document_cookie);
+ WriteParam(m, p.selection_only);
}
static bool Read(const Message* m, void** iter, param_type* p) {
return ReadParam(m, iter, &p->printable_size) &&
@@ -1433,7 +1438,8 @@ struct ParamTraits<ViewMsg_Print_Params> {
ReadParam(m, iter, &p->min_shrink) &&
ReadParam(m, iter, &p->max_shrink) &&
ReadParam(m, iter, &p->desired_dpi) &&
- ReadParam(m, iter, &p->document_cookie);
+ ReadParam(m, iter, &p->document_cookie) &&
+ ReadParam(m, iter, &p->selection_only);
}
static void Log(const param_type& p, std::wstring* l) {
l->append(L"<ViewMsg_Print_Params>");
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 655df6a..d6d56bf 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -1070,10 +1070,11 @@ IPC_BEGIN_MESSAGES(ViewHost)
// by javascript. This step is about showing UI to the user to select the
// final print settings. The output parameter is the same as
// ViewMsg_PrintPages which is executed implicitly.
- IPC_SYNC_MESSAGE_ROUTED3_1(ViewHostMsg_ScriptedPrint,
+ IPC_SYNC_MESSAGE_ROUTED4_1(ViewHostMsg_ScriptedPrint,
gfx::NativeViewId /* host_window */,
int /* cookie */,
int /* expected_pages_count */,
+ bool /* has_selection */,
ViewMsg_PrintPages_Params /* settings choosen by
the user*/)
#endif // defined(OS_WIN)
diff --git a/chrome/common/temp_scaffolding_stubs.h b/chrome/common/temp_scaffolding_stubs.h
index dfdb277..c800f32 100644
--- a/chrome/common/temp_scaffolding_stubs.h
+++ b/chrome/common/temp_scaffolding_stubs.h
@@ -105,6 +105,7 @@ class PrinterQuery : public base::RefCountedThreadSafe<PrinterQuery> {
void GetSettings(GetSettingsAskParam ask_user_for_settings,
int parent_window,
int expected_page_count,
+ bool has_selection,
CancelableTask* callback) { NOTIMPLEMENTED(); }
PrintingContext::Result last_status() { return PrintingContext::FAILED; }
const PrintSettings& settings() { NOTIMPLEMENTED(); return settings_; }
diff --git a/chrome/renderer/mock_printer.cc b/chrome/renderer/mock_printer.cc
index 88f9909..1b0dcc5 100644
--- a/chrome/renderer/mock_printer.cc
+++ b/chrome/renderer/mock_printer.cc
@@ -20,6 +20,7 @@ MockPrinter::MockPrinter()
max_shrink_(2.0),
min_shrink_(1.25),
desired_dpi_(72),
+ selection_only_(false),
document_cookie_(-1),
current_document_cookie_(0),
printer_status_(PRINTER_READY),
@@ -49,6 +50,7 @@ void MockPrinter::GetDefaultPrintSettings(ViewMsg_Print_Params* params) {
params->max_shrink = max_shrink_;
params->min_shrink = min_shrink_;
params->desired_dpi = desired_dpi_;
+ params->selection_only = selection_only_;
params->document_cookie = document_cookie_;
params->printable_size.set_width(printable_width_);
params->printable_size.set_height(printable_height_);
@@ -59,12 +61,14 @@ void MockPrinter::SetDefaultPrintSettings(const ViewMsg_Print_Params& params) {
max_shrink_ = params.max_shrink;
min_shrink_ = params.min_shrink;
desired_dpi_ = params.desired_dpi;
+ selection_only_ = params.selection_only;
printable_width_ = params.printable_size.width();
printable_height_ = params.printable_size.height();
}
void MockPrinter::ScriptedPrint(int cookie,
int expected_pages_count,
+ bool has_selection,
ViewMsg_PrintPages_Params* settings) {
// Verify the input parameters.
EXPECT_EQ(document_cookie_, cookie);
@@ -74,6 +78,7 @@ void MockPrinter::ScriptedPrint(int cookie,
settings->params.max_shrink = max_shrink_;
settings->params.min_shrink = min_shrink_;
settings->params.desired_dpi = desired_dpi_;
+ settings->params.selection_only = selection_only_;
settings->params.document_cookie = document_cookie_;
settings->params.printable_size.set_width(printable_width_);
settings->params.printable_size.set_height(printable_height_);
diff --git a/chrome/renderer/mock_printer.h b/chrome/renderer/mock_printer.h
index bf318c1..16577cb 100644
--- a/chrome/renderer/mock_printer.h
+++ b/chrome/renderer/mock_printer.h
@@ -100,6 +100,7 @@ class MockPrinter {
void GetDefaultPrintSettings(ViewMsg_Print_Params* params);
void ScriptedPrint(int cookie,
int expected_pages_count,
+ bool has_selection,
ViewMsg_PrintPages_Params* settings);
void SetPrintedPagesCount(int cookie, int number_pages);
void PrintPage(const ViewHostMsg_DidPrintPage_Params& params);
@@ -133,6 +134,9 @@ class MockPrinter {
// Desired apparent dpi on paper.
int desired_dpi_;
+ // Print selection.
+ bool selection_only_;
+
// Cookie for the document to ensure correctness.
int document_cookie_;
int current_document_cookie_;
diff --git a/chrome/renderer/mock_render_thread.cc b/chrome/renderer/mock_render_thread.cc
index 8ff04a9..a9df6fd 100644
--- a/chrome/renderer/mock_render_thread.cc
+++ b/chrome/renderer/mock_render_thread.cc
@@ -117,9 +117,14 @@ void MockRenderThread::OnGetDefaultPrintSettings(ViewMsg_Print_Params* params) {
void MockRenderThread::OnScriptedPrint(gfx::NativeViewId host_window,
int cookie,
int expected_pages_count,
+ bool has_selection,
ViewMsg_PrintPages_Params* settings) {
- if (printer_.get())
- printer_->ScriptedPrint(cookie, expected_pages_count, settings);
+ if (printer_.get()) {
+ printer_->ScriptedPrint(cookie,
+ expected_pages_count,
+ has_selection,
+ settings);
+ }
}
void MockRenderThread::OnDidGetPrintedPagesCount(int cookie, int number_pages) {
diff --git a/chrome/renderer/mock_render_thread.h b/chrome/renderer/mock_render_thread.h
index ebca0df..75ca5d3 100644
--- a/chrome/renderer/mock_render_thread.h
+++ b/chrome/renderer/mock_render_thread.h
@@ -92,6 +92,7 @@ class MockRenderThread : public RenderThreadBase {
void OnScriptedPrint(gfx::NativeViewId host_window,
int cookie,
int expected_pages_count,
+ bool has_selection,
ViewMsg_PrintPages_Params* settings);
void OnDidGetPrintedPagesCount(int cookie, int number_pages);
diff --git a/chrome/renderer/print_web_view_helper.cc b/chrome/renderer/print_web_view_helper.cc
index 4e1f50f..687f196 100644
--- a/chrome/renderer/print_web_view_helper.cc
+++ b/chrome/renderer/print_web_view_helper.cc
@@ -127,10 +127,16 @@ void PrintWebViewHelper::SyncPrint(WebFrame* frame) {
render_view_->host_window(),
default_settings.document_cookie,
expected_pages_count,
+ true, // has_selection
&print_settings);
if (Send(msg)) {
msg = NULL;
+ // Printing selection only not supported yet.
+ if (print_settings.params.selection_only) {
+ NOTIMPLEMENTED();
+ }
+
// If the settings are invalid, early quit.
if (print_settings.params.dpi &&
print_settings.params.document_cookie) {