| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 #include "ui/shell_dialogs/selected_file_info.h" | 79 #include "ui/shell_dialogs/selected_file_info.h" |
| 80 #include "webkit/browser/fileapi/isolated_context.h" | 80 #include "webkit/browser/fileapi/isolated_context.h" |
| 81 | 81 |
| 82 #if defined(OS_MACOSX) | 82 #if defined(OS_MACOSX) |
| 83 #include "content/browser/renderer_host/popup_menu_helper_mac.h" | 83 #include "content/browser/renderer_host/popup_menu_helper_mac.h" |
| 84 #elif defined(OS_ANDROID) | 84 #elif defined(OS_ANDROID) |
| 85 #include "content/browser/media/android/browser_media_player_manager.h" | 85 #include "content/browser/media/android/browser_media_player_manager.h" |
| 86 #endif | 86 #endif |
| 87 | 87 |
| 88 using base::TimeDelta; | 88 using base::TimeDelta; |
| 89 using WebKit::WebConsoleMessage; | 89 using blink::WebConsoleMessage; |
| 90 using WebKit::WebDragOperation; | 90 using blink::WebDragOperation; |
| 91 using WebKit::WebDragOperationNone; | 91 using blink::WebDragOperationNone; |
| 92 using WebKit::WebDragOperationsMask; | 92 using blink::WebDragOperationsMask; |
| 93 using WebKit::WebInputEvent; | 93 using blink::WebInputEvent; |
| 94 using WebKit::WebMediaPlayerAction; | 94 using blink::WebMediaPlayerAction; |
| 95 using WebKit::WebPluginAction; | 95 using blink::WebPluginAction; |
| 96 | 96 |
| 97 namespace content { | 97 namespace content { |
| 98 namespace { | 98 namespace { |
| 99 | 99 |
| 100 // Delay to wait on closing the WebContents for a beforeunload/unload handler to | 100 // Delay to wait on closing the WebContents for a beforeunload/unload handler to |
| 101 // fire. | 101 // fire. |
| 102 const int kUnloadTimeoutMS = 1000; | 102 const int kUnloadTimeoutMS = 1000; |
| 103 | 103 |
| 104 // Translate a WebKit text direction into a base::i18n one. | 104 // Translate a WebKit text direction into a base::i18n one. |
| 105 base::i18n::TextDirection WebTextDirectionToChromeTextDirection( | 105 base::i18n::TextDirection WebTextDirectionToChromeTextDirection( |
| 106 WebKit::WebTextDirection dir) { | 106 blink::WebTextDirection dir) { |
| 107 switch (dir) { | 107 switch (dir) { |
| 108 case WebKit::WebTextDirectionLeftToRight: | 108 case blink::WebTextDirectionLeftToRight: |
| 109 return base::i18n::LEFT_TO_RIGHT; | 109 return base::i18n::LEFT_TO_RIGHT; |
| 110 case WebKit::WebTextDirectionRightToLeft: | 110 case blink::WebTextDirectionRightToLeft: |
| 111 return base::i18n::RIGHT_TO_LEFT; | 111 return base::i18n::RIGHT_TO_LEFT; |
| 112 default: | 112 default: |
| 113 NOTREACHED(); | 113 NOTREACHED(); |
| 114 return base::i18n::UNKNOWN_DIRECTION; | 114 return base::i18n::UNKNOWN_DIRECTION; |
| 115 } | 115 } |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| 119 | 119 |
| 120 /////////////////////////////////////////////////////////////////////////////// | 120 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1301 FilterURL(policy, GetProcess(), false, &validated_params.target_url); | 1301 FilterURL(policy, GetProcess(), false, &validated_params.target_url); |
| 1302 FilterURL(policy, GetProcess(), false, &validated_params.opener_url); | 1302 FilterURL(policy, GetProcess(), false, &validated_params.opener_url); |
| 1303 FilterURL(policy, GetProcess(), true, | 1303 FilterURL(policy, GetProcess(), true, |
| 1304 &validated_params.opener_security_origin); | 1304 &validated_params.opener_security_origin); |
| 1305 | 1305 |
| 1306 delegate_->CreateNewWindow(route_id, main_frame_route_id, | 1306 delegate_->CreateNewWindow(route_id, main_frame_route_id, |
| 1307 validated_params, session_storage_namespace); | 1307 validated_params, session_storage_namespace); |
| 1308 } | 1308 } |
| 1309 | 1309 |
| 1310 void RenderViewHostImpl::CreateNewWidget(int route_id, | 1310 void RenderViewHostImpl::CreateNewWidget(int route_id, |
| 1311 WebKit::WebPopupType popup_type) { | 1311 blink::WebPopupType popup_type) { |
| 1312 delegate_->CreateNewWidget(route_id, popup_type); | 1312 delegate_->CreateNewWidget(route_id, popup_type); |
| 1313 } | 1313 } |
| 1314 | 1314 |
| 1315 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) { | 1315 void RenderViewHostImpl::CreateNewFullscreenWidget(int route_id) { |
| 1316 delegate_->CreateNewFullscreenWidget(route_id); | 1316 delegate_->CreateNewFullscreenWidget(route_id); |
| 1317 } | 1317 } |
| 1318 | 1318 |
| 1319 void RenderViewHostImpl::OnShowView(int route_id, | 1319 void RenderViewHostImpl::OnShowView(int route_id, |
| 1320 WindowOpenDisposition disposition, | 1320 WindowOpenDisposition disposition, |
| 1321 const gfx::Rect& initial_pos, | 1321 const gfx::Rect& initial_pos, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1508 GetProcess()->ReceivedBadMessage(); | 1508 GetProcess()->ReceivedBadMessage(); |
| 1509 return; | 1509 return; |
| 1510 } | 1510 } |
| 1511 | 1511 |
| 1512 delegate_->UpdateState(this, page_id, state); | 1512 delegate_->UpdateState(this, page_id, state); |
| 1513 } | 1513 } |
| 1514 | 1514 |
| 1515 void RenderViewHostImpl::OnUpdateTitle( | 1515 void RenderViewHostImpl::OnUpdateTitle( |
| 1516 int32 page_id, | 1516 int32 page_id, |
| 1517 const string16& title, | 1517 const string16& title, |
| 1518 WebKit::WebTextDirection title_direction) { | 1518 blink::WebTextDirection title_direction) { |
| 1519 if (title.length() > kMaxTitleChars) { | 1519 if (title.length() > kMaxTitleChars) { |
| 1520 NOTREACHED() << "Renderer sent too many characters in title."; | 1520 NOTREACHED() << "Renderer sent too many characters in title."; |
| 1521 return; | 1521 return; |
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 delegate_->UpdateTitle(this, page_id, title, | 1524 delegate_->UpdateTitle(this, page_id, title, |
| 1525 WebTextDirectionToChromeTextDirection( | 1525 WebTextDirectionToChromeTextDirection( |
| 1526 title_direction)); | 1526 title_direction)); |
| 1527 } | 1527 } |
| 1528 | 1528 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1863 | 1863 |
| 1864 void RenderViewHostImpl::OnBlur() { | 1864 void RenderViewHostImpl::OnBlur() { |
| 1865 delegate_->Deactivate(); | 1865 delegate_->Deactivate(); |
| 1866 } | 1866 } |
| 1867 | 1867 |
| 1868 gfx::Rect RenderViewHostImpl::GetRootWindowResizerRect() const { | 1868 gfx::Rect RenderViewHostImpl::GetRootWindowResizerRect() const { |
| 1869 return delegate_->GetRootWindowResizerRect(); | 1869 return delegate_->GetRootWindowResizerRect(); |
| 1870 } | 1870 } |
| 1871 | 1871 |
| 1872 void RenderViewHostImpl::ForwardMouseEvent( | 1872 void RenderViewHostImpl::ForwardMouseEvent( |
| 1873 const WebKit::WebMouseEvent& mouse_event) { | 1873 const blink::WebMouseEvent& mouse_event) { |
| 1874 | 1874 |
| 1875 // We make a copy of the mouse event because | 1875 // We make a copy of the mouse event because |
| 1876 // RenderWidgetHost::ForwardMouseEvent will delete |mouse_event|. | 1876 // RenderWidgetHost::ForwardMouseEvent will delete |mouse_event|. |
| 1877 WebKit::WebMouseEvent event_copy(mouse_event); | 1877 blink::WebMouseEvent event_copy(mouse_event); |
| 1878 RenderWidgetHostImpl::ForwardMouseEvent(event_copy); | 1878 RenderWidgetHostImpl::ForwardMouseEvent(event_copy); |
| 1879 | 1879 |
| 1880 switch (event_copy.type) { | 1880 switch (event_copy.type) { |
| 1881 case WebInputEvent::MouseMove: | 1881 case WebInputEvent::MouseMove: |
| 1882 delegate_->HandleMouseMove(); | 1882 delegate_->HandleMouseMove(); |
| 1883 break; | 1883 break; |
| 1884 case WebInputEvent::MouseLeave: | 1884 case WebInputEvent::MouseLeave: |
| 1885 delegate_->HandleMouseLeave(); | 1885 delegate_->HandleMouseLeave(); |
| 1886 break; | 1886 break; |
| 1887 case WebInputEvent::MouseDown: | 1887 case WebInputEvent::MouseDown: |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2012 } | 2012 } |
| 2013 | 2013 |
| 2014 void RenderViewHostImpl::DisownOpener() { | 2014 void RenderViewHostImpl::DisownOpener() { |
| 2015 // This should only be called when swapped out. | 2015 // This should only be called when swapped out. |
| 2016 DCHECK(is_swapped_out_); | 2016 DCHECK(is_swapped_out_); |
| 2017 | 2017 |
| 2018 Send(new ViewMsg_DisownOpener(GetRoutingID())); | 2018 Send(new ViewMsg_DisownOpener(GetRoutingID())); |
| 2019 } | 2019 } |
| 2020 | 2020 |
| 2021 void RenderViewHostImpl::SetAccessibilityCallbackForTesting( | 2021 void RenderViewHostImpl::SetAccessibilityCallbackForTesting( |
| 2022 const base::Callback<void(WebKit::WebAXEvent)>& callback) { | 2022 const base::Callback<void(blink::WebAXEvent)>& callback) { |
| 2023 accessibility_testing_callback_ = callback; | 2023 accessibility_testing_callback_ = callback; |
| 2024 } | 2024 } |
| 2025 | 2025 |
| 2026 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { | 2026 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { |
| 2027 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); | 2027 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); |
| 2028 } | 2028 } |
| 2029 | 2029 |
| 2030 void RenderViewHostImpl::NotifyTimezoneChange() { | 2030 void RenderViewHostImpl::NotifyTimezoneChange() { |
| 2031 Send(new ViewMsg_TimezoneChange(GetRoutingID())); | 2031 Send(new ViewMsg_TimezoneChange(GetRoutingID())); |
| 2032 } | 2032 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2049 void RenderViewHostImpl::Zoom(PageZoom zoom) { | 2049 void RenderViewHostImpl::Zoom(PageZoom zoom) { |
| 2050 Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); | 2050 Send(new ViewMsg_Zoom(GetRoutingID(), zoom)); |
| 2051 } | 2051 } |
| 2052 | 2052 |
| 2053 void RenderViewHostImpl::ReloadFrame() { | 2053 void RenderViewHostImpl::ReloadFrame() { |
| 2054 Send(new ViewMsg_ReloadFrame(GetRoutingID())); | 2054 Send(new ViewMsg_ReloadFrame(GetRoutingID())); |
| 2055 } | 2055 } |
| 2056 | 2056 |
| 2057 void RenderViewHostImpl::Find(int request_id, | 2057 void RenderViewHostImpl::Find(int request_id, |
| 2058 const string16& search_text, | 2058 const string16& search_text, |
| 2059 const WebKit::WebFindOptions& options) { | 2059 const blink::WebFindOptions& options) { |
| 2060 Send(new ViewMsg_Find(GetRoutingID(), request_id, search_text, options)); | 2060 Send(new ViewMsg_Find(GetRoutingID(), request_id, search_text, options)); |
| 2061 } | 2061 } |
| 2062 | 2062 |
| 2063 void RenderViewHostImpl::InsertCSS(const string16& frame_xpath, | 2063 void RenderViewHostImpl::InsertCSS(const string16& frame_xpath, |
| 2064 const std::string& css) { | 2064 const std::string& css) { |
| 2065 Send(new ViewMsg_CSSInsertRequest(GetRoutingID(), frame_xpath, css)); | 2065 Send(new ViewMsg_CSSInsertRequest(GetRoutingID(), frame_xpath, css)); |
| 2066 } | 2066 } |
| 2067 | 2067 |
| 2068 void RenderViewHostImpl::DisableScrollbarsForThreshold(const gfx::Size& size) { | 2068 void RenderViewHostImpl::DisableScrollbarsForThreshold(const gfx::Size& size) { |
| 2069 Send(new ViewMsg_DisableScrollbarsForSmallWindows(GetRoutingID(), size)); | 2069 Send(new ViewMsg_DisableScrollbarsForSmallWindows(GetRoutingID(), size)); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2092 void RenderViewHostImpl::NotifyContextMenuClosed( | 2092 void RenderViewHostImpl::NotifyContextMenuClosed( |
| 2093 const CustomContextMenuContext& context) { | 2093 const CustomContextMenuContext& context) { |
| 2094 Send(new ViewMsg_ContextMenuClosed(GetRoutingID(), context)); | 2094 Send(new ViewMsg_ContextMenuClosed(GetRoutingID(), context)); |
| 2095 } | 2095 } |
| 2096 | 2096 |
| 2097 void RenderViewHostImpl::CopyImageAt(int x, int y) { | 2097 void RenderViewHostImpl::CopyImageAt(int x, int y) { |
| 2098 Send(new ViewMsg_CopyImageAt(GetRoutingID(), x, y)); | 2098 Send(new ViewMsg_CopyImageAt(GetRoutingID(), x, y)); |
| 2099 } | 2099 } |
| 2100 | 2100 |
| 2101 void RenderViewHostImpl::ExecuteMediaPlayerActionAtLocation( | 2101 void RenderViewHostImpl::ExecuteMediaPlayerActionAtLocation( |
| 2102 const gfx::Point& location, const WebKit::WebMediaPlayerAction& action) { | 2102 const gfx::Point& location, const blink::WebMediaPlayerAction& action) { |
| 2103 Send(new ViewMsg_MediaPlayerActionAt(GetRoutingID(), location, action)); | 2103 Send(new ViewMsg_MediaPlayerActionAt(GetRoutingID(), location, action)); |
| 2104 } | 2104 } |
| 2105 | 2105 |
| 2106 void RenderViewHostImpl::ExecutePluginActionAtLocation( | 2106 void RenderViewHostImpl::ExecutePluginActionAtLocation( |
| 2107 const gfx::Point& location, const WebKit::WebPluginAction& action) { | 2107 const gfx::Point& location, const blink::WebPluginAction& action) { |
| 2108 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); | 2108 Send(new ViewMsg_PluginActionAt(GetRoutingID(), location, action)); |
| 2109 } | 2109 } |
| 2110 | 2110 |
| 2111 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { | 2111 void RenderViewHostImpl::NotifyMoveOrResizeStarted() { |
| 2112 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); | 2112 Send(new ViewMsg_MoveOrResizeStarted(GetRoutingID())); |
| 2113 } | 2113 } |
| 2114 | 2114 |
| 2115 void RenderViewHostImpl::StopFinding(StopFindAction action) { | 2115 void RenderViewHostImpl::StopFinding(StopFindAction action) { |
| 2116 Send(new ViewMsg_StopFinding(GetRoutingID(), action)); | 2116 Send(new ViewMsg_StopFinding(GetRoutingID(), action)); |
| 2117 } | 2117 } |
| 2118 | 2118 |
| 2119 void RenderViewHostImpl::OnAccessibilityEvents( | 2119 void RenderViewHostImpl::OnAccessibilityEvents( |
| 2120 const std::vector<AccessibilityHostMsg_EventParams>& params) { | 2120 const std::vector<AccessibilityHostMsg_EventParams>& params) { |
| 2121 if (view_ && !is_swapped_out_) | 2121 if (view_ && !is_swapped_out_) |
| 2122 view_->OnAccessibilityEvents(params); | 2122 view_->OnAccessibilityEvents(params); |
| 2123 | 2123 |
| 2124 // Always send an ACK or the renderer can be in a bad state. | 2124 // Always send an ACK or the renderer can be in a bad state. |
| 2125 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); | 2125 Send(new AccessibilityMsg_Events_ACK(GetRoutingID())); |
| 2126 | 2126 |
| 2127 // The rest of this code is just for testing; bail out if we're not | 2127 // The rest of this code is just for testing; bail out if we're not |
| 2128 // in that mode. | 2128 // in that mode. |
| 2129 if (accessibility_testing_callback_.is_null()) | 2129 if (accessibility_testing_callback_.is_null()) |
| 2130 return; | 2130 return; |
| 2131 | 2131 |
| 2132 for (unsigned i = 0; i < params.size(); i++) { | 2132 for (unsigned i = 0; i < params.size(); i++) { |
| 2133 const AccessibilityHostMsg_EventParams& param = params[i]; | 2133 const AccessibilityHostMsg_EventParams& param = params[i]; |
| 2134 WebKit::WebAXEvent src_type = param.event_type; | 2134 blink::WebAXEvent src_type = param.event_type; |
| 2135 if (src_type == WebKit::WebAXEventLayoutComplete || | 2135 if (src_type == blink::WebAXEventLayoutComplete || |
| 2136 src_type == WebKit::WebAXEventLoadComplete) { | 2136 src_type == blink::WebAXEventLoadComplete) { |
| 2137 MakeAccessibilityNodeDataTree(param.nodes, &accessibility_tree_); | 2137 MakeAccessibilityNodeDataTree(param.nodes, &accessibility_tree_); |
| 2138 } | 2138 } |
| 2139 accessibility_testing_callback_.Run(src_type); | 2139 accessibility_testing_callback_.Run(src_type); |
| 2140 } | 2140 } |
| 2141 } | 2141 } |
| 2142 | 2142 |
| 2143 void RenderViewHostImpl::OnScriptEvalResponse(int id, | 2143 void RenderViewHostImpl::OnScriptEvalResponse(int id, |
| 2144 const base::ListValue& result) { | 2144 const base::ListValue& result) { |
| 2145 const base::Value* result_value; | 2145 const base::Value* result_value; |
| 2146 if (!result.Get(0, &result_value)) { | 2146 if (!result.Get(0, &result_value)) { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2269 void RenderViewHostImpl::AttachToFrameTree() { | 2269 void RenderViewHostImpl::AttachToFrameTree() { |
| 2270 FrameTree* frame_tree = delegate_->GetFrameTree(); | 2270 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 2271 | 2271 |
| 2272 frame_tree->SwapMainFrame(main_render_frame_host_.get()); | 2272 frame_tree->SwapMainFrame(main_render_frame_host_.get()); |
| 2273 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) { | 2273 if (main_frame_id() != FrameTreeNode::kInvalidFrameId) { |
| 2274 frame_tree->OnFirstNavigationAfterSwap(main_frame_id()); | 2274 frame_tree->OnFirstNavigationAfterSwap(main_frame_id()); |
| 2275 } | 2275 } |
| 2276 } | 2276 } |
| 2277 | 2277 |
| 2278 } // namespace content | 2278 } // namespace content |
| OLD | NEW |