| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 1005 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 push_messaging_dispatcher_(NULL), | 1016 push_messaging_dispatcher_(NULL), |
| 1017 presentation_dispatcher_(NULL), | 1017 presentation_dispatcher_(NULL), |
| 1018 blink_service_registry_(service_registry_.GetWeakPtr()), | 1018 blink_service_registry_(service_registry_.GetWeakPtr()), |
| 1019 screen_orientation_dispatcher_(NULL), | 1019 screen_orientation_dispatcher_(NULL), |
| 1020 manifest_manager_(NULL), | 1020 manifest_manager_(NULL), |
| 1021 accessibility_mode_(AccessibilityModeOff), | 1021 accessibility_mode_(AccessibilityModeOff), |
| 1022 renderer_accessibility_(NULL), | 1022 renderer_accessibility_(NULL), |
| 1023 media_player_delegate_(NULL), | 1023 media_player_delegate_(NULL), |
| 1024 is_using_lofi_(false), | 1024 is_using_lofi_(false), |
| 1025 is_pasting_(false), | 1025 is_pasting_(false), |
| 1026 suppress_further_dialogs_(false), |
| 1026 blame_context_(nullptr), | 1027 blame_context_(nullptr), |
| 1027 weak_factory_(this) { | 1028 weak_factory_(this) { |
| 1028 std::pair<RoutingIDFrameMap::iterator, bool> result = | 1029 std::pair<RoutingIDFrameMap::iterator, bool> result = |
| 1029 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 1030 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
| 1030 CHECK(result.second) << "Inserting a duplicate item."; | 1031 CHECK(result.second) << "Inserting a duplicate item."; |
| 1031 | 1032 |
| 1032 RenderThread::Get()->AddRoute(routing_id_, this); | 1033 RenderThread::Get()->AddRoute(routing_id_, this); |
| 1033 | 1034 |
| 1034 render_view_->RegisterRenderFrame(this); | 1035 render_view_->RegisterRenderFrame(this); |
| 1035 | 1036 |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1431 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) | 1432 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) |
| 1432 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) | 1433 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) |
| 1433 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks, | 1434 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks, |
| 1434 OnGetSavableResourceLinks) | 1435 OnGetSavableResourceLinks) |
| 1435 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks, | 1436 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks, |
| 1436 OnGetSerializedHtmlWithLocalLinks) | 1437 OnGetSerializedHtmlWithLocalLinks) |
| 1437 IPC_MESSAGE_HANDLER(FrameMsg_SerializeAsMHTML, OnSerializeAsMHTML) | 1438 IPC_MESSAGE_HANDLER(FrameMsg_SerializeAsMHTML, OnSerializeAsMHTML) |
| 1438 IPC_MESSAGE_HANDLER(FrameMsg_Find, OnFind) | 1439 IPC_MESSAGE_HANDLER(FrameMsg_Find, OnFind) |
| 1439 IPC_MESSAGE_HANDLER(FrameMsg_StopFinding, OnStopFinding) | 1440 IPC_MESSAGE_HANDLER(FrameMsg_StopFinding, OnStopFinding) |
| 1440 IPC_MESSAGE_HANDLER(FrameMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1441 IPC_MESSAGE_HANDLER(FrameMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 1442 IPC_MESSAGE_HANDLER(FrameMsg_SuppressFurtherDialogs, |
| 1443 OnSuppressFurtherDialogs) |
| 1441 #if defined(OS_ANDROID) | 1444 #if defined(OS_ANDROID) |
| 1442 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | 1445 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
| 1443 OnActivateNearestFindResult) | 1446 OnActivateNearestFindResult) |
| 1444 IPC_MESSAGE_HANDLER(FrameMsg_FindMatchRects, OnFindMatchRects) | 1447 IPC_MESSAGE_HANDLER(FrameMsg_FindMatchRects, OnFindMatchRects) |
| 1445 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) | 1448 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) |
| 1446 #elif defined(OS_MACOSX) | 1449 #elif defined(OS_MACOSX) |
| 1447 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 1450 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
| 1448 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) | 1451 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) |
| 1449 #endif | 1452 #endif |
| 1450 IPC_END_MESSAGE_MAP() | 1453 IPC_END_MESSAGE_MAP() |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1562 proxy->web_frame()->initializeFromFrame(frame_); | 1565 proxy->web_frame()->initializeFromFrame(frame_); |
| 1563 | 1566 |
| 1564 // Let WebKit know that this view is hidden so it can drop resources and | 1567 // Let WebKit know that this view is hidden so it can drop resources and |
| 1565 // stop compositing. | 1568 // stop compositing. |
| 1566 // TODO(creis): Support this for subframes as well. | 1569 // TODO(creis): Support this for subframes as well. |
| 1567 if (is_main_frame_) { | 1570 if (is_main_frame_) { |
| 1568 render_view_->webview()->setVisibilityState( | 1571 render_view_->webview()->setVisibilityState( |
| 1569 blink::WebPageVisibilityStateHidden, false); | 1572 blink::WebPageVisibilityStateHidden, false); |
| 1570 } | 1573 } |
| 1571 | 1574 |
| 1572 // It is now safe to show modal dialogs again. | |
| 1573 // TODO(creis): Deal with modal dialogs from subframes. | |
| 1574 if (is_main_frame_) | |
| 1575 render_view_->suppress_dialogs_until_swap_out_ = false; | |
| 1576 | |
| 1577 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); | 1575 Send(new FrameHostMsg_SwapOut_ACK(routing_id_)); |
| 1578 | 1576 |
| 1579 RenderViewImpl* render_view = render_view_.get(); | 1577 RenderViewImpl* render_view = render_view_.get(); |
| 1580 bool is_main_frame = is_main_frame_; | 1578 bool is_main_frame = is_main_frame_; |
| 1581 int routing_id = GetRoutingID(); | 1579 int routing_id = GetRoutingID(); |
| 1582 | 1580 |
| 1583 // Now that all of the cleanup is complete and the browser side is notified, | 1581 // Now that all of the cleanup is complete and the browser side is notified, |
| 1584 // start using the RenderFrameProxy, if one is created. | 1582 // start using the RenderFrameProxy, if one is created. |
| 1585 if (proxy) { | 1583 if (proxy) { |
| 1586 // The swap call deletes this RenderFrame via frameDetached. Do not access | 1584 // The swap call deletes this RenderFrame via frameDetached. Do not access |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2138 message->EnableMessagePumping(); // Runs a nested message loop. | 2136 message->EnableMessagePumping(); // Runs a nested message loop. |
| 2139 return Send(message); | 2137 return Send(message); |
| 2140 } | 2138 } |
| 2141 | 2139 |
| 2142 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, | 2140 bool RenderFrameImpl::RunJavaScriptMessage(JavaScriptMessageType type, |
| 2143 const base::string16& message, | 2141 const base::string16& message, |
| 2144 const base::string16& default_value, | 2142 const base::string16& default_value, |
| 2145 const GURL& frame_url, | 2143 const GURL& frame_url, |
| 2146 base::string16* result) { | 2144 base::string16* result) { |
| 2147 // Don't allow further dialogs if we are waiting to swap out, since the | 2145 // Don't allow further dialogs if we are waiting to swap out, since the |
| 2148 // PageGroupLoadDeferrer in our stack prevents it. | 2146 // ScopedPageLoadDeferrer in our stack prevents it. |
| 2149 if (render_view()->suppress_dialogs_until_swap_out_) | 2147 if (suppress_further_dialogs_) |
| 2150 return false; | 2148 return false; |
| 2151 | 2149 |
| 2152 bool success = false; | 2150 bool success = false; |
| 2153 base::string16 result_temp; | 2151 base::string16 result_temp; |
| 2154 if (!result) | 2152 if (!result) |
| 2155 result = &result_temp; | 2153 result = &result_temp; |
| 2156 | 2154 |
| 2157 SendAndRunNestedMessageLoop(new FrameHostMsg_RunJavaScriptMessage( | 2155 SendAndRunNestedMessageLoop(new FrameHostMsg_RunJavaScriptMessage( |
| 2158 routing_id_, message, default_value, frame_url, type, &success, result)); | 2156 routing_id_, message, default_value, frame_url, type, &success, result)); |
| 2159 return success; | 2157 return success; |
| (...skipping 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3602 default_value, | 3600 default_value, |
| 3603 frame_->document().url(), | 3601 frame_->document().url(), |
| 3604 &result); | 3602 &result); |
| 3605 if (ok) | 3603 if (ok) |
| 3606 actual_value->assign(result); | 3604 actual_value->assign(result); |
| 3607 return ok; | 3605 return ok; |
| 3608 } | 3606 } |
| 3609 | 3607 |
| 3610 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { | 3608 bool RenderFrameImpl::runModalBeforeUnloadDialog(bool is_reload) { |
| 3611 // Don't allow further dialogs if we are waiting to swap out, since the | 3609 // Don't allow further dialogs if we are waiting to swap out, since the |
| 3612 // PageGroupLoadDeferrer in our stack prevents it. | 3610 // ScopedPageLoadDeferrer in our stack prevents it. |
| 3613 if (render_view()->suppress_dialogs_until_swap_out_) | 3611 if (suppress_further_dialogs_) |
| 3614 return false; | 3612 return false; |
| 3615 | 3613 |
| 3616 bool success = false; | 3614 bool success = false; |
| 3617 // This is an ignored return value, but is included so we can accept the same | 3615 // This is an ignored return value, but is included so we can accept the same |
| 3618 // response as RunJavaScriptMessage. | 3616 // response as RunJavaScriptMessage. |
| 3619 base::string16 ignored_result; | 3617 base::string16 ignored_result; |
| 3620 SendAndRunNestedMessageLoop(new FrameHostMsg_RunBeforeUnloadConfirm( | 3618 SendAndRunNestedMessageLoop(new FrameHostMsg_RunBeforeUnloadConfirm( |
| 3621 routing_id_, frame_->document().url(), is_reload, &success, | 3619 routing_id_, frame_->document().url(), is_reload, &success, |
| 3622 &ignored_result)); | 3620 &ignored_result)); |
| 3623 return success; | 3621 return success; |
| (...skipping 1483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5107 } | 5105 } |
| 5108 } | 5106 } |
| 5109 } | 5107 } |
| 5110 | 5108 |
| 5111 void RenderFrameImpl::OnEnableViewSourceMode() { | 5109 void RenderFrameImpl::OnEnableViewSourceMode() { |
| 5112 DCHECK(frame_); | 5110 DCHECK(frame_); |
| 5113 DCHECK(!frame_->parent()); | 5111 DCHECK(!frame_->parent()); |
| 5114 frame_->enableViewSourceMode(true); | 5112 frame_->enableViewSourceMode(true); |
| 5115 } | 5113 } |
| 5116 | 5114 |
| 5115 void RenderFrameImpl::OnSuppressFurtherDialogs() { |
| 5116 suppress_further_dialogs_ = true; |
| 5117 } |
| 5118 |
| 5117 #if defined(OS_ANDROID) | 5119 #if defined(OS_ANDROID) |
| 5118 void RenderFrameImpl::OnActivateNearestFindResult(int request_id, | 5120 void RenderFrameImpl::OnActivateNearestFindResult(int request_id, |
| 5119 float x, | 5121 float x, |
| 5120 float y) { | 5122 float y) { |
| 5121 WebRect selection_rect; | 5123 WebRect selection_rect; |
| 5122 int ordinal = | 5124 int ordinal = |
| 5123 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect); | 5125 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect); |
| 5124 if (ordinal == -1) { | 5126 if (ordinal == -1) { |
| 5125 // Something went wrong, so send a no-op reply (force the frame to report | 5127 // Something went wrong, so send a no-op reply (force the frame to report |
| 5126 // the current match count) in case the host is waiting for a response due | 5128 // the current match count) in case the host is waiting for a response due |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6027 int match_count, | 6029 int match_count, |
| 6028 int ordinal, | 6030 int ordinal, |
| 6029 const WebRect& selection_rect, | 6031 const WebRect& selection_rect, |
| 6030 bool final_status_update) { | 6032 bool final_status_update) { |
| 6031 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6033 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6032 selection_rect, ordinal, | 6034 selection_rect, ordinal, |
| 6033 final_status_update)); | 6035 final_status_update)); |
| 6034 } | 6036 } |
| 6035 | 6037 |
| 6036 } // namespace content | 6038 } // namespace content |
| OLD | NEW |