OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_DISTILLER_PAGE_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ |
6 #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // the distilled page. |value| contains data returned by the script. | 48 // the distilled page. |value| contains data returned by the script. |
49 virtual void OnDistillationDone(const GURL& page_url, | 49 virtual void OnDistillationDone(const GURL& page_url, |
50 const base::Value* value); | 50 const base::Value* value); |
51 | 51 |
52 protected: | 52 protected: |
53 // Called by |DistillPage| to carry out platform-specific instructions to load | 53 // Called by |DistillPage| to carry out platform-specific instructions to load |
54 // and distill the |url| using the provided |script|. The extracted content | 54 // and distill the |url| using the provided |script|. The extracted content |
55 // should be the same regardless of the DistillerPage implementation. | 55 // should be the same regardless of the DistillerPage implementation. |
56 virtual void DistillPageImpl(const GURL& url, const std::string& script) = 0; | 56 virtual void DistillPageImpl(const GURL& url, const std::string& script) = 0; |
57 | 57 |
| 58 // The value returned between the JavaScript and the DistillerPage can be |
| 59 // either a dictionary with all the content, or a stringified version. |
| 60 virtual bool StringifyOutput() = 0; |
| 61 |
| 62 // If true, forces the creation of a new window context to evaluate the |
| 63 // JavaScript. |
| 64 virtual bool CreateNewContext() = 0; |
| 65 |
58 private: | 66 private: |
59 bool ready_; | 67 bool ready_; |
60 DistillerPageCallback distiller_page_callback_; | 68 DistillerPageCallback distiller_page_callback_; |
61 DISALLOW_COPY_AND_ASSIGN(DistillerPage); | 69 DISALLOW_COPY_AND_ASSIGN(DistillerPage); |
62 }; | 70 }; |
63 | 71 |
64 // Factory for generating a |DistillerPage|. | 72 // Factory for generating a |DistillerPage|. |
65 class DistillerPageFactory { | 73 class DistillerPageFactory { |
66 public: | 74 public: |
67 virtual ~DistillerPageFactory(); | 75 virtual ~DistillerPageFactory(); |
68 | 76 |
69 // Constructs and returns a new DistillerPage. The implementation of this | 77 // Constructs and returns a new DistillerPage. The implementation of this |
70 // should be very cheap, since the pages can be thrown away without being | 78 // should be very cheap, since the pages can be thrown away without being |
71 // used. | 79 // used. |
72 virtual scoped_ptr<DistillerPage> CreateDistillerPage( | 80 virtual scoped_ptr<DistillerPage> CreateDistillerPage( |
73 const gfx::Size& render_view_size) const = 0; | 81 const gfx::Size& render_view_size) const = 0; |
74 virtual scoped_ptr<DistillerPage> CreateDistillerPageWithHandle( | 82 virtual scoped_ptr<DistillerPage> CreateDistillerPageWithHandle( |
75 scoped_ptr<SourcePageHandle> handle) const = 0; | 83 scoped_ptr<SourcePageHandle> handle) const = 0; |
76 }; | 84 }; |
77 | 85 |
78 } // namespace dom_distiller | 86 } // namespace dom_distiller |
79 | 87 |
80 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ | 88 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ |
OLD | NEW |