OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer_host/render_view_host.h" | 5 #include "content/browser/renderer_host/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "chrome/common/bindings_policy.h" | 22 #include "chrome/common/bindings_policy.h" |
23 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
24 #include "chrome/common/chrome_switches.h" | 24 #include "chrome/common/chrome_switches.h" |
25 #include "chrome/common/extensions/extension_messages.h" | 25 #include "chrome/common/extensions/extension_messages.h" |
26 #include "chrome/common/print_messages.h" | 26 #include "chrome/common/print_messages.h" |
27 #include "chrome/common/render_messages.h" | 27 #include "chrome/common/render_messages.h" |
28 #include "chrome/common/safebrowsing_messages.h" | 28 #include "chrome/common/safebrowsing_messages.h" |
29 #include "chrome/common/spellcheck_messages.h" | 29 #include "chrome/common/spellcheck_messages.h" |
30 #include "chrome/common/translate_errors.h" | 30 #include "chrome/common/translate_errors.h" |
31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
32 #include "chrome/common/web_apps.h" | |
33 #include "content/browser/child_process_security_policy.h" | 32 #include "content/browser/child_process_security_policy.h" |
34 #include "content/browser/cross_site_request_manager.h" | 33 #include "content/browser/cross_site_request_manager.h" |
35 #include "content/browser/in_process_webkit/session_storage_namespace.h" | 34 #include "content/browser/in_process_webkit/session_storage_namespace.h" |
36 #include "content/browser/renderer_host/render_process_host.h" | 35 #include "content/browser/renderer_host/render_process_host.h" |
37 #include "content/browser/renderer_host/render_view_host_delegate.h" | 36 #include "content/browser/renderer_host/render_view_host_delegate.h" |
38 #include "content/browser/renderer_host/render_widget_host.h" | 37 #include "content/browser/renderer_host/render_widget_host.h" |
39 #include "content/browser/renderer_host/render_widget_host_view.h" | 38 #include "content/browser/renderer_host/render_widget_host_view.h" |
40 #include "content/browser/site_instance.h" | 39 #include "content/browser/site_instance.h" |
41 #include "content/common/drag_messages.h" | 40 #include "content/common/drag_messages.h" |
42 #include "content/common/native_web_keyboard_event.h" | 41 #include "content/common/native_web_keyboard_event.h" |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 if (!url.is_valid()) { | 553 if (!url.is_valid()) { |
555 NOTREACHED(); | 554 NOTREACHED(); |
556 return 0; | 555 return 0; |
557 } | 556 } |
558 static int next_id = 1; | 557 static int next_id = 1; |
559 int id = next_id++; | 558 int id = next_id++; |
560 Send(new ViewMsg_DownloadFavicon(routing_id(), id, url, image_size)); | 559 Send(new ViewMsg_DownloadFavicon(routing_id(), id, url, image_size)); |
561 return id; | 560 return id; |
562 } | 561 } |
563 | 562 |
564 void RenderViewHost::GetApplicationInfo(int32 page_id) { | |
565 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); | |
566 } | |
567 | |
568 void RenderViewHost::CaptureSnapshot() { | 563 void RenderViewHost::CaptureSnapshot() { |
569 Send(new ViewMsg_CaptureSnapshot(routing_id())); | 564 Send(new ViewMsg_CaptureSnapshot(routing_id())); |
570 } | 565 } |
571 | 566 |
572 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, | 567 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, |
573 bool success, | 568 bool success, |
574 const std::wstring& prompt) { | 569 const std::wstring& prompt) { |
575 process()->set_ignore_input_events(false); | 570 process()->set_ignore_input_events(false); |
576 bool is_waiting = | 571 bool is_waiting = |
577 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; | 572 is_waiting_for_beforeunload_ack_ || is_waiting_for_unload_ack_; |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) | 736 IPC_MESSAGE_HANDLER(ViewHostMsg_Close, OnMsgClose) |
742 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) | 737 IPC_MESSAGE_HANDLER(ViewHostMsg_RequestMove, OnMsgRequestMove) |
743 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartLoading, OnMsgDidStartLoading) | 738 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStartLoading, OnMsgDidStartLoading) |
744 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopLoading, OnMsgDidStopLoading) | 739 IPC_MESSAGE_HANDLER(ViewHostMsg_DidStopLoading, OnMsgDidStopLoading) |
745 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, | 740 IPC_MESSAGE_HANDLER(ViewHostMsg_DidChangeLoadProgress, |
746 OnMsgDidChangeLoadProgress) | 741 OnMsgDidChangeLoadProgress) |
747 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, | 742 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentAvailableInMainFrame, |
748 OnMsgDocumentAvailableInMainFrame) | 743 OnMsgDocumentAvailableInMainFrame) |
749 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentOnLoadCompletedInMainFrame, | 744 IPC_MESSAGE_HANDLER(ViewHostMsg_DocumentOnLoadCompletedInMainFrame, |
750 OnMsgDocumentOnLoadCompletedInMainFrame) | 745 OnMsgDocumentOnLoadCompletedInMainFrame) |
751 IPC_MESSAGE_HANDLER(ViewHostMsg_ExecuteCodeFinished, | |
752 OnExecuteCodeFinished) | |
753 IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) | 746 IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu) |
754 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) | 747 IPC_MESSAGE_HANDLER(ViewHostMsg_OpenURL, OnMsgOpenURL) |
755 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, | 748 IPC_MESSAGE_HANDLER(ViewHostMsg_DidContentsPreferredSizeChange, |
756 OnMsgDidContentsPreferredSizeChange) | 749 OnMsgDidContentsPreferredSizeChange) |
757 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, | 750 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, |
758 OnMsgDomOperationResponse) | 751 OnMsgDomOperationResponse) |
759 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnMsgWebUISend) | 752 IPC_MESSAGE_HANDLER(ViewHostMsg_WebUISend, OnMsgWebUISend) |
760 IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardMessageToExternalHost, | 753 IPC_MESSAGE_HANDLER(ViewHostMsg_ForwardMessageToExternalHost, |
761 OnMsgForwardMessageToExternalHost) | 754 OnMsgForwardMessageToExternalHost) |
762 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) | 755 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) |
763 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, | 756 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, |
764 OnMsgRunJavaScriptMessage) | 757 OnMsgRunJavaScriptMessage) |
765 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, | 758 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, |
766 OnMsgRunBeforeUnloadConfirm) | 759 OnMsgRunBeforeUnloadConfirm) |
767 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) | 760 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) |
768 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 761 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
769 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 762 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
770 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 763 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
771 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) | 764 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) |
772 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnExtensionRequest) | |
773 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) | 765 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) |
774 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, | 766 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, |
775 OnAccessibilityNotifications) | 767 OnAccessibilityNotifications) |
776 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) | 768 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) |
777 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) | 769 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) |
778 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 770 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
779 IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) | 771 IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) |
780 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) | 772 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) |
781 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 773 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
782 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 774 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 } | 1016 } |
1025 | 1017 |
1026 void RenderViewHost::OnMsgDocumentAvailableInMainFrame() { | 1018 void RenderViewHost::OnMsgDocumentAvailableInMainFrame() { |
1027 delegate_->DocumentAvailableInMainFrame(this); | 1019 delegate_->DocumentAvailableInMainFrame(this); |
1028 } | 1020 } |
1029 | 1021 |
1030 void RenderViewHost::OnMsgDocumentOnLoadCompletedInMainFrame(int32 page_id) { | 1022 void RenderViewHost::OnMsgDocumentOnLoadCompletedInMainFrame(int32 page_id) { |
1031 delegate_->DocumentOnLoadCompletedInMainFrame(this, page_id); | 1023 delegate_->DocumentOnLoadCompletedInMainFrame(this, page_id); |
1032 } | 1024 } |
1033 | 1025 |
1034 void RenderViewHost::OnExecuteCodeFinished(int request_id, bool success) { | |
1035 std::pair<int, bool> result_details(request_id, success); | |
1036 NotificationService::current()->Notify( | |
1037 NotificationType::TAB_CODE_EXECUTED, | |
1038 NotificationService::AllSources(), | |
1039 Details<std::pair<int, bool> >(&result_details)); | |
1040 } | |
1041 | |
1042 void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) { | 1026 void RenderViewHost::OnMsgContextMenu(const ContextMenuParams& params) { |
1043 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 1027 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
1044 if (!view) | 1028 if (!view) |
1045 return; | 1029 return; |
1046 | 1030 |
1047 // Validate the URLs in |params|. If the renderer can't request the URLs | 1031 // Validate the URLs in |params|. If the renderer can't request the URLs |
1048 // directly, don't show them in the context menu. | 1032 // directly, don't show them in the context menu. |
1049 ContextMenuParams validated_params(params); | 1033 ContextMenuParams validated_params(params); |
1050 int renderer_id = process()->id(); | 1034 int renderer_id = process()->id(); |
1051 ChildProcessSecurityPolicy* policy = | 1035 ChildProcessSecurityPolicy* policy = |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1382 Send(new ViewMsg_SetEditCommandsForNextKeyEvent(routing_id(), edit_commands)); | 1366 Send(new ViewMsg_SetEditCommandsForNextKeyEvent(routing_id(), edit_commands)); |
1383 } | 1367 } |
1384 | 1368 |
1385 void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message, | 1369 void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message, |
1386 const std::string& origin, | 1370 const std::string& origin, |
1387 const std::string& target) { | 1371 const std::string& target) { |
1388 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), message, origin, | 1372 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), message, origin, |
1389 target)); | 1373 target)); |
1390 } | 1374 } |
1391 | 1375 |
1392 void RenderViewHost::OnExtensionRequest( | |
1393 const ExtensionHostMsg_DomMessage_Params& params) { | |
1394 if (!ChildProcessSecurityPolicy::GetInstance()-> | |
1395 HasExtensionBindings(process()->id())) { | |
1396 // This can happen if someone uses window.open() to open an extension URL | |
1397 // from a non-extension context. | |
1398 BlockExtensionRequest(params.request_id); | |
1399 return; | |
1400 } | |
1401 | |
1402 delegate_->ProcessWebUIMessage(params); | |
1403 } | |
1404 | |
1405 void RenderViewHost::SendExtensionResponse(int request_id, bool success, | |
1406 const std::string& response, | |
1407 const std::string& error) { | |
1408 Send(new ExtensionMsg_Response( | |
1409 routing_id(), request_id, success, response, error)); | |
1410 } | |
1411 | |
1412 void RenderViewHost::BlockExtensionRequest(int request_id) { | |
1413 SendExtensionResponse(request_id, false, "", | |
1414 "Access to extension API denied."); | |
1415 } | |
1416 | |
1417 void RenderViewHost::UpdateBrowserWindowId(int window_id) { | 1376 void RenderViewHost::UpdateBrowserWindowId(int window_id) { |
1418 Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id)); | 1377 Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id)); |
1419 } | 1378 } |
1420 | 1379 |
1421 void RenderViewHost::PerformCustomContextMenuAction( | 1380 void RenderViewHost::PerformCustomContextMenuAction( |
1422 const webkit_glue::CustomContextMenuContext& custom_context, | 1381 const webkit_glue::CustomContextMenuContext& custom_context, |
1423 unsigned action) { | 1382 unsigned action) { |
1424 Send(new ViewMsg_CustomContextMenuAction(routing_id(), | 1383 Send(new ViewMsg_CustomContextMenuAction(routing_id(), |
1425 custom_context, | 1384 custom_context, |
1426 action)); | 1385 action)); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1611 LOG(DFATAL) << "Invalid checked state " << checked_state; | 1570 LOG(DFATAL) << "Invalid checked state " << checked_state; |
1612 return; | 1571 return; |
1613 } | 1572 } |
1614 | 1573 |
1615 CommandState state; | 1574 CommandState state; |
1616 state.is_enabled = is_enabled; | 1575 state.is_enabled = is_enabled; |
1617 state.checked_state = | 1576 state.checked_state = |
1618 static_cast<RenderViewCommandCheckedState>(checked_state); | 1577 static_cast<RenderViewCommandCheckedState>(checked_state); |
1619 command_states_[static_cast<RenderViewCommand>(command)] = state; | 1578 command_states_[static_cast<RenderViewCommand>(command)] = state; |
1620 } | 1579 } |
OLD | NEW |