Chromium Code Reviews| Index: chrome/browser/ui/webui/print_preview/print_preview_distiller.cc |
| diff --git a/chrome/browser/ui/webui/print_preview/print_preview_distiller.cc b/chrome/browser/ui/webui/print_preview/print_preview_distiller.cc |
| index 213078ceb85605bc3e15201f11a47283ef373f82..40994ef99046f562042d1b95ee5e4782bf27e7e7 100644 |
| --- a/chrome/browser/ui/webui/print_preview/print_preview_distiller.cc |
| +++ b/chrome/browser/ui/webui/print_preview/print_preview_distiller.cc |
| @@ -21,6 +21,7 @@ |
| #include "chrome/common/prerender_messages.h" |
| #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" |
| #include "components/printing/common/print_messages.h" |
| +#include "content/public/browser/navigation_details.h" |
| #include "content/public/browser/notification_service.h" |
| #include "content/public/browser/render_frame_host.h" |
| #include "content/public/browser/render_process_host.h" |
| @@ -135,25 +136,10 @@ class PrintPreviewDistiller::WebContentsDelegateImpl |
| render_frame_host->GetRoutingID(), true)); |
| } |
| - void DidFinishLoad(content::RenderFrameHost* render_frame_host, |
| - const GURL& validated_url) override { |
| - // Ask the page to trigger an anchor navigation once the distilled |
| - // contents are added to the page. |
| - dom_distiller::RunIsolatedJavaScript( |
| - web_contents()->GetMainFrame(), |
| - "navigate_on_initial_content_load = true;"); |
| - } |
| - |
| - void DidNavigateMainFrame( |
| - const content::LoadCommittedDetails& details, |
| - const content::FrameNavigateParams& params) override { |
| - // The second content loads signals that the distilled contents have |
| - // been delivered to the page via inline JavaScript execution. |
| - if (web_contents()->GetController().GetEntryCount() > 1) { |
| - RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| - rvh->Send(new PrintMsg_InitiatePrintPreview(rvh->GetRoutingID(), false)); |
| - rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), *settings_)); |
| - } |
| + void DoPrintPreview() { |
| + RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| + rvh->Send(new PrintMsg_InitiatePrintPreview(rvh->GetRoutingID(), false)); |
| + rvh->Send(new PrintMsg_PrintPreview(rvh->GetRoutingID(), *settings_)); |
| } |
| void DidGetRedirectForResourceRequest( |
| @@ -169,6 +155,18 @@ class PrintPreviewDistiller::WebContentsDelegateImpl |
| on_failed_callback_.Run(); |
| } |
| + void DidNavigateMainFrame( |
| + const content::LoadCommittedDetails& details, |
| + const content::FrameNavigateParams& params) override { |
| + // Wait until we are done distilling the article and the target |
| + // WebContents is ready for printing. |
| + // The navigation to notify print preview that content is on the page will |
| + // be an in-page navigation. |
| + if (!details.is_in_page) |
| + return; |
| + DoPrintPreview(); |
|
wychen
2016/04/11 21:37:21
Add a TODO saying resources are not necessarily re
mvendramini_hp
2016/04/12 13:01:27
Done - added both our names. I would need some hel
|
| + } |
| + |
| void Observe(int type, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) override { |