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 94fb24e04b7f223fceb42651c0bca22b267603eb..371b3b04df79b6760a67a120f647c978d89813f6 100644 |
--- a/chrome/browser/dom_distiller/tab_utils.cc |
+++ b/chrome/browser/dom_distiller/tab_utils.cc |
@@ -110,10 +110,11 @@ void StartNavigationToDistillerViewer(content::WebContents* web_contents, |
web_contents->GetController().LoadURLWithParams(params); |
} |
-void MaybeStartDistillation(content::WebContents* web_contents) { |
+void MaybeStartDistillation(content::WebContents* web_contents, bool owned) { |
const GURL& last_committed_url = web_contents->GetLastCommittedURL(); |
if (!dom_distiller::url_utils::IsUrlDistillable(last_committed_url)) { |
- delete web_contents; |
+ if (owned) |
+ delete web_contents; |
return; |
} |
@@ -121,9 +122,8 @@ void MaybeStartDistillation(content::WebContents* web_contents) { |
// around until the viewer requests distillation. |
SelfDeletingRequestDelegate* view_request_delegate = |
new SelfDeletingRequestDelegate(web_contents); |
- scoped_ptr<content::WebContents> old_web_contents_sptr(web_contents); |
scoped_ptr<SourcePageHandleWebContents> source_page_handle( |
- new SourcePageHandleWebContents(old_web_contents_sptr.Pass())); |
+ new SourcePageHandleWebContents(web_contents, owned)); |
cjhopman
2015/05/12 21:18:42
If you wrap this in the sourcepagehandle at the be
nyquist
2015/05/13 00:06:52
Done.
|
DomDistillerService* dom_distiller_service = |
DomDistillerServiceFactory::GetForBrowserContext( |
web_contents->GetBrowserContext()); |
@@ -161,5 +161,15 @@ void DistillCurrentPageAndView(content::WebContents* old_web_contents) { |
CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents( |
old_web_contents, new_web_contents, false, false); |
- MaybeStartDistillation(old_web_contents); |
+ MaybeStartDistillation(old_web_contents, true); |
+} |
+ |
+void DistillAndView(content::WebContents* source_web_contents, |
+ content::WebContents* destination_web_contents) { |
+ DCHECK(source_web_contents); |
+ DCHECK(destination_web_contents); |
+ |
+ MaybeStartDistillation(source_web_contents, false); |
+ StartNavigationToDistillerViewer(destination_web_contents, |
+ source_web_contents->GetLastCommittedURL()); |
} |