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 #include "components/dom_distiller/core/distiller_page.h" | 5 #include "components/dom_distiller/core/distiller_page.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 DistilledPageInfo::DistilledPageInfo() {} | 51 DistilledPageInfo::DistilledPageInfo() {} |
52 | 52 |
53 DistilledPageInfo::~DistilledPageInfo() {} | 53 DistilledPageInfo::~DistilledPageInfo() {} |
54 | 54 |
55 DistillerPageFactory::~DistillerPageFactory() {} | 55 DistillerPageFactory::~DistillerPageFactory() {} |
56 | 56 |
57 DistillerPage::DistillerPage() : ready_(true) {} | 57 DistillerPage::DistillerPage() : ready_(true) {} |
58 | 58 |
59 DistillerPage::~DistillerPage() {} | 59 DistillerPage::~DistillerPage() {} |
60 | 60 |
61 void DistillerPage::DistillPage(const GURL& gurl, | 61 void DistillerPage::DistillPage( |
62 const DistillerPageCallback& callback) { | 62 const GURL& gurl, |
| 63 const dom_distiller::proto::DomDistillerOptions options, |
| 64 const DistillerPageCallback& callback) { |
63 DCHECK(ready_); | 65 DCHECK(ready_); |
64 // It is only possible to distill one page at a time. |ready_| is reset when | 66 // It is only possible to distill one page at a time. |ready_| is reset when |
65 // the callback to OnDistillationDone happens. | 67 // the callback to OnDistillationDone happens. |
66 ready_ = false; | 68 ready_ = false; |
67 distiller_page_callback_ = callback; | 69 distiller_page_callback_ = callback; |
68 dom_distiller::proto::DomDistillerOptions options; | |
69 DistillPageImpl(gurl, GetDistillerScriptWithOptions(options)); | 70 DistillPageImpl(gurl, GetDistillerScriptWithOptions(options)); |
70 } | 71 } |
71 | 72 |
72 void DistillerPage::OnDistillationDone(const GURL& page_url, | 73 void DistillerPage::OnDistillationDone(const GURL& page_url, |
73 const base::Value* value) { | 74 const base::Value* value) { |
74 DCHECK(!ready_); | 75 DCHECK(!ready_); |
75 ready_ = true; | 76 ready_ = true; |
76 | 77 |
77 scoped_ptr<DistilledPageInfo> page_info(new DistilledPageInfo()); | 78 scoped_ptr<DistilledPageInfo> page_info(new DistilledPageInfo()); |
78 bool found_content = !value->IsType(base::Value::TYPE_NULL); | 79 bool found_content = !value->IsType(base::Value::TYPE_NULL); |
(...skipping 13 matching lines...) Expand all Loading... |
92 } | 93 } |
93 } | 94 } |
94 | 95 |
95 base::MessageLoop::current()->PostTask( | 96 base::MessageLoop::current()->PostTask( |
96 FROM_HERE, | 97 FROM_HERE, |
97 base::Bind( | 98 base::Bind( |
98 distiller_page_callback_, base::Passed(&page_info), found_content)); | 99 distiller_page_callback_, base::Passed(&page_info), found_content)); |
99 } | 100 } |
100 | 101 |
101 } // namespace dom_distiller | 102 } // namespace dom_distiller |
OLD | NEW |