| 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 11 matching lines...) Expand all Loading... |
| 22 std::string next_page_url; | 22 std::string next_page_url; |
| 23 std::string prev_page_url; | 23 std::string prev_page_url; |
| 24 std::vector<std::string> image_urls; | 24 std::vector<std::string> image_urls; |
| 25 DistilledPageInfo(); | 25 DistilledPageInfo(); |
| 26 ~DistilledPageInfo(); | 26 ~DistilledPageInfo(); |
| 27 | 27 |
| 28 private: | 28 private: |
| 29 DISALLOW_COPY_AND_ASSIGN(DistilledPageInfo); | 29 DISALLOW_COPY_AND_ASSIGN(DistilledPageInfo); |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 class SourcePageHandle { | |
| 33 public: | |
| 34 virtual ~SourcePageHandle() {} | |
| 35 }; | |
| 36 | |
| 37 // Injects JavaScript into a page, and uses it to extract and return long-form | 32 // Injects JavaScript into a page, and uses it to extract and return long-form |
| 38 // content. The class can be reused to load and distill multiple pages, | 33 // content. The class can be reused to load and distill multiple pages, |
| 39 // following the state transitions described along with the class's states. | 34 // following the state transitions described along with the class's states. |
| 40 // Constructing a DistillerPage should be cheap, as some of the instances can be | 35 // Constructing a DistillerPage should be cheap, as some of the instances can be |
| 41 // thrown away without ever being used. | 36 // thrown away without ever being used. |
| 42 class DistillerPage { | 37 class DistillerPage { |
| 43 public: | 38 public: |
| 44 typedef base::Callback<void(scoped_ptr<DistilledPageInfo> distilled_page, | 39 typedef base::Callback<void(scoped_ptr<DistilledPageInfo> distilled_page, |
| 45 bool distillation_successful)> | 40 bool distillation_successful)> |
| 46 DistillerPageCallback; | 41 DistillerPageCallback; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 60 // the distilled page. |value| contains data returned by the script. | 55 // the distilled page. |value| contains data returned by the script. |
| 61 virtual void OnDistillationDone(const GURL& page_url, | 56 virtual void OnDistillationDone(const GURL& page_url, |
| 62 const base::Value* value); | 57 const base::Value* value); |
| 63 | 58 |
| 64 protected: | 59 protected: |
| 65 // Called by |DistillPage| to carry out platform-specific instructions to load | 60 // Called by |DistillPage| to carry out platform-specific instructions to load |
| 66 // and distill the |url| using the provided |script|. The extracted content | 61 // and distill the |url| using the provided |script|. The extracted content |
| 67 // should be the same regardless of the DistillerPage implementation. | 62 // should be the same regardless of the DistillerPage implementation. |
| 68 virtual void DistillPageImpl(const GURL& url, const std::string& script) = 0; | 63 virtual void DistillPageImpl(const GURL& url, const std::string& script) = 0; |
| 69 | 64 |
| 65 // Called by |ExecuteJavaScript| to carry out platform-specific instructions |
| 66 // to inject and execute JavaScript within the context of the loaded page. |
| 67 //virtual void ExecuteJavaScriptImpl() = 0; |
| 68 |
| 70 private: | 69 private: |
| 71 bool ready_; | 70 bool ready_; |
| 72 DistillerPageCallback distiller_page_callback_; | 71 DistillerPageCallback distiller_page_callback_; |
| 73 DISALLOW_COPY_AND_ASSIGN(DistillerPage); | 72 DISALLOW_COPY_AND_ASSIGN(DistillerPage); |
| 74 }; | 73 }; |
| 75 | 74 |
| 76 // Factory for generating a |DistillerPage|. | 75 // Factory for generating a |DistillerPage|. |
| 77 class DistillerPageFactory { | 76 class DistillerPageFactory { |
| 78 public: | 77 public: |
| 79 virtual ~DistillerPageFactory(); | 78 virtual ~DistillerPageFactory(); |
| 80 | 79 |
| 81 // Constructs and returns a new DistillerPage. The implementation of this | 80 // Constructs and returns a new DistillerPage. The implementation of this |
| 82 // should be very cheap, since the pages can be thrown away without being | 81 // should be very cheap, since the pages can be thrown away without being |
| 83 // used. | 82 // used. |
| 84 virtual scoped_ptr<DistillerPage> CreateDistillerPage() const = 0; | 83 virtual scoped_ptr<DistillerPage> CreateDistillerPage() const = 0; |
| 85 virtual scoped_ptr<DistillerPage> CreateDistillerPageWithHandle( | |
| 86 scoped_ptr<SourcePageHandle> handle) const = 0; | |
| 87 }; | 84 }; |
| 88 | 85 |
| 89 } // namespace dom_distiller | 86 } // namespace dom_distiller |
| 90 | 87 |
| 91 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ | 88 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLER_PAGE_H_ |
| OLD | NEW |