Don't preload rarely seen large images
[chromium-blink-merge.git] / components / dom_distiller / core / viewer.h
blob9b05daad5a610978f16a24be5bf214932b94f939
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 an HTML template page based on the given |page_proto| which provides
31 // basic information about the page (i.e. title, text direction, etc.). This is
32 // supposed to be displayed to the end user. The returned HTML should be
33 // considered unsafe, so callers must ensure rendering it does not compromise
34 // Chrome.
35 const std::string GetUnsafeArticleTemplateHtml(
36 const std::string original_url,
37 const DistilledPagePrefs::Theme theme,
38 const DistilledPagePrefs::FontFamily font_family);
40 // Returns the JavaScript to place a full article's HTML on the page. The
41 // returned HTML should be considered unsafe, so callers must ensure
42 // rendering it does not compromise Chrome.
43 const std::string GetUnsafeArticleContentJs(
44 const DistilledArticleProto* article_proto);
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 the JavaScript to set the title of the distilled article page.
55 const std::string GetSetTitleJs(std::string title);
57 // Return the JavaScript to set the text direction of the distiller page.
58 const std::string GetSetTextDirectionJs(const std::string& direction);
60 // Returns a JavaScript blob for updating a view request with error page
61 // contents.
62 const std::string GetErrorPageJs();
64 // Returns a JavaScript blob for controlling the "in-progress" indicator when
65 // viewing a partially-distilled page. |is_last_page| indicates whether this is
66 // the last page of the article (i.e. loading indicator should be removed).
67 const std::string GetToggleLoadingIndicatorJs(const bool is_last_page);
69 // Returns the default CSS to be used for a viewer.
70 const std::string GetCss();
72 // Returns the iOS specific CSS to be used for the distiller viewer.
73 const std::string GetIOSCss();
75 // Returns the default JS to be used for a viewer.
76 const std::string GetJavaScript();
78 // Based on the given path, calls into the DomDistillerServiceInterface for
79 // viewing distilled content based on the |path|.
80 scoped_ptr<ViewerHandle> CreateViewRequest(
81 DomDistillerServiceInterface* dom_distiller_service,
82 const std::string& path,
83 ViewRequestDelegate* view_request_delegate,
84 const gfx::Size& render_view_size);
86 // Returns JavaScript coresponding to setting the font family.
87 const std::string GetDistilledPageFontFamilyJs(
88 DistilledPagePrefs::FontFamily font);
90 // Returns JavaScript corresponding to setting a specific theme.
91 const std::string GetDistilledPageThemeJs(DistilledPagePrefs::Theme theme);
93 } // namespace viewer
95 } // namespace dom_distiller
97 #endif // COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_