| 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.h" | 5 #include "components/dom_distiller/core/distiller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 if (distiller_result->has_pagination_info()) { | 171 if (distiller_result->has_pagination_info()) { |
| 172 proto::PaginationInfo pagination_info = | 172 proto::PaginationInfo pagination_info = |
| 173 distiller_result->pagination_info(); | 173 distiller_result->pagination_info(); |
| 174 if (pagination_info.has_next_page()) { | 174 if (pagination_info.has_next_page()) { |
| 175 GURL next_page_url(pagination_info.next_page()); | 175 GURL next_page_url(pagination_info.next_page()); |
| 176 if (next_page_url.is_valid()) { | 176 if (next_page_url.is_valid()) { |
| 177 // The pages should be in same origin. | 177 // The pages should be in same origin. |
| 178 DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin()); | 178 DCHECK_EQ(next_page_url.GetOrigin(), page_url.GetOrigin()); |
| 179 AddToDistillationQueue(page_num + 1, next_page_url); | 179 AddToDistillationQueue(page_num + 1, next_page_url); |
| 180 page_data->distilled_page_proto->data.mutable_pagination_info()-> |
| 181 set_next_page(next_page_url.spec()); |
| 180 } | 182 } |
| 181 } | 183 } |
| 182 | 184 |
| 183 if (pagination_info.has_prev_page()) { | 185 if (pagination_info.has_prev_page()) { |
| 184 GURL prev_page_url(pagination_info.prev_page()); | 186 GURL prev_page_url(pagination_info.prev_page()); |
| 185 if (prev_page_url.is_valid()) { | 187 if (prev_page_url.is_valid()) { |
| 186 DCHECK_EQ(prev_page_url.GetOrigin(), page_url.GetOrigin()); | 188 DCHECK_EQ(prev_page_url.GetOrigin(), page_url.GetOrigin()); |
| 187 AddToDistillationQueue(page_num - 1, prev_page_url); | 189 AddToDistillationQueue(page_num - 1, prev_page_url); |
| 190 page_data->distilled_page_proto->data.mutable_pagination_info()-> |
| 191 set_prev_page(prev_page_url.spec()); |
| 192 } |
| 193 } |
| 194 |
| 195 if (pagination_info.has_canonical_page()) { |
| 196 GURL canonical_page_url(pagination_info.canonical_page()); |
| 197 if (canonical_page_url.is_valid()) { |
| 198 page_data->distilled_page_proto->data.mutable_pagination_info()-> |
| 199 set_canonical_page(canonical_page_url.spec()); |
| 188 } | 200 } |
| 189 } | 201 } |
| 190 } | 202 } |
| 191 | 203 |
| 192 for (int img_num = 0; img_num < distiller_result->image_urls_size(); | 204 for (int img_num = 0; img_num < distiller_result->image_urls_size(); |
| 193 ++img_num) { | 205 ++img_num) { |
| 194 std::string image_id = | 206 std::string image_id = |
| 195 base::IntToString(page_num + 1) + "_" + base::IntToString(img_num); | 207 base::IntToString(page_num + 1) + "_" + base::IntToString(img_num); |
| 196 FetchImage(page_num, image_id, distiller_result->image_urls(img_num)); | 208 FetchImage(page_num, image_id, distiller_result->image_urls(img_num)); |
| 197 } | 209 } |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 DCHECK(finished_pages_index_.empty()); | 324 DCHECK(finished_pages_index_.empty()); |
| 313 | 325 |
| 314 base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_, | 326 base::AutoReset<bool> dont_delete_this_in_callback(&destruction_allowed_, |
| 315 false); | 327 false); |
| 316 finished_cb_.Run(article_proto.Pass()); | 328 finished_cb_.Run(article_proto.Pass()); |
| 317 finished_cb_.Reset(); | 329 finished_cb_.Reset(); |
| 318 } | 330 } |
| 319 } | 331 } |
| 320 | 332 |
| 321 } // namespace dom_distiller | 333 } // namespace dom_distiller |
| OLD | NEW |