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