Chromium Code Reviews| 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 #ifndef COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "components/dom_distiller/core/reader_mode_preferences.h" | |
|
nyquist
2014/06/27 20:48:27
Can you instead forward declare this in the header
smaslo
2014/06/30 17:57:15
The compiler doesn't allow forward declarations of
| |
| 14 | 15 |
| 15 namespace dom_distiller { | 16 namespace dom_distiller { |
| 16 | 17 |
| 17 class DistilledArticleProto; | 18 class DistilledArticleProto; |
| 18 class DistilledPageProto; | 19 class DistilledPageProto; |
| 19 class DomDistillerServiceInterface; | 20 class DomDistillerServiceInterface; |
| 20 class ViewerHandle; | 21 class ViewerHandle; |
| 21 class ViewRequestDelegate; | 22 class ViewRequestDelegate; |
| 22 | 23 |
| 23 namespace viewer { | 24 namespace viewer { |
| 24 | 25 |
| 25 // Returns a full HTML page based on the given |article_proto|. This is supposed | 26 // Returns a full HTML page based on the given |article_proto|. This is supposed |
| 26 // to be displayed to the end user. The returned HTML should be considered | 27 // to be displayed to the end user. The returned HTML should be considered |
| 27 // unsafe, so callers must ensure rendering it does not compromise Chrome. | 28 // unsafe, so callers must ensure rendering it does not compromise Chrome. |
| 28 const std::string GetUnsafeArticleHtml( | 29 const std::string GetUnsafeArticleHtml( |
| 29 const DistilledArticleProto* article_proto); | 30 const DistilledArticleProto* article_proto, |
| 31 const ReaderModePrefs::Theme theme); | |
| 30 | 32 |
| 31 // Returns the base Viewer HTML page based on the given |page_proto|. This is | 33 // Returns the base Viewer HTML page based on the given |page_proto|. This is |
| 32 // supposed to be displayed to the end user. The returned HTML should be | 34 // 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 | 35 // considered unsafe, so callers must ensure rendering it does not compromise |
| 34 // Chrome. The difference from |GetUnsafeArticleHtml| is that this can be used | 36 // Chrome. The difference from |GetUnsafeArticleHtml| is that this can be used |
| 35 // for displaying an in-flight distillation instead of waiting for the full | 37 // for displaying an in-flight distillation instead of waiting for the full |
| 36 // article. | 38 // article. |
| 37 const std::string GetUnsafePartialArticleHtml( | 39 const std::string GetUnsafePartialArticleHtml( |
| 38 const DistilledPageProto* page_proto); | 40 const DistilledPageProto* page_proto, const ReaderModePrefs::Theme theme); |
| 39 | 41 |
| 40 // Returns a JavaScript blob for updating a partial view request with additional | 42 // Returns a JavaScript blob for updating a partial view request with additional |
| 41 // distilled content. Meant for use when viewing a slow or long multi-page | 43 // distilled content. Meant for use when viewing a slow or long multi-page |
| 42 // article. |is_last_page| indicates whether this is the last page of the | 44 // article. |is_last_page| indicates whether this is the last page of the |
| 43 // article. | 45 // article. |
| 44 const std::string GetUnsafeIncrementalDistilledPageJs( | 46 const std::string GetUnsafeIncrementalDistilledPageJs( |
| 45 const DistilledPageProto* page_proto, | 47 const DistilledPageProto* page_proto, |
| 46 const bool is_last_page); | 48 const bool is_last_page); |
| 47 | 49 |
| 48 // Returns a JavaScript blob for controlling the "in-progress" indicator when | 50 // Returns a JavaScript blob for controlling the "in-progress" indicator when |
| 49 // viewing a partially-distilled page. |is_last_page| indicates whether this is | 51 // viewing a partially-distilled page. |is_last_page| indicates whether this is |
| 50 // the last page of the article (i.e. loading indicator should be removed). | 52 // the last page of the article (i.e. loading indicator should be removed). |
| 51 const std::string GetToggleLoadingIndicatorJs(const bool is_last_page); | 53 const std::string GetToggleLoadingIndicatorJs(const bool is_last_page); |
| 52 | 54 |
| 53 // Returns a full HTML page which displays a generic error. | 55 // Returns a full HTML page which displays a generic error. |
| 54 const std::string GetErrorPageHtml(); | 56 const std::string GetErrorPageHtml(const ReaderModePrefs::Theme theme); |
| 55 | 57 |
| 56 // Returns the default CSS to be used for a viewer. | 58 // Returns the default CSS to be used for a viewer. |
| 57 const std::string GetCss(); | 59 const std::string GetCss(); |
| 58 | 60 |
| 59 // Returns the default JS to be used for a viewer. | 61 // Returns the default JS to be used for a viewer. |
| 60 const std::string GetJavaScript(); | 62 const std::string GetJavaScript(); |
| 61 | 63 |
| 62 // Based on the given path, calls into the DomDistillerServiceInterface for | 64 // Based on the given path, calls into the DomDistillerServiceInterface for |
| 63 // viewing distilled content based on the |path|. | 65 // viewing distilled content based on the |path|. |
| 64 scoped_ptr<ViewerHandle> CreateViewRequest( | 66 scoped_ptr<ViewerHandle> CreateViewRequest( |
| 65 DomDistillerServiceInterface* dom_distiller_service, | 67 DomDistillerServiceInterface* dom_distiller_service, |
| 66 const std::string& path, | 68 const std::string& path, |
| 67 ViewRequestDelegate* view_request_delegate); | 69 ViewRequestDelegate* view_request_delegate); |
| 68 | 70 |
| 71 // Returns the corresponding CSS class | |
| 72 const char* GetBodyCssClass(ReaderModePrefs::Theme theme); | |
|
nyquist
2014/06/27 20:48:27
Could this return std::string? Also can this be co
smaslo
2014/06/30 17:57:15
Made std::string, but couldn't make it const. I t
| |
| 73 | |
| 69 } // namespace viewer | 74 } // namespace viewer |
| 70 | 75 |
| 71 } // namespace dom_distiller | 76 } // namespace dom_distiller |
| 72 | 77 |
| 73 #endif // COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_ | 78 #endif // COMPONENTS_DOM_DISTILLER_CORE_VIEWER_H_ |
| OLD | NEW |