summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-28 23:37:55 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-28 23:37:55 +0000
commit87c0254db050a6df147be484e2496aaa4b4f95a1 (patch)
treef0db8c3d0ab2c5e92ae48e43cbf210ca1e3042dd /chrome
parent0fc9dca2aae7f778a5a43aee1f898af7d93b15b8 (diff)
downloadchromium_src-87c0254db050a6df147be484e2496aaa4b4f95a1.zip
chromium_src-87c0254db050a6df147be484e2496aaa4b4f95a1.tar.gz
chromium_src-87c0254db050a6df147be484e2496aaa4b4f95a1.tar.bz2
Roll back r8821
Review URL: http://codereview.chromium.org/19453 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8834 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/printing/print_view_manager.cc16
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc8
-rw-r--r--chrome/browser/renderer_host/render_view_host.h16
-rw-r--r--chrome/browser/tab_contents/web_contents.cc13
-rw-r--r--chrome/common/render_messages_internal.h8
-rw-r--r--chrome/renderer/render_view.cc29
-rw-r--r--chrome/renderer/render_view.h4
7 files changed, 73 insertions, 21 deletions
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc
index 436742a..6813a15 100644
--- a/chrome/browser/printing/print_view_manager.cc
+++ b/chrome/browser/printing/print_view_manager.cc
@@ -254,8 +254,14 @@ void PrintViewManager::OnNotifyPrintJobInitEvent(
owner_.render_view_host()->IsRenderViewLive() &&
(!old_print_params.Equals(print_params_) ||
!event_details.document()->page_count())) {
- // TODO(maruel): Will never happen, this code is about to be deleted.
- NOTREACHED();
+ // This will generate a DidGetPrintedPagesCount() callback.
+ if (!owner_.render_view_host()->GetPrintedPagesCount(print_params_)) {
+ NOTREACHED();
+ if (inside_inner_message_loop_) {
+ MessageLoop::current()->Quit();
+ return;
+ }
+ }
}
// Continue even if owner_.render_view_host() is dead because we may already
@@ -471,8 +477,10 @@ void PrintViewManager::PrintNowInternal() {
if (!print_job_->document() ||
!print_job_->document()->IsComplete()) {
- // TODO(maruel): Will never happen. This code is about to be deleted.
- NOTREACHED();
+ ViewMsg_PrintPages_Params params;
+ params.params = print_params_;
+ params.pages = PageRange::GetPages(print_job_->settings().ranges);
+ owner_.render_view_host()->PrintPages(params);
}
}
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 4a4a431..cfc8aff 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -321,8 +321,12 @@ void RenderViewHost::Stop() {
Send(new ViewMsg_Stop(routing_id()));
}
-bool RenderViewHost::PrintPages() {
- return Send(new ViewMsg_PrintPages(routing_id()));
+bool RenderViewHost::GetPrintedPagesCount(const ViewMsg_Print_Params& params) {
+ return Send(new ViewMsg_GetPrintedPagesCount(routing_id(), params));
+}
+
+bool RenderViewHost::PrintPages(const ViewMsg_PrintPages_Params& params) {
+ return Send(new ViewMsg_PrintPages(routing_id(), params));
}
void RenderViewHost::StartFinding(int request_id,
diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h
index 19bb424..b355f48 100644
--- a/chrome/browser/renderer_host/render_view_host.h
+++ b/chrome/browser/renderer_host/render_view_host.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__
-#define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__
+#ifndef CHROME_BROWSER_RENDER_VIEW_HOST_H__
+#define CHROME_BROWSER_RENDER_VIEW_HOST_H__
#include <string>
#include <vector>
@@ -180,9 +180,13 @@ class RenderViewHost : public RenderWidgetHost {
void Stop();
- // Asks the renderer to "render" printed pages and initiate printing on our
- // behalf.
- bool PrintPages();
+ // Retrieves the number of printed pages that would result for the current web
+ // page and the specified settings. The response is a
+ // ViewHostMsg_DidGetPrintedPagesCount.
+ bool GetPrintedPagesCount(const ViewMsg_Print_Params& params);
+
+ // Asks the renderer to "render" printed pages.
+ bool PrintPages(const ViewMsg_PrintPages_Params& params);
// Start looking for a string within the content of the page, with the
// specified options.
@@ -623,4 +627,4 @@ class RenderViewHostFactory {
base::WaitableEvent* modal_dialog_event) = 0;
};
-#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__
+#endif // CHROME_BROWSER_RENDER_VIEW_HOST_H__
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index 63e6689..5c2fdb2 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -589,8 +589,15 @@ void WebContents::SavePage(const std::wstring& main_file,
}
void WebContents::PrintPreview() {
- // We don't show the print preview yet, only the print dialog.
- PrintNow();
+ // We can't print interstitial page for now.
+ if (showing_interstitial_page())
+ return;
+
+ // If we have a find bar it needs to hide as well.
+ view_->HideFindBar(false);
+
+ // We don't show the print preview for the beta, only the print dialog.
+ printing_.ShowPrintDialog();
}
bool WebContents::PrintNow() {
@@ -601,7 +608,7 @@ bool WebContents::PrintNow() {
// If we have a find bar it needs to hide as well.
view_->HideFindBar(false);
- return render_view_host()->PrintPages();
+ return printing_.PrintNow();
}
bool WebContents::IsActiveEntry(int32 page_id) {
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index c03a110..30c6469 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -97,9 +97,15 @@ IPC_BEGIN_MESSAGES(View, 1)
// This signals the render view that it can send another PaintRect message.
IPC_MESSAGE_ROUTED0(ViewMsg_PaintRect_ACK)
+ // Asks the renderer to calculate the number of printed pages according to the
+ // supplied settings. The renderer will reply with
+ // ViewHostMsg_DidGetPrintedPagesCount.
+ IPC_MESSAGE_ROUTED1(ViewMsg_GetPrintedPagesCount,
+ ViewMsg_Print_Params)
+
// 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.
- IPC_MESSAGE_ROUTED0(ViewMsg_PrintPages)
+ IPC_MESSAGE_ROUTED1(ViewMsg_PrintPages, ViewMsg_PrintPages_Params)
// Tells the render view that a ViewHostMsg_ScrollRect message was processed.
// This signals the render view that it can send another ScrollRect message.
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 45a64dc..b8d321a 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -341,6 +341,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_BEGIN_MESSAGE_MAP(RenderView, message)
IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, SendThumbnail)
+ IPC_MESSAGE_HANDLER(ViewMsg_GetPrintedPagesCount, OnGetPrintedPagesCount)
IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages)
IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop)
@@ -514,6 +515,12 @@ void RenderView::SwitchFrameToDisplayMediaType(WebFrame* frame) {
printed_document_width_ = 0;
}
+void RenderView::OnPrintPage(const ViewMsg_PrintPage_Params& params) {
+ DCHECK(webview());
+ if (webview())
+ PrintPage(params, webview()->GetMainFrame());
+}
+
void RenderView::PrintPage(const ViewMsg_PrintPage_Params& params,
WebFrame* frame) {
#if defined(OS_WIN)
@@ -639,12 +646,26 @@ void RenderView::PrintPage(const ViewMsg_PrintPage_Params& params,
#endif
}
-void RenderView::OnPrintPages() {
+void RenderView::OnGetPrintedPagesCount(const ViewMsg_Print_Params& params) {
DCHECK(webview());
- if (webview()) {
- // The renderer own the control flow as if it was a window.print() call.
- ScriptedPrint(webview()->GetMainFrame());
+ if (!webview()) {
+ Send(new ViewHostMsg_DidGetPrintedPagesCount(routing_id_,
+ params.document_cookie,
+ 0));
+ return;
}
+ WebFrame* frame = webview()->GetMainFrame();
+ int expected_pages = SwitchFrameToPrintMediaType(params, frame);
+ Send(new ViewHostMsg_DidGetPrintedPagesCount(routing_id_,
+ params.document_cookie,
+ expected_pages));
+ SwitchFrameToDisplayMediaType(frame);
+}
+
+void RenderView::OnPrintPages(const ViewMsg_PrintPages_Params& params) {
+ DCHECK(webview());
+ if (webview())
+ PrintPages(params, webview()->GetMainFrame());
}
void RenderView::PrintPages(const ViewMsg_PrintPages_Params& params,
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index ffd551e..c7f5384 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -398,7 +398,9 @@ class RenderView : public RenderWidget,
// RenderView IPC message handlers
void OnCreatingNewAck(gfx::NativeViewId parent);
void SendThumbnail();
- void OnPrintPages();
+ void OnPrintPage(const ViewMsg_PrintPage_Params& params);
+ void OnGetPrintedPagesCount(const ViewMsg_Print_Params& params);
+ void OnPrintPages(const ViewMsg_PrintPages_Params& params);
void OnNavigate(const ViewMsg_Navigate_Params& params);
void OnStop();
void OnLoadAlternateHTMLText(const std::string& html_contents,