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/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 <memory> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 } | 130 } |
131 | 131 |
132 void DomDistillerViewerSource::RequestViewerHandle::DidFinishNavigation( | 132 void DomDistillerViewerSource::RequestViewerHandle::DidFinishNavigation( |
133 content::NavigationHandle* navigation_handle) { | 133 content::NavigationHandle* navigation_handle) { |
134 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) | 134 if (!navigation_handle->IsInMainFrame() || !navigation_handle->HasCommitted()) |
135 return; | 135 return; |
136 | 136 |
137 const GURL& navigation = navigation_handle->GetURL(); | 137 const GURL& navigation = navigation_handle->GetURL(); |
138 bool expected_main_view_request = | 138 bool expected_main_view_request = |
139 navigation.SchemeIs(expected_scheme_.c_str()) && | 139 navigation.SchemeIs(expected_scheme_) && |
140 expected_request_path_ == navigation.query(); | 140 expected_request_path_ == navigation.query(); |
141 if (navigation_handle->IsSameDocument() || expected_main_view_request) { | 141 if (navigation_handle->IsSameDocument() || expected_main_view_request) { |
142 // In-page navigations, as well as the main view request can be ignored. | 142 // In-page navigations, as well as the main view request can be ignored. |
143 if (expected_main_view_request) { | 143 if (expected_main_view_request) { |
144 content::RenderFrameHost* render_frame_host = | 144 content::RenderFrameHost* render_frame_host = |
145 navigation_handle->GetRenderFrameHost(); | 145 navigation_handle->GetRenderFrameHost(); |
146 CHECK_EQ(0, render_frame_host->GetEnabledBindings()); | 146 CHECK_EQ(0, render_frame_host->GetEnabledBindings()); |
147 | 147 |
148 // Add mojo service for JavaScript functionality. This is the receiving | 148 // Add mojo service for JavaScript functionality. This is the receiving |
149 // end of this particular service. | 149 // end of this particular service. |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 if (kViewerCssPath == path) { | 284 if (kViewerCssPath == path) { |
285 return "text/css"; | 285 return "text/css"; |
286 } else if (kViewerLoadingImagePath == path) { | 286 } else if (kViewerLoadingImagePath == path) { |
287 return "image/svg+xml"; | 287 return "image/svg+xml"; |
288 } | 288 } |
289 return "text/html"; | 289 return "text/html"; |
290 } | 290 } |
291 | 291 |
292 bool DomDistillerViewerSource::ShouldServiceRequest( | 292 bool DomDistillerViewerSource::ShouldServiceRequest( |
293 const net::URLRequest* request) const { | 293 const net::URLRequest* request) const { |
294 return request->url().SchemeIs(scheme_.c_str()); | 294 return request->url().SchemeIs(scheme_); |
295 } | 295 } |
296 | 296 |
297 // TODO(nyquist): Start tracking requests using this method. | 297 // TODO(nyquist): Start tracking requests using this method. |
298 void DomDistillerViewerSource::WillServiceRequest( | 298 void DomDistillerViewerSource::WillServiceRequest( |
299 const net::URLRequest* request, | 299 const net::URLRequest* request, |
300 std::string* path) const { | 300 std::string* path) const { |
301 } | 301 } |
302 | 302 |
303 std::string DomDistillerViewerSource::GetContentSecurityPolicyStyleSrc() | 303 std::string DomDistillerViewerSource::GetContentSecurityPolicyStyleSrc() |
304 const { | 304 const { |
305 return "style-src 'self' https://fonts.googleapis.com;"; | 305 return "style-src 'self' https://fonts.googleapis.com;"; |
306 } | 306 } |
307 | 307 |
308 std::string DomDistillerViewerSource::GetContentSecurityPolicyChildSrc() const { | 308 std::string DomDistillerViewerSource::GetContentSecurityPolicyChildSrc() const { |
309 return "child-src *;"; | 309 return "child-src *;"; |
310 } | 310 } |
311 | 311 |
312 } // namespace dom_distiller | 312 } // namespace dom_distiller |
OLD | NEW |