| 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/renderer/render_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "content/common/input_messages.h" | 46 #include "content/common/input_messages.h" |
| 47 #include "content/common/java_bridge_messages.h" | 47 #include "content/common/java_bridge_messages.h" |
| 48 #include "content/common/pepper_messages.h" | 48 #include "content/common/pepper_messages.h" |
| 49 #include "content/common/socket_stream_handle_data.h" | 49 #include "content/common/socket_stream_handle_data.h" |
| 50 #include "content/common/ssl_status_serialization.h" | 50 #include "content/common/ssl_status_serialization.h" |
| 51 #include "content/common/view_messages.h" | 51 #include "content/common/view_messages.h" |
| 52 #include "content/public/common/bindings_policy.h" | 52 #include "content/public/common/bindings_policy.h" |
| 53 #include "content/public/common/content_client.h" | 53 #include "content/public/common/content_client.h" |
| 54 #include "content/public/common/content_constants.h" | 54 #include "content/public/common/content_constants.h" |
| 55 #include "content/public/common/content_switches.h" | 55 #include "content/public/common/content_switches.h" |
| 56 #include "content/public/common/context_menu_params.h" | |
| 57 #include "content/public/common/drop_data.h" | 56 #include "content/public/common/drop_data.h" |
| 58 #include "content/public/common/favicon_url.h" | 57 #include "content/public/common/favicon_url.h" |
| 59 #include "content/public/common/file_chooser_params.h" | 58 #include "content/public/common/file_chooser_params.h" |
| 60 #include "content/public/common/page_zoom.h" | 59 #include "content/public/common/page_zoom.h" |
| 61 #include "content/public/common/ssl_status.h" | 60 #include "content/public/common/ssl_status.h" |
| 62 #include "content/public/common/three_d_api_types.h" | 61 #include "content/public/common/three_d_api_types.h" |
| 63 #include "content/public/common/url_constants.h" | 62 #include "content/public/common/url_constants.h" |
| 64 #include "content/public/common/url_utils.h" | 63 #include "content/public/common/url_utils.h" |
| 65 #include "content/public/renderer/content_renderer_client.h" | 64 #include "content/public/renderer/content_renderer_client.h" |
| 66 #include "content/public/renderer/context_menu_client.h" | |
| 67 #include "content/public/renderer/document_state.h" | 65 #include "content/public/renderer/document_state.h" |
| 68 #include "content/public/renderer/history_item_serialization.h" | 66 #include "content/public/renderer/history_item_serialization.h" |
| 69 #include "content/public/renderer/navigation_state.h" | 67 #include "content/public/renderer/navigation_state.h" |
| 70 #include "content/public/renderer/render_view_observer.h" | 68 #include "content/public/renderer/render_view_observer.h" |
| 71 #include "content/public/renderer/render_view_visitor.h" | 69 #include "content/public/renderer/render_view_visitor.h" |
| 72 #include "content/public/renderer/web_preferences.h" | 70 #include "content/public/renderer/web_preferences.h" |
| 73 #include "content/renderer/accessibility/renderer_accessibility.h" | 71 #include "content/renderer/accessibility/renderer_accessibility.h" |
| 74 #include "content/renderer/accessibility/renderer_accessibility_complete.h" | 72 #include "content/renderer/accessibility/renderer_accessibility_complete.h" |
| 75 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" | 73 #include "content/renderer/accessibility/renderer_accessibility_focus_only.h" |
| 76 #include "content/renderer/browser_plugin/browser_plugin.h" | 74 #include "content/renderer/browser_plugin/browser_plugin.h" |
| 77 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 75 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
| 78 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" | 76 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" |
| 79 #include "content/renderer/context_menu_params_builder.h" | |
| 80 #include "content/renderer/devtools/devtools_agent.h" | 77 #include "content/renderer/devtools/devtools_agent.h" |
| 81 #include "content/renderer/disambiguation_popup_helper.h" | 78 #include "content/renderer/disambiguation_popup_helper.h" |
| 82 #include "content/renderer/dom_automation_controller.h" | 79 #include "content/renderer/dom_automation_controller.h" |
| 83 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 80 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
| 84 #include "content/renderer/drop_data_builder.h" | 81 #include "content/renderer/drop_data_builder.h" |
| 85 #include "content/renderer/external_popup_menu.h" | 82 #include "content/renderer/external_popup_menu.h" |
| 86 #include "content/renderer/geolocation_dispatcher.h" | 83 #include "content/renderer/geolocation_dispatcher.h" |
| 87 #include "content/renderer/gpu/render_widget_compositor.h" | 84 #include "content/renderer/gpu/render_widget_compositor.h" |
| 88 #include "content/renderer/idle_user_detector.h" | 85 #include "content/renderer/idle_user_detector.h" |
| 89 #include "content/renderer/image_loading_helper.h" | 86 #include "content/renderer/image_loading_helper.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 #include "content/renderer/media/rtc_peer_connection_handler.h" | 242 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 246 #endif | 243 #endif |
| 247 | 244 |
| 248 using blink::WebAXObject; | 245 using blink::WebAXObject; |
| 249 using blink::WebApplicationCacheHost; | 246 using blink::WebApplicationCacheHost; |
| 250 using blink::WebApplicationCacheHostClient; | 247 using blink::WebApplicationCacheHostClient; |
| 251 using blink::WebCString; | 248 using blink::WebCString; |
| 252 using blink::WebColor; | 249 using blink::WebColor; |
| 253 using blink::WebColorName; | 250 using blink::WebColorName; |
| 254 using blink::WebConsoleMessage; | 251 using blink::WebConsoleMessage; |
| 255 using blink::WebContextMenuData; | |
| 256 using blink::WebData; | 252 using blink::WebData; |
| 257 using blink::WebDataSource; | 253 using blink::WebDataSource; |
| 258 using blink::WebDocument; | 254 using blink::WebDocument; |
| 259 using blink::WebDOMEvent; | 255 using blink::WebDOMEvent; |
| 260 using blink::WebDOMMessageEvent; | 256 using blink::WebDOMMessageEvent; |
| 261 using blink::WebDragData; | 257 using blink::WebDragData; |
| 262 using blink::WebDragOperation; | 258 using blink::WebDragOperation; |
| 263 using blink::WebDragOperationsMask; | 259 using blink::WebDragOperationsMask; |
| 264 using blink::WebElement; | 260 using blink::WebElement; |
| 265 using blink::WebExternalPopupMenu; | 261 using blink::WebExternalPopupMenu; |
| (...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 #endif | 846 #endif |
| 851 #if defined(ENABLE_PLUGINS) | 847 #if defined(ENABLE_PLUGINS) |
| 852 focused_pepper_plugin_(NULL), | 848 focused_pepper_plugin_(NULL), |
| 853 pepper_last_mouse_event_target_(NULL), | 849 pepper_last_mouse_event_target_(NULL), |
| 854 #endif | 850 #endif |
| 855 enumeration_completion_id_(0), | 851 enumeration_completion_id_(0), |
| 856 load_progress_tracker_(new LoadProgressTracker(this)), | 852 load_progress_tracker_(new LoadProgressTracker(this)), |
| 857 session_storage_namespace_id_(params->session_storage_namespace_id), | 853 session_storage_namespace_id_(params->session_storage_namespace_id), |
| 858 handling_select_range_(false), | 854 handling_select_range_(false), |
| 859 next_snapshot_id_(0), | 855 next_snapshot_id_(0), |
| 860 allow_partial_swap_(params->allow_partial_swap), | 856 allow_partial_swap_(params->allow_partial_swap) { |
| 861 context_menu_source_type_(ui::MENU_SOURCE_MOUSE) { | |
| 862 } | 857 } |
| 863 | 858 |
| 864 void RenderViewImpl::Initialize(RenderViewImplParams* params) { | 859 void RenderViewImpl::Initialize(RenderViewImplParams* params) { |
| 865 routing_id_ = params->routing_id; | 860 routing_id_ = params->routing_id; |
| 866 surface_id_ = params->surface_id; | 861 surface_id_ = params->surface_id; |
| 867 if (params->opener_id != MSG_ROUTING_NONE && params->is_renderer_created) | 862 if (params->opener_id != MSG_ROUTING_NONE && params->is_renderer_created) |
| 868 opener_id_ = params->opener_id; | 863 opener_id_ = params->opener_id; |
| 869 | 864 |
| 870 // Ensure we start with a valid next_page_id_ from the browser. | 865 // Ensure we start with a valid next_page_id_ from the browser. |
| 871 DCHECK_GE(next_page_id_, 0); | 866 DCHECK_GE(next_page_id_, 0); |
| (...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1305 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) | 1300 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
| 1306 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) | 1301 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
| 1307 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, | 1302 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 1308 OnDisableScrollbarsForSmallWindows) | 1303 OnDisableScrollbarsForSmallWindows) |
| 1309 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) | 1304 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
| 1310 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) | 1305 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
| 1311 IPC_MESSAGE_HANDLER(ViewMsg_OrientationChangeEvent, | 1306 IPC_MESSAGE_HANDLER(ViewMsg_OrientationChangeEvent, |
| 1312 OnOrientationChangeEvent) | 1307 OnOrientationChangeEvent) |
| 1313 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) | 1308 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
| 1314 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) | 1309 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
| 1315 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, | |
| 1316 OnCustomContextMenuAction) | |
| 1317 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, | 1310 IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
| 1318 OnGetAllSavableResourceLinksForCurrentPage) | 1311 OnGetAllSavableResourceLinksForCurrentPage) |
| 1319 IPC_MESSAGE_HANDLER( | 1312 IPC_MESSAGE_HANDLER( |
| 1320 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, | 1313 ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
| 1321 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) | 1314 OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
| 1322 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) | |
| 1323 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) | 1315 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
| 1324 // TODO(viettrungluu): Move to a separate message filter. | 1316 // TODO(viettrungluu): Move to a separate message filter. |
| 1325 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 1317 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 1326 OnSetHistoryLengthAndPrune) | 1318 OnSetHistoryLengthAndPrune) |
| 1327 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 1319 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
| 1328 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) | 1320 IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) |
| 1329 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) | 1321 IPC_MESSAGE_HANDLER(ViewMsg_DisownOpener, OnDisownOpener) |
| 1330 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupDIB, | 1322 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupDIB, |
| 1331 OnReleaseDisambiguationPopupDIB) | 1323 OnReleaseDisambiguationPopupDIB) |
| 1332 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, | 1324 IPC_MESSAGE_HANDLER(ViewMsg_WindowSnapshotCompleted, |
| (...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 Send(new ViewHostMsg_HideValidationMessage(routing_id())); | 2645 Send(new ViewHostMsg_HideValidationMessage(routing_id())); |
| 2654 } | 2646 } |
| 2655 | 2647 |
| 2656 void RenderViewImpl::moveValidationMessage( | 2648 void RenderViewImpl::moveValidationMessage( |
| 2657 const blink::WebRect& anchor_in_root_view) { | 2649 const blink::WebRect& anchor_in_root_view) { |
| 2658 Send(new ViewHostMsg_MoveValidationMessage(routing_id(), | 2650 Send(new ViewHostMsg_MoveValidationMessage(routing_id(), |
| 2659 anchor_in_root_view)); | 2651 anchor_in_root_view)); |
| 2660 } | 2652 } |
| 2661 | 2653 |
| 2662 void RenderViewImpl::showContextMenu( | 2654 void RenderViewImpl::showContextMenu( |
| 2663 WebFrame* frame, const WebContextMenuData& data) { | 2655 WebFrame* frame, const blink::WebContextMenuData& data) { |
| 2664 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); | 2656 // TODO(jam): move this method to WebFrameClient. |
| 2665 params.source_type = context_menu_source_type_; | 2657 RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); |
| 2666 if (context_menu_source_type_ == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { | 2658 render_frame->showContextMenu(data); |
| 2667 params.x = touch_editing_context_menu_location_.x(); | |
| 2668 params.y = touch_editing_context_menu_location_.y(); | |
| 2669 } | |
| 2670 OnShowHostContextMenu(¶ms); | |
| 2671 | |
| 2672 // Plugins, e.g. PDF, don't currently update the render view when their | |
| 2673 // selected text changes, but the context menu params do contain the updated | |
| 2674 // selection. If that's the case, update the render view's state just prior | |
| 2675 // to showing the context menu. | |
| 2676 // TODO(asvitkine): http://crbug.com/152432 | |
| 2677 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_, | |
| 2678 selection_text_offset_, | |
| 2679 selection_range_, | |
| 2680 params)) { | |
| 2681 selection_text_ = params.selection_text; | |
| 2682 // TODO(asvitkine): Text offset and range is not available in this case. | |
| 2683 selection_text_offset_ = 0; | |
| 2684 selection_range_ = gfx::Range(0, selection_text_.length()); | |
| 2685 Send(new ViewHostMsg_SelectionChanged(routing_id_, | |
| 2686 selection_text_, | |
| 2687 selection_text_offset_, | |
| 2688 selection_range_)); | |
| 2689 } | |
| 2690 | |
| 2691 // frame is NULL if invoked by BlockedPlugin. | |
| 2692 if (frame) | |
| 2693 params.frame_id = frame->identifier(); | |
| 2694 | |
| 2695 // Serializing a GURL longer than kMaxURLChars will fail, so don't do | |
| 2696 // it. We replace it with an empty GURL so the appropriate items are disabled | |
| 2697 // in the context menu. | |
| 2698 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large | |
| 2699 // data encoded images. We should have a way to save them. | |
| 2700 if (params.src_url.spec().size() > GetMaxURLChars()) | |
| 2701 params.src_url = GURL(); | |
| 2702 context_menu_node_ = data.node; | |
| 2703 | |
| 2704 #if defined(OS_ANDROID) | |
| 2705 gfx::Rect start_rect; | |
| 2706 gfx::Rect end_rect; | |
| 2707 GetSelectionBounds(&start_rect, &end_rect); | |
| 2708 params.selection_start = gfx::Point(start_rect.x(), start_rect.bottom()); | |
| 2709 params.selection_end = gfx::Point(end_rect.right(), end_rect.bottom()); | |
| 2710 #endif | |
| 2711 | |
| 2712 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); | |
| 2713 | |
| 2714 FOR_EACH_OBSERVER( | |
| 2715 RenderViewObserver, observers_, DidRequestShowContextMenu(frame, data)); | |
| 2716 } | 2659 } |
| 2717 | 2660 |
| 2718 void RenderViewImpl::clearContextMenu() { | 2661 void RenderViewImpl::clearContextMenu() { |
| 2719 context_menu_node_.reset(); | 2662 context_menu_node_.reset(); |
| 2720 } | 2663 } |
| 2721 | 2664 |
| 2722 void RenderViewImpl::setStatusText(const WebString& text) { | 2665 void RenderViewImpl::setStatusText(const WebString& text) { |
| 2723 } | 2666 } |
| 2724 | 2667 |
| 2725 void RenderViewImpl::UpdateTargetURL(const GURL& url, | 2668 void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| (...skipping 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3992 const WebRect& selection_rect, | 3935 const WebRect& selection_rect, |
| 3993 bool final_status_update) { | 3936 bool final_status_update) { |
| 3994 Send(new ViewHostMsg_Find_Reply(routing_id_, | 3937 Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 3995 request_id, | 3938 request_id, |
| 3996 match_count, | 3939 match_count, |
| 3997 selection_rect, | 3940 selection_rect, |
| 3998 ordinal, | 3941 ordinal, |
| 3999 final_status_update)); | 3942 final_status_update)); |
| 4000 } | 3943 } |
| 4001 | 3944 |
| 4002 // static | |
| 4003 bool RenderViewImpl::ShouldUpdateSelectionTextFromContextMenuParams( | |
| 4004 const base::string16& selection_text, | |
| 4005 size_t selection_text_offset, | |
| 4006 const gfx::Range& selection_range, | |
| 4007 const ContextMenuParams& params) { | |
| 4008 base::string16 trimmed_selection_text; | |
| 4009 if (!selection_text.empty() && !selection_range.is_empty()) { | |
| 4010 const int start = selection_range.GetMin() - selection_text_offset; | |
| 4011 const size_t length = selection_range.length(); | |
| 4012 if (start >= 0 && start + length <= selection_text.length()) { | |
| 4013 TrimWhitespace(selection_text.substr(start, length), TRIM_ALL, | |
| 4014 &trimmed_selection_text); | |
| 4015 } | |
| 4016 } | |
| 4017 base::string16 trimmed_params_text; | |
| 4018 TrimWhitespace(params.selection_text, TRIM_ALL, &trimmed_params_text); | |
| 4019 return trimmed_params_text != trimmed_selection_text; | |
| 4020 } | |
| 4021 | |
| 4022 void RenderViewImpl::reportFindInPageMatchCount(int request_id, | 3945 void RenderViewImpl::reportFindInPageMatchCount(int request_id, |
| 4023 int count, | 3946 int count, |
| 4024 bool final_update) { | 3947 bool final_update) { |
| 4025 NOTREACHED(); | 3948 NOTREACHED(); |
| 4026 } | 3949 } |
| 4027 | 3950 |
| 4028 void RenderViewImpl::reportFindInPageSelection(int request_id, | 3951 void RenderViewImpl::reportFindInPageSelection(int request_id, |
| 4029 int active_match_ordinal, | 3952 int active_match_ordinal, |
| 4030 const WebRect& selection_rect) { | 3953 const WebRect& selection_rect) { |
| 4031 NOTREACHED(); | 3954 NOTREACHED(); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4244 } | 4167 } |
| 4245 | 4168 |
| 4246 bool RenderViewImpl::GetContentStateImmediately() const { | 4169 bool RenderViewImpl::GetContentStateImmediately() const { |
| 4247 return send_content_state_immediately_; | 4170 return send_content_state_immediately_; |
| 4248 } | 4171 } |
| 4249 | 4172 |
| 4250 float RenderViewImpl::GetFilteredTimePerFrame() const { | 4173 float RenderViewImpl::GetFilteredTimePerFrame() const { |
| 4251 return filtered_time_per_frame(); | 4174 return filtered_time_per_frame(); |
| 4252 } | 4175 } |
| 4253 | 4176 |
| 4254 int RenderViewImpl::ShowContextMenu(ContextMenuClient* client, | |
| 4255 const ContextMenuParams& params) { | |
| 4256 DCHECK(client); // A null client means "internal" when we issue callbacks. | |
| 4257 ContextMenuParams our_params(params); | |
| 4258 our_params.custom_context.request_id = pending_context_menus_.Add(client); | |
| 4259 Send(new ViewHostMsg_ContextMenu(routing_id_, our_params)); | |
| 4260 return our_params.custom_context.request_id; | |
| 4261 } | |
| 4262 | |
| 4263 void RenderViewImpl::CancelContextMenu(int request_id) { | |
| 4264 DCHECK(pending_context_menus_.Lookup(request_id)); | |
| 4265 pending_context_menus_.Remove(request_id); | |
| 4266 } | |
| 4267 | |
| 4268 blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { | 4177 blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { |
| 4269 return visibilityState(); | 4178 return visibilityState(); |
| 4270 } | 4179 } |
| 4271 | 4180 |
| 4272 void RenderViewImpl::RunModalAlertDialog(blink::WebFrame* frame, | 4181 void RenderViewImpl::RunModalAlertDialog(blink::WebFrame* frame, |
| 4273 const blink::WebString& message) { | 4182 const blink::WebString& message) { |
| 4274 return runModalAlertDialog(frame, message); | 4183 return runModalAlertDialog(frame, message); |
| 4275 } | 4184 } |
| 4276 | 4185 |
| 4277 void RenderViewImpl::DidStartLoading() { | 4186 void RenderViewImpl::DidStartLoading() { |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4829 void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { | 4738 void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
| 4830 webkit_preferences_ = prefs; | 4739 webkit_preferences_ = prefs; |
| 4831 ApplyWebPreferences(webkit_preferences_, webview()); | 4740 ApplyWebPreferences(webkit_preferences_, webview()); |
| 4832 } | 4741 } |
| 4833 | 4742 |
| 4834 void RenderViewImpl::OnUpdateTimezone() { | 4743 void RenderViewImpl::OnUpdateTimezone() { |
| 4835 if (webview()) | 4744 if (webview()) |
| 4836 NotifyTimezoneChange(webview()->mainFrame()); | 4745 NotifyTimezoneChange(webview()->mainFrame()); |
| 4837 } | 4746 } |
| 4838 | 4747 |
| 4839 void RenderViewImpl::OnCustomContextMenuAction( | |
| 4840 const CustomContextMenuContext& custom_context, | |
| 4841 unsigned action) { | |
| 4842 if (custom_context.request_id) { | |
| 4843 // External context menu request, look in our map. | |
| 4844 ContextMenuClient* client = | |
| 4845 pending_context_menus_.Lookup(custom_context.request_id); | |
| 4846 if (client) | |
| 4847 client->OnMenuAction(custom_context.request_id, action); | |
| 4848 } else { | |
| 4849 // Internal request, forward to WebKit. | |
| 4850 webview()->performCustomContextMenuAction(action); | |
| 4851 } | |
| 4852 } | |
| 4853 | |
| 4854 void RenderViewImpl::OnEnumerateDirectoryResponse( | 4748 void RenderViewImpl::OnEnumerateDirectoryResponse( |
| 4855 int id, | 4749 int id, |
| 4856 const std::vector<base::FilePath>& paths) { | 4750 const std::vector<base::FilePath>& paths) { |
| 4857 if (!enumeration_completions_[id]) | 4751 if (!enumeration_completions_[id]) |
| 4858 return; | 4752 return; |
| 4859 | 4753 |
| 4860 WebVector<WebString> ws_file_names(paths.size()); | 4754 WebVector<WebString> ws_file_names(paths.size()); |
| 4861 for (size_t i = 0; i < paths.size(); ++i) | 4755 for (size_t i = 0; i < paths.size(); ++i) |
| 4862 ws_file_names[i] = paths[i].AsUTF16Unsafe(); | 4756 ws_file_names[i] = paths[i].AsUTF16Unsafe(); |
| 4863 | 4757 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5359 RenderWidget::Close(); | 5253 RenderWidget::Close(); |
| 5360 g_view_map.Get().erase(doomed); | 5254 g_view_map.Get().erase(doomed); |
| 5361 g_routing_id_view_map.Get().erase(routing_id_); | 5255 g_routing_id_view_map.Get().erase(routing_id_); |
| 5362 } | 5256 } |
| 5363 | 5257 |
| 5364 void RenderViewImpl::DidHandleKeyEvent() { | 5258 void RenderViewImpl::DidHandleKeyEvent() { |
| 5365 ClearEditCommands(); | 5259 ClearEditCommands(); |
| 5366 } | 5260 } |
| 5367 | 5261 |
| 5368 bool RenderViewImpl::WillHandleMouseEvent(const blink::WebMouseEvent& event) { | 5262 bool RenderViewImpl::WillHandleMouseEvent(const blink::WebMouseEvent& event) { |
| 5369 context_menu_source_type_ = ui::MENU_SOURCE_MOUSE; | |
| 5370 possible_drag_event_info_.event_source = | 5263 possible_drag_event_info_.event_source = |
| 5371 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; | 5264 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; |
| 5372 possible_drag_event_info_.event_location = | 5265 possible_drag_event_info_.event_location = |
| 5373 gfx::Point(event.globalX, event.globalY); | 5266 gfx::Point(event.globalX, event.globalY); |
| 5374 | 5267 |
| 5375 #if defined(ENABLE_PLUGINS) | 5268 #if defined(ENABLE_PLUGINS) |
| 5376 // This method is called for every mouse event that the render view receives. | 5269 // This method is called for every mouse event that the render view receives. |
| 5377 // And then the mouse event is forwarded to WebKit, which dispatches it to the | 5270 // And then the mouse event is forwarded to WebKit, which dispatches it to the |
| 5378 // event target. Potentially a Pepper plugin will receive the event. | 5271 // event target. Potentially a Pepper plugin will receive the event. |
| 5379 // In order to tell whether a plugin gets the last mouse event and which it | 5272 // In order to tell whether a plugin gets the last mouse event and which it |
| 5380 // is, we set |pepper_last_mouse_event_target_| to NULL here. If a plugin gets | 5273 // is, we set |pepper_last_mouse_event_target_| to NULL here. If a plugin gets |
| 5381 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 5274 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 5382 // |pepper_last_mouse_event_target_|. | 5275 // |pepper_last_mouse_event_target_|. |
| 5383 pepper_last_mouse_event_target_ = NULL; | 5276 pepper_last_mouse_event_target_ = NULL; |
| 5384 #endif | 5277 #endif |
| 5385 | 5278 |
| 5386 // If the mouse is locked, only the current owner of the mouse lock can | 5279 // If the mouse is locked, only the current owner of the mouse lock can |
| 5387 // process mouse events. | 5280 // process mouse events. |
| 5388 return mouse_lock_dispatcher_->WillHandleMouseEvent(event); | 5281 return mouse_lock_dispatcher_->WillHandleMouseEvent(event); |
| 5389 } | 5282 } |
| 5390 | 5283 |
| 5391 bool RenderViewImpl::WillHandleKeyEvent(const blink::WebKeyboardEvent& event) { | |
| 5392 context_menu_source_type_ = ui::MENU_SOURCE_KEYBOARD; | |
| 5393 return false; | |
| 5394 } | |
| 5395 | |
| 5396 bool RenderViewImpl::WillHandleGestureEvent( | 5284 bool RenderViewImpl::WillHandleGestureEvent( |
| 5397 const blink::WebGestureEvent& event) { | 5285 const blink::WebGestureEvent& event) { |
| 5398 context_menu_source_type_ = ui::MENU_SOURCE_TOUCH; | |
| 5399 possible_drag_event_info_.event_source = | 5286 possible_drag_event_info_.event_source = |
| 5400 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; | 5287 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
| 5401 possible_drag_event_info_.event_location = | 5288 possible_drag_event_info_.event_location = |
| 5402 gfx::Point(event.globalX, event.globalY); | 5289 gfx::Point(event.globalX, event.globalY); |
| 5403 return false; | 5290 return false; |
| 5404 } | 5291 } |
| 5405 | 5292 |
| 5406 void RenderViewImpl::DidHandleMouseEvent(const WebMouseEvent& event) { | 5293 void RenderViewImpl::DidHandleMouseEvent(const WebMouseEvent& event) { |
| 5407 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); | 5294 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
| 5408 } | 5295 } |
| (...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6035 // it to the browser UI thread. Ignore the extra-messages. | 5922 // it to the browser UI thread. Ignore the extra-messages. |
| 6036 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | 5923 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. |
| 6037 if (!external_popup_menu_) | 5924 if (!external_popup_menu_) |
| 6038 return; | 5925 return; |
| 6039 | 5926 |
| 6040 external_popup_menu_->DidSelectItems(canceled, selected_indices); | 5927 external_popup_menu_->DidSelectItems(canceled, selected_indices); |
| 6041 external_popup_menu_.reset(); | 5928 external_popup_menu_.reset(); |
| 6042 } | 5929 } |
| 6043 #endif | 5930 #endif |
| 6044 | 5931 |
| 6045 void RenderViewImpl::OnContextMenuClosed( | |
| 6046 const CustomContextMenuContext& custom_context) { | |
| 6047 if (custom_context.request_id) { | |
| 6048 // External request, should be in our map. | |
| 6049 ContextMenuClient* client = | |
| 6050 pending_context_menus_.Lookup(custom_context.request_id); | |
| 6051 if (client) { | |
| 6052 client->OnMenuClosed(custom_context.request_id); | |
| 6053 pending_context_menus_.Remove(custom_context.request_id); | |
| 6054 } | |
| 6055 } else { | |
| 6056 // Internal request, forward to WebKit. | |
| 6057 context_menu_node_.reset(); | |
| 6058 } | |
| 6059 } | |
| 6060 | |
| 6061 void RenderViewImpl::OnShowContextMenu(const gfx::Point& location) { | 5932 void RenderViewImpl::OnShowContextMenu(const gfx::Point& location) { |
| 6062 context_menu_source_type_ = ui::MENU_SOURCE_TOUCH_EDIT_MENU; | 5933 context_menu_source_type_ = ui::MENU_SOURCE_TOUCH_EDIT_MENU; |
| 6063 touch_editing_context_menu_location_ = location; | 5934 touch_editing_context_menu_location_ = location; |
| 6064 if (webview()) | 5935 if (webview()) |
| 6065 webview()->showContextMenu(); | 5936 webview()->showContextMenu(); |
| 6066 } | 5937 } |
| 6067 | 5938 |
| 6068 void RenderViewImpl::OnEnableViewSourceMode() { | 5939 void RenderViewImpl::OnEnableViewSourceMode() { |
| 6069 if (!webview()) | 5940 if (!webview()) |
| 6070 return; | 5941 return; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6242 for (size_t i = 0; i < icon_urls.size(); i++) { | 6113 for (size_t i = 0; i < icon_urls.size(); i++) { |
| 6243 WebURL url = icon_urls[i].iconURL(); | 6114 WebURL url = icon_urls[i].iconURL(); |
| 6244 if (!url.isEmpty()) | 6115 if (!url.isEmpty()) |
| 6245 urls.push_back(FaviconURL(url, | 6116 urls.push_back(FaviconURL(url, |
| 6246 ToFaviconType(icon_urls[i].iconType()))); | 6117 ToFaviconType(icon_urls[i].iconType()))); |
| 6247 } | 6118 } |
| 6248 SendUpdateFaviconURL(urls); | 6119 SendUpdateFaviconURL(urls); |
| 6249 } | 6120 } |
| 6250 | 6121 |
| 6251 } // namespace content | 6122 } // namespace content |
| OLD | NEW |