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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 #endif | 798 #endif |
799 enumeration_completion_id_(0), | 799 enumeration_completion_id_(0), |
800 #if defined(OS_ANDROID) | 800 #if defined(OS_ANDROID) |
801 load_progress_tracker_(new LoadProgressTracker(this)), | 801 load_progress_tracker_(new LoadProgressTracker(this)), |
802 #endif | 802 #endif |
803 session_storage_namespace_id_(params->session_storage_namespace_id), | 803 session_storage_namespace_id_(params->session_storage_namespace_id), |
804 decrement_shared_popup_at_destruction_(false), | 804 decrement_shared_popup_at_destruction_(false), |
805 handling_select_range_(false), | 805 handling_select_range_(false), |
806 next_snapshot_id_(0), | 806 next_snapshot_id_(0), |
807 allow_partial_swap_(params->allow_partial_swap), | 807 allow_partial_swap_(params->allow_partial_swap), |
808 context_menu_source_type_(content::CONTEXT_MENU_SOURCE_MOUSE) { | 808 context_menu_source_type_(ui::MENU_SOURCE_MOUSE) { |
809 } | 809 } |
810 | 810 |
811 void RenderViewImpl::Initialize(RenderViewImplParams* params) { | 811 void RenderViewImpl::Initialize(RenderViewImplParams* params) { |
812 main_render_frame_.reset(new RenderFrameImpl( | 812 main_render_frame_.reset(new RenderFrameImpl( |
813 this, params->main_frame_routing_id)); | 813 this, params->main_frame_routing_id)); |
814 | 814 |
815 #if defined(ENABLE_PLUGINS) | 815 #if defined(ENABLE_PLUGINS) |
816 pepper_helper_.reset(new PepperPluginDelegateImpl(this)); | 816 pepper_helper_.reset(new PepperPluginDelegateImpl(this)); |
817 #else | 817 #else |
818 pepper_helper_.reset(new RenderViewPepperHelper()); | 818 pepper_helper_.reset(new RenderViewPepperHelper()); |
(...skipping 1626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2445 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( | 2445 SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( |
2446 routing_id_, frame->document().url(), message, is_reload, | 2446 routing_id_, frame->document().url(), message, is_reload, |
2447 &success, &ignored_result)); | 2447 &success, &ignored_result)); |
2448 return success; | 2448 return success; |
2449 } | 2449 } |
2450 | 2450 |
2451 void RenderViewImpl::showContextMenu( | 2451 void RenderViewImpl::showContextMenu( |
2452 WebFrame* frame, const WebContextMenuData& data) { | 2452 WebFrame* frame, const WebContextMenuData& data) { |
2453 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); | 2453 ContextMenuParams params = ContextMenuParamsBuilder::Build(data); |
2454 params.source_type = context_menu_source_type_; | 2454 params.source_type = context_menu_source_type_; |
2455 if (context_menu_source_type_ == CONTEXT_MENU_SOURCE_TOUCH_EDIT_MENU) { | 2455 if (context_menu_source_type_ == ui::MENU_SOURCE_TOUCH_EDIT_MENU) { |
2456 params.x = touch_editing_context_menu_location_.x(); | 2456 params.x = touch_editing_context_menu_location_.x(); |
2457 params.y = touch_editing_context_menu_location_.y(); | 2457 params.y = touch_editing_context_menu_location_.y(); |
2458 } | 2458 } |
2459 | 2459 |
2460 // Plugins, e.g. PDF, don't currently update the render view when their | 2460 // Plugins, e.g. PDF, don't currently update the render view when their |
2461 // selected text changes, but the context menu params do contain the updated | 2461 // selected text changes, but the context menu params do contain the updated |
2462 // selection. If that's the case, update the render view's state just prior | 2462 // selection. If that's the case, update the render view's state just prior |
2463 // to showing the context menu. | 2463 // to showing the context menu. |
2464 // TODO(asvitkine): http://crbug.com/152432 | 2464 // TODO(asvitkine): http://crbug.com/152432 |
2465 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_, | 2465 if (ShouldUpdateSelectionTextFromContextMenuParams(selection_text_, |
(...skipping 3475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5941 RenderWidget::Close(); | 5941 RenderWidget::Close(); |
5942 g_view_map.Get().erase(doomed); | 5942 g_view_map.Get().erase(doomed); |
5943 g_routing_id_view_map.Get().erase(routing_id_); | 5943 g_routing_id_view_map.Get().erase(routing_id_); |
5944 } | 5944 } |
5945 | 5945 |
5946 void RenderViewImpl::DidHandleKeyEvent() { | 5946 void RenderViewImpl::DidHandleKeyEvent() { |
5947 ClearEditCommands(); | 5947 ClearEditCommands(); |
5948 } | 5948 } |
5949 | 5949 |
5950 bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 5950 bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
5951 context_menu_source_type_ = CONTEXT_MENU_SOURCE_MOUSE; | 5951 context_menu_source_type_ = ui::MENU_SOURCE_MOUSE; |
5952 possible_drag_event_info_.event_source = | 5952 possible_drag_event_info_.event_source = |
5953 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; | 5953 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; |
5954 possible_drag_event_info_.event_location = | 5954 possible_drag_event_info_.event_location = |
5955 gfx::Point(event.globalX, event.globalY); | 5955 gfx::Point(event.globalX, event.globalY); |
5956 pepper_helper_->WillHandleMouseEvent(); | 5956 pepper_helper_->WillHandleMouseEvent(); |
5957 | 5957 |
5958 // If the mouse is locked, only the current owner of the mouse lock can | 5958 // If the mouse is locked, only the current owner of the mouse lock can |
5959 // process mouse events. | 5959 // process mouse events. |
5960 return mouse_lock_dispatcher_->WillHandleMouseEvent(event); | 5960 return mouse_lock_dispatcher_->WillHandleMouseEvent(event); |
5961 } | 5961 } |
5962 | 5962 |
5963 bool RenderViewImpl::WillHandleKeyEvent(const WebKit::WebKeyboardEvent& event) { | 5963 bool RenderViewImpl::WillHandleKeyEvent(const WebKit::WebKeyboardEvent& event) { |
5964 context_menu_source_type_ = CONTEXT_MENU_SOURCE_KEYBOARD; | 5964 context_menu_source_type_ = ui::MENU_SOURCE_KEYBOARD; |
5965 return false; | 5965 return false; |
5966 } | 5966 } |
5967 | 5967 |
5968 bool RenderViewImpl::WillHandleGestureEvent( | 5968 bool RenderViewImpl::WillHandleGestureEvent( |
5969 const WebKit::WebGestureEvent& event) { | 5969 const WebKit::WebGestureEvent& event) { |
5970 context_menu_source_type_ = CONTEXT_MENU_SOURCE_TOUCH; | 5970 context_menu_source_type_ = ui::MENU_SOURCE_TOUCH; |
5971 possible_drag_event_info_.event_source = | 5971 possible_drag_event_info_.event_source = |
5972 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; | 5972 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
5973 possible_drag_event_info_.event_location = | 5973 possible_drag_event_info_.event_location = |
5974 gfx::Point(event.globalX, event.globalY); | 5974 gfx::Point(event.globalX, event.globalY); |
5975 return false; | 5975 return false; |
5976 } | 5976 } |
5977 | 5977 |
5978 void RenderViewImpl::DidHandleMouseEvent(const WebMouseEvent& event) { | 5978 void RenderViewImpl::DidHandleMouseEvent(const WebMouseEvent& event) { |
5979 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); | 5979 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
5980 } | 5980 } |
(...skipping 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6587 client->OnMenuClosed(custom_context.request_id); | 6587 client->OnMenuClosed(custom_context.request_id); |
6588 pending_context_menus_.Remove(custom_context.request_id); | 6588 pending_context_menus_.Remove(custom_context.request_id); |
6589 } | 6589 } |
6590 } else { | 6590 } else { |
6591 // Internal request, forward to WebKit. | 6591 // Internal request, forward to WebKit. |
6592 context_menu_node_.reset(); | 6592 context_menu_node_.reset(); |
6593 } | 6593 } |
6594 } | 6594 } |
6595 | 6595 |
6596 void RenderViewImpl::OnShowContextMenu(const gfx::Point& location) { | 6596 void RenderViewImpl::OnShowContextMenu(const gfx::Point& location) { |
6597 context_menu_source_type_ = CONTEXT_MENU_SOURCE_TOUCH_EDIT_MENU; | 6597 context_menu_source_type_ = ui::MENU_SOURCE_TOUCH_EDIT_MENU; |
6598 touch_editing_context_menu_location_ = location; | 6598 touch_editing_context_menu_location_ = location; |
6599 if (webview()) | 6599 if (webview()) |
6600 webview()->showContextMenu(); | 6600 webview()->showContextMenu(); |
6601 } | 6601 } |
6602 | 6602 |
6603 void RenderViewImpl::OnEnableViewSourceMode() { | 6603 void RenderViewImpl::OnEnableViewSourceMode() { |
6604 if (!webview()) | 6604 if (!webview()) |
6605 return; | 6605 return; |
6606 WebFrame* main_frame = webview()->mainFrame(); | 6606 WebFrame* main_frame = webview()->mainFrame(); |
6607 if (!main_frame) | 6607 if (!main_frame) |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6749 WebURL url = icon_urls[i].iconURL(); | 6749 WebURL url = icon_urls[i].iconURL(); |
6750 if (!url.isEmpty()) | 6750 if (!url.isEmpty()) |
6751 urls.push_back(FaviconURL(url, | 6751 urls.push_back(FaviconURL(url, |
6752 ToFaviconType(icon_urls[i].iconType()))); | 6752 ToFaviconType(icon_urls[i].iconType()))); |
6753 } | 6753 } |
6754 SendUpdateFaviconURL(urls); | 6754 SendUpdateFaviconURL(urls); |
6755 } | 6755 } |
6756 | 6756 |
6757 | 6757 |
6758 } // namespace content | 6758 } // namespace content |
OLD | NEW |