#include "components/dom_distiller/core/viewer.h"
#include <memory>
#include <string>
#include <vector>
#include "base/json/json_writer.h"
#include "base/metrics/histogram_macros.h"
#include "base/strings/escape.h"
#include "base/strings/strcat.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "build/blink_buildflags.h"
#include "build/build_config.h"
#include "components/dom_distiller/core/distilled_page_prefs.h"
#include "components/dom_distiller/core/dom_distiller_service.h"
#include "components/dom_distiller/core/experiments.h"
#include "components/dom_distiller/core/proto/distilled_article.pb.h"
#include "components/dom_distiller/core/proto/distilled_page.pb.h"
#include "components/dom_distiller/core/task_tracker.h"
#include "components/dom_distiller/core/url_constants.h"
#include "components/dom_distiller/core/url_utils.h"
#include "components/grit/components_resources.h"
#include "components/strings/grit/components_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/template_expressions.h"
#include "url/gurl.h"
namespace dom_distiller {
namespace viewer {
namespace {
const char kDarkJsTheme[] = …;
const char kLightJsTheme[] = …;
const char kSepiaJsTheme[] = …;
const char kDarkCssClass[] = …;
const char kLightCssClass[] = …;
const char kSepiaCssClass[] = …;
const char kSerifJsFontFamily[] = …;
const char kSansSerifJsFontFamily[] = …;
const char kMonospaceJsFontFamily[] = …;
const char kSerifCssClass[] = …;
const char kSansSerifCssClass[] = …;
const char kMonospaceCssClass[] = …;
std::string GetPlatformSpecificCss() { … }
const std::string GetJsTheme(mojom::Theme theme) { … }
const std::string GetThemeCssClass(mojom::Theme theme) { … }
const std::string GetJsFontFamily(mojom::FontFamily font_family) { … }
const std::string GetFontCssClass(mojom::FontFamily font_family) { … }
void EnsureNonEmptyContent(std::string* content) { … }
std::string ReplaceHtmlTemplateValues(const mojom::Theme theme,
const mojom::FontFamily font_family,
const std::string& csp_nonce) { … }
}
const std::string GetUnsafeIncrementalDistilledPageJs(
const DistilledPageProto* page_proto,
bool is_last_page) { … }
const std::string GetErrorPageJs() { … }
const std::string GetSetTitleJs(std::string title) { … }
const std::string GetSetTextDirectionJs(const std::string& direction) { … }
const std::string GetToggleLoadingIndicatorJs(bool is_last_page) { … }
const std::string GetArticleTemplateHtml(mojom::Theme theme,
mojom::FontFamily font_family,
const std::string& csp_nonce) { … }
const std::string GetUnsafeArticleContentJs(
const DistilledArticleProto* article_proto) { … }
const std::string GetCss() { … }
const std::string GetLoadingImage() { … }
const std::string GetJavaScript() { … }
std::unique_ptr<ViewerHandle> CreateViewRequest(
DomDistillerServiceInterface* dom_distiller_service,
const GURL& url,
ViewRequestDelegate* view_request_delegate,
const gfx::Size& render_view_size) { … }
const std::string GetDistilledPageThemeJs(mojom::Theme theme) { … }
const std::string GetDistilledPageFontFamilyJs(mojom::FontFamily font_family) { … }
const std::string GetDistilledPageFontScalingJs(float scaling) { … }
}
}