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

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

Issue 2051663003: base::ListValue::Append cleanup: pass unique_ptr instead of the released pointer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 6 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
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 <utility>
7 #include <vector> 8 #include <vector>
8 9
9 #include "base/bind.h" 10 #include "base/bind.h"
10 #include "base/values.h" 11 #include "base/values.h"
11 #include "components/dom_distiller/core/dom_distiller_service.h" 12 #include "components/dom_distiller/core/dom_distiller_service.h"
12 #include "components/dom_distiller/core/proto/distilled_page.pb.h" 13 #include "components/dom_distiller/core/proto/distilled_page.pb.h"
13 #include "components/dom_distiller/core/url_utils.h" 14 #include "components/dom_distiller/core/url_utils.h"
14 #include "content/public/browser/web_contents.h" 15 #include "content/public/browser/web_contents.h"
15 #include "content/public/browser/web_ui.h" 16 #include "content/public/browser/web_ui.h"
16 #include "net/base/escape.h" 17 #include "net/base/escape.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 it != entries_specifics.end(); 108 it != entries_specifics.end();
108 ++it) { 109 ++it) {
109 const ArticleEntry& article = *it; 110 const ArticleEntry& article = *it;
110 DCHECK(IsEntryValid(article)); 111 DCHECK(IsEntryValid(article));
111 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); 112 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue());
112 entry->SetString("entry_id", article.entry_id()); 113 entry->SetString("entry_id", article.entry_id());
113 std::string title = (!article.has_title() || article.title().empty()) 114 std::string title = (!article.has_title() || article.title().empty())
114 ? article.entry_id() 115 ? article.entry_id()
115 : article.title(); 116 : article.title();
116 entry->SetString("title", net::EscapeForHTML(title)); 117 entry->SetString("title", net::EscapeForHTML(title));
117 entries.Append(entry.release()); 118 entries.Append(std::move(entry));
118 } 119 }
119 // TODO(nyquist): Write a test that ensures we sanitize the data we send. 120 // TODO(nyquist): Write a test that ensures we sanitize the data we send.
120 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onReceivedEntries", 121 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onReceivedEntries",
121 entries); 122 entries);
122 } 123 }
123 124
124 void DomDistillerHandler::OnArticleAdded(bool article_available) { 125 void DomDistillerHandler::OnArticleAdded(bool article_available) {
125 // TODO(nyquist): Update this function. 126 // TODO(nyquist): Update this function.
126 if (article_available) { 127 if (article_available) {
127 HandleRequestEntries(NULL); 128 HandleRequestEntries(NULL);
128 } else { 129 } else {
129 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onArticleAddFailed"); 130 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onArticleAddFailed");
130 } 131 }
131 } 132 }
132 133
133 } // namespace dom_distiller 134 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698