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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 58 // The value returned between the JavaScript and the DistillerPage can be |
59 // either a dictionary with all the content, or a stringified version. | 59 // either a dictionary with all the content, or a stringified version. |
60 virtual bool StringifyOutput() = 0; | 60 virtual bool StringifyOutput() = 0; |
61 | 61 |
62 // If true, forces the creation of a new window context to evaluate the | |
63 // JavaScript. | |
64 virtual bool CreateNewContext() = 0; | |
65 | |
66 private: | 62 private: |
67 bool ready_; | 63 bool ready_; |
68 DistillerPageCallback distiller_page_callback_; | 64 DistillerPageCallback distiller_page_callback_; |
69 base::TimeTicks distillation_start_; | 65 base::TimeTicks distillation_start_; |
70 DISALLOW_COPY_AND_ASSIGN(DistillerPage); | 66 DISALLOW_COPY_AND_ASSIGN(DistillerPage); |
71 }; | 67 }; |
72 | 68 |
73 // Factory for generating a |DistillerPage|. | 69 // Factory for generating a |DistillerPage|. |
74 class DistillerPageFactory { | 70 class DistillerPageFactory { |
75 public: | 71 public: |
76 virtual ~DistillerPageFactory(); | 72 virtual ~DistillerPageFactory(); |
77 | 73 |
78 // Constructs and returns a new DistillerPage. The implementation of this | 74 // Constructs and returns a new DistillerPage. The implementation of this |
79 // should be very cheap, since the pages can be thrown away without being | 75 // should be very cheap, since the pages can be thrown away without being |
80 // used. | 76 // used. |
81 virtual scoped_ptr<DistillerPage> CreateDistillerPage( | 77 virtual scoped_ptr<DistillerPage> CreateDistillerPage( |
82 const gfx::Size& render_view_size) const = 0; | 78 const gfx::Size& render_view_size) const = 0; |
83 virtual scoped_ptr<DistillerPage> CreateDistillerPageWithHandle( | 79 virtual scoped_ptr<DistillerPage> CreateDistillerPageWithHandle( |
84 scoped_ptr<SourcePageHandle> handle) const = 0; | 80 scoped_ptr<SourcePageHandle> handle) const = 0; |
85 }; | 81 }; |
86 | 82 |
87 } // namespace dom_distiller | 83 } // namespace dom_distiller |
88 | 84 |
89 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ | 85 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ |
OLD | NEW |