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

Side by Side Diff: components/dom_distiller/webui/dom_distiller_handler.cc

Issue 1879613003: Convert //components/dom_distiller from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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
« no previous file with comments | « components/dom_distiller/standalone/content_extractor_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/webui/dom_distiller_handler.h" 5 #include "components/dom_distiller/webui/dom_distiller_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 } 101 }
102 102
103 void DomDistillerHandler::HandleRequestEntries(const base::ListValue* args) { 103 void DomDistillerHandler::HandleRequestEntries(const base::ListValue* args) {
104 base::ListValue entries; 104 base::ListValue entries;
105 const std::vector<ArticleEntry>& entries_specifics = service_->GetEntries(); 105 const std::vector<ArticleEntry>& entries_specifics = service_->GetEntries();
106 for (std::vector<ArticleEntry>::const_iterator it = entries_specifics.begin(); 106 for (std::vector<ArticleEntry>::const_iterator it = entries_specifics.begin();
107 it != entries_specifics.end(); 107 it != entries_specifics.end();
108 ++it) { 108 ++it) {
109 const ArticleEntry& article = *it; 109 const ArticleEntry& article = *it;
110 DCHECK(IsEntryValid(article)); 110 DCHECK(IsEntryValid(article));
111 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); 111 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
112 entry->SetString("entry_id", article.entry_id()); 112 entry->SetString("entry_id", article.entry_id());
113 std::string title = (!article.has_title() || article.title().empty()) 113 std::string title = (!article.has_title() || article.title().empty())
114 ? article.entry_id() 114 ? article.entry_id()
115 : article.title(); 115 : article.title();
116 entry->SetString("title", net::EscapeForHTML(title)); 116 entry->SetString("title", net::EscapeForHTML(title));
117 entries.Append(entry.release()); 117 entries.Append(entry.release());
118 } 118 }
119 // TODO(nyquist): Write a test that ensures we sanitize the data we send. 119 // TODO(nyquist): Write a test that ensures we sanitize the data we send.
120 web_ui()->CallJavascriptFunction("domDistiller.onReceivedEntries", entries); 120 web_ui()->CallJavascriptFunction("domDistiller.onReceivedEntries", entries);
121 } 121 }
122 122
123 void DomDistillerHandler::OnArticleAdded(bool article_available) { 123 void DomDistillerHandler::OnArticleAdded(bool article_available) {
124 // TODO(nyquist): Update this function. 124 // TODO(nyquist): Update this function.
125 if (article_available) { 125 if (article_available) {
126 HandleRequestEntries(NULL); 126 HandleRequestEntries(NULL);
127 } else { 127 } else {
128 web_ui()->CallJavascriptFunction("domDistiller.onArticleAddFailed"); 128 web_ui()->CallJavascriptFunction("domDistiller.onArticleAddFailed");
129 } 129 }
130 } 130 }
131 131
132 } // namespace dom_distiller 132 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/standalone/content_extractor_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698