summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authormaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-28 20:23:58 +0000
committermaruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-28 20:23:58 +0000
commitdbc77768039c629d0165b6f0ec8ce26e24e1da4d (patch)
tree947c519d1518c57a230961b73a0d03795531ab57 /chrome
parentb5a58cba835df1fecff5383d3a81093e8bfa2573 (diff)
downloadchromium_src-dbc77768039c629d0165b6f0ec8ce26e24e1da4d.zip
chromium_src-dbc77768039c629d0165b6f0ec8ce26e24e1da4d.tar.gz
chromium_src-dbc77768039c629d0165b6f0ec8ce26e24e1da4d.tar.bz2
Disconnect the "browser controlled printing" and always delegate the control flow to the renderer.
Followup changes will remove more parts that are not needed anymore. Review URL: http://codereview.chromium.org/18860 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8821 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, 21 insertions, 73 deletions
diff --git a/chrome/browser/printing/print_view_manager.cc b/chrome/browser/printing/print_view_manager.cc
index 6813a15..436742a 100644
--- a/chrome/browser/printing/print_view_manager.cc
+++ b/chrome/browser/printing/print_view_manager.cc
@@ -254,14 +254,8 @@ void PrintViewManager::OnNotifyPrintJobInitEvent(
owner_.render_view_host()->IsRenderViewLive() &&
(!old_print_params.Equals(print_params_) ||
!event_details.document()->page_count())) {
- // This will generate a DidGetPrintedPagesCount() callback.
- if (!owner_.render_view_host()->GetPrintedPagesCount(print_params_)) {
- NOTREACHED();
- if (inside_inner_message_loop_) {
- MessageLoop::current()->Quit();
- return;
- }
- }
+ // TODO(maruel): Will never happen, this code is about to be deleted.
+ NOTREACHED();
}
// Continue even if owner_.render_view_host() is dead because we may already
@@ -477,10 +471,8 @@ void PrintViewManager::PrintNowInternal() {
if (!print_job_->document() ||
!print_job_->document()->IsComplete()) {
- ViewMsg_PrintPages_Params params;
- params.params = print_params_;
- params.pages = PageRange::GetPages(print_job_->settings().ranges);
- owner_.render_view_host()->PrintPages(params);
+ // TODO(maruel): Will never happen. This code is about to be deleted.
+ NOTREACHED();
}
}
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 5bd9af5..24a2a31 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -318,12 +318,8 @@ void RenderViewHost::Stop() {
Send(new ViewMsg_Stop(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));
+bool RenderViewHost::PrintPages() {
+ return Send(new ViewMsg_PrintPages(routing_id()));
}
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 0c968e4..9529258 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_RENDER_VIEW_HOST_H__
-#define CHROME_BROWSER_RENDER_VIEW_HOST_H__
+#ifndef CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__
+#define CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__
#include <string>
#include <vector>
@@ -173,13 +173,9 @@ class RenderViewHost : public RenderWidgetHost {
void Stop();
- // 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);
+ // Asks the renderer to "render" printed pages and initiate printing on our
+ // behalf.
+ bool PrintPages();
// Start looking for a string within the content of the page, with the
// specified options.
@@ -620,4 +616,4 @@ class RenderViewHostFactory {
base::WaitableEvent* modal_dialog_event) = 0;
};
-#endif // CHROME_BROWSER_RENDER_VIEW_HOST_H__
+#endif // CHROME_BROWSER_RENDERER_HOST_RENDER_VIEW_HOST_H__
diff --git a/chrome/browser/tab_contents/web_contents.cc b/chrome/browser/tab_contents/web_contents.cc
index 5c2fdb2..63e6689 100644
--- a/chrome/browser/tab_contents/web_contents.cc
+++ b/chrome/browser/tab_contents/web_contents.cc
@@ -589,15 +589,8 @@ void WebContents::SavePage(const std::wstring& main_file,
}
void WebContents::PrintPreview() {
- // 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();
+ // We don't show the print preview yet, only the print dialog.
+ PrintNow();
}
bool WebContents::PrintNow() {
@@ -608,7 +601,7 @@ bool WebContents::PrintNow() {
// If we have a find bar it needs to hide as well.
view_->HideFindBar(false);
- return printing_.PrintNow();
+ return render_view_host()->PrintPages();
}
bool WebContents::IsActiveEntry(int32 page_id) {
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 30c6469..c03a110 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -97,15 +97,9 @@ 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_ROUTED1(ViewMsg_PrintPages, ViewMsg_PrintPages_Params)
+ IPC_MESSAGE_ROUTED0(ViewMsg_PrintPages)
// 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 b8d321a..45a64dc 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -341,7 +341,6 @@ 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)
@@ -515,12 +514,6 @@ 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)
@@ -646,26 +639,12 @@ void RenderView::PrintPage(const ViewMsg_PrintPage_Params& params,
#endif
}
-void RenderView::OnGetPrintedPagesCount(const ViewMsg_Print_Params& params) {
+void RenderView::OnPrintPages() {
DCHECK(webview());
- if (!webview()) {
- Send(new ViewHostMsg_DidGetPrintedPagesCount(routing_id_,
- params.document_cookie,
- 0));
- return;
+ if (webview()) {
+ // The renderer own the control flow as if it was a window.print() call.
+ ScriptedPrint(webview()->GetMainFrame());
}
- 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 c7f5384..ffd551e 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -398,9 +398,7 @@ class RenderView : public RenderWidget,
// RenderView IPC message handlers
void OnCreatingNewAck(gfx::NativeViewId parent);
void SendThumbnail();
- void OnPrintPage(const ViewMsg_PrintPage_Params& params);
- void OnGetPrintedPagesCount(const ViewMsg_Print_Params& params);
- void OnPrintPages(const ViewMsg_PrintPages_Params& params);
+ void OnPrintPages();
void OnNavigate(const ViewMsg_Navigate_Params& params);
void OnStop();
void OnLoadAlternateHTMLText(const std::string& html_contents,