OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/webui/web_ui_impl.h" | 5 #include "content/browser/webui/web_ui_impl.h" |
6 | 6 |
7 #include "base/debug/dump_without_crashing.h" | 7 #include "base/debug/dump_without_crashing.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
215 if (callback != message_callbacks_.end()) { | 215 if (callback != message_callbacks_.end()) { |
216 // Forward this message and content on. | 216 // Forward this message and content on. |
217 callback->second.Run(&args); | 217 callback->second.Run(&args); |
218 } else { | 218 } else { |
219 NOTREACHED() << "Unhandled chrome.send(\"" << message << "\");"; | 219 NOTREACHED() << "Unhandled chrome.send(\"" << message << "\");"; |
220 } | 220 } |
221 } | 221 } |
222 | 222 |
223 // WebUIImpl, protected: ------------------------------------------------------- | 223 // WebUIImpl, protected: ------------------------------------------------------- |
224 | 224 |
225 void WebUIImpl::AddMessageHandler(WebUIMessageHandler* handler) { | 225 void WebUIImpl::AddMessageHandler(WebUIMessageHandler* handler) { |
Dan Beam
2015/10/29 01:47:20
this would be cooler, IMO:
template<class T>
T* W
tommycli
2015/10/29 17:34:14
Agreed. Unfortunately the vast majority of the 50-
| |
226 DCHECK(!handler->web_ui()); | 226 DCHECK(!handler->web_ui() || handler->web_ui() == this); |
227 handler->set_web_ui(this); | 227 handler->set_web_ui(this); |
228 handler->RegisterMessages(); | 228 handler->RegisterMessages(); |
229 handlers_.push_back(handler); | 229 handlers_.push_back(handler); |
230 } | 230 } |
231 | 231 |
232 void WebUIImpl::ExecuteJavascript(const base::string16& javascript) { | 232 void WebUIImpl::ExecuteJavascript(const base::string16& javascript) { |
233 RenderFrameHost* target_frame = TargetFrame(); | 233 RenderFrameHost* target_frame = TargetFrame(); |
234 if (target_frame) { | 234 if (target_frame) { |
235 if (!(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( | 235 if (!(ChildProcessSecurityPolicyImpl::GetInstance()->HasWebUIBindings( |
236 target_frame->GetProcess()->GetID()) || | 236 target_frame->GetProcess()->GetID()) || |
(...skipping 27 matching lines...) Expand all Loading... | |
264 } | 264 } |
265 | 265 |
266 void WebUIImpl::AddToSetIfFrameNameMatches( | 266 void WebUIImpl::AddToSetIfFrameNameMatches( |
267 std::set<RenderFrameHost*>* frame_set, | 267 std::set<RenderFrameHost*>* frame_set, |
268 RenderFrameHost* host) { | 268 RenderFrameHost* host) { |
269 if (host->GetFrameName() == frame_name_) | 269 if (host->GetFrameName() == frame_name_) |
270 frame_set->insert(host); | 270 frame_set->insert(host); |
271 } | 271 } |
272 | 272 |
273 } // namespace content | 273 } // namespace content |
OLD | NEW |