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

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

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 <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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 args->GetString(0, &url); 63 args->GetString(0, &url);
64 GURL gurl(url); 64 GURL gurl(url);
65 if (gurl.is_valid()) { 65 if (gurl.is_valid()) {
66 service_->AddToList( 66 service_->AddToList(
67 gurl, 67 gurl,
68 service_->CreateDefaultDistillerPage( 68 service_->CreateDefaultDistillerPage(
69 web_ui()->GetWebContents()->GetContainerBounds().size()), 69 web_ui()->GetWebContents()->GetContainerBounds().size()),
70 base::Bind(base::Bind(&DomDistillerHandler::OnArticleAdded, 70 base::Bind(base::Bind(&DomDistillerHandler::OnArticleAdded,
71 base::Unretained(this)))); 71 base::Unretained(this))));
72 } else { 72 } else {
73 web_ui()->CallJavascriptFunction("domDistiller.onArticleAddFailed"); 73 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onArticleAddFailed");
74 } 74 }
75 } 75 }
76 76
77 void DomDistillerHandler::HandleViewUrl(const base::ListValue* args) { 77 void DomDistillerHandler::HandleViewUrl(const base::ListValue* args) {
78 GURL view_url = GetViewUrlFromArgs(article_scheme_, args); 78 GURL view_url = GetViewUrlFromArgs(article_scheme_, args);
79 if (view_url.is_valid()) { 79 if (view_url.is_valid()) {
80 web_ui()->GetWebContents()->GetController().LoadURL( 80 web_ui()->GetWebContents()->GetController().LoadURL(
81 view_url, 81 view_url,
82 content::Referrer(), 82 content::Referrer(),
83 ui::PAGE_TRANSITION_GENERATED, 83 ui::PAGE_TRANSITION_GENERATED,
84 std::string()); 84 std::string());
85 } else { 85 } else {
86 web_ui()->CallJavascriptFunction("domDistiller.onViewUrlFailed"); 86 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onViewUrlFailed");
87 } 87 }
88 } 88 }
89 89
90 void DomDistillerHandler::HandleSelectArticle(const base::ListValue* args) { 90 void DomDistillerHandler::HandleSelectArticle(const base::ListValue* args) {
91 std::string entry_id; 91 std::string entry_id;
92 args->GetString(0, &entry_id); 92 args->GetString(0, &entry_id);
93 GURL url = 93 GURL url =
94 url_utils::GetDistillerViewUrlFromEntryId(article_scheme_, entry_id); 94 url_utils::GetDistillerViewUrlFromEntryId(article_scheme_, entry_id);
95 DCHECK(url.is_valid()); 95 DCHECK(url.is_valid());
96 web_ui()->GetWebContents()->GetController().LoadURL( 96 web_ui()->GetWebContents()->GetController().LoadURL(
(...skipping 13 matching lines...) Expand all
110 DCHECK(IsEntryValid(article)); 110 DCHECK(IsEntryValid(article));
111 std::unique_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()->CallJavascriptFunctionUnsafe("domDistiller.onReceivedEntries",
121 entries);
121 } 122 }
122 123
123 void DomDistillerHandler::OnArticleAdded(bool article_available) { 124 void DomDistillerHandler::OnArticleAdded(bool article_available) {
124 // TODO(nyquist): Update this function. 125 // TODO(nyquist): Update this function.
125 if (article_available) { 126 if (article_available) {
126 HandleRequestEntries(NULL); 127 HandleRequestEntries(NULL);
127 } else { 128 } else {
128 web_ui()->CallJavascriptFunction("domDistiller.onArticleAddFailed"); 129 web_ui()->CallJavascriptFunctionUnsafe("domDistiller.onArticleAddFailed");
129 } 130 }
130 } 131 }
131 132
132 } // namespace dom_distiller 133 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « chrome/test/data/webui/async_gen.cc ('k') | components/proximity_auth/webui/proximity_auth_webui_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698