| OLD | NEW |
| 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 24 matching lines...) Expand all Loading... |
| 35 #include "third_party/skia/include/core/SkBitmap.h" | 35 #include "third_party/skia/include/core/SkBitmap.h" |
| 36 #include "webkit/api/public/WebFindOptions.h" | 36 #include "webkit/api/public/WebFindOptions.h" |
| 37 #include "webkit/glue/autofill_form.h" | 37 #include "webkit/glue/autofill_form.h" |
| 38 | 38 |
| 39 #if defined(OS_WIN) | 39 #if defined(OS_WIN) |
| 40 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. | 40 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. |
| 41 #include "chrome/browser/browser_accessibility_manager.h" | 41 #include "chrome/browser/browser_accessibility_manager.h" |
| 42 #endif | 42 #endif |
| 43 | 43 |
| 44 using base::TimeDelta; | 44 using base::TimeDelta; |
| 45 using webkit_glue::AutofillForm; | |
| 46 using webkit_glue::PasswordFormDomManager; | 45 using webkit_glue::PasswordFormDomManager; |
| 47 using WebKit::WebConsoleMessage; | 46 using WebKit::WebConsoleMessage; |
| 48 using WebKit::WebFindOptions; | 47 using WebKit::WebFindOptions; |
| 49 using WebKit::WebInputEvent; | 48 using WebKit::WebInputEvent; |
| 50 | 49 |
| 51 namespace { | 50 namespace { |
| 52 | 51 |
| 53 void FilterURL(ChildProcessSecurityPolicy* policy, int renderer_id, GURL* url) { | 52 void FilterURL(ChildProcessSecurityPolicy* policy, int renderer_id, GURL* url) { |
| 54 if (!url->is_valid()) | 53 if (!url->is_valid()) |
| 55 return; // We don't need to block invalid URLs. | 54 return; // We don't need to block invalid URLs. |
| (...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 routing_id(), | 562 routing_id(), |
| 564 gfx::Point(client_x, client_y), | 563 gfx::Point(client_x, client_y), |
| 565 gfx::Point(screen_x, screen_y), | 564 gfx::Point(screen_x, screen_y), |
| 566 false)); | 565 false)); |
| 567 } | 566 } |
| 568 | 567 |
| 569 void RenderViewHost::DragSourceSystemDragEnded() { | 568 void RenderViewHost::DragSourceSystemDragEnded() { |
| 570 Send(new ViewMsg_DragSourceSystemDragEnded(routing_id())); | 569 Send(new ViewMsg_DragSourceSystemDragEnded(routing_id())); |
| 571 } | 570 } |
| 572 | 571 |
| 573 void RenderViewHost::AllowDomAutomationBindings() { | 572 void RenderViewHost::AllowBindings(int bindings_flags) { |
| 574 DCHECK(!renderer_initialized_); | 573 DCHECK(!renderer_initialized_); |
| 575 enabled_bindings_ |= BindingsPolicy::DOM_AUTOMATION; | 574 enabled_bindings_ |= bindings_flags; |
| 576 } | |
| 577 | |
| 578 void RenderViewHost::AllowExternalHostBindings() { | |
| 579 DCHECK(!renderer_initialized_); | |
| 580 enabled_bindings_ |= BindingsPolicy::EXTERNAL_HOST; | |
| 581 } | |
| 582 | |
| 583 void RenderViewHost::AllowDOMUIBindings() { | |
| 584 DCHECK(!renderer_initialized_); | |
| 585 enabled_bindings_ |= BindingsPolicy::DOM_UI; | |
| 586 } | |
| 587 | |
| 588 void RenderViewHost::AllowExtensionBindings() { | |
| 589 DCHECK(!renderer_initialized_); | |
| 590 enabled_bindings_ |= BindingsPolicy::EXTENSION; | |
| 591 } | 575 } |
| 592 | 576 |
| 593 void RenderViewHost::SetDOMUIProperty(const std::string& name, | 577 void RenderViewHost::SetDOMUIProperty(const std::string& name, |
| 594 const std::string& value) { | 578 const std::string& value) { |
| 595 DCHECK(BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)); | 579 DCHECK(BindingsPolicy::is_dom_ui_enabled(enabled_bindings_)); |
| 596 Send(new ViewMsg_SetDOMUIProperty(routing_id(), name, value)); | 580 Send(new ViewMsg_SetDOMUIProperty(routing_id(), name, value)); |
| 597 } | 581 } |
| 598 | 582 |
| 599 void RenderViewHost::GotFocus() { | 583 void RenderViewHost::GotFocus() { |
| 600 RenderWidgetHost::GotFocus(); // Notifies the renderer it got focus. | 584 RenderWidgetHost::GotFocus(); // Notifies the renderer it got focus. |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 FilterURL(policy, renderer_id, &validated_params.url); | 860 FilterURL(policy, renderer_id, &validated_params.url); |
| 877 FilterURL(policy, renderer_id, &validated_params.referrer); | 861 FilterURL(policy, renderer_id, &validated_params.referrer); |
| 878 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); | 862 for (std::vector<GURL>::iterator it(validated_params.redirects.begin()); |
| 879 it != validated_params.redirects.end(); ++it) { | 863 it != validated_params.redirects.end(); ++it) { |
| 880 FilterURL(policy, renderer_id, &(*it)); | 864 FilterURL(policy, renderer_id, &(*it)); |
| 881 } | 865 } |
| 882 FilterURL(policy, renderer_id, &validated_params.searchable_form_url); | 866 FilterURL(policy, renderer_id, &validated_params.searchable_form_url); |
| 883 FilterURL(policy, renderer_id, &validated_params.password_form.origin); | 867 FilterURL(policy, renderer_id, &validated_params.password_form.origin); |
| 884 FilterURL(policy, renderer_id, &validated_params.password_form.action); | 868 FilterURL(policy, renderer_id, &validated_params.password_form.action); |
| 885 | 869 |
| 886 if (PageTransition::IsMainFrame(validated_params.transition)) { | |
| 887 ExtensionFunctionDispatcher* new_efd = NULL; | |
| 888 if (validated_params.url.SchemeIs(chrome::kExtensionScheme)) { | |
| 889 new_efd = delegate()->CreateExtensionFunctionDispatcher(this, | |
| 890 validated_params.url.host()); | |
| 891 } | |
| 892 extension_function_dispatcher_.reset(new_efd); | |
| 893 } | |
| 894 | |
| 895 delegate_->DidNavigate(this, validated_params); | 870 delegate_->DidNavigate(this, validated_params); |
| 896 | 871 |
| 897 UpdateBackForwardListCount(); | 872 UpdateBackForwardListCount(); |
| 898 } | 873 } |
| 899 | 874 |
| 900 void RenderViewHost::OnMsgUpdateState(int32 page_id, | 875 void RenderViewHost::OnMsgUpdateState(int32 page_id, |
| 901 const std::string& state) { | 876 const std::string& state) { |
| 902 delegate_->UpdateState(this, page_id, state); | 877 delegate_->UpdateState(this, page_id, state); |
| 903 } | 878 } |
| 904 | 879 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1064 delegate_->DomOperationResponse(json_string, automation_id); | 1039 delegate_->DomOperationResponse(json_string, automation_id); |
| 1065 } | 1040 } |
| 1066 | 1041 |
| 1067 void RenderViewHost::OnMsgDOMUISend( | 1042 void RenderViewHost::OnMsgDOMUISend( |
| 1068 const std::string& message, const std::string& content) { | 1043 const std::string& message, const std::string& content) { |
| 1069 if (!ChildProcessSecurityPolicy::GetInstance()-> | 1044 if (!ChildProcessSecurityPolicy::GetInstance()-> |
| 1070 HasDOMUIBindings(process()->pid())) { | 1045 HasDOMUIBindings(process()->pid())) { |
| 1071 NOTREACHED() << "Blocked unauthorized use of DOMUIBindings."; | 1046 NOTREACHED() << "Blocked unauthorized use of DOMUIBindings."; |
| 1072 return; | 1047 return; |
| 1073 } | 1048 } |
| 1074 delegate_->ProcessDOMUIMessage(message, content); | 1049 |
| 1050 // DOMUI doesn't use these values yet. |
| 1051 // TODO(aa): When DOMUI is ported to ExtensionFunctionDispatcher, send real |
| 1052 // values here. |
| 1053 const int kRequestId = -1; |
| 1054 const bool kHasCallback = false; |
| 1055 |
| 1056 delegate_->ProcessDOMUIMessage(message, content, kRequestId, kHasCallback); |
| 1075 } | 1057 } |
| 1076 | 1058 |
| 1077 void RenderViewHost::OnMsgForwardMessageToExternalHost( | 1059 void RenderViewHost::OnMsgForwardMessageToExternalHost( |
| 1078 const std::string& message, const std::string& origin, | 1060 const std::string& message, const std::string& origin, |
| 1079 const std::string& target) { | 1061 const std::string& target) { |
| 1080 delegate_->ProcessExternalHostMessage(message, origin, target); | 1062 delegate_->ProcessExternalHostMessage(message, origin, target); |
| 1081 } | 1063 } |
| 1082 | 1064 |
| 1083 void RenderViewHost::OnMsgDocumentLoadedInFrame() { | 1065 void RenderViewHost::OnMsgDocumentLoadedInFrame() { |
| 1084 delegate_->DocumentLoadedInFrame(); | 1066 delegate_->DocumentLoadedInFrame(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 modal_dialog_event_->Signal(); | 1130 modal_dialog_event_->Signal(); |
| 1149 delegate_->ShowModalHTMLDialog(url, width, height, json_arguments, reply_msg); | 1131 delegate_->ShowModalHTMLDialog(url, width, height, json_arguments, reply_msg); |
| 1150 } | 1132 } |
| 1151 | 1133 |
| 1152 void RenderViewHost::OnMsgPasswordFormsSeen( | 1134 void RenderViewHost::OnMsgPasswordFormsSeen( |
| 1153 const std::vector<webkit_glue::PasswordForm>& forms) { | 1135 const std::vector<webkit_glue::PasswordForm>& forms) { |
| 1154 delegate_->PasswordFormsSeen(forms); | 1136 delegate_->PasswordFormsSeen(forms); |
| 1155 } | 1137 } |
| 1156 | 1138 |
| 1157 void RenderViewHost::OnMsgAutofillFormSubmitted( | 1139 void RenderViewHost::OnMsgAutofillFormSubmitted( |
| 1158 const AutofillForm& form) { | 1140 const webkit_glue::AutofillForm& form) { |
| 1159 delegate_->AutofillFormSubmitted(form); | 1141 delegate_->AutofillFormSubmitted(form); |
| 1160 } | 1142 } |
| 1161 | 1143 |
| 1162 void RenderViewHost::OnMsgStartDragging( | 1144 void RenderViewHost::OnMsgStartDragging( |
| 1163 const WebDropData& drop_data) { | 1145 const WebDropData& drop_data) { |
| 1164 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1146 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 1165 if (view) | 1147 if (view) |
| 1166 view->StartDragging(drop_data); | 1148 view->StartDragging(drop_data); |
| 1167 } | 1149 } |
| 1168 | 1150 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 void RenderViewHost::OnExtensionRequest(const std::string& name, | 1343 void RenderViewHost::OnExtensionRequest(const std::string& name, |
| 1362 const std::string& args, | 1344 const std::string& args, |
| 1363 int request_id, | 1345 int request_id, |
| 1364 bool has_callback) { | 1346 bool has_callback) { |
| 1365 if (!ChildProcessSecurityPolicy::GetInstance()-> | 1347 if (!ChildProcessSecurityPolicy::GetInstance()-> |
| 1366 HasExtensionBindings(process()->pid())) { | 1348 HasExtensionBindings(process()->pid())) { |
| 1367 NOTREACHED() << "Blocked unauthorized use of extension bindings."; | 1349 NOTREACHED() << "Blocked unauthorized use of extension bindings."; |
| 1368 return; | 1350 return; |
| 1369 } | 1351 } |
| 1370 | 1352 |
| 1371 DCHECK(extension_function_dispatcher_.get()); | 1353 delegate_->ProcessDOMUIMessage(name, args, request_id, has_callback); |
| 1372 extension_function_dispatcher_->HandleRequest(name, args, request_id, | |
| 1373 has_callback); | |
| 1374 } | 1354 } |
| 1375 | 1355 |
| 1376 void RenderViewHost::SendExtensionResponse(int request_id, bool success, | 1356 void RenderViewHost::SendExtensionResponse(int request_id, bool success, |
| 1377 const std::string& response, | 1357 const std::string& response, |
| 1378 const std::string& error) { | 1358 const std::string& error) { |
| 1379 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success, | 1359 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success, |
| 1380 response, error)); | 1360 response, error)); |
| 1381 } | 1361 } |
| 1382 | 1362 |
| 1383 void RenderViewHost::OnExtensionPostMessage( | 1363 void RenderViewHost::OnExtensionPostMessage( |
| 1384 int port_id, const std::string& message) { | 1364 int port_id, const std::string& message) { |
| 1385 URLRequestContext* context = process()->profile()->GetRequestContext(); | 1365 URLRequestContext* context = process()->profile()->GetRequestContext(); |
| 1386 ExtensionMessageService::GetInstance(context)-> | 1366 ExtensionMessageService::GetInstance(context)-> |
| 1387 PostMessageFromRenderer(port_id, message); | 1367 PostMessageFromRenderer(port_id, message); |
| 1388 } | 1368 } |
| 1389 | 1369 |
| 1390 void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) { | 1370 void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) { |
| 1391 #if defined(OS_WIN) | 1371 #if defined(OS_WIN) |
| 1392 BrowserAccessibilityManager::GetInstance()-> | 1372 BrowserAccessibilityManager::GetInstance()-> |
| 1393 ChangeAccessibilityFocus(acc_obj_id, process()->pid(), routing_id()); | 1373 ChangeAccessibilityFocus(acc_obj_id, process()->pid(), routing_id()); |
| 1394 #else | 1374 #else |
| 1395 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. | 1375 // TODO(port): accessibility not yet implemented. See http://crbug.com/8288. |
| 1396 #endif | 1376 #endif |
| 1397 } | 1377 } |
| 1398 | 1378 |
| 1399 void RenderViewHost::OnCSSInserted() { | 1379 void RenderViewHost::OnCSSInserted() { |
| 1400 delegate_->DidInsertCSS(); | 1380 delegate_->DidInsertCSS(); |
| 1401 } | 1381 } |
| OLD | NEW |