| 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" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "base/values.h" | 13 #include "base/values.h" |
| 14 #include "third_party/dom_distiller_js/dom_distiller.pb.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 namespace dom_distiller { | 17 namespace dom_distiller { |
| 17 | 18 |
| 18 struct DistilledPageInfo { | 19 struct DistilledPageInfo { |
| 19 std::string title; | 20 std::string title; |
| 20 std::string html; | 21 std::string html; |
| 21 std::string next_page_url; | 22 std::string next_page_url; |
| 22 std::string prev_page_url; | 23 std::string prev_page_url; |
| 23 std::vector<std::string> image_urls; | 24 std::vector<std::string> image_urls; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 37 public: | 38 public: |
| 38 typedef base::Callback<void(scoped_ptr<DistilledPageInfo> distilled_page, | 39 typedef base::Callback<void(scoped_ptr<DistilledPageInfo> distilled_page, |
| 39 bool distillation_successful)> | 40 bool distillation_successful)> |
| 40 DistillerPageCallback; | 41 DistillerPageCallback; |
| 41 | 42 |
| 42 DistillerPage(); | 43 DistillerPage(); |
| 43 virtual ~DistillerPage(); | 44 virtual ~DistillerPage(); |
| 44 | 45 |
| 45 // Loads a URL. |OnDistillationDone| is called when the load completes or | 46 // Loads a URL. |OnDistillationDone| is called when the load completes or |
| 46 // fails. May be called when the distiller is idle. Callers can assume that, | 47 // fails. May be called when the distiller is idle. Callers can assume that, |
| 47 // for a given |url|, any DistillerPage implementation will extract the same | 48 // for a given |url| and |options|, any DistillerPage implementation will |
| 48 // content. | 49 // extract the same content. |
| 49 void DistillPage(const GURL& url, const DistillerPageCallback& callback); | 50 void DistillPage(const GURL& url, |
| 51 const dom_distiller::proto::DomDistillerOptions options, |
| 52 const DistillerPageCallback& callback); |
| 50 | 53 |
| 51 // Called when the JavaScript execution completes. |page_url| is the url of | 54 // Called when the JavaScript execution completes. |page_url| is the url of |
| 52 // the distilled page. |value| contains data returned by the script. | 55 // the distilled page. |value| contains data returned by the script. |
| 53 virtual void OnDistillationDone(const GURL& page_url, | 56 virtual void OnDistillationDone(const GURL& page_url, |
| 54 const base::Value* value); | 57 const base::Value* value); |
| 55 | 58 |
| 56 protected: | 59 protected: |
| 57 // Called by |DistillPage| to carry out platform-specific instructions to load | 60 // Called by |DistillPage| to carry out platform-specific instructions to load |
| 58 // and distill the |url| using the provided |script|. The extracted content | 61 // and distill the |url| using the provided |script|. The extracted content |
| 59 // should be the same regardless of the DistillerPage implementation. | 62 // should be the same regardless of the DistillerPage implementation. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 76 | 79 |
| 77 // Constructs and returns a new DistillerPage. The implementation of this | 80 // Constructs and returns a new DistillerPage. The implementation of this |
| 78 // 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 |
| 79 // used. | 82 // used. |
| 80 virtual scoped_ptr<DistillerPage> CreateDistillerPage() const = 0; | 83 virtual scoped_ptr<DistillerPage> CreateDistillerPage() 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 |