| 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 d83252b5433babb0b0d03d7dc377bb78dfc4a863..aa150d7604da61996bc2bf09b570f19ed27dc63a 100644
|
| --- a/components/dom_distiller/content/dom_distiller_viewer_source.cc
|
| +++ b/components/dom_distiller/content/dom_distiller_viewer_source.cc
|
| @@ -26,14 +26,17 @@
|
|
|
| namespace {
|
|
|
| +const char kCssPath[] = "readability.css";
|
| +
|
| 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);
|
| }
|
|
|
| @@ -114,8 +117,17 @@ void DomDistillerViewerSource::StartDataRequest(
|
| DCHECK(render_view_host);
|
| CHECK_EQ(0, render_view_host->GetEnabledBindings());
|
|
|
| + if (kCssPath == path) {
|
| + std::string css = ResourceBundle::GetSharedInstance()
|
| + .GetRawDataResource(IDR_DISTILLER_CSS)
|
| + .as_string();
|
| + callback.Run(base::RefCountedString::TakeString(&css));
|
| + return;
|
| + }
|
| +
|
| scoped_ptr<RequestViewerHandle> request_viewer_handle(
|
| new RequestViewerHandle(callback));
|
| +
|
| std::string entry_id = StringToUpperASCII(path);
|
| scoped_ptr<ViewerHandle> viewer_handle =
|
| dom_distiller_service_->ViewEntry(request_viewer_handle.get(), entry_id);
|
| @@ -125,7 +137,7 @@ void DomDistillerViewerSource::StartDataRequest(
|
| // request is not cancelled. The |RequestViewerHandle| will delete itself
|
| // after receiving the callback.
|
| request_viewer_handle.get()->TakeViewerHandle(viewer_handle.Pass());
|
| - (void) request_viewer_handle.release();
|
| + (void)request_viewer_handle.release();
|
| } else {
|
| std::string title = l10n_util::GetStringUTF8(
|
| IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_TITLE);
|
| @@ -138,6 +150,8 @@ void DomDistillerViewerSource::StartDataRequest(
|
|
|
| std::string DomDistillerViewerSource::GetMimeType(const std::string& path)
|
| const {
|
| + if (path == kCssPath)
|
| + return "text/css";
|
| return "text/html";
|
| }
|
|
|
| @@ -149,9 +163,16 @@ 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 = request->url().host();
|
| + if (*path != kCssPath) {
|
| + // Since the full request is not available to StartDataRequest, replace the
|
| + // path to contain the data needed.
|
| + *path = request->url().host();
|
| + }
|
| };
|
|
|
| +std::string DomDistillerViewerSource::GetContentSecurityPolicyObjectSrc()
|
| + const {
|
| + return "object-src 'none'; style-src 'self'";
|
| +}
|
| +
|
| } // namespace dom_distiller
|
|
|