Chromium Code Reviews| 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/core/viewer.h" | 5 #include "components/dom_distiller/core/viewer.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 base::StringPiece html_template = | 68 base::StringPiece html_template = |
| 69 ResourceBundle::GetSharedInstance().GetRawDataResource( | 69 ResourceBundle::GetSharedInstance().GetRawDataResource( |
| 70 IDR_DOM_DISTILLER_VIEWER_HTML); | 70 IDR_DOM_DISTILLER_VIEWER_HTML); |
| 71 std::vector<std::string> substitutions; | 71 std::vector<std::string> substitutions; |
| 72 substitutions.push_back(title); // $1 | 72 substitutions.push_back(title); // $1 |
| 73 substitutions.push_back(kViewerCssPath); // $2 | 73 substitutions.push_back(kViewerCssPath); // $2 |
| 74 substitutions.push_back(kViewerJsPath); // $3 | 74 substitutions.push_back(kViewerJsPath); // $3 |
| 75 substitutions.push_back(GetCssClass(theme)); // $4 | 75 substitutions.push_back(GetCssClass(theme)); // $4 |
| 76 substitutions.push_back(content); // $5 | 76 substitutions.push_back(content); // $5 |
| 77 substitutions.push_back(loading_indicator_class); // $6 | 77 substitutions.push_back(loading_indicator_class); // $6 |
| 78 substitutions.push_back(original_url); // $7 | |
| 78 substitutions.push_back( | 79 substitutions.push_back( |
| 79 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_LOADING_STRING)); // $7 | 80 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $8 |
| 80 substitutions.push_back(original_url); // $8 | |
| 81 substitutions.push_back( | |
| 82 l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_VIEW_ORIGINAL)); // $9 | |
| 83 return ReplaceStringPlaceholders(html_template, substitutions, NULL); | 81 return ReplaceStringPlaceholders(html_template, substitutions, NULL); |
| 84 } | 82 } |
| 85 | 83 |
| 86 } // namespace | 84 } // namespace |
| 87 | 85 |
| 88 namespace viewer { | 86 namespace viewer { |
| 89 | 87 |
| 90 const std::string GetUnsafeIncrementalDistilledPageJs( | 88 const std::string GetUnsafeIncrementalDistilledPageJs( |
| 91 const DistilledPageProto* page_proto, | 89 const DistilledPageProto* page_proto, |
| 92 const bool is_last_page) { | 90 const bool is_last_page) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 109 | 107 |
| 110 const std::string GetUnsafePartialArticleHtml( | 108 const std::string GetUnsafePartialArticleHtml( |
| 111 const DistilledPageProto* page_proto, | 109 const DistilledPageProto* page_proto, |
| 112 const DistilledPagePrefs::Theme theme) { | 110 const DistilledPagePrefs::Theme theme) { |
| 113 DCHECK(page_proto); | 111 DCHECK(page_proto); |
| 114 std::string title = net::EscapeForHTML(page_proto->title()); | 112 std::string title = net::EscapeForHTML(page_proto->title()); |
| 115 std::ostringstream unsafe_output_stream; | 113 std::ostringstream unsafe_output_stream; |
| 116 unsafe_output_stream << page_proto->html(); | 114 unsafe_output_stream << page_proto->html(); |
| 117 std::string unsafe_article_html = unsafe_output_stream.str(); | 115 std::string unsafe_article_html = unsafe_output_stream.str(); |
| 118 std::string original_url = page_proto->url(); | 116 std::string original_url = page_proto->url(); |
| 119 return ReplaceHtmlTemplateValues(title, | 117 return ReplaceHtmlTemplateValues( |
| 120 unsafe_article_html, | 118 title, unsafe_article_html, "visible", original_url, theme); |
|
robliao
2014/08/07 17:58:07
This line didn't change, so I would leave it alone
sunangel
2014/08/07 20:57:57
Done.
| |
| 121 "visible", | |
| 122 original_url, | |
| 123 theme); | |
| 124 } | 119 } |
| 125 | 120 |
| 126 const std::string GetUnsafeArticleHtml( | 121 const std::string GetUnsafeArticleHtml( |
| 127 const DistilledArticleProto* article_proto, | 122 const DistilledArticleProto* article_proto, |
| 128 const DistilledPagePrefs::Theme theme) { | 123 const DistilledPagePrefs::Theme theme) { |
| 129 DCHECK(article_proto); | 124 DCHECK(article_proto); |
| 130 std::string title; | 125 std::string title; |
| 131 std::string unsafe_article_html; | 126 std::string unsafe_article_html; |
| 132 if (article_proto->has_title() && article_proto->pages_size() > 0 && | 127 if (article_proto->has_title() && article_proto->pages_size() > 0 && |
| 133 article_proto->pages(0).has_html()) { | 128 article_proto->pages(0).has_html()) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 return scoped_ptr<ViewerHandle>(); | 206 return scoped_ptr<ViewerHandle>(); |
| 212 } | 207 } |
| 213 | 208 |
| 214 const std::string GetDistilledPageThemeJs(DistilledPagePrefs::Theme theme) { | 209 const std::string GetDistilledPageThemeJs(DistilledPagePrefs::Theme theme) { |
| 215 return "useTheme('" + GetJsTheme(theme) + "');"; | 210 return "useTheme('" + GetJsTheme(theme) + "');"; |
| 216 } | 211 } |
| 217 | 212 |
| 218 } // namespace viewer | 213 } // namespace viewer |
| 219 | 214 |
| 220 } // namespace dom_distiller | 215 } // namespace dom_distiller |
| OLD | NEW |