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

Side by Side Diff: chrome/browser/renderer_host/render_view_host.cc

Issue 119014: Add some browser-level checks to prohibit access to extension bindings by... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "chrome/browser/renderer_host/render_view_host.h" 5 #include "chrome/browser/renderer_host/render_view_host.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 138
139 // The process may (if we're sharing a process with another host that already 139 // The process may (if we're sharing a process with another host that already
140 // initialized it) or may not (we have our own process or the old process 140 // initialized it) or may not (we have our own process or the old process
141 // crashed) have been initialized. Calling Init multiple times will be 141 // crashed) have been initialized. Calling Init multiple times will be
142 // ignored, so this is safe. 142 // ignored, so this is safe.
143 if (!process()->Init()) 143 if (!process()->Init())
144 return false; 144 return false;
145 DCHECK(process()->channel()); 145 DCHECK(process()->channel());
146 DCHECK(process()->profile()); 146 DCHECK(process()->profile());
147 147
148 if (enabled_bindings_ & BindingsPolicy::DOM_UI) { 148 if (BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)) {
149 ChildProcessSecurityPolicy::GetInstance()->GrantDOMUIBindings( 149 ChildProcessSecurityPolicy::GetInstance()->GrantDOMUIBindings(
150 process()->pid()); 150 process()->pid());
151 } 151 }
152 152
153 if (BindingsPolicy::is_extension_enabled(enabled_bindings_)) {
154 ChildProcessSecurityPolicy::GetInstance()->GrantExtensionBindings(
155 process()->pid());
156 }
157
153 renderer_initialized_ = true; 158 renderer_initialized_ = true;
154 159
155 #if defined(OS_WIN) 160 #if defined(OS_WIN)
156 HANDLE modal_dialog_event_handle; 161 HANDLE modal_dialog_event_handle;
157 HANDLE renderer_process_handle = process()->process().handle(); 162 HANDLE renderer_process_handle = process()->process().handle();
158 if (renderer_process_handle == NULL) 163 if (renderer_process_handle == NULL)
159 renderer_process_handle = GetCurrentProcess(); 164 renderer_process_handle = GetCurrentProcess();
160 165
161 BOOL result = DuplicateHandle(GetCurrentProcess(), 166 BOOL result = DuplicateHandle(GetCurrentProcess(),
162 modal_dialog_event_->handle(), 167 modal_dialog_event_->handle(),
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 const std::string& origin, 1422 const std::string& origin,
1418 const std::string& target) { 1423 const std::string& target) {
1419 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), message, origin, 1424 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), message, origin,
1420 target)); 1425 target));
1421 } 1426 }
1422 1427
1423 void RenderViewHost::OnExtensionRequest(const std::string& name, 1428 void RenderViewHost::OnExtensionRequest(const std::string& name,
1424 const std::string& args, 1429 const std::string& args,
1425 int request_id, 1430 int request_id,
1426 bool has_callback) { 1431 bool has_callback) {
1427 // TODO(aa): Here is where we can check that this renderer was supposed to be 1432 if (!BindingsPolicy::is_extension_enabled(enabled_bindings_)) {
1428 // able to call extension APIs. 1433 NOTREACHED() << "Blocked unauthorized use of extension bindings.";
1434 return;
1435 }
1436
1429 DCHECK(extension_function_dispatcher_.get()); 1437 DCHECK(extension_function_dispatcher_.get());
1430 extension_function_dispatcher_->HandleRequest(name, args, request_id, 1438 extension_function_dispatcher_->HandleRequest(name, args, request_id,
1431 has_callback); 1439 has_callback);
1432 } 1440 }
1433 1441
1434 void RenderViewHost::SendExtensionResponse(int request_id, bool success, 1442 void RenderViewHost::SendExtensionResponse(int request_id, bool success,
1435 const std::string& response, 1443 const std::string& response,
1436 const std::string& error) { 1444 const std::string& error) {
1437 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success, 1445 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success,
1438 response, error)); 1446 response, error));
1439 } 1447 }
1440 1448
1441 void RenderViewHost::OnExtensionPostMessage( 1449 void RenderViewHost::OnExtensionPostMessage(
1442 int port_id, const std::string& message) { 1450 int port_id, const std::string& message) {
1443 URLRequestContext* context = process()->profile()->GetRequestContext(); 1451 URLRequestContext* context = process()->profile()->GetRequestContext();
1444 ExtensionMessageService::GetInstance(context)-> 1452 ExtensionMessageService::GetInstance(context)->
1445 PostMessageFromRenderer(port_id, message); 1453 PostMessageFromRenderer(port_id, message);
1446 } 1454 }
1447 1455
1448 void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) { 1456 void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) {
1449 #if defined(OS_WIN) 1457 #if defined(OS_WIN)
1450 BrowserAccessibilityManager::GetInstance()-> 1458 BrowserAccessibilityManager::GetInstance()->
1451 ChangeAccessibilityFocus(acc_obj_id, process()->pid(), routing_id()); 1459 ChangeAccessibilityFocus(acc_obj_id, process()->pid(), routing_id());
1452 #else 1460 #else
1453 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. 1461 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288.
1454 #endif 1462 #endif
1455 } 1463 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_message_service.cc ('k') | chrome/browser/tab_contents/tab_contents.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698