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

Unified Diff: chrome/browser/dom_distiller/tab_utils.cc

Issue 1003153003: Avoid starting a distillation process if the URL is not distillable. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix issues pointed out, release web_contents properly when not used. Created 5 years, 9 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/dom_distiller/tab_utils.cc
diff --git a/chrome/browser/dom_distiller/tab_utils.cc b/chrome/browser/dom_distiller/tab_utils.cc
index c288d909129f8ea72516bf60ad52064a7553f49c..94fb24e04b7f223fceb42651c0bca22b267603eb 100644
--- a/chrome/browser/dom_distiller/tab_utils.cc
+++ b/chrome/browser/dom_distiller/tab_utils.cc
@@ -110,7 +110,13 @@ void StartNavigationToDistillerViewer(content::WebContents* web_contents,
web_contents->GetController().LoadURLWithParams(params);
}
-void StartDistillation(content::WebContents* web_contents) {
+void MaybeStartDistillation(content::WebContents* web_contents) {
+ const GURL& last_committed_url = web_contents->GetLastCommittedURL();
+ if (!dom_distiller::url_utils::IsUrlDistillable(last_committed_url)) {
+ delete web_contents;
+ return;
+ }
+
// Start distillation using |web_contents|, and ensure ViewerHandle stays
// around until the viewer requests distillation.
SelfDeletingRequestDelegate* view_request_delegate =
@@ -125,7 +131,6 @@ void StartDistillation(content::WebContents* web_contents) {
dom_distiller_service->CreateDefaultDistillerPageWithHandle(
source_page_handle.Pass()).Pass();
- const GURL& last_committed_url = web_contents->GetLastCommittedURL();
scoped_ptr<ViewerHandle> viewer_handle = dom_distiller_service->ViewUrl(
view_request_delegate, distiller_page.Pass(), last_committed_url);
view_request_delegate->TakeViewerHandle(viewer_handle.Pass());
@@ -156,5 +161,5 @@ void DistillCurrentPageAndView(content::WebContents* old_web_contents) {
CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents(
old_web_contents, new_web_contents, false, false);
- StartDistillation(old_web_contents);
+ MaybeStartDistillation(old_web_contents);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698