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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "content/child/webmessageportchannel_impl.h" | 46 #include "content/child/webmessageportchannel_impl.h" |
47 #include "content/common/content_constants_internal.h" | 47 #include "content/common/content_constants_internal.h" |
48 #include "content/common/content_switches_internal.h" | 48 #include "content/common/content_switches_internal.h" |
49 #include "content/common/dom_storage/dom_storage_types.h" | 49 #include "content/common/dom_storage/dom_storage_types.h" |
50 #include "content/common/drag_messages.h" | 50 #include "content/common/drag_messages.h" |
51 #include "content/common/frame_messages.h" | 51 #include "content/common/frame_messages.h" |
52 #include "content/common/frame_replication_state.h" | 52 #include "content/common/frame_replication_state.h" |
53 #include "content/common/input_messages.h" | 53 #include "content/common/input_messages.h" |
54 #include "content/common/page_messages.h" | 54 #include "content/common/page_messages.h" |
55 #include "content/common/render_message_filter.mojom.h" | 55 #include "content/common/render_message_filter.mojom.h" |
56 #include "content/common/site_isolation_policy.h" | |
57 #include "content/common/view_messages.h" | 56 #include "content/common/view_messages.h" |
58 #include "content/public/common/bindings_policy.h" | 57 #include "content/public/common/bindings_policy.h" |
59 #include "content/public/common/browser_side_navigation_policy.h" | 58 #include "content/public/common/browser_side_navigation_policy.h" |
60 #include "content/public/common/content_client.h" | 59 #include "content/public/common/content_client.h" |
61 #include "content/public/common/content_constants.h" | 60 #include "content/public/common/content_constants.h" |
62 #include "content/public/common/content_switches.h" | 61 #include "content/public/common/content_switches.h" |
63 #include "content/public/common/favicon_url.h" | 62 #include "content/public/common/favicon_url.h" |
64 #include "content/public/common/page_importance_signals.h" | 63 #include "content/public/common/page_importance_signals.h" |
65 #include "content/public/common/page_state.h" | 64 #include "content/public/common/page_state.h" |
66 #include "content/public/common/page_zoom.h" | 65 #include "content/public/common/page_zoom.h" |
67 #include "content/public/common/three_d_api_types.h" | 66 #include "content/public/common/three_d_api_types.h" |
68 #include "content/public/common/url_constants.h" | 67 #include "content/public/common/url_constants.h" |
69 #include "content/public/common/web_preferences.h" | 68 #include "content/public/common/web_preferences.h" |
70 #include "content/public/renderer/content_renderer_client.h" | 69 #include "content/public/renderer/content_renderer_client.h" |
71 #include "content/public/renderer/document_state.h" | 70 #include "content/public/renderer/document_state.h" |
72 #include "content/public/renderer/navigation_state.h" | 71 #include "content/public/renderer/navigation_state.h" |
73 #include "content/public/renderer/render_view_observer.h" | 72 #include "content/public/renderer/render_view_observer.h" |
74 #include "content/public/renderer/render_view_visitor.h" | 73 #include "content/public/renderer/render_view_visitor.h" |
75 #include "content/renderer/browser_plugin/browser_plugin.h" | 74 #include "content/renderer/browser_plugin/browser_plugin.h" |
76 #include "content/renderer/browser_plugin/browser_plugin_manager.h" | 75 #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
77 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" | 76 #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
78 #include "content/renderer/drop_data_builder.h" | 77 #include "content/renderer/drop_data_builder.h" |
79 #include "content/renderer/gpu/render_widget_compositor.h" | 78 #include "content/renderer/gpu/render_widget_compositor.h" |
80 #include "content/renderer/history_controller.h" | |
81 #include "content/renderer/history_serialization.h" | 79 #include "content/renderer/history_serialization.h" |
82 #include "content/renderer/idle_user_detector.h" | 80 #include "content/renderer/idle_user_detector.h" |
83 #include "content/renderer/ime_event_guard.h" | 81 #include "content/renderer/ime_event_guard.h" |
84 #include "content/renderer/input/input_handler_manager.h" | 82 #include "content/renderer/input/input_handler_manager.h" |
85 #include "content/renderer/internal_document_state_data.h" | 83 #include "content/renderer/internal_document_state_data.h" |
86 #include "content/renderer/media/audio_device_factory.h" | 84 #include "content/renderer/media/audio_device_factory.h" |
87 #include "content/renderer/media/video_capture_impl_manager.h" | 85 #include "content/renderer/media/video_capture_impl_manager.h" |
88 #include "content/renderer/navigation_state_impl.h" | 86 #include "content/renderer/navigation_state_impl.h" |
89 #include "content/renderer/render_frame_impl.h" | 87 #include "content/renderer/render_frame_impl.h" |
90 #include "content/renderer/render_frame_proxy.h" | 88 #include "content/renderer/render_frame_proxy.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 703 |
706 UpdateWebViewWithDeviceScaleFactor(); | 704 UpdateWebViewWithDeviceScaleFactor(); |
707 OnSetRendererPrefs(params.renderer_preferences); | 705 OnSetRendererPrefs(params.renderer_preferences); |
708 | 706 |
709 if (!params.enable_auto_resize) { | 707 if (!params.enable_auto_resize) { |
710 OnResize(params.initial_size); | 708 OnResize(params.initial_size); |
711 } else { | 709 } else { |
712 OnEnableAutoResize(params.min_size, params.max_size); | 710 OnEnableAutoResize(params.min_size, params.max_size); |
713 } | 711 } |
714 | 712 |
715 // We don't use HistoryController in OOPIF-enabled modes. | |
716 if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) | |
717 history_controller_.reset(new HistoryController(this)); | |
718 | |
719 new IdleUserDetector(this); | 713 new IdleUserDetector(this); |
720 | 714 |
721 if (command_line.HasSwitch(switches::kDomAutomationController)) | 715 if (command_line.HasSwitch(switches::kDomAutomationController)) |
722 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; | 716 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
723 if (command_line.HasSwitch(switches::kStatsCollectionController)) | 717 if (command_line.HasSwitch(switches::kStatsCollectionController)) |
724 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; | 718 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
725 | 719 |
726 GetContentClient()->renderer()->RenderViewCreated(this); | 720 GetContentClient()->renderer()->RenderViewCreated(this); |
727 | 721 |
728 // Ensure that sandbox flags are inherited from an opener in a different | 722 // Ensure that sandbox flags are inherited from an opener in a different |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1336 void RenderViewImpl::OnUpdateWindowScreenRect(gfx::Rect window_screen_rect) { | 1330 void RenderViewImpl::OnUpdateWindowScreenRect(gfx::Rect window_screen_rect) { |
1337 RenderWidget::OnUpdateWindowScreenRect(window_screen_rect); | 1331 RenderWidget::OnUpdateWindowScreenRect(window_screen_rect); |
1338 } | 1332 } |
1339 | 1333 |
1340 void RenderViewImpl::OnAudioStateChanged(bool is_audio_playing) { | 1334 void RenderViewImpl::OnAudioStateChanged(bool is_audio_playing) { |
1341 webview()->audioStateChanged(is_audio_playing); | 1335 webview()->audioStateChanged(is_audio_playing); |
1342 } | 1336 } |
1343 | 1337 |
1344 /////////////////////////////////////////////////////////////////////////////// | 1338 /////////////////////////////////////////////////////////////////////////////// |
1345 | 1339 |
1346 void RenderViewImpl::SendUpdateState() { | |
1347 // We don't use this path in OOPIF-enabled modes. | |
1348 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); | |
1349 | |
1350 HistoryEntry* entry = history_controller_->GetCurrentEntry(); | |
1351 if (!entry) | |
1352 return; | |
1353 | |
1354 Send(new ViewHostMsg_UpdateState(GetRoutingID(), | |
1355 HistoryEntryToPageState(entry))); | |
1356 } | |
1357 | |
1358 void RenderViewImpl::ShowCreatedPopupWidget(RenderWidget* popup_widget, | 1340 void RenderViewImpl::ShowCreatedPopupWidget(RenderWidget* popup_widget, |
1359 WebNavigationPolicy policy, | 1341 WebNavigationPolicy policy, |
1360 const gfx::Rect& initial_rect) { | 1342 const gfx::Rect& initial_rect) { |
1361 Send(new ViewHostMsg_ShowWidget(GetRoutingID(), popup_widget->routing_id(), | 1343 Send(new ViewHostMsg_ShowWidget(GetRoutingID(), popup_widget->routing_id(), |
1362 initial_rect)); | 1344 initial_rect)); |
1363 } | 1345 } |
1364 | 1346 |
1365 void RenderViewImpl::ShowCreatedFullscreenWidget( | 1347 void RenderViewImpl::ShowCreatedFullscreenWidget( |
1366 RenderWidget* fullscreen_widget, | 1348 RenderWidget* fullscreen_widget, |
1367 WebNavigationPolicy policy, | 1349 WebNavigationPolicy policy, |
1368 const gfx::Rect& initial_rect) { | 1350 const gfx::Rect& initial_rect) { |
1369 Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(), | 1351 Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(), |
1370 fullscreen_widget->routing_id())); | 1352 fullscreen_widget->routing_id())); |
1371 } | 1353 } |
1372 | 1354 |
1373 void RenderViewImpl::SendFrameStateUpdates() { | 1355 void RenderViewImpl::SendFrameStateUpdates() { |
1374 // We only use this path in OOPIF-enabled modes. | |
1375 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); | |
1376 | |
1377 // Tell each frame with pending state to send its UpdateState message. | 1356 // Tell each frame with pending state to send its UpdateState message. |
1378 for (int render_frame_routing_id : frames_with_pending_state_) { | 1357 for (int render_frame_routing_id : frames_with_pending_state_) { |
1379 RenderFrameImpl* frame = | 1358 RenderFrameImpl* frame = |
1380 RenderFrameImpl::FromRoutingID(render_frame_routing_id); | 1359 RenderFrameImpl::FromRoutingID(render_frame_routing_id); |
1381 if (frame) | 1360 if (frame) |
1382 frame->SendUpdateState(); | 1361 frame->SendUpdateState(); |
1383 } | 1362 } |
1384 frames_with_pending_state_.clear(); | 1363 frames_with_pending_state_.clear(); |
1385 } | 1364 } |
1386 | 1365 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 } | 1653 } |
1675 | 1654 |
1676 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( | 1655 gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( |
1677 const gfx::RectF& rect) const { | 1656 const gfx::RectF& rect) const { |
1678 gfx::RectF window_rect = rect; | 1657 gfx::RectF window_rect = rect; |
1679 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); | 1658 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); |
1680 return window_rect; | 1659 return window_rect; |
1681 } | 1660 } |
1682 | 1661 |
1683 void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { | 1662 void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { |
1684 // In OOPIF modes, keep track of which frames have pending updates. | 1663 // Keep track of which frames have pending updates. |
1685 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) | 1664 frames_with_pending_state_.insert(frame->GetRoutingID()); |
1686 frames_with_pending_state_.insert(frame->GetRoutingID()); | |
1687 | 1665 |
1688 int delay; | 1666 int delay; |
1689 if (send_content_state_immediately_) | 1667 if (send_content_state_immediately_) |
1690 delay = 0; | 1668 delay = 0; |
1691 else if (is_hidden()) | 1669 else if (is_hidden()) |
1692 delay = kDelaySecondsForContentStateSyncHidden; | 1670 delay = kDelaySecondsForContentStateSyncHidden; |
1693 else | 1671 else |
1694 delay = kDelaySecondsForContentStateSync; | 1672 delay = kDelaySecondsForContentStateSync; |
1695 | 1673 |
1696 if (nav_state_sync_timer_.IsRunning()) { | 1674 if (nav_state_sync_timer_.IsRunning()) { |
1697 // The timer is already running. If the delay of the timer maches the amount | 1675 // The timer is already running. If the delay of the timer maches the amount |
1698 // we want to delay by, then return. Otherwise stop the timer so that it | 1676 // we want to delay by, then return. Otherwise stop the timer so that it |
1699 // gets started with the right delay. | 1677 // gets started with the right delay. |
1700 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) | 1678 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
1701 return; | 1679 return; |
1702 nav_state_sync_timer_.Stop(); | 1680 nav_state_sync_timer_.Stop(); |
1703 } | 1681 } |
1704 | 1682 |
1705 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 1683 // Tell each frame with pending state to inform the browser. |
1706 // In OOPIF modes, tell each frame with pending state to inform the browser. | 1684 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
1707 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, | 1685 &RenderViewImpl::SendFrameStateUpdates); |
1708 &RenderViewImpl::SendFrameStateUpdates); | |
1709 } else { | |
1710 // By default, send an UpdateState for the current history item. | |
1711 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, | |
1712 &RenderViewImpl::SendUpdateState); | |
1713 } | |
1714 } | 1686 } |
1715 | 1687 |
1716 void RenderViewImpl::setMouseOverURL(const WebURL& url) { | 1688 void RenderViewImpl::setMouseOverURL(const WebURL& url) { |
1717 mouse_over_url_ = GURL(url); | 1689 mouse_over_url_ = GURL(url); |
1718 UpdateTargetURL(mouse_over_url_, focus_url_); | 1690 UpdateTargetURL(mouse_over_url_, focus_url_); |
1719 } | 1691 } |
1720 | 1692 |
1721 void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { | 1693 void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { |
1722 focus_url_ = GURL(url); | 1694 focus_url_ = GURL(url); |
1723 UpdateTargetURL(focus_url_, mouse_over_url_); | 1695 UpdateTargetURL(focus_url_, mouse_over_url_); |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2728 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2700 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2729 } | 2701 } |
2730 | 2702 |
2731 std::unique_ptr<InputEventAck> ack( | 2703 std::unique_ptr<InputEventAck> ack( |
2732 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type(), | 2704 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type(), |
2733 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 2705 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
2734 OnInputEventAck(std::move(ack)); | 2706 OnInputEventAck(std::move(ack)); |
2735 } | 2707 } |
2736 | 2708 |
2737 } // namespace content | 2709 } // namespace content |
OLD | NEW |