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

Side by Side Diff: content/browser/webui/web_ui_impl.cc

Issue 9360014: Create a content public browser API around the ChildProcessSecurityPolicy class. The implementati... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 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 (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/command_line.h" 7 #include "base/command_line.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "content/browser/child_process_security_policy.h" 12 #include "content/browser/child_process_security_policy_impl.h"
13 #include "content/browser/renderer_host/render_process_host_impl.h" 13 #include "content/browser/renderer_host/render_process_host_impl.h"
14 #include "content/browser/renderer_host/render_view_host.h" 14 #include "content/browser/renderer_host/render_view_host.h"
15 #include "content/browser/tab_contents/tab_contents.h" 15 #include "content/browser/tab_contents/tab_contents.h"
16 #include "content/browser/webui/generic_handler.h" 16 #include "content/browser/webui/generic_handler.h"
17 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
18 #include "content/public/browser/web_contents_view.h" 18 #include "content/public/browser/web_contents_view.h"
19 #include "content/public/browser/web_ui_controller.h" 19 #include "content/public/browser/web_ui_controller.h"
20 #include "content/public/common/bindings_policy.h" 20 #include "content/public/common/bindings_policy.h"
21 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
22 22
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 IPC_BEGIN_MESSAGE_MAP(WebUIImpl, message) 72 IPC_BEGIN_MESSAGE_MAP(WebUIImpl, message)
73 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend) 73 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnWebUISend)
74 IPC_MESSAGE_UNHANDLED(handled = false) 74 IPC_MESSAGE_UNHANDLED(handled = false)
75 IPC_END_MESSAGE_MAP() 75 IPC_END_MESSAGE_MAP()
76 return handled; 76 return handled;
77 } 77 }
78 78
79 void WebUIImpl::OnWebUISend(const GURL& source_url, 79 void WebUIImpl::OnWebUISend(const GURL& source_url,
80 const std::string& message, 80 const std::string& message,
81 const ListValue& args) { 81 const ListValue& args) {
82 if (!ChildProcessSecurityPolicy::GetInstance()-> 82 if (!ChildProcessSecurityPolicyImpl::GetInstance()->
83 HasWebUIBindings(web_contents_->GetRenderProcessHost()->GetID())) { 83 HasWebUIBindings(web_contents_->GetRenderProcessHost()->GetID())) {
84 NOTREACHED() << "Blocked unauthorized use of WebUIBindings."; 84 NOTREACHED() << "Blocked unauthorized use of WebUIBindings.";
85 return; 85 return;
86 } 86 }
87 87
88 if (controller_->OverrideHandleWebUIMessage(source_url, message,args)) 88 if (controller_->OverrideHandleWebUIMessage(source_url, message,args))
89 return; 89 return;
90 90
91 // Look up the callback for this message. 91 // Look up the callback for this message.
92 MessageCallbackMap::const_iterator callback = 92 MessageCallbackMap::const_iterator callback =
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 DCHECK(!handler->web_ui()); 257 DCHECK(!handler->web_ui());
258 handler->set_web_ui(this); 258 handler->set_web_ui(this);
259 handler->RegisterMessages(); 259 handler->RegisterMessages();
260 handlers_.push_back(handler); 260 handlers_.push_back(handler);
261 } 261 }
262 262
263 void WebUIImpl::ExecuteJavascript(const string16& javascript) { 263 void WebUIImpl::ExecuteJavascript(const string16& javascript) {
264 web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame( 264 web_contents_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(
265 ASCIIToUTF16(frame_xpath_), javascript); 265 ASCIIToUTF16(frame_xpath_), javascript);
266 } 266 }
OLDNEW
« no previous file with comments | « content/browser/tab_contents/tab_contents.cc ('k') | content/browser/worker_host/worker_process_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698