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

Unified Diff: components/dom_distiller/content/distiller_page_web_contents.cc

Issue 146843010: Add support for multipage distillation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address Chris' comments. Created 6 years, 11 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
Index: components/dom_distiller/content/distiller_page_web_contents.cc
diff --git a/components/dom_distiller/content/distiller_page_web_contents.cc b/components/dom_distiller/content/distiller_page_web_contents.cc
index c0c7ff565225cc228a9ec156c87149037986479f..06bd6bcff97c25918a524958b88046216866e9f4 100644
--- a/components/dom_distiller/content/distiller_page_web_contents.cc
+++ b/components/dom_distiller/content/distiller_page_web_contents.cc
@@ -55,16 +55,22 @@ void DistillerPageWebContents::ExecuteJavaScriptImpl(
base::string16(), // frame_xpath
base::UTF8ToUTF16(script),
base::Bind(&DistillerPage::OnExecuteJavaScriptDone,
- base::Unretained(this)));
+ base::Unretained(this),
+ web_contents_->GetLastCommittedURL()));
}
void DistillerPageWebContents::DidFinishLoad(int64 frame_id,
const GURL& validated_url,
bool is_main_frame,
RenderViewHost* render_view_host) {
- content::WebContentsObserver::Observe(NULL);
- OnLoadURLDone();
+ // TODO(shashishekhar): Find a better way to detect when it is safe to run the
+ // distillation script. Waiting for the entire page to load is really slow.
+ if (is_main_frame) {
+ content::WebContentsObserver::Observe(NULL);
+ OnLoadURLDone();
+ }
}
+
void DistillerPageWebContents::DidFailLoad(
int64 frame_id,
const GURL& validated_url,
@@ -72,8 +78,10 @@ void DistillerPageWebContents::DidFailLoad(
int error_code,
const base::string16& error_description,
RenderViewHost* render_view_host) {
- content::WebContentsObserver::Observe(NULL);
- OnLoadURLFailed();
+ if (is_main_frame) {
+ content::WebContentsObserver::Observe(NULL);
+ OnLoadURLFailed();
+ }
}
} // namespace dom_distiller

Powered by Google App Engine
This is Rietveld 408576698