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 |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/json/json_reader.h" | 13 #include "base/json/json_reader.h" |
14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
15 #include "base/time.h" | 15 #include "base/time.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/dom_operation_notification_details.h" | 18 #include "chrome/browser/dom_operation_notification_details.h" |
19 #include "chrome/browser/extensions/extension_message_service.h" | 19 #include "chrome/browser/extensions/extension_message_service.h" |
20 #include "chrome/browser/metrics/user_metrics.h" | 20 #include "chrome/browser/metrics/user_metrics.h" |
21 #include "chrome/browser/net/predictor_api.h" | 21 #include "chrome/browser/net/predictor_api.h" |
22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
23 #include "chrome/common/bindings_policy.h" | 23 #include "chrome/common/bindings_policy.h" |
24 #include "chrome/common/chrome_constants.h" | 24 #include "chrome/common/chrome_constants.h" |
25 #include "chrome/common/chrome_switches.h" | 25 #include "chrome/common/chrome_switches.h" |
| 26 #include "chrome/common/extensions/extension_messages.h" |
26 #include "chrome/common/net/url_request_context_getter.h" | 27 #include "chrome/common/net/url_request_context_getter.h" |
27 #include "chrome/common/render_messages.h" | 28 #include "chrome/common/render_messages.h" |
28 #include "chrome/common/print_messages.h" | 29 #include "chrome/common/print_messages.h" |
29 #include "chrome/common/safebrowsing_messages.h" | 30 #include "chrome/common/safebrowsing_messages.h" |
30 #include "chrome/common/spellcheck_messages.h" | 31 #include "chrome/common/spellcheck_messages.h" |
31 #include "chrome/common/translate_errors.h" | 32 #include "chrome/common/translate_errors.h" |
32 #include "chrome/common/url_constants.h" | 33 #include "chrome/common/url_constants.h" |
33 #include "chrome/common/web_apps.h" | 34 #include "chrome/common/web_apps.h" |
34 #include "content/browser/child_process_security_policy.h" | 35 #include "content/browser/child_process_security_policy.h" |
35 #include "content/browser/cross_site_request_manager.h" | 36 #include "content/browser/cross_site_request_manager.h" |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 NOTREACHED(); | 559 NOTREACHED(); |
559 return 0; | 560 return 0; |
560 } | 561 } |
561 static int next_id = 1; | 562 static int next_id = 1; |
562 int id = next_id++; | 563 int id = next_id++; |
563 Send(new ViewMsg_DownloadFavicon(routing_id(), id, url, image_size)); | 564 Send(new ViewMsg_DownloadFavicon(routing_id(), id, url, image_size)); |
564 return id; | 565 return id; |
565 } | 566 } |
566 | 567 |
567 void RenderViewHost::GetApplicationInfo(int32 page_id) { | 568 void RenderViewHost::GetApplicationInfo(int32 page_id) { |
568 Send(new ViewMsg_GetApplicationInfo(routing_id(), page_id)); | 569 Send(new ExtensionMsg_GetApplicationInfo(routing_id(), page_id)); |
569 } | 570 } |
570 | 571 |
571 void RenderViewHost::CaptureSnapshot() { | 572 void RenderViewHost::CaptureSnapshot() { |
572 Send(new ViewMsg_CaptureSnapshot(routing_id())); | 573 Send(new ViewMsg_CaptureSnapshot(routing_id())); |
573 } | 574 } |
574 | 575 |
575 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, | 576 void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, |
576 bool success, | 577 bool success, |
577 const std::wstring& prompt) { | 578 const std::wstring& prompt) { |
578 process()->set_ignore_input_events(false); | 579 process()->set_ignore_input_events(false); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) | 766 IPC_MESSAGE_HANDLER(ViewHostMsg_SetTooltipText, OnMsgSetTooltipText) |
766 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, | 767 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunJavaScriptMessage, |
767 OnMsgRunJavaScriptMessage) | 768 OnMsgRunJavaScriptMessage) |
768 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, | 769 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunBeforeUnloadConfirm, |
769 OnMsgRunBeforeUnloadConfirm) | 770 OnMsgRunBeforeUnloadConfirm) |
770 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) | 771 IPC_MESSAGE_HANDLER(DragHostMsg_StartDragging, OnMsgStartDragging) |
771 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 772 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
772 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 773 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
773 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) | 774 IPC_MESSAGE_HANDLER(ViewHostMsg_AddMessageToConsole, OnAddMessageToConsole) |
774 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) | 775 IPC_MESSAGE_HANDLER(ViewHostMsg_ShouldClose_ACK, OnMsgShouldCloseACK) |
775 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionRequest, OnExtensionRequest) | 776 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnExtensionRequest) |
776 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) | 777 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectionChanged, OnMsgSelectionChanged) |
777 IPC_MESSAGE_HANDLER(ViewHostMsg_ExtensionPostMessage, | 778 IPC_MESSAGE_HANDLER(ExtensionHostMsg_PostMessage, OnExtensionPostMessage) |
778 OnExtensionPostMessage) | |
779 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, | 779 IPC_MESSAGE_HANDLER(ViewHostMsg_AccessibilityNotifications, |
780 OnAccessibilityNotifications) | 780 OnAccessibilityNotifications) |
781 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) | 781 IPC_MESSAGE_HANDLER(ViewHostMsg_OnCSSInserted, OnCSSInserted) |
782 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) | 782 IPC_MESSAGE_HANDLER(ViewHostMsg_ContentBlocked, OnContentBlocked) |
783 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) | 783 IPC_MESSAGE_HANDLER(ViewHostMsg_AppCacheAccessed, OnAppCacheAccessed) |
784 IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) | 784 IPC_MESSAGE_HANDLER(ViewHostMsg_WebDatabaseAccessed, OnWebDatabaseAccessed) |
785 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) | 785 IPC_MESSAGE_HANDLER(ViewHostMsg_FocusedNodeChanged, OnMsgFocusedNodeChanged) |
786 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) | 786 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateZoomLimits, OnUpdateZoomLimits) |
787 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 787 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
788 #if defined(OS_MACOSX) | 788 #if defined(OS_MACOSX) |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1108 if (!content.empty()) { | 1108 if (!content.empty()) { |
1109 value.reset(base::JSONReader::Read(content, false)); | 1109 value.reset(base::JSONReader::Read(content, false)); |
1110 if (!value.get() || !value->IsType(Value::TYPE_LIST)) { | 1110 if (!value.get() || !value->IsType(Value::TYPE_LIST)) { |
1111 // The page sent us something that we didn't understand. | 1111 // The page sent us something that we didn't understand. |
1112 // This probably indicates a programming error. | 1112 // This probably indicates a programming error. |
1113 NOTREACHED() << "Invalid JSON argument in OnMsgWebUISend."; | 1113 NOTREACHED() << "Invalid JSON argument in OnMsgWebUISend."; |
1114 return; | 1114 return; |
1115 } | 1115 } |
1116 } | 1116 } |
1117 | 1117 |
1118 ViewHostMsg_DomMessage_Params params; | 1118 ExtensionHostMsg_DomMessage_Params params; |
1119 params.name = message; | 1119 params.name = message; |
1120 if (value.get()) | 1120 if (value.get()) |
1121 params.arguments.Swap(static_cast<ListValue*>(value.get())); | 1121 params.arguments.Swap(static_cast<ListValue*>(value.get())); |
1122 params.source_url = source_url; | 1122 params.source_url = source_url; |
1123 // WebUI doesn't use these values yet. | 1123 // WebUI doesn't use these values yet. |
1124 // TODO(aa): When WebUI is ported to ExtensionFunctionDispatcher, send real | 1124 // TODO(aa): When WebUI is ported to ExtensionFunctionDispatcher, send real |
1125 // values here. | 1125 // values here. |
1126 params.request_id = -1; | 1126 params.request_id = -1; |
1127 params.has_callback = false; | 1127 params.has_callback = false; |
1128 params.user_gesture = false; | 1128 params.user_gesture = false; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 } | 1392 } |
1393 | 1393 |
1394 void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message, | 1394 void RenderViewHost::ForwardMessageFromExternalHost(const std::string& message, |
1395 const std::string& origin, | 1395 const std::string& origin, |
1396 const std::string& target) { | 1396 const std::string& target) { |
1397 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), message, origin, | 1397 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), message, origin, |
1398 target)); | 1398 target)); |
1399 } | 1399 } |
1400 | 1400 |
1401 void RenderViewHost::OnExtensionRequest( | 1401 void RenderViewHost::OnExtensionRequest( |
1402 const ViewHostMsg_DomMessage_Params& params) { | 1402 const ExtensionHostMsg_DomMessage_Params& params) { |
1403 if (!ChildProcessSecurityPolicy::GetInstance()-> | 1403 if (!ChildProcessSecurityPolicy::GetInstance()-> |
1404 HasExtensionBindings(process()->id())) { | 1404 HasExtensionBindings(process()->id())) { |
1405 // This can happen if someone uses window.open() to open an extension URL | 1405 // This can happen if someone uses window.open() to open an extension URL |
1406 // from a non-extension context. | 1406 // from a non-extension context. |
1407 BlockExtensionRequest(params.request_id); | 1407 BlockExtensionRequest(params.request_id); |
1408 return; | 1408 return; |
1409 } | 1409 } |
1410 | 1410 |
1411 delegate_->ProcessWebUIMessage(params); | 1411 delegate_->ProcessWebUIMessage(params); |
1412 } | 1412 } |
1413 | 1413 |
1414 void RenderViewHost::SendExtensionResponse(int request_id, bool success, | 1414 void RenderViewHost::SendExtensionResponse(int request_id, bool success, |
1415 const std::string& response, | 1415 const std::string& response, |
1416 const std::string& error) { | 1416 const std::string& error) { |
1417 Send(new ViewMsg_ExtensionResponse(routing_id(), request_id, success, | 1417 Send(new ExtensionMsg_Response( |
1418 response, error)); | 1418 routing_id(), request_id, success, response, error)); |
1419 } | 1419 } |
1420 | 1420 |
1421 void RenderViewHost::BlockExtensionRequest(int request_id) { | 1421 void RenderViewHost::BlockExtensionRequest(int request_id) { |
1422 SendExtensionResponse(request_id, false, "", | 1422 SendExtensionResponse(request_id, false, "", |
1423 "Access to extension API denied."); | 1423 "Access to extension API denied."); |
1424 } | 1424 } |
1425 | 1425 |
1426 void RenderViewHost::UpdateBrowserWindowId(int window_id) { | 1426 void RenderViewHost::UpdateBrowserWindowId(int window_id) { |
1427 Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id)); | 1427 Send(new ViewMsg_UpdateBrowserWindowId(routing_id(), window_id)); |
1428 } | 1428 } |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1628 LOG(DFATAL) << "Invalid checked state " << checked_state; | 1628 LOG(DFATAL) << "Invalid checked state " << checked_state; |
1629 return; | 1629 return; |
1630 } | 1630 } |
1631 | 1631 |
1632 CommandState state; | 1632 CommandState state; |
1633 state.is_enabled = is_enabled; | 1633 state.is_enabled = is_enabled; |
1634 state.checked_state = | 1634 state.checked_state = |
1635 static_cast<RenderViewCommandCheckedState>(checked_state); | 1635 static_cast<RenderViewCommandCheckedState>(checked_state); |
1636 command_states_[static_cast<RenderViewCommand>(command)] = state; | 1636 command_states_[static_cast<RenderViewCommand>(command)] = state; |
1637 } | 1637 } |
OLD | NEW |