Roll src/third_party/skia de7665a:76033be
[chromium-blink-merge.git] / components / dom_distiller / core / viewer.h
blob9e1ded3b26e983f9c6783c0b5be2121a5760e366
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_
6 #define COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/strings/string16.h"
14 #include "components/dom_distiller/core/distilled_page_prefs.h"
15 #include "ui/gfx/geometry/size.h"
17 namespace dom_distiller {
19 class DistilledArticleProto;
20 class DistilledPageProto;
21 class DomDistillerServiceInterface;
22 class ViewerHandle;
23 class ViewRequestDelegate;
25 namespace viewer {
27 // Returns a full HTML page based on the given |article_proto|. This is supposed
28 // to be displayed to the end user. The returned HTML should be considered
29 // unsafe, so callers must ensure rendering it does not compromise Chrome.
30 const std::string GetUnsafeArticleHtml(
31 const DistilledArticleProto* article_proto,
32 const DistilledPagePrefs::Theme theme,
33 const DistilledPagePrefs::FontFamily font_family);
35 // Returns the base Viewer HTML page based on the given |page_proto|. This is
36 // supposed to be displayed to the end user. The returned HTML should be
37 // considered unsafe, so callers must ensure rendering it does not compromise
38 // Chrome. The difference from |GetUnsafeArticleHtml| is that this can be used
39 // for displaying an in-flight distillation instead of waiting for the full
40 // article.
41 const std::string GetUnsafePartialArticleHtml(
42 const DistilledPageProto* page_proto,
43 const DistilledPagePrefs::Theme theme,
44 const DistilledPagePrefs::FontFamily font_family);
46 // Returns a JavaScript blob for updating a partial view request with additional
47 // distilled content. Meant for use when viewing a slow or long multi-page
48 // article. |is_last_page| indicates whether this is the last page of the
49 // article.
50 const std::string GetUnsafeIncrementalDistilledPageJs(
51 const DistilledPageProto* page_proto,
52 const bool is_last_page);
54 // Returns a JavaScript blob for controlling the "in-progress" indicator when
55 // viewing a partially-distilled page. |is_last_page| indicates whether this is
56 // the last page of the article (i.e. loading indicator should be removed).
57 const std::string GetToggleLoadingIndicatorJs(const bool is_last_page);
59 // Returns a full HTML page which displays a generic error.
60 const std::string GetErrorPageHtml(
61 const DistilledPagePrefs::Theme theme,
62 const DistilledPagePrefs::FontFamily font_family);
64 // Returns the default CSS to be used for a viewer.
65 const std::string GetCss();
67 // Returns the default JS to be used for a viewer.
68 const std::string GetJavaScript();
70 // Based on the given path, calls into the DomDistillerServiceInterface for
71 // viewing distilled content based on the |path|.
72 scoped_ptr<ViewerHandle> CreateViewRequest(
73 DomDistillerServiceInterface* dom_distiller_service,
74 const std::string& path,
75 ViewRequestDelegate* view_request_delegate,
76 const gfx::Size& render_view_size);
78 // Returns JavaScript coresponding to setting the font family.
79 const std::string GetDistilledPageFontFamilyJs(
80 DistilledPagePrefs::FontFamily font);
82 // Returns JavaScript corresponding to setting a specific theme.
83 const std::string GetDistilledPageThemeJs(DistilledPagePrefs::Theme theme);
85 } // namespace viewer
87 } // namespace dom_distiller
89 #endif // COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_