| 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 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 719 | 719 |
| 720 UpdateWebViewWithDeviceScaleFactor(); | 720 UpdateWebViewWithDeviceScaleFactor(); |
| 721 OnSetRendererPrefs(params.renderer_preferences); | 721 OnSetRendererPrefs(params.renderer_preferences); |
| 722 | 722 |
| 723 if (!params.enable_auto_resize) { | 723 if (!params.enable_auto_resize) { |
| 724 OnResize(params.initial_size); | 724 OnResize(params.initial_size); |
| 725 } else { | 725 } else { |
| 726 OnEnableAutoResize(params.min_size, params.max_size); | 726 OnEnableAutoResize(params.min_size, params.max_size); |
| 727 } | 727 } |
| 728 | 728 |
| 729 new IdleUserDetector(this); | 729 idle_user_detector_.reset(new IdleUserDetector(this)); |
| 730 | 730 |
| 731 GetContentClient()->renderer()->RenderViewCreated(this); | 731 GetContentClient()->renderer()->RenderViewCreated(this); |
| 732 | 732 |
| 733 // Ensure that sandbox flags are inherited from an opener in a different | 733 // Ensure that sandbox flags are inherited from an opener in a different |
| 734 // process. In that case, the browser process will set any inherited sandbox | 734 // process. In that case, the browser process will set any inherited sandbox |
| 735 // flags in |replicated_frame_state|, so apply them here. | 735 // flags in |replicated_frame_state|, so apply them here. |
| 736 if (!was_created_by_renderer && webview()->MainFrame()->IsWebLocalFrame()) { | 736 if (!was_created_by_renderer && webview()->MainFrame()->IsWebLocalFrame()) { |
| 737 webview()->MainFrame()->ToWebLocalFrame()->ForceSandboxFlags( | 737 webview()->MainFrame()->ToWebLocalFrame()->ForceSandboxFlags( |
| 738 params.replicated_frame_state.sandbox_flags); | 738 params.replicated_frame_state.sandbox_flags); |
| 739 } | 739 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 759 // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap. | 759 // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap. |
| 760 ViewMap* views = g_view_map.Pointer(); | 760 ViewMap* views = g_view_map.Pointer(); |
| 761 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) | 761 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 762 DCHECK_NE(this, it->second) << "Failed to call Close?"; | 762 DCHECK_NE(this, it->second) << "Failed to call Close?"; |
| 763 RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer(); | 763 RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer(); |
| 764 for (RoutingIDViewMap::iterator it = routing_id_views->begin(); | 764 for (RoutingIDViewMap::iterator it = routing_id_views->begin(); |
| 765 it != routing_id_views->end(); ++it) | 765 it != routing_id_views->end(); ++it) |
| 766 DCHECK_NE(this, it->second) << "Failed to call Close?"; | 766 DCHECK_NE(this, it->second) << "Failed to call Close?"; |
| 767 #endif | 767 #endif |
| 768 | 768 |
| 769 idle_user_detector_.reset(); |
| 769 for (auto& observer : observers_) | 770 for (auto& observer : observers_) |
| 770 observer.RenderViewGone(); | 771 observer.RenderViewGone(); |
| 771 for (auto& observer : observers_) | 772 for (auto& observer : observers_) |
| 772 observer.OnDestruct(); | 773 observer.OnDestruct(); |
| 773 } | 774 } |
| 774 | 775 |
| 775 /*static*/ | 776 /*static*/ |
| 776 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { | 777 RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
| 777 ViewMap* views = g_view_map.Pointer(); | 778 ViewMap* views = g_view_map.Pointer(); |
| 778 ViewMap::iterator it = views->find(webview); | 779 ViewMap::iterator it = views->find(webview); |
| (...skipping 1874 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2653 } | 2654 } |
| 2654 webview()->GetSettings()->SetPreferCompositingToLCDTextEnabled( | 2655 webview()->GetSettings()->SetPreferCompositingToLCDTextEnabled( |
| 2655 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); | 2656 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
| 2656 } | 2657 } |
| 2657 | 2658 |
| 2658 void RenderViewImpl::OnDiscardInputEvent( | 2659 void RenderViewImpl::OnDiscardInputEvent( |
| 2659 const blink::WebInputEvent* input_event, | 2660 const blink::WebInputEvent* input_event, |
| 2660 const std::vector<const blink::WebInputEvent*>& coalesced_events, | 2661 const std::vector<const blink::WebInputEvent*>& coalesced_events, |
| 2661 const ui::LatencyInfo& latency_info, | 2662 const ui::LatencyInfo& latency_info, |
| 2662 InputEventDispatchType dispatch_type) { | 2663 InputEventDispatchType dispatch_type) { |
| 2663 if (!input_event || (dispatch_type != DISPATCH_TYPE_BLOCKING && | 2664 if (!input_event || dispatch_type == DISPATCH_TYPE_NON_BLOCKING) { |
| 2664 dispatch_type != DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN)) { | |
| 2665 return; | 2665 return; |
| 2666 } | 2666 } |
| 2667 | 2667 |
| 2668 if (dispatch_type == DISPATCH_TYPE_BLOCKING_NOTIFY_MAIN) { | |
| 2669 NotifyInputEventHandled(input_event->GetType(), | |
| 2670 blink::WebInputEventResult::kNotHandled, | |
| 2671 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | |
| 2672 } | |
| 2673 | |
| 2674 std::unique_ptr<InputEventAck> ack(new InputEventAck( | 2668 std::unique_ptr<InputEventAck> ack(new InputEventAck( |
| 2675 InputEventAckSource::MAIN_THREAD, input_event->GetType(), | 2669 InputEventAckSource::MAIN_THREAD, input_event->GetType(), |
| 2676 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 2670 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
| 2677 OnInputEventAck(std::move(ack)); | 2671 OnInputEventAck(std::move(ack)); |
| 2678 } | 2672 } |
| 2679 | 2673 |
| 2674 InputEventAckState RenderViewImpl::HandleInputEvent( |
| 2675 const blink::WebCoalescedInputEvent& input_event, |
| 2676 const ui::LatencyInfo& latency_info, |
| 2677 InputEventDispatchType dispatch_type) { |
| 2678 if (is_swapped_out_) { |
| 2679 OnDiscardInputEvent(&input_event.Event(), |
| 2680 input_event.GetCoalescedEventsPointers(), latency_info, |
| 2681 dispatch_type); |
| 2682 return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 2683 } |
| 2684 idle_user_detector_->ActivityDetected(); |
| 2685 return RenderWidget::HandleInputEvent(input_event, latency_info, |
| 2686 dispatch_type); |
| 2687 } |
| 2688 |
| 2680 } // namespace content | 2689 } // namespace content |
| OLD | NEW |