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/metrics/histogram.h" |
12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
13 #include "components/dom_distiller/core/distilled_page_prefs.h" | 14 #include "components/dom_distiller/core/distilled_page_prefs.h" |
14 #include "components/dom_distiller/core/dom_distiller_service.h" | 15 #include "components/dom_distiller/core/dom_distiller_service.h" |
15 #include "components/dom_distiller/core/proto/distilled_article.pb.h" | 16 #include "components/dom_distiller/core/proto/distilled_article.pb.h" |
16 #include "components/dom_distiller/core/proto/distilled_page.pb.h" | 17 #include "components/dom_distiller/core/proto/distilled_page.pb.h" |
17 #include "components/dom_distiller/core/task_tracker.h" | 18 #include "components/dom_distiller/core/task_tracker.h" |
18 #include "components/dom_distiller/core/url_constants.h" | 19 #include "components/dom_distiller/core/url_constants.h" |
19 #include "components/dom_distiller/core/url_utils.h" | 20 #include "components/dom_distiller/core/url_utils.h" |
20 #include "grit/components_resources.h" | 21 #include "grit/components_resources.h" |
21 #include "grit/components_strings.h" | 22 #include "grit/components_strings.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return kSerifCssClass; | 86 return kSerifCssClass; |
86 } else if (font_family == DistilledPagePrefs::MONOSPACE) { | 87 } else if (font_family == DistilledPagePrefs::MONOSPACE) { |
87 return kMonospaceCssClass; | 88 return kMonospaceCssClass; |
88 } | 89 } |
89 return kSansSerifCssClass; | 90 return kSansSerifCssClass; |
90 } | 91 } |
91 | 92 |
92 void EnsureNonEmptyTitleAndContent(std::string* title, std::string* content) { | 93 void EnsureNonEmptyTitleAndContent(std::string* title, std::string* content) { |
93 if (title->empty()) | 94 if (title->empty()) |
94 *title = l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE); | 95 *title = l10n_util::GetStringUTF8(IDS_DOM_DISTILLER_VIEWER_NO_DATA_TITLE); |
| 96 UMA_HISTOGRAM_BOOLEAN("DomDistiller.PageHasDistilledData", !content->empty()); |
95 if (content->empty()) { | 97 if (content->empty()) { |
96 *content = l10n_util::GetStringUTF8( | 98 *content = l10n_util::GetStringUTF8( |
97 IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); | 99 IDS_DOM_DISTILLER_VIEWER_NO_DATA_CONTENT); |
98 } | 100 } |
99 } | 101 } |
100 | 102 |
101 std::string ReplaceHtmlTemplateValues( | 103 std::string ReplaceHtmlTemplateValues( |
102 const std::string& title, | 104 const std::string& title, |
103 const std::string& content, | 105 const std::string& content, |
104 const std::string& loading_indicator_class, | 106 const std::string& loading_indicator_class, |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 } | 255 } |
254 | 256 |
255 const std::string GetDistilledPageFontFamilyJs( | 257 const std::string GetDistilledPageFontFamilyJs( |
256 DistilledPagePrefs::FontFamily font_family) { | 258 DistilledPagePrefs::FontFamily font_family) { |
257 return "useFontFamily('" + GetJsFontFamily(font_family) + "');"; | 259 return "useFontFamily('" + GetJsFontFamily(font_family) + "');"; |
258 } | 260 } |
259 | 261 |
260 } // namespace viewer | 262 } // namespace viewer |
261 | 263 |
262 } // namespace dom_distiller | 264 } // namespace dom_distiller |
OLD | NEW |