| OLD | NEW |
| 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/dom_distiller_viewer_source.h" | 5 #include "components/dom_distiller/content/dom_distiller_viewer_source.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 if (kViewerJsPath == path) { | 266 if (kViewerJsPath == path) { |
| 267 std::string js = viewer::GetJavaScript(); | 267 std::string js = viewer::GetJavaScript(); |
| 268 callback.Run(base::RefCountedString::TakeString(&js)); | 268 callback.Run(base::RefCountedString::TakeString(&js)); |
| 269 return; | 269 return; |
| 270 } | 270 } |
| 271 content::WebContents* web_contents = | 271 content::WebContents* web_contents = |
| 272 content::WebContents::FromRenderFrameHost( | 272 content::WebContents::FromRenderFrameHost( |
| 273 content::RenderFrameHost::FromID(render_process_id, | 273 content::RenderFrameHost::FromID(render_process_id, |
| 274 render_frame_id)); | 274 render_frame_id)); |
| 275 DCHECK(web_contents); | 275 DCHECK(web_contents); |
| 276 RequestViewerHandle* request_viewer_handle = | 276 // An empty |path| is invalid, but guard against it. If not empty, assume |
| 277 new RequestViewerHandle(web_contents, scheme_, path.substr(1), callback); | 277 // |path| starts with '?', which is stripped away. |
| 278 const std::string path_after_query_separator = |
| 279 path.size() > 0 ? path.substr(1) : ""; |
| 280 RequestViewerHandle* request_viewer_handle = new RequestViewerHandle( |
| 281 web_contents, scheme_, path_after_query_separator, callback); |
| 278 scoped_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest( | 282 scoped_ptr<ViewerHandle> viewer_handle = viewer::CreateViewRequest( |
| 279 dom_distiller_service_, path, request_viewer_handle); | 283 dom_distiller_service_, path, request_viewer_handle); |
| 280 | 284 |
| 281 if (viewer_handle) { | 285 if (viewer_handle) { |
| 282 // The service returned a |ViewerHandle| and guarantees it will call | 286 // The service returned a |ViewerHandle| and guarantees it will call |
| 283 // the |RequestViewerHandle|, so passing ownership to it, to ensure the | 287 // the |RequestViewerHandle|, so passing ownership to it, to ensure the |
| 284 // request is not cancelled. The |RequestViewerHandle| will delete itself | 288 // request is not cancelled. The |RequestViewerHandle| will delete itself |
| 285 // after receiving the callback. | 289 // after receiving the callback. |
| 286 request_viewer_handle->TakeViewerHandle(viewer_handle.Pass()); | 290 request_viewer_handle->TakeViewerHandle(viewer_handle.Pass()); |
| 287 } else { | 291 } else { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 315 const net::URLRequest* request, | 319 const net::URLRequest* request, |
| 316 std::string* path) const { | 320 std::string* path) const { |
| 317 } | 321 } |
| 318 | 322 |
| 319 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() | 323 std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc() |
| 320 const { | 324 const { |
| 321 return "object-src 'none'; style-src 'self';"; | 325 return "object-src 'none'; style-src 'self';"; |
| 322 } | 326 } |
| 323 | 327 |
| 324 } // namespace dom_distiller | 328 } // namespace dom_distiller |
| OLD | NEW |