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" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "components/dom_distiller/core/dom_distiller_service.h" | 13 #include "components/dom_distiller/core/dom_distiller_service.h" |
14 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 14 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
15 #include "components/dom_distiller/core/proto/distilled_page.pb.h" | 15 #include "components/dom_distiller/core/proto/distilled_page.pb.h" |
| 16 #include "components/dom_distiller/core/reader_mode_preferences.h" |
16 #include "components/dom_distiller/core/task_tracker.h" | 17 #include "components/dom_distiller/core/task_tracker.h" |
17 #include "components/dom_distiller/core/url_constants.h" | 18 #include "components/dom_distiller/core/url_constants.h" |
18 #include "components/dom_distiller/core/url_utils.h" | 19 #include "components/dom_distiller/core/url_utils.h" |
19 #include "grit/component_resources.h" | 20 #include "grit/component_resources.h" |
20 #include "grit/components_strings.h" | 21 #include "grit/components_strings.h" |
21 #include "net/base/escape.h" | 22 #include "net/base/escape.h" |
22 #include "net/url_request/url_request.h" | 23 #include "net/url_request/url_request.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
25 #include "url/gurl.h" | 26 #include "url/gurl.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 } | 121 } |
121 | 122 |
122 const std::string GetErrorPageHtml() { | 123 const std::string GetErrorPageHtml() { |
123 std::string title = l10n_util::GetStringUTF8( | 124 std::string title = l10n_util::GetStringUTF8( |
124 IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_TITLE); | 125 IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_TITLE); |
125 std::string content = l10n_util::GetStringUTF8( | 126 std::string content = l10n_util::GetStringUTF8( |
126 IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_CONTENT); | 127 IDS_DOM_DISTILLER_VIEWER_FAILED_TO_FIND_ARTICLE_CONTENT); |
127 return ReplaceHtmlTemplateValues(title, content, "hidden", ""); | 128 return ReplaceHtmlTemplateValues(title, content, "hidden", ""); |
128 } | 129 } |
129 | 130 |
130 const std::string GetCss() { | 131 const std::string GetCss(ReaderModePrefs* reader_mode_prefs) { |
131 return ResourceBundle::GetSharedInstance() | 132 return reader_mode_prefs->ReplaceCSSTemplateValues(); |
132 .GetRawDataResource(IDR_DISTILLER_CSS) | |
133 .as_string(); | |
134 } | 133 } |
135 | 134 |
136 const std::string GetJavaScript() { | 135 const std::string GetJavaScript() { |
137 return ResourceBundle::GetSharedInstance() | 136 return ResourceBundle::GetSharedInstance() |
138 .GetRawDataResource(IDR_DOM_DISTILLER_VIEWER_JS) | 137 .GetRawDataResource(IDR_DOM_DISTILLER_VIEWER_JS) |
139 .as_string(); | 138 .as_string(); |
140 } | 139 } |
141 | 140 |
142 scoped_ptr<ViewerHandle> CreateViewRequest( | 141 scoped_ptr<ViewerHandle> CreateViewRequest( |
143 DomDistillerServiceInterface* dom_distiller_service, | 142 DomDistillerServiceInterface* dom_distiller_service, |
(...skipping 27 matching lines...) Expand all Loading... |
171 requested_url).Pass(); | 170 requested_url).Pass(); |
172 } | 171 } |
173 | 172 |
174 // It is invalid to not specify a query param for |kEntryIdKey| or |kUrlKey|. | 173 // It is invalid to not specify a query param for |kEntryIdKey| or |kUrlKey|. |
175 return scoped_ptr<ViewerHandle>(); | 174 return scoped_ptr<ViewerHandle>(); |
176 } | 175 } |
177 | 176 |
178 } // namespace viewer | 177 } // namespace viewer |
179 | 178 |
180 } // namespace dom_distiller | 179 } // namespace dom_distiller |
OLD | NEW |