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

Side by Side Diff: chrome/browser/dom_distiller/tab_utils.cc

Issue 1551503002: Convert Pass()→std::move() in //chrome (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/dom_distiller/tab_utils.h" 5 #include "chrome/browser/dom_distiller/tab_utils.h"
6 6
7 #include <utility>
8
7 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
8 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" 10 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h"
9 #include "chrome/browser/ui/tab_contents/core_tab_helper.h" 11 #include "chrome/browser/ui/tab_contents/core_tab_helper.h"
10 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h" 12 #include "chrome/browser/ui/tab_contents/core_tab_helper_delegate.h"
11 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h " 13 #include "components/dom_distiller/content/browser/distiller_page_web_contents.h "
12 #include "components/dom_distiller/core/distiller_page.h" 14 #include "components/dom_distiller/core/distiller_page.h"
13 #include "components/dom_distiller/core/dom_distiller_service.h" 15 #include "components/dom_distiller/core/dom_distiller_service.h"
14 #include "components/dom_distiller/core/task_tracker.h" 16 #include "components/dom_distiller/core/task_tracker.h"
15 #include "components/dom_distiller/core/url_constants.h" 17 #include "components/dom_distiller/core/url_constants.h"
16 #include "components/dom_distiller/core/url_utils.h" 18 #include "components/dom_distiller/core/url_utils.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 void SelfDeletingRequestDelegate::OnArticleReady( 92 void SelfDeletingRequestDelegate::OnArticleReady(
91 const DistilledArticleProto* article_proto) { 93 const DistilledArticleProto* article_proto) {
92 } 94 }
93 95
94 void SelfDeletingRequestDelegate::OnArticleUpdated( 96 void SelfDeletingRequestDelegate::OnArticleUpdated(
95 ArticleDistillationUpdate article_update) { 97 ArticleDistillationUpdate article_update) {
96 } 98 }
97 99
98 void SelfDeletingRequestDelegate::TakeViewerHandle( 100 void SelfDeletingRequestDelegate::TakeViewerHandle(
99 scoped_ptr<ViewerHandle> viewer_handle) { 101 scoped_ptr<ViewerHandle> viewer_handle) {
100 viewer_handle_ = viewer_handle.Pass(); 102 viewer_handle_ = std::move(viewer_handle);
101 } 103 }
102 104
103 // Start loading the viewer URL of the current page in |web_contents|. 105 // Start loading the viewer URL of the current page in |web_contents|.
104 void StartNavigationToDistillerViewer(content::WebContents* web_contents, 106 void StartNavigationToDistillerViewer(content::WebContents* web_contents,
105 const GURL& url) { 107 const GURL& url) {
106 GURL viewer_url = dom_distiller::url_utils::GetDistillerViewUrlFromUrl( 108 GURL viewer_url = dom_distiller::url_utils::GetDistillerViewUrlFromUrl(
107 dom_distiller::kDomDistillerScheme, url); 109 dom_distiller::kDomDistillerScheme, url);
108 content::NavigationController::LoadURLParams params(viewer_url); 110 content::NavigationController::LoadURLParams params(viewer_url);
109 params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK; 111 params.transition_type = ui::PAGE_TRANSITION_AUTO_BOOKMARK;
110 web_contents->GetController().LoadURLWithParams(params); 112 web_contents->GetController().LoadURLWithParams(params);
111 } 113 }
112 114
113 void MaybeStartDistillation( 115 void MaybeStartDistillation(
114 scoped_ptr<SourcePageHandleWebContents> source_page_handle) { 116 scoped_ptr<SourcePageHandleWebContents> source_page_handle) {
115 const GURL& last_committed_url = 117 const GURL& last_committed_url =
116 source_page_handle->web_contents()->GetLastCommittedURL(); 118 source_page_handle->web_contents()->GetLastCommittedURL();
117 if (!dom_distiller::url_utils::IsUrlDistillable(last_committed_url)) 119 if (!dom_distiller::url_utils::IsUrlDistillable(last_committed_url))
118 return; 120 return;
119 121
120 // Start distillation using |source_page_handle|, and ensure ViewerHandle 122 // Start distillation using |source_page_handle|, and ensure ViewerHandle
121 // stays around until the viewer requests distillation. 123 // stays around until the viewer requests distillation.
122 SelfDeletingRequestDelegate* view_request_delegate = 124 SelfDeletingRequestDelegate* view_request_delegate =
123 new SelfDeletingRequestDelegate(source_page_handle->web_contents()); 125 new SelfDeletingRequestDelegate(source_page_handle->web_contents());
124 DomDistillerService* dom_distiller_service = 126 DomDistillerService* dom_distiller_service =
125 DomDistillerServiceFactory::GetForBrowserContext( 127 DomDistillerServiceFactory::GetForBrowserContext(
126 source_page_handle->web_contents()->GetBrowserContext()); 128 source_page_handle->web_contents()->GetBrowserContext());
127 scoped_ptr<DistillerPage> distiller_page = 129 scoped_ptr<DistillerPage> distiller_page =
128 dom_distiller_service->CreateDefaultDistillerPageWithHandle( 130 dom_distiller_service->CreateDefaultDistillerPageWithHandle(
129 source_page_handle.Pass()).Pass(); 131 std::move(source_page_handle));
130 132
131 scoped_ptr<ViewerHandle> viewer_handle = dom_distiller_service->ViewUrl( 133 scoped_ptr<ViewerHandle> viewer_handle = dom_distiller_service->ViewUrl(
132 view_request_delegate, distiller_page.Pass(), last_committed_url); 134 view_request_delegate, std::move(distiller_page), last_committed_url);
133 view_request_delegate->TakeViewerHandle(viewer_handle.Pass()); 135 view_request_delegate->TakeViewerHandle(std::move(viewer_handle));
134 } 136 }
135 137
136 } // namespace 138 } // namespace
137 139
138 void DistillCurrentPageAndView(content::WebContents* old_web_contents) { 140 void DistillCurrentPageAndView(content::WebContents* old_web_contents) {
139 DCHECK(old_web_contents); 141 DCHECK(old_web_contents);
140 // Create new WebContents. 142 // Create new WebContents.
141 content::WebContents::CreateParams create_params( 143 content::WebContents::CreateParams create_params(
142 old_web_contents->GetBrowserContext()); 144 old_web_contents->GetBrowserContext());
143 content::WebContents* new_web_contents = 145 content::WebContents* new_web_contents =
(...skipping 10 matching lines...) Expand all
154 // the back button. 156 // the back button.
155 StartNavigationToDistillerViewer(new_web_contents, 157 StartNavigationToDistillerViewer(new_web_contents,
156 old_web_contents->GetLastCommittedURL()); 158 old_web_contents->GetLastCommittedURL());
157 159
158 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents( 160 CoreTabHelper::FromWebContents(old_web_contents)->delegate()->SwapTabContents(
159 old_web_contents, new_web_contents, false, false); 161 old_web_contents, new_web_contents, false, false);
160 162
161 scoped_ptr<SourcePageHandleWebContents> source_page_handle( 163 scoped_ptr<SourcePageHandleWebContents> source_page_handle(
162 new SourcePageHandleWebContents(old_web_contents, true)); 164 new SourcePageHandleWebContents(old_web_contents, true));
163 165
164 MaybeStartDistillation(source_page_handle.Pass()); 166 MaybeStartDistillation(std::move(source_page_handle));
165 } 167 }
166 168
167 void DistillAndView(content::WebContents* source_web_contents, 169 void DistillAndView(content::WebContents* source_web_contents,
168 content::WebContents* destination_web_contents) { 170 content::WebContents* destination_web_contents) {
169 DCHECK(source_web_contents); 171 DCHECK(source_web_contents);
170 DCHECK(destination_web_contents); 172 DCHECK(destination_web_contents);
171 173
172 scoped_ptr<SourcePageHandleWebContents> source_page_handle( 174 scoped_ptr<SourcePageHandleWebContents> source_page_handle(
173 new SourcePageHandleWebContents(source_web_contents, false)); 175 new SourcePageHandleWebContents(source_web_contents, false));
174 176
175 MaybeStartDistillation(source_page_handle.Pass()); 177 MaybeStartDistillation(std::move(source_page_handle));
176 StartNavigationToDistillerViewer(destination_web_contents, 178 StartNavigationToDistillerViewer(destination_web_contents,
177 source_web_contents->GetLastCommittedURL()); 179 source_web_contents->GetLastCommittedURL());
178 } 180 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698