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

Unified Diff: chrome/browser/ui/webui/print_preview/print_preview_distiller.cc

Issue 1575473002: Improve syncing between dom distiller and the print preview request (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added TODO item - resources readiness before calling doprintpreview Created 4 years, 8 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
« no previous file with comments | « no previous file | components/dom_distiller/core/javascript/dom_distiller_viewer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..6dc6db85ded55449c6c8878d80e4c6678a2554e5 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,21 @@ 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;
+ // TODO(mvendra, wychen): resources (images, web fonts) are not necessarily
+ // ready at this point - so deferring the call to
+ // DoPrintPreview could be warranted
+ DoPrintPreview();
+ }
+
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override {
« no previous file with comments | « no previous file | components/dom_distiller/core/javascript/dom_distiller_viewer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698