[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] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 44 | #include "content/common/drag_messages.h" |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 45 | #include "content/common/frame_messages.h" |
alexmos | bc7eafa | 2014-12-06 01:38:09 | [diff] [blame] | 46 | #include "content/common/frame_replication_state.h" |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 47 | #include "content/common/input_messages.h" |
lfg | db5c4ed | 2016-03-04 23:09:07 | [diff] [blame] | 48 | #include "content/common/page_messages.h" |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 49 | #include "content/common/render_message_filter.mojom.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 50 | #include "content/common/view_messages.h" |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 51 | #include "content/public/common/content_client.h" |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 52 | #include "content/public/common/content_constants.h" |
Tarun Bansal | 73dd2ff8 | 2017-10-03 05:29:34 | [diff] [blame] | 53 | #include "content/public/common/content_features.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 54 | #include "content/public/common/content_switches.h" |
clamy | da97e832 | 2014-10-07 21:57:25 | [diff] [blame] | 55 | #include "content/public/common/page_state.h" |
Leon Han | 963dc18 | 2018-11-06 05:41:48 | [diff] [blame] | 56 | #include "content/public/common/referrer_type_converters.h" |
[email protected] | 818915cd | 2012-11-20 13:14:11 | [diff] [blame] | 57 | #include "content/public/common/three_d_api_types.h" |
[email protected] | a1d2916 | 2011-10-14 17:14:03 | [diff] [blame] | 58 | #include "content/public/common/url_constants.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 59 | #include "content/public/common/web_preferences.h" |
[email protected] | d344114c | 2011-10-01 01:24:34 | [diff] [blame] | 60 | #include "content/public/renderer/content_renderer_client.h" |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 61 | #include "content/public/renderer/document_state.h" |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 62 | #include "content/public/renderer/render_thread.h" |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 63 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 64 | #include "content/public/renderer/render_view_visitor.h" |
scottmg | 8e6c608 | 2017-02-13 23:15:48 | [diff] [blame] | 65 | #include "content/public/renderer/window_features_converter.h" |
Sadrul Habib Chowdhury | 31c9871 | 2018-12-11 04:15:13 | [diff] [blame] | 66 | #include "content/renderer/compositor/layer_tree_view.h" |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 67 | #include "content/renderer/drop_data_builder.h" |
[email protected] | dc06435 | 2014-04-25 08:36:38 | [diff] [blame] | 68 | #include "content/renderer/history_serialization.h" |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 69 | #include "content/renderer/ime_event_guard.h" |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 70 | #include "content/renderer/internal_document_state_data.h" |
John Abd-El-Malek | 6b56ef71 | 2017-10-21 22:52:46 | [diff] [blame] | 71 | #include "content/renderer/loader/request_extra_data.h" |
Amos Lim | bcc710e | 2018-06-08 05:51:17 | [diff] [blame] | 72 | #include "content/renderer/media/audio/audio_device_factory.h" |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 73 | #include "content/renderer/render_frame_impl.h" |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 74 | #include "content/renderer/render_frame_proxy.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 75 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 76 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 77 | #include "content/renderer/render_widget_fullscreen_pepper.h" |
Daniel Murphy | e3eec92c | 2018-02-23 19:09:15 | [diff] [blame] | 78 | #include "content/renderer/renderer_blink_platform_impl.h" |
[email protected] | 12a936d | 2013-05-15 04:55:49 | [diff] [blame] | 79 | #include "content/renderer/savable_resources.h" |
John Abd-El-Malek | 312a30bb | 2017-10-23 19:51:52 | [diff] [blame] | 80 | #include "content/renderer/v8_value_converter_impl.h" |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 81 | #include "content/renderer/web_ui_extension_data.h" |
[email protected] | f596114 | 2013-04-17 23:09:42 | [diff] [blame] | 82 | #include "media/audio/audio_output_device.h" |
[email protected] | ee68378a | 2010-08-10 01:05:41 | [diff] [blame] | 83 | #include "media/base/media_switches.h" |
Scott Violet | a35f9a4 | 2018-03-22 22:00:44 | [diff] [blame] | 84 | #include "media/media_buildflags.h" |
servolk | f54f5c8f | 2015-02-24 20:32:39 | [diff] [blame] | 85 | #include "media/renderers/audio_renderer_impl.h" |
Dale Curtis | 863022e | 2017-08-19 02:05:34 | [diff] [blame] | 86 | #include "media/video/gpu_video_accelerator_factories.h" |
Julie Jeongeun Kim | caacf910 | 2019-09-12 02:13:05 | [diff] [blame] | 87 | #include "mojo/public/cpp/bindings/pending_receiver.h" |
[email protected] | d1ef81d | 2012-07-24 11:39:36 | [diff] [blame] | 88 | #include "net/base/data_url.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 89 | #include "net/base/escape.h" |
| 90 | #include "net/base/net_errors.h" |
[email protected] | 18fb7a77 | 2012-09-20 19:25:09 | [diff] [blame] | 91 | #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 92 | #include "net/http/http_util.h" |
Tarun Bansal | 73d67f0 | 2018-01-17 05:56:25 | [diff] [blame] | 93 | #include "net/nqe/effective_connection_type.h" |
Scott Violet | 02e38b9 | 2018-03-27 23:42:14 | [diff] [blame] | 94 | #include "ppapi/buildflags/buildflags.h" |
luken | b171b53 | 2014-09-24 05:50:38 | [diff] [blame] | 95 | #include "skia/ext/platform_canvas.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 96 | #include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 97 | #include "third_party/blink/public/common/dom_storage/session_storage_namespace_id.h" |
Mustaq Ahmed | 76c2f431 | 2018-06-07 20:48:01 | [diff] [blame] | 98 | #include "third_party/blink/public/common/frame/user_activation_update_source.h" |
Dave Tapuska | 129cef8 | 2019-12-19 16:36:48 | [diff] [blame] | 99 | #include "third_party/blink/public/common/input/web_input_event.h" |
Sergio Villar Senin | eb8c25245 | 2019-10-04 17:18:28 | [diff] [blame] | 100 | #include "third_party/blink/public/common/plugin/plugin_action.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 101 | #include "third_party/blink/public/platform/file_path_conversion.h" |
Antonio Gomes | 925f9b9 | 2019-07-30 23:23:23 | [diff] [blame] | 102 | #include "third_party/blink/public/platform/modules/video_capture/web_video_capture_impl_manager.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 103 | #include "third_party/blink/public/platform/url_conversion.h" |
| 104 | #include "third_party/blink/public/platform/web_connection_type.h" |
| 105 | #include "third_party/blink/public/platform/web_effective_connection_type.h" |
| 106 | #include "third_party/blink/public/platform/web_http_body.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 107 | #include "third_party/blink/public/platform/web_input_event_result.h" |
| 108 | #include "third_party/blink/public/platform/web_network_state_notifier.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 109 | #include "third_party/blink/public/platform/web_rect.h" |
| 110 | #include "third_party/blink/public/platform/web_runtime_features.h" |
| 111 | #include "third_party/blink/public/platform/web_size.h" |
| 112 | #include "third_party/blink/public/platform/web_string.h" |
W. James MacLean | 6219867 | 2019-06-04 16:46:10 | [diff] [blame] | 113 | #include "third_party/blink/public/platform/web_text_autosizer_page_info.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 114 | #include "third_party/blink/public/platform/web_url.h" |
| 115 | #include "third_party/blink/public/platform/web_url_error.h" |
| 116 | #include "third_party/blink/public/platform/web_url_request.h" |
| 117 | #include "third_party/blink/public/platform/web_url_response.h" |
| 118 | #include "third_party/blink/public/platform/web_vector.h" |
| 119 | #include "third_party/blink/public/public_buildflags.h" |
Guido Urdaneta | dc709037 | 2019-07-29 17:59:54 | [diff] [blame] | 120 | #include "third_party/blink/public/web/modules/mediastream/web_media_stream_device_observer.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 121 | #include "third_party/blink/public/web/web_autofill_client.h" |
| 122 | #include "third_party/blink/public/web/web_ax_object.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 123 | #include "third_party/blink/public/web/web_document.h" |
| 124 | #include "third_party/blink/public/web/web_dom_event.h" |
| 125 | #include "third_party/blink/public/web/web_dom_message_event.h" |
| 126 | #include "third_party/blink/public/web/web_element.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 127 | #include "third_party/blink/public/web/web_form_control_element.h" |
| 128 | #include "third_party/blink/public/web/web_form_element.h" |
| 129 | #include "third_party/blink/public/web/web_frame.h" |
| 130 | #include "third_party/blink/public/web/web_frame_content_dumper.h" |
| 131 | #include "third_party/blink/public/web/web_frame_widget.h" |
| 132 | #include "third_party/blink/public/web/web_history_item.h" |
| 133 | #include "third_party/blink/public/web/web_hit_test_result.h" |
| 134 | #include "third_party/blink/public/web/web_input_element.h" |
| 135 | #include "third_party/blink/public/web/web_local_frame.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 136 | #include "third_party/blink/public/web/web_navigation_policy.h" |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 137 | #include "third_party/blink/public/web/web_page_popup.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 138 | #include "third_party/blink/public/web/web_plugin.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 139 | #include "third_party/blink/public/web/web_range.h" |
| 140 | #include "third_party/blink/public/web/web_render_theme.h" |
| 141 | #include "third_party/blink/public/web/web_script_source.h" |
| 142 | #include "third_party/blink/public/web/web_searchable_form_data.h" |
| 143 | #include "third_party/blink/public/web/web_security_policy.h" |
| 144 | #include "third_party/blink/public/web/web_settings.h" |
Blink Reformat | a30d423 | 2018-04-07 15:31:06 | [diff] [blame] | 145 | #include "third_party/blink/public/web/web_view.h" |
| 146 | #include "third_party/blink/public/web/web_window_features.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 147 | #include "third_party/icu/source/common/unicode/uchar.h" |
| 148 | #include "third_party/icu/source/common/unicode/uscript.h" |
eseckler | f2bd55f7 | 2017-03-31 09:11:57 | [diff] [blame] | 149 | #include "third_party/skia/include/core/SkColor.h" |
Ionel Popescu | 2649f2f | 2020-01-10 10:06:59 | [diff] [blame] | 150 | #include "ui/base/ui_base_features.h" |
[email protected] | 1400e6dc | 2013-04-27 02:36:27 | [diff] [blame] | 151 | #include "ui/base/ui_base_switches_util.h" |
tfarina | 655f81d | 2014-12-23 02:38:50 | [diff] [blame] | 152 | #include "ui/gfx/geometry/point.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 153 | #include "ui/gfx/geometry/rect.h" |
| 154 | #include "ui/gfx/geometry/rect_conversions.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 155 | #include "ui/gfx/geometry/size_conversions.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 156 | #include "ui/gfx/native_widget_types.h" |
ccameron | 772317d | 2017-06-04 18:35:03 | [diff] [blame] | 157 | #include "ui/gfx/switches.h" |
mfomitchev | 3ba450ad | 2017-04-03 18:20:40 | [diff] [blame] | 158 | #include "ui/latency/latency_info.h" |
csharrison | d88f975 | 2016-10-26 23:56:36 | [diff] [blame] | 159 | #include "url/origin.h" |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 160 | #include "url/url_constants.h" |
[email protected] | c4a9e93 | 2011-03-05 04:05:55 | [diff] [blame] | 161 | #include "v8/include/v8.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 162 | |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 163 | #if defined(OS_ANDROID) |
[email protected] | befe5478 | 2013-04-23 00:49:25 | [diff] [blame] | 164 | #include <cpu-features.h> |
| 165 | |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 166 | #include "base/android/build_info.h" |
kylechar | e7d8d5c7 | 2018-01-05 19:06:28 | [diff] [blame] | 167 | #include "content/child/child_thread_impl.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 168 | #include "ui/gfx/geometry/rect_f.h" |
[email protected] | e69bb06 | 2013-06-03 13:05:40 | [diff] [blame] | 169 | |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 170 | #elif defined(OS_MACOSX) |
| 171 | #include "skia/ext/skia_utils_mac.h" |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 172 | #endif |
| 173 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 174 | #if BUILDFLAG(ENABLE_PLUGINS) |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 175 | #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 176 | #include "content/renderer/pepper/pepper_plugin_registry.h" |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 177 | #endif |
| 178 | |
Sergio Villar Senin | eb8c25245 | 2019-10-04 17:18:28 | [diff] [blame] | 179 | using blink::PluginAction; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 180 | using blink::WebAXObject; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 181 | using blink::WebConsoleMessage; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 182 | using blink::WebData; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 183 | using blink::WebDocument; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 184 | using blink::WebDragOperation; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 185 | using blink::WebElement; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 186 | using blink::WebFormControlElement; |
| 187 | using blink::WebFormElement; |
| 188 | using blink::WebFrame; |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 189 | using blink::WebFrameContentDumper; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 190 | using blink::WebGestureEvent; |
| 191 | using blink::WebHistoryItem; |
dglazkov | 8d0c21dd | 2016-08-06 15:56:36 | [diff] [blame] | 192 | using blink::WebHitTestResult; |
Sergio Villar Senin | eb8c25245 | 2019-10-04 17:18:28 | [diff] [blame] | 193 | using blink::WebHTTPBody; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 194 | using blink::WebInputElement; |
| 195 | using blink::WebInputEvent; |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 196 | using blink::WebLocalFrame; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 197 | using blink::WebMouseEvent; |
| 198 | using blink::WebNavigationPolicy; |
| 199 | using blink::WebNavigationType; |
| 200 | using blink::WebNode; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 201 | using blink::WebRect; |
Sergio Villar Senin | eb8c25245 | 2019-10-04 17:18:28 | [diff] [blame] | 202 | using blink::WebRuntimeFeatures; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 203 | using blink::WebScriptSource; |
| 204 | using blink::WebSearchableFormData; |
| 205 | using blink::WebSecurityOrigin; |
| 206 | using blink::WebSecurityPolicy; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 207 | using blink::WebSettings; |
| 208 | using blink::WebSize; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 209 | using blink::WebString; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 210 | using blink::WebTouchEvent; |
| 211 | using blink::WebURL; |
| 212 | using blink::WebURLError; |
| 213 | using blink::WebURLRequest; |
| 214 | using blink::WebURLResponse; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 215 | using blink::WebVector; |
| 216 | using blink::WebView; |
| 217 | using blink::WebWidget; |
| 218 | using blink::WebWindowFeatures; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 219 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 220 | namespace content { |
| 221 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 222 | //----------------------------------------------------------------------------- |
| 223 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 224 | typedef std::map<blink::WebView*, RenderViewImpl*> ViewMap; |
jbroman | 8319b23 | 2017-03-08 22:53:29 | [diff] [blame] | 225 | static base::LazyInstance<ViewMap>::Leaky g_view_map = |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 226 | LAZY_INSTANCE_INITIALIZER; |
scottmg | 5e65e3a | 2017-03-08 08:48:46 | [diff] [blame] | 227 | typedef std::map<int32_t, RenderViewImpl*> RoutingIDViewMap; |
jbroman | 8319b23 | 2017-03-08 22:53:29 | [diff] [blame] | 228 | static base::LazyInstance<RoutingIDViewMap>::Leaky g_routing_id_view_map = |
| 229 | LAZY_INSTANCE_INITIALIZER; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 230 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 231 | // Time, in seconds, we delay before sending content state changes (such as form |
| 232 | // state and scroll position) to the browser. We delay sending changes to avoid |
| 233 | // spamming the browser. |
| 234 | // To avoid having tab/session restore require sending a message to get the |
| 235 | // current content state during tab closing we use a shorter timeout for the |
| 236 | // foreground renderer. This means there is a small window of time from which |
| 237 | // content state is modified and not sent to session restore, but this is |
| 238 | // better than having to wake up all renderers during shutdown. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 239 | const int kDelaySecondsForContentStateSyncHidden = 5; |
| 240 | const int kDelaySecondsForContentStateSync = 1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 241 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 242 | static RenderViewImpl* (*g_create_render_view_impl)( |
| 243 | CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 244 | const mojom::CreateViewParams&) = nullptr; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 245 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 246 | // static |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 247 | WindowOpenDisposition RenderViewImpl::NavigationPolicyToDisposition( |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 248 | WebNavigationPolicy policy) { |
| 249 | switch (policy) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 250 | case blink::kWebNavigationPolicyDownload: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 251 | return WindowOpenDisposition::SAVE_TO_DISK; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 252 | case blink::kWebNavigationPolicyCurrentTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 253 | return WindowOpenDisposition::CURRENT_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 254 | case blink::kWebNavigationPolicyNewBackgroundTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 255 | return WindowOpenDisposition::NEW_BACKGROUND_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 256 | case blink::kWebNavigationPolicyNewForegroundTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 257 | return WindowOpenDisposition::NEW_FOREGROUND_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 258 | case blink::kWebNavigationPolicyNewWindow: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 259 | return WindowOpenDisposition::NEW_WINDOW; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 260 | case blink::kWebNavigationPolicyNewPopup: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 261 | return WindowOpenDisposition::NEW_POPUP; |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 262 | default: |
| 263 | NOTREACHED() << "Unexpected WebNavigationPolicy"; |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 264 | return WindowOpenDisposition::IGNORE_ACTION; |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 265 | } |
| 266 | } |
| 267 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 268 | /////////////////////////////////////////////////////////////////////////////// |
| 269 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 270 | namespace { |
| 271 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 272 | typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, |
| 273 | const base::string16&, |
| 274 | UScriptCode); |
| 275 | |
| 276 | void SetStandardFontFamilyWrapper(WebSettings* settings, |
| 277 | const base::string16& font, |
| 278 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 279 | settings->SetStandardFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 280 | } |
| 281 | |
| 282 | void SetFixedFontFamilyWrapper(WebSettings* settings, |
| 283 | const base::string16& font, |
| 284 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 285 | settings->SetFixedFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | void SetSerifFontFamilyWrapper(WebSettings* settings, |
| 289 | const base::string16& font, |
| 290 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 291 | settings->SetSerifFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 292 | } |
| 293 | |
| 294 | void SetSansSerifFontFamilyWrapper(WebSettings* settings, |
| 295 | const base::string16& font, |
| 296 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 297 | settings->SetSansSerifFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | void SetCursiveFontFamilyWrapper(WebSettings* settings, |
| 301 | const base::string16& font, |
| 302 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 303 | settings->SetCursiveFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | void SetFantasyFontFamilyWrapper(WebSettings* settings, |
| 307 | const base::string16& font, |
| 308 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 309 | settings->SetFantasyFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | void SetPictographFontFamilyWrapper(WebSettings* settings, |
| 313 | const base::string16& font, |
| 314 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 315 | settings->SetPictographFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | // If |scriptCode| is a member of a family of "similar" script codes, returns |
| 319 | // the script code in that family that is used by WebKit for font selection |
| 320 | // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are |
| 321 | // considered equivalent for the purposes of font selection. WebKit uses the |
| 322 | // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is |
| 323 | // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit |
| 324 | // uses different scripts than the ones in Chrome pref names because the version |
| 325 | // of ICU included on certain ports does not have some of the newer scripts. If |
| 326 | // |scriptCode| is not a member of such a family, returns |scriptCode|. |
| 327 | UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) { |
| 328 | switch (scriptCode) { |
| 329 | case USCRIPT_HIRAGANA: |
| 330 | case USCRIPT_KATAKANA: |
| 331 | case USCRIPT_JAPANESE: |
| 332 | return USCRIPT_KATAKANA_OR_HIRAGANA; |
| 333 | case USCRIPT_KOREAN: |
| 334 | return USCRIPT_HANGUL; |
| 335 | default: |
| 336 | return scriptCode; |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | void ApplyFontsFromMap(const ScriptFontFamilyMap& map, |
| 341 | SetFontFamilyWrapper setter, |
| 342 | WebSettings* settings) { |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 343 | for (auto it = map.begin(); it != map.end(); ++it) { |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 344 | int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 345 | if (script >= 0 && script < USCRIPT_CODE_LIMIT) { |
| 346 | UScriptCode code = static_cast<UScriptCode>(script); |
| 347 | (*setter)(settings, it->second, GetScriptForWebSettings(code)); |
| 348 | } |
| 349 | } |
| 350 | } |
| 351 | |
danakj | efcb843 | 2019-01-16 18:47:14 | [diff] [blame] | 352 | void ApplyCommandLineToSettings(WebSettings* settings) { |
| 353 | const base::CommandLine& command_line = |
| 354 | *base::CommandLine::ForCurrentProcess(); |
| 355 | |
danakj | ed946461 | 2019-01-16 00:00:59 | [diff] [blame] | 356 | settings->SetThreadedScrollingEnabled( |
| 357 | !command_line.HasSwitch(switches::kDisableThreadedScrolling)); |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 358 | |
danakj | ed946461 | 2019-01-16 00:00:59 | [diff] [blame] | 359 | if (switches::IsTouchDragDropEnabled()) |
| 360 | settings->SetTouchDragDropEnabled(true); |
| 361 | |
| 362 | WebSettings::SelectionStrategyType selection_strategy; |
| 363 | if (command_line.GetSwitchValueASCII(switches::kTouchTextSelectionStrategy) == |
| 364 | "direction") |
| 365 | selection_strategy = WebSettings::SelectionStrategyType::kDirection; |
| 366 | else |
| 367 | selection_strategy = WebSettings::SelectionStrategyType::kCharacter; |
| 368 | settings->SetSelectionStrategy(selection_strategy); |
| 369 | |
| 370 | std::string passive_listeners_default = |
| 371 | command_line.GetSwitchValueASCII(switches::kPassiveListenersDefault); |
| 372 | if (!passive_listeners_default.empty()) { |
| 373 | WebSettings::PassiveEventListenerDefault passive_default = |
| 374 | WebSettings::PassiveEventListenerDefault::kFalse; |
| 375 | if (passive_listeners_default == "true") |
| 376 | passive_default = WebSettings::PassiveEventListenerDefault::kTrue; |
| 377 | else if (passive_listeners_default == "forcealltrue") |
| 378 | passive_default = WebSettings::PassiveEventListenerDefault::kForceAllTrue; |
| 379 | settings->SetPassiveEventListenerDefault(passive_default); |
| 380 | } |
| 381 | |
| 382 | std::string network_quiet_timeout = |
| 383 | command_line.GetSwitchValueASCII(switches::kNetworkQuietTimeout); |
| 384 | if (!network_quiet_timeout.empty()) { |
| 385 | double network_quiet_timeout_seconds = 0.0; |
| 386 | if (base::StringToDouble(network_quiet_timeout, |
| 387 | &network_quiet_timeout_seconds)) |
| 388 | settings->SetNetworkQuietTimeout(network_quiet_timeout_seconds); |
| 389 | } |
| 390 | |
| 391 | if (command_line.HasSwitch(switches::kBlinkSettings)) { |
| 392 | std::vector<std::string> blink_settings = base::SplitString( |
| 393 | command_line.GetSwitchValueASCII(switches::kBlinkSettings), ",", |
| 394 | base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
| 395 | for (const std::string& setting : blink_settings) { |
| 396 | size_t pos = setting.find('='); |
| 397 | settings->SetFromStrings( |
| 398 | blink::WebString::FromLatin1(setting.substr(0, pos)), |
| 399 | blink::WebString::FromLatin1( |
| 400 | pos == std::string::npos ? "" : setting.substr(pos + 1))); |
| 401 | } |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 402 | } |
| 403 | } |
| 404 | |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 405 | content::mojom::WindowContainerType WindowFeaturesToContainerType( |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 406 | const blink::WebWindowFeatures& window_features) { |
japhet | bfc4789 | 2017-06-02 23:01:19 | [diff] [blame] | 407 | if (window_features.background) { |
| 408 | if (window_features.persistent) |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 409 | return content::mojom::WindowContainerType::PERSISTENT; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 410 | else |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 411 | return content::mojom::WindowContainerType::BACKGROUND; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 412 | } else { |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 413 | return content::mojom::WindowContainerType::NORMAL; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 414 | } |
| 415 | } |
| 416 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 417 | } // namespace |
| 418 | |
Hajime Hoshi | 315a61f | 2018-08-14 17:27:28 | [diff] [blame] | 419 | RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, |
| 420 | const mojom::CreateViewParams& params) |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 421 | : routing_id_(params.view_id), |
danakj | 73dd303 | 2018-07-28 17:49:53 | [diff] [blame] | 422 | renderer_wide_named_frame_lookup_( |
| 423 | params.renderer_wide_named_frame_lookup), |
danakj | 77eb7e8 | 2020-01-09 19:38:46 | [diff] [blame] | 424 | widgets_never_composited_(params.never_composited), |
danakj | 4b8a2d9a | 2019-10-15 15:53:59 | [diff] [blame] | 425 | compositor_deps_(compositor_deps), |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 426 | webkit_preferences_(params.web_preferences), |
Jeremy Roman | 3bca4bf | 2019-07-11 03:41:25 | [diff] [blame] | 427 | session_storage_namespace_id_(params.session_storage_namespace_id) { |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 428 | DCHECK(!session_storage_namespace_id_.empty()) |
| 429 | << "Session storage namespace must be populated."; |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 430 | // Please put all logic in RenderViewImpl::Initialize(). |
| 431 | } |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 432 | |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 433 | void RenderViewImpl::Initialize( |
Erik Chen | 10e9b02 | 2019-08-21 23:33:23 | [diff] [blame] | 434 | CompositorDependencies* compositor_deps, |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 435 | mojom::CreateViewParamsPtr params, |
| 436 | RenderWidget::ShowCallback show_callback, |
| 437 | scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 438 | DCHECK(RenderThread::IsMainThread()); |
| 439 | |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 440 | RenderThread::Get()->AddRoute(routing_id_, this); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 441 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 442 | #if defined(OS_ANDROID) |
danakj | c87bfede | 2018-10-10 22:32:49 | [diff] [blame] | 443 | bool has_show_callback = !!show_callback; |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 444 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 445 | |
Lukasz Anforowicz | af2f3357 | 2018-01-17 14:05:08 | [diff] [blame] | 446 | WebFrame* opener_frame = |
| 447 | RenderFrameImpl::ResolveOpener(params->opener_frame_route_id); |
| 448 | |
Erik Chen | 562ca42b | 2019-08-22 19:46:06 | [diff] [blame] | 449 | // The newly created webview_ is owned by this instance. |
danakj | 284d557d | 2019-01-16 17:00:26 | [diff] [blame] | 450 | webview_ = WebView::Create(this, params->hidden, |
Sadrul Habib Chowdhury | 042a471 | 2018-12-06 00:16:56 | [diff] [blame] | 451 | /*compositing_enabled=*/true, |
danakj | a4ba7e5 | 2018-11-29 23:04:31 | [diff] [blame] | 452 | opener_frame ? opener_frame->View() : nullptr); |
Albert J. Wong | 2727e8a8 | 2019-02-15 16:56:11 | [diff] [blame] | 453 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 454 | g_view_map.Get().insert(std::make_pair(webview(), this)); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 455 | g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this)); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 456 | |
danakj | 242c2e1 | 2019-10-08 16:34:15 | [diff] [blame] | 457 | bool local_main_frame = params->main_frame_routing_id != MSG_ROUTING_NONE; |
| 458 | |
| 459 | // TODO(danakj): Put this in with making the RenderFrame? Does order matter? |
| 460 | if (local_main_frame) |
| 461 | webview()->SetDisplayMode(params->visual_properties.display_mode); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 462 | |
danakj | fd0c7f4 | 2018-10-12 18:01:08 | [diff] [blame] | 463 | ApplyWebPreferences(webkit_preferences_, webview()); |
danakj | efcb843 | 2019-01-16 18:47:14 | [diff] [blame] | 464 | ApplyCommandLineToSettings(webview()->GetSettings()); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 465 | |
danakj | 242c2e1 | 2019-10-08 16:34:15 | [diff] [blame] | 466 | if (local_main_frame) { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 467 | main_render_frame_ = RenderFrameImpl::CreateMainFrame( |
Erik Chen | 10e9b02 | 2019-08-21 23:33:23 | [diff] [blame] | 468 | this, compositor_deps, opener_frame, ¶ms, std::move(show_callback)); |
danakj | af29226f | 2018-09-25 17:56:57 | [diff] [blame] | 469 | } else { |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 470 | RenderFrameProxy::CreateFrameProxy(params->proxy_routing_id, GetRoutingID(), |
nick | 3b5a21f | 2016-11-22 23:07:11 | [diff] [blame] | 471 | opener_frame, MSG_ROUTING_NONE, |
Dmitry Gozman | 8936121 | 2018-02-13 16:10:44 | [diff] [blame] | 472 | params->replicated_frame_state, |
| 473 | params->devtools_main_frame_token); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 474 | } |
| 475 | |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 476 | // TODO(davidben): Move this state from Blink into content. |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 477 | if (params->window_was_created_with_opener) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 478 | webview()->SetOpenedByDOM(); |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 479 | |
Leon Han | 2c81b5d | 2019-01-25 01:58:33 | [diff] [blame] | 480 | OnSetRendererPrefs(*params->renderer_preferences); |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 481 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 482 | GetContentClient()->renderer()->RenderViewCreated(this); |
Hajime Hoshi | f3437441 | 2018-03-05 14:32:54 | [diff] [blame] | 483 | |
| 484 | nav_state_sync_timer_.SetTaskRunner(task_runner); |
danakj | c87bfede | 2018-10-10 22:32:49 | [diff] [blame] | 485 | |
Adithya Srinivasan | 46b8a79 | 2019-02-01 14:47:23 | [diff] [blame] | 486 | // We pass this state to Page, but it's only used by the main frame in the |
| 487 | // page. |
| 488 | if (params->inside_portal) |
| 489 | webview()->SetInsidePortal(true); |
| 490 | |
danakj | c87bfede | 2018-10-10 22:32:49 | [diff] [blame] | 491 | #if defined(OS_ANDROID) |
| 492 | // TODO(sgurun): crbug.com/325351 Needed only for android webview's deprecated |
| 493 | // HandleNavigation codepath. |
| 494 | // Renderer-created RenderViews have a ShowCallback because they send a Show |
| 495 | // request (ViewHostMsg_ShowWidget, ViewHostMsg_ShowFullscreenWidget, or |
| 496 | // FrameHostMsg_ShowCreatedWindow) to the browser to attach them to the UI |
| 497 | // there. Browser-created RenderViews do not send a Show request to the |
| 498 | // browser, so have no such callback. |
| 499 | was_created_by_renderer_ = has_show_callback; |
| 500 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 501 | } |
| 502 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 503 | RenderViewImpl::~RenderViewImpl() { |
danakj | cdfc426 | 2019-10-01 20:09:48 | [diff] [blame] | 504 | DCHECK(destroying_); // Always deleted through Destroy(). |
danakj | cdfc426 | 2019-10-01 20:09:48 | [diff] [blame] | 505 | |
| 506 | g_routing_id_view_map.Get().erase(routing_id_); |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 507 | RenderThread::Get()->RemoveRoute(routing_id_); |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 508 | |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 509 | #ifndef NDEBUG |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 510 | // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap. |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 511 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 512 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 513 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 514 | RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer(); |
| 515 | for (RoutingIDViewMap::iterator it = routing_id_views->begin(); |
| 516 | it != routing_id_views->end(); ++it) |
| 517 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 518 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 519 | |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 520 | for (auto& observer : observers_) |
| 521 | observer.RenderViewGone(); |
| 522 | for (auto& observer : observers_) |
| 523 | observer.OnDestruct(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 524 | } |
| 525 | |
| 526 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 527 | RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 528 | DCHECK(RenderThread::IsMainThread()); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 529 | ViewMap* views = g_view_map.Pointer(); |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 530 | auto it = views->find(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 531 | return it == views->end() ? NULL : it->second; |
| 532 | } |
| 533 | |
| 534 | /*static*/ |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 535 | RenderView* RenderView::FromWebView(blink::WebView* webview) { |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 536 | return RenderViewImpl::FromWebView(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 537 | } |
| 538 | |
| 539 | /*static*/ |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 540 | RenderViewImpl* RenderViewImpl::FromRoutingID(int32_t routing_id) { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 541 | DCHECK(RenderThread::IsMainThread()); |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 542 | RoutingIDViewMap* views = g_routing_id_view_map.Pointer(); |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 543 | auto it = views->find(routing_id); |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 544 | return it == views->end() ? NULL : it->second; |
| 545 | } |
| 546 | |
| 547 | /*static*/ |
| 548 | RenderView* RenderView::FromRoutingID(int routing_id) { |
| 549 | return RenderViewImpl::FromRoutingID(routing_id); |
| 550 | } |
| 551 | |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 552 | /* static */ |
jochen | 9c7b8f24 | 2015-06-01 15:32:02 | [diff] [blame] | 553 | size_t RenderView::GetRenderViewCount() { |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 554 | return g_view_map.Get().size(); |
| 555 | } |
| 556 | |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 557 | /*static*/ |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 558 | void RenderView::ForEach(RenderViewVisitor* visitor) { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 559 | DCHECK(RenderThread::IsMainThread()); |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 560 | ViewMap* views = g_view_map.Pointer(); |
jdoerrie | 5a73d0fa | 2018-10-02 23:54:05 | [diff] [blame] | 561 | for (auto it = views->begin(); it != views->end(); ++it) { |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 562 | if (!visitor->Visit(it->second)) |
| 563 | return; |
| 564 | } |
| 565 | } |
| 566 | |
| 567 | /*static*/ |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 568 | void RenderView::ApplyWebPreferences(const WebPreferences& prefs, |
| 569 | WebView* web_view) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 570 | WebSettings* settings = web_view->GetSettings(); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 571 | ApplyFontsFromMap(prefs.standard_font_family_map, |
| 572 | SetStandardFontFamilyWrapper, settings); |
| 573 | ApplyFontsFromMap(prefs.fixed_font_family_map, |
| 574 | SetFixedFontFamilyWrapper, settings); |
| 575 | ApplyFontsFromMap(prefs.serif_font_family_map, |
| 576 | SetSerifFontFamilyWrapper, settings); |
| 577 | ApplyFontsFromMap(prefs.sans_serif_font_family_map, |
| 578 | SetSansSerifFontFamilyWrapper, settings); |
| 579 | ApplyFontsFromMap(prefs.cursive_font_family_map, |
| 580 | SetCursiveFontFamilyWrapper, settings); |
| 581 | ApplyFontsFromMap(prefs.fantasy_font_family_map, |
| 582 | SetFantasyFontFamilyWrapper, settings); |
| 583 | ApplyFontsFromMap(prefs.pictograph_font_family_map, |
| 584 | SetPictographFontFamilyWrapper, settings); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 585 | settings->SetDefaultFontSize(prefs.default_font_size); |
| 586 | settings->SetDefaultFixedFontSize(prefs.default_fixed_font_size); |
| 587 | settings->SetMinimumFontSize(prefs.minimum_font_size); |
| 588 | settings->SetMinimumLogicalFontSize(prefs.minimum_logical_font_size); |
| 589 | settings->SetDefaultTextEncodingName( |
| 590 | WebString::FromASCII(prefs.default_encoding)); |
| 591 | settings->SetJavaScriptEnabled(prefs.javascript_enabled); |
| 592 | settings->SetWebSecurityEnabled(prefs.web_security_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 593 | settings->SetLoadsImagesAutomatically(prefs.loads_images_automatically); |
| 594 | settings->SetImagesEnabled(prefs.images_enabled); |
| 595 | settings->SetPluginsEnabled(prefs.plugins_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 596 | settings->SetDOMPasteAllowed(prefs.dom_paste_enabled); |
| 597 | settings->SetTextAreasAreResizable(prefs.text_areas_are_resizable); |
| 598 | settings->SetAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows); |
| 599 | settings->SetDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled); |
| 600 | settings->SetJavaScriptCanAccessClipboard( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 601 | prefs.javascript_can_access_clipboard); |
Chris Cunningham | e9b5ad74 | 2019-04-23 19:40:38 | [diff] [blame] | 602 | WebRuntimeFeatures::EnableXSLT(prefs.xslt_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 603 | settings->SetDNSPrefetchingEnabled(prefs.dns_prefetching_enabled); |
Tarun Bansal | 333819e | 2018-05-15 16:38:42 | [diff] [blame] | 604 | blink::WebNetworkStateNotifier::SetSaveDataEnabled(prefs.data_saver_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 605 | settings->SetLocalStorageEnabled(prefs.local_storage_enabled); |
| 606 | settings->SetSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled); |
| 607 | WebRuntimeFeatures::EnableDatabase(prefs.databases_enabled); |
| 608 | settings->SetOfflineWebApplicationCacheEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 609 | prefs.application_cache_enabled); |
Arthur Sonzogni | 721f48e | 2018-10-31 17:10:02 | [diff] [blame] | 610 | settings->SetShouldProtectAgainstIpcFlooding( |
| 611 | !prefs.disable_ipc_flooding_protection); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 612 | settings->SetHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled); |
| 613 | settings->SetCookieEnabled(prefs.cookie_enabled); |
| 614 | settings->SetNavigateOnDragDrop(prefs.navigate_on_drag_drop); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 615 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 616 | // By default, allow_universal_access_from_file_urls is set to false and thus |
| 617 | // we mitigate attacks from local HTML files by not granting file:// URLs |
| 618 | // universal access. Only test shell will enable this. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 619 | settings->SetAllowUniversalAccessFromFileURLs( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 620 | prefs.allow_universal_access_from_file_urls); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 621 | settings->SetAllowFileAccessFromFileURLs( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 622 | prefs.allow_file_access_from_file_urls); |
| 623 | |
Zhenyao Mo | a3fda997 | 2017-09-16 01:34:40 | [diff] [blame] | 624 | settings->SetWebGL1Enabled(prefs.webgl1_enabled); |
| 625 | settings->SetWebGL2Enabled(prefs.webgl2_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 626 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 627 | // Enable WebGL errors to the JS console if requested. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 628 | settings->SetWebGLErrorsToConsoleEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 629 | prefs.webgl_errors_to_console_enabled); |
| 630 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 631 | settings->SetHideScrollbars(prefs.hide_scrollbars); |
eseckler | 61ff914 | 2016-09-23 22:57:59 | [diff] [blame] | 632 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 633 | // Enable gpu-accelerated 2d canvas if requested on the command line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 634 | WebRuntimeFeatures::EnableAccelerated2dCanvas( |
junov | 524668f2 | 2016-08-08 20:16:52 | [diff] [blame] | 635 | prefs.accelerated_2d_canvas_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 636 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 637 | // Disable antialiasing for 2d canvas if requested on the command line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 638 | settings->SetAntialiased2dCanvasEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 639 | !prefs.antialiased_2d_canvas_disabled); |
| 640 | |
zakerinasab | 20ebca0 | 2016-09-27 14:22:34 | [diff] [blame] | 641 | // Disable antialiasing of clips for 2d canvas if requested on the command |
robertphillips | e25137b | 2014-10-20 13:44:34 | [diff] [blame] | 642 | // line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 643 | settings->SetAntialiasedClips2dCanvasEnabled( |
robertphillips | e25137b | 2014-10-20 13:44:34 | [diff] [blame] | 644 | prefs.antialiased_clips_2d_canvas_enabled); |
| 645 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 646 | // Set MSAA sample count for 2d canvas if requested on the command line (or |
| 647 | // default value if not). |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 648 | settings->SetAccelerated2dCanvasMSAASampleCount( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 649 | prefs.accelerated_2d_canvas_msaa_sample_count); |
| 650 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 651 | // Tabs to link is not part of the settings. WebCore calls |
| 652 | // ChromeClient::tabsToLinks which is part of the glue code. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 653 | web_view->SetTabsToLinks(prefs.tabs_to_links); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 654 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 655 | settings->SetAllowRunningOfInsecureContent( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 656 | prefs.allow_running_insecure_content); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 657 | settings->SetDisableReadingFromCanvas(prefs.disable_reading_from_canvas); |
| 658 | settings->SetStrictMixedContentChecking(prefs.strict_mixed_content_checking); |
mkwst | 2384c822 | 2015-07-30 07:26:47 | [diff] [blame] | 659 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 660 | settings->SetStrictlyBlockBlockableMixedContent( |
mkwst | 2384c822 | 2015-07-30 07:26:47 | [diff] [blame] | 661 | prefs.strictly_block_blockable_mixed_content); |
| 662 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 663 | settings->SetStrictMixedContentCheckingForPlugin( |
mkwst | 0d233e5 | 2015-08-10 09:33:14 | [diff] [blame] | 664 | prefs.block_mixed_plugin_content); |
| 665 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 666 | settings->SetStrictPowerfulFeatureRestrictions( |
mkwst | 673a452f | 2015-01-10 14:41:50 | [diff] [blame] | 667 | prefs.strict_powerful_feature_restrictions); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 668 | settings->SetAllowGeolocationOnInsecureOrigins( |
jww | 9d4ca2d | 2016-01-19 20:58:59 | [diff] [blame] | 669 | prefs.allow_geolocation_on_insecure_origins); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 670 | settings->SetPasswordEchoEnabled(prefs.password_echo_enabled); |
| 671 | settings->SetShouldPrintBackgrounds(prefs.should_print_backgrounds); |
| 672 | settings->SetShouldClearDocumentBackground( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 673 | prefs.should_clear_document_background); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 674 | settings->SetEnableScrollAnimator(prefs.enable_scroll_animator); |
Stephen McGruer | bc3d0e6 | 2019-01-23 17:40:19 | [diff] [blame] | 675 | settings->SetPrefersReducedMotion(prefs.prefers_reduced_motion); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 676 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 677 | WebRuntimeFeatures::EnableTouchEventFeatureDetection( |
sunyunjia | fa6a8afc | 2016-12-09 04:25:47 | [diff] [blame] | 678 | prefs.touch_event_feature_detection_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 679 | settings->SetMaxTouchPoints(prefs.pointer_events_max_touch_points); |
| 680 | settings->SetAvailablePointerTypes(prefs.available_pointer_types); |
| 681 | settings->SetPrimaryPointerType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 682 | static_cast<blink::PointerType>(prefs.primary_pointer_type)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 683 | settings->SetAvailableHoverTypes(prefs.available_hover_types); |
| 684 | settings->SetPrimaryHoverType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 685 | static_cast<blink::HoverType>(prefs.primary_hover_type)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 686 | settings->SetEnableTouchAdjustment(prefs.touch_adjustment_enabled); |
Dave Tapuska | a59fdb6 | 2017-08-23 16:28:27 | [diff] [blame] | 687 | settings->SetBarrelButtonForDragEnabled(prefs.barrel_button_for_drag_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 688 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 689 | settings->SetShouldRespectImageOrientation( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 690 | prefs.should_respect_image_orientation); |
| 691 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 692 | settings->SetEditingBehavior( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 693 | static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior)); |
| 694 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 695 | settings->SetSupportsMultipleWindows(prefs.supports_multiple_windows); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 696 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 697 | settings->SetMainFrameClipsContent(!prefs.record_whole_document); |
khushalsagar | 2da2b23 | 2016-03-23 22:11:35 | [diff] [blame] | 698 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 699 | settings->SetSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 700 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 701 | settings->SetSpatialNavigationEnabled(prefs.spatial_navigation_enabled); |
Hugo Holgersson | 943ae69 | 2019-01-10 10:04:14 | [diff] [blame] | 702 | // Spatnav depends on KeyboardFocusableScrollers. The WebUI team has |
| 703 | // disabled KFS because they need more time to update their custom elements, |
| 704 | // crbug.com/907284. Meanwhile, we pre-ship KFS to spatnav users. |
| 705 | if (prefs.spatial_navigation_enabled) |
| 706 | WebRuntimeFeatures::EnableKeyboardFocusableScrollers(true); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 707 | |
Bruce Long | 015d96f | 2019-07-12 22:59:10 | [diff] [blame] | 708 | settings->SetCaretBrowsingEnabled(prefs.caret_browsing_enabled); |
| 709 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 710 | settings->SetSelectionIncludesAltImageText(true); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 711 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 712 | settings->SetV8CacheOptions( |
[email protected] | 35103c0 | 2014-08-12 15:08:47 | [diff] [blame] | 713 | static_cast<WebSettings::V8CacheOptions>(prefs.v8_cache_options)); |
| 714 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 715 | settings->SetImageAnimationPolicy( |
je_julie.kim | 7fbb5a1a | 2015-02-09 17:26:05 | [diff] [blame] | 716 | static_cast<WebSettings::ImageAnimationPolicy>(prefs.animation_policy)); |
| 717 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 718 | settings->SetPresentationRequiresUserGesture( |
zqzhang | 1215ad42 | 2016-02-10 13:27:22 | [diff] [blame] | 719 | prefs.user_gesture_required_for_presentation); |
| 720 | |
Elly Fong-Jones | f9289739 | 2019-01-24 16:05:49 | [diff] [blame] | 721 | settings->SetTextTrackBackgroundColor( |
| 722 | WebString::FromASCII(prefs.text_track_background_color)); |
| 723 | settings->SetTextTrackTextColor( |
| 724 | WebString::FromASCII(prefs.text_track_text_color)); |
Rahul Singh | 1862faa9 | 2019-03-06 22:41:43 | [diff] [blame] | 725 | settings->SetTextTrackTextSize( |
| 726 | WebString::FromASCII(prefs.text_track_text_size)); |
| 727 | settings->SetTextTrackTextShadow( |
| 728 | WebString::FromASCII(prefs.text_track_text_shadow)); |
| 729 | settings->SetTextTrackFontFamily( |
| 730 | WebString::FromASCII(prefs.text_track_font_family)); |
| 731 | settings->SetTextTrackFontVariant( |
| 732 | WebString::FromASCII(prefs.text_track_font_variant)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 733 | settings->SetTextTrackMarginPercentage(prefs.text_track_margin_percentage); |
Abigail Klein | 74de85bd | 2019-07-11 19:11:56 | [diff] [blame] | 734 | settings->SetTextTrackWindowColor( |
| 735 | WebString::FromASCII(prefs.text_track_window_color)); |
| 736 | settings->SetTextTrackWindowPadding( |
| 737 | WebString::FromASCII(prefs.text_track_window_padding)); |
| 738 | settings->SetTextTrackWindowRadius( |
| 739 | WebString::FromASCII(prefs.text_track_window_radius)); |
halliwell | 4002be4 | 2016-03-18 18:33:40 | [diff] [blame] | 740 | |
David Bokan | a03511a9 | 2018-09-13 04:25:24 | [diff] [blame] | 741 | // Needs to happen before SetDefaultPageScaleLimits below since that'll |
| 742 | // recalculate the final page scale limits and that depends on this setting. |
| 743 | settings->SetShrinksViewportContentToFit( |
| 744 | prefs.shrinks_viewport_contents_to_fit); |
| 745 | |
| 746 | // Needs to happen before SetIgnoreViewportTagScaleLimits below. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 747 | web_view->SetDefaultPageScaleLimits(prefs.default_minimum_page_scale_factor, |
| 748 | prefs.default_maximum_page_scale_factor); |
dcheng | 5ae8ca36 | 2015-02-05 04:03:47 | [diff] [blame] | 749 | |
Allan Sandfeld Jensen | e3533709 | 2019-05-15 13:56:09 | [diff] [blame] | 750 | settings->SetFullscreenSupported(prefs.fullscreen_supported); |
Ahmed Fakhry | 4222145 | 2018-05-30 01:18:39 | [diff] [blame] | 751 | settings->SetTextAutosizingEnabled(prefs.text_autosizing_enabled); |
| 752 | settings->SetDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled); |
Tarun Bansal | d10f17a0 | 2018-09-13 00:23:17 | [diff] [blame] | 753 | blink::WebNetworkStateNotifier::SetNetworkQualityWebHoldback( |
| 754 | static_cast<blink::WebEffectiveConnectionType>( |
| 755 | prefs.network_quality_estimator_web_holdback)); |
Ahmed Fakhry | 4222145 | 2018-05-30 01:18:39 | [diff] [blame] | 756 | |
chaopeng | 7e8fb35 | 2019-03-26 03:34:49 | [diff] [blame] | 757 | settings->SetDontSendKeyEventsToJavascript( |
| 758 | prefs.dont_send_key_events_to_javascript); |
Mounir Lamouri | 6926107f | 2019-01-31 18:17:43 | [diff] [blame] | 759 | settings->SetWebAppScope(WebString::FromASCII(prefs.web_app_scope.spec())); |
| 760 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 761 | #if defined(OS_ANDROID) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 762 | settings->SetAllowCustomScrollbarInMainFrame(false); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 763 | settings->SetAccessibilityFontScaleFactor(prefs.font_scale_factor); |
| 764 | settings->SetDeviceScaleAdjustment(prefs.device_scale_adjustment); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 765 | web_view->SetIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); |
| 766 | settings->SetAutoZoomFocusedNodeToLegibleScale(true); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 767 | settings->SetDefaultVideoPosterURL( |
| 768 | WebString::FromASCII(prefs.default_video_poster_url.spec())); |
| 769 | settings->SetSupportDeprecatedTargetDensityDPI( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 770 | prefs.support_deprecated_target_density_dpi); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 771 | settings->SetUseLegacyBackgroundSizeShorthandBehavior( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 772 | prefs.use_legacy_background_size_shorthand_behavior); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 773 | settings->SetWideViewportQuirkEnabled(prefs.wide_viewport_quirk); |
| 774 | settings->SetUseWideViewport(prefs.use_wide_viewport); |
| 775 | settings->SetForceZeroLayoutHeight(prefs.force_zero_layout_height); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 776 | settings->SetViewportMetaMergeContentQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 777 | prefs.viewport_meta_merge_content_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 778 | settings->SetViewportMetaNonUserScalableQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 779 | prefs.viewport_meta_non_user_scalable_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 780 | settings->SetViewportMetaZeroValuesQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 781 | prefs.viewport_meta_zero_values_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 782 | settings->SetClobberUserAgentInitialScaleQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 783 | prefs.clobber_user_agent_initial_scale_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 784 | settings->SetIgnoreMainFrameOverflowHiddenQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 785 | prefs.ignore_main_frame_overflow_hidden_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 786 | settings->SetReportScreenSizeInPhysicalPixelsQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 787 | prefs.report_screen_size_in_physical_pixels_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 788 | settings->SetShouldReuseGlobalForUnownedMainFrame( |
tzik | 30eb52c | 2018-03-27 06:55:18 | [diff] [blame] | 789 | prefs.reuse_global_for_unowned_main_frame); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 790 | settings->SetPreferHiddenVolumeControls(true); |
| 791 | settings->SetSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default); |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 792 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 793 | WebRuntimeFeatures::EnableVideoFullscreenOrientationLock( |
mlamouri | 1d266bf | 2016-12-05 17:42:36 | [diff] [blame] | 794 | prefs.video_fullscreen_orientation_lock_enabled); |
johnme | 913ee5f | 2017-04-28 21:36:16 | [diff] [blame] | 795 | WebRuntimeFeatures::EnableVideoRotateToFullscreen( |
| 796 | prefs.video_rotate_to_fullscreen_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 797 | settings->SetEmbeddedMediaExperienceEnabled( |
shaktisahu | f97f753 | 2017-02-24 22:46:13 | [diff] [blame] | 798 | prefs.embedded_media_experience_enabled); |
Ian Vollick | eeca1d8 | 2018-02-07 02:43:42 | [diff] [blame] | 799 | settings->SetImmersiveModeEnabled(prefs.immersive_mode_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 800 | settings->SetDoNotUpdateSelectionOnMutatingSelectionRange( |
changwan | e54ccdb9 | 2017-04-05 19:20:54 | [diff] [blame] | 801 | prefs.do_not_update_selection_on_mutating_selection_range); |
Noel Gordon | f311a84 | 2017-07-27 00:10:07 | [diff] [blame] | 802 | WebRuntimeFeatures::EnableCSSHexAlphaColor(prefs.css_hex_alpha_color_enabled); |
Tobias Sargeant | 416174f | 2017-09-01 01:18:09 | [diff] [blame] | 803 | WebRuntimeFeatures::EnableScrollTopLeftInterop( |
| 804 | prefs.scroll_top_left_interop_enabled); |
Fernando Serboncini | 1fb12a8 | 2019-08-08 20:46:01 | [diff] [blame] | 805 | WebRuntimeFeatures::EnableSurfaceEmbeddingFeatures( |
| 806 | !prefs.disable_features_depending_on_viz); |
Aaron Krajeski | 0fb5128 | 2019-09-17 15:01:27 | [diff] [blame] | 807 | WebRuntimeFeatures::EnableAcceleratedSmallCanvases( |
| 808 | !prefs.disable_accelerated_small_canvases); |
Mason Freed | 8cbef17 | 2019-11-07 19:42:41 | [diff] [blame] | 809 | if (prefs.reenable_web_components_v0) { |
| 810 | WebRuntimeFeatures::EnableShadowDOMV0(true); |
| 811 | WebRuntimeFeatures::EnableCustomElementsV0(true); |
| 812 | WebRuntimeFeatures::EnableHTMLImports(true); |
| 813 | } |
zqzhang | df72ed08 | 2016-12-08 16:07:55 | [diff] [blame] | 814 | #endif // defined(OS_ANDROID) |
Rune Lillesveen | b46bb48 | 2019-04-02 07:36:29 | [diff] [blame] | 815 | settings->SetForceDarkModeEnabled(prefs.force_dark_mode_enabled); |
| 816 | |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 817 | switch (prefs.autoplay_policy) { |
| 818 | case AutoplayPolicy::kNoUserGestureRequired: |
mlamouri | 276a6f3 | 2017-05-12 09:24:28 | [diff] [blame] | 819 | settings->SetAutoplayPolicy( |
| 820 | WebSettings::AutoplayPolicy::kNoUserGestureRequired); |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 821 | break; |
| 822 | case AutoplayPolicy::kUserGestureRequired: |
mlamouri | 276a6f3 | 2017-05-12 09:24:28 | [diff] [blame] | 823 | settings->SetAutoplayPolicy( |
| 824 | WebSettings::AutoplayPolicy::kUserGestureRequired); |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 825 | break; |
mlamouri | 431bb4e | 2017-06-06 08:54:24 | [diff] [blame] | 826 | case AutoplayPolicy::kDocumentUserActivationRequired: |
| 827 | settings->SetAutoplayPolicy( |
| 828 | WebSettings::AutoplayPolicy::kDocumentUserActivationRequired); |
| 829 | break; |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 830 | } |
| 831 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 832 | settings->SetViewportEnabled(prefs.viewport_enabled); |
| 833 | settings->SetViewportMetaEnabled(prefs.viewport_meta_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 834 | settings->SetViewportStyle( |
alokp | 5d56696 | 2016-04-19 00:54:16 | [diff] [blame] | 835 | static_cast<blink::WebViewportStyle>(prefs.viewport_style)); |
| 836 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 837 | settings->SetLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale); |
| 838 | settings->SetMainFrameResizesAreOrientationChanges( |
yoav | a1a508b4 | 2015-10-20 12:03:21 | [diff] [blame] | 839 | prefs.main_frame_resizes_are_orientation_changes); |
| 840 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 841 | settings->SetShowContextMenuOnMouseUp(prefs.context_menu_on_mouse_up); |
| 842 | settings->SetAlwaysShowContextMenuOnTouch( |
amaralp | 547e419 | 2016-06-03 19:17:35 | [diff] [blame] | 843 | prefs.always_show_context_menu_on_touch); |
Sandra Sun | c79fc93a | 2018-04-10 15:22:23 | [diff] [blame] | 844 | settings->SetSmoothScrollForFindEnabled(prefs.smooth_scroll_for_find_enabled); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 845 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 846 | settings->SetHideDownloadUI(prefs.hide_download_ui); |
qinmin | 72e8bd0 | 2016-10-21 19:35:37 | [diff] [blame] | 847 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 848 | settings->SetPresentationReceiver(prefs.presentation_receiver); |
mlamouri | 57359d91 | 2016-11-29 20:11:50 | [diff] [blame] | 849 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 850 | settings->SetMediaControlsEnabled(prefs.media_controls_enabled); |
mlamouri | 5cd9ae8 | 2017-02-18 11:05:09 | [diff] [blame] | 851 | |
Tarun Bansal | 73d67f0 | 2018-01-17 05:56:25 | [diff] [blame] | 852 | settings->SetLowPriorityIframesThreshold( |
| 853 | static_cast<blink::WebEffectiveConnectionType>( |
| 854 | prefs.low_priority_iframes_threshold)); |
| 855 | |
Mounir Lamouri | 9c99a160 | 2018-07-05 15:01:44 | [diff] [blame] | 856 | settings->SetPictureInPictureEnabled( |
| 857 | prefs.picture_in_picture_enabled && |
[email protected] | 69db58f | 2018-09-26 20:27:56 | [diff] [blame] | 858 | MediaFactory::GetVideoSurfaceLayerMode() != |
CJ DiMeglio | 8924047 | 2018-10-18 18:21:10 | [diff] [blame] | 859 | blink::WebMediaPlayer::SurfaceLayerMode::kNever); |
François Beaufort | 8c08979fc | 2018-03-05 13:06:31 | [diff] [blame] | 860 | |
Tarun Bansal | 333819e | 2018-05-15 16:38:42 | [diff] [blame] | 861 | settings->SetDataSaverHoldbackWebApi( |
| 862 | prefs.data_saver_holdback_web_api_enabled); |
Tarun Bansal | 333819e | 2018-05-15 16:38:42 | [diff] [blame] | 863 | |
rajendrant | e87ed71 | 2018-11-30 01:55:00 | [diff] [blame] | 864 | settings->SetLazyLoadEnabled(prefs.lazy_load_enabled); |
| 865 | |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 866 | for (const auto& ect_distance_pair : |
| 867 | prefs.lazy_frame_loading_distance_thresholds_px) { |
| 868 | switch (ect_distance_pair.first) { |
| 869 | case net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN: |
| 870 | settings->SetLazyFrameLoadingDistanceThresholdPxUnknown( |
| 871 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 872 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 873 | case net::EFFECTIVE_CONNECTION_TYPE_OFFLINE: |
| 874 | settings->SetLazyFrameLoadingDistanceThresholdPxOffline( |
| 875 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 876 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 877 | case net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G: |
| 878 | settings->SetLazyFrameLoadingDistanceThresholdPxSlow2G( |
| 879 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 880 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 881 | case net::EFFECTIVE_CONNECTION_TYPE_2G: |
| 882 | settings->SetLazyFrameLoadingDistanceThresholdPx2G( |
| 883 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 884 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 885 | case net::EFFECTIVE_CONNECTION_TYPE_3G: |
| 886 | settings->SetLazyFrameLoadingDistanceThresholdPx3G( |
| 887 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 888 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 889 | case net::EFFECTIVE_CONNECTION_TYPE_4G: |
| 890 | settings->SetLazyFrameLoadingDistanceThresholdPx4G( |
| 891 | ect_distance_pair.second); |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 892 | continue; |
| 893 | case net::EFFECTIVE_CONNECTION_TYPE_LAST: |
| 894 | continue; |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 895 | } |
rajendrant | d802634 | 2018-08-29 08:08:39 | [diff] [blame] | 896 | NOTREACHED(); |
| 897 | } |
| 898 | |
| 899 | for (const auto& ect_distance_pair : |
| 900 | prefs.lazy_image_loading_distance_thresholds_px) { |
| 901 | switch (ect_distance_pair.first) { |
| 902 | case net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN: |
| 903 | settings->SetLazyImageLoadingDistanceThresholdPxUnknown( |
| 904 | ect_distance_pair.second); |
| 905 | continue; |
| 906 | case net::EFFECTIVE_CONNECTION_TYPE_OFFLINE: |
| 907 | settings->SetLazyImageLoadingDistanceThresholdPxOffline( |
| 908 | ect_distance_pair.second); |
| 909 | continue; |
| 910 | case net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G: |
| 911 | settings->SetLazyImageLoadingDistanceThresholdPxSlow2G( |
| 912 | ect_distance_pair.second); |
| 913 | continue; |
| 914 | case net::EFFECTIVE_CONNECTION_TYPE_2G: |
| 915 | settings->SetLazyImageLoadingDistanceThresholdPx2G( |
| 916 | ect_distance_pair.second); |
| 917 | continue; |
| 918 | case net::EFFECTIVE_CONNECTION_TYPE_3G: |
| 919 | settings->SetLazyImageLoadingDistanceThresholdPx3G( |
| 920 | ect_distance_pair.second); |
| 921 | continue; |
| 922 | case net::EFFECTIVE_CONNECTION_TYPE_4G: |
| 923 | settings->SetLazyImageLoadingDistanceThresholdPx4G( |
| 924 | ect_distance_pair.second); |
| 925 | continue; |
| 926 | case net::EFFECTIVE_CONNECTION_TYPE_LAST: |
| 927 | continue; |
| 928 | } |
| 929 | NOTREACHED(); |
Scott Little | 878f7d670 | 2018-05-31 22:09:06 | [diff] [blame] | 930 | } |
| 931 | |
rajendrant | 3daeae29 | 2019-09-20 07:57:54 | [diff] [blame] | 932 | for (const auto& fully_load_k_pair : prefs.lazy_image_first_k_fully_load) { |
| 933 | switch (fully_load_k_pair.first) { |
| 934 | case net::EFFECTIVE_CONNECTION_TYPE_OFFLINE: |
| 935 | continue; |
| 936 | case net::EFFECTIVE_CONNECTION_TYPE_UNKNOWN: |
| 937 | settings->SetLazyImageFirstKFullyLoadUnknown(fully_load_k_pair.second); |
| 938 | continue; |
| 939 | case net::EFFECTIVE_CONNECTION_TYPE_SLOW_2G: |
| 940 | settings->SetLazyImageFirstKFullyLoadSlow2G(fully_load_k_pair.second); |
| 941 | continue; |
| 942 | case net::EFFECTIVE_CONNECTION_TYPE_2G: |
| 943 | settings->SetLazyImageFirstKFullyLoad2G(fully_load_k_pair.second); |
| 944 | continue; |
| 945 | case net::EFFECTIVE_CONNECTION_TYPE_3G: |
| 946 | settings->SetLazyImageFirstKFullyLoad3G(fully_load_k_pair.second); |
| 947 | continue; |
| 948 | case net::EFFECTIVE_CONNECTION_TYPE_4G: |
| 949 | settings->SetLazyImageFirstKFullyLoad4G(fully_load_k_pair.second); |
| 950 | continue; |
| 951 | case net::EFFECTIVE_CONNECTION_TYPE_LAST: |
| 952 | continue; |
| 953 | } |
| 954 | NOTREACHED(); |
| 955 | } |
| 956 | |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 957 | #if defined(OS_MACOSX) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 958 | web_view->SetMaximumLegibleScale(prefs.default_maximum_page_scale_factor); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 959 | #endif |
sunyunjia | 87f287b | 2016-09-09 00:38:13 | [diff] [blame] | 960 | |
| 961 | #if defined(OS_WIN) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 962 | WebRuntimeFeatures::EnableMiddleClickAutoscroll(true); |
sunyunjia | 87f287b | 2016-09-09 00:38:13 | [diff] [blame] | 963 | #endif |
Dave Tapuska | c6627e1 | 2018-08-30 15:07:19 | [diff] [blame] | 964 | |
Dave Tapuska | a38e325 | 2018-11-13 03:01:17 | [diff] [blame] | 965 | WebRuntimeFeatures::EnableTranslateService(prefs.translate_service_available); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | /*static*/ |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 969 | RenderViewImpl* RenderViewImpl::Create( |
| 970 | CompositorDependencies* compositor_deps, |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 971 | mojom::CreateViewParamsPtr params, |
danakj | df1ceb7 | 2018-07-18 20:02:25 | [diff] [blame] | 972 | RenderWidget::ShowCallback show_callback, |
Hajime Hoshi | abb3c8f | 2017-12-04 18:41:39 | [diff] [blame] | 973 | scoped_refptr<base::SingleThreadTaskRunner> task_runner) { |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 974 | DCHECK(params->view_id != MSG_ROUTING_NONE); |
danakj | d434db4 | 2020-01-07 22:27:39 | [diff] [blame] | 975 | // Frame and widget routing ids come together. |
| 976 | DCHECK_EQ(params->main_frame_routing_id == MSG_ROUTING_NONE, |
| 977 | params->main_frame_widget_routing_id == MSG_ROUTING_NONE); |
| 978 | // We have either a main frame or a proxy routing id. |
| 979 | DCHECK_NE(params->main_frame_routing_id != MSG_ROUTING_NONE, |
| 980 | params->proxy_routing_id != MSG_ROUTING_NONE); |
[email protected] | 0287e76 | 2014-04-11 13:07:58 | [diff] [blame] | 981 | |
danakj | d434db4 | 2020-01-07 22:27:39 | [diff] [blame] | 982 | RenderViewImpl* render_view; |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 983 | if (g_create_render_view_impl) { |
| 984 | render_view = g_create_render_view_impl(compositor_deps, *params); |
| 985 | } else { |
| 986 | render_view = new RenderViewImpl(compositor_deps, *params); |
| 987 | } |
| 988 | |
Erik Chen | 10e9b02 | 2019-08-21 23:33:23 | [diff] [blame] | 989 | render_view->Initialize(compositor_deps, std::move(params), |
Albert J. Wong | 7faa3da | 2019-03-21 20:43:43 | [diff] [blame] | 990 | std::move(show_callback), std::move(task_runner)); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 991 | return render_view; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 992 | } |
| 993 | |
Erik Chen | 3433ee0 | 2019-08-05 20:14:26 | [diff] [blame] | 994 | void RenderViewImpl::Destroy() { |
danakj | cdfc426 | 2019-10-01 20:09:48 | [diff] [blame] | 995 | destroying_ = true; |
| 996 | |
Erik Chen | 562ca42b | 2019-08-22 19:46:06 | [diff] [blame] | 997 | webview_->Close(); |
Erik Chen | 3433ee0 | 2019-08-05 20:14:26 | [diff] [blame] | 998 | // The webview_ is already destroyed by the time we get here, remove any |
| 999 | // references to it. |
| 1000 | g_view_map.Get().erase(webview_); |
| 1001 | webview_ = nullptr; |
Erik Chen | 562ca42b | 2019-08-22 19:46:06 | [diff] [blame] | 1002 | |
Erik Chen | 3433ee0 | 2019-08-05 20:14:26 | [diff] [blame] | 1003 | delete this; |
| 1004 | } |
| 1005 | |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1006 | // static |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1007 | void RenderViewImpl::InstallCreateHook(RenderViewImpl* ( |
| 1008 | *create_render_view_impl)(CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 1009 | const mojom::CreateViewParams&)) { |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1010 | CHECK(!g_create_render_view_impl); |
| 1011 | g_create_render_view_impl = create_render_view_impl; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1012 | } |
| 1013 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1014 | void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1015 | observers_.AddObserver(observer); |
| 1016 | } |
| 1017 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1018 | void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 1019 | observer->RenderViewGone(); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1020 | observers_.RemoveObserver(observer); |
| 1021 | } |
| 1022 | |
Peter Kasting | a4a3ed1 | 2018-01-31 04:07:59 | [diff] [blame] | 1023 | blink::WebView* RenderViewImpl::webview() { |
| 1024 | return webview_; |
| 1025 | } |
| 1026 | |
| 1027 | const blink::WebView* RenderViewImpl::webview() const { |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 1028 | return webview_; |
[email protected] | 4d51d5bf | 2010-07-26 18:48:26 | [diff] [blame] | 1029 | } |
| 1030 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1031 | // RenderWidgetOwnerDelegate ----------------------------------------- |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1032 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1033 | void RenderViewImpl::SetActiveForWidget(bool active) { |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 1034 | if (webview()) |
| 1035 | webview()->SetIsActive(active); |
| 1036 | } |
| 1037 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1038 | bool RenderViewImpl::SupportsMultipleWindowsForWidget() { |
| 1039 | return webkit_preferences_.supports_multiple_windows; |
| 1040 | } |
| 1041 | |
David Bokan | 11f6ef48 | 2019-03-18 17:47:27 | [diff] [blame] | 1042 | bool RenderViewImpl::ShouldAckSyntheticInputImmediately() { |
| 1043 | // TODO(bokan): The RequestPresentation API appears not to function in VR. As |
| 1044 | // a short term workaround for https://crbug.com/940063, ACK input |
| 1045 | // immediately rather than using RequestPresentation. |
| 1046 | if (webkit_preferences_.immersive_mode_enabled) |
| 1047 | return true; |
| 1048 | return false; |
| 1049 | } |
| 1050 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1051 | void RenderViewImpl::ApplyNewDisplayModeForWidget( |
Eric Willigers | 052f043 | 2019-10-04 04:06:57 | [diff] [blame] | 1052 | blink::mojom::DisplayMode new_display_mode) { |
danakj | 1ab8faf | 2018-10-12 18:24:28 | [diff] [blame] | 1053 | webview()->SetDisplayMode(new_display_mode); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1054 | } |
| 1055 | |
| 1056 | void RenderViewImpl::ApplyAutoResizeLimitsForWidget(const gfx::Size& min_size, |
| 1057 | const gfx::Size& max_size) { |
| 1058 | webview()->EnableAutoResizeMode(min_size, max_size); |
| 1059 | } |
| 1060 | |
| 1061 | void RenderViewImpl::DisableAutoResizeForWidget() { |
| 1062 | webview()->DisableAutoResizeMode(); |
| 1063 | } |
| 1064 | |
| 1065 | void RenderViewImpl::ScrollFocusedNodeIntoViewForWidget() { |
| 1066 | if (WebLocalFrame* focused_frame = GetWebView()->FocusedFrame()) { |
danakj | 5f06901 | 2019-10-09 23:14:17 | [diff] [blame] | 1067 | blink::WebFrameWidget* frame_widget = |
| 1068 | focused_frame->LocalRoot()->FrameWidget(); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1069 | frame_widget->ScrollFocusedEditableElementIntoView(); |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | void RenderViewImpl::DidReceiveSetFocusEventForWidget() { |
| 1074 | // This message must always be received when the main frame is a |
| 1075 | // WebLocalFrame. |
Albert J. Wong | 7bbf22d | 2018-12-20 00:27:27 | [diff] [blame] | 1076 | // TODO(ajwong): Can this be removed and just check |delegate_| in |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1077 | // RenderWidget instead? |
| 1078 | CHECK(webview()->MainFrame()->IsWebLocalFrame()); |
| 1079 | } |
| 1080 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1081 | void RenderViewImpl::DidCommitCompositorFrameForWidget() { |
| 1082 | for (auto& observer : observers_) |
| 1083 | observer.DidCommitCompositorFrame(); |
Philip Rogers | 33cd2bcc | 2018-08-13 21:29:29 | [diff] [blame] | 1084 | UpdatePreferredSize(); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1085 | } |
| 1086 | |
| 1087 | void RenderViewImpl::DidCompletePageScaleAnimationForWidget() { |
| 1088 | if (auto* focused_frame = GetWebView()->FocusedFrame()) { |
| 1089 | if (focused_frame->AutofillClient()) |
| 1090 | focused_frame->AutofillClient()->DidCompleteFocusChangeInFrame(); |
| 1091 | } |
| 1092 | } |
| 1093 | |
| 1094 | void RenderViewImpl::ResizeWebWidgetForWidget( |
danakj | 748ef909 | 2019-10-17 23:40:53 | [diff] [blame] | 1095 | const gfx::Size& widget_size, |
Sinan Sahin | 92a360bc | 2019-12-05 19:20:45 | [diff] [blame] | 1096 | cc::BrowserControlsParams browser_controls_params) { |
| 1097 | webview()->ResizeWithBrowserControls(widget_size, browser_controls_params); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1098 | } |
| 1099 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1100 | void RenderViewImpl::SetScreenMetricsEmulationParametersForWidget( |
| 1101 | bool enabled, |
| 1102 | const blink::WebDeviceEmulationParams& params) { |
danakj | 1ab8faf | 2018-10-12 18:24:28 | [diff] [blame] | 1103 | if (enabled) |
| 1104 | webview()->EnableDeviceEmulation(params); |
| 1105 | else |
| 1106 | webview()->DisableDeviceEmulation(); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1107 | } |
| 1108 | |
| 1109 | // IPC message handlers ----------------------------------------- |
| 1110 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1111 | void RenderViewImpl::OnUpdateTargetURLAck() { |
| 1112 | // Check if there is a targeturl waiting to be sent. |
| 1113 | if (target_url_status_ == TARGET_PENDING) |
| 1114 | Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), pending_target_url_)); |
| 1115 | |
| 1116 | target_url_status_ = TARGET_NONE; |
| 1117 | } |
| 1118 | |
| 1119 | void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
| 1120 | int history_length) { |
| 1121 | // -1 <= history_offset < history_length <= kMaxSessionHistoryEntries(50). |
| 1122 | DCHECK_LE(-1, history_offset); |
| 1123 | DCHECK_LT(history_offset, history_length); |
| 1124 | DCHECK_LE(history_length, kMaxSessionHistoryEntries); |
| 1125 | |
| 1126 | history_list_offset_ = history_offset; |
| 1127 | history_list_length_ = history_length; |
| 1128 | } |
| 1129 | |
| 1130 | void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
| 1131 | if (!webview()) |
| 1132 | return; |
| 1133 | webview()->SetInitialFocus(reverse); |
| 1134 | } |
| 1135 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1136 | void RenderViewImpl::OnAudioStateChanged(bool is_audio_playing) { |
| 1137 | webview()->AudioStateChanged(is_audio_playing); |
| 1138 | } |
| 1139 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1140 | /////////////////////////////////////////////////////////////////////////////// |
| 1141 | |
| 1142 | void RenderViewImpl::ShowCreatedPopupWidget(RenderWidget* popup_widget, |
| 1143 | WebNavigationPolicy policy, |
| 1144 | const gfx::Rect& initial_rect) { |
| 1145 | Send(new ViewHostMsg_ShowWidget(GetRoutingID(), popup_widget->routing_id(), |
| 1146 | initial_rect)); |
| 1147 | } |
| 1148 | |
| 1149 | void RenderViewImpl::ShowCreatedFullscreenWidget( |
| 1150 | RenderWidget* fullscreen_widget, |
| 1151 | WebNavigationPolicy policy, |
| 1152 | const gfx::Rect& initial_rect) { |
| 1153 | Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(), |
| 1154 | fullscreen_widget->routing_id())); |
| 1155 | } |
| 1156 | |
| 1157 | void RenderViewImpl::SendFrameStateUpdates() { |
| 1158 | // Tell each frame with pending state to send its UpdateState message. |
| 1159 | for (int render_frame_routing_id : frames_with_pending_state_) { |
| 1160 | RenderFrameImpl* frame = |
| 1161 | RenderFrameImpl::FromRoutingID(render_frame_routing_id); |
| 1162 | if (frame) |
| 1163 | frame->SendUpdateState(); |
| 1164 | } |
| 1165 | frames_with_pending_state_.clear(); |
| 1166 | } |
| 1167 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1168 | // IPC::Listener ------------------------------------------------------------- |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1169 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1170 | bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
Ivan Kotenkov | 2c0d2bb3 | 2017-11-01 15:41:28 | [diff] [blame] | 1171 | WebFrame* main_frame = webview() ? webview()->MainFrame() : nullptr; |
Avi Drissman | b5f8e24 | 2017-12-12 05:21:56 | [diff] [blame] | 1172 | if (main_frame) { |
| 1173 | GURL active_url; |
| 1174 | if (main_frame->IsWebLocalFrame()) |
| 1175 | active_url = main_frame->ToWebLocalFrame()->GetDocument().Url(); |
lukasza | bedb4b2 | 2017-06-23 00:00:13 | [diff] [blame] | 1176 | GetContentClient()->SetActiveURL( |
Avi Drissman | b5f8e24 | 2017-12-12 05:21:56 | [diff] [blame] | 1177 | active_url, main_frame->Top()->GetSecurityOrigin().ToString().Utf8()); |
| 1178 | } |
[email protected] | f8b6b6f | 2009-03-10 16:48:26 | [diff] [blame] | 1179 | |
dcheng | a2d442c2 | 2016-10-13 15:39:21 | [diff] [blame] | 1180 | for (auto& observer : observers_) { |
| 1181 | if (observer.OnMessageReceived(message)) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1182 | return true; |
dcheng | a2d442c2 | 2016-10-13 15:39:21 | [diff] [blame] | 1183 | } |
[email protected] | b2abac7 | 2009-02-26 12:39:28 | [diff] [blame] | 1184 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1185 | bool handled = true; |
[email protected] | e44d134 | 2014-05-16 21:29:33 | [diff] [blame] | 1186 | IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1187 | IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1188 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 1189 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 1190 | IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
[email protected] | ab32b16c | 2009-10-16 14:57:25 | [diff] [blame] | 1191 | IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1192 | OnEnablePreferredSizeChangedMode) |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1193 | IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
W. James MacLean | d973a55b | 2018-11-29 21:39:13 | [diff] [blame] | 1194 | IPC_MESSAGE_HANDLER(ViewMsg_AnimateDoubleTapZoom, |
| 1195 | OnAnimateDoubleTapZoomInMainFrame) |
W. James MacLean | 5372eb7 | 2018-12-19 12:56:36 | [diff] [blame] | 1196 | IPC_MESSAGE_HANDLER(ViewMsg_ZoomToFindInPageRect, OnZoomToFindInPageRect) |
danakj | d51fd53d | 2018-12-21 23:06:09 | [diff] [blame] | 1197 | IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1198 | |
| 1199 | // Page messages. |
Collin Baker | 98457b5 | 2019-11-06 21:34:29 | [diff] [blame] | 1200 | IPC_MESSAGE_HANDLER(PageMsg_VisibilityChanged, OnPageVisibilityChanged) |
alexmos | 136fd6e6 | 2016-08-15 20:58:41 | [diff] [blame] | 1201 | IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, |
| 1202 | OnSetHistoryOffsetAndLength) |
altimin | d8bd26c | 2016-11-04 11:44:54 | [diff] [blame] | 1203 | IPC_MESSAGE_HANDLER(PageMsg_AudioStateChanged, OnAudioStateChanged) |
Francois Doray | 47f759d | 2018-06-11 18:13:51 | [diff] [blame] | 1204 | IPC_MESSAGE_HANDLER(PageMsg_SetPageFrozen, SetPageFrozen) |
Yuzu Saijo | dfba8fa6 | 2019-08-27 02:15:22 | [diff] [blame] | 1205 | IPC_MESSAGE_HANDLER(PageMsg_PutPageIntoBackForwardCache, |
| 1206 | PutPageIntoBackForwardCache) |
| 1207 | IPC_MESSAGE_HANDLER(PageMsg_RestorePageFromBackForwardCache, |
| 1208 | RestorePageFromBackForwardCache) |
W. James MacLean | 6219867 | 2019-06-04 16:46:10 | [diff] [blame] | 1209 | IPC_MESSAGE_HANDLER(PageMsg_UpdateTextAutosizerPageInfoForRemoteMainFrames, |
| 1210 | OnTextAutosizerPageInfoChanged) |
Bruce Long | 1e3e1f54 | 2019-10-16 17:56:28 | [diff] [blame] | 1211 | IPC_MESSAGE_HANDLER(PageMsg_SetRendererPrefs, OnSetRendererPrefs) |
Adithya Srinivasan | 11af2c5 | 2019-12-16 22:52:55 | [diff] [blame] | 1212 | IPC_MESSAGE_HANDLER(PageMsg_SetInsidePortal, OnSetInsidePortal) |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 1213 | |
[email protected] | a794f3a | 2013-10-30 17:00:32 | [diff] [blame] | 1214 | // Adding a new message? Add platform independent ones first, then put the |
| 1215 | // platform specific ones at the end. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1216 | IPC_END_MESSAGE_MAP() |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 1217 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1218 | return handled; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1219 | } |
| 1220 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1221 | // blink::WebViewClient ------------------------------------------------------ |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1222 | |
Mustaq Ahmed | 55944cb | 2018-05-25 20:44:27 | [diff] [blame] | 1223 | // TODO(csharrison): Migrate this method to WebLocalFrameClient / |
| 1224 | // RenderFrameImpl, as it is now serviced by a mojo interface scoped to the |
| 1225 | // opener frame. |
Daniel Murphy | c8e991a | 2018-10-12 22:09:03 | [diff] [blame] | 1226 | WebView* RenderViewImpl::CreateView( |
| 1227 | WebLocalFrame* creator, |
| 1228 | const WebURLRequest& request, |
| 1229 | const WebWindowFeatures& features, |
| 1230 | const WebString& frame_name, |
| 1231 | WebNavigationPolicy policy, |
Antonio Gomes | 7096ac0 | 2020-02-14 14:29:54 | [diff] [blame] | 1232 | blink::mojom::WebSandboxFlags sandbox_flags, |
Ehsan Karamad | 3940708 | 2019-02-19 23:38:19 | [diff] [blame] | 1233 | const blink::FeaturePolicy::FeatureState& opener_feature_state, |
Daniel Murphy | c8e991a | 2018-10-12 22:09:03 | [diff] [blame] | 1234 | const blink::SessionStorageNamespaceId& session_storage_namespace_id) { |
nick | 5ae4d2d | 2017-01-06 01:18:35 | [diff] [blame] | 1235 | RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1236 | mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 1237 | |
Mustaq Ahmed | e5f1256 | 2019-10-30 18:02:03 | [diff] [blame] | 1238 | // The user activation check is done at the browser process through |
| 1239 | // |frame_host->CreateNewWindow()| call below. But the extensions case |
| 1240 | // handled through the following |if| is an exception. |
Mustaq Ahmed | 8601a56 | 2020-01-31 18:05:52 | [diff] [blame] | 1241 | params->allow_popup = false; |
[email protected] | 00323f0 | 2013-07-24 15:47:41 | [diff] [blame] | 1242 | if (GetContentClient()->renderer()->AllowPopup()) |
Mustaq Ahmed | 8601a56 | 2020-01-31 18:05:52 | [diff] [blame] | 1243 | params->allow_popup = true; |
Mustaq Ahmed | c4cb716 | 2018-06-05 16:28:36 | [diff] [blame] | 1244 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1245 | params->window_container_type = WindowFeaturesToContainerType(features); |
Daniel Murphy | e3eec92c | 2018-02-23 19:09:15 | [diff] [blame] | 1246 | |
Daniel Murphy | c8e991a | 2018-10-12 22:09:03 | [diff] [blame] | 1247 | params->session_storage_namespace_id = session_storage_namespace_id; |
| 1248 | // TODO(dmurph): Don't copy session storage when features.noopener is true: |
| 1249 | // https://html.spec.whatwg.org/multipage/browsers.html#copy-session-storage |
| 1250 | // https://crbug.com/771959 |
Daniel Murphy | e3eec92c | 2018-02-23 19:09:15 | [diff] [blame] | 1251 | params->clone_from_session_storage_namespace_id = |
| 1252 | session_storage_namespace_id_; |
Daniel Murphy | e3eec92c | 2018-02-23 19:09:15 | [diff] [blame] | 1253 | |
Daniel Cheng | d5e56ff | 2017-06-24 07:44:02 | [diff] [blame] | 1254 | const std::string& frame_name_utf8 = frame_name.Utf8( |
| 1255 | WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD); |
| 1256 | params->frame_name = frame_name_utf8; |
Nate Chapin | 43f307d | 2019-04-15 21:04:41 | [diff] [blame] | 1257 | params->opener_suppressed = features.noopener; |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1258 | params->disposition = NavigationPolicyToDisposition(policy); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1259 | if (!request.IsNull()) { |
| 1260 | params->target_url = request.Url(); |
Dominic Farolino | aee9c1b8 | 2019-12-18 03:20:10 | [diff] [blame] | 1261 | params->referrer = blink::mojom::Referrer::New( |
| 1262 | blink::WebStringToGURL(request.ReferrerString()), |
| 1263 | request.GetReferrerPolicy()); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 1264 | } |
scottmg | 8e6c608 | 2017-02-13 23:15:48 | [diff] [blame] | 1265 | params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1266 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1267 | // We preserve this information before sending the message since |params| is |
| 1268 | // moved on send. |
| 1269 | bool is_background_tab = |
| 1270 | params->disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB; |
[email protected] | 22217ed3 | 2013-11-18 18:40:23 | [diff] [blame] | 1271 | |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1272 | mojom::CreateNewWindowStatus status; |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1273 | mojom::CreateNewWindowReplyPtr reply; |
Balazs Engedy | a40712f | 2017-09-15 15:01:11 | [diff] [blame] | 1274 | auto* frame_host = creator_frame->GetFrameHost(); |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1275 | bool err = !frame_host->CreateNewWindow(std::move(params), &status, &reply); |
| 1276 | if (err || status == mojom::CreateNewWindowStatus::kIgnore) |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1277 | return nullptr; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1278 | |
Jochen Eisinger | 515337a | 2017-05-26 14:12:52 | [diff] [blame] | 1279 | // For Android WebView, we support a pop-up like behavior for window.open() |
| 1280 | // even if the embedding app doesn't support multiple windows. In this case, |
| 1281 | // window.open() will return "window" and navigate it to whatever URL was |
Jochen Eisinger | 8cb2849 | 2017-10-04 10:58:13 | [diff] [blame] | 1282 | // passed. We also don't need to consume user gestures to protect against |
| 1283 | // multiple windows being opened, because, well, the app doesn't support |
| 1284 | // multiple windows. |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1285 | // 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] | 1286 | // used much in Blink, except to enable web testing... perhaps this should |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1287 | // be checked directly in the browser side. |
| 1288 | if (status == mojom::CreateNewWindowStatus::kReuse) |
Jochen Eisinger | 515337a | 2017-05-26 14:12:52 | [diff] [blame] | 1289 | return webview(); |
| 1290 | |
Daniel Cheng | 8bb30c6 | 2017-10-23 20:40:47 | [diff] [blame] | 1291 | DCHECK(reply); |
| 1292 | DCHECK_NE(MSG_ROUTING_NONE, reply->route_id); |
| 1293 | DCHECK_NE(MSG_ROUTING_NONE, reply->main_frame_route_id); |
| 1294 | DCHECK_NE(MSG_ROUTING_NONE, reply->main_frame_widget_route_id); |
| 1295 | |
Mustaq Ahmed | 76c2f431 | 2018-06-07 20:48:01 | [diff] [blame] | 1296 | // The browser allowed creation of a new window and consumed the user |
Mustaq Ahmed | e5f1256 | 2019-10-30 18:02:03 | [diff] [blame] | 1297 | // activation. |
Mustaq Ahmed | 4baa9a6e8 | 2019-12-20 23:43:46 | [diff] [blame] | 1298 | bool was_consumed = creator->ConsumeTransientUserActivation( |
| 1299 | blink::UserActivationUpdateSource::kBrowser); |
Jochen Eisinger | 8cb2849 | 2017-10-04 10:58:13 | [diff] [blame] | 1300 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 1301 | // While this view may be a background extension page, it can spawn a visible |
| 1302 | // render view. So we just assume that the new one is not another background |
| 1303 | // page instead of passing on our own value. |
| 1304 | // TODO(vangelis): Can we tell if the new view will be a background page? |
danakj | 77eb7e8 | 2020-01-09 19:38:46 | [diff] [blame] | 1305 | bool never_composited = false; |
[email protected] | 9115d5f | 2013-03-24 04:37:41 | [diff] [blame] | 1306 | |
[email protected] | d6fa88f | 2013-10-18 16:00:43 | [diff] [blame] | 1307 | // The initial hidden state for the RenderViewImpl here has to match what the |
| 1308 | // browser will eventually decide for the given disposition. Since we have to |
| 1309 | // return from this call synchronously, we just have to make our best guess |
| 1310 | // and rely on the browser sending a WasHidden / WasShown message if it |
| 1311 | // disagrees. |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1312 | mojom::CreateViewParamsPtr view_params = mojom::CreateViewParams::New(); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1313 | |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1314 | view_params->opener_frame_route_id = creator_frame->GetRoutingID(); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1315 | DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1316 | |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1317 | view_params->window_was_created_with_opener = true; |
Leon Han | 2c81b5d | 2019-01-25 01:58:33 | [diff] [blame] | 1318 | view_params->renderer_preferences = renderer_preferences_.Clone(); |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1319 | view_params->web_preferences = webkit_preferences_; |
| 1320 | view_params->view_id = reply->route_id; |
| 1321 | view_params->main_frame_routing_id = reply->main_frame_route_id; |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 1322 | view_params |
| 1323 | ->main_frame_interface_bundle = mojom::DocumentScopedInterfaceBundle::New( |
| 1324 | std::move(reply->main_frame_interface_bundle->interface_provider), |
Oksana Zhuravlova | fee097c | 2019-07-26 17:01:30 | [diff] [blame] | 1325 | std::move(reply->main_frame_interface_bundle->browser_interface_broker)); |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1326 | view_params->main_frame_widget_routing_id = reply->main_frame_widget_route_id; |
| 1327 | view_params->session_storage_namespace_id = |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1328 | reply->cloned_session_storage_namespace_id; |
Daniel Murphy | 95792ef | 2018-10-04 01:29:55 | [diff] [blame] | 1329 | DCHECK(!view_params->session_storage_namespace_id.empty()) |
| 1330 | << "Session storage namespace must be populated."; |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1331 | view_params->replicated_frame_state.frame_policy.sandbox_flags = |
| 1332 | sandbox_flags; |
Ehsan Karamad | 3940708 | 2019-02-19 23:38:19 | [diff] [blame] | 1333 | view_params->replicated_frame_state.opener_feature_state = |
| 1334 | opener_feature_state; |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1335 | view_params->replicated_frame_state.name = frame_name_utf8; |
| 1336 | view_params->devtools_main_frame_token = reply->devtools_main_frame_token; |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1337 | view_params->hidden = is_background_tab; |
danakj | 77eb7e8 | 2020-01-09 19:38:46 | [diff] [blame] | 1338 | view_params->never_composited = never_composited; |
danakj | be56b813 | 2019-10-12 00:57:41 | [diff] [blame] | 1339 | view_params->visual_properties = reply->visual_properties; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1340 | |
nick | 5ae4d2d | 2017-01-06 01:18:35 | [diff] [blame] | 1341 | // Unretained() is safe here because our calling function will also call |
| 1342 | // show(). |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1343 | RenderWidget::ShowCallback show_callback = |
danakj | df1ceb7 | 2018-07-18 20:02:25 | [diff] [blame] | 1344 | base::BindOnce(&RenderFrameImpl::ShowCreatedWindow, |
Mustaq Ahmed | e5f1256 | 2019-10-30 18:02:03 | [diff] [blame] | 1345 | base::Unretained(creator_frame), was_consumed); |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1346 | |
Balazs Engedy | ba034e7 | 2017-10-27 22:26:28 | [diff] [blame] | 1347 | RenderViewImpl* view = RenderViewImpl::Create( |
danakj | 4b8a2d9a | 2019-10-15 15:53:59 | [diff] [blame] | 1348 | compositor_deps_, std::move(view_params), std::move(show_callback), |
Hajime Hoshi | 6fc9114 | 2018-05-11 08:21:17 | [diff] [blame] | 1349 | creator->GetTaskRunner(blink::TaskType::kInternalDefault)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1350 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1351 | return view->webview(); |
| 1352 | } |
| 1353 | |
danakj | 19f3e51 | 2018-12-14 21:02:05 | [diff] [blame] | 1354 | blink::WebPagePopup* RenderViewImpl::CreatePopup( |
| 1355 | blink::WebLocalFrame* creator) { |
Julie Jeongeun Kim | caacf910 | 2019-09-12 02:13:05 | [diff] [blame] | 1356 | mojo::PendingRemote<mojom::Widget> widget_channel; |
| 1357 | mojo::PendingReceiver<mojom::Widget> widget_channel_receiver = |
| 1358 | widget_channel.InitWithNewPipeAndPassReceiver(); |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1359 | |
| 1360 | // Do a synchronous IPC to obtain a routing ID. |
| 1361 | int32_t widget_routing_id = MSG_ROUTING_NONE; |
| 1362 | bool success = |
| 1363 | RenderThreadImpl::current_render_message_filter()->CreateNewWidget( |
| 1364 | GetRoutingID(), std::move(widget_channel), &widget_routing_id); |
| 1365 | if (!success) { |
| 1366 | // When the renderer is being killed the mojo message will fail. |
Ivan Kotenkov | 2c0d2bb3 | 2017-11-01 15:41:28 | [diff] [blame] | 1367 | return nullptr; |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1368 | } |
| 1369 | |
| 1370 | RenderWidget::ShowCallback opener_callback = base::BindOnce( |
| 1371 | &RenderViewImpl::ShowCreatedPopupWidget, weak_ptr_factory_.GetWeakPtr()); |
| 1372 | |
danakj | 9359397 | 2019-10-11 00:02:49 | [diff] [blame] | 1373 | RenderWidget* opener_render_widget = |
Erik Chen | 6bc8da0 | 2019-09-20 15:51:38 | [diff] [blame] | 1374 | RenderFrameImpl::FromWebFrame(creator)->GetLocalRootRenderWidget(); |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1375 | |
Erik Chen | 3433ee0 | 2019-08-05 20:14:26 | [diff] [blame] | 1376 | RenderWidget* popup_widget = RenderWidget::CreateForPopup( |
danakj | 9359397 | 2019-10-11 00:02:49 | [diff] [blame] | 1377 | widget_routing_id, opener_render_widget->compositor_deps(), |
danakj | 4b8a2d9a | 2019-10-15 15:53:59 | [diff] [blame] | 1378 | blink::mojom::DisplayMode::kUndefined, |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1379 | /*hidden=*/false, |
danakj | 77eb7e8 | 2020-01-09 19:38:46 | [diff] [blame] | 1380 | /*never_composited=*/false, std::move(widget_channel_receiver)); |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1381 | |
| 1382 | // The returned WebPagePopup is self-referencing, so the pointer here is not |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 1383 | // an owning pointer. It is de-referenced by calling Close(). |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1384 | blink::WebPagePopup* popup_web_widget = |
Erik Chen | 3433ee0 | 2019-08-05 20:14:26 | [diff] [blame] | 1385 | blink::WebPagePopup::Create(popup_widget); |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1386 | |
| 1387 | // Adds a self-reference on the |popup_widget| so it will not be destroyed |
| 1388 | // when leaving scope. The WebPagePopup takes responsibility for Close()ing |
| 1389 | // and thus destroying the RenderWidget. |
danakj | 9359397 | 2019-10-11 00:02:49 | [diff] [blame] | 1390 | popup_widget->InitForPopup(std::move(opener_callback), opener_render_widget, |
| 1391 | popup_web_widget, |
| 1392 | opener_render_widget->GetOriginalScreenInfo()); |
danakj | 25ec6e2b | 2018-09-26 17:01:31 | [diff] [blame] | 1393 | return popup_web_widget; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1394 | } |
| 1395 | |
danakj | 295c43f18 | 2019-03-13 16:37:17 | [diff] [blame] | 1396 | void RenderViewImpl::DoDeferredClose() { |
| 1397 | // The main widget is currently not active. The active main frame widget is |
| 1398 | // in a different process. Have the browser route the close request to the |
| 1399 | // active widget instead, so that the correct unload handlers are run. |
| 1400 | Send(new ViewHostMsg_RouteCloseEvent(GetRoutingID())); |
| 1401 | } |
| 1402 | |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 1403 | void RenderViewImpl::CloseWindowSoon() { |
Avi Drissman | 07d2245 | 2019-03-25 17:56:39 | [diff] [blame] | 1404 | DCHECK(RenderThread::IsMainThread()); |
danakj | d330a8b | 2020-01-16 20:59:14 | [diff] [blame] | 1405 | if (!main_render_frame_) { |
danakj | 295c43f18 | 2019-03-13 16:37:17 | [diff] [blame] | 1406 | // Ask the RenderViewHost with a local main frame to initiate close. We |
| 1407 | // could be called from deep in Javascript. If we ask the RenderViewHost to |
| 1408 | // close now, the window could be closed before the JS finishes executing, |
danakj | bd1a86a | 2019-09-06 17:24:31 | [diff] [blame] | 1409 | // thanks to nested message loops running and handling the resulting Close |
danakj | 295c43f18 | 2019-03-13 16:37:17 | [diff] [blame] | 1410 | // IPC. So instead, post a message back to the message loop, which won't run |
| 1411 | // until the JS is complete, and then the Close request can be sent. |
| 1412 | GetCleanupTaskRunner()->PostTask( |
| 1413 | FROM_HERE, base::BindOnce(&RenderViewImpl::DoDeferredClose, |
| 1414 | weak_ptr_factory_.GetWeakPtr())); |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 1415 | return; |
| 1416 | } |
| 1417 | |
danakj | 50b3703 | 2020-01-15 22:44:00 | [diff] [blame] | 1418 | // If the main frame is in this RenderView's frame tree, then the Close |
danakj | d330a8b | 2020-01-16 20:59:14 | [diff] [blame] | 1419 | // request gets routed through the RenderWidget since non-frame RenderWidgets |
| 1420 | // share the code path. |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1421 | main_render_frame_->GetLocalRootRenderWidget()->CloseWidgetSoon(); |
danakj | 45e4a4f | 2019-03-12 22:50:42 | [diff] [blame] | 1422 | } |
| 1423 | |
Daniel Murphy | 31bbb8b1 | 2018-02-07 21:44:10 | [diff] [blame] | 1424 | base::StringPiece RenderViewImpl::GetSessionStorageNamespaceId() { |
| 1425 | CHECK(!session_storage_namespace_id_.empty()); |
Daniel Murphy | 0ce6e2c | 2017-11-21 01:54:26 | [diff] [blame] | 1426 | return session_storage_namespace_id_; |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1427 | } |
| 1428 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1429 | void RenderViewImpl::PrintPage(WebLocalFrame* frame) { |
Erik Chen | faa928c | 2019-09-20 23:41:15 | [diff] [blame] | 1430 | RenderFrameImpl* render_frame = RenderFrameImpl::FromWebFrame(frame); |
| 1431 | RenderWidget* render_widget = render_frame->GetLocalRootRenderWidget(); |
| 1432 | |
| 1433 | render_frame->ScriptedPrint( |
| 1434 | render_widget->input_handler().handling_input_event()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1435 | } |
| 1436 | |
danakj | cf409aa | 2019-09-20 15:22:30 | [diff] [blame] | 1437 | bool RenderViewImpl::SetZoomLevel(double zoom_level) { |
| 1438 | if (zoom_level == page_zoom_level_) |
| 1439 | return false; |
| 1440 | |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1441 | // If we change the zoom level for the view, make sure any subsequent subframe |
| 1442 | // loads reflect the current zoom level. |
| 1443 | page_zoom_level_ = zoom_level; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1444 | webview()->SetZoomLevel(zoom_level); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1445 | for (auto& observer : observers_) |
| 1446 | observer.OnZoomLevelChanged(); |
danakj | cf409aa | 2019-09-20 15:22:30 | [diff] [blame] | 1447 | return true; |
| 1448 | } |
| 1449 | |
| 1450 | void RenderViewImpl::SetPreferCompositingToLCDTextEnabled(bool prefer) { |
| 1451 | webview()->GetSettings()->SetPreferCompositingToLCDTextEnabled(prefer); |
| 1452 | } |
| 1453 | |
| 1454 | void RenderViewImpl::SetDeviceScaleFactor(bool use_zoom_for_dsf, |
| 1455 | float device_scale_factor) { |
| 1456 | if (use_zoom_for_dsf) |
| 1457 | webview()->SetZoomFactorForDeviceScaleFactor(device_scale_factor); |
| 1458 | else |
| 1459 | webview()->SetDeviceScaleFactor(device_scale_factor); |
| 1460 | } |
| 1461 | |
danakj | 748ef909 | 2019-10-17 23:40:53 | [diff] [blame] | 1462 | void RenderViewImpl::SetVisibleViewportSize( |
| 1463 | const gfx::Size& visible_viewport_size) { |
| 1464 | if (main_render_frame_) { |
| 1465 | // A local main frame controls the size of the WebView through |
| 1466 | // ResizeWebWidgetForWidget(). The VisualViewport is updated independently |
| 1467 | // here. |
| 1468 | webview()->ResizeVisualViewport(visible_viewport_size); |
| 1469 | } else { |
| 1470 | // RenderWidgets in a RenderView's frame tree without a local main frame |
| 1471 | // set the size of the WebView to be the |visible_viewport_size|, in order |
| 1472 | // to limit compositing in (out of process) child frames to what is visible. |
| 1473 | // |
| 1474 | // Note that child frames in the same process/RenderView frame tree as the |
| 1475 | // main frame do not benefit from this. |
| 1476 | webview()->Resize(visible_viewport_size); |
| 1477 | } |
| 1478 | } |
| 1479 | |
danakj | cf409aa | 2019-09-20 15:22:30 | [diff] [blame] | 1480 | void RenderViewImpl::PropagatePageZoomToNewlyAttachedFrame( |
| 1481 | bool use_zoom_for_dsf, |
| 1482 | float device_scale_factor) { |
| 1483 | if (use_zoom_for_dsf) |
| 1484 | webview()->SetZoomFactorForDeviceScaleFactor(device_scale_factor); |
| 1485 | else |
| 1486 | webview()->SetZoomLevel(page_zoom_level_); |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 1487 | } |
| 1488 | |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1489 | void RenderViewImpl::SetValidationMessageDirection( |
| 1490 | base::string16* wrapped_main_text, |
Miyoung Shin | 8dabef3 | 2020-02-19 16:25:25 | [diff] [blame^] | 1491 | base::i18n::TextDirection main_text_hint, |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1492 | base::string16* wrapped_sub_text, |
Miyoung Shin | 8dabef3 | 2020-02-19 16:25:25 | [diff] [blame^] | 1493 | base::i18n::TextDirection sub_text_hint) { |
| 1494 | if (main_text_hint == base::i18n::LEFT_TO_RIGHT) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1495 | *wrapped_main_text = |
| 1496 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text); |
Miyoung Shin | 8dabef3 | 2020-02-19 16:25:25 | [diff] [blame^] | 1497 | } else if (main_text_hint == base::i18n::RIGHT_TO_LEFT && |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1498 | !base::i18n::IsRTL()) { |
| 1499 | base::i18n::WrapStringWithRTLFormatting(wrapped_main_text); |
| 1500 | } |
| 1501 | |
| 1502 | if (!wrapped_sub_text->empty()) { |
Miyoung Shin | 8dabef3 | 2020-02-19 16:25:25 | [diff] [blame^] | 1503 | if (sub_text_hint == base::i18n::RIGHT_TO_LEFT) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1504 | *wrapped_sub_text = |
| 1505 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_sub_text); |
Miyoung Shin | 8dabef3 | 2020-02-19 16:25:25 | [diff] [blame^] | 1506 | } else if (sub_text_hint == base::i18n::LEFT_TO_RIGHT) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1507 | base::i18n::WrapStringWithRTLFormatting(wrapped_sub_text); |
| 1508 | } |
| 1509 | } |
| 1510 | } |
| 1511 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1512 | void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 1513 | const GURL& fallback_url) { |
[email protected] | aa6b90b3 | 2010-04-26 15:49:58 | [diff] [blame] | 1514 | GURL latest_url = url.is_empty() ? fallback_url : url; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1515 | if (latest_url == target_url_) |
| 1516 | return; |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1517 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1518 | // Tell the browser to display a destination link. |
| 1519 | if (target_url_status_ == TARGET_INFLIGHT || |
| 1520 | target_url_status_ == TARGET_PENDING) { |
| 1521 | // If we have a request in-flight, save the URL to be sent when we |
| 1522 | // receive an ACK to the in-flight request. We can happily overwrite |
| 1523 | // any existing pending sends. |
| 1524 | pending_target_url_ = latest_url; |
| 1525 | target_url_status_ = TARGET_PENDING; |
| 1526 | } else { |
mnaganov | bf08742 | 2015-12-16 05:10:03 | [diff] [blame] | 1527 | // URLs larger than |kMaxURLChars| cannot be sent through IPC - |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1528 | // see |ParamTraits<GURL>|. |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 1529 | if (latest_url.possibly_invalid_spec().size() > url::kMaxURLChars) |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1530 | latest_url = GURL(); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1531 | Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), latest_url)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1532 | target_url_ = latest_url; |
| 1533 | target_url_status_ = TARGET_INFLIGHT; |
| 1534 | } |
| 1535 | } |
| 1536 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1537 | void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { |
creis | ce0ef357 | 2017-01-26 17:53:08 | [diff] [blame] | 1538 | // Keep track of which frames have pending updates. |
| 1539 | frames_with_pending_state_.insert(frame->GetRoutingID()); |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1540 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1541 | int delay; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1542 | if (send_content_state_immediately_) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1543 | delay = 0; |
Collin Baker | 98457b5 | 2019-11-06 21:34:29 | [diff] [blame] | 1544 | else if (GetWebView()->GetVisibilityState() != PageVisibilityState::kVisible) |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1545 | delay = kDelaySecondsForContentStateSyncHidden; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1546 | else |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1547 | delay = kDelaySecondsForContentStateSync; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1548 | |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1549 | if (nav_state_sync_timer_.IsRunning()) { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1550 | // The timer is already running. If the delay of the timer maches the amount |
| 1551 | // we want to delay by, then return. Otherwise stop the timer so that it |
| 1552 | // gets started with the right delay. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1553 | if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1554 | return; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1555 | nav_state_sync_timer_.Stop(); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1556 | } |
| 1557 | |
creis | ce0ef357 | 2017-01-26 17:53:08 | [diff] [blame] | 1558 | // Tell each frame with pending state to inform the browser. |
danakj | 19f3e51 | 2018-12-14 21:02:05 | [diff] [blame] | 1559 | nav_state_sync_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(delay), |
| 1560 | this, &RenderViewImpl::SendFrameStateUpdates); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1561 | } |
| 1562 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1563 | void RenderViewImpl::SetMouseOverURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1564 | mouse_over_url_ = GURL(url); |
| 1565 | UpdateTargetURL(mouse_over_url_, focus_url_); |
| 1566 | } |
| 1567 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1568 | void RenderViewImpl::SetKeyboardFocusURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1569 | focus_url_ = GURL(url); |
| 1570 | UpdateTargetURL(focus_url_, mouse_over_url_); |
| 1571 | } |
| 1572 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1573 | bool RenderViewImpl::AcceptsLoadDrops() { |
[email protected] | 28b92df | 2009-09-25 17:35:45 | [diff] [blame] | 1574 | return renderer_preferences_.can_accept_load_drops; |
| 1575 | } |
| 1576 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1577 | void RenderViewImpl::FocusNext() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1578 | Send(new ViewHostMsg_TakeFocus(GetRoutingID(), false)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1579 | } |
| 1580 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1581 | void RenderViewImpl::FocusPrevious() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1582 | Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1583 | } |
| 1584 | |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1585 | void RenderViewImpl::FocusedElementChanged(const WebElement& from_element, |
| 1586 | const WebElement& to_element) { |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1587 | RenderFrameImpl* previous_frame = nullptr; |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1588 | if (!from_element.IsNull()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1589 | previous_frame = |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1590 | RenderFrameImpl::FromWebFrame(from_element.GetDocument().GetFrame()); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1591 | RenderFrameImpl* new_frame = nullptr; |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1592 | if (!to_element.IsNull()) |
| 1593 | new_frame = |
| 1594 | RenderFrameImpl::FromWebFrame(to_element.GetDocument().GetFrame()); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1595 | |
| 1596 | if (previous_frame && previous_frame != new_frame) |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1597 | previous_frame->FocusedElementChanged(WebElement()); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1598 | if (new_frame) |
Kent Tamura | 69d143e | 2019-05-22 00:31:45 | [diff] [blame] | 1599 | new_frame->FocusedElementChanged(to_element); |
[email protected] | 08e9e13 | 2010-06-01 16:58:49 | [diff] [blame] | 1600 | } |
| 1601 | |
Philip Rogers | 07965881 | 2018-08-01 23:19:09 | [diff] [blame] | 1602 | void RenderViewImpl::DidUpdateMainFrameLayout() { |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1603 | for (auto& observer : observers_) |
Philip Rogers | 07965881 | 2018-08-01 23:19:09 | [diff] [blame] | 1604 | observer.DidUpdateMainFrameLayout(); |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 1605 | |
Philip Rogers | 33cd2bcc | 2018-08-13 21:29:29 | [diff] [blame] | 1606 | // The main frame may have changed size. |
| 1607 | needs_preferred_size_update_ = true; |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 1608 | } |
| 1609 | |
Michael Martis | 2415478f | 2019-04-17 07:35:00 | [diff] [blame] | 1610 | void RenderViewImpl::RegisterRendererPreferenceWatcher( |
Julie Jeongeun Kim | 6d8b749 | 2019-08-20 19:24:11 | [diff] [blame] | 1611 | mojo::PendingRemote<blink::mojom::RendererPreferenceWatcher> watcher) { |
| 1612 | renderer_preference_watchers_.Add(std::move(watcher)); |
Makoto Shimazu | c3c730e | 2018-08-15 09:51:11 | [diff] [blame] | 1613 | } |
| 1614 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1615 | int RenderViewImpl::HistoryBackListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1616 | return history_list_offset_ < 0 ? 0 : history_list_offset_; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1617 | } |
| 1618 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1619 | int RenderViewImpl::HistoryForwardListCount() { |
| 1620 | return history_list_length_ - HistoryBackListCount() - 1; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1621 | } |
| 1622 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1623 | // blink::WebWidgetClient ---------------------------------------------------- |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1624 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1625 | bool RenderViewImpl::CanHandleGestureEvent() { |
slangley | 1a6375e6 | 2017-03-29 06:03:23 | [diff] [blame] | 1626 | return true; |
| 1627 | } |
| 1628 | |
Avi Drissman | 4a80048 | 2019-12-12 15:03:28 | [diff] [blame] | 1629 | // TODO(https://crbug.com/937569): Remove this in Chrome 88. |
Avi Drissman | fb96126 | 2019-03-05 22:50:29 | [diff] [blame] | 1630 | bool RenderViewImpl::AllowPopupsDuringPageUnload() { |
Avi Drissman | 16dfa1c | 2019-10-09 21:41:13 | [diff] [blame] | 1631 | // The switch version is for enabling via enterprise policy. The feature |
| 1632 | // version is for enabling via about:flags and Finch policy. |
Avi Drissman | fb96126 | 2019-03-05 22:50:29 | [diff] [blame] | 1633 | const base::CommandLine& command_line = |
| 1634 | *base::CommandLine::ForCurrentProcess(); |
Avi Drissman | 7e5079f | 2019-09-30 14:06:40 | [diff] [blame] | 1635 | return command_line.HasSwitch(switches::kAllowPopupsDuringPageUnload) || |
| 1636 | base::FeatureList::IsEnabled(features::kAllowPopupsDuringPageUnload); |
Avi Drissman | fb96126 | 2019-03-05 22:50:29 | [diff] [blame] | 1637 | } |
| 1638 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1639 | bool RenderViewImpl::CanUpdateLayout() { |
slangley | 1a6375e6 | 2017-03-29 06:03:23 | [diff] [blame] | 1640 | return true; |
| 1641 | } |
| 1642 | |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1643 | void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name, |
| 1644 | const std::string& value) { |
Erik Chen | f277280 | 2019-10-04 22:16:25 | [diff] [blame] | 1645 | // This is test-only code. Only propagate the command if there is a main |
| 1646 | // render frame. |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1647 | if (main_render_frame_) { |
| 1648 | RenderWidget* widget = main_render_frame_->GetLocalRootRenderWidget(); |
| 1649 | widget->SetEditCommandForNextKeyEvent(name, value); |
| 1650 | } |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1651 | } |
| 1652 | |
| 1653 | void RenderViewImpl::ClearEditCommands() { |
Erik Chen | f277280 | 2019-10-04 22:16:25 | [diff] [blame] | 1654 | // This is test-only code. Only propagate the command if there is a main |
| 1655 | // render frame. |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1656 | if (main_render_frame_) { |
| 1657 | RenderWidget* widget = main_render_frame_->GetLocalRootRenderWidget(); |
| 1658 | widget->ClearEditCommands(); |
| 1659 | } |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1660 | } |
| 1661 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1662 | const std::string& RenderViewImpl::GetAcceptLanguages() { |
[email protected] | b38806a | 2013-10-04 16:01:38 | [diff] [blame] | 1663 | return renderer_preferences_.accept_languages; |
| 1664 | } |
| 1665 | |
Philip Rogers | 601fd07 | 2018-08-07 22:58:22 | [diff] [blame] | 1666 | void RenderViewImpl::UpdatePreferredSize() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 1667 | // We don't always want to send the change messages over IPC, only if we've |
| 1668 | // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 1669 | // message. |
danakj | 3dcceba | 2019-10-09 22:16:23 | [diff] [blame] | 1670 | if (!send_preferred_size_changes_ || !webview() || !main_render_frame_) |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 1671 | return; |
Philip Rogers | 33cd2bcc | 2018-08-13 21:29:29 | [diff] [blame] | 1672 | |
| 1673 | if (!needs_preferred_size_update_) |
| 1674 | return; |
| 1675 | needs_preferred_size_update_ = false; |
| 1676 | |
danakj | 3dcceba | 2019-10-09 22:16:23 | [diff] [blame] | 1677 | blink::WebSize web_size = webview()->ContentsPreferredMinimumSize(); |
| 1678 | blink::WebRect web_rect(0, 0, web_size.width, web_size.height); |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1679 | main_render_frame_->GetLocalRootRenderWidget()->ConvertViewportToWindow( |
| 1680 | &web_rect); |
danakj | 3dcceba | 2019-10-09 22:16:23 | [diff] [blame] | 1681 | gfx::Size size(web_rect.width, web_rect.height); |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 1682 | |
danakj | 3dcceba | 2019-10-09 22:16:23 | [diff] [blame] | 1683 | if (size != preferred_size_) { |
| 1684 | preferred_size_ = size; |
| 1685 | Send(new ViewHostMsg_DidContentsPreferredSizeChange(GetRoutingID(), size)); |
| 1686 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1687 | } |
| 1688 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1689 | blink::WebString RenderViewImpl::AcceptLanguages() { |
| 1690 | return WebString::FromUTF8(renderer_preferences_.accept_languages); |
[email protected] | 9982c80 | 2013-06-12 15:22:06 | [diff] [blame] | 1691 | } |
| 1692 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1693 | // RenderView implementation --------------------------------------------------- |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1694 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1695 | bool RenderViewImpl::Send(IPC::Message* message) { |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 1696 | // No messages sent through RenderView come without a routing id, yay. Let's |
| 1697 | // keep that up. |
| 1698 | CHECK_NE(message->routing_id(), MSG_ROUTING_NONE); |
danakj | 3130f12 | 2019-07-16 17:49:47 | [diff] [blame] | 1699 | return RenderThread::Get()->Send(message); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1700 | } |
| 1701 | |
mostynb | c3335323 | 2014-09-12 09:38:31 | [diff] [blame] | 1702 | RenderFrameImpl* RenderViewImpl::GetMainRenderFrame() { |
nasko | 77de231 | 2015-05-12 03:09:16 | [diff] [blame] | 1703 | return main_render_frame_; |
[email protected] | b849847b | 2013-12-10 21:57:58 | [diff] [blame] | 1704 | } |
| 1705 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1706 | int RenderViewImpl::GetRoutingID() { |
Albert J. Wong | cb00463 | 2018-07-10 22:58:25 | [diff] [blame] | 1707 | return routing_id_; |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1708 | } |
| 1709 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1710 | float RenderViewImpl::GetZoomLevel() { |
Marc Treib | 06d6603 | 2017-10-19 08:43:20 | [diff] [blame] | 1711 | return page_zoom_level_; |
| 1712 | } |
| 1713 | |
thestig | 8a8fdfd3 | 2017-05-06 18:46:54 | [diff] [blame] | 1714 | const WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1715 | return webkit_preferences_; |
| 1716 | } |
| 1717 | |
[email protected] | 324825d | 2012-11-30 12:37:15 | [diff] [blame] | 1718 | void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { |
| 1719 | OnUpdateWebPreferences(preferences); |
| 1720 | } |
| 1721 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1722 | blink::WebView* RenderViewImpl::GetWebView() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1723 | return webview(); |
| 1724 | } |
| 1725 | |
Lucas Furukawa Gadani | d51ff5d6 | 2018-12-07 21:26:49 | [diff] [blame] | 1726 | bool RenderViewImpl::GetContentStateImmediately() { |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1727 | return send_content_state_immediately_; |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1728 | } |
| 1729 | |
Collin Baker | 98457b5 | 2019-11-06 21:34:29 | [diff] [blame] | 1730 | void RenderViewImpl::ApplyPageVisibilityState( |
| 1731 | PageVisibilityState visibility_state, |
| 1732 | bool initial_setting) { |
| 1733 | webview()->SetVisibilityState(visibility_state, initial_setting); |
Collin Baker | c525996 | 2019-11-14 17:51:58 | [diff] [blame] | 1734 | for (auto& observer : observers_) |
| 1735 | observer.OnPageVisibilityChanged(visibility_state); |
danakj | 7874491 | 2018-11-30 23:46:42 | [diff] [blame] | 1736 | // Note: RenderWidget visibility is separately set from the IPC handlers, and |
| 1737 | // does not change when tests override the visibility of the Page. |
danakj | 1b35e9d | 2018-11-07 19:09:28 | [diff] [blame] | 1738 | } |
| 1739 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1740 | void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 1741 | webkit_preferences_ = prefs; |
danakj | fd0c7f4 | 2018-10-12 18:01:08 | [diff] [blame] | 1742 | ApplyWebPreferences(webkit_preferences_, webview()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1743 | } |
| 1744 | |
[email protected] | 2bf834f | 2011-11-17 20:02:21 | [diff] [blame] | 1745 | void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 1746 | if (send_preferred_size_changes_) |
| 1747 | return; |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 1748 | send_preferred_size_changes_ = true; |
[email protected] | 770dd8b | 2010-05-24 18:11:39 | [diff] [blame] | 1749 | |
Philip Rogers | 601fd07 | 2018-08-07 22:58:22 | [diff] [blame] | 1750 | if (!webview()) |
| 1751 | return; |
| 1752 | |
Philip Rogers | 33cd2bcc | 2018-08-13 21:29:29 | [diff] [blame] | 1753 | needs_preferred_size_update_ = true; |
| 1754 | |
Philip Rogers | 601fd07 | 2018-08-07 22:58:22 | [diff] [blame] | 1755 | // We need to ensure |UpdatePreferredSize| gets called. If a layout is needed, |
| 1756 | // force an update here which will call |DidUpdateMainFrameLayout|. |
Erik Chen | ab7ed49 | 2019-08-28 01:34:49 | [diff] [blame] | 1757 | if (webview()->MainFrameWidget()) { |
| 1758 | webview()->MainFrameWidget()->UpdateLifecycle( |
| 1759 | WebWidget::LifecycleUpdate::kLayout, |
Stephen Chenney | d4b0f8a1 | 2020-01-31 22:55:45 | [diff] [blame] | 1760 | blink::DocumentUpdateReason::kSizeChange); |
Erik Chen | ab7ed49 | 2019-08-28 01:34:49 | [diff] [blame] | 1761 | } |
Philip Rogers | 601fd07 | 2018-08-07 22:58:22 | [diff] [blame] | 1762 | |
| 1763 | // If a layout was not needed, |DidUpdateMainFrameLayout| will not be called. |
| 1764 | // We explicitly update the preferred size here to ensure the preferred size |
| 1765 | // notification is sent. |
| 1766 | UpdatePreferredSize(); |
[email protected] | 0666aef | 2009-05-13 19:48:08 | [diff] [blame] | 1767 | } |
| 1768 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1769 | void RenderViewImpl::OnSetRendererPrefs( |
Leon Han | c819dc6 | 2019-01-28 04:30:19 | [diff] [blame] | 1770 | const blink::mojom::RendererPreferences& renderer_prefs) { |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 1771 | std::string old_accept_languages = renderer_preferences_.accept_languages; |
| 1772 | |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1773 | renderer_preferences_ = renderer_prefs; |
ananta | 59b9fe7 | 2015-04-07 01:33:26 | [diff] [blame] | 1774 | |
Julie Jeongeun Kim | 6d8b749 | 2019-08-20 19:24:11 | [diff] [blame] | 1775 | for (auto& watcher : renderer_preference_watchers_) |
| 1776 | watcher->NotifyUpdate(renderer_prefs.Clone()); |
Makoto Shimazu | c3c730e | 2018-08-15 09:51:11 | [diff] [blame] | 1777 | |
[email protected] | 6e282c9 | 2009-07-24 01:19:37 | [diff] [blame] | 1778 | UpdateFontRenderingFromRendererPrefs(); |
scottmg | b92365e | 2016-08-30 20:54:40 | [diff] [blame] | 1779 | UpdateThemePrefs(); |
Leon Han | 2c81b5d | 2019-01-25 01:58:33 | [diff] [blame] | 1780 | blink::SetCaretBlinkInterval( |
| 1781 | renderer_prefs.caret_blink_interval.has_value() |
| 1782 | ? renderer_prefs.caret_blink_interval.value() |
| 1783 | : base::TimeDelta::FromMilliseconds( |
Leon Han | c819dc6 | 2019-01-28 04:30:19 | [diff] [blame] | 1784 | blink::mojom::kDefaultCaretBlinkIntervalInMilliseconds)); |
[email protected] | 38a8571 | 2013-01-02 22:45:02 | [diff] [blame] | 1785 | |
Christopher Cameron | f8e279d3 | 2019-05-15 18:50:56 | [diff] [blame] | 1786 | #if defined(USE_AURA) |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 1787 | if (renderer_prefs.use_custom_colors) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1788 | blink::SetFocusRingColor(renderer_prefs.focus_ring_color); |
Christopher Cameron | f6fc7ec | 2019-05-13 18:52:53 | [diff] [blame] | 1789 | blink::SetSelectionColors(renderer_prefs.active_selection_bg_color, |
| 1790 | renderer_prefs.active_selection_fg_color, |
| 1791 | renderer_prefs.inactive_selection_bg_color, |
| 1792 | renderer_prefs.inactive_selection_fg_color); |
Erik Chen | ab7ed49 | 2019-08-28 01:34:49 | [diff] [blame] | 1793 | if (webview() && webview()->MainFrameWidget()) |
danakj | 763c240 | 2018-11-09 02:46:22 | [diff] [blame] | 1794 | webview()->MainFrameWidget()->ThemeChanged(); |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 1795 | } |
Christopher Cameron | f8e279d3 | 2019-05-15 18:50:56 | [diff] [blame] | 1796 | #endif |
[email protected] | d299d97 | 2012-03-23 02:26:55 | [diff] [blame] | 1797 | |
Ionel Popescu | 2649f2f | 2020-01-10 10:06:59 | [diff] [blame] | 1798 | if (features::IsFormControlsRefreshEnabled() && |
| 1799 | renderer_prefs.use_custom_colors) { |
| 1800 | blink::SetFocusRingColor(renderer_prefs.focus_ring_color); |
| 1801 | } |
| 1802 | |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 1803 | if (webview() && |
| 1804 | old_accept_languages != renderer_preferences_.accept_languages) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1805 | webview()->AcceptLanguagesChanged(); |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 1806 | } |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1807 | } |
| 1808 | |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1809 | void RenderViewImpl::OnPluginActionAt(const gfx::Point& location, |
Sergio Villar Senin | eb8c25245 | 2019-10-04 17:18:28 | [diff] [blame] | 1810 | const PluginAction& action) { |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1811 | if (webview()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1812 | webview()->PerformPluginAction(action, location); |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1813 | } |
| 1814 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1815 | void RenderViewImpl::OnMoveOrResizeStarted() { |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 1816 | if (webview()) |
danakj | a5c39d5 | 2018-12-13 22:20:56 | [diff] [blame] | 1817 | webview()->CancelPagePopup(); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 1818 | } |
| 1819 | |
Collin Baker | 98457b5 | 2019-11-06 21:34:29 | [diff] [blame] | 1820 | void RenderViewImpl::OnPageVisibilityChanged( |
| 1821 | PageVisibilityState visibility_state) { |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 1822 | #if defined(OS_ANDROID) |
Collin Baker | 98457b5 | 2019-11-06 21:34:29 | [diff] [blame] | 1823 | SuspendVideoCaptureDevices(visibility_state != PageVisibilityState::kVisible); |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 1824 | #endif |
[email protected] | 2d7b82c | 2012-06-01 05:57:50 | [diff] [blame] | 1825 | |
Collin Baker | 98457b5 | 2019-11-06 21:34:29 | [diff] [blame] | 1826 | ApplyPageVisibilityState(visibility_state, |
| 1827 | /*initial_setting=*/false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 1828 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 1829 | |
Francois Doray | 47f759d | 2018-06-11 18:13:51 | [diff] [blame] | 1830 | void RenderViewImpl::SetPageFrozen(bool frozen) { |
| 1831 | if (webview()) |
| 1832 | webview()->SetPageFrozen(frozen); |
Fadi Meawad | a6573e0 | 2018-03-10 00:52:11 | [diff] [blame] | 1833 | } |
| 1834 | |
Yuzu Saijo | dfba8fa6 | 2019-08-27 02:15:22 | [diff] [blame] | 1835 | void RenderViewImpl::PutPageIntoBackForwardCache() { |
| 1836 | if (webview()) |
| 1837 | webview()->PutPageIntoBackForwardCache(); |
| 1838 | } |
| 1839 | |
Fergal Daly | 87f79d6 | 2019-11-11 01:24:04 | [diff] [blame] | 1840 | void RenderViewImpl::RestorePageFromBackForwardCache( |
| 1841 | base::TimeTicks navigation_start) { |
Yuzu Saijo | dfba8fa6 | 2019-08-27 02:15:22 | [diff] [blame] | 1842 | if (webview()) |
Fergal Daly | 87f79d6 | 2019-11-11 01:24:04 | [diff] [blame] | 1843 | webview()->RestorePageFromBackForwardCache(navigation_start); |
Yuzu Saijo | dfba8fa6 | 2019-08-27 02:15:22 | [diff] [blame] | 1844 | } |
| 1845 | |
W. James MacLean | 6219867 | 2019-06-04 16:46:10 | [diff] [blame] | 1846 | // This function receives TextAutosizerPageInfo from the main frame's renderer |
| 1847 | // and makes it available to other renderers with frames on the same page. |
| 1848 | void RenderViewImpl::OnTextAutosizerPageInfoChanged( |
| 1849 | const blink::WebTextAutosizerPageInfo& page_info) { |
| 1850 | // Only propagate the remote page info if our main frame is remote. It's |
| 1851 | // possible a main frame renderer may receive this message, as SendPageMessage |
| 1852 | // in RenderFrameHostManager may send to a speculative RenderFrameHost that |
| 1853 | // corresponds to a local main frame. Since a local main frame will generate |
| 1854 | // these values for itself, we shouldn't override them with values from |
| 1855 | // another renderer. |
| 1856 | if (!webview()->MainFrame()->IsWebLocalFrame()) |
| 1857 | webview()->SetTextAutosizePageInfo(page_info); |
| 1858 | } |
| 1859 | |
Adithya Srinivasan | 11af2c5 | 2019-12-16 22:52:55 | [diff] [blame] | 1860 | void RenderViewImpl::OnSetInsidePortal(bool inside_portal) { |
| 1861 | webview()->SetInsidePortal(inside_portal); |
| 1862 | } |
| 1863 | |
W. James MacLean | 6219867 | 2019-06-04 16:46:10 | [diff] [blame] | 1864 | void RenderViewImpl::DidUpdateTextAutosizerPageInfo( |
| 1865 | const blink::WebTextAutosizerPageInfo& page_info) { |
| 1866 | DCHECK(webview()->MainFrame()->IsWebLocalFrame()); |
| 1867 | Send(new ViewHostMsg_NotifyTextAutosizerPageInfoChangedInLocalMainFrame( |
| 1868 | GetRoutingID(), page_info)); |
| 1869 | } |
| 1870 | |
danakj | 9a8a9cf | 2018-07-17 23:52:12 | [diff] [blame] | 1871 | void RenderViewImpl::DidAutoResize(const blink::WebSize& newSize) { |
Erik Chen | e4ae6b4 | 2019-10-01 12:06:28 | [diff] [blame] | 1872 | // Auto resize should only happen on local main frames. |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1873 | DCHECK(main_render_frame_); |
| 1874 | main_render_frame_->GetLocalRootRenderWidget()->DidAutoResize(newSize); |
danakj | 9a8a9cf | 2018-07-17 23:52:12 | [diff] [blame] | 1875 | } |
| 1876 | |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1877 | void RenderViewImpl::DidFocus(blink::WebLocalFrame* calling_frame) { |
| 1878 | // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 1879 | // we won't have to test for user gesture anymore and we can |
| 1880 | // move that code back to render_widget.cc |
Mustaq Ahmed | 4baa9a6e8 | 2019-12-20 23:43:46 | [diff] [blame] | 1881 | if (calling_frame && calling_frame->HasTransientUserActivation() && |
Kent Tamura | 2eab5b1 | 2018-12-07 04:31:23 | [diff] [blame] | 1882 | !RenderThreadImpl::current()->web_test_mode()) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1883 | Send(new ViewHostMsg_Focus(GetRoutingID())); |
| 1884 | |
| 1885 | // Tattle on the frame that called |window.focus()|. |
| 1886 | RenderFrameImpl* calling_render_frame = |
| 1887 | RenderFrameImpl::FromWebFrame(calling_frame); |
| 1888 | if (calling_render_frame) |
| 1889 | calling_render_frame->FrameDidCallFocus(); |
| 1890 | } |
| 1891 | } |
| 1892 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 1893 | #if defined(OS_ANDROID) |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 1894 | void RenderViewImpl::SuspendVideoCaptureDevices(bool suspend) { |
| 1895 | if (!main_render_frame_) |
| 1896 | return; |
| 1897 | |
Guido Urdaneta | dc709037 | 2019-07-29 17:59:54 | [diff] [blame] | 1898 | blink::WebMediaStreamDeviceObserver* media_stream_device_observer = |
Antonio Gomes | 32f24faf | 2019-08-18 16:41:36 | [diff] [blame] | 1899 | main_render_frame_->MediaStreamDeviceObserver(); |
Chandan Padhi | 26dbd9b3 | 2017-11-27 11:13:35 | [diff] [blame] | 1900 | if (!media_stream_device_observer) |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 1901 | return; |
| 1902 | |
Guido Urdaneta | 73fa663 | 2019-01-14 18:46:26 | [diff] [blame] | 1903 | blink::MediaStreamDevices video_devices = |
Chandan Padhi | 26dbd9b3 | 2017-11-27 11:13:35 | [diff] [blame] | 1904 | media_stream_device_observer->GetNonScreenCaptureDevices(); |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 1905 | RenderThreadImpl::current()->video_capture_impl_manager()->SuspendDevices( |
Chandan Padhi | 6dbfb73 | 2017-09-01 16:08:49 | [diff] [blame] | 1906 | video_devices, suspend); |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 1907 | } |
estade | 6b9696bd | 2016-05-04 23:51:36 | [diff] [blame] | 1908 | #endif // defined(OS_ANDROID) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 1909 | |
[email protected] | b283d29 | 2013-02-21 08:40:34 | [diff] [blame] | 1910 | unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| 1911 | return history_list_length_; |
| 1912 | } |
| 1913 | |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 1914 | void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { |
Nasko Oskov | a463a05 | 2018-05-08 16:42:14 | [diff] [blame] | 1915 | // If the main frame is remote, return immediately. Page level focus |
| 1916 | // should be set from the browser process, so if needed by tests it should |
| 1917 | // be properly supported. |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1918 | if (!main_render_frame_) |
Nasko Oskov | a463a05 | 2018-05-08 16:42:14 | [diff] [blame] | 1919 | return; |
| 1920 | |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1921 | RenderWidget* render_widget = main_render_frame_->GetLocalRootRenderWidget(); |
| 1922 | |
| 1923 | if (enable == render_widget->has_focus()) |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1924 | return; |
| 1925 | |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 1926 | if (enable) { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1927 | SetActiveForWidget(true); |
| 1928 | // Fake an IPC message so go through the IPC handler. |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1929 | render_widget->OnSetFocus(true); |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 1930 | } else { |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1931 | // Fake an IPC message so go through the IPC handler. |
danakj | ee8f490 | 2020-01-17 18:06:10 | [diff] [blame] | 1932 | render_widget->OnSetFocus(false); |
danakj | a2c9d0a9 | 2018-07-25 20:01:18 | [diff] [blame] | 1933 | SetActiveForWidget(false); |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 1934 | } |
| 1935 | } |
| 1936 | |
W. James MacLean | d973a55b | 2018-11-29 21:39:13 | [diff] [blame] | 1937 | void RenderViewImpl::OnAnimateDoubleTapZoomInMainFrame( |
Dave Tapuska | ff7b061 | 2020-01-21 19:51:25 | [diff] [blame] | 1938 | const gfx::Point& point, |
W. James MacLean | d973a55b | 2018-11-29 21:39:13 | [diff] [blame] | 1939 | const blink::WebRect& bound) { |
| 1940 | webview()->AnimateDoubleTapZoom(point, bound); |
| 1941 | } |
| 1942 | |
W. James MacLean | 5372eb7 | 2018-12-19 12:56:36 | [diff] [blame] | 1943 | void RenderViewImpl::OnZoomToFindInPageRect( |
| 1944 | const blink::WebRect& rect_to_zoom) { |
| 1945 | webview()->ZoomToFindInPageRect(rect_to_zoom); |
| 1946 | } |
| 1947 | |
danakj | d51fd53d | 2018-12-21 23:06:09 | [diff] [blame] | 1948 | void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
| 1949 | if (!webview()) |
| 1950 | return; |
| 1951 | |
| 1952 | if (opaque) { |
| 1953 | webview()->ClearBaseBackgroundColorOverride(); |
| 1954 | webview()->ClearBackgroundColorOverride(); |
| 1955 | } else { |
| 1956 | webview()->SetBaseBackgroundColorOverride(SK_ColorTRANSPARENT); |
| 1957 | webview()->SetBackgroundColorOverride(SK_ColorTRANSPARENT); |
| 1958 | } |
| 1959 | } |
| 1960 | |
danakj | 295c43f18 | 2019-03-13 16:37:17 | [diff] [blame] | 1961 | // static |
| 1962 | scoped_refptr<base::SingleThreadTaskRunner> |
| 1963 | RenderViewImpl::GetCleanupTaskRunner() { |
| 1964 | return RenderThreadImpl::current_blink_platform_impl() |
| 1965 | ->main_thread_scheduler() |
| 1966 | ->CleanupTaskRunner(); |
| 1967 | } |
| 1968 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1969 | } // namespace content |