Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(152)

Side by Side Diff: components/dom_distiller/core/distiller_page.cc

Issue 411253008: dom distiller: extract markup properties from protobuf (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 script.replace(options_offset, strlen(kOptionsPlaceholder), options_json); 45 script.replace(options_offset, strlen(kOptionsPlaceholder), options_json);
46 return script; 46 return script;
47 } 47 }
48 48
49 } 49 }
50 50
51 DistilledPageInfo::DistilledPageInfo() {} 51 DistilledPageInfo::DistilledPageInfo() {}
52 52
53 DistilledPageInfo::~DistilledPageInfo() {} 53 DistilledPageInfo::~DistilledPageInfo() {}
54 54
55 DistilledPageInfo::MarkupArticle::MarkupArticle() {}
56
57 DistilledPageInfo::MarkupArticle::~MarkupArticle() {}
58
59 DistilledPageInfo::MarkupImage::MarkupImage() {}
60
61 DistilledPageInfo::MarkupImage::~MarkupImage() {}
62
63 DistilledPageInfo::MarkupInfo::MarkupInfo() {}
64
65 DistilledPageInfo::MarkupInfo::~MarkupInfo() {}
66
55 DistillerPageFactory::~DistillerPageFactory() {} 67 DistillerPageFactory::~DistillerPageFactory() {}
56 68
57 DistillerPage::DistillerPage() : ready_(true) {} 69 DistillerPage::DistillerPage() : ready_(true) {}
58 70
59 DistillerPage::~DistillerPage() {} 71 DistillerPage::~DistillerPage() {}
60 72
61 void DistillerPage::DistillPage( 73 void DistillerPage::DistillPage(
62 const GURL& gurl, 74 const GURL& gurl,
63 const dom_distiller::proto::DomDistillerOptions options, 75 const dom_distiller::proto::DomDistillerOptions options,
64 const DistillerPageCallback& callback) { 76 const DistillerPageCallback& callback) {
(...skipping 19 matching lines...) Expand all
84 page_info->title = distiller_result.title(); 96 page_info->title = distiller_result.title();
85 page_info->html = distiller_result.distilled_content().html(); 97 page_info->html = distiller_result.distilled_content().html();
86 page_info->next_page_url = distiller_result.pagination_info().next_page(); 98 page_info->next_page_url = distiller_result.pagination_info().next_page();
87 page_info->prev_page_url = distiller_result.pagination_info().prev_page(); 99 page_info->prev_page_url = distiller_result.pagination_info().prev_page();
88 for (int i = 0; i < distiller_result.image_urls_size(); ++i) { 100 for (int i = 0; i < distiller_result.image_urls_size(); ++i) {
89 const std::string image_url = distiller_result.image_urls(i); 101 const std::string image_url = distiller_result.image_urls(i);
90 if (GURL(image_url).is_valid()) { 102 if (GURL(image_url).is_valid()) {
91 page_info->image_urls.push_back(image_url); 103 page_info->image_urls.push_back(image_url);
92 } 104 }
93 } 105 }
106 const dom_distiller::proto::MarkupInfo& src_markup_info =
107 distiller_result.markup_info();
108 DistilledPageInfo::MarkupInfo& dst_markup_info = page_info->markup_info;
109 dst_markup_info.title = src_markup_info.title();
110 dst_markup_info.type = src_markup_info.type();
111 dst_markup_info.url = src_markup_info.url();
112 dst_markup_info.description = src_markup_info.description();
113 dst_markup_info.publisher = src_markup_info.publisher();
114 dst_markup_info.copyright = src_markup_info.copyright();
115 dst_markup_info.author = src_markup_info.author();
116
117 const dom_distiller::proto::MarkupArticle& src_article =
118 src_markup_info.article();
119 DistilledPageInfo::MarkupArticle& dst_article = dst_markup_info.article;
120 dst_article.published_time = src_article.published_time();
121 dst_article.modified_time = src_article.modified_time();
122 dst_article.expiration_time = src_article.expiration_time();
123 dst_article.section = src_article.section();
124 for (int i = 0; i < src_article.authors_size(); ++i) {
125 dst_article.authors.push_back(src_article.authors(i));
126 }
127
128 for (int i = 0; i < src_markup_info.images_size(); ++i) {
129 const dom_distiller::proto::MarkupImage& src_image =
130 src_markup_info.images(i);
131 DistilledPageInfo::MarkupImage dst_image;
132 dst_image.url = src_image.url();
133 dst_image.secure_url = src_image.secure_url();
134 dst_image.type = src_image.type();
135 dst_image.caption = src_image.caption();
136 dst_image.width = src_image.width();
137 dst_image.height = src_image.height();
138 dst_markup_info.images.push_back(dst_image);
139 }
94 } 140 }
95 141
96 base::MessageLoop::current()->PostTask( 142 base::MessageLoop::current()->PostTask(
97 FROM_HERE, 143 FROM_HERE,
98 base::Bind( 144 base::Bind(
99 distiller_page_callback_, base::Passed(&page_info), found_content)); 145 distiller_page_callback_, base::Passed(&page_info), found_content));
100 } 146 }
101 147
102 } // namespace dom_distiller 148 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/distiller_page.h ('k') | components/test/data/dom_distiller/markup_article.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698