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

Side by Side Diff: components/dom_distiller/content/browser/dom_distiller_viewer_source.cc

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 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 "components/dom_distiller/content/browser/dom_distiller_viewer_source.h " 5 #include "components/dom_distiller/content/browser/dom_distiller_viewer_source.h "
6 6
7 #include <memory>
7 #include <string> 8 #include <string>
8 #include <utility> 9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/memory/ref_counted_memory.h" 12 #include "base/memory/ref_counted_memory.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/message_loop/message_loop.h" 13 #include "base/message_loop/message_loop.h"
14 #include "base/metrics/user_metrics.h" 14 #include "base/metrics/user_metrics.h"
15 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
16 #include "base/strings/string_util.h" 16 #include "base/strings/string_util.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "components/dom_distiller/content/browser/distiller_javascript_service_ impl.h" 18 #include "components/dom_distiller/content/browser/distiller_javascript_service_ impl.h"
19 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h" 19 #include "components/dom_distiller/content/browser/distiller_javascript_utils.h"
20 #include "components/dom_distiller/content/browser/distiller_ui_handle.h" 20 #include "components/dom_distiller/content/browser/distiller_ui_handle.h"
21 #include "components/dom_distiller/content/common/distiller_page_notifier_servic e.mojom.h" 21 #include "components/dom_distiller/content/common/distiller_page_notifier_servic e.mojom.h"
22 #include "components/dom_distiller/core/distilled_page_prefs.h" 22 #include "components/dom_distiller/core/distilled_page_prefs.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 if (!buffer_.empty()) { 162 if (!buffer_.empty()) {
163 RunIsolatedJavaScript(web_contents()->GetMainFrame(), buffer_); 163 RunIsolatedJavaScript(web_contents()->GetMainFrame(), buffer_);
164 buffer_.clear(); 164 buffer_.clear();
165 } 165 }
166 // No need to Cancel() here. 166 // No need to Cancel() here.
167 } 167 }
168 168
169 DomDistillerViewerSource::DomDistillerViewerSource( 169 DomDistillerViewerSource::DomDistillerViewerSource(
170 DomDistillerServiceInterface* dom_distiller_service, 170 DomDistillerServiceInterface* dom_distiller_service,
171 const std::string& scheme, 171 const std::string& scheme,
172 scoped_ptr<DistillerUIHandle> ui_handle) 172 std::unique_ptr<DistillerUIHandle> ui_handle)
173 : scheme_(scheme), 173 : scheme_(scheme),
174 dom_distiller_service_(dom_distiller_service), 174 dom_distiller_service_(dom_distiller_service),
175 distiller_ui_handle_(std::move(ui_handle)) {} 175 distiller_ui_handle_(std::move(ui_handle)) {}
176 176
177 DomDistillerViewerSource::~DomDistillerViewerSource() { 177 DomDistillerViewerSource::~DomDistillerViewerSource() {
178 } 178 }
179 179
180 std::string DomDistillerViewerSource::GetSource() const { 180 std::string DomDistillerViewerSource::GetSource() const {
181 return scheme_ + "://"; 181 return scheme_ + "://";
182 } 182 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 content::WebContents* web_contents = 214 content::WebContents* web_contents =
215 content::WebContents::FromRenderFrameHost(render_frame_host); 215 content::WebContents::FromRenderFrameHost(render_frame_host);
216 DCHECK(web_contents); 216 DCHECK(web_contents);
217 // An empty |path| is invalid, but guard against it. If not empty, assume 217 // An empty |path| is invalid, but guard against it. If not empty, assume
218 // |path| starts with '?', which is stripped away. 218 // |path| starts with '?', which is stripped away.
219 const std::string path_after_query_separator = 219 const std::string path_after_query_separator =
220 path.size() > 0 ? path.substr(1) : ""; 220 path.size() > 0 ? path.substr(1) : "";
221 RequestViewerHandle* request_viewer_handle = 221 RequestViewerHandle* request_viewer_handle =
222 new RequestViewerHandle(web_contents, scheme_, path_after_query_separator, 222 new RequestViewerHandle(web_contents, scheme_, path_after_query_separator,
223 dom_distiller_service_->GetDistilledPagePrefs()); 223 dom_distiller_service_->GetDistilledPagePrefs());
224 scoped_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest( 224 std::unique_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest(
225 dom_distiller_service_, path, request_viewer_handle, 225 dom_distiller_service_, path, request_viewer_handle,
226 web_contents->GetContainerBounds().size()); 226 web_contents->GetContainerBounds().size());
227 227
228 GURL current_url(url_utils::GetValueForKeyInUrlPathQuery(path, kUrlKey)); 228 GURL current_url(url_utils::GetValueForKeyInUrlPathQuery(path, kUrlKey));
229 std::string unsafe_page_html = viewer::GetUnsafeArticleTemplateHtml( 229 std::string unsafe_page_html = viewer::GetUnsafeArticleTemplateHtml(
230 url_utils::GetOriginalUrlFromDistillerUrl(current_url).spec(), 230 url_utils::GetOriginalUrlFromDistillerUrl(current_url).spec(),
231 dom_distiller_service_->GetDistilledPagePrefs()->GetTheme(), 231 dom_distiller_service_->GetDistilledPagePrefs()->GetTheme(),
232 dom_distiller_service_->GetDistilledPagePrefs()->GetFontFamily()); 232 dom_distiller_service_->GetDistilledPagePrefs()->GetFontFamily());
233 233
234 // Add mojo service for JavaScript functionality. This is the receiving end 234 // Add mojo service for JavaScript functionality. This is the receiving end
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() 283 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc()
284 const { 284 const {
285 return "object-src 'none'; style-src 'self' https://fonts.googleapis.com;"; 285 return "object-src 'none'; style-src 'self' https://fonts.googleapis.com;";
286 } 286 }
287 287
288 std::string DomDistillerViewerSource::GetContentSecurityPolicyFrameSrc() const { 288 std::string DomDistillerViewerSource::GetContentSecurityPolicyFrameSrc() const {
289 return "frame-src *;"; 289 return "frame-src *;";
290 } 290 }
291 291
292 } // namespace dom_distiller 292 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698