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