Chromium Code Reviews| Index: components/dom_distiller/content/dom_distiller_viewer_source.cc |
| diff --git a/components/dom_distiller/content/dom_distiller_viewer_source.cc b/components/dom_distiller/content/dom_distiller_viewer_source.cc |
| index aa12149f059f51b23b1275b67a3d3927f1d2d878..3cbcd7960b2c3f4f89cec6848e676bc00c4d8ab6 100644 |
| --- a/components/dom_distiller/content/dom_distiller_viewer_source.cc |
| +++ b/components/dom_distiller/content/dom_distiller_viewer_source.cc |
| @@ -24,14 +24,17 @@ |
| namespace { |
| +const std::string kCssPath = "readability.css"; |
|
Tom Sepez
2014/01/14 22:22:50
This creates a Non-POD static initializer. Use con
Nico
2014/01/15 05:35:26
Yup.
nyquist
2014/01/15 22:50:59
Done.
|
| + |
| std::string ReplaceHtmlTemplateValues(std::string title, std::string content) { |
| base::StringPiece html_template = |
| ResourceBundle::GetSharedInstance().GetRawDataResource( |
| IDR_DOM_DISTILLER_VIEWER_HTML); |
| std::vector<std::string> substitutions; |
| - substitutions.push_back(title); // $1 |
| - substitutions.push_back(title); // $2 |
| - substitutions.push_back(content); // $3 |
| + substitutions.push_back(title); // $1 |
| + substitutions.push_back(kCssPath); // $2 |
| + substitutions.push_back(title); // $3 |
| + substitutions.push_back(content); // $4 |
| return ReplaceStringPlaceholders(html_template, substitutions, NULL); |
| } |
| } |
| @@ -103,6 +106,14 @@ void DomDistillerViewerSource::StartDataRequest( |
| int render_process_id, |
| int render_view_id, |
| const content::URLDataSource::GotDataCallback& callback) { |
| + if (kCssPath == path) { |
| + std::string css = ResourceBundle::GetSharedInstance() |
| + .GetRawDataResource(IDR_DISTILLER_CSS) |
|
Tom Sepez
2014/01/14 22:22:50
nit: not sure if the style guide wants the "."s on
Nico
2014/01/15 05:35:26
I think this is what clang-format produces.
nyquist
2014/01/15 22:50:59
Yeah, this is pure clang-format. Keeping as is the
|
| + .as_string(); |
| + callback.Run(base::RefCountedString::TakeString(&css)); |
| + return; |
| + } |
| + |
| RequestViewerHandle* request_viewer_handle = |
| new RequestViewerHandle(callback); |
| std::string entry_id = StringToUpperASCII(path); |
| @@ -129,6 +140,8 @@ void DomDistillerViewerSource::StartDataRequest( |
| std::string DomDistillerViewerSource::GetMimeType(const std::string& path) |
| const { |
| + if (path == kCssPath) |
| + return "text/css"; |
| return "text/html"; |
| } |
| @@ -140,13 +153,15 @@ bool DomDistillerViewerSource::ShouldServiceRequest( |
| void DomDistillerViewerSource::WillServiceRequest( |
| const net::URLRequest* request, |
| std::string* path) const { |
| - // Since the full request is not available to StartDataRequest, replace the |
| - // path to contain the data needed. |
| - path->assign(request->url().host()); |
| + if (*path != kCssPath) { |
| + // Since the full request is not available to StartDataRequest, replace the |
| + // path to contain the data needed. |
| + path->assign(request->url().host()); |
| + } |
| }; |
| std::string DomDistillerViewerSource::GetContentSecurityPolicyFrameSrc() const { |
| - return "frame-src none;"; |
| + return "default-src 'none'; style-src 'self'"; |
| } |
| } // namespace dom_distiller |