Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / components / dom_distiller / core / viewer.h
blobe365c52effe9155a6a30e759454759139ff99d39
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 the JavaScript to show the feedback footer for a distilled page.
28 const std::string GetShowFeedbackFormJs();
30 // Returns a full HTML page based on the given |article_proto|. This is supposed
31 // to be displayed to the end user. The returned HTML should be considered
32 // unsafe, so callers must ensure rendering it does not compromise Chrome.
33 const std::string GetUnsafeArticleHtml(
34 const DistilledArticleProto* article_proto,
35 const DistilledPagePrefs::Theme theme,
36 const DistilledPagePrefs::FontFamily font_family);
38 // Returns an HTML template page based on the given |page_proto| which provides
39 // basic information about the page (i.e. title, text direction, etc.). This is
40 // supposed to be displayed to the end user. The returned HTML should be
41 // considered unsafe, so callers must ensure rendering it does not compromise
42 // Chrome.
43 const std::string GetUnsafeArticleTemplateHtml(
44 const DistilledPageProto* page_proto,
45 const DistilledPagePrefs::Theme theme,
46 const DistilledPagePrefs::FontFamily font_family);
48 // Returns the JavaScript to place a full article's HTML on the page. The
49 // returned HTML should be considered unsafe, so callers must ensure
50 // rendering it does not compromise Chrome.
51 const std::string GetUnsafeArticleContentJs(
52 const DistilledArticleProto* article_proto);
54 // Returns a JavaScript blob for updating a partial view request with additional
55 // distilled content. Meant for use when viewing a slow or long multi-page
56 // article. |is_last_page| indicates whether this is the last page of the
57 // article.
58 const std::string GetUnsafeIncrementalDistilledPageJs(
59 const DistilledPageProto* page_proto,
60 const bool is_last_page);
62 // Returns a JavaScript blob for updating a view request with error page
63 // contents.
64 const std::string GetErrorPageJs();
66 // Returns a JavaScript blob for controlling the "in-progress" indicator when
67 // viewing a partially-distilled page. |is_last_page| indicates whether this is
68 // the last page of the article (i.e. loading indicator should be removed).
69 const std::string GetToggleLoadingIndicatorJs(const bool is_last_page);
71 // Returns a full HTML page which displays a generic error.
72 const std::string GetErrorPageHtml(
73 const DistilledPagePrefs::Theme theme,
74 const DistilledPagePrefs::FontFamily font_family);
76 // Returns the default CSS to be used for a viewer.
77 const std::string GetCss();
79 // Returns the default JS to be used for a viewer.
80 const std::string GetJavaScript();
82 // Based on the given path, calls into the DomDistillerServiceInterface for
83 // viewing distilled content based on the |path|.
84 scoped_ptr<ViewerHandle> CreateViewRequest(
85 DomDistillerServiceInterface* dom_distiller_service,
86 const std::string& path,
87 ViewRequestDelegate* view_request_delegate,
88 const gfx::Size& render_view_size);
90 // Returns JavaScript coresponding to setting the font family.
91 const std::string GetDistilledPageFontFamilyJs(
92 DistilledPagePrefs::FontFamily font);
94 // Returns JavaScript corresponding to setting a specific theme.
95 const std::string GetDistilledPageThemeJs(DistilledPagePrefs::Theme theme);
97 } // namespace viewer
99 } // namespace dom_distiller
101 #endif // COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_