[email protected] | b553edd5 | 2012-01-10 12:15:23 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5 | #include "content/renderer/render_view_impl.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 6 | |
| 7 | #include <algorithm> |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 8 | #include <cmath> |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 9 | #include <memory> |
lukasza | 5d0dee4 | 2017-06-14 21:57:37 | [diff] [blame] | 10 | #include <utility> |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 11 | |
[email protected] | 5d4e36d | 2013-02-15 15:18:20 | [diff] [blame] | 12 | #include "base/auto_reset.h" |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 13 | #include "base/bind.h" |
| 14 | #include "base/bind_helpers.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 15 | #include "base/command_line.h" |
[email protected] | bb063b7 | 2009-03-27 23:18:50 | [diff] [blame] | 16 | #include "base/compiler_specific.h" |
[email protected] | 2132d6b | 2013-06-05 00:15:43 | [diff] [blame] | 17 | #include "base/debug/alias.h" |
avayvod | 23275794 | 2017-04-29 04:12:34 | [diff] [blame] | 18 | #include "base/feature_list.h" |
[email protected] | 728c2ee | 2013-06-25 04:01:07 | [diff] [blame] | 19 | #include "base/files/file_path.h" |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 20 | #include "base/i18n/rtl.h" |
[email protected] | b1cf337 | 2011-04-20 21:28:10 | [diff] [blame] | 21 | #include "base/json/json_writer.h" |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 22 | #include "base/lazy_instance.h" |
fdoray | 7a8954a4 | 2016-06-07 04:28:38 | [diff] [blame] | 23 | #include "base/location.h" |
[email protected] | f29efe6b | 2014-06-09 05:01:51 | [diff] [blame] | 24 | #include "base/metrics/field_trial.h" |
[email protected] | d3b4ee2 | 2013-07-24 22:50:06 | [diff] [blame] | 25 | #include "base/process/kill.h" |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 26 | #include "base/process/process.h" |
fdoray | 7a8954a4 | 2016-06-07 04:28:38 | [diff] [blame] | 27 | #include "base/single_thread_task_runner.h" |
danakj | a4ba7e5 | 2018-11-29 23:04:31 | [diff] [blame] | 28 | #include "base/stl_util.h" |
[email protected] | 21aa9968 | 2013-06-11 07:17:01 | [diff] [blame] | 29 | #include "base/strings/string_number_conversions.h" |
[email protected] | b9e7c479f | 2013-04-12 04:33:24 | [diff] [blame] | 30 | #include "base/strings/string_piece.h" |
[email protected] | 27c0573 | 2013-02-15 21:55:49 | [diff] [blame] | 31 | #include "base/strings/string_split.h" |
[email protected] | 21aa9968 | 2013-06-11 07:17:01 | [diff] [blame] | 32 | #include "base/strings/string_util.h" |
[email protected] | 40d11e0 | 2013-03-28 17:43:14 | [diff] [blame] | 33 | #include "base/strings/sys_string_conversions.h" |
[email protected] | 74ebfb1 | 2013-06-07 20:48:00 | [diff] [blame] | 34 | #include "base/strings/utf_string_conversions.h" |
Sebastien Marchand | 75a7cdf | 2018-11-13 23:47:03 | [diff] [blame] | 35 | #include "base/system/sys_info.h" |
fdoray | 7a8954a4 | 2016-06-07 04:28:38 | [diff] [blame] | 36 | #include "base/threading/thread_task_runner_handle.h" |
[email protected] | abb52216 | 2013-06-28 01:54:16 | [diff] [blame] | 37 | #include "base/time/time.h" |
primiano | 9e38d55 | 2015-01-28 04:18:01 | [diff] [blame] | 38 | #include "base/trace_event/trace_event.h" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 39 | #include "build/build_config.h" |
dongseong.hwang | e095dfa | 2016-02-04 11:21:39 | [diff] [blame] | 40 | #include "cc/base/switches.h" |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 41 | #include "cc/paint/skia_paint_canvas.h" |
danakj | 4c98765 | 2018-07-05 15:49:41 | [diff] [blame] | 42 | #include "cc/trees/layer_tree_host.h" |
jinho.bang | 632a1a72 | 2014-09-18 03:02:56 | [diff] [blame] | 43 | #include "content/common/content_constants_internal.h" |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 44 | #include "content/common/dom_storage/dom_storage_types.h" |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 45 | #include "content/common/drag_messages.h" |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 46 | #include "content/common/frame_messages.h" |
alexmos | bc7eafa | 2014-12-06 01:38:09 | [diff] [blame] | 47 | #include "content/common/frame_replication_state.h" |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 48 | #include "content/common/input_messages.h" |
lfg | db5c4ed | 2016-03-04 23:09:07 | [diff] [blame] | 49 | #include "content/common/page_messages.h" |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 50 | #include "content/common/render_message_filter.mojom.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 51 | #include "content/common/view_messages.h" |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 52 | #include "content/public/common/content_client.h" |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 53 | #include "content/public/common/content_constants.h" |
Tarun Bansal | 73dd2ff8 | 2017-10-03 05:29:34 | [diff] [blame] | 54 | #include "content/public/common/content_features.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 55 | #include "content/public/common/content_switches.h" |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 56 | #include "content/public/common/page_importance_signals.h" |
clamy | da97e832 | 2014-10-07 21:57:25 | [diff] [blame] | 57 | #include "content/public/common/page_state.h" |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 58 | #include "content/public/common/page_zoom.h" |
Leon Han | 963dc18 | 2018-11-06 05:41:48 | [diff] [blame] | 59 | #include "content/public/common/referrer_type_converters.h" |
[email protected] | 818915cd | 2012-11-20 13:14:11 | [diff] [blame] | 60 | #include "content/public/common/three_d_api_types.h" |
[email protected] | a1d2916 | 2011-10-14 17:14:03 | [diff] [blame] | 61 | #include "content/public/common/url_constants.h" |
Jaebaek Seo | 53ab80a66 | 2018-01-29 04:50:46 | [diff] [blame] | 62 | #include "content/public/common/use_zoom_for_dsf_policy.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 63 | #include "content/public/common/web_preferences.h" |
[email protected] | d344114c | 2011-10-01 01:24:34 | [diff] [blame] | 64 | #include "content/public/renderer/content_renderer_client.h" |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 65 | #include "content/public/renderer/document_state.h" |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 66 | #include "content/public/renderer/render_thread.h" |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 67 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 68 | #include "content/public/renderer/render_view_visitor.h" |
scottmg | 8e6c608 | 2017-02-13 23:15:48 | [diff] [blame] | 69 | #include "content/public/renderer/window_features_converter.h" |
[email protected] | e6e5675 | 2012-08-10 00:46:06 | [diff] [blame] | 70 | #include "content/renderer/browser_plugin/browser_plugin.h" |
| 71 | #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
Sadrul Habib Chowdhury | 31c9871 | 2018-12-11 04:15:13 | [diff] [blame] | 72 | #include "content/renderer/compositor/layer_tree_view.h" |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 73 | #include "content/renderer/drop_data_builder.h" |
[email protected] | dc06435 | 2014-04-25 08:36:38 | [diff] [blame] | 74 | #include "content/renderer/history_serialization.h" |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 75 | #include "content/renderer/ime_event_guard.h" |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 76 | #include "content/renderer/internal_document_state_data.h" |
John Abd-El-Malek | 6b56ef71 | 2017-10-21 22:52:46 | [diff] [blame] | 77 | #include "content/renderer/loader/request_extra_data.h" |
Amos Lim | bcc710e | 2018-06-08 05:51:17 | [diff] [blame] | 78 | #include "content/renderer/media/audio/audio_device_factory.h" |
Miguel Casas | a8c2c5a | 2018-02-12 18:51:03 | [diff] [blame] | 79 | #include "content/renderer/media/stream/media_stream_device_observer.h" |
Guido Urdaneta | bd7f096 | 2019-03-25 17:52:02 | [diff] [blame] | 80 | #include "content/renderer/media/video_capture/video_capture_impl_manager.h" |
Patrik Höglund | b564859b | 2018-05-17 11:17:16 | [diff] [blame] | 81 | #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
| 82 | #include "content/renderer/media/webrtc/rtc_peer_connection_handler.h" |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 83 | #include "content/renderer/render_frame_impl.h" |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 84 | #include "content/renderer/render_frame_proxy.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 85 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 86 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 87 | #include "content/renderer/render_widget_fullscreen_pepper.h" |
Daniel Murphy | e3eec92c | 2018-02-23 19:09:15 | [diff] [blame] | 88 | #include "content/renderer/renderer_blink_platform_impl.h" |
[email protected] | 12a936d | 2013-05-15 04:55:49 | [diff] [blame] | 89 | #include "content/renderer/savable_resources.h" |
John Abd-El-Malek | 312a30bb | 2017-10-23 19:51:52 | [diff] [blame] | 90 | #include "content/renderer/v8_value_converter_impl.h" |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 91 | #include "content/renderer/web_ui_extension_data.h" |
[email protected] | f596114 | 2013-04-17 23:09:42 | [diff] [blame] | 92 | #include "media/audio/audio_output_device.h" |
[email protected] | ee68378a | 2010-08-10 01:05:41 | [diff] [blame] | 93 | #include "media/base/media_switches.h" |
Scott Violet | a35f9a4 | 2018-03-22 22:00:44 | [diff] [blame] | 94 | #include "media/media_buildflags.h" |
servolk | f54f5c8f | 2015-02-24 20:32:39 | [diff] [blame] | 95 | #include "media/renderers/audio_renderer_impl.h" |
Dale Curtis | 863022e | 2017-08-19 02:05:34 | [diff] [blame] | 96 | #include "media/video/gpu_video_accelerator_factories.h" |
[email protected] | d1ef81d | 2012-07-24 11:39:36 | [diff] [blame] | 97 | #include "net/base/data_url.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 98 | #include "net/base/escape.h" |
| 99 | #include "net/base/net_errors.h" |
[email protected] | 18fb7a77 | 2012-09-20 19:25:09 | [diff] [blame] | 100 | #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 101 | #include "net/http/http_util.h" |
Tarun Bansal | 73d67f0 | 2018-01-17 05:56:25 | [diff] [blame] | 102 | #include "net/nqe/effective_connection_type.h" |
Scott Violet | 02e38b9 | 2018-03-27 23:42:14 | [diff] [blame] | 103 | #include "ppapi/buildflags/buildflags.h" |
luken | b171b53 | 2014-09-24 05:50:38 | [diff] [blame] | 104 | #include "skia/ext/platform_canvas.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 105 | #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 106 | #include "third_party/blink/public/common/dom_storage/session_storage_namespace_id.h" |
Mustaq Ahmed | 76c2f431 | 2018-06-07 20:48:01 | [diff] [blame] | 107 | #include "third_party/blink/public/common/frame/user_activation_update_source.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 108 | #include "third_party/blink/public/platform/file_path_conversion.h" |
| 109 | #include "third_party/blink/public/platform/url_conversion.h" |
| 110 | #include "third_party/blink/public/platform/web_connection_type.h" |
| 111 | #include "third_party/blink/public/platform/web_effective_connection_type.h" |
| 112 | #include "third_party/blink/public/platform/web_http_body.h" |
| 113 | #include "third_party/blink/public/platform/web_image.h" |
| 114 | #include "third_party/blink/public/platform/web_input_event.h" |
| 115 | #include "third_party/blink/public/platform/web_input_event_result.h" |
| 116 | #include "third_party/blink/public/platform/web_network_state_notifier.h" |
| 117 | #include "third_party/blink/public/platform/web_point.h" |
| 118 | #include "third_party/blink/public/platform/web_rect.h" |
| 119 | #include "third_party/blink/public/platform/web_runtime_features.h" |
| 120 | #include "third_party/blink/public/platform/web_size.h" |
| 121 | #include "third_party/blink/public/platform/web_string.h" |
W. James MacLean | 6219867 | 2019-06-04 16:46:10 | [diff] [blame] | 122 | #include "third_party/blink/public/platform/web_text_autosizer_page_info.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 123 | #include "third_party/blink/public/platform/web_url.h" |
| 124 | #include "third_party/blink/public/platform/web_url_error.h" |
| 125 | #include "third_party/blink/public/platform/web_url_request.h" |
| 126 | #include "third_party/blink/public/platform/web_url_response.h" |
| 127 | #include "third_party/blink/public/platform/web_vector.h" |
| 128 | #include "third_party/blink/public/public_buildflags.h" |
| 129 | #include "third_party/blink/public/web/web_autofill_client.h" |
| 130 | #include "third_party/blink/public/web/web_ax_object.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 131 | #include "third_party/blink/public/web/web_document.h" |
| 132 | #include "third_party/blink/public/web/web_dom_event.h" |
| 133 | #include "third_party/blink/public/web/web_dom_message_event.h" |
| 134 | #include "third_party/blink/public/web/web_element.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 135 | #include "third_party/blink/public/web/web_form_control_element.h" |
| 136 | #include "third_party/blink/public/web/web_form_element.h" |
| 137 | #include "third_party/blink/public/web/web_frame.h" |
| 138 | #include "third_party/blink/public/web/web_frame_content_dumper.h" |
| 139 | #include "third_party/blink/public/web/web_frame_widget.h" |
| 140 | #include "third_party/blink/public/web/web_history_item.h" |
| 141 | #include "third_party/blink/public/web/web_hit_test_result.h" |
| 142 | #include "third_party/blink/public/web/web_input_element.h" |
| 143 | #include "third_party/blink/public/web/web_local_frame.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 144 | #include "third_party/blink/public/web/web_navigation_policy.h" |
| 145 | #include "third_party/blink/public/web/web_page_importance_signals.h" |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 146 | #include "third_party/blink/public/web/web_page_popup.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 147 | #include "third_party/blink/public/web/web_plugin.h" |
| 148 | #include "third_party/blink/public/web/web_plugin_action.h" |
| 149 | #include "third_party/blink/public/web/web_range.h" |
| 150 | #include "third_party/blink/public/web/web_render_theme.h" |
| 151 | #include "third_party/blink/public/web/web_script_source.h" |
| 152 | #include "third_party/blink/public/web/web_searchable_form_data.h" |
| 153 | #include "third_party/blink/public/web/web_security_policy.h" |
| 154 | #include "third_party/blink/public/web/web_settings.h" |
| 155 | #include "third_party/blink/public/web/web_user_gesture_indicator.h" |
| 156 | #include "third_party/blink/public/web/web_view.h" |
| 157 | #include "third_party/blink/public/web/web_window_features.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 158 | #include "third_party/icu/source/common/unicode/uchar.h" |
| 159 | #include "third_party/icu/source/common/unicode/uscript.h" |
eseckler | f2bd55f7 | 2017-03-31 09:11:57 | [diff] [blame] | 160 | #include "third_party/skia/include/core/SkColor.h" |
[email protected] | 1400e6dc | 2013-04-27 02:36:27 | [diff] [blame] | 161 | #include "ui/base/ui_base_switches_util.h" |
tfarina | 655f81d | 2014-12-23 02:38:50 | [diff] [blame] | 162 | #include "ui/gfx/geometry/point.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 163 | #include "ui/gfx/geometry/rect.h" |
| 164 | #include "ui/gfx/geometry/rect_conversions.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 165 | #include "ui/gfx/geometry/size_conversions.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 166 | #include "ui/gfx/native_widget_types.h" |
ccameron | 772317d | 2017-06-04 18:35:03 | [diff] [blame] | 167 | #include "ui/gfx/switches.h" |
mfomitchev | 3ba450ad | 2017-04-03 18:20:40 | [diff] [blame] | 168 | #include "ui/latency/latency_info.h" |
csharrison | d88f975 | 2016-10-26 23:56:36 | [diff] [blame] | 169 | #include "url/origin.h" |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 170 | #include "url/url_constants.h" |
[email protected] | c4a9e93 | 2011-03-05 04:05:55 | [diff] [blame] | 171 | #include "v8/include/v8.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 172 | |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 173 | #if defined(OS_ANDROID) |
[email protected] | befe5478 | 2013-04-23 00:49:25 | [diff] [blame] | 174 | #include <cpu-features.h> |
| 175 | |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 176 | #include "base/android/build_info.h" |
kylechar | e7d8d5c7 | 2018-01-05 19:06:28 | [diff] [blame] | 177 | #include "base/memory/shared_memory.h" |
| 178 | #include "content/child/child_thread_impl.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 179 | #include "ui/gfx/geometry/rect_f.h" |
[email protected] | e69bb06 | 2013-06-03 13:05:40 | [diff] [blame] | 180 | |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 181 | #elif defined(OS_MACOSX) |
| 182 | #include "skia/ext/skia_utils_mac.h" |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 183 | #endif |
| 184 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 185 | #if BUILDFLAG(ENABLE_PLUGINS) |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 186 | #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 187 | #include "content/renderer/pepper/pepper_plugin_registry.h" |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 188 | #endif |
| 189 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 190 | using blink::WebAXObject; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 191 | using blink::WebConsoleMessage; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 192 | using blink::WebData; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 193 | using blink::WebDocument; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 194 | using blink::WebDragOperation; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 195 | using blink::WebElement; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 196 | using blink::WebFormControlElement; |
| 197 | using blink::WebFormElement; |
| 198 | using blink::WebFrame; |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 199 | using blink::WebFrameContentDumper; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 200 | using blink::WebGestureEvent; |
| 201 | using blink::WebHistoryItem; |
| 202 | using blink::WebHTTPBody; |
dglazkov | 8d0c21dd | 2016-08-06 15:56:36 | [diff] [blame] | 203 | using blink::WebHitTestResult; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 204 | using blink::WebImage; |
| 205 | using blink::WebInputElement; |
| 206 | using blink::WebInputEvent; |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 207 | using blink::WebLocalFrame; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 208 | using blink::WebMouseEvent; |
| 209 | using blink::WebNavigationPolicy; |
| 210 | using blink::WebNavigationType; |
| 211 | using blink::WebNode; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 212 | using blink::WebPluginAction; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 213 | using blink::WebPoint; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 214 | using blink::WebRect; |
Daniel Cheng | d5e56ff | 2017-06-24 07:44:02 | [diff] [blame] | 215 | using blink::WebSandboxFlags; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 216 | using blink::WebScriptSource; |
| 217 | using blink::WebSearchableFormData; |
| 218 | using blink::WebSecurityOrigin; |
| 219 | using blink::WebSecurityPolicy; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 220 | using blink::WebSettings; |
| 221 | using blink::WebSize; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 222 | using blink::WebString; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 223 | using blink::WebTextDirection; |
| 224 | using blink::WebTouchEvent; |
| 225 | using blink::WebURL; |
| 226 | using blink::WebURLError; |
| 227 | using blink::WebURLRequest; |
| 228 | using blink::WebURLResponse; |
| 229 | using blink::WebUserGestureIndicator; |
| 230 | using blink::WebVector; |
| 231 | using blink::WebView; |
| 232 | using blink::WebWidget; |
| 233 | using blink::WebWindowFeatures; |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 234 | using blink::WebRuntimeFeatures; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 235 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 236 | namespace content { |
| 237 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 238 | //----------------------------------------------------------------------------- |
| 239 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 240 | typedef std::map<blink::WebView*, RenderViewImpl*> ViewMap; |
jbroman | 8319b23 | 2017-03-08 22:53:29 | [diff] [blame] | 241 | static base::LazyInstance<ViewMap>::Leaky g_view_map = |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 242 | LAZY_INSTANCE_INITIALIZER; |
scottmg | 5e65e3a | 2017-03-08 08:48:46 | [diff] [blame] | 243 | typedef std::map<int32_t, RenderViewImpl*> RoutingIDViewMap; |
jbroman | 8319b23 | 2017-03-08 22:53:29 | [diff] [blame] | 244 | static base::LazyInstance<RoutingIDViewMap>::Leaky g_routing_id_view_map = |
| 245 | LAZY_INSTANCE_INITIALIZER; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 246 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 247 | // Time, in seconds, we delay before sending content state changes (such as form |
| 248 | // state and scroll position) to the browser. We delay sending changes to avoid |
| 249 | // spamming the browser. |
| 250 | // To avoid having tab/session restore require sending a message to get the |
| 251 | // current content state during tab closing we use a shorter timeout for the |
| 252 | // foreground renderer. This means there is a small window of time from which |
| 253 | // content state is modified and not sent to session restore, but this is |
| 254 | // better than having to wake up all renderers during shutdown. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 255 | const int kDelaySecondsForContentStateSyncHidden = 5; |
| 256 | const int kDelaySecondsForContentStateSync = 1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 257 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 258 | static RenderViewImpl* (*g_create_render_view_impl)( |
| 259 | CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 260 | const mojom::CreateViewParams&) = nullptr; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 261 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 262 | // static |
[email protected] | e507045d | 2013-07-24 15:23:44 | [diff] [blame] | 263 | Referrer RenderViewImpl::GetReferrerFromRequest( |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 264 | WebFrame* frame, |
| 265 | const WebURLRequest& request) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 266 | return Referrer(blink::WebStringToGURL( |
| 267 | request.HttpHeaderField(WebString::FromUTF8("Referer"))), |
| 268 | request.GetReferrerPolicy()); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 269 | } |
| 270 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 271 | // static |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 272 | WindowOpenDisposition RenderViewImpl::NavigationPolicyToDisposition( |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 273 | WebNavigationPolicy policy) { |
| 274 | switch (policy) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 275 | case blink::kWebNavigationPolicyDownload: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 276 | return WindowOpenDisposition::SAVE_TO_DISK; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 277 | case blink::kWebNavigationPolicyCurrentTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 278 | return WindowOpenDisposition::CURRENT_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 279 | case blink::kWebNavigationPolicyNewBackgroundTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 280 | return WindowOpenDisposition::NEW_BACKGROUND_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 281 | case blink::kWebNavigationPolicyNewForegroundTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 282 | return WindowOpenDisposition::NEW_FOREGROUND_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 283 | case blink::kWebNavigationPolicyNewWindow: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 284 | return WindowOpenDisposition::NEW_WINDOW; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 285 | case blink::kWebNavigationPolicyNewPopup: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 286 | return WindowOpenDisposition::NEW_POPUP; |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 287 | default: |
| 288 | NOTREACHED() << "Unexpected WebNavigationPolicy"; |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 289 | return WindowOpenDisposition::IGNORE_ACTION; |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 293 | /////////////////////////////////////////////////////////////////////////////// |
| 294 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 295 | namespace { |
| 296 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 297 | typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, |
| 298 | const base::string16&, |
| 299 | UScriptCode); |
| 300 | |
| 301 | void SetStandardFontFamilyWrapper(WebSettings* settings, |
| 302 | const base::string16& font, |
| 303 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 304 | settings->SetStandardFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | void SetFixedFontFamilyWrapper(WebSettings* settings, |
| 308 | const base::string16& font, |
| 309 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 310 | settings->SetFixedFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | void SetSerifFontFamilyWrapper(WebSettings* settings, |
| 314 | const base::string16& font, |
| 315 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 316 | settings->SetSerifFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 317 | } |
| 318 | |
| 319 | void SetSansSerifFontFamilyWrapper(WebSettings* settings, |
| 320 | const base::string16& font, |
| 321 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 322 | settings->SetSansSerifFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | void SetCursiveFontFamilyWrapper(WebSettings* settings, |
| 326 | const base::string16& font, |
| 327 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 328 | settings->SetCursiveFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | void SetFantasyFontFamilyWrapper(WebSettings* settings, |
| 332 | const base::string16& font, |
| 333 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 334 | settings->SetFantasyFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | void SetPictographFontFamilyWrapper(WebSettings* settings, |
| 338 | const base::string16& font, |
| 339 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 340 | settings->SetPictographFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | // If |scriptCode| is a member of a family of "similar" script codes, returns |
| 344 | // the script code in that family that is used by WebKit for font selection |
| 345 | // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are |
| 346 | // considered equivalent for the purposes of font selection. WebKit uses the |
| 347 | // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is |
| 348 | // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit |
| 349 | // uses different scripts than the ones in Chrome pref names because the version |
| 350 | // of ICU included on certain ports does not have some of the newer scripts. If |
| 351 | // |scriptCode| is not a member of such a family, returns |scriptCode|. |
| 352 | UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) { |
| 353 | switch (scriptCode) { |
| 354 | case USCRIPT_HIRAGANA: |
| 355 | case USCRIPT_KATAKANA: |
| 356 | case USCRIPT_JAPANESE: |
| 357 | return USCRIPT_KATAKANA_OR_HIRAGANA; |
| 358 | case USCRIPT_KOREAN: |
| 359 | return USCRIPT_HANGUL; |
| 360 | default: |
| 361 | return scriptCode; |
| 362 | } |
| 363 | } |
| 364 | |
| 365 | void ApplyFontsFromMap(const ScriptFontFamilyMap& map, |
| 366 | SetFontFamilyWrapper setter, |
| 367 | WebSettings* settings) { |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 368 | for (auto it = map.begin(); it != map.end(); ++it) { |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 369 | int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 370 | if (script >= 0 && script < USCRIPT_CODE_LIMIT) { |
| 371 | UScriptCode code = static_cast<UScriptCode>(script); |
| 372 | (*setter)(settings, it->second, GetScriptForWebSettings(code)); |
| 373 | } |
| 374 | } |
| 375 | } |
| 376 | |
danakj | efcb843 | 2019-01-16 18:47:14 | [diff] [blame] | 377 | void ApplyCommandLineToSettings(WebSettings* settings) { |
| 378 | const base::CommandLine& command_line = |
| 379 | *base::CommandLine::ForCurrentProcess(); |
| 380 | |
danakj | ed946461 | 2019-01-16 00:00:59 | [diff] [blame] | 381 | settings->SetThreadedScrollingEnabled( |
| 382 | !command_line.HasSwitch(switches::kDisableThreadedScrolling)); |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 383 | |
danakj | ed946461 | 2019-01-16 00:00:59 | [diff] [blame] | 384 | if (switches::IsTouchDragDropEnabled()) |
| 385 | settings->SetTouchDragDropEnabled(true); |
| 386 | |
| 387 | WebSettings::SelectionStrategyType selection_strategy; |
| 388 | if (command_line.GetSwitchValueASCII(switches::kTouchTextSelectionStrategy) == |
| 389 | "direction") |
| 390 | selection_strategy = WebSettings::SelectionStrategyType::kDirection; |
| 391 | else |
| 392 | selection_strategy = WebSettings::SelectionStrategyType::kCharacter; |
| 393 | settings->SetSelectionStrategy(selection_strategy); |
| 394 | |
| 395 | std::string passive_listeners_default = |
| 396 | command_line.GetSwitchValueASCII(switches::kPassiveListenersDefault); |
| 397 | if (!passive_listeners_default.empty()) { |
| 398 | WebSettings::PassiveEventListenerDefault passive_default = |
| 399 | WebSettings::PassiveEventListenerDefault::kFalse; |
| 400 | if (passive_listeners_default == "true") |
| 401 | passive_default = WebSettings::PassiveEventListenerDefault::kTrue; |
| 402 | else if (passive_listeners_default == "forcealltrue") |
| 403 | passive_default = WebSettings::PassiveEventListenerDefault::kForceAllTrue; |
| 404 | settings->SetPassiveEventListenerDefault(passive_default); |
| 405 | } |
| 406 | |
| 407 | std::string network_quiet_timeout = |
| 408 | command_line.GetSwitchValueASCII(switches::kNetworkQuietTimeout); |
| 409 | if (!network_quiet_timeout.empty()) { |
| 410 | double network_quiet_timeout_seconds = 0.0; |
| 411 | if (base::StringToDouble(network_quiet_timeout, |
| 412 | &network_quiet_timeout_seconds)) |
| 413 | settings->SetNetworkQuietTimeout(network_quiet_timeout_seconds); |
| 414 | } |
| 415 | |
| 416 | if (command_line.HasSwitch(switches::kBlinkSettings)) { |
| 417 | std::vector<std::string> blink_settings = base::SplitString( |
| 418 | command_line.GetSwitchValueASCII(switches::kBlinkSettings), ",", |
| 419 | base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 420 | for (const std::string& setting : blink_settings) { |
| 421 | size_t pos = setting.find('='); |
| 422 | settings->SetFromStrings( |
| 423 | blink::WebString::FromLatin1(setting.substr(0, pos)), |
| 424 | blink::WebString::FromLatin1( |
| 425 | pos == std::string::npos ? "" : setting.substr(pos + 1))); |
| 426 | } |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 427 | } |
| 428 | } |
| 429 | |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 430 | content::mojom::WindowContainerType WindowFeaturesToContainerType( |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 431 | const blink::WebWindowFeatures& window_features) { |
japhet | bfc4789 | 2017-06-02 23:01:19 | [diff] [blame] | 432 | if (window_features.background) { |
| 433 | if (window_features.persistent) |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 434 | return content::mojom::WindowContainerType::PERSISTENT; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 435 | else |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 436 | return content::mojom::WindowContainerType::BACKGROUND; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 437 | } else { |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 438 | return content::mojom::WindowContainerType::NORMAL; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 439 | } |
| 440 | } |
| 441 | |
Ahmed Fakhry | 58e6ef54 | 2018-09-04 18:05:38 | [diff] [blame] | 442 | // Check content::BrowserControlsState, and cc::BrowserControlsState |
| 443 | // are kept in sync. |
| 444 | static_assert(int(BROWSER_CONTROLS_STATE_SHOWN) == |
| 445 | int(cc::BrowserControlsState::kShown), |
| 446 | "mismatching enums: SHOWN"); |
| 447 | static_assert(int(BROWSER_CONTROLS_STATE_HIDDEN) == |
| 448 | int(cc::BrowserControlsState::kHidden), |
| 449 | "mismatching enums: HIDDEN"); |
| 450 | static_assert(int(BROWSER_CONTROLS_STATE_BOTH) == |
| 451 | int(cc::BrowserControlsState::kBoth), |
| 452 | "mismatching enums: BOTH"); |
| 453 | |
| 454 | cc::BrowserControlsState ContentToCc(BrowserControlsState state) { |
| 455 | return static_cast<cc::BrowserControlsState>(state); |
| 456 | } |
Ahmed Fakhry | 58e6ef54 | 2018-09-04 18:05:38 | [diff] [blame] | 457 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 458 | } // namespace |
| 459 | |
Hajime Hoshi | 315a61f | 2018-08-14 17:27:28 | [diff] [blame] | 460 | RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, |
| 461 | const mojom::CreateViewParams& params) |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 462 | : routing_id_(params.view_id), |
danakj | 73dd303 | 2018-07-28 17:49:53 | [diff] [blame] | 463 | renderer_wide_named_frame_lookup_( |
| 464 | params.renderer_wide_named_frame_lookup), |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 465 | webkit_preferences_(params.web_preferences), |
Jeremy Roman | 3bca4bf | 2019-07-11 03:41:25 | [diff] [blame] | 466 | session_storage_namespace_id_(params.session_storage_namespace_id) { |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 467 | DCHECK(!session_storage_namespace_id_.empty()) |
| 468 | << "Session storage namespace must be populated."; |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 469 | // Please put all logic in RenderViewImpl::Initialize(). |
| 470 | } |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 471 | |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 472 | void RenderViewImpl::Initialize( |
| 473 | RenderWidget* render_widget, |
| 474 | mojom::CreateViewParamsPtr params, |
| 475 | RenderWidget::ShowCallback show_callback, |
| 476 | scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 477 | DCHECK(RenderThread::IsMainThread()); |
| 478 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 479 | // RenderView used to inherit from RenderWidget. Creating a delegate |
| 480 | // interface and explicitly passing ownership of ourselves to the |
| 481 | // RenderWidget preserves the lifetime semantics. This is a stepping |
| 482 | // stone to having RenderWidget creation taken out of the RenderViewImpl |
| 483 | // constructor. See the corresponding explicit reset() of the delegate |
| 484 | // in the ~RenderWidget(). Also, I hate inheritance. |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 485 | render_widget_ = render_widget; |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 486 | GetWidget()->set_delegate(base::WrapUnique(this)); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 487 | RenderThread::Get()->AddRoute(routing_id_, this); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 488 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 489 | #if defined(OS_ANDROID) |
danakj | c87bfede | 2018-10-10 22:32:49 | [diff] [blame] | 490 | bool has_show_callback = !!show_callback; |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 491 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 492 | |
Lukasz Anforowicz | af2f3357 | 2018-01-17 14:05:08 | [diff] [blame] | 493 | WebFrame* opener_frame = |
| 494 | RenderFrameImpl::ResolveOpener(params->opener_frame_route_id); |
| 495 | |
danakj | 9a8a9cf | 2018-07-17 23:52:12 | [diff] [blame] | 496 | // Pass WidgetClient(), not |this|, as the WebWidgetClient. The method may |
Kent Tamura | 21d1de6 | 2018-12-10 04:45:20 | [diff] [blame] | 497 | // be overridden in web tests to inject a test-only WebWidgetClient. |
danakj | 284d557d | 2019-01-16 17:00:26 | [diff] [blame] | 498 | webview_ = WebView::Create(this, params->hidden, |
Sadrul Habib Chowdhury | 042a471 | 2018-12-06 00:16:56 | [diff] [blame] | 499 | /*compositing_enabled=*/true, |
danakj | a4ba7e5 | 2018-11-29 23:04:31 | [diff] [blame] | 500 | opener_frame ? opener_frame->View() : nullptr); |
Albert J. Wong | 2727e8a8 | 2019-02-15 16:56:11 | [diff] [blame] | 501 | |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 502 | // Note: The GetWidget->Init() call causes an AddRef() to itself meaning that |
| 503 | // IPC system has taken conceptual ownership of the object. Though it is |
| 504 | // tempting to have RenderView retain the RenderWidget(), this lifecycle |
| 505 | // only requires single ownership and adding scoped_refptr<RenderWidget> |
| 506 | // muddies this unnecessarily -- especially since this RenderWidget should |
| 507 | // ultimately be own by the main frame. |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 508 | GetWidget()->Init(std::move(show_callback), webview_->MainFrameWidget()); |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 509 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 510 | g_view_map.Get().insert(std::make_pair(webview(), this)); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 511 | g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this)); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 512 | |
danakj | 50547679 | 2019-01-11 23:53:46 | [diff] [blame] | 513 | webview()->SetDisplayMode(params->visual_properties.display_mode); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 514 | |
danakj | fd0c7f4 | 2018-10-12 18:01:08 | [diff] [blame] | 515 | ApplyWebPreferences(webkit_preferences_, webview()); |
danakj | efcb843 | 2019-01-16 18:47:14 | [diff] [blame] | 516 | ApplyCommandLineToSettings(webview()->GetSettings()); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 517 | |
danakj | af29226f | 2018-09-25 17:56:57 | [diff] [blame] | 518 | // We have either a main frame or a proxy routing id. |
| 519 | DCHECK_NE(params->main_frame_routing_id != MSG_ROUTING_NONE, |
| 520 | params->proxy_routing_id != MSG_ROUTING_NONE); |
| 521 | |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 522 | if (params->main_frame_routing_id != MSG_ROUTING_NONE) { |
Oksana Zhuravlova | 8b88e57 | 2019-01-07 21:54:00 | [diff] [blame] | 523 | CHECK(params->main_frame_interface_bundle); |
Ken Rockot | 26efbd6 | 2017-11-16 04:39:49 | [diff] [blame] | 524 | service_manager::mojom::InterfaceProviderPtr main_frame_interface_provider( |
Oksana Zhuravlova | 8b88e57 | 2019-01-07 21:54:00 | [diff] [blame] | 525 | std::move(params->main_frame_interface_bundle->interface_provider)); |
| 526 | |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 527 | main_render_frame_ = RenderFrameImpl::CreateMainFrame( |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 528 | this, params->main_frame_routing_id, |
Ken Rockot | 26efbd6 | 2017-11-16 04:39:49 | [diff] [blame] | 529 | std::move(main_frame_interface_provider), |
Oksana Zhuravlova | 8b88e57 | 2019-01-07 21:54:00 | [diff] [blame] | 530 | blink::mojom::DocumentInterfaceBrokerPtr( |
| 531 | std::move(params->main_frame_interface_bundle |
| 532 | ->document_interface_broker_content)), |
| 533 | blink::mojom::DocumentInterfaceBrokerPtr( |
| 534 | std::move(params->main_frame_interface_bundle |
| 535 | ->document_interface_broker_blink)), |
Fady Samuel | a863f15 | 2018-03-09 16:10:03 | [diff] [blame] | 536 | params->main_frame_widget_routing_id, params->hidden, |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 537 | GetWidget()->GetWebScreenInfo(), GetWidget()->compositor_deps(), |
| 538 | opener_frame, params->devtools_main_frame_token, |
| 539 | params->replicated_frame_state, params->has_committed_real_load); |
danakj | af29226f | 2018-09-25 17:56:57 | [diff] [blame] | 540 | } else { |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 541 | RenderFrameProxy::CreateFrameProxy(params->proxy_routing_id, GetRoutingID(), |
nick | 3b5a21f | 2016-11-22 23:07:11 | [diff] [blame] | 542 | opener_frame, MSG_ROUTING_NONE, |
Dmitry Gozman | 8936121 | 2018-02-13 16:10:44 | [diff] [blame] | 543 | params->replicated_frame_state, |
| 544 | params->devtools_main_frame_token); |
danakj | b08b371 | 2019-01-16 18:59:56 | [diff] [blame] | 545 | // TODO(danakj): Make WebViewImpl not need a WebWidgetClient when there is a |
| 546 | // remote main frame (when the RenderWidget is frozen). |
danakj | 40d0793 | 2019-02-28 18:07:10 | [diff] [blame] | 547 | webview_->DidAttachRemoteMainFrame(render_widget_); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 548 | } |
| 549 | |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 550 | // TODO(davidben): Move this state from Blink into content. |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 551 | if (params->window_was_created_with_opener) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 552 | webview()->SetOpenedByDOM(); |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 553 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 554 | GetWidget()->UpdateWebViewWithDeviceScaleFactor(); |
Leon Han | 2c81b5d | 2019-01-25 01:58:33 | [diff] [blame] | 555 | OnSetRendererPrefs(*params->renderer_preferences); |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 556 | GetWidget()->OnSynchronizeVisualProperties(params->visual_properties); |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 557 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 558 | GetContentClient()->renderer()->RenderViewCreated(this); |
akaba | c6bd121 | 2018-06-25 20:10:48 | [diff] [blame] | 559 | page_zoom_level_ = 0; |
Hajime Hoshi | f3437441 | 2018-03-05 14:32:54 | [diff] [blame] | 560 | |
| 561 | nav_state_sync_timer_.SetTaskRunner(task_runner); |
danakj | c87bfede | 2018-10-10 22:32:49 | [diff] [blame] | 562 | |
Adithya Srinivasan | 46b8a79 | 2019-02-01 14:47:23 | [diff] [blame] | 563 | // We pass this state to Page, but it's only used by the main frame in the |
| 564 | // page. |
| 565 | if (params->inside_portal) |
| 566 | webview()->SetInsidePortal(true); |
| 567 | |
danakj | c87bfede | 2018-10-10 22:32:49 | [diff] [blame] | 568 | #if defined(OS_ANDROID) |
| 569 | // TODO(sgurun): crbug.com/325351 Needed only for android webview's deprecated |
| 570 | // HandleNavigation codepath. |
| 571 | // Renderer-created RenderViews have a ShowCallback because they send a Show |
| 572 | // request (ViewHostMsg_ShowWidget, ViewHostMsg_ShowFullscreenWidget, or |
| 573 | // FrameHostMsg_ShowCreatedWindow) to the browser to attach them to the UI |
| 574 | // there. Browser-created RenderViews do not send a Show request to the |
| 575 | // browser, so have no such callback. |
| 576 | was_created_by_renderer_ = has_show_callback; |
| 577 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 578 | } |
| 579 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 580 | RenderViewImpl::~RenderViewImpl() { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 581 | DCHECK(!frame_widget_); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 582 | RenderThread::Get()->RemoveRoute(routing_id_); |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 583 | |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 584 | #ifndef NDEBUG |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 585 | // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap. |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 586 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 587 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 588 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 589 | RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer(); |
| 590 | for (RoutingIDViewMap::iterator it = routing_id_views->begin(); |
| 591 | it != routing_id_views->end(); ++it) |
| 592 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 593 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 594 | |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 595 | for (auto& observer : observers_) |
| 596 | observer.RenderViewGone(); |
| 597 | for (auto& observer : observers_) |
| 598 | observer.OnDestruct(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 599 | } |
| 600 | |
| 601 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 602 | RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 603 | DCHECK(RenderThread::IsMainThread()); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 604 | ViewMap* views = g_view_map.Pointer(); |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 605 | auto it = views->find(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 606 | return it == views->end() ? NULL : it->second; |
| 607 | } |
| 608 | |
| 609 | /*static*/ |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 610 | RenderView* RenderView::FromWebView(blink::WebView* webview) { |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 611 | return RenderViewImpl::FromWebView(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 612 | } |
| 613 | |
| 614 | /*static*/ |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 615 | RenderViewImpl* RenderViewImpl::FromRoutingID(int32_t routing_id) { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 616 | DCHECK(RenderThread::IsMainThread()); |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 617 | RoutingIDViewMap* views = g_routing_id_view_map.Pointer(); |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 618 | auto it = views->find(routing_id); |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 619 | return it == views->end() ? NULL : it->second; |
| 620 | } |
| 621 | |
| 622 | /*static*/ |
| 623 | RenderView* RenderView::FromRoutingID(int routing_id) { |
| 624 | return RenderViewImpl::FromRoutingID(routing_id); |
| 625 | } |
| 626 | |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 627 | /* static */ |
jochen | 9c7b8f24 | 2015-06-01 15:32:02 | [diff] [blame] | 628 | size_t RenderView::GetRenderViewCount() { |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 629 | return g_view_map.Get().size(); |
| 630 | } |
| 631 | |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 632 | /*static*/ |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 633 | void RenderView::ForEach(RenderViewVisitor* visitor) { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 634 | DCHECK(RenderThread::IsMainThread()); |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 635 | ViewMap* views = g_view_map.Pointer(); |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 636 | for (auto it = views->begin(); it != views->end(); ++it) { |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 637 | if (!visitor->Visit(it->second)) |
| 638 | return; |
| 639 | } |
| 640 | } |
| 641 | |
| 642 | /*static*/ |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 643 | void RenderView::ApplyWebPreferences(const WebPreferences& prefs, |
| 644 | WebView* web_view) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 645 | WebSettings* settings = web_view->GetSettings(); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 646 | ApplyFontsFromMap(prefs.standard_font_family_map, |
| 647 | SetStandardFontFamilyWrapper, settings); |
| 648 | ApplyFontsFromMap(prefs.fixed_font_family_map, |
| 649 | SetFixedFontFamilyWrapper, settings); |
| 650 | ApplyFontsFromMap(prefs.serif_font_family_map, |
| 651 | SetSerifFontFamilyWrapper, settings); |
| 652 | ApplyFontsFromMap(prefs.sans_serif_font_family_map, |
| 653 | SetSansSerifFontFamilyWrapper, settings); |
| 654 | ApplyFontsFromMap(prefs.cursive_font_family_map, |
| 655 | SetCursiveFontFamilyWrapper, settings); |
| 656 | ApplyFontsFromMap(prefs.fantasy_font_family_map, |
| 657 | SetFantasyFontFamilyWrapper, settings); |
| 658 | ApplyFontsFromMap(prefs.pictograph_font_family_map, |
| 659 | SetPictographFontFamilyWrapper, settings); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 660 | settings->SetDefaultFontSize(prefs.default_font_size); |
| 661 | settings->SetDefaultFixedFontSize(prefs.default_fixed_font_size); |
| 662 | settings->SetMinimumFontSize(prefs.minimum_font_size); |
| 663 | settings->SetMinimumLogicalFontSize(prefs.minimum_logical_font_size); |
| 664 | settings->SetDefaultTextEncodingName( |
| 665 | WebString::FromASCII(prefs.default_encoding)); |
| 666 | settings->SetJavaScriptEnabled(prefs.javascript_enabled); |
| 667 | settings->SetWebSecurityEnabled(prefs.web_security_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 668 | settings->SetLoadsImagesAutomatically(prefs.loads_images_automatically); |
| 669 | settings->SetImagesEnabled(prefs.images_enabled); |
| 670 | settings->SetPluginsEnabled(prefs.plugins_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 671 | settings->SetDOMPasteAllowed(prefs.dom_paste_enabled); |
| 672 | settings->SetTextAreasAreResizable(prefs.text_areas_are_resizable); |
| 673 | settings->SetAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows); |
| 674 | settings->SetDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled); |
| 675 | settings->SetJavaScriptCanAccessClipboard( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 676 | prefs.javascript_can_access_clipboard); |
Chris Cunningham | e9b5ad74 | 2019-04-23 19:40:38 | [diff] [blame] | 677 | WebRuntimeFeatures::EnableXSLT(prefs.xslt_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 678 | settings->SetXSSAuditorEnabled(prefs.xss_auditor_enabled); |
| 679 | settings->SetDNSPrefetchingEnabled(prefs.dns_prefetching_enabled); |
Tarun Bansal | 333819e | 2018-05-15 16:38:42 | [diff] [blame] | 680 | blink::WebNetworkStateNotifier::SetSaveDataEnabled(prefs.data_saver_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 681 | settings->SetLocalStorageEnabled(prefs.local_storage_enabled); |
| 682 | settings->SetSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled); |
| 683 | WebRuntimeFeatures::EnableDatabase(prefs.databases_enabled); |
| 684 | settings->SetOfflineWebApplicationCacheEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 685 | prefs.application_cache_enabled); |
Arthur Sonzogni | 721f48e | 2018-10-31 17:10:02 | [diff] [blame] | 686 | settings->SetShouldProtectAgainstIpcFlooding( |
| 687 | !prefs.disable_ipc_flooding_protection); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 688 | settings->SetHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled); |
| 689 | settings->SetCookieEnabled(prefs.cookie_enabled); |
| 690 | settings->SetNavigateOnDragDrop(prefs.navigate_on_drag_drop); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 691 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 692 | // By default, allow_universal_access_from_file_urls is set to false and thus |
| 693 | // we mitigate attacks from local HTML files by not granting file:// URLs |
| 694 | // universal access. Only test shell will enable this. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 695 | settings->SetAllowUniversalAccessFromFileURLs( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 696 | prefs.allow_universal_access_from_file_urls); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 697 | settings->SetAllowFileAccessFromFileURLs( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 698 | prefs.allow_file_access_from_file_urls); |
| 699 | |
Zhenyao Mo | a3fda997 | 2017-09-16 01:34:40 | [diff] [blame] | 700 | settings->SetWebGL1Enabled(prefs.webgl1_enabled); |
| 701 | settings->SetWebGL2Enabled(prefs.webgl2_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 702 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 703 | // Enable WebGL errors to the JS console if requested. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 704 | settings->SetWebGLErrorsToConsoleEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 705 | prefs.webgl_errors_to_console_enabled); |
| 706 | |
| 707 | // Uses the mock theme engine for scrollbars. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 708 | settings->SetMockScrollbarsEnabled(prefs.mock_scrollbars_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 709 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 710 | settings->SetHideScrollbars(prefs.hide_scrollbars); |
eseckler | 61ff914 | 2016-09-23 22:57:59 | [diff] [blame] | 711 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 712 | // Enable gpu-accelerated 2d canvas if requested on the command line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 713 | WebRuntimeFeatures::EnableAccelerated2dCanvas( |
junov | 524668f2 | 2016-08-08 20:16:52 | [diff] [blame] | 714 | prefs.accelerated_2d_canvas_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 715 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 716 | settings->SetMinimumAccelerated2dCanvasSize( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 717 | prefs.minimum_accelerated_2d_canvas_size); |
| 718 | |
| 719 | // Disable antialiasing for 2d canvas if requested on the command line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 720 | settings->SetAntialiased2dCanvasEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 721 | !prefs.antialiased_2d_canvas_disabled); |
| 722 | |
zakerinasab | 20ebca0 | 2016-09-27 14:22:34 | [diff] [blame] | 723 | // Disable antialiasing of clips for 2d canvas if requested on the command |
robertphillips | e25137b | 2014-10-20 13:44:34 | [diff] [blame] | 724 | // line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 725 | settings->SetAntialiasedClips2dCanvasEnabled( |
robertphillips | e25137b | 2014-10-20 13:44:34 | [diff] [blame] | 726 | prefs.antialiased_clips_2d_canvas_enabled); |
| 727 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 728 | // Set MSAA sample count for 2d canvas if requested on the command line (or |
| 729 | // default value if not). |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 730 | settings->SetAccelerated2dCanvasMSAASampleCount( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 731 | prefs.accelerated_2d_canvas_msaa_sample_count); |
| 732 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 733 | // Tabs to link is not part of the settings. WebCore calls |
| 734 | // ChromeClient::tabsToLinks which is part of the glue code. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 735 | web_view->SetTabsToLinks(prefs.tabs_to_links); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 736 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 737 | settings->SetAllowRunningOfInsecureContent( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 738 | prefs.allow_running_insecure_content); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 739 | settings->SetDisableReadingFromCanvas(prefs.disable_reading_from_canvas); |
| 740 | settings->SetStrictMixedContentChecking(prefs.strict_mixed_content_checking); |
mkwst | 2384c822 | 2015-07-30 07:26:47 | [diff] [blame] | 741 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 742 | settings->SetStrictlyBlockBlockableMixedContent( |
mkwst | 2384c822 | 2015-07-30 07:26:47 | [diff] [blame] | 743 | prefs.strictly_block_blockable_mixed_content); |
| 744 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 745 | settings->SetStrictMixedContentCheckingForPlugin( |
mkwst | 0d233e5 | 2015-08-10 09:33:14 | [diff] [blame] | 746 | prefs.block_mixed_plugin_content); |
| 747 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 748 | settings->SetStrictPowerfulFeatureRestrictions( |
mkwst | 673a452f | 2015-01-10 14:41:50 | [diff] [blame] | 749 | prefs.strict_powerful_feature_restrictions); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 750 | settings->SetAllowGeolocationOnInsecureOrigins( |
jww | 9d4ca2d | 2016-01-19 20:58:59 | [diff] [blame] | 751 | prefs.allow_geolocation_on_insecure_origins); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 752 | settings->SetPasswordEchoEnabled(prefs.password_echo_enabled); |
| 753 | settings->SetShouldPrintBackgrounds(prefs.should_print_backgrounds); |
| 754 | settings->SetShouldClearDocumentBackground( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 755 | prefs.should_clear_document_background); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 756 | settings->SetEnableScrollAnimator(prefs.enable_scroll_animator); |
Stephen McGruer | bc3d0e6 | 2019-01-23 17:40:19 | [diff] [blame] | 757 | settings->SetPrefersReducedMotion(prefs.prefers_reduced_motion); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 758 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 759 | WebRuntimeFeatures::EnableTouchEventFeatureDetection( |
sunyunjia | fa6a8afc | 2016-12-09 04:25:47 | [diff] [blame] | 760 | prefs.touch_event_feature_detection_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 761 | settings->SetMaxTouchPoints(prefs.pointer_events_max_touch_points); |
| 762 | settings->SetAvailablePointerTypes(prefs.available_pointer_types); |
| 763 | settings->SetPrimaryPointerType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 764 | static_cast<blink::PointerType>(prefs.primary_pointer_type)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 765 | settings->SetAvailableHoverTypes(prefs.available_hover_types); |
| 766 | settings->SetPrimaryHoverType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 767 | static_cast<blink::HoverType>(prefs.primary_hover_type)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 768 | settings->SetEnableTouchAdjustment(prefs.touch_adjustment_enabled); |
Dave Tapuska | a59fdb6 | 2017-08-23 16:28:27 | [diff] [blame] | 769 | settings->SetBarrelButtonForDragEnabled(prefs.barrel_button_for_drag_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 770 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 771 | settings->SetShouldRespectImageOrientation( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 772 | prefs.should_respect_image_orientation); |
| 773 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 774 | settings->SetEditingBehavior( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 775 | static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior)); |
| 776 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 777 | settings->SetSupportsMultipleWindows(prefs.supports_multiple_windows); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 778 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 779 | settings->SetMainFrameClipsContent(!prefs.record_whole_document); |
khushalsagar | 2da2b23 | 2016-03-23 22:11:35 | [diff] [blame] | 780 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 781 | settings->SetSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 782 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 783 | settings->SetSpatialNavigationEnabled(prefs.spatial_navigation_enabled); |
Hugo Holgersson | 943ae69 | 2019-01-10 10:04:14 | [diff] [blame] | 784 | // Spatnav depends on KeyboardFocusableScrollers. The WebUI team has |
| 785 | // disabled KFS because they need more time to update their custom elements, |
| 786 | // crbug.com/907284. Meanwhile, we pre-ship KFS to spatnav users. |
| 787 | if (prefs.spatial_navigation_enabled) |
| 788 | WebRuntimeFeatures::EnableKeyboardFocusableScrollers(true); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 789 | |
Bruce Long | 015d96f | 2019-07-12 22:59:10 | [diff] [blame] | 790 | settings->SetCaretBrowsingEnabled(prefs.caret_browsing_enabled); |
| 791 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 792 | settings->SetSelectionIncludesAltImageText(true); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 793 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 794 | settings->SetV8CacheOptions( |
[email protected] | 35103c0 | 2014-08-12 15:08:47 | [diff] [blame] | 795 | static_cast<WebSettings::V8CacheOptions>(prefs.v8_cache_options)); |
| 796 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 797 | settings->SetImageAnimationPolicy( |
je_julie.kim | 7fbb5a1a | 2015-02-09 17:26:05 | [diff] [blame] | 798 | static_cast<WebSettings::ImageAnimationPolicy>(prefs.animation_policy)); |
| 799 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 800 | settings->SetPresentationRequiresUserGesture( |
zqzhang | 1215ad42 | 2016-02-10 13:27:22 | [diff] [blame] | 801 | prefs.user_gesture_required_for_presentation); |
| 802 | |
Elly Fong-Jones | f9289739 | 2019-01-24 16:05:49 | [diff] [blame] | 803 | settings->SetTextTrackBackgroundColor( |
| 804 | WebString::FromASCII(prefs.text_track_background_color)); |
| 805 | settings->SetTextTrackTextColor( |
| 806 | WebString::FromASCII(prefs.text_track_text_color)); |
Rahul Singh | 1862faa9 | 2019-03-06 22:41:43 | [diff] [blame] | 807 | settings->SetTextTrackTextSize( |
| 808 | WebString::FromASCII(prefs.text_track_text_size)); |
| 809 | settings->SetTextTrackTextShadow( |
| 810 | WebString::FromASCII(prefs.text_track_text_shadow)); |
| 811 | settings->SetTextTrackFontFamily( |
| 812 | WebString::FromASCII(prefs.text_track_font_family)); |
| 813 | settings->SetTextTrackFontVariant( |
| 814 | WebString::FromASCII(prefs.text_track_font_variant)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 815 | settings->SetTextTrackMarginPercentage(prefs.text_track_margin_percentage); |
Abigail Klein | 74de85bd | 2019-07-11 19:11:56 | [diff] [blame] | 816 | settings->SetTextTrackWindowColor( |
| 817 | WebString::FromASCII(prefs.text_track_window_color)); |
| 818 | settings->SetTextTrackWindowPadding( |
| 819 | WebString::FromASCII(prefs.text_track_window_padding)); |
| 820 | settings->SetTextTrackWindowRadius( |
| 821 | WebString::FromASCII(prefs.text_track_window_radius)); |
halliwell | 4002be4 | 2016-03-18 18:33:40 | [diff] [blame] | 822 | |
David Bokan | a03511a9 | 2018-09-13 04:25:24 | [diff] [blame] | 823 | // Needs to happen before SetDefaultPageScaleLimits below since that'll |
| 824 | // recalculate the final page scale limits and that depends on this setting. |
| 825 | settings->SetShrinksViewportContentToFit( |
| 826 | prefs.shrinks_viewport_contents_to_fit); |
| 827 | |
| 828 | // Needs to happen before SetIgnoreViewportTagScaleLimits below. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 829 | web_view->SetDefaultPageScaleLimits(prefs.default_minimum_page_scale_factor, |
| 830 | prefs.default_maximum_page_scale_factor); |
dcheng | 5ae8ca36 | 2015-02-05 04:03:47 | [diff] [blame] | 831 | |
Allan Sandfeld Jensen | e3533709 | 2019-05-15 13:56:09 | [diff] [blame] | 832 | settings->SetFullscreenSupported(prefs.fullscreen_supported); |
Ahmed Fakhry | 4222145 | 2018-05-30 01:18:39 | [diff] [blame] | 833 | settings->SetTextAutosizingEnabled(prefs.text_autosizing_enabled); |
| 834 | settings->SetDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled); |
Tarun Bansal | d10f17a0 | 2018-09-13 00:23:17 | [diff] [blame] | 835 | blink::WebNetworkStateNotifier::SetNetworkQualityWebHoldback( |
| 836 | static_cast<blink::WebEffectiveConnectionType>( |
| 837 | prefs.network_quality_estimator_web_holdback)); |
Ahmed Fakhry | 4222145 | 2018-05-30 01:18:39 | [diff] [blame] | 838 | |
chaopeng | 7e8fb35 | 2019-03-26 03:34:49 | [diff] [blame] | 839 | settings->SetDontSendKeyEventsToJavascript( |
| 840 | prefs.dont_send_key_events_to_javascript); |
Mounir Lamouri | 6926107f | 2019-01-31 18:17:43 | [diff] [blame] | 841 | settings->SetWebAppScope(WebString::FromASCII(prefs.web_app_scope.spec())); |
| 842 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 843 | #if defined(OS_ANDROID) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 844 | settings->SetAllowCustomScrollbarInMainFrame(false); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 845 | settings->SetAccessibilityFontScaleFactor(prefs.font_scale_factor); |
| 846 | settings->SetDeviceScaleAdjustment(prefs.device_scale_adjustment); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 847 | web_view->SetIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); |
| 848 | settings->SetAutoZoomFocusedNodeToLegibleScale(true); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 849 | settings->SetDefaultVideoPosterURL( |
| 850 | WebString::FromASCII(prefs.default_video_poster_url.spec())); |
| 851 | settings->SetSupportDeprecatedTargetDensityDPI( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 852 | prefs.support_deprecated_target_density_dpi); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 853 | settings->SetUseLegacyBackgroundSizeShorthandBehavior( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 854 | prefs.use_legacy_background_size_shorthand_behavior); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 855 | settings->SetWideViewportQuirkEnabled(prefs.wide_viewport_quirk); |
| 856 | settings->SetUseWideViewport(prefs.use_wide_viewport); |
| 857 | settings->SetForceZeroLayoutHeight(prefs.force_zero_layout_height); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 858 | settings->SetViewportMetaMergeContentQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 859 | prefs.viewport_meta_merge_content_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 860 | settings->SetViewportMetaNonUserScalableQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 861 | prefs.viewport_meta_non_user_scalable_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 862 | settings->SetViewportMetaZeroValuesQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 863 | prefs.viewport_meta_zero_values_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 864 | settings->SetClobberUserAgentInitialScaleQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 865 | prefs.clobber_user_agent_initial_scale_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 866 | settings->SetIgnoreMainFrameOverflowHiddenQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 867 | prefs.ignore_main_frame_overflow_hidden_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 868 | settings->SetReportScreenSizeInPhysicalPixelsQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 869 | prefs.report_screen_size_in_physical_pixels_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 870 | settings->SetShouldReuseGlobalForUnownedMainFrame( |
tzik | 30eb52c | 2018-03-27 06:55:18 | [diff] [blame] | 871 | prefs.reuse_global_for_unowned_main_frame); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 872 | settings->SetPreferHiddenVolumeControls(true); |
| 873 | settings->SetSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default); |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 874 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 875 | WebRuntimeFeatures::EnableVideoFullscreenOrientationLock( |
mlamouri | 1d266bf | 2016-12-05 17:42:36 | [diff] [blame] | 876 | prefs.video_fullscreen_orientation_lock_enabled); |
johnme | 913ee5f | 2017-04-28 21:36:16 | [diff] [blame] | 877 | WebRuntimeFeatures::EnableVideoRotateToFullscreen( |
| 878 | prefs.video_rotate_to_fullscreen_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 879 | WebRuntimeFeatures::EnableVideoFullscreenDetection( |
zqzhang | 93e959d1 | 2017-03-16 13:10:20 | [diff] [blame] | 880 | prefs.video_fullscreen_detection_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 881 | settings->SetEmbeddedMediaExperienceEnabled( |
shaktisahu | f97f753 | 2017-02-24 22:46:13 | [diff] [blame] | 882 | prefs.embedded_media_experience_enabled); |
Ian Vollick | eeca1d8 | 2018-02-07 02:43:42 | [diff] [blame] | 883 | settings->SetImmersiveModeEnabled(prefs.immersive_mode_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 884 | settings->SetDoNotUpdateSelectionOnMutatingSelectionRange( |
changwan | e54ccdb9 | 2017-04-05 19:20:54 | [diff] [blame] | 885 | prefs.do_not_update_selection_on_mutating_selection_range); |
Noel Gordon | f311a84 | 2017-07-27 00:10:07 | [diff] [blame] | 886 | WebRuntimeFeatures::EnableCSSHexAlphaColor(prefs.css_hex_alpha_color_enabled); |
Tobias Sargeant | 416174f | 2017-09-01 01:18:09 | [diff] [blame] | 887 | WebRuntimeFeatures::EnableScrollTopLeftInterop( |
| 888 | prefs.scroll_top_left_interop_enabled); |
zqzhang | df72ed08 | 2016-12-08 16:07:55 | [diff] [blame] | 889 | #endif // defined(OS_ANDROID) |
liberato | 9e93489 | 2016-05-03 19:00:27 | [diff] [blame] | 890 | |
Rune Lillesveen | b46bb48 | 2019-04-02 07:36:29 | [diff] [blame] | 891 | settings->SetForceDarkModeEnabled(prefs.force_dark_mode_enabled); |
| 892 | |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 893 | switch (prefs.autoplay_policy) { |
| 894 | case AutoplayPolicy::kNoUserGestureRequired: |
mlamouri | 276a6f3 | 2017-05-12 09:24:28 | [diff] [blame] | 895 | settings->SetAutoplayPolicy( |
| 896 | WebSettings::AutoplayPolicy::kNoUserGestureRequired); |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 897 | break; |
| 898 | case AutoplayPolicy::kUserGestureRequired: |
mlamouri | 276a6f3 | 2017-05-12 09:24:28 | [diff] [blame] | 899 | settings->SetAutoplayPolicy( |
| 900 | WebSettings::AutoplayPolicy::kUserGestureRequired); |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 901 | break; |
mlamouri | 431bb4e | 2017-06-06 08:54:24 | [diff] [blame] | 902 | case AutoplayPolicy::kDocumentUserActivationRequired: |
| 903 | settings->SetAutoplayPolicy( |
| 904 | WebSettings::AutoplayPolicy::kDocumentUserActivationRequired); |
| 905 | break; |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 906 | } |
| 907 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 908 | settings->SetViewportEnabled(prefs.viewport_enabled); |
| 909 | settings->SetViewportMetaEnabled(prefs.viewport_meta_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 910 | settings->SetViewportStyle( |
alokp | 5d56696 | 2016-04-19 00:54:16 | [diff] [blame] | 911 | static_cast<blink::WebViewportStyle>(prefs.viewport_style)); |
| 912 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 913 | settings->SetLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale); |
| 914 | settings->SetMainFrameResizesAreOrientationChanges( |
yoav | a1a508b4 | 2015-10-20 12:03:21 | [diff] [blame] | 915 | prefs.main_frame_resizes_are_orientation_changes); |
| 916 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 917 | settings->SetUseSolidColorScrollbars(prefs.use_solid_color_scrollbars); |
jinho.bang | 8f11ffa | 2014-12-04 06:03:03 | [diff] [blame] | 918 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 919 | settings->SetShowContextMenuOnMouseUp(prefs.context_menu_on_mouse_up); |
| 920 | settings->SetAlwaysShowContextMenuOnTouch( |
amaralp | 547e419 | 2016-06-03 19:17:35 | [diff] [blame] | 921 | prefs.always_show_context_menu_on_touch); |
Sandra Sun | c79fc93a | 2018-04-10 15:22:23 | [diff] [blame] | 922 | settings->SetSmoothScrollForFindEnabled(prefs.smooth_scroll_for_find_enabled); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 923 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 924 | settings->SetHideDownloadUI(prefs.hide_download_ui); |
qinmin | 72e8bd0 | 2016-10-21 19:35:37 | [diff] [blame] | 925 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 926 | settings->SetPresentationReceiver(prefs.presentation_receiver); |
mlamouri | 57359d91 | 2016-11-29 20:11:50 | [diff] [blame] | 927 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 928 | settings->SetMediaControlsEnabled(prefs.media_controls_enabled); |
mlamouri | 5cd9ae8 | 2017-02-18 11:05:09 | [diff] [blame] | 929 | |
Tarun Bansal | 73d67f0 | 2018-01-17 05:56:25 | [diff] [blame] | 930 | settings->SetLowPriorityIframesThreshold( |
| 931 | static_cast<blink::WebEffectiveConnectionType>( |
| 932 | prefs.low_priority_iframes_threshold)); |
| 933 | |
Mounir Lamouri | 9c99a160 | 2018-07-05 15:01:44 | [diff] [blame] | 934 | settings->SetPictureInPictureEnabled( |
| 935 | prefs.picture_in_picture_enabled && |
[email protected] | 69db58f | 2018-09-26 20:27:56 | [diff] [blame] | 936 | MediaFactory::GetVideoSurfaceLayerMode() != |
CJ DiMeglio | 8924047 | 2018-10-18 18:21:10 | [diff] [blame] | 937 | blink::WebMediaPlayer::SurfaceLayerMode::kNever); |
François Beaufort | 8c08979fc | 2018-03-05 13:06:31 | [diff] [blame] | 938 | |
Tarun Bansal | 333819e | 2018-05-15 16:38:42 | [diff] [blame] | 939 | settings->SetDataSaverHoldbackWebApi( |
| 940 | prefs.data_saver_holdback_web_api_enabled); |
Tarun Bansal | 333819e | 2018-05-15 16:38:42 | [diff] [blame] | 941 | |
rajendrant | e87ed71 | 2018-11-30 01:55:00 | [diff] [blame] | 942 | settings->SetLazyLoadEnabled(prefs.lazy_load_enabled); |
Rune Lillesveen | e17fb70 | 2019-03-15 07:26:14 | [diff] [blame] | 943 | settings->SetPreferredColorScheme(prefs.preferred_color_scheme); |
Alison Maher | be15c07 | 2019-07-08 18:12:39 | [diff] [blame] | 944 | settings->SetForcedColors(prefs.forced_colors); |
rajendrant | e87ed71 | 2018-11-30 01:55:00 | [diff] [blame] | 945 | |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 946 | for (const auto& ect_distance_pair : |
| 947 | prefs.lazy_frame_loading_distance_thresholds_px) { |
| 948 | switch (ect_distance_pair.first) { |
| 949 | case net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN: |
| 950 | settings->SetLazyFrameLoadingDistanceThresholdPxUnknown( |
| 951 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 952 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 953 | case net::EFFECTIVE_CONNECTION_TYPE_OFFLINE: |
| 954 | settings->SetLazyFrameLoadingDistanceThresholdPxOffline( |
| 955 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 956 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 957 | case net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G: |
| 958 | settings->SetLazyFrameLoadingDistanceThresholdPxSlow2G( |
| 959 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 960 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 961 | case net::EFFECTIVE_CONNECTION_TYPE_2G: |
| 962 | settings->SetLazyFrameLoadingDistanceThresholdPx2G( |
| 963 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 964 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 965 | case net::EFFECTIVE_CONNECTION_TYPE_3G: |
| 966 | settings->SetLazyFrameLoadingDistanceThresholdPx3G( |
| 967 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 968 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 969 | case net::EFFECTIVE_CONNECTION_TYPE_4G: |
| 970 | settings->SetLazyFrameLoadingDistanceThresholdPx4G( |
| 971 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 972 | continue; |
| 973 | case net::EFFECTIVE_CONNECTION_TYPE_LAST: |
| 974 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 975 | } |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 976 | NOTREACHED(); |
| 977 | } |
| 978 | |
| 979 | for (const auto& ect_distance_pair : |
| 980 | prefs.lazy_image_loading_distance_thresholds_px) { |
| 981 | switch (ect_distance_pair.first) { |
| 982 | case net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN: |
| 983 | settings->SetLazyImageLoadingDistanceThresholdPxUnknown( |
| 984 | ect_distance_pair.second); |
| 985 | continue; |
| 986 | case net::EFFECTIVE_CONNECTION_TYPE_OFFLINE: |
| 987 | settings->SetLazyImageLoadingDistanceThresholdPxOffline( |
| 988 | ect_distance_pair.second); |
| 989 | continue; |
| 990 | case net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G: |
| 991 | settings->SetLazyImageLoadingDistanceThresholdPxSlow2G( |
| 992 | ect_distance_pair.second); |
| 993 | continue; |
| 994 | case net::EFFECTIVE_CONNECTION_TYPE_2G: |
| 995 | settings->SetLazyImageLoadingDistanceThresholdPx2G( |
| 996 | ect_distance_pair.second); |
| 997 | continue; |
| 998 | case net::EFFECTIVE_CONNECTION_TYPE_3G: |
| 999 | settings->SetLazyImageLoadingDistanceThresholdPx3G( |
| 1000 | ect_distance_pair.second); |
| 1001 | continue; |
| 1002 | case net::EFFECTIVE_CONNECTION_TYPE_4G: |
| 1003 | settings->SetLazyImageLoadingDistanceThresholdPx4G( |
| 1004 | ect_distance_pair.second); |
| 1005 | continue; |
| 1006 | case net::EFFECTIVE_CONNECTION_TYPE_LAST: |
| 1007 | continue; |
| 1008 | } |
| 1009 | NOTREACHED(); |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 1010 | } |
| 1011 | |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1012 | #if defined(OS_MACOSX) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1013 | web_view->SetMaximumLegibleScale(prefs.default_maximum_page_scale_factor); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1014 | #endif |
sunyunjia | 87f287b | 2016-09-09 00:38:13 | [diff] [blame] | 1015 | |
| 1016 | #if defined(OS_WIN) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1017 | WebRuntimeFeatures::EnableMiddleClickAutoscroll(true); |
sunyunjia | 87f287b | 2016-09-09 00:38:13 | [diff] [blame] | 1018 | #endif |
Dave Tapuska | c6627e1 | 2018-08-30 15:07:19 | [diff] [blame] | 1019 | |
Dave Tapuska | a38e325 | 2018-11-13 03:01:17 | [diff] [blame] | 1020 | WebRuntimeFeatures::EnableTranslateService(prefs.translate_service_available); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1021 | } |
| 1022 | |
| 1023 | /*static*/ |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1024 | RenderViewImpl* RenderViewImpl::Create( |
| 1025 | CompositorDependencies* compositor_deps, |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1026 | mojom::CreateViewParamsPtr params, |
danakj | df1ceb7 | 2018-07-18 20:02:25 | [diff] [blame] | 1027 | RenderWidget::ShowCallback show_callback, |
Hajime Hoshi | abb3c8f | 2017-12-04 18:41:39 | [diff] [blame] | 1028 | scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1029 | DCHECK(params->view_id != MSG_ROUTING_NONE); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 1030 | DCHECK(params->main_frame_widget_routing_id != MSG_ROUTING_NONE); |
Lei Zhang | 88f23ba | 2017-10-27 05:56:26 | [diff] [blame] | 1031 | RenderViewImpl* render_view; |
[email protected] | 0287e76 | 2014-04-11 13:07:58 | [diff] [blame] | 1032 | |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 1033 | auto render_widget = RenderWidget::CreateForFrame( |
| 1034 | params->main_frame_widget_routing_id, compositor_deps, |
| 1035 | params->visual_properties.screen_info, |
| 1036 | params->visual_properties.display_mode, |
| 1037 | /*is_frozen=*/params->main_frame_routing_id == MSG_ROUTING_NONE, |
| 1038 | params->hidden, params->never_visible, |
| 1039 | /*widget_request=*/nullptr); |
| 1040 | |
| 1041 | if (g_create_render_view_impl) { |
| 1042 | render_view = g_create_render_view_impl(compositor_deps, *params); |
| 1043 | } else { |
| 1044 | render_view = new RenderViewImpl(compositor_deps, *params); |
| 1045 | } |
| 1046 | |
| 1047 | // After this call, the |render_widget| will be self-owning. |
| 1048 | // |
| 1049 | // TODO(http://crbug.com/419087): This refcoutning is messy. get the |
| 1050 | // RenderWidget initialization out of the render_view::Initialize() function. |
| 1051 | render_view->Initialize(render_widget.get(), std::move(params), |
| 1052 | std::move(show_callback), std::move(task_runner)); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1053 | return render_view; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | // static |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1057 | void RenderViewImpl::InstallCreateHook(RenderViewImpl* ( |
| 1058 | *create_render_view_impl)(CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 1059 | const mojom::CreateViewParams&)) { |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1060 | CHECK(!g_create_render_view_impl); |
| 1061 | g_create_render_view_impl = create_render_view_impl; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1062 | } |
| 1063 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1064 | void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1065 | observers_.AddObserver(observer); |
| 1066 | } |
| 1067 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1068 | void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 1069 | observer->RenderViewGone(); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1070 | observers_.RemoveObserver(observer); |
| 1071 | } |
| 1072 | |
Peter Kasting | a4a3ed1 | 2018-01-31 04:07:59 | [diff] [blame] | 1073 | blink::WebView* RenderViewImpl::webview() { |
| 1074 | return webview_; |
| 1075 | } |
| 1076 | |
| 1077 | const blink::WebView* RenderViewImpl::webview() const { |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 1078 | return webview_; |
[email protected] | 4d51d5bf | 2010-07-26 18:48:26 | [diff] [blame] | 1079 | } |
| 1080 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1081 | // RenderWidgetOwnerDelegate ----------------------------------------- |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1082 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1083 | blink::WebWidget* RenderViewImpl::GetWebWidgetForWidget() const { |
| 1084 | return frame_widget_; |
| 1085 | } |
| 1086 | |
| 1087 | bool RenderViewImpl::RenderWidgetWillHandleMouseEventForWidget( |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1088 | const blink::WebMouseEvent& event) { |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1089 | // If the mouse is locked, only the current owner of the mouse lock can |
| 1090 | // process mouse events. |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1091 | return GetWidget()->mouse_lock_dispatcher()->WillHandleMouseEvent(event); |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1092 | } |
| 1093 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1094 | void RenderViewImpl::SetActiveForWidget(bool active) { |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 1095 | if (webview()) |
| 1096 | webview()->SetIsActive(active); |
| 1097 | } |
| 1098 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1099 | bool RenderViewImpl::SupportsMultipleWindowsForWidget() { |
| 1100 | return webkit_preferences_.supports_multiple_windows; |
| 1101 | } |
| 1102 | |
| 1103 | void RenderViewImpl::DidHandleGestureEventForWidget( |
| 1104 | const WebGestureEvent& event) { |
| 1105 | for (auto& observer : observers_) |
| 1106 | observer.DidHandleGestureEvent(event); |
| 1107 | } |
| 1108 | |
David Bokan | 11f6ef48 | 2019-03-18 17:47:27 | [diff] [blame] | 1109 | bool RenderViewImpl::ShouldAckSyntheticInputImmediately() { |
| 1110 | // TODO(bokan): The RequestPresentation API appears not to function in VR. As |
| 1111 | // a short term workaround for https://crbug.com/940063, ACK input |
| 1112 | // immediately rather than using RequestPresentation. |
| 1113 | if (webkit_preferences_.immersive_mode_enabled) |
| 1114 | return true; |
| 1115 | return false; |
| 1116 | } |
| 1117 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1118 | void RenderViewImpl::DidCloseWidget() { |
| 1119 | // The webview_ is already destroyed by the time we get here, remove any |
| 1120 | // references to it. |
| 1121 | g_view_map.Get().erase(webview_); |
| 1122 | webview_ = nullptr; |
| 1123 | g_routing_id_view_map.Get().erase(GetRoutingID()); |
Albert J. Wong | 2727e8a8 | 2019-02-15 16:56:11 | [diff] [blame] | 1124 | |
| 1125 | // The |render_widget_| is deleted after DidCloseWidget() returns. Drop the |
| 1126 | // reference to it to avoid a UaF. |
| 1127 | render_widget_ = nullptr; |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1128 | } |
| 1129 | |
danakj | 84bbf55 | 2019-01-21 21:33:31 | [diff] [blame] | 1130 | void RenderViewImpl::CancelPagePopupForWidget() { |
| 1131 | webview()->CancelPagePopup(); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1132 | } |
| 1133 | |
| 1134 | void RenderViewImpl::ApplyNewDisplayModeForWidget( |
| 1135 | const blink::WebDisplayMode& new_display_mode) { |
danakj | 1ab8faf | 2018-10-12 18:24:28 | [diff] [blame] | 1136 | webview()->SetDisplayMode(new_display_mode); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1137 | } |
| 1138 | |
| 1139 | void RenderViewImpl::ApplyAutoResizeLimitsForWidget(const gfx::Size& min_size, |
| 1140 | const gfx::Size& max_size) { |
| 1141 | webview()->EnableAutoResizeMode(min_size, max_size); |
| 1142 | } |
| 1143 | |
| 1144 | void RenderViewImpl::DisableAutoResizeForWidget() { |
| 1145 | webview()->DisableAutoResizeMode(); |
| 1146 | } |
| 1147 | |
| 1148 | void RenderViewImpl::ScrollFocusedNodeIntoViewForWidget() { |
| 1149 | if (WebLocalFrame* focused_frame = GetWebView()->FocusedFrame()) { |
| 1150 | auto* frame_widget = focused_frame->LocalRoot()->FrameWidget(); |
| 1151 | frame_widget->ScrollFocusedEditableElementIntoView(); |
| 1152 | } |
| 1153 | } |
| 1154 | |
| 1155 | void RenderViewImpl::DidReceiveSetFocusEventForWidget() { |
| 1156 | // This message must always be received when the main frame is a |
| 1157 | // WebLocalFrame. |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 1158 | // TODO(ajwong): Can this be removed and just check |delegate_| in |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1159 | // RenderWidget instead? |
| 1160 | CHECK(webview()->MainFrame()->IsWebLocalFrame()); |
| 1161 | } |
| 1162 | |
| 1163 | void RenderViewImpl::DidChangeFocusForWidget() { |
| 1164 | // Notify all BrowserPlugins of the RenderView's focus state. |
| 1165 | if (BrowserPluginManager::Get()) |
| 1166 | BrowserPluginManager::Get()->UpdateFocusState(); |
| 1167 | } |
| 1168 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1169 | void RenderViewImpl::DidCommitCompositorFrameForWidget() { |
| 1170 | for (auto& observer : observers_) |
| 1171 | observer.DidCommitCompositorFrame(); |
Philip Rogers | 33cd2bcc | 2018-08-13 21:29:29 | [diff] [blame] | 1172 | UpdatePreferredSize(); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1173 | } |
| 1174 | |
| 1175 | void RenderViewImpl::DidCompletePageScaleAnimationForWidget() { |
| 1176 | if (auto* focused_frame = GetWebView()->FocusedFrame()) { |
| 1177 | if (focused_frame->AutofillClient()) |
| 1178 | focused_frame->AutofillClient()->DidCompleteFocusChangeInFrame(); |
| 1179 | } |
| 1180 | } |
| 1181 | |
| 1182 | void RenderViewImpl::ResizeWebWidgetForWidget( |
| 1183 | const gfx::Size& size, |
| 1184 | float top_controls_height, |
| 1185 | float bottom_controls_height, |
| 1186 | bool browser_controls_shrink_blink_size) { |
| 1187 | webview()->ResizeWithBrowserControls(size, top_controls_height, |
| 1188 | bottom_controls_height, |
| 1189 | browser_controls_shrink_blink_size); |
| 1190 | } |
| 1191 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1192 | void RenderViewImpl::SetScreenMetricsEmulationParametersForWidget( |
| 1193 | bool enabled, |
| 1194 | const blink::WebDeviceEmulationParams& params) { |
danakj | 1ab8faf | 2018-10-12 18:24:28 | [diff] [blame] | 1195 | if (enabled) |
| 1196 | webview()->EnableDeviceEmulation(params); |
| 1197 | else |
| 1198 | webview()->DisableDeviceEmulation(); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1199 | } |
| 1200 | |
| 1201 | // IPC message handlers ----------------------------------------- |
| 1202 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1203 | void RenderViewImpl::OnUpdateTargetURLAck() { |
| 1204 | // Check if there is a targeturl waiting to be sent. |
| 1205 | if (target_url_status_ == TARGET_PENDING) |
| 1206 | Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), pending_target_url_)); |
| 1207 | |
| 1208 | target_url_status_ = TARGET_NONE; |
| 1209 | } |
| 1210 | |
| 1211 | void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
| 1212 | int history_length) { |
| 1213 | // -1 <= history_offset < history_length <= kMaxSessionHistoryEntries(50). |
| 1214 | DCHECK_LE(-1, history_offset); |
| 1215 | DCHECK_LT(history_offset, history_length); |
| 1216 | DCHECK_LE(history_length, kMaxSessionHistoryEntries); |
| 1217 | |
| 1218 | history_list_offset_ = history_offset; |
| 1219 | history_list_length_ = history_length; |
| 1220 | } |
| 1221 | |
| 1222 | void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
| 1223 | if (!webview()) |
| 1224 | return; |
| 1225 | webview()->SetInitialFocus(reverse); |
| 1226 | } |
| 1227 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1228 | void RenderViewImpl::OnAudioStateChanged(bool is_audio_playing) { |
| 1229 | webview()->AudioStateChanged(is_audio_playing); |
| 1230 | } |
| 1231 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1232 | /////////////////////////////////////////////////////////////////////////////// |
| 1233 | |
| 1234 | void RenderViewImpl::ShowCreatedPopupWidget(RenderWidget* popup_widget, |
| 1235 | WebNavigationPolicy policy, |
| 1236 | const gfx::Rect& initial_rect) { |
| 1237 | Send(new ViewHostMsg_ShowWidget(GetRoutingID(), popup_widget->routing_id(), |
| 1238 | initial_rect)); |
| 1239 | } |
| 1240 | |
| 1241 | void RenderViewImpl::ShowCreatedFullscreenWidget( |
| 1242 | RenderWidget* fullscreen_widget, |
| 1243 | WebNavigationPolicy policy, |
| 1244 | const gfx::Rect& initial_rect) { |
| 1245 | Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(), |
| 1246 | fullscreen_widget->routing_id())); |
| 1247 | } |
| 1248 | |
| 1249 | void RenderViewImpl::SendFrameStateUpdates() { |
| 1250 | // Tell each frame with pending state to send its UpdateState message. |
| 1251 | for (int render_frame_routing_id : frames_with_pending_state_) { |
| 1252 | RenderFrameImpl* frame = |
| 1253 | RenderFrameImpl::FromRoutingID(render_frame_routing_id); |
| 1254 | if (frame) |
| 1255 | frame->SendUpdateState(); |
| 1256 | } |
| 1257 | frames_with_pending_state_.clear(); |
| 1258 | } |
| 1259 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1260 | // IPC::Listener ------------------------------------------------------------- |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1261 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1262 | bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
Ivan Kotenkov | 2c0d2bb3 | 2017-11-01 15:41:28 | [diff] [blame] | 1263 | WebFrame* main_frame = webview() ? webview()->MainFrame() : nullptr; |
Avi Drissman | b5f8e24 | 2017-12-12 05:21:56 | [diff] [blame] | 1264 | if (main_frame) { |
| 1265 | GURL active_url; |
| 1266 | if (main_frame->IsWebLocalFrame()) |
| 1267 | active_url = main_frame->ToWebLocalFrame()->GetDocument().Url(); |
lukasza | bedb4b2 | 2017-06-23 00:00:13 | [diff] [blame] | 1268 | GetContentClient()->SetActiveURL( |
Avi Drissman | b5f8e24 | 2017-12-12 05:21:56 | [diff] [blame] | 1269 | active_url, main_frame->Top()->GetSecurityOrigin().ToString().Utf8()); |
| 1270 | } |
[email protected] | f8b6b6f | 2009-03-10 16:48:26 | [diff] [blame] | 1271 | |
dcheng | a2d442c2 | 2016-10-13 15:39:21 | [diff] [blame] | 1272 | for (auto& observer : observers_) { |
| 1273 | if (observer.OnMessageReceived(message)) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1274 | return true; |
dcheng | a2d442c2 | 2016-10-13 15:39:21 | [diff] [blame] | 1275 | } |
[email protected] | b2abac7 | 2009-02-26 12:39:28 | [diff] [blame] | 1276 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1277 | bool handled = true; |
[email protected] | e44d134 | 2014-05-16 21:29:33 | [diff] [blame] | 1278 | IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 1279 | IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1280 | IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1281 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 1282 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1283 | IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 1284 | IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
[email protected] | ab32b16c | 2009-10-16 14:57:25 | [diff] [blame] | 1285 | IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1286 | OnEnablePreferredSizeChangedMode) |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1287 | IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1288 | IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
W. James MacLean | d973a55b | 2018-11-29 21:39:13 | [diff] [blame] | 1289 | IPC_MESSAGE_HANDLER(ViewMsg_AnimateDoubleTapZoom, |
| 1290 | OnAnimateDoubleTapZoomInMainFrame) |
W. James MacLean | 5372eb7 | 2018-12-19 12:56:36 | [diff] [blame] | 1291 | IPC_MESSAGE_HANDLER(ViewMsg_ZoomToFindInPageRect, OnZoomToFindInPageRect) |
danakj | d51fd53d | 2018-12-21 23:06:09 | [diff] [blame] | 1292 | IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1293 | |
| 1294 | // Page messages. |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 1295 | IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) |
| 1296 | IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) |
alexmos | 136fd6e6 | 2016-08-15 20:58:41 | [diff] [blame] | 1297 | IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, |
| 1298 | OnSetHistoryOffsetAndLength) |
altimin | d8bd26c | 2016-11-04 11:44:54 | [diff] [blame] | 1299 | IPC_MESSAGE_HANDLER(PageMsg_AudioStateChanged, OnAudioStateChanged) |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 1300 | IPC_MESSAGE_HANDLER(PageMsg_UpdateScreenInfo, OnUpdateScreenInfo) |
W. James MacLean | 7c858107 | 2019-06-18 18:07:53 | [diff] [blame] | 1301 | IPC_MESSAGE_HANDLER(PageMsg_UpdatePageVisualProperties, |
| 1302 | OnUpdatePageVisualProperties) |
Francois Doray | 47f759d | 2018-06-11 18:13:51 | [diff] [blame] | 1303 | IPC_MESSAGE_HANDLER(PageMsg_SetPageFrozen, SetPageFrozen) |
W. James MacLean | 6219867 | 2019-06-04 16:46:10 | [diff] [blame] | 1304 | IPC_MESSAGE_HANDLER(PageMsg_UpdateTextAutosizerPageInfoForRemoteMainFrames, |
| 1305 | OnTextAutosizerPageInfoChanged) |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 1306 | |
[email protected] | a794f3a | 2013-10-30 17:00:32 | [diff] [blame] | 1307 | // Adding a new message? Add platform independent ones first, then put the |
| 1308 | // platform specific ones at the end. |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1309 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 1310 | // Have the widget handle all other messages. |
| 1311 | // TODO(ajwong): Remove this cross-object dispatch. |
| 1312 | IPC_MESSAGE_UNHANDLED(handled = GetWidget()->OnMessageReceived(message)) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1313 | IPC_END_MESSAGE_MAP() |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 1314 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1315 | return handled; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1316 | } |
| 1317 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1318 | // blink::WebViewClient ------------------------------------------------------ |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1319 | |
Mustaq Ahmed | 55944cb | 2018-05-25 20:44:27 | [diff] [blame] | 1320 | // TODO(csharrison): Migrate this method to WebLocalFrameClient / |
| 1321 | // RenderFrameImpl, as it is now serviced by a mojo interface scoped to the |
| 1322 | // opener frame. |
Daniel Murphy | c8e991a | 2018-10-12 22:09:03 | [diff] [blame] | 1323 | WebView* RenderViewImpl::CreateView( |
| 1324 | WebLocalFrame* creator, |
| 1325 | const WebURLRequest& request, |
| 1326 | const WebWindowFeatures& features, |
| 1327 | const WebString& frame_name, |
| 1328 | WebNavigationPolicy policy, |
Daniel Murphy | c8e991a | 2018-10-12 22:09:03 | [diff] [blame] | 1329 | WebSandboxFlags sandbox_flags, |
Ehsan Karamad | 3940708 | 2019-02-19 23:38:19 | [diff] [blame] | 1330 | const blink::FeaturePolicy::FeatureState& opener_feature_state, |
Daniel Murphy | c8e991a | 2018-10-12 22:09:03 | [diff] [blame] | 1331 | const blink::SessionStorageNamespaceId& session_storage_namespace_id) { |
nick | 5ae4d2d | 2017-01-06 01:18:35 | [diff] [blame] | 1332 | RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1333 | mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 1334 | |
| 1335 | // User Activation v2 moves user gesture checks to the browser process, with |
| 1336 | // the exception of the extensions case handled through the following |if|. |
| 1337 | params->mimic_user_gesture = |
| 1338 | base::FeatureList::IsEnabled(features::kUserActivationV2) |
| 1339 | ? false |
| 1340 | : WebUserGestureIndicator::IsProcessingUserGesture(creator); |
Sergey Kuznetsov | 32257a2 | 2019-02-11 20:26:50 | [diff] [blame] | 1341 | // TODO(mustaq): Investigate if mimic_user_gesture can wrongly expose presence |
| 1342 | // of user activation w/o any user interaction, e.g. through |
| 1343 | // |WebChromeClient#onCreateWindow|. One case to deep-dive: disabling popup |
| 1344 | // blocker then calling window.open at onload event. crbug.com/929729 |
[email protected] | 00323f0 | 2013-07-24 15:47:41 | [diff] [blame] | 1345 | if (GetContentClient()->renderer()->AllowPopup()) |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 1346 | params->mimic_user_gesture = true; |
| 1347 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1348 | params->window_container_type = WindowFeaturesToContainerType(features); |
Daniel Murphy | e3eec92c | 2018-02-23 19:09:15 | [diff] [blame] | 1349 | |
Daniel Murphy | c8e991a | 2018-10-12 22:09:03 | [diff] [blame] | 1350 | params->session_storage_namespace_id = session_storage_namespace_id; |
| 1351 | // TODO(dmurph): Don't copy session storage when features.noopener is true: |
| 1352 | // https://html.spec.whatwg.org/multipage/browsers.html#copy-session-storage |
| 1353 | // https://crbug.com/771959 |
Daniel Murphy | e3eec92c | 2018-02-23 19:09:15 | [diff] [blame] | 1354 | params->clone_from_session_storage_namespace_id = |
| 1355 | session_storage_namespace_id_; |
Daniel Murphy | e3eec92c | 2018-02-23 19:09:15 | [diff] [blame] | 1356 | |
Daniel Cheng | d5e56ff | 2017-06-24 07:44:02 | [diff] [blame] | 1357 | const std::string& frame_name_utf8 = frame_name.Utf8( |
| 1358 | WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD); |
| 1359 | params->frame_name = frame_name_utf8; |
Nate Chapin | 43f307d | 2019-04-15 21:04:41 | [diff] [blame] | 1360 | params->opener_suppressed = features.noopener; |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1361 | params->disposition = NavigationPolicyToDisposition(policy); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1362 | if (!request.IsNull()) { |
| 1363 | params->target_url = request.Url(); |
Leon Han | 963dc18 | 2018-11-06 05:41:48 | [diff] [blame] | 1364 | params->referrer = |
| 1365 | blink::mojom::Referrer::From(GetReferrerFromRequest(creator, request)); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 1366 | } |
scottmg | 8e6c608 | 2017-02-13 23:15:48 | [diff] [blame] | 1367 | params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1368 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1369 | // We preserve this information before sending the message since |params| is |
| 1370 | // moved on send. |
| 1371 | bool is_background_tab = |
| 1372 | params->disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB; |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 1373 | bool opened_by_user_gesture = params->mimic_user_gesture; |
[email protected] | 22217ed3 | 2013-11-18 18:40:23 | [diff] [blame] | 1374 | |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1375 | mojom::CreateNewWindowStatus status; |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1376 | mojom::CreateNewWindowReplyPtr reply; |
Balazs Engedy | a40712f | 2017-09-15 15:01:11 | [diff] [blame] | 1377 | auto* frame_host = creator_frame->GetFrameHost(); |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1378 | bool err = !frame_host->CreateNewWindow(std::move(params), &status, &reply); |
| 1379 | if (err || status == mojom::CreateNewWindowStatus::kIgnore) |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1380 | return nullptr; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1381 | |
Jochen Eisinger | 515337a | 2017-05-26 14:12:52 | [diff] [blame] | 1382 | // For Android WebView, we support a pop-up like behavior for window.open() |
| 1383 | // even if the embedding app doesn't support multiple windows. In this case, |
| 1384 | // window.open() will return "window" and navigate it to whatever URL was |
Jochen Eisinger | 8cb2849 | 2017-10-04 10:58:13 | [diff] [blame] | 1385 | // passed. We also don't need to consume user gestures to protect against |
| 1386 | // multiple windows being opened, because, well, the app doesn't support |
| 1387 | // multiple windows. |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1388 | // TODO(dcheng): It's awkward that this is plumbed into Blink but not really |
Kent Tamura | 21d1de6 | 2018-12-10 04:45:20 | [diff] [blame] | 1389 | // used much in Blink, except to enable web testing... perhaps this should |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1390 | // be checked directly in the browser side. |
| 1391 | if (status == mojom::CreateNewWindowStatus::kReuse) |
Jochen Eisinger | 515337a | 2017-05-26 14:12:52 | [diff] [blame] | 1392 | return webview(); |
| 1393 | |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1394 | DCHECK(reply); |
| 1395 | DCHECK_NE(MSG_ROUTING_NONE, reply->route_id); |
| 1396 | DCHECK_NE(MSG_ROUTING_NONE, reply->main_frame_route_id); |
| 1397 | DCHECK_NE(MSG_ROUTING_NONE, reply->main_frame_widget_route_id); |
| 1398 | |
Mustaq Ahmed | 76c2f431 | 2018-06-07 20:48:01 | [diff] [blame] | 1399 | // The browser allowed creation of a new window and consumed the user |
| 1400 | // activation (UAv2 only). |
Sergey Kuznetsov | 32257a2 | 2019-02-11 20:26:50 | [diff] [blame] | 1401 | bool was_consumed = WebUserGestureIndicator::ConsumeUserGesture( |
Mustaq Ahmed | 76c2f431 | 2018-06-07 20:48:01 | [diff] [blame] | 1402 | creator, blink::UserActivationUpdateSource::kBrowser); |
Sergey Kuznetsov | 32257a2 | 2019-02-11 20:26:50 | [diff] [blame] | 1403 | if (base::FeatureList::IsEnabled(features::kUserActivationV2)) |
| 1404 | opened_by_user_gesture = was_consumed; |
Jochen Eisinger | 8cb2849 | 2017-10-04 10:58:13 | [diff] [blame] | 1405 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 1406 | // While this view may be a background extension page, it can spawn a visible |
| 1407 | // render view. So we just assume that the new one is not another background |
| 1408 | // page instead of passing on our own value. |
| 1409 | // TODO(vangelis): Can we tell if the new view will be a background page? |
| 1410 | bool never_visible = false; |
[email protected] | 9115d5f | 2013-03-24 04:37:41 | [diff] [blame] | 1411 | |
Fady Samuel | ff5b6eb56 | 2018-05-01 16:16:08 | [diff] [blame] | 1412 | VisualProperties visual_properties = VisualProperties(); |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 1413 | visual_properties.screen_info = GetWidget()->screen_info(); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 1414 | |
[email protected] | d6fa88f | 2013-10-18 16:00:43 | [diff] [blame] | 1415 | // The initial hidden state for the RenderViewImpl here has to match what the |
| 1416 | // browser will eventually decide for the given disposition. Since we have to |
| 1417 | // return from this call synchronously, we just have to make our best guess |
| 1418 | // and rely on the browser sending a WasHidden / WasShown message if it |
| 1419 | // disagrees. |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1420 | mojom::CreateViewParamsPtr view_params = mojom::CreateViewParams::New(); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1421 | |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1422 | view_params->opener_frame_route_id = creator_frame->GetRoutingID(); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1423 | DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1424 | |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1425 | view_params->window_was_created_with_opener = true; |
Leon Han | 2c81b5d | 2019-01-25 01:58:33 | [diff] [blame] | 1426 | view_params->renderer_preferences = renderer_preferences_.Clone(); |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1427 | view_params->web_preferences = webkit_preferences_; |
| 1428 | view_params->view_id = reply->route_id; |
| 1429 | view_params->main_frame_routing_id = reply->main_frame_route_id; |
Oksana Zhuravlova | 8b88e57 | 2019-01-07 21:54:00 | [diff] [blame] | 1430 | view_params->main_frame_interface_bundle = |
| 1431 | mojom::DocumentScopedInterfaceBundle::New( |
| 1432 | std::move(reply->main_frame_interface_bundle->interface_provider), |
| 1433 | std::move(reply->main_frame_interface_bundle |
| 1434 | ->document_interface_broker_content), |
| 1435 | std::move(reply->main_frame_interface_bundle |
| 1436 | ->document_interface_broker_blink)); |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1437 | view_params->main_frame_widget_routing_id = reply->main_frame_widget_route_id; |
| 1438 | view_params->session_storage_namespace_id = |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1439 | reply->cloned_session_storage_namespace_id; |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 1440 | DCHECK(!view_params->session_storage_namespace_id.empty()) |
| 1441 | << "Session storage namespace must be populated."; |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1442 | view_params->replicated_frame_state.frame_policy.sandbox_flags = |
| 1443 | sandbox_flags; |
Ehsan Karamad | 3940708 | 2019-02-19 23:38:19 | [diff] [blame] | 1444 | view_params->replicated_frame_state.opener_feature_state = |
| 1445 | opener_feature_state; |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1446 | view_params->replicated_frame_state.name = frame_name_utf8; |
| 1447 | view_params->devtools_main_frame_token = reply->devtools_main_frame_token; |
Daniel Cheng | d5e56ff | 2017-06-24 07:44:02 | [diff] [blame] | 1448 | // Even if the main frame has a name, the main frame's unique name is always |
| 1449 | // the empty string. |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1450 | view_params->hidden = is_background_tab; |
| 1451 | view_params->never_visible = never_visible; |
Fady Samuel | ff5b6eb56 | 2018-05-01 16:16:08 | [diff] [blame] | 1452 | view_params->visual_properties = visual_properties; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1453 | |
nick | 5ae4d2d | 2017-01-06 01:18:35 | [diff] [blame] | 1454 | // Unretained() is safe here because our calling function will also call |
| 1455 | // show(). |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1456 | RenderWidget::ShowCallback show_callback = |
danakj | df1ceb7 | 2018-07-18 20:02:25 | [diff] [blame] | 1457 | base::BindOnce(&RenderFrameImpl::ShowCreatedWindow, |
| 1458 | base::Unretained(creator_frame), opened_by_user_gesture); |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1459 | |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1460 | RenderViewImpl* view = RenderViewImpl::Create( |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 1461 | GetWidget()->compositor_deps(), std::move(view_params), |
| 1462 | std::move(show_callback), |
Hajime Hoshi | 6fc9114 | 2018-05-11 08:21:17 | [diff] [blame] | 1463 | creator->GetTaskRunner(blink::TaskType::kInternalDefault)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1464 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1465 | return view->webview(); |
| 1466 | } |
| 1467 | |
danakj | 19f3e51 | 2018-12-14 21:02:05 | [diff] [blame] | 1468 | blink::WebPagePopup* RenderViewImpl::CreatePopup( |
| 1469 | blink::WebLocalFrame* creator) { |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1470 | mojom::WidgetPtr widget_channel; |
| 1471 | mojom::WidgetRequest widget_channel_request = |
| 1472 | mojo::MakeRequest(&widget_channel); |
| 1473 | |
| 1474 | // Do a synchronous IPC to obtain a routing ID. |
| 1475 | int32_t widget_routing_id = MSG_ROUTING_NONE; |
| 1476 | bool success = |
| 1477 | RenderThreadImpl::current_render_message_filter()->CreateNewWidget( |
| 1478 | GetRoutingID(), std::move(widget_channel), &widget_routing_id); |
| 1479 | if (!success) { |
| 1480 | // When the renderer is being killed the mojo message will fail. |
Ivan Kotenkov | 2c0d2bb3 | 2017-11-01 15:41:28 | [diff] [blame] | 1481 | return nullptr; |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1482 | } |
| 1483 | |
| 1484 | RenderWidget::ShowCallback opener_callback = base::BindOnce( |
| 1485 | &RenderViewImpl::ShowCreatedPopupWidget, weak_ptr_factory_.GetWeakPtr()); |
| 1486 | |
| 1487 | // The RenderWidget associated with the RenderView. This should be the |
| 1488 | // RenderWidget for the main frame, but may be a zombie RenderWidget when |
| 1489 | // the main frame is remote (we don't need a RenderWidget for it then). |
| 1490 | // However for now (https://crbug.com/419087) we know it exists and grab |
| 1491 | // state off it for the popup. |
| 1492 | // TODO(crbug.com/419087): This should probably be using the local root's |
| 1493 | // RenderWidget for the frame making the popup. |
| 1494 | RenderWidget* view_render_widget = GetWidget(); |
| 1495 | |
Albert J. Wong | 2727e8a8 | 2019-02-15 16:56:11 | [diff] [blame] | 1496 | auto popup_widget = RenderWidget::CreateForPopup( |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1497 | widget_routing_id, view_render_widget->compositor_deps(), |
danakj | 89ae453 | 2018-12-12 22:52:55 | [diff] [blame] | 1498 | view_render_widget->screen_info(), blink::kWebDisplayModeUndefined, |
danakj | 6dcbc596 | 2018-11-16 16:45:42 | [diff] [blame] | 1499 | /*is_frozen=*/false, |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1500 | /*hidden=*/false, |
| 1501 | /*never_visible=*/false, std::move(widget_channel_request)); |
| 1502 | |
| 1503 | // The returned WebPagePopup is self-referencing, so the pointer here is not |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 1504 | // an owning pointer. It is de-referenced by calling Close(). |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1505 | blink::WebPagePopup* popup_web_widget = |
| 1506 | blink::WebPagePopup::Create(popup_widget.get()); |
| 1507 | |
| 1508 | // Adds a self-reference on the |popup_widget| so it will not be destroyed |
| 1509 | // when leaving scope. The WebPagePopup takes responsibility for Close()ing |
| 1510 | // and thus destroying the RenderWidget. |
| 1511 | popup_widget->InitForPopup(std::move(opener_callback), popup_web_widget); |
| 1512 | // TODO(crbug.com/419087): RenderWidget has some weird logic for picking a |
| 1513 | // WebWidget which doesn't apply to this case. So we verify. This can go away |
| 1514 | // when RenderWidget::GetWebWidget() is just a simple accessor. |
| 1515 | DCHECK_EQ(popup_widget->GetWebWidget(), popup_web_widget); |
| 1516 | |
| 1517 | // Devtools emulation, which may be currently applied to the |
| 1518 | // |view_render_widget|, should also apply to the new popup. This doesn't |
| 1519 | // happen automatically. |
| 1520 | popup_widget->ApplyEmulatedScreenMetricsForPopupWidget(view_render_widget); |
| 1521 | |
| 1522 | return popup_web_widget; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1523 | } |
| 1524 | |
danakj | 295c43f18 | 2019-03-13 16:37:17 | [diff] [blame] | 1525 | void RenderViewImpl::DoDeferredClose() { |
| 1526 | // The main widget is currently not active. The active main frame widget is |
| 1527 | // in a different process. Have the browser route the close request to the |
| 1528 | // active widget instead, so that the correct unload handlers are run. |
| 1529 | Send(new ViewHostMsg_RouteCloseEvent(GetRoutingID())); |
| 1530 | } |
| 1531 | |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 1532 | void RenderViewImpl::CloseWindowSoon() { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 1533 | DCHECK(RenderThread::IsMainThread()); |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 1534 | if (render_widget_->is_frozen()) { |
danakj | 295c43f18 | 2019-03-13 16:37:17 | [diff] [blame] | 1535 | // Ask the RenderViewHost with a local main frame to initiate close. We |
| 1536 | // could be called from deep in Javascript. If we ask the RenderViewHost to |
| 1537 | // close now, the window could be closed before the JS finishes executing, |
| 1538 | // thanks to nested message loops running and handling the resuliting Close |
| 1539 | // IPC. So instead, post a message back to the message loop, which won't run |
| 1540 | // until the JS is complete, and then the Close request can be sent. |
| 1541 | GetCleanupTaskRunner()->PostTask( |
| 1542 | FROM_HERE, base::BindOnce(&RenderViewImpl::DoDeferredClose, |
| 1543 | weak_ptr_factory_.GetWeakPtr())); |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 1544 | return; |
| 1545 | } |
| 1546 | |
| 1547 | // If the main widget is not frozen then the Close request goes directly |
| 1548 | // through it, because the RenderWidget ultimately owns the RenderViewImpl. |
| 1549 | render_widget_->CloseWidgetSoon(); |
| 1550 | } |
| 1551 | |
Daniel Murphy | 31bbb8b1 | 2018-02-07 21:44:10 | [diff] [blame] | 1552 | base::StringPiece RenderViewImpl::GetSessionStorageNamespaceId() { |
| 1553 | CHECK(!session_storage_namespace_id_.empty()); |
Daniel Murphy | 0ce6e2c | 2017-11-21 01:54:26 | [diff] [blame] | 1554 | return session_storage_namespace_id_; |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1555 | } |
| 1556 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1557 | void RenderViewImpl::PrintPage(WebLocalFrame* frame) { |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 1558 | RenderFrameImpl::FromWebFrame(frame)->ScriptedPrint( |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 1559 | GetWidget()->input_handler().handling_input_event()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1560 | } |
| 1561 | |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 1562 | void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 1563 | // The previous WebFrameWidget must already be detached by CloseForFrame(). |
| 1564 | DCHECK(!frame_widget_); |
| 1565 | frame_widget_ = frame_widget; |
danakj | efcb843 | 2019-01-16 18:47:14 | [diff] [blame] | 1566 | |
| 1567 | // Initialization for the WebFrameWidget that should only occur for the main |
| 1568 | // frame, and that uses types not allowed in blink. This should maybe be |
| 1569 | // passed to the creation of the WebFrameWidget or the main RenderFrame. |
| 1570 | const base::CommandLine& command_line = |
| 1571 | *base::CommandLine::ForCurrentProcess(); |
danakj | 175a17a | 2019-03-15 23:10:38 | [diff] [blame] | 1572 | render_widget_->SetShowFPSCounter( |
danakj | efcb843 | 2019-01-16 18:47:14 | [diff] [blame] | 1573 | command_line.HasSwitch(cc::switches::kShowFPSCounter)); |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 1574 | } |
| 1575 | |
danakj | 8f4465b | 2018-11-07 20:11:28 | [diff] [blame] | 1576 | void RenderViewImpl::DetachWebFrameWidget() { |
danakj | b08b371 | 2019-01-16 18:59:56 | [diff] [blame] | 1577 | DCHECK(GetWidget()->is_frozen() || GetWidget()->is_closing()); |
danakj | 8f4465b | 2018-11-07 20:11:28 | [diff] [blame] | 1578 | DCHECK(frame_widget_); |
danakj | 8f4465b | 2018-11-07 20:11:28 | [diff] [blame] | 1579 | frame_widget_->Close(); |
| 1580 | frame_widget_ = nullptr; |
| 1581 | } |
| 1582 | |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 1583 | void RenderViewImpl::SetZoomLevel(double zoom_level) { |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1584 | // If we change the zoom level for the view, make sure any subsequent subframe |
| 1585 | // loads reflect the current zoom level. |
| 1586 | page_zoom_level_ = zoom_level; |
| 1587 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1588 | webview()->SetZoomLevel(zoom_level); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1589 | for (auto& observer : observers_) |
| 1590 | observer.OnZoomLevelChanged(); |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 1591 | } |
| 1592 | |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1593 | void RenderViewImpl::SetValidationMessageDirection( |
| 1594 | base::string16* wrapped_main_text, |
| 1595 | blink::WebTextDirection main_text_hint, |
| 1596 | base::string16* wrapped_sub_text, |
| 1597 | blink::WebTextDirection sub_text_hint) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1598 | if (main_text_hint == blink::kWebTextDirectionLeftToRight) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1599 | *wrapped_main_text = |
| 1600 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1601 | } else if (main_text_hint == blink::kWebTextDirectionRightToLeft && |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1602 | !base::i18n::IsRTL()) { |
| 1603 | base::i18n::WrapStringWithRTLFormatting(wrapped_main_text); |
| 1604 | } |
| 1605 | |
| 1606 | if (!wrapped_sub_text->empty()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1607 | if (sub_text_hint == blink::kWebTextDirectionLeftToRight) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1608 | *wrapped_sub_text = |
| 1609 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_sub_text); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1610 | } else if (sub_text_hint == blink::kWebTextDirectionRightToLeft) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1611 | base::i18n::WrapStringWithRTLFormatting(wrapped_sub_text); |
| 1612 | } |
| 1613 | } |
| 1614 | } |
| 1615 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1616 | void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 1617 | const GURL& fallback_url) { |
[email protected] | aa6b90b3 | 2010-04-26 15:49:58 | [diff] [blame] | 1618 | GURL latest_url = url.is_empty() ? fallback_url : url; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1619 | if (latest_url == target_url_) |
| 1620 | return; |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1621 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1622 | // Tell the browser to display a destination link. |
| 1623 | if (target_url_status_ == TARGET_INFLIGHT || |
| 1624 | target_url_status_ == TARGET_PENDING) { |
| 1625 | // If we have a request in-flight, save the URL to be sent when we |
| 1626 | // receive an ACK to the in-flight request. We can happily overwrite |
| 1627 | // any existing pending sends. |
| 1628 | pending_target_url_ = latest_url; |
| 1629 | target_url_status_ = TARGET_PENDING; |
| 1630 | } else { |
mnaganov | bf08742 | 2015-12-16 05:10:03 | [diff] [blame] | 1631 | // URLs larger than |kMaxURLChars| cannot be sent through IPC - |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1632 | // see |ParamTraits<GURL>|. |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 1633 | if (latest_url.possibly_invalid_spec().size() > url::kMaxURLChars) |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1634 | latest_url = GURL(); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1635 | Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), latest_url)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1636 | target_url_ = latest_url; |
| 1637 | target_url_status_ = TARGET_INFLIGHT; |
| 1638 | } |
| 1639 | } |
| 1640 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1641 | void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { |
creis | ce0ef357 | 2017-01-26 17:53:08 | [diff] [blame] | 1642 | // Keep track of which frames have pending updates. |
| 1643 | frames_with_pending_state_.insert(frame->GetRoutingID()); |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1644 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1645 | int delay; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1646 | if (send_content_state_immediately_) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1647 | delay = 0; |
danakj | 7874491 | 2018-11-30 23:46:42 | [diff] [blame] | 1648 | else if (GetWebView()->IsHidden()) |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1649 | delay = kDelaySecondsForContentStateSyncHidden; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1650 | else |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1651 | delay = kDelaySecondsForContentStateSync; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1652 | |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1653 | if (nav_state_sync_timer_.IsRunning()) { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1654 | // The timer is already running. If the delay of the timer maches the amount |
| 1655 | // we want to delay by, then return. Otherwise stop the timer so that it |
| 1656 | // gets started with the right delay. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1657 | if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1658 | return; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1659 | nav_state_sync_timer_.Stop(); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1660 | } |
| 1661 | |
creis | ce0ef357 | 2017-01-26 17:53:08 | [diff] [blame] | 1662 | // Tell each frame with pending state to inform the browser. |
danakj | 19f3e51 | 2018-12-14 21:02:05 | [diff] [blame] | 1663 | nav_state_sync_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(delay), |
| 1664 | this, &RenderViewImpl::SendFrameStateUpdates); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1665 | } |
| 1666 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1667 | void RenderViewImpl::SetMouseOverURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1668 | mouse_over_url_ = GURL(url); |
| 1669 | UpdateTargetURL(mouse_over_url_, focus_url_); |
| 1670 | } |
| 1671 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1672 | void RenderViewImpl::SetKeyboardFocusURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1673 | focus_url_ = GURL(url); |
| 1674 | UpdateTargetURL(focus_url_, mouse_over_url_); |
| 1675 | } |
| 1676 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1677 | bool RenderViewImpl::AcceptsLoadDrops() { |
[email protected] | 28b92df | 2009-09-25 17:35:45 | [diff] [blame] | 1678 | return renderer_preferences_.can_accept_load_drops; |
| 1679 | } |
| 1680 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1681 | void RenderViewImpl::FocusNext() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1682 | Send(new ViewHostMsg_TakeFocus(GetRoutingID(), false)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1683 | } |
| 1684 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1685 | void RenderViewImpl::FocusPrevious() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1686 | Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1687 | } |
| 1688 | |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1689 | void RenderViewImpl::FocusedElementChanged(const WebElement& from_element, |
| 1690 | const WebElement& to_element) { |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1691 | RenderFrameImpl* previous_frame = nullptr; |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1692 | if (!from_element.IsNull()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1693 | previous_frame = |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1694 | RenderFrameImpl::FromWebFrame(from_element.GetDocument().GetFrame()); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1695 | RenderFrameImpl* new_frame = nullptr; |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1696 | if (!to_element.IsNull()) |
| 1697 | new_frame = |
| 1698 | RenderFrameImpl::FromWebFrame(to_element.GetDocument().GetFrame()); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1699 | |
| 1700 | if (previous_frame && previous_frame != new_frame) |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1701 | previous_frame->FocusedElementChanged(WebElement()); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1702 | if (new_frame) |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1703 | new_frame->FocusedElementChanged(to_element); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1704 | |
| 1705 | // TODO(dmazzoni): remove once there's a separate a11y tree per frame. |
nasko | e8d11575 | 2015-08-07 00:43:13 | [diff] [blame] | 1706 | if (main_render_frame_) |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1707 | main_render_frame_->FocusedElementChangedForAccessibility(to_element); |
[email protected] | 08e9e13 | 2010-06-01 16:58:49 | [diff] [blame] | 1708 | } |
| 1709 | |
Philip Rogers | 07965881 | 2018-08-01 23:19:09 | [diff] [blame] | 1710 | void RenderViewImpl::DidUpdateMainFrameLayout() { |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1711 | for (auto& observer : observers_) |
Philip Rogers | 07965881 | 2018-08-01 23:19:09 | [diff] [blame] | 1712 | observer.DidUpdateMainFrameLayout(); |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 1713 | |
Philip Rogers | 33cd2bcc | 2018-08-13 21:29:29 | [diff] [blame] | 1714 | // The main frame may have changed size. |
| 1715 | needs_preferred_size_update_ = true; |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 1716 | } |
| 1717 | |
Arthur Sonzogni | a7d715a | 2018-09-20 16:11:13 | [diff] [blame] | 1718 | void RenderViewImpl::NavigateBackForwardSoon(int offset, |
| 1719 | bool has_user_gesture) { |
Alex Clarke | bf3dceb | 2017-11-24 12:27:43 | [diff] [blame] | 1720 | history_navigation_virtual_time_pauser_ = |
| 1721 | RenderThreadImpl::current() |
Yuta Kitamura | 3331f5c | 2018-04-05 11:12:25 | [diff] [blame] | 1722 | ->GetWebMainThreadScheduler() |
Alex Clarke | b28db54 | 2018-02-07 12:53:13 | [diff] [blame] | 1723 | ->CreateWebScopedVirtualTimePauser( |
Alex Clarke | aaf006b | 2018-04-05 18:35:24 | [diff] [blame] | 1724 | "NavigateBackForwardSoon", |
Alex Clarke | b28db54 | 2018-02-07 12:53:13 | [diff] [blame] | 1725 | blink::WebScopedVirtualTimePauser::VirtualTaskDuration::kInstant); |
Alex Clarke | aaf006b | 2018-04-05 18:35:24 | [diff] [blame] | 1726 | history_navigation_virtual_time_pauser_.PauseVirtualTime(); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1727 | } |
| 1728 | |
Alex Clarke | bf3dceb | 2017-11-24 12:27:43 | [diff] [blame] | 1729 | void RenderViewImpl::DidCommitProvisionalHistoryLoad() { |
Alex Clarke | aaf006b | 2018-04-05 18:35:24 | [diff] [blame] | 1730 | history_navigation_virtual_time_pauser_.UnpauseVirtualTime(); |
Alex Clarke | bf3dceb | 2017-11-24 12:27:43 | [diff] [blame] | 1731 | } |
| 1732 | |
Michael Martis | 2415478f | 2019-04-17 07:35:00 | [diff] [blame] | 1733 | void RenderViewImpl::RegisterRendererPreferenceWatcher( |
Leon Han | f4003a16 | 2019-01-28 05:31:58 | [diff] [blame] | 1734 | blink::mojom::RendererPreferenceWatcherPtr watcher) { |
Makoto Shimazu | c3c730e | 2018-08-15 09:51:11 | [diff] [blame] | 1735 | renderer_preference_watchers_.AddPtr(std::move(watcher)); |
| 1736 | } |
| 1737 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1738 | int RenderViewImpl::HistoryBackListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1739 | return history_list_offset_ < 0 ? 0 : history_list_offset_; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1740 | } |
| 1741 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1742 | int RenderViewImpl::HistoryForwardListCount() { |
| 1743 | return history_list_length_ - HistoryBackListCount() - 1; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1744 | } |
| 1745 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1746 | // blink::WebWidgetClient ---------------------------------------------------- |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1747 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1748 | bool RenderViewImpl::CanHandleGestureEvent() { |
slangley | 1a6375e6 | 2017-03-29 06:03:23 | [diff] [blame] | 1749 | return true; |
| 1750 | } |
| 1751 | |
Avi Drissman | fb96126 | 2019-03-05 22:50:29 | [diff] [blame] | 1752 | // TODO(https://crbug.com/937569): Remove this in Chrome 82. |
| 1753 | bool RenderViewImpl::AllowPopupsDuringPageUnload() { |
| 1754 | const base::CommandLine& command_line = |
| 1755 | *base::CommandLine::ForCurrentProcess(); |
| 1756 | return command_line.HasSwitch(switches::kAllowPopupsDuringPageUnload); |
| 1757 | } |
| 1758 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1759 | bool RenderViewImpl::CanUpdateLayout() { |
slangley | 1a6375e6 | 2017-03-29 06:03:23 | [diff] [blame] | 1760 | return true; |
| 1761 | } |
| 1762 | |
Mustaq Ahmed | 55944cb | 2018-05-25 20:44:27 | [diff] [blame] | 1763 | // blink::WebLocalFrameClient |
| 1764 | // ----------------------------------------------------- |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1765 | |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1766 | void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name, |
| 1767 | const std::string& value) { |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 1768 | GetWidget()->SetEditCommandForNextKeyEvent(name, value); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1769 | } |
| 1770 | |
| 1771 | void RenderViewImpl::ClearEditCommands() { |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 1772 | GetWidget()->ClearEditCommands(); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1773 | } |
| 1774 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1775 | const std::string& RenderViewImpl::GetAcceptLanguages() { |
[email protected] | b38806a | 2013-10-04 16:01:38 | [diff] [blame] | 1776 | return renderer_preferences_.accept_languages; |
| 1777 | } |
| 1778 | |
Ahmed Fakhry | 58e6ef54 | 2018-09-04 18:05:38 | [diff] [blame] | 1779 | void RenderViewImpl::UpdateBrowserControlsState( |
| 1780 | BrowserControlsState constraints, |
| 1781 | BrowserControlsState current, |
| 1782 | bool animate) { |
David Bokan | 3746d2c | 2018-10-29 20:21:35 | [diff] [blame] | 1783 | TRACE_EVENT2("renderer", "RenderViewImpl::UpdateBrowserControlsState", |
| 1784 | "Constraint", static_cast<int>(constraints), "Current", |
| 1785 | static_cast<int>(current)); |
| 1786 | TRACE_EVENT_INSTANT1("renderer", "is_animated", TRACE_EVENT_SCOPE_THREAD, |
| 1787 | "animated", animate); |
| 1788 | |
David Bokan | 1e37ebf | 2018-10-16 13:53:37 | [diff] [blame] | 1789 | if (GetWidget() && GetWidget()->layer_tree_view()) { |
| 1790 | GetWidget()->layer_tree_view()->UpdateBrowserControlsState( |
| 1791 | ContentToCc(constraints), ContentToCc(current), animate); |
Ahmed Fakhry | 58e6ef54 | 2018-09-04 18:05:38 | [diff] [blame] | 1792 | } |
| 1793 | |
| 1794 | top_controls_constraints_ = constraints; |
| 1795 | } |
| 1796 | |
David Bokan | 1e37ebf | 2018-10-16 13:53:37 | [diff] [blame] | 1797 | #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 1798 | |
Ahmed Fakhry | 58e6ef54 | 2018-09-04 18:05:38 | [diff] [blame] | 1799 | void RenderViewImpl::didScrollWithKeyboard(const blink::WebSize& delta) { |
| 1800 | if (delta.height == 0) |
| 1801 | return; |
| 1802 | |
| 1803 | BrowserControlsState current = delta.height < 0 |
| 1804 | ? BROWSER_CONTROLS_STATE_SHOWN |
| 1805 | : BROWSER_CONTROLS_STATE_HIDDEN; |
| 1806 | |
| 1807 | UpdateBrowserControlsState(top_controls_constraints_, current, true); |
| 1808 | } |
| 1809 | |
| 1810 | #endif |
| 1811 | |
danakj | dea2efb | 2016-03-10 19:13:17 | [diff] [blame] | 1812 | void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) { |
danakj | 175a17a | 2019-03-15 23:10:38 | [diff] [blame] | 1813 | render_widget_->ConvertViewportToWindow(rect); |
oshima | e2b3b40 | 2015-12-04 04:27:24 | [diff] [blame] | 1814 | } |
| 1815 | |
huangs | 2a34235 | 2015-12-15 16:59:24 | [diff] [blame] | 1816 | gfx::RectF RenderViewImpl::ElementBoundsInWindow( |
| 1817 | const blink::WebElement& element) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1818 | blink::WebRect bounding_box_in_window = element.BoundsInViewport(); |
danakj | 175a17a | 2019-03-15 23:10:38 | [diff] [blame] | 1819 | render_widget_->ConvertViewportToWindow(&bounding_box_in_window); |
huangs | 2a34235 | 2015-12-15 16:59:24 | [diff] [blame] | 1820 | return gfx::RectF(bounding_box_in_window); |
| 1821 | } |
| 1822 | |
Philip Rogers | 601fd07 | 2018-08-07 22:58:22 | [diff] [blame] | 1823 | void RenderViewImpl::UpdatePreferredSize() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 1824 | // We don't always want to send the change messages over IPC, only if we've |
| 1825 | // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 1826 | // message. |
| 1827 | if (!send_preferred_size_changes_ || !webview()) |
| 1828 | return; |
Philip Rogers | 33cd2bcc | 2018-08-13 21:29:29 | [diff] [blame] | 1829 | |
| 1830 | if (!needs_preferred_size_update_) |
| 1831 | return; |
| 1832 | needs_preferred_size_update_ = false; |
| 1833 | |
oshima | 1a688b5c | 2017-06-16 19:00:13 | [diff] [blame] | 1834 | blink::WebSize tmp_size = webview()->ContentsPreferredMinimumSize(); |
| 1835 | blink::WebRect tmp_rect(0, 0, tmp_size.width, tmp_size.height); |
danakj | 175a17a | 2019-03-15 23:10:38 | [diff] [blame] | 1836 | render_widget_->ConvertViewportToWindow(&tmp_rect); |
oshima | 1a688b5c | 2017-06-16 19:00:13 | [diff] [blame] | 1837 | gfx::Size size(tmp_rect.width, tmp_rect.height); |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 1838 | if (size == preferred_size_) |
| 1839 | return; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 1840 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 1841 | preferred_size_ = size; |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1842 | Send(new ViewHostMsg_DidContentsPreferredSizeChange(GetRoutingID(), |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 1843 | preferred_size_)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1844 | } |
| 1845 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1846 | blink::WebString RenderViewImpl::AcceptLanguages() { |
| 1847 | return WebString::FromUTF8(renderer_preferences_.accept_languages); |
[email protected] | 9982c80 | 2013-06-12 15:22:06 | [diff] [blame] | 1848 | } |
| 1849 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1850 | // RenderView implementation --------------------------------------------------- |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1851 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1852 | bool RenderViewImpl::Send(IPC::Message* message) { |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame^] | 1853 | // No messages sent through RenderView come without a routing id, yay. Let's |
| 1854 | // keep that up. |
| 1855 | CHECK_NE(message->routing_id(), MSG_ROUTING_NONE); |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 1856 | |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame^] | 1857 | // Don't send any messages after the browser has told us to close. |
| 1858 | if (GetWidget()->is_closing()) { |
| 1859 | delete message; |
| 1860 | return false; |
| 1861 | } |
| 1862 | return RenderThread::Get()->Send(message); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1863 | } |
| 1864 | |
Peter Kasting | a4a3ed1 | 2018-01-31 04:07:59 | [diff] [blame] | 1865 | RenderWidget* RenderViewImpl::GetWidget() { |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 1866 | return render_widget_; |
| 1867 | } |
| 1868 | |
| 1869 | const RenderWidget* RenderViewImpl::GetWidget() const { |
| 1870 | return render_widget_; |
avi | 8a45c109 | 2016-03-01 16:12:34 | [diff] [blame] | 1871 | } |
| 1872 | |
mostynb | c3335323 | 2014-09-12 09:38:31 | [diff] [blame] | 1873 | RenderFrameImpl* RenderViewImpl::GetMainRenderFrame() { |
nasko | 77de231 | 2015-05-12 03:09:16 | [diff] [blame] | 1874 | return main_render_frame_; |
[email protected] | b849847b | 2013-12-10 21:57:58 | [diff] [blame] | 1875 | } |
| 1876 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1877 | int RenderViewImpl::GetRoutingID() { |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 1878 | return routing_id_; |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1879 | } |
| 1880 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1881 | gfx::Size RenderViewImpl::GetSize() { |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 1882 | return GetWidget()->size(); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1883 | } |
| 1884 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1885 | float RenderViewImpl::GetDeviceScaleFactor() { |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 1886 | return GetWidget()->GetWebScreenInfo().device_scale_factor; |
oshima | 129b75e | 2016-01-14 09:15:14 | [diff] [blame] | 1887 | } |
| 1888 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1889 | float RenderViewImpl::GetZoomLevel() { |
Marc Treib | 06d6603 | 2017-10-19 08:43:20 | [diff] [blame] | 1890 | return page_zoom_level_; |
| 1891 | } |
| 1892 | |
thestig | 8a8fdfd3 | 2017-05-06 18:46:54 | [diff] [blame] | 1893 | const WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1894 | return webkit_preferences_; |
| 1895 | } |
| 1896 | |
[email protected] | 324825d | 2012-11-30 12:37:15 | [diff] [blame] | 1897 | void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { |
| 1898 | OnUpdateWebPreferences(preferences); |
| 1899 | } |
| 1900 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1901 | blink::WebView* RenderViewImpl::GetWebView() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1902 | return webview(); |
| 1903 | } |
| 1904 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1905 | bool RenderViewImpl::GetContentStateImmediately() { |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1906 | return send_content_state_immediately_; |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1907 | } |
| 1908 | |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 1909 | void RenderViewImpl::OnSetPageScale(float page_scale_factor) { |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 1910 | if (!webview()) |
| 1911 | return; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1912 | webview()->SetPageScaleFactor(page_scale_factor); |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 1913 | } |
| 1914 | |
akaba | 3483d8f | 2018-07-10 21:43:09 | [diff] [blame] | 1915 | void RenderViewImpl::UpdateZoomLevel(double zoom_level) { |
danakj | a5c39d5 | 2018-12-13 22:20:56 | [diff] [blame] | 1916 | webview()->CancelPagePopup(); |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1917 | SetZoomLevel(zoom_level); |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 1918 | } |
| 1919 | |
danakj | 7874491 | 2018-11-30 23:46:42 | [diff] [blame] | 1920 | void RenderViewImpl::ApplyPageHidden(bool hidden, bool initial_setting) { |
| 1921 | webview()->SetIsHidden(hidden, initial_setting); |
| 1922 | // Note: RenderWidget visibility is separately set from the IPC handlers, and |
| 1923 | // does not change when tests override the visibility of the Page. |
danakj | 1b35e9d | 2018-11-07 19:09:28 | [diff] [blame] | 1924 | } |
| 1925 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1926 | void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 1927 | webkit_preferences_ = prefs; |
danakj | fd0c7f4 | 2018-10-12 18:01:08 | [diff] [blame] | 1928 | ApplyWebPreferences(webkit_preferences_, webview()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1929 | } |
| 1930 | |
[email protected] | 2bf834f | 2011-11-17 20:02:21 | [diff] [blame] | 1931 | void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 1932 | if (send_preferred_size_changes_) |
| 1933 | return; |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 1934 | send_preferred_size_changes_ = true; |
[email protected] | 770dd8b | 2010-05-24 18:11:39 | [diff] [blame] | 1935 | |
Philip Rogers | 601fd07 | 2018-08-07 22:58:22 | [diff] [blame] | 1936 | if (!webview()) |
| 1937 | return; |
| 1938 | |
Philip Rogers | 33cd2bcc | 2018-08-13 21:29:29 | [diff] [blame] | 1939 | needs_preferred_size_update_ = true; |
| 1940 | |
Philip Rogers | 601fd07 | 2018-08-07 22:58:22 | [diff] [blame] | 1941 | // We need to ensure |UpdatePreferredSize| gets called. If a layout is needed, |
| 1942 | // force an update here which will call |DidUpdateMainFrameLayout|. |
danakj | 763c240 | 2018-11-09 02:46:22 | [diff] [blame] | 1943 | webview()->MainFrameWidget()->UpdateLifecycle( |
Stephen Chenney | ec431261 | 2018-11-21 12:40:16 | [diff] [blame] | 1944 | WebWidget::LifecycleUpdate::kLayout, |
| 1945 | WebWidget::LifecycleUpdateReason::kOther); |
Philip Rogers | 601fd07 | 2018-08-07 22:58:22 | [diff] [blame] | 1946 | |
| 1947 | // If a layout was not needed, |DidUpdateMainFrameLayout| will not be called. |
| 1948 | // We explicitly update the preferred size here to ensure the preferred size |
| 1949 | // notification is sent. |
| 1950 | UpdatePreferredSize(); |
[email protected] | 0666aef | 2009-05-13 19:48:08 | [diff] [blame] | 1951 | } |
| 1952 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1953 | void RenderViewImpl::OnSetRendererPrefs( |
Leon Han | c819dc6 | 2019-01-28 04:30:19 | [diff] [blame] | 1954 | const blink::mojom::RendererPreferences& renderer_prefs) { |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 1955 | std::string old_accept_languages = renderer_preferences_.accept_languages; |
| 1956 | |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1957 | renderer_preferences_ = renderer_prefs; |
ananta | 59b9fe7 | 2015-04-07 01:33:26 | [diff] [blame] | 1958 | |
Makoto Shimazu | c3c730e | 2018-08-15 09:51:11 | [diff] [blame] | 1959 | renderer_preference_watchers_.ForAllPtrs( |
Leon Han | f4003a16 | 2019-01-28 05:31:58 | [diff] [blame] | 1960 | [&renderer_prefs](blink::mojom::RendererPreferenceWatcher* watcher) { |
Leon Han | 2c81b5d | 2019-01-25 01:58:33 | [diff] [blame] | 1961 | watcher->NotifyUpdate(renderer_prefs.Clone()); |
Makoto Shimazu | c3c730e | 2018-08-15 09:51:11 | [diff] [blame] | 1962 | }); |
| 1963 | |
[email protected] | 6e282c9 | 2009-07-24 01:19:37 | [diff] [blame] | 1964 | UpdateFontRenderingFromRendererPrefs(); |
scottmg | b92365e | 2016-08-30 20:54:40 | [diff] [blame] | 1965 | UpdateThemePrefs(); |
Leon Han | 2c81b5d | 2019-01-25 01:58:33 | [diff] [blame] | 1966 | blink::SetCaretBlinkInterval( |
| 1967 | renderer_prefs.caret_blink_interval.has_value() |
| 1968 | ? renderer_prefs.caret_blink_interval.value() |
| 1969 | : base::TimeDelta::FromMilliseconds( |
Leon Han | c819dc6 | 2019-01-28 04:30:19 | [diff] [blame] | 1970 | blink::mojom::kDefaultCaretBlinkIntervalInMilliseconds)); |
[email protected] | 38a8571 | 2013-01-02 22:45:02 | [diff] [blame] | 1971 | |
Christopher Cameron | f8e279d3 | 2019-05-15 18:50:56 | [diff] [blame] | 1972 | #if defined(USE_AURA) |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 1973 | if (renderer_prefs.use_custom_colors) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1974 | blink::SetFocusRingColor(renderer_prefs.focus_ring_color); |
Christopher Cameron | f6fc7ec | 2019-05-13 18:52:53 | [diff] [blame] | 1975 | blink::SetSelectionColors(renderer_prefs.active_selection_bg_color, |
| 1976 | renderer_prefs.active_selection_fg_color, |
| 1977 | renderer_prefs.inactive_selection_bg_color, |
| 1978 | renderer_prefs.inactive_selection_fg_color); |
| 1979 | if (webview()) |
danakj | 763c240 | 2018-11-09 02:46:22 | [diff] [blame] | 1980 | webview()->MainFrameWidget()->ThemeChanged(); |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 1981 | } |
Christopher Cameron | f8e279d3 | 2019-05-15 18:50:56 | [diff] [blame] | 1982 | #endif |
[email protected] | d299d97 | 2012-03-23 02:26:55 | [diff] [blame] | 1983 | |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 1984 | if (webview() && |
| 1985 | old_accept_languages != renderer_preferences_.accept_languages) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1986 | webview()->AcceptLanguagesChanged(); |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 1987 | } |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1988 | } |
| 1989 | |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1990 | void RenderViewImpl::OnPluginActionAt(const gfx::Point& location, |
| 1991 | const WebPluginAction& action) { |
| 1992 | if (webview()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1993 | webview()->PerformPluginAction(action, location); |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1994 | } |
| 1995 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1996 | void RenderViewImpl::OnClosePage() { |
lukasza | 5d0dee4 | 2017-06-14 21:57:37 | [diff] [blame] | 1997 | // ViewMsg_ClosePage should only be sent to active, non-swapped-out views. |
| 1998 | DCHECK(webview()->MainFrame()->IsWebLocalFrame()); |
| 1999 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2000 | // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 2001 | // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 2002 | // in the onunload handler from appearing. For now, we're bypassing that and |
| 2003 | // calling the FrameLoader's CloseURL method directly. This should be |
| 2004 | // revisited to avoid having two ways to close a page. Having a single way |
| 2005 | // to close that can run onunload is also useful for fixing |
| 2006 | // http://b/issue?id=753080. |
lukasza | 5d0dee4 | 2017-06-14 21:57:37 | [diff] [blame] | 2007 | webview()->MainFrame()->ToWebLocalFrame()->DispatchUnloadEvent(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2008 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2009 | Send(new ViewHostMsg_ClosePage_ACK(GetRoutingID())); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2010 | } |
| 2011 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2012 | void RenderViewImpl::OnMoveOrResizeStarted() { |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2013 | if (webview()) |
danakj | a5c39d5 | 2018-12-13 22:20:56 | [diff] [blame] | 2014 | webview()->CancelPagePopup(); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2015 | } |
| 2016 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2017 | void RenderViewImpl::OnPageWasHidden() { |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2018 | #if defined(OS_ANDROID) |
| 2019 | SuspendVideoCaptureDevices(true); |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2020 | #endif |
[email protected] | 2d7b82c | 2012-06-01 05:57:50 | [diff] [blame] | 2021 | |
danakj | 7874491 | 2018-11-30 23:46:42 | [diff] [blame] | 2022 | ApplyPageHidden(/*hidden=*/true, /*initial_setting=*/false); |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 2023 | } |
| 2024 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2025 | void RenderViewImpl::OnPageWasShown() { |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2026 | #if defined(OS_ANDROID) |
| 2027 | SuspendVideoCaptureDevices(false); |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 2028 | #endif |
| 2029 | |
danakj | 7874491 | 2018-11-30 23:46:42 | [diff] [blame] | 2030 | ApplyPageHidden(/*hidden=*/false, /*initial_setting=*/false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 2031 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 2032 | |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 2033 | void RenderViewImpl::OnUpdateScreenInfo(const ScreenInfo& screen_info) { |
| 2034 | // This IPC only updates the screen info on RenderViews that have a remote |
| 2035 | // main frame. For local main frames, the ScreenInfo is updated in |
| 2036 | // ViewMsg_Resize. |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 2037 | // TODO(danakj): Move this message to RenderWidget? |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 2038 | if (!main_render_frame_) |
danakj | 5380269 | 2018-07-25 21:46:44 | [diff] [blame] | 2039 | GetWidget()->set_screen_info(screen_info); |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 2040 | } |
| 2041 | |
W. James MacLean | 7c858107 | 2019-06-18 18:07:53 | [diff] [blame] | 2042 | void RenderViewImpl::OnUpdatePageVisualProperties( |
| 2043 | const gfx::Size& viewport_size) { |
| 2044 | // Using this pathway to update the visual viewport should only happen for |
| 2045 | // remote main frames. Local main frames will update the viewport size by |
| 2046 | // RenderWidget calling RenderViewImpl::ResizeVisualViewport() directly. |
| 2047 | if (!main_render_frame_) { |
| 2048 | // Since the viewport size comes directly from the browser, we may |
| 2049 | // need to adjust it for device scale factor. |
| 2050 | // TODO(wjmaclean): we should look into having the browser apply this scale |
| 2051 | // before sending the viewport size. |
| 2052 | gfx::Size device_scale_factor_scaled_visual_viewport_size = viewport_size; |
| 2053 | if (RenderThreadImpl::current()->IsUseZoomForDSFEnabled()) { |
| 2054 | device_scale_factor_scaled_visual_viewport_size = gfx::ScaleToCeiledSize( |
| 2055 | viewport_size, GetScreenInfo().device_scale_factor); |
| 2056 | } |
| 2057 | // TODO(wjmaclean): At present this makes use of the WebWidget part of |
| 2058 | // WebViewImpl in order to be able to re-size the view |
| 2059 | // without having to plumb through the browser-controls state. When |
| 2060 | // WebViewImpl is no longer a WebWidget, then we'll need to plumb these |
| 2061 | // values as well. At that time, presumably WebViewImpl::Resize() will |
| 2062 | // also have migrated to the WebView API. https://crbug.com/419087 |
| 2063 | // Note: If WebViewImpl stops having any widget association when the |
| 2064 | // main frame is remote, then this should be replaced with a direct call to |
| 2065 | // webview()->ResizeVisualViewport(). |
| 2066 | webview()->MainFrameWidget()->Resize( |
| 2067 | device_scale_factor_scaled_visual_viewport_size); |
| 2068 | } |
| 2069 | } |
| 2070 | |
| 2071 | void RenderViewImpl::ResizeVisualViewportForWidget( |
| 2072 | const gfx::Size& scaled_viewport_size) { |
| 2073 | // This function is currently only called for local main frames. Once remote |
| 2074 | // main frames no longer have a RenderWidget, they may also route through |
| 2075 | // here via RenderViewImpl::OnUpdatePageVisualProperties(). In that case, |
| 2076 | // WebViewImpl will need to implement its Size() function based on something |
| 2077 | // other than the widget size. |
| 2078 | webview()->ResizeVisualViewport(scaled_viewport_size); |
| 2079 | } |
| 2080 | |
Francois Doray | 47f759d | 2018-06-11 18:13:51 | [diff] [blame] | 2081 | void RenderViewImpl::SetPageFrozen(bool frozen) { |
| 2082 | if (webview()) |
| 2083 | webview()->SetPageFrozen(frozen); |
Fadi Meawad | a6573e0 | 2018-03-10 00:52:11 | [diff] [blame] | 2084 | } |
| 2085 | |
W. James MacLean | 6219867 | 2019-06-04 16:46:10 | [diff] [blame] | 2086 | // This function receives TextAutosizerPageInfo from the main frame's renderer |
| 2087 | // and makes it available to other renderers with frames on the same page. |
| 2088 | void RenderViewImpl::OnTextAutosizerPageInfoChanged( |
| 2089 | const blink::WebTextAutosizerPageInfo& page_info) { |
| 2090 | // Only propagate the remote page info if our main frame is remote. It's |
| 2091 | // possible a main frame renderer may receive this message, as SendPageMessage |
| 2092 | // in RenderFrameHostManager may send to a speculative RenderFrameHost that |
| 2093 | // corresponds to a local main frame. Since a local main frame will generate |
| 2094 | // these values for itself, we shouldn't override them with values from |
| 2095 | // another renderer. |
| 2096 | if (!webview()->MainFrame()->IsWebLocalFrame()) |
| 2097 | webview()->SetTextAutosizePageInfo(page_info); |
| 2098 | } |
| 2099 | |
alexmos | 3fcd0ca | 2015-10-23 18:18:33 | [diff] [blame] | 2100 | void RenderViewImpl::SetFocus(bool enable) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2101 | // This is not an IPC message, don't go through the IPC handler. This is used |
| 2102 | // in cases where the IPC message should not happen. |
| 2103 | GetWidget()->SetFocus(enable); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 2104 | } |
| 2105 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2106 | void RenderViewImpl::ZoomLimitsChanged(double minimum_level, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2107 | double maximum_level) { |
a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 2108 | // Round the double to avoid returning incorrect minimum/maximum zoom |
| 2109 | // percentages. |
| 2110 | int minimum_percent = round( |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 2111 | ZoomLevelToZoomFactor(minimum_level) * 100); |
a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 2112 | int maximum_percent = round( |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 2113 | ZoomLevelToZoomFactor(maximum_level) * 100); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2114 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2115 | Send(new ViewHostMsg_UpdateZoomLimits(GetRoutingID(), minimum_percent, |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2116 | maximum_percent)); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2117 | } |
| 2118 | |
W. James MacLean | 233a64ff | 2019-05-18 16:18:49 | [diff] [blame] | 2119 | void RenderViewImpl::PageScaleFactorChanged(float page_scale_factor) { |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2120 | if (!webview()) |
| 2121 | return; |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 2122 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2123 | Send(new ViewHostMsg_PageScaleFactorChanged(GetRoutingID(), |
W. James MacLean | f40603e | 2019-03-25 17:23:06 | [diff] [blame] | 2124 | page_scale_factor)); |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2125 | } |
| 2126 | |
W. James MacLean | 6219867 | 2019-06-04 16:46:10 | [diff] [blame] | 2127 | void RenderViewImpl::DidUpdateTextAutosizerPageInfo( |
| 2128 | const blink::WebTextAutosizerPageInfo& page_info) { |
| 2129 | DCHECK(webview()->MainFrame()->IsWebLocalFrame()); |
| 2130 | Send(new ViewHostMsg_NotifyTextAutosizerPageInfoChangedInLocalMainFrame( |
| 2131 | GetRoutingID(), page_info)); |
| 2132 | } |
| 2133 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2134 | void RenderViewImpl::PageImportanceSignalsChanged() { |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 2135 | if (!webview() || !main_render_frame_) |
| 2136 | return; |
| 2137 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2138 | auto* web_signals = webview()->PageImportanceSignals(); |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 2139 | |
| 2140 | PageImportanceSignals signals; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2141 | signals.had_form_interaction = web_signals->HadFormInteraction(); |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 2142 | |
| 2143 | main_render_frame_->Send(new FrameHostMsg_UpdatePageImportanceSignals( |
| 2144 | main_render_frame_->GetRoutingID(), signals)); |
| 2145 | } |
| 2146 | |
danakj | 9a8a9cf | 2018-07-17 23:52:12 | [diff] [blame] | 2147 | void RenderViewImpl::DidAutoResize(const blink::WebSize& newSize) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2148 | GetWidget()->DidAutoResize(newSize); |
danakj | 9a8a9cf | 2018-07-17 23:52:12 | [diff] [blame] | 2149 | } |
| 2150 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2151 | void RenderViewImpl::DidFocus(blink::WebLocalFrame* calling_frame) { |
| 2152 | // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 2153 | // we won't have to test for user gesture anymore and we can |
| 2154 | // move that code back to render_widget.cc |
| 2155 | if (WebUserGestureIndicator::IsProcessingUserGesture(calling_frame) && |
Kent Tamura | 2eab5b1 | 2018-12-07 04:31:23 | [diff] [blame] | 2156 | !RenderThreadImpl::current()->web_test_mode()) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2157 | Send(new ViewHostMsg_Focus(GetRoutingID())); |
| 2158 | |
| 2159 | // Tattle on the frame that called |window.focus()|. |
| 2160 | RenderFrameImpl* calling_render_frame = |
| 2161 | RenderFrameImpl::FromWebFrame(calling_frame); |
| 2162 | if (calling_render_frame) |
| 2163 | calling_render_frame->FrameDidCallFocus(); |
| 2164 | } |
| 2165 | } |
| 2166 | |
danakj | 46b3dde | 2018-10-18 16:12:17 | [diff] [blame] | 2167 | blink::WebScreenInfo RenderViewImpl::GetScreenInfo() { |
| 2168 | const ScreenInfo& info = GetWidget()->screen_info(); |
| 2169 | |
| 2170 | blink::WebScreenInfo web_screen_info; |
| 2171 | web_screen_info.device_scale_factor = info.device_scale_factor; |
| 2172 | web_screen_info.color_space = info.color_space; |
| 2173 | web_screen_info.depth = info.depth; |
| 2174 | web_screen_info.depth_per_component = info.depth_per_component; |
| 2175 | web_screen_info.is_monochrome = info.is_monochrome; |
| 2176 | web_screen_info.rect = blink::WebRect(info.rect); |
| 2177 | web_screen_info.available_rect = blink::WebRect(info.available_rect); |
| 2178 | switch (info.orientation_type) { |
| 2179 | case SCREEN_ORIENTATION_VALUES_PORTRAIT_PRIMARY: |
| 2180 | web_screen_info.orientation_type = |
| 2181 | blink::kWebScreenOrientationPortraitPrimary; |
| 2182 | break; |
| 2183 | case SCREEN_ORIENTATION_VALUES_PORTRAIT_SECONDARY: |
| 2184 | web_screen_info.orientation_type = |
| 2185 | blink::kWebScreenOrientationPortraitSecondary; |
| 2186 | break; |
| 2187 | case SCREEN_ORIENTATION_VALUES_LANDSCAPE_PRIMARY: |
| 2188 | web_screen_info.orientation_type = |
| 2189 | blink::kWebScreenOrientationLandscapePrimary; |
| 2190 | break; |
| 2191 | case SCREEN_ORIENTATION_VALUES_LANDSCAPE_SECONDARY: |
| 2192 | web_screen_info.orientation_type = |
| 2193 | blink::kWebScreenOrientationLandscapeSecondary; |
| 2194 | break; |
| 2195 | default: |
| 2196 | web_screen_info.orientation_type = blink::kWebScreenOrientationUndefined; |
| 2197 | break; |
| 2198 | } |
| 2199 | web_screen_info.orientation_angle = info.orientation_angle; |
| 2200 | |
| 2201 | return web_screen_info; |
| 2202 | } |
| 2203 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2204 | #if defined(OS_ANDROID) |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2205 | void RenderViewImpl::SuspendVideoCaptureDevices(bool suspend) { |
| 2206 | if (!main_render_frame_) |
| 2207 | return; |
| 2208 | |
Chandan Padhi | 26dbd9b3 | 2017-11-27 11:13:35 | [diff] [blame] | 2209 | MediaStreamDeviceObserver* media_stream_device_observer = |
| 2210 | main_render_frame_->GetMediaStreamDeviceObserver(); |
| 2211 | if (!media_stream_device_observer) |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2212 | return; |
| 2213 | |
Guido Urdaneta | 73fa663 | 2019-01-14 18:46:26 | [diff] [blame] | 2214 | blink::MediaStreamDevices video_devices = |
Chandan Padhi | 26dbd9b3 | 2017-11-27 11:13:35 | [diff] [blame] | 2215 | media_stream_device_observer->GetNonScreenCaptureDevices(); |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2216 | RenderThreadImpl::current()->video_capture_impl_manager()->SuspendDevices( |
Chandan Padhi | 6dbfb73 | 2017-09-01 16:08:49 | [diff] [blame] | 2217 | video_devices, suspend); |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2218 | } |
estade | 6b9696bd | 2016-05-04 23:51:36 | [diff] [blame] | 2219 | #endif // defined(OS_ANDROID) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2220 | |
[email protected] | b283d29 | 2013-02-21 08:40:34 | [diff] [blame] | 2221 | unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| 2222 | return history_list_length_; |
| 2223 | } |
| 2224 | |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 2225 | void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { |
Nasko Oskov | a463a05 | 2018-05-08 16:42:14 | [diff] [blame] | 2226 | // If the main frame is remote, return immediately. Page level focus |
| 2227 | // should be set from the browser process, so if needed by tests it should |
| 2228 | // be properly supported. |
| 2229 | if (webview()->MainFrame()->IsWebRemoteFrame()) |
| 2230 | return; |
| 2231 | |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 2232 | if (enable == GetWidget()->has_focus()) |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2233 | return; |
| 2234 | |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 2235 | if (enable) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2236 | SetActiveForWidget(true); |
| 2237 | // Fake an IPC message so go through the IPC handler. |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 2238 | GetWidget()->OnSetFocus(true); |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 2239 | } else { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2240 | // Fake an IPC message so go through the IPC handler. |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 2241 | GetWidget()->OnSetFocus(false); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 2242 | SetActiveForWidget(false); |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 2243 | } |
| 2244 | } |
| 2245 | |
W. James MacLean | d973a55b | 2018-11-29 21:39:13 | [diff] [blame] | 2246 | void RenderViewImpl::OnAnimateDoubleTapZoomInMainFrame( |
| 2247 | const blink::WebPoint& point, |
| 2248 | const blink::WebRect& bound) { |
| 2249 | webview()->AnimateDoubleTapZoom(point, bound); |
| 2250 | } |
| 2251 | |
W. James MacLean | 5372eb7 | 2018-12-19 12:56:36 | [diff] [blame] | 2252 | void RenderViewImpl::OnZoomToFindInPageRect( |
| 2253 | const blink::WebRect& rect_to_zoom) { |
| 2254 | webview()->ZoomToFindInPageRect(rect_to_zoom); |
| 2255 | } |
| 2256 | |
danakj | d51fd53d | 2018-12-21 23:06:09 | [diff] [blame] | 2257 | void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
| 2258 | if (!webview()) |
| 2259 | return; |
| 2260 | |
| 2261 | if (opaque) { |
| 2262 | webview()->ClearBaseBackgroundColorOverride(); |
| 2263 | webview()->ClearBackgroundColorOverride(); |
| 2264 | } else { |
| 2265 | webview()->SetBaseBackgroundColorOverride(SK_ColorTRANSPARENT); |
| 2266 | webview()->SetBackgroundColorOverride(SK_ColorTRANSPARENT); |
| 2267 | } |
| 2268 | } |
| 2269 | |
danakj | 295c43f18 | 2019-03-13 16:37:17 | [diff] [blame] | 2270 | // static |
| 2271 | scoped_refptr<base::SingleThreadTaskRunner> |
| 2272 | RenderViewImpl::GetCleanupTaskRunner() { |
| 2273 | return RenderThreadImpl::current_blink_platform_impl() |
| 2274 | ->main_thread_scheduler() |
| 2275 | ->CleanupTaskRunner(); |
| 2276 | } |
| 2277 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2278 | } // namespace content |