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

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

Issue 11783038: Allow multiple WebUIControllerFactory objects to be registered. This makes is possible to implement… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: reland after bogus revert of r175971 Created 7 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/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/stl_util.h" 8 #include "base/stl_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "content/browser/child_process_security_policy_impl.h" 11 #include "content/browser/child_process_security_policy_impl.h"
12 #include "content/browser/renderer_host/dip_util.h" 12 #include "content/browser/renderer_host/dip_util.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_impl.h" 14 #include "content/browser/renderer_host/render_view_host_impl.h"
15 #include "content/browser/web_contents/web_contents_impl.h" 15 #include "content/browser/web_contents/web_contents_impl.h"
16 #include "content/browser/webui/web_ui_controller_factory_registry.h"
16 #include "content/common/view_messages.h" 17 #include "content/common/view_messages.h"
17 #include "content/public/browser/content_browser_client.h" 18 #include "content/public/browser/content_browser_client.h"
18 #include "content/public/browser/web_contents_delegate.h" 19 #include "content/public/browser/web_contents_delegate.h"
19 #include "content/public/browser/web_contents_view.h" 20 #include "content/public/browser/web_contents_view.h"
20 #include "content/public/browser/web_ui_controller.h" 21 #include "content/public/browser/web_ui_controller.h"
21 #include "content/public/browser/web_ui_controller_factory.h"
22 #include "content/public/browser/web_ui_message_handler.h" 22 #include "content/public/browser/web_ui_message_handler.h"
23 #include "content/public/common/bindings_policy.h" 23 #include "content/public/common/bindings_policy.h"
24 #include "content/public/common/content_client.h" 24 #include "content/public/common/content_client.h"
25 25
26 namespace content { 26 namespace content {
27 27
28 const WebUI::TypeID WebUI::kNoWebUI = NULL; 28 const WebUI::TypeID WebUI::kNoWebUI = NULL;
29 29
30 // static 30 // static
31 string16 WebUI::GetJavascriptCall( 31 string16 WebUI::GetJavascriptCall(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 IPC_MESSAGE_UNHANDLED(handled = false) 70 IPC_MESSAGE_UNHANDLED(handled = false)
71 IPC_END_MESSAGE_MAP() 71 IPC_END_MESSAGE_MAP()
72 return handled; 72 return handled;
73 } 73 }
74 74
75 void WebUIImpl::OnWebUISend(const GURL& source_url, 75 void WebUIImpl::OnWebUISend(const GURL& source_url,
76 const std::string& message, 76 const std::string& message,
77 const ListValue& args) { 77 const ListValue& args) {
78 WebContentsDelegate* delegate = web_contents_->GetDelegate(); 78 WebContentsDelegate* delegate = web_contents_->GetDelegate();
79 bool data_urls_allowed = delegate && delegate->CanLoadDataURLsInWebUI(); 79 bool data_urls_allowed = delegate && delegate->CanLoadDataURLsInWebUI();
80 WebUIControllerFactory* factory =
81 GetContentClient()->browser()->GetWebUIControllerFactory();
82 if (!ChildProcessSecurityPolicyImpl::GetInstance()-> 80 if (!ChildProcessSecurityPolicyImpl::GetInstance()->
83 HasWebUIBindings(web_contents_->GetRenderProcessHost()->GetID()) || 81 HasWebUIBindings(web_contents_->GetRenderProcessHost()->GetID()) ||
84 !factory->IsURLAcceptableForWebUI(web_contents_->GetBrowserContext(), 82 !WebUIControllerFactoryRegistry::GetInstance()->IsURLAcceptableForWebUI(
85 source_url, 83 web_contents_->GetBrowserContext(), source_url, data_urls_allowed)) {
86 data_urls_allowed)) {
87 NOTREACHED() << "Blocked unauthorized use of WebUIBindings."; 84 NOTREACHED() << "Blocked unauthorized use of WebUIBindings.";
88 return; 85 return;
89 } 86 }
90 87
91 ProcessWebUIMessage(source_url, message, args); 88 ProcessWebUIMessage(source_url, message, args);
92 } 89 }
93 90
94 void WebUIImpl::RenderViewCreated(RenderViewHost* render_view_host) { 91 void WebUIImpl::RenderViewCreated(RenderViewHost* render_view_host) {
95 controller_->RenderViewCreated(render_view_host); 92 controller_->RenderViewCreated(render_view_host);
96 93
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 handlers_.push_back(handler); 257 handlers_.push_back(handler);
261 } 258 }
262 259
263 void WebUIImpl::ExecuteJavascript(const string16& javascript) { 260 void WebUIImpl::ExecuteJavascript(const string16& javascript) {
264 static_cast<RenderViewHostImpl*>( 261 static_cast<RenderViewHostImpl*>(
265 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame( 262 web_contents_->GetRenderViewHost())->ExecuteJavascriptInWebFrame(
266 ASCIIToUTF16(frame_xpath_), javascript); 263 ASCIIToUTF16(frame_xpath_), javascript);
267 } 264 }
268 265
269 } // namespace content 266 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/webui/web_ui_controller_factory_registry.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698