[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> |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 10 | |
[email protected] | 5d4e36d | 2013-02-15 15:18:20 | [diff] [blame] | 11 | #include "base/auto_reset.h" |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 12 | #include "base/bind.h" |
| 13 | #include "base/bind_helpers.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 14 | #include "base/command_line.h" |
[email protected] | bb063b7 | 2009-03-27 23:18:50 | [diff] [blame] | 15 | #include "base/compiler_specific.h" |
[email protected] | 2132d6b | 2013-06-05 00:15:43 | [diff] [blame] | 16 | #include "base/debug/alias.h" |
avayvod | 23275794 | 2017-04-29 04:12:34 | [diff] [blame] | 17 | #include "base/feature_list.h" |
[email protected] | 728c2ee | 2013-06-25 04:01:07 | [diff] [blame] | 18 | #include "base/files/file_path.h" |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 19 | #include "base/i18n/rtl.h" |
[email protected] | b1cf337 | 2011-04-20 21:28:10 | [diff] [blame] | 20 | #include "base/json/json_writer.h" |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 21 | #include "base/lazy_instance.h" |
fdoray | 7a8954a4 | 2016-06-07 04:28:38 | [diff] [blame] | 22 | #include "base/location.h" |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 23 | #include "base/memory/ptr_util.h" |
[email protected] | f29efe6b | 2014-06-09 05:01:51 | [diff] [blame] | 24 | #include "base/metrics/field_trial.h" |
asvitkine | 8d51e9d | 2016-09-02 23:55:43 | [diff] [blame] | 25 | #include "base/metrics/histogram_macros.h" |
[email protected] | d3b4ee2 | 2013-07-24 22:50:06 | [diff] [blame] | 26 | #include "base/process/kill.h" |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 27 | #include "base/process/process.h" |
fdoray | 7a8954a4 | 2016-06-07 04:28:38 | [diff] [blame] | 28 | #include "base/single_thread_task_runner.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" |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 35 | #include "base/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" |
[email protected] | a8cb3b73b | 2013-08-12 05:50:50 | [diff] [blame] | 42 | #include "content/child/appcache/appcache_dispatcher.h" |
| 43 | #include "content/child/appcache/web_application_cache_host_impl.h" |
[email protected] | 541b7b0 | 2013-06-07 00:59:34 | [diff] [blame] | 44 | #include "content/child/request_extra_data.h" |
mek | 87e0ab5 | 2015-02-13 01:18:26 | [diff] [blame] | 45 | #include "content/child/v8_value_converter_impl.h" |
[email protected] | 10208ea | 2013-06-06 20:08:03 | [diff] [blame] | 46 | #include "content/child/webmessageportchannel_impl.h" |
jinho.bang | 632a1a72 | 2014-09-18 03:02:56 | [diff] [blame] | 47 | #include "content/common/content_constants_internal.h" |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 48 | #include "content/common/content_switches_internal.h" |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 49 | #include "content/common/dom_storage/dom_storage_types.h" |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 50 | #include "content/common/drag_messages.h" |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 51 | #include "content/common/frame_messages.h" |
alexmos | bc7eafa | 2014-12-06 01:38:09 | [diff] [blame] | 52 | #include "content/common/frame_replication_state.h" |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 53 | #include "content/common/input_messages.h" |
lfg | db5c4ed | 2016-03-04 23:09:07 | [diff] [blame] | 54 | #include "content/common/page_messages.h" |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 55 | #include "content/common/render_message_filter.mojom.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 56 | #include "content/common/view_messages.h" |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 57 | #include "content/public/common/associated_interface_provider.h" |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 58 | #include "content/public/common/bindings_policy.h" |
arthursonzogni | c517fc3 | 2016-08-11 11:04:24 | [diff] [blame] | 59 | #include "content/public/common/browser_side_navigation_policy.h" |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 60 | #include "content/public/common/content_client.h" |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 61 | #include "content/public/common/content_constants.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 62 | #include "content/public/common/content_switches.h" |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 63 | #include "content/public/common/favicon_url.h" |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 64 | #include "content/public/common/page_importance_signals.h" |
clamy | da97e832 | 2014-10-07 21:57:25 | [diff] [blame] | 65 | #include "content/public/common/page_state.h" |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 66 | #include "content/public/common/page_zoom.h" |
[email protected] | 818915cd | 2012-11-20 13:14:11 | [diff] [blame] | 67 | #include "content/public/common/three_d_api_types.h" |
[email protected] | a1d2916 | 2011-10-14 17:14:03 | [diff] [blame] | 68 | #include "content/public/common/url_constants.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 69 | #include "content/public/common/web_preferences.h" |
[email protected] | d344114c | 2011-10-01 01:24:34 | [diff] [blame] | 70 | #include "content/public/renderer/content_renderer_client.h" |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 71 | #include "content/public/renderer/document_state.h" |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 72 | #include "content/public/renderer/navigation_state.h" |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 73 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 74 | #include "content/public/renderer/render_view_visitor.h" |
scottmg | 8e6c608 | 2017-02-13 23:15:48 | [diff] [blame] | 75 | #include "content/public/renderer/window_features_converter.h" |
[email protected] | e6e5675 | 2012-08-10 00:46:06 | [diff] [blame] | 76 | #include "content/renderer/browser_plugin/browser_plugin.h" |
| 77 | #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
[email protected] | 1910fe8 | 2012-05-10 00:04:10 | [diff] [blame] | 78 | #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 79 | #include "content/renderer/drop_data_builder.h" |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 80 | #include "content/renderer/gpu/render_widget_compositor.h" |
[email protected] | dc06435 | 2014-04-25 08:36:38 | [diff] [blame] | 81 | #include "content/renderer/history_serialization.h" |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 82 | #include "content/renderer/idle_user_detector.h" |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 83 | #include "content/renderer/ime_event_guard.h" |
[email protected] | 7a72d45 | 2013-12-13 10:01:13 | [diff] [blame] | 84 | #include "content/renderer/input/input_handler_manager.h" |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 85 | #include "content/renderer/internal_document_state_data.h" |
[email protected] | 4a91488 | 2013-01-10 00:43:48 | [diff] [blame] | 86 | #include "content/renderer/media/audio_device_factory.h" |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 87 | #include "content/renderer/media/media_stream_dispatcher.h" |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 88 | #include "content/renderer/media/video_capture_impl_manager.h" |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 89 | #include "content/renderer/navigation_state_impl.h" |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 90 | #include "content/renderer/render_frame_impl.h" |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 91 | #include "content/renderer/render_frame_proxy.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 92 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 93 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 94 | #include "content/renderer/render_widget_fullscreen_pepper.h" |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 95 | #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 96 | #include "content/renderer/resizing_mode_selector.h" |
[email protected] | 12a936d | 2013-05-15 04:55:49 | [diff] [blame] | 97 | #include "content/renderer/savable_resources.h" |
nhiroki | 2820b8b | 2017-01-10 08:13:30 | [diff] [blame] | 98 | #include "content/renderer/shared_worker/websharedworker_proxy.h" |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 99 | #include "content/renderer/speech_recognition_dispatcher.h" |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 100 | #include "content/renderer/web_ui_extension_data.h" |
[email protected] | f596114 | 2013-04-17 23:09:42 | [diff] [blame] | 101 | #include "media/audio/audio_output_device.h" |
[email protected] | ee68378a | 2010-08-10 01:05:41 | [diff] [blame] | 102 | #include "media/base/media_switches.h" |
Brett Wilson | 0748bf41 | 2016-11-22 17:55:46 | [diff] [blame] | 103 | #include "media/media_features.h" |
servolk | f54f5c8f | 2015-02-24 20:32:39 | [diff] [blame] | 104 | #include "media/renderers/audio_renderer_impl.h" |
servolk | 8b3b39b | 2015-03-03 19:08:18 | [diff] [blame] | 105 | #include "media/renderers/gpu_video_accelerator_factories.h" |
[email protected] | d1ef81d | 2012-07-24 11:39:36 | [diff] [blame] | 106 | #include "net/base/data_url.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 107 | #include "net/base/escape.h" |
| 108 | #include "net/base/net_errors.h" |
[email protected] | 18fb7a77 | 2012-09-20 19:25:09 | [diff] [blame] | 109 | #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 110 | #include "net/http/http_util.h" |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 111 | #include "ppapi/features/features.h" |
xlai | 11ac780 | 2017-04-07 20:13:18 | [diff] [blame] | 112 | #include "services/ui/public/cpp/bitmap/child_shared_bitmap_manager.h" |
luken | b171b53 | 2014-09-24 05:50:38 | [diff] [blame] | 113 | #include "skia/ext/platform_canvas.h" |
kinuko | b473f00 | 2016-02-22 05:23:19 | [diff] [blame] | 114 | #include "third_party/WebKit/public/platform/FilePathConversion.h" |
brettw | dfbcc3b | 2016-01-20 01:49:17 | [diff] [blame] | 115 | #include "third_party/WebKit/public/platform/URLConversion.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 116 | #include "third_party/WebKit/public/platform/WebConnectionType.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 117 | #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
| 118 | #include "third_party/WebKit/public/platform/WebImage.h" |
dtapuska | 836e1f9 | 2016-11-15 00:38:06 | [diff] [blame] | 119 | #include "third_party/WebKit/public/platform/WebInputEvent.h" |
skyostil | cff6288 | 2017-01-28 13:18:04 | [diff] [blame] | 120 | #include "third_party/WebKit/public/platform/WebInputEventResult.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 121 | #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 122 | #include "third_party/WebKit/public/platform/WebPoint.h" |
| 123 | #include "third_party/WebKit/public/platform/WebRect.h" |
nverne | 61d2da87 | 2017-05-24 10:15:30 | [diff] [blame] | 124 | #include "third_party/WebKit/public/platform/WebRuntimeFeatures.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 125 | #include "third_party/WebKit/public/platform/WebSize.h" |
[email protected] | ec173b52 | 2013-11-14 11:01:18 | [diff] [blame] | 126 | #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 127 | #include "third_party/WebKit/public/platform/WebString.h" |
| 128 | #include "third_party/WebKit/public/platform/WebURL.h" |
| 129 | #include "third_party/WebKit/public/platform/WebURLError.h" |
| 130 | #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 131 | #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 132 | #include "third_party/WebKit/public/platform/WebVector.h" |
brettw | 8a274fa | 2016-11-15 00:20:40 | [diff] [blame] | 133 | #include "third_party/WebKit/public/public_features.h" |
[email protected] | 10760e4a | 2013-09-04 23:32:20 | [diff] [blame] | 134 | #include "third_party/WebKit/public/web/WebAXObject.h" |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 135 | #include "third_party/WebKit/public/web/WebAutofillClient.h" |
[email protected] | 8bc5ff0 | 2013-11-29 06:34:03 | [diff] [blame] | 136 | #include "third_party/WebKit/public/web/WebColorSuggestion.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 137 | #include "third_party/WebKit/public/web/WebDOMEvent.h" |
| 138 | #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" |
| 139 | #include "third_party/WebKit/public/web/WebDataSource.h" |
| 140 | #include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h" |
| 141 | #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 142 | #include "third_party/WebKit/public/web/WebDocument.h" |
| 143 | #include "third_party/WebKit/public/web/WebElement.h" |
| 144 | #include "third_party/WebKit/public/web/WebFileChooserParams.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 145 | #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 146 | #include "third_party/WebKit/public/web/WebFormElement.h" |
| 147 | #include "third_party/WebKit/public/web/WebFrame.h" |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 148 | #include "third_party/WebKit/public/web/WebFrameContentDumper.h" |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 149 | #include "third_party/WebKit/public/web/WebFrameWidget.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 150 | #include "third_party/WebKit/public/web/WebHistoryItem.h" |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 151 | #include "third_party/WebKit/public/web/WebHitTestResult.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 152 | #include "third_party/WebKit/public/web/WebInputElement.h" |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 153 | #include "third_party/WebKit/public/web/WebLocalFrame.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 154 | #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |
| 155 | #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 156 | #include "third_party/WebKit/public/web/WebPageImportanceSignals.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 157 | #include "third_party/WebKit/public/web/WebPlugin.h" |
| 158 | #include "third_party/WebKit/public/web/WebPluginAction.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 159 | #include "third_party/WebKit/public/web/WebRange.h" |
ellyjones | 8ae1769 | 2016-08-05 15:19:21 | [diff] [blame] | 160 | #include "third_party/WebKit/public/web/WebRenderTheme.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 161 | #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 162 | #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 163 | #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 164 | #include "third_party/WebKit/public/web/WebSettings.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 165 | #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 166 | #include "third_party/WebKit/public/web/WebView.h" |
| 167 | #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 168 | #include "third_party/icu/source/common/unicode/uchar.h" |
| 169 | #include "third_party/icu/source/common/unicode/uscript.h" |
eseckler | f2bd55f7 | 2017-03-31 09:11:57 | [diff] [blame] | 170 | #include "third_party/skia/include/core/SkColor.h" |
[email protected] | 1400e6dc | 2013-04-27 02:36:27 | [diff] [blame] | 171 | #include "ui/base/ui_base_switches_util.h" |
tfarina | 655f81d | 2014-12-23 02:38:50 | [diff] [blame] | 172 | #include "ui/gfx/geometry/point.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 173 | #include "ui/gfx/geometry/rect.h" |
| 174 | #include "ui/gfx/geometry/rect_conversions.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 175 | #include "ui/gfx/geometry/size_conversions.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 176 | #include "ui/gfx/native_widget_types.h" |
mfomitchev | 3ba450ad | 2017-04-03 18:20:40 | [diff] [blame] | 177 | #include "ui/latency/latency_info.h" |
csharrison | d88f975 | 2016-10-26 23:56:36 | [diff] [blame] | 178 | #include "url/origin.h" |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 179 | #include "url/url_constants.h" |
[email protected] | c4a9e93 | 2011-03-05 04:05:55 | [diff] [blame] | 180 | #include "v8/include/v8.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 181 | |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 182 | #if defined(OS_ANDROID) |
[email protected] | befe5478 | 2013-04-23 00:49:25 | [diff] [blame] | 183 | #include <cpu-features.h> |
| 184 | |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 185 | #include "base/android/build_info.h" |
estade | 6b9696bd | 2016-05-04 23:51:36 | [diff] [blame] | 186 | #include "content/renderer/android/disambiguation_popup_helper.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 187 | #include "ui/gfx/geometry/rect_f.h" |
[email protected] | e69bb06 | 2013-06-03 13:05:40 | [diff] [blame] | 188 | |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 189 | #elif defined(OS_MACOSX) |
| 190 | #include "skia/ext/skia_utils_mac.h" |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 191 | #endif |
| 192 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 193 | #if BUILDFLAG(ENABLE_PLUGINS) |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 194 | #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 195 | #include "content/renderer/pepper/pepper_plugin_registry.h" |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 196 | #endif |
| 197 | |
Brett Wilson | 0748bf41 | 2016-11-22 17:55:46 | [diff] [blame] | 198 | #if BUILDFLAG(ENABLE_WEBRTC) |
[email protected] | 9ac667e | 2013-09-09 12:49:21 | [diff] [blame] | 199 | #include "content/renderer/media/rtc_peer_connection_handler.h" |
[email protected] | 22fe91d | 2014-08-12 17:07:12 | [diff] [blame] | 200 | #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
[email protected] | 9ac667e | 2013-09-09 12:49:21 | [diff] [blame] | 201 | #endif |
| 202 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 203 | using blink::WebAXObject; |
| 204 | using blink::WebApplicationCacheHost; |
| 205 | using blink::WebApplicationCacheHostClient; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 206 | using blink::WebColor; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 207 | using blink::WebConsoleMessage; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 208 | using blink::WebData; |
| 209 | using blink::WebDataSource; |
| 210 | using blink::WebDocument; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 211 | using blink::WebDragOperation; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 212 | using blink::WebElement; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 213 | using blink::WebFileChooserCompletion; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 214 | using blink::WebFormControlElement; |
| 215 | using blink::WebFormElement; |
| 216 | using blink::WebFrame; |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 217 | using blink::WebFrameContentDumper; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 218 | using blink::WebGestureEvent; |
| 219 | using blink::WebHistoryItem; |
| 220 | using blink::WebHTTPBody; |
dglazkov | 8d0c21dd | 2016-08-06 15:56:36 | [diff] [blame] | 221 | using blink::WebHitTestResult; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 222 | using blink::WebIconURL; |
| 223 | using blink::WebImage; |
| 224 | using blink::WebInputElement; |
| 225 | using blink::WebInputEvent; |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 226 | using blink::WebLocalFrame; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 227 | using blink::WebMediaPlayerAction; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 228 | using blink::WebMouseEvent; |
| 229 | using blink::WebNavigationPolicy; |
| 230 | using blink::WebNavigationType; |
| 231 | using blink::WebNode; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 232 | using blink::WebPluginAction; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 233 | using blink::WebPoint; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 234 | using blink::WebRect; |
| 235 | using blink::WebReferrerPolicy; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 236 | using blink::WebScriptSource; |
| 237 | using blink::WebSearchableFormData; |
| 238 | using blink::WebSecurityOrigin; |
| 239 | using blink::WebSecurityPolicy; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 240 | using blink::WebSettings; |
| 241 | using blink::WebSize; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 242 | using blink::WebStorageNamespace; |
| 243 | using blink::WebStorageQuotaCallbacks; |
| 244 | using blink::WebStorageQuotaError; |
| 245 | using blink::WebStorageQuotaType; |
| 246 | using blink::WebString; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 247 | using blink::WebTextDirection; |
| 248 | using blink::WebTouchEvent; |
| 249 | using blink::WebURL; |
| 250 | using blink::WebURLError; |
| 251 | using blink::WebURLRequest; |
| 252 | using blink::WebURLResponse; |
| 253 | using blink::WebUserGestureIndicator; |
| 254 | using blink::WebVector; |
| 255 | using blink::WebView; |
| 256 | using blink::WebWidget; |
| 257 | using blink::WebWindowFeatures; |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 258 | using blink::WebRuntimeFeatures; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 259 | using base::Time; |
| 260 | using base::TimeDelta; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 261 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 262 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 263 | namespace content { |
| 264 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 265 | //----------------------------------------------------------------------------- |
| 266 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 267 | typedef std::map<blink::WebView*, RenderViewImpl*> ViewMap; |
jbroman | 8319b23 | 2017-03-08 22:53:29 | [diff] [blame] | 268 | static base::LazyInstance<ViewMap>::Leaky g_view_map = |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 269 | LAZY_INSTANCE_INITIALIZER; |
scottmg | 5e65e3a | 2017-03-08 08:48:46 | [diff] [blame] | 270 | typedef std::map<int32_t, RenderViewImpl*> RoutingIDViewMap; |
jbroman | 8319b23 | 2017-03-08 22:53:29 | [diff] [blame] | 271 | static base::LazyInstance<RoutingIDViewMap>::Leaky g_routing_id_view_map = |
| 272 | LAZY_INSTANCE_INITIALIZER; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 273 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 274 | // Time, in seconds, we delay before sending content state changes (such as form |
| 275 | // state and scroll position) to the browser. We delay sending changes to avoid |
| 276 | // spamming the browser. |
| 277 | // To avoid having tab/session restore require sending a message to get the |
| 278 | // current content state during tab closing we use a shorter timeout for the |
| 279 | // foreground renderer. This means there is a small window of time from which |
| 280 | // content state is modified and not sent to session restore, but this is |
| 281 | // better than having to wake up all renderers during shutdown. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 282 | const int kDelaySecondsForContentStateSyncHidden = 5; |
| 283 | const int kDelaySecondsForContentStateSync = 1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 284 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 285 | static RenderViewImpl* (*g_create_render_view_impl)( |
| 286 | CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 287 | const mojom::CreateViewParams&) = nullptr; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 288 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 289 | // static |
[email protected] | e507045d | 2013-07-24 15:23:44 | [diff] [blame] | 290 | Referrer RenderViewImpl::GetReferrerFromRequest( |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 291 | WebFrame* frame, |
| 292 | const WebURLRequest& request) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 293 | return Referrer(blink::WebStringToGURL( |
| 294 | request.HttpHeaderField(WebString::FromUTF8("Referer"))), |
| 295 | request.GetReferrerPolicy()); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 296 | } |
| 297 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 298 | // static |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 299 | WindowOpenDisposition RenderViewImpl::NavigationPolicyToDisposition( |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 300 | WebNavigationPolicy policy) { |
| 301 | switch (policy) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 302 | case blink::kWebNavigationPolicyIgnore: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 303 | return WindowOpenDisposition::IGNORE_ACTION; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 304 | case blink::kWebNavigationPolicyDownload: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 305 | return WindowOpenDisposition::SAVE_TO_DISK; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 306 | case blink::kWebNavigationPolicyCurrentTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 307 | return WindowOpenDisposition::CURRENT_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 308 | case blink::kWebNavigationPolicyNewBackgroundTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 309 | return WindowOpenDisposition::NEW_BACKGROUND_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 310 | case blink::kWebNavigationPolicyNewForegroundTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 311 | return WindowOpenDisposition::NEW_FOREGROUND_TAB; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 312 | case blink::kWebNavigationPolicyNewWindow: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 313 | return WindowOpenDisposition::NEW_WINDOW; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 314 | case blink::kWebNavigationPolicyNewPopup: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 315 | return WindowOpenDisposition::NEW_POPUP; |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 316 | default: |
| 317 | NOTREACHED() << "Unexpected WebNavigationPolicy"; |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 318 | return WindowOpenDisposition::IGNORE_ACTION; |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 322 | // Returns true if the device scale is high enough that losing subpixel |
| 323 | // antialiasing won't have a noticeable effect on text quality. |
| 324 | static bool DeviceScaleEnsuresTextQuality(float device_scale_factor) { |
bokan | e6e68ae | 2017-03-24 00:54:44 | [diff] [blame] | 325 | #if defined(OS_ANDROID) || defined(OS_CHROMEOS) |
| 326 | // On Android, we never have subpixel antialiasing. On Chrome OS we prefer to |
| 327 | // composite all scrollers so that we get animated overlay scrollbars. |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 328 | return true; |
| 329 | #else |
jdduke | 7d452b4a | 2015-08-19 21:25:21 | [diff] [blame] | 330 | // 1.5 is a common touchscreen tablet device scale factor. For such |
| 331 | // devices main thread antialiasing is a heavy burden. |
| 332 | return device_scale_factor >= 1.5f; |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 333 | #endif |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 334 | } |
| 335 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 336 | static bool PreferCompositingToLCDText(CompositorDependencies* compositor_deps, |
| 337 | float device_scale_factor) { |
avi | 83883c8 | 2014-12-23 00:08:49 | [diff] [blame] | 338 | const base::CommandLine& command_line = |
| 339 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | b8ec111 | 2014-08-17 20:09:10 | [diff] [blame] | 340 | if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) |
[email protected] | fb85419 | 2013-02-06 01:30:04 | [diff] [blame] | 341 | return false; |
[email protected] | b8ec111 | 2014-08-17 20:09:10 | [diff] [blame] | 342 | if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) |
[email protected] | fb85419 | 2013-02-06 01:30:04 | [diff] [blame] | 343 | return true; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 344 | if (!compositor_deps->IsLcdTextEnabled()) |
[email protected] | 10c1973 | 2014-08-18 19:39:23 | [diff] [blame] | 345 | return true; |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 346 | return DeviceScaleEnsuresTextQuality(device_scale_factor); |
| 347 | } |
| 348 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 349 | static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 350 | switch (type) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 351 | case blink::WebIconURL::kTypeFavicon: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 352 | return FaviconURL::FAVICON; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 353 | case blink::WebIconURL::kTypeTouch: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 354 | return FaviconURL::TOUCH_ICON; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 355 | case blink::WebIconURL::kTypeTouchPrecomposed: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 356 | return FaviconURL::TOUCH_PRECOMPOSED_ICON; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 357 | case blink::WebIconURL::kTypeInvalid: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 358 | return FaviconURL::INVALID_ICON; |
| 359 | } |
| 360 | return FaviconURL::INVALID_ICON; |
| 361 | } |
| 362 | |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 363 | static void ConvertToFaviconSizes( |
| 364 | const blink::WebVector<blink::WebSize>& web_sizes, |
| 365 | std::vector<gfx::Size>* sizes) { |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 366 | DCHECK(sizes->empty()); |
| 367 | sizes->reserve(web_sizes.size()); |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 368 | for (size_t i = 0; i < web_sizes.size(); ++i) |
| 369 | sizes->push_back(gfx::Size(web_sizes[i])); |
| 370 | } |
| 371 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 372 | /////////////////////////////////////////////////////////////////////////////// |
| 373 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 374 | namespace { |
| 375 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 376 | typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, |
| 377 | const base::string16&, |
| 378 | UScriptCode); |
| 379 | |
| 380 | void SetStandardFontFamilyWrapper(WebSettings* settings, |
| 381 | const base::string16& font, |
| 382 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 383 | settings->SetStandardFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 384 | } |
| 385 | |
| 386 | void SetFixedFontFamilyWrapper(WebSettings* settings, |
| 387 | const base::string16& font, |
| 388 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 389 | settings->SetFixedFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | void SetSerifFontFamilyWrapper(WebSettings* settings, |
| 393 | const base::string16& font, |
| 394 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 395 | settings->SetSerifFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | void SetSansSerifFontFamilyWrapper(WebSettings* settings, |
| 399 | const base::string16& font, |
| 400 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 401 | settings->SetSansSerifFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | void SetCursiveFontFamilyWrapper(WebSettings* settings, |
| 405 | const base::string16& font, |
| 406 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 407 | settings->SetCursiveFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | void SetFantasyFontFamilyWrapper(WebSettings* settings, |
| 411 | const base::string16& font, |
| 412 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 413 | settings->SetFantasyFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 414 | } |
| 415 | |
| 416 | void SetPictographFontFamilyWrapper(WebSettings* settings, |
| 417 | const base::string16& font, |
| 418 | UScriptCode script) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 419 | settings->SetPictographFontFamily(WebString::FromUTF16(font), script); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 420 | } |
| 421 | |
| 422 | // If |scriptCode| is a member of a family of "similar" script codes, returns |
| 423 | // the script code in that family that is used by WebKit for font selection |
| 424 | // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are |
| 425 | // considered equivalent for the purposes of font selection. WebKit uses the |
| 426 | // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is |
| 427 | // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit |
| 428 | // uses different scripts than the ones in Chrome pref names because the version |
| 429 | // of ICU included on certain ports does not have some of the newer scripts. If |
| 430 | // |scriptCode| is not a member of such a family, returns |scriptCode|. |
| 431 | UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) { |
| 432 | switch (scriptCode) { |
| 433 | case USCRIPT_HIRAGANA: |
| 434 | case USCRIPT_KATAKANA: |
| 435 | case USCRIPT_JAPANESE: |
| 436 | return USCRIPT_KATAKANA_OR_HIRAGANA; |
| 437 | case USCRIPT_KOREAN: |
| 438 | return USCRIPT_HANGUL; |
| 439 | default: |
| 440 | return scriptCode; |
| 441 | } |
| 442 | } |
| 443 | |
| 444 | void ApplyFontsFromMap(const ScriptFontFamilyMap& map, |
| 445 | SetFontFamilyWrapper setter, |
| 446 | WebSettings* settings) { |
| 447 | for (ScriptFontFamilyMap::const_iterator it = map.begin(); it != map.end(); |
| 448 | ++it) { |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 449 | int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 450 | if (script >= 0 && script < USCRIPT_CODE_LIMIT) { |
| 451 | UScriptCode code = static_cast<UScriptCode>(script); |
| 452 | (*setter)(settings, it->second, GetScriptForWebSettings(code)); |
| 453 | } |
| 454 | } |
| 455 | } |
| 456 | |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 457 | void ApplyBlinkSettings(const base::CommandLine& command_line, |
| 458 | WebSettings* settings) { |
| 459 | if (!command_line.HasSwitch(switches::kBlinkSettings)) |
| 460 | return; |
| 461 | |
brettw | 26dab8f0 | 2015-08-08 00:28:47 | [diff] [blame] | 462 | std::vector<std::string> blink_settings = base::SplitString( |
| 463 | command_line.GetSwitchValueASCII(switches::kBlinkSettings), |
| 464 | ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 465 | for (const std::string& setting : blink_settings) { |
| 466 | size_t pos = setting.find('='); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 467 | settings->SetFromStrings( |
| 468 | blink::WebString::FromLatin1(setting.substr(0, pos)), |
| 469 | blink::WebString::FromLatin1( |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 470 | pos == std::string::npos ? "" : setting.substr(pos + 1))); |
| 471 | } |
| 472 | } |
| 473 | |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 474 | WebSettings::V8CacheStrategiesForCacheStorage |
| 475 | GetV8CacheStrategiesForCacheStorage() { |
| 476 | const base::CommandLine& command_line = |
| 477 | *base::CommandLine::ForCurrentProcess(); |
| 478 | std::string v8_cache_strategies = command_line.GetSwitchValueASCII( |
| 479 | switches::kV8CacheStrategiesForCacheStorage); |
horo | e0ff13d | 2016-05-27 14:47:22 | [diff] [blame] | 480 | if (v8_cache_strategies.empty()) { |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 481 | v8_cache_strategies = |
| 482 | base::FieldTrialList::FindFullName("V8CacheStrategiesForCacheStorage"); |
horo | e0ff13d | 2016-05-27 14:47:22 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | if (base::StartsWith(v8_cache_strategies, "none", |
| 486 | base::CompareCase::SENSITIVE)) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 487 | return WebSettings::V8CacheStrategiesForCacheStorage::kNone; |
horo | e0ff13d | 2016-05-27 14:47:22 | [diff] [blame] | 488 | } else if (base::StartsWith(v8_cache_strategies, "normal", |
| 489 | base::CompareCase::SENSITIVE)) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 490 | return WebSettings::V8CacheStrategiesForCacheStorage::kNormal; |
horo | e0ff13d | 2016-05-27 14:47:22 | [diff] [blame] | 491 | } else if (base::StartsWith(v8_cache_strategies, "aggressive", |
| 492 | base::CompareCase::SENSITIVE)) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 493 | return WebSettings::V8CacheStrategiesForCacheStorage::kAggressive; |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 494 | } else { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 495 | return WebSettings::V8CacheStrategiesForCacheStorage::kDefault; |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 496 | } |
| 497 | } |
| 498 | |
svartmetal | 751af1f9 | 2016-08-13 11:47:33 | [diff] [blame] | 499 | // This class represents promise which is robust to (will not be broken by) |
| 500 | // |DidNotSwapReason::SWAP_FAILS| events. |
| 501 | class AlwaysDrawSwapPromise : public cc::SwapPromise { |
| 502 | public: |
| 503 | explicit AlwaysDrawSwapPromise(const ui::LatencyInfo& latency_info) |
| 504 | : latency_info_(latency_info) {} |
| 505 | |
| 506 | ~AlwaysDrawSwapPromise() override = default; |
| 507 | |
| 508 | void DidActivate() override {} |
| 509 | |
samans | e7345c8 | 2016-12-16 02:51:16 | [diff] [blame] | 510 | void WillSwap(cc::CompositorFrameMetadata* metadata) override { |
svartmetal | 751af1f9 | 2016-08-13 11:47:33 | [diff] [blame] | 511 | DCHECK(!latency_info_.terminated()); |
| 512 | metadata->latency_info.push_back(latency_info_); |
| 513 | } |
| 514 | |
samans | e7345c8 | 2016-12-16 02:51:16 | [diff] [blame] | 515 | void DidSwap() override {} |
| 516 | |
svartmetal | 751af1f9 | 2016-08-13 11:47:33 | [diff] [blame] | 517 | DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { |
| 518 | return reason == DidNotSwapReason::SWAP_FAILS |
| 519 | ? DidNotSwapAction::KEEP_ACTIVE |
| 520 | : DidNotSwapAction::BREAK_PROMISE; |
| 521 | } |
| 522 | |
| 523 | void OnCommit() override {} |
| 524 | |
| 525 | int64_t TraceId() const override { return latency_info_.trace_id(); } |
| 526 | |
| 527 | private: |
| 528 | ui::LatencyInfo latency_info_; |
| 529 | }; |
| 530 | |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 531 | content::mojom::WindowContainerType WindowFeaturesToContainerType( |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 532 | const blink::WebWindowFeatures& window_features) { |
japhet | bfc4789 | 2017-06-02 23:01:19 | [diff] [blame^] | 533 | if (window_features.background) { |
| 534 | if (window_features.persistent) |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 535 | return content::mojom::WindowContainerType::PERSISTENT; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 536 | else |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 537 | return content::mojom::WindowContainerType::BACKGROUND; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 538 | } else { |
scottmg | de42fb9 | 2017-02-10 17:56:03 | [diff] [blame] | 539 | return content::mojom::WindowContainerType::NORMAL; |
scottmg | 05324cb | 2017-02-09 23:46:04 | [diff] [blame] | 540 | } |
| 541 | } |
| 542 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 543 | } // namespace |
| 544 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 545 | RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 546 | const mojom::CreateViewParams& params) |
nick | 8331f8ad | 2016-11-15 20:42:45 | [diff] [blame] | 547 | : RenderWidget(params.view_id, |
| 548 | compositor_deps, |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 549 | blink::kWebPopupTypeNone, |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 550 | params.initial_size.screen_info, |
| 551 | params.swapped_out, |
| 552 | params.hidden, |
| 553 | params.never_visible), |
| 554 | webkit_preferences_(params.web_preferences), |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 555 | send_content_state_immediately_(false), |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 556 | enabled_bindings_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 557 | send_preferred_size_changes_(false), |
[email protected] | e75cb49e | 2009-01-05 23:13:21 | [diff] [blame] | 558 | navigation_gesture_(NavigationGestureUnknown), |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 559 | history_list_offset_(-1), |
| 560 | history_list_length_(0), |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 561 | frames_in_progress_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 562 | target_url_status_(TARGET_NONE), |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 563 | uses_temporary_zoom_level_(false), |
[email protected] | bbc8856d | 2013-06-14 10:37:04 | [diff] [blame] | 564 | #if defined(OS_ANDROID) |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 565 | top_controls_constraints_(BROWSER_CONTROLS_STATE_BOTH), |
[email protected] | bbc8856d | 2013-06-14 10:37:04 | [diff] [blame] | 566 | #endif |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 567 | browser_controls_shrink_blink_size_(false), |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 568 | top_controls_height_(0.f), |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 569 | webview_(nullptr), |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 570 | has_scrolled_focused_editable_node_into_rect_(false), |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 571 | page_zoom_level_(params.page_zoom_level), |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 572 | main_render_frame_(nullptr), |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 573 | frame_widget_(nullptr), |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 574 | speech_recognition_dispatcher_(NULL), |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 575 | #if defined(OS_ANDROID) |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 576 | was_created_by_renderer_(false), |
[email protected] | a756427 | 2013-04-19 14:24:46 | [diff] [blame] | 577 | #endif |
[email protected] | 8a67aa35 | 2013-02-20 02:58:29 | [diff] [blame] | 578 | enumeration_completion_id_(0), |
changwan | d659e20 | 2016-06-13 02:39:12 | [diff] [blame] | 579 | session_storage_namespace_id_(params.session_storage_namespace_id), |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 580 | weak_ptr_factory_(this) { |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 581 | GetWidget()->set_owner_delegate(this); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 582 | } |
| 583 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 584 | void RenderViewImpl::Initialize( |
| 585 | const mojom::CreateViewParams& params, |
| 586 | const RenderWidget::ShowCallback& show_callback) { |
| 587 | bool was_created_by_renderer = !show_callback.is_null(); |
| 588 | #if defined(OS_ANDROID) |
| 589 | // TODO(sgurun): crbug.com/325351 Needed only for android webview's deprecated |
| 590 | // HandleNavigation codepath. |
| 591 | was_created_by_renderer_ = was_created_by_renderer; |
| 592 | #endif |
thestig | 6057a6b2 | 2015-11-12 23:01:33 | [diff] [blame] | 593 | display_mode_ = params.initial_size.display_mode; |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 594 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 595 | webview_ = WebView::Create(this, is_hidden() |
| 596 | ? blink::kWebPageVisibilityStateHidden |
| 597 | : blink::kWebPageVisibilityStateVisible); |
| 598 | RenderWidget::Init(show_callback, webview_->GetWidget()); |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 599 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 600 | g_view_map.Get().insert(std::make_pair(webview(), this)); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 601 | g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this)); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 602 | |
avi | 83883c8 | 2014-12-23 00:08:49 | [diff] [blame] | 603 | const base::CommandLine& command_line = |
| 604 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 605 | |
[email protected] | 27c521a | 2013-05-29 20:44:32 | [diff] [blame] | 606 | if (command_line.HasSwitch(switches::kStatsCollectionController)) |
| 607 | stats_collection_observer_.reset(new StatsCollectionObserver(this)); |
| 608 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 609 | webview()->SetDisplayMode(display_mode_); |
| 610 | webview()->GetSettings()->SetPreferCompositingToLCDTextEnabled( |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 611 | PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 612 | webview()->GetSettings()->SetThreadedScrollingEnabled( |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 613 | !command_line.HasSwitch(switches::kDisableThreadedScrolling)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 614 | webview()->SetShowFPSCounter( |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 615 | command_line.HasSwitch(cc::switches::kShowFPSCounter)); |
ccameron | 009667d | 2017-05-15 04:14:49 | [diff] [blame] | 616 | webview()->SetDeviceColorProfile(params.image_decode_color_space); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 617 | |
| 618 | ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_); |
| 619 | |
| 620 | if (switches::IsTouchDragDropEnabled()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 621 | webview()->GetSettings()->SetTouchDragDropEnabled(true); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 622 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 623 | webview()->GetSettings()->SetBrowserSideNavigationEnabled( |
arthursonzogni | c517fc3 | 2016-08-11 11:04:24 | [diff] [blame] | 624 | IsBrowserSideNavigationEnabled()); |
| 625 | |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 626 | WebSettings::SelectionStrategyType selection_strategy = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 627 | WebSettings::SelectionStrategyType::kCharacter; |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 628 | const std::string selection_strategy_str = |
| 629 | base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 630 | switches::kTouchTextSelectionStrategy); |
| 631 | if (selection_strategy_str == "direction") |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 632 | selection_strategy = WebSettings::SelectionStrategyType::kDirection; |
| 633 | webview()->GetSettings()->SetSelectionStrategy(selection_strategy); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 634 | |
dtapuska | f65650b | 2016-05-13 17:21:34 | [diff] [blame] | 635 | std::string passiveListenersDefault = |
| 636 | command_line.GetSwitchValueASCII(switches::kPassiveListenersDefault); |
| 637 | if (!passiveListenersDefault.empty()) { |
| 638 | WebSettings::PassiveEventListenerDefault passiveDefault = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 639 | WebSettings::PassiveEventListenerDefault::kFalse; |
dtapuska | acc2fb2 | 2016-07-06 23:26:23 | [diff] [blame] | 640 | if (passiveListenersDefault == "true") |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 641 | passiveDefault = WebSettings::PassiveEventListenerDefault::kTrue; |
dtapuska | f65650b | 2016-05-13 17:21:34 | [diff] [blame] | 642 | else if (passiveListenersDefault == "forcealltrue") |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 643 | passiveDefault = WebSettings::PassiveEventListenerDefault::kForceAllTrue; |
| 644 | webview()->GetSettings()->SetPassiveEventListenerDefault(passiveDefault); |
dtapuska | f65650b | 2016-05-13 17:21:34 | [diff] [blame] | 645 | } |
| 646 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 647 | ApplyBlinkSettings(command_line, webview()->GetSettings()); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 648 | |
nick | 3b5a21f | 2016-11-22 23:07:11 | [diff] [blame] | 649 | WebFrame* opener_frame = |
| 650 | RenderFrameImpl::ResolveOpener(params.opener_frame_route_id); |
| 651 | |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 652 | if (params.main_frame_routing_id != MSG_ROUTING_NONE) { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 653 | main_render_frame_ = RenderFrameImpl::CreateMainFrame( |
| 654 | this, params.main_frame_routing_id, params.main_frame_widget_routing_id, |
dcheng | 9e24bd35 | 2016-03-01 19:15:51 | [diff] [blame] | 655 | params.hidden, screen_info(), compositor_deps_, opener_frame); |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 656 | } |
| 657 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 658 | if (params.proxy_routing_id != MSG_ROUTING_NONE) { |
| 659 | CHECK(params.swapped_out); |
nick | 3b5a21f | 2016-11-22 23:07:11 | [diff] [blame] | 660 | RenderFrameProxy::CreateFrameProxy(params.proxy_routing_id, GetRoutingID(), |
| 661 | opener_frame, MSG_ROUTING_NONE, |
| 662 | params.replicated_frame_state); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 663 | } |
| 664 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 665 | if (main_render_frame_) |
| 666 | main_render_frame_->Initialize(); |
| 667 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 668 | // If this RenderView's creation was initiated by an opener page in this |
| 669 | // process, (e.g. window.open()), we won't be visible until we ask the opener, |
| 670 | // via show_callback, to make us visible. Otherwise, we went through a |
| 671 | // browser-initiated creation, and show() won't be called. |
| 672 | if (!was_created_by_renderer) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 673 | did_show_ = true; |
mfomitchev | 5ad034ec | 2015-04-24 21:57:27 | [diff] [blame] | 674 | |
alexmos | 35799be | 2015-07-02 08:59:50 | [diff] [blame] | 675 | // Set the main frame's name. Only needs to be done for WebLocalFrames, |
| 676 | // since the remote case was handled as part of SetReplicatedState on the |
| 677 | // proxy above. |
| 678 | if (!params.replicated_frame_state.name.empty() && |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 679 | webview()->MainFrame()->IsWebLocalFrame()) { |
| 680 | webview()->MainFrame()->SetName( |
| 681 | blink::WebString::FromUTF8(params.replicated_frame_state.name)); |
alexmos | 3448b55 | 2015-06-26 07:49:13 | [diff] [blame] | 682 | } |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 683 | |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 684 | // TODO(davidben): Move this state from Blink into content. |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 685 | if (params.window_was_created_with_opener) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 686 | webview()->SetOpenedByDOM(); |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 687 | |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 688 | UpdateWebViewWithDeviceScaleFactor(); |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 689 | OnSetRendererPrefs(params.renderer_preferences); |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 690 | |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 691 | if (!params.enable_auto_resize) { |
| 692 | OnResize(params.initial_size); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 693 | } else { |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 694 | OnEnableAutoResize(params.min_size, params.max_size); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 695 | } |
| 696 | |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 697 | idle_user_detector_.reset(new IdleUserDetector(this)); |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 698 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 699 | GetContentClient()->renderer()->RenderViewCreated(this); |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 700 | |
dcheng | 9e24bd35 | 2016-03-01 19:15:51 | [diff] [blame] | 701 | // Ensure that sandbox flags are inherited from an opener in a different |
| 702 | // process. In that case, the browser process will set any inherited sandbox |
| 703 | // flags in |replicated_frame_state|, so apply them here. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 704 | if (!was_created_by_renderer && webview()->MainFrame()->IsWebLocalFrame()) { |
| 705 | webview()->MainFrame()->ToWebLocalFrame()->ForceSandboxFlags( |
dcheng | 9e24bd35 | 2016-03-01 19:15:51 | [diff] [blame] | 706 | params.replicated_frame_state.sandbox_flags); |
alexmos | aedfc6f | 2016-01-21 23:57:38 | [diff] [blame] | 707 | } |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 708 | |
| 709 | page_zoom_level_ = params.page_zoom_level; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 710 | } |
| 711 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 712 | RenderViewImpl::~RenderViewImpl() { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 713 | DCHECK(!frame_widget_); |
| 714 | |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 715 | for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); |
| 716 | it != disambiguation_bitmaps_.end(); |
| 717 | ++it) |
| 718 | delete it->second; |
[email protected] | 91a2aea | 2013-07-08 23:14:39 | [diff] [blame] | 719 | |
[email protected] | 8ed1d3f | 2013-02-20 11:45:55 | [diff] [blame] | 720 | #if defined(OS_ANDROID) |
davve | 17e025e1 | 2016-05-23 15:30:20 | [diff] [blame] | 721 | // The date/time picker client is both a std::unique_ptr member of this class |
| 722 | // and a RenderViewObserver. Reset it to prevent double deletion. |
[email protected] | 8ed1d3f | 2013-02-20 11:45:55 | [diff] [blame] | 723 | date_time_picker_client_.reset(); |
| 724 | #endif |
| 725 | |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 726 | #ifndef NDEBUG |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 727 | // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap. |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 728 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 729 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 730 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 731 | RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer(); |
| 732 | for (RoutingIDViewMap::iterator it = routing_id_views->begin(); |
| 733 | it != routing_id_views->end(); ++it) |
| 734 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 735 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 736 | |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 737 | idle_user_detector_.reset(); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 738 | for (auto& observer : observers_) |
| 739 | observer.RenderViewGone(); |
| 740 | for (auto& observer : observers_) |
| 741 | observer.OnDestruct(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 742 | } |
| 743 | |
| 744 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 745 | RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 746 | ViewMap* views = g_view_map.Pointer(); |
| 747 | ViewMap::iterator it = views->find(webview); |
| 748 | return it == views->end() ? NULL : it->second; |
| 749 | } |
| 750 | |
| 751 | /*static*/ |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 752 | RenderView* RenderView::FromWebView(blink::WebView* webview) { |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 753 | return RenderViewImpl::FromWebView(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | /*static*/ |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 757 | RenderViewImpl* RenderViewImpl::FromRoutingID(int32_t routing_id) { |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 758 | RoutingIDViewMap* views = g_routing_id_view_map.Pointer(); |
| 759 | RoutingIDViewMap::iterator it = views->find(routing_id); |
| 760 | return it == views->end() ? NULL : it->second; |
| 761 | } |
| 762 | |
| 763 | /*static*/ |
| 764 | RenderView* RenderView::FromRoutingID(int routing_id) { |
| 765 | return RenderViewImpl::FromRoutingID(routing_id); |
| 766 | } |
| 767 | |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 768 | /* static */ |
jochen | 9c7b8f24 | 2015-06-01 15:32:02 | [diff] [blame] | 769 | size_t RenderView::GetRenderViewCount() { |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 770 | return g_view_map.Get().size(); |
| 771 | } |
| 772 | |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 773 | /*static*/ |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 774 | void RenderView::ForEach(RenderViewVisitor* visitor) { |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 775 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 776 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 777 | if (!visitor->Visit(it->second)) |
| 778 | return; |
| 779 | } |
| 780 | } |
| 781 | |
| 782 | /*static*/ |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 783 | void RenderView::ApplyWebPreferences(const WebPreferences& prefs, |
| 784 | WebView* web_view) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 785 | WebSettings* settings = web_view->GetSettings(); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 786 | ApplyFontsFromMap(prefs.standard_font_family_map, |
| 787 | SetStandardFontFamilyWrapper, settings); |
| 788 | ApplyFontsFromMap(prefs.fixed_font_family_map, |
| 789 | SetFixedFontFamilyWrapper, settings); |
| 790 | ApplyFontsFromMap(prefs.serif_font_family_map, |
| 791 | SetSerifFontFamilyWrapper, settings); |
| 792 | ApplyFontsFromMap(prefs.sans_serif_font_family_map, |
| 793 | SetSansSerifFontFamilyWrapper, settings); |
| 794 | ApplyFontsFromMap(prefs.cursive_font_family_map, |
| 795 | SetCursiveFontFamilyWrapper, settings); |
| 796 | ApplyFontsFromMap(prefs.fantasy_font_family_map, |
| 797 | SetFantasyFontFamilyWrapper, settings); |
| 798 | ApplyFontsFromMap(prefs.pictograph_font_family_map, |
| 799 | SetPictographFontFamilyWrapper, settings); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 800 | settings->SetDefaultFontSize(prefs.default_font_size); |
| 801 | settings->SetDefaultFixedFontSize(prefs.default_fixed_font_size); |
| 802 | settings->SetMinimumFontSize(prefs.minimum_font_size); |
| 803 | settings->SetMinimumLogicalFontSize(prefs.minimum_logical_font_size); |
| 804 | settings->SetDefaultTextEncodingName( |
| 805 | WebString::FromASCII(prefs.default_encoding)); |
| 806 | settings->SetJavaScriptEnabled(prefs.javascript_enabled); |
| 807 | settings->SetWebSecurityEnabled(prefs.web_security_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 808 | settings->SetLoadsImagesAutomatically(prefs.loads_images_automatically); |
| 809 | settings->SetImagesEnabled(prefs.images_enabled); |
| 810 | settings->SetPluginsEnabled(prefs.plugins_enabled); |
| 811 | settings->SetEncryptedMediaEnabled(prefs.encrypted_media_enabled); |
| 812 | settings->SetDOMPasteAllowed(prefs.dom_paste_enabled); |
| 813 | settings->SetTextAreasAreResizable(prefs.text_areas_are_resizable); |
| 814 | settings->SetAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows); |
| 815 | settings->SetDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled); |
| 816 | settings->SetJavaScriptCanAccessClipboard( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 817 | prefs.javascript_can_access_clipboard); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 818 | WebRuntimeFeatures::EnableXSLT(prefs.xslt_enabled); |
| 819 | settings->SetXSSAuditorEnabled(prefs.xss_auditor_enabled); |
| 820 | settings->SetDNSPrefetchingEnabled(prefs.dns_prefetching_enabled); |
| 821 | settings->SetDataSaverEnabled(prefs.data_saver_enabled); |
| 822 | settings->SetLocalStorageEnabled(prefs.local_storage_enabled); |
| 823 | settings->SetSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled); |
| 824 | WebRuntimeFeatures::EnableDatabase(prefs.databases_enabled); |
| 825 | settings->SetOfflineWebApplicationCacheEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 826 | prefs.application_cache_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 827 | settings->SetHistoryEntryRequiresUserGesture( |
japhet | 5018fe6 | 2016-09-14 19:14:04 | [diff] [blame] | 828 | prefs.history_entry_requires_user_gesture); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 829 | settings->SetHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled); |
| 830 | settings->SetCookieEnabled(prefs.cookie_enabled); |
| 831 | settings->SetNavigateOnDragDrop(prefs.navigate_on_drag_drop); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 832 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 833 | // By default, allow_universal_access_from_file_urls is set to false and thus |
| 834 | // we mitigate attacks from local HTML files by not granting file:// URLs |
| 835 | // universal access. Only test shell will enable this. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 836 | settings->SetAllowUniversalAccessFromFileURLs( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 837 | prefs.allow_universal_access_from_file_urls); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 838 | settings->SetAllowFileAccessFromFileURLs( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 839 | prefs.allow_file_access_from_file_urls); |
| 840 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 841 | // Enable experimental WebGL support if requested on command line |
| 842 | // and support is compiled in. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 843 | settings->SetExperimentalWebGLEnabled(prefs.experimental_webgl_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 844 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 845 | // Enable WebGL errors to the JS console if requested. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 846 | settings->SetWebGLErrorsToConsoleEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 847 | prefs.webgl_errors_to_console_enabled); |
| 848 | |
| 849 | // Uses the mock theme engine for scrollbars. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 850 | settings->SetMockScrollbarsEnabled(prefs.mock_scrollbars_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 851 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 852 | settings->SetHideScrollbars(prefs.hide_scrollbars); |
eseckler | 61ff914 | 2016-09-23 22:57:59 | [diff] [blame] | 853 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 854 | // Enable gpu-accelerated 2d canvas if requested on the command line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 855 | WebRuntimeFeatures::EnableAccelerated2dCanvas( |
junov | 524668f2 | 2016-08-08 20:16:52 | [diff] [blame] | 856 | prefs.accelerated_2d_canvas_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 857 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 858 | settings->SetMinimumAccelerated2dCanvasSize( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 859 | prefs.minimum_accelerated_2d_canvas_size); |
| 860 | |
| 861 | // Disable antialiasing for 2d canvas if requested on the command line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 862 | settings->SetAntialiased2dCanvasEnabled( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 863 | !prefs.antialiased_2d_canvas_disabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 864 | WebRuntimeFeatures::ForceDisable2dCanvasCopyOnWrite( |
boliu | cfcae41 | 2016-02-11 22:16:38 | [diff] [blame] | 865 | prefs.disable_2d_canvas_copy_on_write); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 866 | |
zakerinasab | 20ebca0 | 2016-09-27 14:22:34 | [diff] [blame] | 867 | // Disable antialiasing of clips for 2d canvas if requested on the command |
robertphillips | e25137b | 2014-10-20 13:44:34 | [diff] [blame] | 868 | // line. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 869 | settings->SetAntialiasedClips2dCanvasEnabled( |
robertphillips | e25137b | 2014-10-20 13:44:34 | [diff] [blame] | 870 | prefs.antialiased_clips_2d_canvas_enabled); |
| 871 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 872 | // Set MSAA sample count for 2d canvas if requested on the command line (or |
| 873 | // default value if not). |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 874 | settings->SetAccelerated2dCanvasMSAASampleCount( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 875 | prefs.accelerated_2d_canvas_msaa_sample_count); |
| 876 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 877 | // Tabs to link is not part of the settings. WebCore calls |
| 878 | // ChromeClient::tabsToLinks which is part of the glue code. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 879 | web_view->SetTabsToLinks(prefs.tabs_to_links); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 880 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 881 | settings->SetAllowRunningOfInsecureContent( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 882 | prefs.allow_running_insecure_content); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 883 | settings->SetDisableReadingFromCanvas(prefs.disable_reading_from_canvas); |
| 884 | settings->SetStrictMixedContentChecking(prefs.strict_mixed_content_checking); |
mkwst | 2384c822 | 2015-07-30 07:26:47 | [diff] [blame] | 885 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 886 | settings->SetStrictlyBlockBlockableMixedContent( |
mkwst | 2384c822 | 2015-07-30 07:26:47 | [diff] [blame] | 887 | prefs.strictly_block_blockable_mixed_content); |
| 888 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 889 | settings->SetStrictMixedContentCheckingForPlugin( |
mkwst | 0d233e5 | 2015-08-10 09:33:14 | [diff] [blame] | 890 | prefs.block_mixed_plugin_content); |
| 891 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 892 | settings->SetStrictPowerfulFeatureRestrictions( |
mkwst | 673a452f | 2015-01-10 14:41:50 | [diff] [blame] | 893 | prefs.strict_powerful_feature_restrictions); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 894 | settings->SetAllowGeolocationOnInsecureOrigins( |
jww | 9d4ca2d | 2016-01-19 20:58:59 | [diff] [blame] | 895 | prefs.allow_geolocation_on_insecure_origins); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 896 | settings->SetPasswordEchoEnabled(prefs.password_echo_enabled); |
| 897 | settings->SetShouldPrintBackgrounds(prefs.should_print_backgrounds); |
| 898 | settings->SetShouldClearDocumentBackground( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 899 | prefs.should_clear_document_background); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 900 | settings->SetEnableScrollAnimator(prefs.enable_scroll_animator); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 901 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 902 | WebRuntimeFeatures::EnableTouchEventFeatureDetection( |
sunyunjia | fa6a8afc | 2016-12-09 04:25:47 | [diff] [blame] | 903 | prefs.touch_event_feature_detection_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 904 | settings->SetMaxTouchPoints(prefs.pointer_events_max_touch_points); |
| 905 | settings->SetAvailablePointerTypes(prefs.available_pointer_types); |
| 906 | settings->SetPrimaryPointerType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 907 | static_cast<blink::PointerType>(prefs.primary_pointer_type)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 908 | settings->SetAvailableHoverTypes(prefs.available_hover_types); |
| 909 | settings->SetPrimaryHoverType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 910 | static_cast<blink::HoverType>(prefs.primary_hover_type)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 911 | settings->SetEnableTouchAdjustment(prefs.touch_adjustment_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 912 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 913 | WebRuntimeFeatures::EnableColorCorrectRendering( |
ccameron | 7c4df6c2 | 2016-08-11 03:03:15 | [diff] [blame] | 914 | prefs.color_correct_rendering_enabled); |
ccameron | 41530d89 | 2016-11-29 06:12:33 | [diff] [blame] | 915 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 916 | settings->SetShouldRespectImageOrientation( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 917 | prefs.should_respect_image_orientation); |
| 918 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 919 | settings->SetEditingBehavior( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 920 | static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior)); |
| 921 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 922 | settings->SetSupportsMultipleWindows(prefs.supports_multiple_windows); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 923 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 924 | settings->SetInertVisualViewport(prefs.inert_visual_viewport); |
ymalik | 835268c2 | 2016-02-22 16:28:12 | [diff] [blame] | 925 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 926 | settings->SetMainFrameClipsContent(!prefs.record_whole_document); |
khushalsagar | 2da2b23 | 2016-03-23 22:11:35 | [diff] [blame] | 927 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 928 | settings->SetSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 929 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 930 | settings->SetSpatialNavigationEnabled(prefs.spatial_navigation_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 931 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 932 | settings->SetSelectionIncludesAltImageText(true); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 933 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 934 | settings->SetV8CacheOptions( |
[email protected] | 35103c0 | 2014-08-12 15:08:47 | [diff] [blame] | 935 | static_cast<WebSettings::V8CacheOptions>(prefs.v8_cache_options)); |
| 936 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 937 | settings->SetV8CacheStrategiesForCacheStorage( |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 938 | GetV8CacheStrategiesForCacheStorage()); |
| 939 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 940 | settings->SetImageAnimationPolicy( |
je_julie.kim | 7fbb5a1a | 2015-02-09 17:26:05 | [diff] [blame] | 941 | static_cast<WebSettings::ImageAnimationPolicy>(prefs.animation_policy)); |
| 942 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 943 | settings->SetPresentationRequiresUserGesture( |
zqzhang | 1215ad42 | 2016-02-10 13:27:22 | [diff] [blame] | 944 | prefs.user_gesture_required_for_presentation); |
| 945 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 946 | settings->SetTextTrackMarginPercentage(prefs.text_track_margin_percentage); |
halliwell | 4002be4 | 2016-03-18 18:33:40 | [diff] [blame] | 947 | |
dcheng | 5ae8ca36 | 2015-02-05 04:03:47 | [diff] [blame] | 948 | // Needs to happen before setIgnoreVIewportTagScaleLimits below. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 949 | web_view->SetDefaultPageScaleLimits(prefs.default_minimum_page_scale_factor, |
| 950 | prefs.default_maximum_page_scale_factor); |
dcheng | 5ae8ca36 | 2015-02-05 04:03:47 | [diff] [blame] | 951 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 952 | settings->SetExpensiveBackgroundThrottlingCPUBudget( |
altimin | 56bb594b | 2016-11-09 19:45:17 | [diff] [blame] | 953 | prefs.expensive_background_throttling_cpu_budget); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 954 | settings->SetExpensiveBackgroundThrottlingInitialBudget( |
altimin | 56bb594b | 2016-11-09 19:45:17 | [diff] [blame] | 955 | prefs.expensive_background_throttling_initial_budget); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 956 | settings->SetExpensiveBackgroundThrottlingMaxBudget( |
altimin | 56bb594b | 2016-11-09 19:45:17 | [diff] [blame] | 957 | prefs.expensive_background_throttling_max_budget); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 958 | settings->SetExpensiveBackgroundThrottlingMaxDelay( |
altimin | 56bb594b | 2016-11-09 19:45:17 | [diff] [blame] | 959 | prefs.expensive_background_throttling_max_delay); |
| 960 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 961 | #if defined(OS_ANDROID) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 962 | settings->SetAllowCustomScrollbarInMainFrame(false); |
| 963 | settings->SetTextAutosizingEnabled(prefs.text_autosizing_enabled); |
| 964 | settings->SetAccessibilityFontScaleFactor(prefs.font_scale_factor); |
| 965 | settings->SetDeviceScaleAdjustment(prefs.device_scale_adjustment); |
| 966 | settings->SetFullscreenSupported(prefs.fullscreen_supported); |
| 967 | web_view->SetIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); |
| 968 | settings->SetAutoZoomFocusedNodeToLegibleScale(true); |
| 969 | settings->SetDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 970 | settings->SetMediaPlaybackGestureWhitelistScope( |
| 971 | blink::WebString::FromUTF8(prefs.media_playback_gesture_whitelist_scope)); |
| 972 | settings->SetDefaultVideoPosterURL( |
| 973 | WebString::FromASCII(prefs.default_video_poster_url.spec())); |
| 974 | settings->SetSupportDeprecatedTargetDensityDPI( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 975 | prefs.support_deprecated_target_density_dpi); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 976 | settings->SetUseLegacyBackgroundSizeShorthandBehavior( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 977 | prefs.use_legacy_background_size_shorthand_behavior); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 978 | settings->SetWideViewportQuirkEnabled(prefs.wide_viewport_quirk); |
| 979 | settings->SetUseWideViewport(prefs.use_wide_viewport); |
| 980 | settings->SetForceZeroLayoutHeight(prefs.force_zero_layout_height); |
| 981 | settings->SetViewportMetaLayoutSizeQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 982 | prefs.viewport_meta_layout_size_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 983 | settings->SetViewportMetaMergeContentQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 984 | prefs.viewport_meta_merge_content_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 985 | settings->SetViewportMetaNonUserScalableQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 986 | prefs.viewport_meta_non_user_scalable_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 987 | settings->SetViewportMetaZeroValuesQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 988 | prefs.viewport_meta_zero_values_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 989 | settings->SetClobberUserAgentInitialScaleQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 990 | prefs.clobber_user_agent_initial_scale_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 991 | settings->SetIgnoreMainFrameOverflowHiddenQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 992 | prefs.ignore_main_frame_overflow_hidden_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 993 | settings->SetReportScreenSizeInPhysicalPixelsQuirk( |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 994 | prefs.report_screen_size_in_physical_pixels_quirk); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 995 | settings->SetShouldReuseGlobalForUnownedMainFrame( |
boliu | 1a00f26 | 2016-04-06 19:08:46 | [diff] [blame] | 996 | prefs.resue_global_for_unowned_main_frame); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 997 | settings->SetProgressBarCompletion( |
japhet | 98e9bd8 | 2016-06-28 23:48:45 | [diff] [blame] | 998 | static_cast<WebSettings::ProgressBarCompletion>( |
| 999 | prefs.progress_bar_completion)); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1000 | settings->SetPreferHiddenVolumeControls(true); |
| 1001 | settings->SetSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default); |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 1002 | |
aelias | e678aa4 | 2017-04-14 22:41:04 | [diff] [blame] | 1003 | // Force preload=none and disable autoplay on older Android |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 1004 | // platforms because their media pipelines are not stable enough to handle |
| 1005 | // concurrent elements. See http://crbug.com/612909, http://crbug.com/622826. |
aelias | e678aa4 | 2017-04-14 22:41:04 | [diff] [blame] | 1006 | const bool is_jelly_bean = |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 1007 | base::android::BuildInfo::GetInstance()->sdk_int() <= |
aelias | e678aa4 | 2017-04-14 22:41:04 | [diff] [blame] | 1008 | base::android::SDK_VERSION_JELLY_BEAN_MR2; |
| 1009 | settings->SetForcePreloadNoneForMediaElements(is_jelly_bean); |
mlamouri | 1d266bf | 2016-12-05 17:42:36 | [diff] [blame] | 1010 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1011 | WebRuntimeFeatures::EnableVideoFullscreenOrientationLock( |
mlamouri | 1d266bf | 2016-12-05 17:42:36 | [diff] [blame] | 1012 | prefs.video_fullscreen_orientation_lock_enabled); |
johnme | 913ee5f | 2017-04-28 21:36:16 | [diff] [blame] | 1013 | WebRuntimeFeatures::EnableVideoRotateToFullscreen( |
| 1014 | prefs.video_rotate_to_fullscreen_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1015 | WebRuntimeFeatures::EnableVideoFullscreenDetection( |
zqzhang | 93e959d1 | 2017-03-16 13:10:20 | [diff] [blame] | 1016 | prefs.video_fullscreen_detection_enabled); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1017 | settings->SetEmbeddedMediaExperienceEnabled( |
shaktisahu | f97f753 | 2017-02-24 22:46:13 | [diff] [blame] | 1018 | prefs.embedded_media_experience_enabled); |
vollick | 8921b24 | 2017-05-25 02:48:15 | [diff] [blame] | 1019 | settings->SetPagePopupsSuppressed(prefs.page_popups_suppressed); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1020 | settings->SetDoNotUpdateSelectionOnMutatingSelectionRange( |
changwan | e54ccdb9 | 2017-04-05 19:20:54 | [diff] [blame] | 1021 | prefs.do_not_update_selection_on_mutating_selection_range); |
zqzhang | df72ed08 | 2016-12-08 16:07:55 | [diff] [blame] | 1022 | #endif // defined(OS_ANDROID) |
liberato | 9e93489 | 2016-05-03 19:00:27 | [diff] [blame] | 1023 | |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 1024 | switch (prefs.autoplay_policy) { |
| 1025 | case AutoplayPolicy::kNoUserGestureRequired: |
mlamouri | 276a6f3 | 2017-05-12 09:24:28 | [diff] [blame] | 1026 | settings->SetAutoplayPolicy( |
| 1027 | WebSettings::AutoplayPolicy::kNoUserGestureRequired); |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 1028 | break; |
| 1029 | case AutoplayPolicy::kUserGestureRequired: |
mlamouri | 276a6f3 | 2017-05-12 09:24:28 | [diff] [blame] | 1030 | settings->SetAutoplayPolicy( |
| 1031 | WebSettings::AutoplayPolicy::kUserGestureRequired); |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 1032 | break; |
| 1033 | case AutoplayPolicy::kUserGestureRequiredForCrossOrigin: |
mlamouri | 276a6f3 | 2017-05-12 09:24:28 | [diff] [blame] | 1034 | settings->SetAutoplayPolicy( |
| 1035 | WebSettings::AutoplayPolicy::kUserGestureRequiredForCrossOrigin); |
mlamouri | 55a0543c | 2017-05-11 10:34:07 | [diff] [blame] | 1036 | break; |
| 1037 | } |
| 1038 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1039 | settings->SetViewportEnabled(prefs.viewport_enabled); |
| 1040 | settings->SetViewportMetaEnabled(prefs.viewport_meta_enabled); |
| 1041 | settings->SetShrinksViewportContentToFit( |
| 1042 | prefs.shrinks_viewport_contents_to_fit); |
| 1043 | settings->SetViewportStyle( |
alokp | 5d56696 | 2016-04-19 00:54:16 | [diff] [blame] | 1044 | static_cast<blink::WebViewportStyle>(prefs.viewport_style)); |
| 1045 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1046 | settings->SetLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale); |
| 1047 | settings->SetMainFrameResizesAreOrientationChanges( |
yoav | a1a508b4 | 2015-10-20 12:03:21 | [diff] [blame] | 1048 | prefs.main_frame_resizes_are_orientation_changes); |
| 1049 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1050 | settings->SetUseSolidColorScrollbars(prefs.use_solid_color_scrollbars); |
jinho.bang | 8f11ffa | 2014-12-04 06:03:03 | [diff] [blame] | 1051 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1052 | settings->SetShowContextMenuOnMouseUp(prefs.context_menu_on_mouse_up); |
| 1053 | settings->SetAlwaysShowContextMenuOnTouch( |
amaralp | 547e419 | 2016-06-03 19:17:35 | [diff] [blame] | 1054 | prefs.always_show_context_menu_on_touch); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1055 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1056 | settings->SetHideDownloadUI(prefs.hide_download_ui); |
| 1057 | WebRuntimeFeatures::EnableBackgroundVideoTrackOptimization( |
avayvod | 39c10240 | 2016-11-23 21:43:13 | [diff] [blame] | 1058 | prefs.background_video_track_optimization_enabled); |
avayvod | 23275794 | 2017-04-29 04:12:34 | [diff] [blame] | 1059 | WebRuntimeFeatures::EnableNewRemotePlaybackPipeline( |
| 1060 | base::FeatureList::IsEnabled(media::kNewRemotePlaybackPipeline)); |
qinmin | 72e8bd0 | 2016-10-21 19:35:37 | [diff] [blame] | 1061 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1062 | settings->SetPresentationReceiver(prefs.presentation_receiver); |
mlamouri | 57359d91 | 2016-11-29 20:11:50 | [diff] [blame] | 1063 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1064 | settings->SetMediaControlsEnabled(prefs.media_controls_enabled); |
mlamouri | 5cd9ae8 | 2017-02-18 11:05:09 | [diff] [blame] | 1065 | |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1066 | #if defined(OS_MACOSX) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1067 | settings->SetDoubleTapToZoomEnabled(true); |
| 1068 | web_view->SetMaximumLegibleScale(prefs.default_maximum_page_scale_factor); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1069 | #endif |
sunyunjia | 87f287b | 2016-09-09 00:38:13 | [diff] [blame] | 1070 | |
| 1071 | #if defined(OS_WIN) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1072 | WebRuntimeFeatures::EnableMiddleClickAutoscroll(true); |
sunyunjia | 87f287b | 2016-09-09 00:38:13 | [diff] [blame] | 1073 | #endif |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1074 | } |
| 1075 | |
| 1076 | /*static*/ |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1077 | RenderViewImpl* RenderViewImpl::Create( |
| 1078 | CompositorDependencies* compositor_deps, |
| 1079 | const mojom::CreateViewParams& params, |
| 1080 | const RenderWidget::ShowCallback& show_callback) { |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1081 | DCHECK(params.view_id != MSG_ROUTING_NONE); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1082 | RenderViewImpl* render_view = NULL; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1083 | if (g_create_render_view_impl) |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1084 | render_view = g_create_render_view_impl(compositor_deps, params); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1085 | else |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1086 | render_view = new RenderViewImpl(compositor_deps, params); |
[email protected] | 0287e76 | 2014-04-11 13:07:58 | [diff] [blame] | 1087 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1088 | render_view->Initialize(params, show_callback); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1089 | return render_view; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1090 | } |
| 1091 | |
| 1092 | // static |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1093 | void RenderViewImpl::InstallCreateHook(RenderViewImpl* ( |
| 1094 | *create_render_view_impl)(CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 1095 | const mojom::CreateViewParams&)) { |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1096 | CHECK(!g_create_render_view_impl); |
| 1097 | g_create_render_view_impl = create_render_view_impl; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1098 | } |
| 1099 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1100 | void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1101 | observers_.AddObserver(observer); |
| 1102 | } |
| 1103 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1104 | void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 1105 | observer->RenderViewGone(); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1106 | observers_.RemoveObserver(observer); |
| 1107 | } |
| 1108 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1109 | blink::WebView* RenderViewImpl::webview() const { |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 1110 | return webview_; |
[email protected] | 4d51d5bf | 2010-07-26 18:48:26 | [diff] [blame] | 1111 | } |
| 1112 | |
brettw | 4b46108 | 2016-11-19 18:55:16 | [diff] [blame] | 1113 | #if BUILDFLAG(ENABLE_PLUGINS) |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 1114 | |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 1115 | #if defined(OS_MACOSX) |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1116 | void RenderViewImpl::OnGetRenderedText() { |
| 1117 | if (!webview()) |
| 1118 | return; |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 1119 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1120 | if (!webview()->MainFrame()->IsWebLocalFrame()) |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 1121 | return; |
| 1122 | |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1123 | // Get rendered text from WebLocalFrame. |
| 1124 | // TODO: Currently IPC truncates any data that has a |
| 1125 | // size > kMaximumMessageSize. May be split the text into smaller chunks and |
| 1126 | // send back using multiple IPC. See http://crbug.com/393444. |
| 1127 | static const size_t kMaximumMessageSize = 8 * 1024 * 1024; |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 1128 | // TODO(dglazkov): Using this API is wrong. It's not OOPIF-compatible and |
| 1129 | // sends text in the wrong order. See http://crbug.com/584798. |
| 1130 | // TODO(dglazkov): WebFrameContentDumper should only be used for |
| 1131 | // testing purposes. See http://crbug.com/585164. |
| 1132 | std::string text = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1133 | WebFrameContentDumper::DumpWebViewAsText(webview(), kMaximumMessageSize) |
| 1134 | .Utf8(); |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1135 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1136 | Send(new ViewMsg_GetRenderedTextCompleted(GetRoutingID(), text)); |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1137 | } |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 1138 | #endif // defined(OS_MACOSX) |
| 1139 | |
| 1140 | #endif // ENABLE_PLUGINS |
| 1141 | |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 1142 | void RenderViewImpl::TransferActiveWheelFlingAnimation( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1143 | const blink::WebActiveWheelFlingParameters& params) { |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 1144 | if (webview()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1145 | webview()->TransferActiveWheelFlingAnimation(params); |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 1146 | } |
| 1147 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1148 | // RenderWidgetInputHandlerDelegate ----------------------------------------- |
| 1149 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1150 | bool RenderViewImpl::DoesRenderWidgetHaveTouchEventHandlersAt( |
| 1151 | const gfx::Point& point) const { |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1152 | if (!webview()) |
| 1153 | return false; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1154 | return webview()->HasTouchEventHandlersAt(point); |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1155 | } |
| 1156 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1157 | bool RenderViewImpl::RenderWidgetWillHandleMouseEvent( |
| 1158 | const blink::WebMouseEvent& event) { |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1159 | // If the mouse is locked, only the current owner of the mouse lock can |
| 1160 | // process mouse events. |
| 1161 | return mouse_lock_dispatcher_->WillHandleMouseEvent(event); |
| 1162 | } |
| 1163 | |
| 1164 | // IPC::Listener implementation ---------------------------------------------- |
| 1165 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1166 | bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1167 | WebFrame* main_frame = webview() ? webview()->MainFrame() : NULL; |
| 1168 | if (main_frame && main_frame->IsWebLocalFrame()) |
| 1169 | GetContentClient()->SetActiveURL(main_frame->GetDocument().Url()); |
[email protected] | f8b6b6f | 2009-03-10 16:48:26 | [diff] [blame] | 1170 | |
nasko | c6edf7e | 2015-10-16 01:48:45 | [diff] [blame] | 1171 | // Input IPC messages must not be processed if the RenderView is in |
| 1172 | // swapped out state. |
dtapuska | 1b0fcc32 | 2016-10-28 18:08:28 | [diff] [blame] | 1173 | if (is_swapped_out_ && |
| 1174 | IPC_MESSAGE_ID_CLASS(message.type()) == InputMsgStart) { |
| 1175 | // TODO(dtapuska): Remove this histogram once we have seen that it actually |
| 1176 | // produces results true. See crbug.com/615090 |
| 1177 | UMA_HISTOGRAM_BOOLEAN("Event.RenderView.DiscardInput", true); |
| 1178 | IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
| 1179 | IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnDiscardInputEvent) |
| 1180 | IPC_END_MESSAGE_MAP() |
nasko | c6edf7e | 2015-10-16 01:48:45 | [diff] [blame] | 1181 | return false; |
dtapuska | 1b0fcc32 | 2016-10-28 18:08:28 | [diff] [blame] | 1182 | } |
nasko | c6edf7e | 2015-10-16 01:48:45 | [diff] [blame] | 1183 | |
dcheng | a2d442c2 | 2016-10-13 15:39:21 | [diff] [blame] | 1184 | for (auto& observer : observers_) { |
| 1185 | if (observer.OnMessageReceived(message)) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1186 | return true; |
dcheng | a2d442c2 | 2016-10-13 15:39:21 | [diff] [blame] | 1187 | } |
[email protected] | b2abac7 | 2009-02-26 12:39:28 | [diff] [blame] | 1188 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1189 | bool handled = true; |
[email protected] | e44d134 | 2014-05-16 21:29:33 | [diff] [blame] | 1190 | IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1191 | IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 1192 | IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1193 | IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
| 1194 | OnScrollFocusedEditableNodeIntoRect) |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 1195 | IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1196 | IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1197 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 1198 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 1199 | IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 1200 | OnEnumerateDirectoryResponse) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1201 | IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 1202 | IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 1203 | IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
[email protected] | ab32b16c | 2009-10-16 14:57:25 | [diff] [blame] | 1204 | IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1205 | OnEnablePreferredSizeChangedMode) |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 1206 | IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 1207 | IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 1208 | IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 1209 | OnDisableScrollbarsForSmallWindows) |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1210 | IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 1211 | IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1212 | IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 1213 | IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 1214 | IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
| 1215 | OnReleaseDisambiguationPopupBitmap) |
aelias | 1b55156e5 | 2017-04-01 00:46:05 | [diff] [blame] | 1216 | IPC_MESSAGE_HANDLER(ViewMsg_ResolveTapDisambiguation, |
| 1217 | OnResolveTapDisambiguation) |
[email protected] | 506563d | 2014-06-23 12:22:41 | [diff] [blame] | 1218 | IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1219 | IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1220 | |
| 1221 | // Page messages. |
lfg | db5c4ed | 2016-03-04 23:09:07 | [diff] [blame] | 1222 | IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, |
| 1223 | OnUpdateWindowScreenRect) |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1224 | IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) |
wjmaclean | 8a795f3 | 2016-08-11 23:49:58 | [diff] [blame] | 1225 | IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor); |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 1226 | IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) |
| 1227 | IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) |
alexmos | 136fd6e6 | 2016-08-15 20:58:41 | [diff] [blame] | 1228 | IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, |
| 1229 | OnSetHistoryOffsetAndLength) |
altimin | d8bd26c | 2016-11-04 11:44:54 | [diff] [blame] | 1230 | IPC_MESSAGE_HANDLER(PageMsg_AudioStateChanged, OnAudioStateChanged) |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 1231 | IPC_MESSAGE_HANDLER(PageMsg_UpdateScreenInfo, OnUpdateScreenInfo) |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 1232 | |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1233 | #if defined(OS_ANDROID) |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 1234 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateBrowserControlsState, |
| 1235 | OnUpdateBrowserControlsState) |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1236 | #elif defined(OS_MACOSX) |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1237 | IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, |
| 1238 | OnGetRenderedText) |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 1239 | IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1240 | #endif |
[email protected] | a794f3a | 2013-10-30 17:00:32 | [diff] [blame] | 1241 | // Adding a new message? Add platform independent ones first, then put the |
| 1242 | // platform specific ones at the end. |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1243 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1244 | // Have the super handle all other messages. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1245 | IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1246 | IPC_END_MESSAGE_MAP() |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 1247 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1248 | return handled; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1249 | } |
| 1250 | |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1251 | void RenderViewImpl::OnSelectWordAroundCaret() { |
donnd | 701cc20 | 2017-05-17 23:11:20 | [diff] [blame] | 1252 | // Set default values for the ACK |
| 1253 | bool did_select = false; |
| 1254 | int start_adjust = 0; |
| 1255 | int end_adjust = 0; |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1256 | |
donnd | 701cc20 | 2017-05-17 23:11:20 | [diff] [blame] | 1257 | if (webview()) { |
| 1258 | WebLocalFrame* focused_frame = GetWebView()->FocusedFrame(); |
| 1259 | if (focused_frame) { |
| 1260 | input_handler_->set_handling_input_event(true); |
| 1261 | blink::WebRange initial_range = focused_frame->SelectionRange(); |
donnd | bde109ff | 2017-05-26 20:20:01 | [diff] [blame] | 1262 | if (!initial_range.IsNull()) |
| 1263 | did_select = focused_frame->SelectWordAroundCaret(); |
donnd | 701cc20 | 2017-05-17 23:11:20 | [diff] [blame] | 1264 | if (did_select) { |
| 1265 | blink::WebRange adjusted_range = focused_frame->SelectionRange(); |
| 1266 | start_adjust = |
| 1267 | adjusted_range.StartOffset() - initial_range.StartOffset(); |
| 1268 | end_adjust = adjusted_range.EndOffset() - initial_range.EndOffset(); |
| 1269 | } |
| 1270 | input_handler_->set_handling_input_event(false); |
| 1271 | } |
| 1272 | } |
| 1273 | Send(new ViewHostMsg_SelectWordAroundCaretAck(GetRoutingID(), did_select, |
| 1274 | start_adjust, end_adjust)); |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1275 | } |
| 1276 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1277 | void RenderViewImpl::OnUpdateTargetURLAck() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1278 | // Check if there is a targeturl waiting to be sent. |
avi | 450ce00e | 2014-09-24 01:58:52 | [diff] [blame] | 1279 | if (target_url_status_ == TARGET_PENDING) |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1280 | Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), pending_target_url_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1281 | |
| 1282 | target_url_status_ = TARGET_NONE; |
| 1283 | } |
| 1284 | |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1285 | void RenderViewImpl::OnExecuteEditCommand(const std::string& name, |
| 1286 | const std::string& value) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1287 | if (!webview() || !webview()->FocusedFrame()) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1288 | return; |
| 1289 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1290 | webview()->FocusedFrame()->ExecuteCommand(WebString::FromUTF8(name), |
| 1291 | WebString::FromUTF8(value)); |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1292 | } |
| 1293 | |
| 1294 | void RenderViewImpl::OnMoveCaret(const gfx::Point& point) { |
| 1295 | if (!webview()) |
| 1296 | return; |
| 1297 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1298 | Send(new InputHostMsg_MoveCaret_ACK(GetRoutingID())); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1299 | webview()->FocusedFrame()->MoveCaretSelection( |
oshima | 93b827d9 | 2016-03-01 18:58:41 | [diff] [blame] | 1300 | ConvertWindowPointToViewport(point)); |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1301 | } |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1302 | |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1303 | void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1304 | const gfx::Rect& rect) { |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 1305 | blink::WebAutofillClient* autofill_client = nullptr; |
| 1306 | if (auto* focused_frame = GetWebView()->FocusedFrame()) |
| 1307 | autofill_client = focused_frame->AutofillClient(); |
| 1308 | |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1309 | if (has_scrolled_focused_editable_node_into_rect_ && |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 1310 | rect == rect_for_scrolled_focused_editable_node_ && autofill_client) { |
| 1311 | autofill_client->DidCompleteFocusChangeInFrame(); |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1312 | return; |
| 1313 | } |
| 1314 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1315 | if (!webview()->ScrollFocusedEditableElementIntoRect(rect)) |
dglazkov | 4969a3e | 2016-05-20 21:13:51 | [diff] [blame] | 1316 | return; |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 1317 | |
dglazkov | 4969a3e | 2016-05-20 21:13:51 | [diff] [blame] | 1318 | rect_for_scrolled_focused_editable_node_ = rect; |
| 1319 | has_scrolled_focused_editable_node_into_rect_ = true; |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 1320 | if (!compositor()->HasPendingPageScaleAnimation() && autofill_client) |
| 1321 | autofill_client->DidCompleteFocusChangeInFrame(); |
[email protected] | 25bcc8f | 2013-01-09 02:49:25 | [diff] [blame] | 1322 | } |
| 1323 | |
avi | 2b17759 | 2014-12-10 02:08:02 | [diff] [blame] | 1324 | void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
| 1325 | int history_length) { |
| 1326 | DCHECK_GE(history_offset, -1); |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 1327 | DCHECK_GE(history_length, 0); |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1328 | |
avi | 2b17759 | 2014-12-10 02:08:02 | [diff] [blame] | 1329 | history_list_offset_ = history_offset; |
| 1330 | history_list_length_ = history_length; |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1331 | } |
| 1332 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1333 | void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1334 | if (!webview()) |
| 1335 | return; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1336 | webview()->SetInitialFocus(reverse); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1337 | } |
| 1338 | |
lfg | db5c4ed | 2016-03-04 23:09:07 | [diff] [blame] | 1339 | void RenderViewImpl::OnUpdateWindowScreenRect(gfx::Rect window_screen_rect) { |
| 1340 | RenderWidget::OnUpdateWindowScreenRect(window_screen_rect); |
| 1341 | } |
| 1342 | |
altimin | d8bd26c | 2016-11-04 11:44:54 | [diff] [blame] | 1343 | void RenderViewImpl::OnAudioStateChanged(bool is_audio_playing) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1344 | webview()->AudioStateChanged(is_audio_playing); |
altimin | d8bd26c | 2016-11-04 11:44:54 | [diff] [blame] | 1345 | } |
| 1346 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1347 | /////////////////////////////////////////////////////////////////////////////// |
| 1348 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1349 | void RenderViewImpl::ShowCreatedPopupWidget(RenderWidget* popup_widget, |
| 1350 | WebNavigationPolicy policy, |
| 1351 | const gfx::Rect& initial_rect) { |
| 1352 | Send(new ViewHostMsg_ShowWidget(GetRoutingID(), popup_widget->routing_id(), |
| 1353 | initial_rect)); |
| 1354 | } |
| 1355 | |
| 1356 | void RenderViewImpl::ShowCreatedFullscreenWidget( |
| 1357 | RenderWidget* fullscreen_widget, |
| 1358 | WebNavigationPolicy policy, |
| 1359 | const gfx::Rect& initial_rect) { |
| 1360 | Send(new ViewHostMsg_ShowFullscreenWidget(GetRoutingID(), |
| 1361 | fullscreen_widget->routing_id())); |
| 1362 | } |
| 1363 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1364 | void RenderViewImpl::SendFrameStateUpdates() { |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1365 | // Tell each frame with pending state to send its UpdateState message. |
| 1366 | for (int render_frame_routing_id : frames_with_pending_state_) { |
| 1367 | RenderFrameImpl* frame = |
| 1368 | RenderFrameImpl::FromRoutingID(render_frame_routing_id); |
| 1369 | if (frame) |
| 1370 | frame->SendUpdateState(); |
| 1371 | } |
| 1372 | frames_with_pending_state_.clear(); |
| 1373 | } |
| 1374 | |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 1375 | void RenderViewImpl::ApplyWebPreferencesInternal( |
| 1376 | const WebPreferences& prefs, |
| 1377 | blink::WebView* web_view, |
| 1378 | CompositorDependencies* compositor_deps) { |
| 1379 | ApplyWebPreferences(prefs, web_view); |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 1380 | } |
| 1381 | |
svartmetal | 751af1f9 | 2016-08-13 11:47:33 | [diff] [blame] | 1382 | void RenderViewImpl::OnForceRedraw(const ui::LatencyInfo& latency_info) { |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 1383 | if (RenderWidgetCompositor* rwc = compositor()) { |
svartmetal | 751af1f9 | 2016-08-13 11:47:33 | [diff] [blame] | 1384 | rwc->QueueSwapPromise( |
| 1385 | base::MakeUnique<AlwaysDrawSwapPromise>(latency_info)); |
danakj | 87fbafb | 2017-04-04 16:54:11 | [diff] [blame] | 1386 | rwc->SetNeedsForcedRedraw(); |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 1387 | } |
[email protected] | c9bc8f1 | 2012-12-15 22:20:09 | [diff] [blame] | 1388 | } |
| 1389 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1390 | // blink::WebViewClient ------------------------------------------------------ |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1391 | |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 1392 | // TODO(csharrison): Migrate this method to WebFrameClient / RenderFrameImpl, as |
| 1393 | // it is now serviced by a mojo interface scoped to the opener frame. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1394 | WebView* RenderViewImpl::CreateView(WebLocalFrame* creator, |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 1395 | const WebURLRequest& request, |
| 1396 | const WebWindowFeatures& features, |
| 1397 | const WebString& frame_name, |
| 1398 | WebNavigationPolicy policy, |
| 1399 | bool suppress_opener) { |
nick | 5ae4d2d | 2017-01-06 01:18:35 | [diff] [blame] | 1400 | RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1401 | mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1402 | params->user_gesture = WebUserGestureIndicator::IsProcessingUserGesture(); |
[email protected] | 00323f0 | 2013-07-24 15:47:41 | [diff] [blame] | 1403 | if (GetContentClient()->renderer()->AllowPopup()) |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1404 | params->user_gesture = true; |
| 1405 | params->window_container_type = WindowFeaturesToContainerType(features); |
| 1406 | params->session_storage_namespace_id = session_storage_namespace_id_; |
[email protected] | 5cef23d | 2013-02-27 13:11:21 | [diff] [blame] | 1407 | if (frame_name != "_blank") |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1408 | params->frame_name = frame_name.Utf8( |
kinuko | a429302 | 2017-01-27 06:43:25 | [diff] [blame] | 1409 | WebString::UTF8ConversionMode::kStrictReplacingErrorsWithFFFD); |
alexmos | a97d5c5 | 2015-06-19 22:19:09 | [diff] [blame] | 1410 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1411 | params->opener_suppressed = suppress_opener; |
| 1412 | params->disposition = NavigationPolicyToDisposition(policy); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1413 | if (!request.IsNull()) { |
| 1414 | params->target_url = request.Url(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1415 | params->referrer = GetReferrerFromRequest(creator, request); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 1416 | } |
scottmg | 8e6c608 | 2017-02-13 23:15:48 | [diff] [blame] | 1417 | params->features = ConvertWebWindowFeaturesToMojoWindowFeatures(features); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1418 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1419 | // We preserve this information before sending the message since |params| is |
| 1420 | // moved on send. |
| 1421 | bool is_background_tab = |
| 1422 | params->disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB; |
| 1423 | bool opened_by_user_gesture = params->user_gesture; |
[email protected] | 22217ed3 | 2013-11-18 18:40:23 | [diff] [blame] | 1424 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1425 | mojom::CreateNewWindowReplyPtr reply; |
csharrison | 95f01e92 | 2017-04-24 18:52:35 | [diff] [blame] | 1426 | mojom::FrameHostAssociatedPtr frame_host_ptr = creator_frame->GetFrameHost(); |
Charles Harrison | f95354a7 | 2017-05-31 23:07:56 | [diff] [blame] | 1427 | bool err = !frame_host_ptr->CreateNewWindow(std::move(params), &reply); |
| 1428 | if (err || reply->route_id == MSG_ROUTING_NONE) |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1429 | return nullptr; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1430 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1431 | WebUserGestureIndicator::ConsumeUserGesture(); |
[email protected] | c5926242 | 2012-11-30 21:20:52 | [diff] [blame] | 1432 | |
Jochen Eisinger | 515337a | 2017-05-26 14:12:52 | [diff] [blame] | 1433 | // For Android WebView, we support a pop-up like behavior for window.open() |
| 1434 | // even if the embedding app doesn't support multiple windows. In this case, |
| 1435 | // window.open() will return "window" and navigate it to whatever URL was |
| 1436 | // passed. |
| 1437 | if (reply->route_id == GetRoutingID()) |
| 1438 | return webview(); |
| 1439 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 1440 | // While this view may be a background extension page, it can spawn a visible |
| 1441 | // render view. So we just assume that the new one is not another background |
| 1442 | // page instead of passing on our own value. |
| 1443 | // TODO(vangelis): Can we tell if the new view will be a background page? |
| 1444 | bool never_visible = false; |
[email protected] | 9115d5f | 2013-03-24 04:37:41 | [diff] [blame] | 1445 | |
fsamuel | 664e8b6 | 2016-01-20 19:54:01 | [diff] [blame] | 1446 | ResizeParams initial_size = ResizeParams(); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 1447 | initial_size.screen_info = screen_info_; |
| 1448 | |
[email protected] | d6fa88f | 2013-10-18 16:00:43 | [diff] [blame] | 1449 | // The initial hidden state for the RenderViewImpl here has to match what the |
| 1450 | // browser will eventually decide for the given disposition. Since we have to |
| 1451 | // return from this call synchronously, we just have to make our best guess |
| 1452 | // and rely on the browser sending a WasHidden / WasShown message if it |
| 1453 | // disagrees. |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 1454 | mojom::CreateViewParams view_params; |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1455 | |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1456 | view_params.opener_frame_route_id = creator_frame->GetRoutingID(); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1457 | DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1458 | |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1459 | view_params.window_was_created_with_opener = true; |
| 1460 | view_params.renderer_preferences = renderer_preferences_; |
| 1461 | view_params.web_preferences = webkit_preferences_; |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1462 | view_params.view_id = reply->route_id; |
| 1463 | view_params.main_frame_routing_id = reply->main_frame_route_id; |
| 1464 | view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1465 | view_params.session_storage_namespace_id = |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1466 | reply->cloned_session_storage_namespace_id; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1467 | view_params.swapped_out = false; |
alexmos | 3448b55 | 2015-06-26 07:49:13 | [diff] [blame] | 1468 | // WebCore will take care of setting the correct name. |
alexmos | bc7eafa | 2014-12-06 01:38:09 | [diff] [blame] | 1469 | view_params.replicated_frame_state = FrameReplicationState(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1470 | view_params.hidden = is_background_tab; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1471 | view_params.never_visible = never_visible; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1472 | view_params.initial_size = initial_size; |
| 1473 | view_params.enable_auto_resize = false; |
| 1474 | view_params.min_size = gfx::Size(); |
| 1475 | view_params.max_size = gfx::Size(); |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1476 | view_params.page_zoom_level = page_zoom_level_; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1477 | |
nick | 5ae4d2d | 2017-01-06 01:18:35 | [diff] [blame] | 1478 | // Unretained() is safe here because our calling function will also call |
| 1479 | // show(). |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1480 | RenderWidget::ShowCallback show_callback = |
nick | 5ae4d2d | 2017-01-06 01:18:35 | [diff] [blame] | 1481 | base::Bind(&RenderFrameImpl::ShowCreatedWindow, |
| 1482 | base::Unretained(creator_frame), opened_by_user_gesture); |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1483 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 1484 | RenderViewImpl* view = |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1485 | RenderViewImpl::Create(compositor_deps_, view_params, show_callback); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1486 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1487 | return view->webview(); |
| 1488 | } |
| 1489 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1490 | WebWidget* RenderViewImpl::CreatePopupMenu(blink::WebPopupType popup_type) { |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1491 | RenderWidget* widget = RenderWidget::CreateForPopup(this, compositor_deps_, |
| 1492 | popup_type, screen_info_); |
[email protected] | 3b78ec1 | 2014-03-04 05:18:28 | [diff] [blame] | 1493 | if (!widget) |
| 1494 | return NULL; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 1495 | if (screen_metrics_emulator_) { |
| 1496 | widget->SetPopupOriginAdjustmentsForEmulation( |
| 1497 | screen_metrics_emulator_.get()); |
| 1498 | } |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 1499 | return widget->GetWebWidget(); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1500 | } |
| 1501 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1502 | WebStorageNamespace* RenderViewImpl::CreateSessionStorageNamespace() { |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 1503 | CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
[email protected] | 1910fe8 | 2012-05-10 00:04:10 | [diff] [blame] | 1504 | return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1505 | } |
| 1506 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1507 | void RenderViewImpl::PrintPage(WebLocalFrame* frame) { |
nasko | e440d8c | 2016-10-12 23:07:56 | [diff] [blame] | 1508 | UMA_HISTOGRAM_BOOLEAN("PrintPreview.InitiatedByScript", |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1509 | frame->Top() == frame); |
nasko | e440d8c | 2016-10-12 23:07:56 | [diff] [blame] | 1510 | |
| 1511 | // Logging whether the top frame is remote is sufficient in this case. If |
| 1512 | // the top frame is local, the printing code will function correctly and |
| 1513 | // the frame itself will be printed, so the cases this histogram tracks is |
| 1514 | // where printing of a subframe will fail as of now. |
| 1515 | UMA_HISTOGRAM_BOOLEAN("PrintPreview.OutOfProcessSubframe", |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1516 | frame->Top()->IsWebRemoteFrame()); |
nasko | e440d8c | 2016-10-12 23:07:56 | [diff] [blame] | 1517 | |
thestig | cb959ce | 2016-11-17 05:56:32 | [diff] [blame] | 1518 | RenderFrameImpl::FromWebFrame(frame)->ScriptedPrint( |
| 1519 | input_handler().handling_input_event()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1520 | } |
| 1521 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1522 | bool RenderViewImpl::EnumerateChosenDirectory( |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1523 | const WebString& path, |
| 1524 | WebFileChooserCompletion* chooser_completion) { |
| 1525 | int id = enumeration_completion_id_++; |
| 1526 | enumeration_completions_[id] = chooser_completion; |
| 1527 | return Send(new ViewHostMsg_EnumerateDirectory( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1528 | GetRoutingID(), id, blink::WebStringToFilePath(path))); |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1529 | } |
| 1530 | |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1531 | void RenderViewImpl::FrameDidStartLoading(WebFrame* frame) { |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1532 | DCHECK_GE(frames_in_progress_, 0); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1533 | if (frames_in_progress_ == 0) { |
| 1534 | for (auto& observer : observers_) |
| 1535 | observer.DidStartLoading(); |
| 1536 | } |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1537 | frames_in_progress_++; |
[email protected] | 6dd5c32 | 2014-03-12 07:58:46 | [diff] [blame] | 1538 | } |
| 1539 | |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1540 | void RenderViewImpl::FrameDidStopLoading(WebFrame* frame) { |
[email protected] | eb47377 | 2014-04-11 20:54:33 | [diff] [blame] | 1541 | // TODO(japhet): This should be a DCHECK, but the pdf plugin sometimes |
| 1542 | // calls DidStopLoading() without a matching DidStartLoading(). |
| 1543 | if (frames_in_progress_ == 0) |
| 1544 | return; |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1545 | frames_in_progress_--; |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1546 | if (frames_in_progress_ == 0) { |
| 1547 | DidStopLoadingIcons(); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1548 | for (auto& observer : observers_) |
| 1549 | observer.DidStopLoading(); |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1550 | } |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1551 | } |
| 1552 | |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 1553 | void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 1554 | // The previous WebFrameWidget must already be detached by CloseForFrame(). |
| 1555 | DCHECK(!frame_widget_); |
| 1556 | frame_widget_ = frame_widget; |
| 1557 | } |
| 1558 | |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 1559 | void RenderViewImpl::SetZoomLevel(double zoom_level) { |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1560 | // If we change the zoom level for the view, make sure any subsequent subframe |
| 1561 | // loads reflect the current zoom level. |
| 1562 | page_zoom_level_ = zoom_level; |
| 1563 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1564 | webview()->SetZoomLevel(zoom_level); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1565 | for (auto& observer : observers_) |
| 1566 | observer.OnZoomLevelChanged(); |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 1567 | } |
| 1568 | |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1569 | void RenderViewImpl::SetValidationMessageDirection( |
| 1570 | base::string16* wrapped_main_text, |
| 1571 | blink::WebTextDirection main_text_hint, |
| 1572 | base::string16* wrapped_sub_text, |
| 1573 | blink::WebTextDirection sub_text_hint) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1574 | if (main_text_hint == blink::kWebTextDirectionLeftToRight) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1575 | *wrapped_main_text = |
| 1576 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1577 | } else if (main_text_hint == blink::kWebTextDirectionRightToLeft && |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1578 | !base::i18n::IsRTL()) { |
| 1579 | base::i18n::WrapStringWithRTLFormatting(wrapped_main_text); |
| 1580 | } |
| 1581 | |
| 1582 | if (!wrapped_sub_text->empty()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1583 | if (sub_text_hint == blink::kWebTextDirectionLeftToRight) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1584 | *wrapped_sub_text = |
| 1585 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_sub_text); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1586 | } else if (sub_text_hint == blink::kWebTextDirectionRightToLeft) { |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1587 | base::i18n::WrapStringWithRTLFormatting(wrapped_sub_text); |
| 1588 | } |
| 1589 | } |
| 1590 | } |
| 1591 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1592 | void RenderViewImpl::ShowValidationMessage( |
bokan | 72a7e34 | 2015-12-03 15:46:28 | [diff] [blame] | 1593 | const blink::WebRect& anchor_in_viewport, |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1594 | const blink::WebString& main_text, |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1595 | blink::WebTextDirection main_text_hint, |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1596 | const blink::WebString& sub_text, |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1597 | blink::WebTextDirection sub_text_hint) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1598 | base::string16 wrapped_main_text = main_text.Utf16(); |
| 1599 | base::string16 wrapped_sub_text = sub_text.Utf16(); |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1600 | |
| 1601 | SetValidationMessageDirection( |
| 1602 | &wrapped_main_text, main_text_hint, &wrapped_sub_text, sub_text_hint); |
| 1603 | |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1604 | Send(new ViewHostMsg_ShowValidationMessage( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1605 | GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport), |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 1606 | wrapped_main_text, wrapped_sub_text)); |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1607 | } |
| 1608 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1609 | void RenderViewImpl::HideValidationMessage() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1610 | Send(new ViewHostMsg_HideValidationMessage(GetRoutingID())); |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1611 | } |
| 1612 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1613 | void RenderViewImpl::MoveValidationMessage( |
bokan | 72a7e34 | 2015-12-03 15:46:28 | [diff] [blame] | 1614 | const blink::WebRect& anchor_in_viewport) { |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 1615 | Send(new ViewHostMsg_MoveValidationMessage( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1616 | GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport))); |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1617 | } |
| 1618 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1619 | void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 1620 | const GURL& fallback_url) { |
[email protected] | aa6b90b3 | 2010-04-26 15:49:58 | [diff] [blame] | 1621 | GURL latest_url = url.is_empty() ? fallback_url : url; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1622 | if (latest_url == target_url_) |
| 1623 | return; |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1624 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1625 | // Tell the browser to display a destination link. |
| 1626 | if (target_url_status_ == TARGET_INFLIGHT || |
| 1627 | target_url_status_ == TARGET_PENDING) { |
| 1628 | // If we have a request in-flight, save the URL to be sent when we |
| 1629 | // receive an ACK to the in-flight request. We can happily overwrite |
| 1630 | // any existing pending sends. |
| 1631 | pending_target_url_ = latest_url; |
| 1632 | target_url_status_ = TARGET_PENDING; |
| 1633 | } else { |
mnaganov | bf08742 | 2015-12-16 05:10:03 | [diff] [blame] | 1634 | // URLs larger than |kMaxURLChars| cannot be sent through IPC - |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1635 | // see |ParamTraits<GURL>|. |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 1636 | if (latest_url.possibly_invalid_spec().size() > url::kMaxURLChars) |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1637 | latest_url = GURL(); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1638 | Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), latest_url)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1639 | target_url_ = latest_url; |
| 1640 | target_url_status_ = TARGET_INFLIGHT; |
| 1641 | } |
| 1642 | } |
| 1643 | |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 1644 | gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( |
| 1645 | const gfx::RectF& rect) const { |
| 1646 | gfx::RectF window_rect = rect; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1647 | window_rect.Scale(device_scale_factor_ * webview()->PageScaleFactor()); |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 1648 | return window_rect; |
| 1649 | } |
| 1650 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1651 | void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { |
creis | ce0ef357 | 2017-01-26 17:53:08 | [diff] [blame] | 1652 | // Keep track of which frames have pending updates. |
| 1653 | frames_with_pending_state_.insert(frame->GetRoutingID()); |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1654 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1655 | int delay; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1656 | if (send_content_state_immediately_) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1657 | delay = 0; |
| 1658 | else if (is_hidden()) |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1659 | delay = kDelaySecondsForContentStateSyncHidden; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1660 | else |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1661 | delay = kDelaySecondsForContentStateSync; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1662 | |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1663 | if (nav_state_sync_timer_.IsRunning()) { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1664 | // The timer is already running. If the delay of the timer maches the amount |
| 1665 | // we want to delay by, then return. Otherwise stop the timer so that it |
| 1666 | // gets started with the right delay. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1667 | if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1668 | return; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1669 | nav_state_sync_timer_.Stop(); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1670 | } |
| 1671 | |
creis | ce0ef357 | 2017-01-26 17:53:08 | [diff] [blame] | 1672 | // Tell each frame with pending state to inform the browser. |
| 1673 | nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
| 1674 | &RenderViewImpl::SendFrameStateUpdates); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1675 | } |
| 1676 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1677 | void RenderViewImpl::SetMouseOverURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1678 | mouse_over_url_ = GURL(url); |
| 1679 | UpdateTargetURL(mouse_over_url_, focus_url_); |
| 1680 | } |
| 1681 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1682 | void RenderViewImpl::SetKeyboardFocusURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1683 | focus_url_ = GURL(url); |
| 1684 | UpdateTargetURL(focus_url_, mouse_over_url_); |
| 1685 | } |
| 1686 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1687 | bool RenderViewImpl::AcceptsLoadDrops() { |
[email protected] | 28b92df | 2009-09-25 17:35:45 | [diff] [blame] | 1688 | return renderer_preferences_.can_accept_load_drops; |
| 1689 | } |
| 1690 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1691 | void RenderViewImpl::FocusNext() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1692 | Send(new ViewHostMsg_TakeFocus(GetRoutingID(), false)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1693 | } |
| 1694 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1695 | void RenderViewImpl::FocusPrevious() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1696 | Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1697 | } |
| 1698 | |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1699 | // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1700 | void RenderViewImpl::FocusedNodeChanged(const WebNode& fromNode, |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1701 | const WebNode& toNode) { |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1702 | has_scrolled_focused_editable_node_into_rect_ = false; |
| 1703 | |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1704 | RenderFrameImpl* previous_frame = nullptr; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1705 | if (!fromNode.IsNull()) |
| 1706 | previous_frame = |
| 1707 | RenderFrameImpl::FromWebFrame(fromNode.GetDocument().GetFrame()); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1708 | RenderFrameImpl* new_frame = nullptr; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1709 | if (!toNode.IsNull()) |
| 1710 | new_frame = RenderFrameImpl::FromWebFrame(toNode.GetDocument().GetFrame()); |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1711 | |
| 1712 | if (previous_frame && previous_frame != new_frame) |
| 1713 | previous_frame->FocusedNodeChanged(WebNode()); |
| 1714 | if (new_frame) |
| 1715 | new_frame->FocusedNodeChanged(toNode); |
| 1716 | |
| 1717 | // TODO(dmazzoni): remove once there's a separate a11y tree per frame. |
nasko | e8d11575 | 2015-08-07 00:43:13 | [diff] [blame] | 1718 | if (main_render_frame_) |
| 1719 | main_render_frame_->FocusedNodeChangedForAccessibility(toNode); |
[email protected] | 08e9e13 | 2010-06-01 16:58:49 | [diff] [blame] | 1720 | } |
| 1721 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1722 | void RenderViewImpl::DidUpdateLayout() { |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1723 | for (auto& observer : observers_) |
| 1724 | observer.DidUpdateLayout(); |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 1725 | |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 1726 | // We don't always want to set up a timer, only if we've been put in that |
| 1727 | // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 1728 | // message. |
| 1729 | if (!send_preferred_size_changes_ || !webview()) |
| 1730 | return; |
| 1731 | |
| 1732 | if (check_preferred_size_timer_.IsRunning()) |
| 1733 | return; |
| 1734 | check_preferred_size_timer_.Start(FROM_HERE, |
| 1735 | TimeDelta::FromMilliseconds(0), this, |
| 1736 | &RenderViewImpl::CheckPreferredSize); |
| 1737 | } |
| 1738 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1739 | void RenderViewImpl::NavigateBackForwardSoon(int offset) { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1740 | Send(new ViewHostMsg_GoToEntryAtOffset(GetRoutingID(), offset)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1741 | } |
| 1742 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1743 | int RenderViewImpl::HistoryBackListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1744 | return history_list_offset_ < 0 ? 0 : history_list_offset_; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1745 | } |
| 1746 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1747 | int RenderViewImpl::HistoryForwardListCount() { |
| 1748 | return history_list_length_ - HistoryBackListCount() - 1; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1749 | } |
| 1750 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1751 | // blink::WebWidgetClient ---------------------------------------------------- |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1752 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1753 | void RenderViewImpl::DidFocus() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 1754 | // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 1755 | // we won't have to test for user gesture anymore and we can |
| 1756 | // move that code back to render_widget.cc |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1757 | if (WebUserGestureIndicator::IsProcessingUserGesture() && |
[email protected] | 70dee7e | 2013-05-29 18:28:30 | [diff] [blame] | 1758 | !RenderThreadImpl::current()->layout_test_mode()) { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1759 | Send(new ViewHostMsg_Focus(GetRoutingID())); |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 1760 | } |
| 1761 | } |
| 1762 | |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1763 | // We are supposed to get a single call to show() for a newly created RenderView |
| 1764 | // that was created via RenderViewImpl::createView. We wait until this point to |
| 1765 | // run |show_callback|, which is bound to our opener's ShowCreatedViewWidget() |
| 1766 | // method. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1767 | // |
| 1768 | // This method provides us with the information about how to display the newly |
[email protected] | 5f9de588 | 2011-09-30 23:36:28 | [diff] [blame] | 1769 | // created RenderView (i.e., as a blocked popup or as a new tab). |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1770 | void RenderViewImpl::Show(WebNavigationPolicy policy) { |
nick | f7b3822 | 2016-11-22 21:59:35 | [diff] [blame] | 1771 | if (did_show_ && !webkit_preferences_.supports_multiple_windows) { |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 1772 | // When supports_multiple_windows is disabled, popups are reusing |
| 1773 | // the same view. In some scenarios, this makes WebKit to call show() twice. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1774 | return; |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 1775 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1776 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1777 | RenderWidget::Show(policy); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1778 | } |
| 1779 | |
miletus | e8d28ba | 2015-06-19 04:52:04 | [diff] [blame] | 1780 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1781 | bool RenderViewImpl::CanHandleGestureEvent() { |
slangley | 1a6375e6 | 2017-03-29 06:03:23 | [diff] [blame] | 1782 | return true; |
| 1783 | } |
| 1784 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1785 | bool RenderViewImpl::CanUpdateLayout() { |
slangley | 1a6375e6 | 2017-03-29 06:03:23 | [diff] [blame] | 1786 | return true; |
| 1787 | } |
| 1788 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1789 | void RenderViewImpl::DidHandleGestureEvent(const WebGestureEvent& event, |
| 1790 | bool event_cancelled) { |
| 1791 | RenderWidget::DidHandleGestureEvent(event, event_cancelled); |
[email protected] | bb37b65 | 2013-11-27 23:47:11 | [diff] [blame] | 1792 | |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 1793 | if (!event_cancelled) { |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 1794 | for (auto& observer : observers_) |
| 1795 | observer.DidHandleGestureEvent(event); |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 1796 | } |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 1797 | } |
| 1798 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1799 | blink::WebLayerTreeView* RenderViewImpl::InitializeLayerTreeView() { |
wjmaclean | 1d97062 | 2017-01-21 22:28:24 | [diff] [blame] | 1800 | // TODO(!wjmaclean): We should be able to just remove this function, and |
| 1801 | // expect the RenderWidget version of the function to be called instead. |
| 1802 | // However, we have a diamond inheritance pattern going on: |
| 1803 | // WebWidgetClient |
| 1804 | // | | |
| 1805 | // RenderWidget WebViewClient |
| 1806 | // | | |
| 1807 | // RenderViewImpl |
| 1808 | // |
| 1809 | // and this seems to prefer calling the empty version in WebWidgetClient |
| 1810 | // or WebViewClient over the non-empty one in RenderWidget. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1811 | return RenderWidget::InitializeLayerTreeView(); |
[email protected] | 6e89eb7 | 2013-07-23 13:28:22 | [diff] [blame] | 1812 | } |
| 1813 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1814 | void RenderViewImpl::CloseWidgetSoon() { |
| 1815 | RenderWidget::CloseWidgetSoon(); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1816 | } |
| 1817 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1818 | void RenderViewImpl::ConvertViewportToWindow(blink::WebRect* rect) { |
| 1819 | RenderWidget::ConvertViewportToWindow(rect); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1820 | } |
| 1821 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1822 | void RenderViewImpl::ConvertWindowToViewport(blink::WebFloatRect* rect) { |
| 1823 | RenderWidget::ConvertWindowToViewport(rect); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1824 | } |
| 1825 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1826 | void RenderViewImpl::DidAutoResize(const blink::WebSize& newSize) { |
lfg | b00fcad | 2016-07-14 14:16:33 | [diff] [blame] | 1827 | RenderWidget::DidAutoResize(newSize); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1828 | } |
| 1829 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1830 | void RenderViewImpl::DidOverscroll( |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1831 | const blink::WebFloatSize& overscrollDelta, |
| 1832 | const blink::WebFloatSize& accumulatedOverscroll, |
| 1833 | const blink::WebFloatPoint& positionInViewport, |
| 1834 | const blink::WebFloatSize& velocityInViewport) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1835 | RenderWidget::DidOverscroll(overscrollDelta, accumulatedOverscroll, |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1836 | positionInViewport, velocityInViewport); |
| 1837 | } |
| 1838 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1839 | void RenderViewImpl::HasTouchEventHandlers(bool has_handlers) { |
| 1840 | RenderWidget::HasTouchEventHandlers(has_handlers); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1841 | } |
| 1842 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1843 | blink::WebRect RenderViewImpl::RootWindowRect() { |
| 1844 | return RenderWidget::WindowRect(); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1845 | } |
| 1846 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1847 | blink::WebScreenInfo RenderViewImpl::GetScreenInfo() { |
| 1848 | return RenderWidget::GetScreenInfo(); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1849 | } |
| 1850 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1851 | void RenderViewImpl::SetToolTipText(const blink::WebString& text, |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1852 | blink::WebTextDirection hint) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1853 | RenderWidget::SetToolTipText(text, hint); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1854 | } |
| 1855 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1856 | void RenderViewImpl::SetTouchAction(blink::WebTouchAction touchAction) { |
| 1857 | RenderWidget::SetTouchAction(touchAction); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1858 | } |
| 1859 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1860 | void RenderViewImpl::ShowUnhandledTapUIIfNeeded( |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1861 | const blink::WebPoint& tappedPosition, |
| 1862 | const blink::WebNode& tappedNode, |
| 1863 | bool pageChanged) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1864 | RenderWidget::ShowUnhandledTapUIIfNeeded(tappedPosition, tappedNode, |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 1865 | pageChanged); |
| 1866 | } |
| 1867 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1868 | blink::WebWidgetClient* RenderViewImpl::WidgetClient() { |
lfg | 0f44062 | 2016-07-20 04:27:14 | [diff] [blame] | 1869 | return static_cast<RenderWidget*>(this); |
| 1870 | } |
| 1871 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1872 | // blink::WebFrameClient ----------------------------------------------------- |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1873 | |
[email protected] | 5e92282f | 2012-08-17 08:11:57 | [diff] [blame] | 1874 | void RenderViewImpl::Repaint(const gfx::Size& size) { |
[email protected] | 3d9ec505 | 2013-01-02 22:05:25 | [diff] [blame] | 1875 | OnRepaint(size); |
[email protected] | 5e92282f | 2012-08-17 08:11:57 | [diff] [blame] | 1876 | } |
| 1877 | |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1878 | void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name, |
| 1879 | const std::string& value) { |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 1880 | GetWidget()->SetEditCommandForNextKeyEvent(name, value); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1881 | } |
| 1882 | |
| 1883 | void RenderViewImpl::ClearEditCommands() { |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 1884 | GetWidget()->ClearEditCommands(); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 1885 | } |
| 1886 | |
[email protected] | b38806a | 2013-10-04 16:01:38 | [diff] [blame] | 1887 | const std::string& RenderViewImpl::GetAcceptLanguages() const { |
| 1888 | return renderer_preferences_.accept_languages; |
| 1889 | } |
| 1890 | |
danakj | dea2efb | 2016-03-10 19:13:17 | [diff] [blame] | 1891 | void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1892 | ConvertViewportToWindow(rect); |
oshima | e2b3b40 | 2015-12-04 04:27:24 | [diff] [blame] | 1893 | } |
| 1894 | |
huangs | 2a34235 | 2015-12-15 16:59:24 | [diff] [blame] | 1895 | gfx::RectF RenderViewImpl::ElementBoundsInWindow( |
| 1896 | const blink::WebElement& element) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1897 | blink::WebRect bounding_box_in_window = element.BoundsInViewport(); |
danakj | dea2efb | 2016-03-10 19:13:17 | [diff] [blame] | 1898 | ConvertViewportToWindowViaWidget(&bounding_box_in_window); |
huangs | 2a34235 | 2015-12-15 16:59:24 | [diff] [blame] | 1899 | return gfx::RectF(bounding_box_in_window); |
| 1900 | } |
| 1901 | |
changwan | d659e20 | 2016-06-13 02:39:12 | [diff] [blame] | 1902 | bool RenderViewImpl::HasAddedInputHandler() const { |
| 1903 | return has_added_input_handler_; |
| 1904 | } |
| 1905 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 1906 | void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 1907 | WebIconURL::Type icon_type) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1908 | if (frame->Parent()) |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 1909 | return; |
| 1910 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1911 | WebVector<WebIconURL> icon_urls = frame->IconURLs(icon_type); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 1912 | std::vector<FaviconURL> urls; |
| 1913 | for (size_t i = 0; i < icon_urls.size(); i++) { |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 1914 | std::vector<gfx::Size> sizes; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1915 | ConvertToFaviconSizes(icon_urls[i].Sizes(), &sizes); |
| 1916 | urls.push_back(FaviconURL(icon_urls[i].GetIconURL(), |
| 1917 | ToFaviconType(icon_urls[i].IconType()), sizes)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 1918 | } |
| 1919 | SendUpdateFaviconURL(urls); |
[email protected] | 5019ef1 | 2010-04-27 17:26:58 | [diff] [blame] | 1920 | } |
| 1921 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1922 | void RenderViewImpl::CheckPreferredSize() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 1923 | // We don't always want to send the change messages over IPC, only if we've |
| 1924 | // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 1925 | // message. |
| 1926 | if (!send_preferred_size_changes_ || !webview()) |
| 1927 | return; |
| 1928 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1929 | gfx::Size size = webview()->ContentsPreferredMinimumSize(); |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 1930 | if (size == preferred_size_) |
| 1931 | return; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 1932 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 1933 | preferred_size_ = size; |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1934 | Send(new ViewHostMsg_DidContentsPreferredSizeChange(GetRoutingID(), |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 1935 | preferred_size_)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1936 | } |
| 1937 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1938 | blink::WebString RenderViewImpl::AcceptLanguages() { |
| 1939 | return WebString::FromUTF8(renderer_preferences_.accept_languages); |
[email protected] | 9982c80 | 2013-06-12 15:22:06 | [diff] [blame] | 1940 | } |
| 1941 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1942 | // RenderView implementation --------------------------------------------------- |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1943 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1944 | bool RenderViewImpl::Send(IPC::Message* message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1945 | return RenderWidget::Send(message); |
| 1946 | } |
| 1947 | |
avi | 8a45c109 | 2016-03-01 16:12:34 | [diff] [blame] | 1948 | RenderWidget* RenderViewImpl::GetWidget() const { |
| 1949 | return const_cast<RenderWidget*>(static_cast<const RenderWidget*>(this)); |
| 1950 | } |
| 1951 | |
mostynb | c3335323 | 2014-09-12 09:38:31 | [diff] [blame] | 1952 | RenderFrameImpl* RenderViewImpl::GetMainRenderFrame() { |
nasko | 77de231 | 2015-05-12 03:09:16 | [diff] [blame] | 1953 | return main_render_frame_; |
[email protected] | b849847b | 2013-12-10 21:57:58 | [diff] [blame] | 1954 | } |
| 1955 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 1956 | int RenderViewImpl::GetRoutingID() const { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1957 | return routing_id(); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1958 | } |
| 1959 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 1960 | gfx::Size RenderViewImpl::GetSize() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1961 | return size(); |
| 1962 | } |
| 1963 | |
oshima | 129b75e | 2016-01-14 09:15:14 | [diff] [blame] | 1964 | float RenderViewImpl::GetDeviceScaleFactor() const { |
| 1965 | return device_scale_factor_; |
| 1966 | } |
| 1967 | |
thestig | 8a8fdfd3 | 2017-05-06 18:46:54 | [diff] [blame] | 1968 | const WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1969 | return webkit_preferences_; |
| 1970 | } |
| 1971 | |
[email protected] | 324825d | 2012-11-30 12:37:15 | [diff] [blame] | 1972 | void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { |
| 1973 | OnUpdateWebPreferences(preferences); |
| 1974 | } |
| 1975 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1976 | blink::WebView* RenderViewImpl::GetWebView() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1977 | return webview(); |
| 1978 | } |
| 1979 | |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 1980 | blink::WebFrameWidget* RenderViewImpl::GetWebFrameWidget() { |
| 1981 | return frame_widget_; |
| 1982 | } |
| 1983 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1984 | bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1985 | return (!send_preferred_size_changes_ || |
| 1986 | (disable_scrollbars_size_limit_.width() <= width || |
| 1987 | disable_scrollbars_size_limit_.height() <= height)); |
| 1988 | } |
| 1989 | |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1990 | bool RenderViewImpl::GetContentStateImmediately() const { |
| 1991 | return send_content_state_immediately_; |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1992 | } |
| 1993 | |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 1994 | void RenderViewImpl::OnSetPageScale(float page_scale_factor) { |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 1995 | if (!webview()) |
| 1996 | return; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 1997 | webview()->SetPageScaleFactor(page_scale_factor); |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 1998 | } |
| 1999 | |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 2000 | void RenderViewImpl::OnSetZoomLevel( |
| 2001 | PageMsg_SetZoomLevel_Command command, |
| 2002 | double zoom_level) { |
| 2003 | switch (command) { |
| 2004 | case PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY: |
| 2005 | uses_temporary_zoom_level_ = false; |
| 2006 | break; |
| 2007 | case PageMsg_SetZoomLevel_Command::SET_TEMPORARY: |
| 2008 | uses_temporary_zoom_level_ = true; |
| 2009 | break; |
| 2010 | case PageMsg_SetZoomLevel_Command::USE_CURRENT_TEMPORARY_MODE: |
| 2011 | // Don't override a temporary zoom level without an explicit SET. |
| 2012 | if (uses_temporary_zoom_level_) |
| 2013 | return; |
| 2014 | break; |
| 2015 | default: |
| 2016 | NOTIMPLEMENTED(); |
| 2017 | } |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2018 | webview()->HidePopups(); |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 2019 | SetZoomLevel(zoom_level); |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 2020 | } |
| 2021 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2022 | void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 2023 | webkit_preferences_ = prefs; |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 2024 | ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2025 | } |
| 2026 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2027 | void RenderViewImpl::OnEnumerateDirectoryResponse( |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2028 | int id, |
[email protected] | c42de73 | 2013-02-16 06:26:31 | [diff] [blame] | 2029 | const std::vector<base::FilePath>& paths) { |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2030 | if (!enumeration_completions_[id]) |
| 2031 | return; |
| 2032 | |
| 2033 | WebVector<WebString> ws_file_names(paths.size()); |
| 2034 | for (size_t i = 0; i < paths.size(); ++i) |
kinuko | a429302 | 2017-01-27 06:43:25 | [diff] [blame] | 2035 | ws_file_names[i] = blink::FilePathToWebString(paths[i]); |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2036 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2037 | enumeration_completions_[id]->DidChooseFile(ws_file_names); |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2038 | enumeration_completions_.erase(id); |
| 2039 | } |
| 2040 | |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 2041 | void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, |
| 2042 | const gfx::Size& max_size) { |
| 2043 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 2044 | if (!webview()) |
| 2045 | return; |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2046 | |
[email protected] | 97e1bf7 | 2013-03-06 14:06:05 | [diff] [blame] | 2047 | auto_resize_mode_ = true; |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2048 | if (IsUseZoomForDSFEnabled()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2049 | webview()->EnableAutoResizeMode( |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2050 | gfx::ScaleToCeiledSize(min_size, device_scale_factor_), |
| 2051 | gfx::ScaleToCeiledSize(max_size, device_scale_factor_)); |
| 2052 | } else { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2053 | webview()->EnableAutoResizeMode(min_size, max_size); |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2054 | } |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 2055 | } |
| 2056 | |
| 2057 | void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) { |
| 2058 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 2059 | if (!webview()) |
| 2060 | return; |
[email protected] | 97e1bf7 | 2013-03-06 14:06:05 | [diff] [blame] | 2061 | auto_resize_mode_ = false; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2062 | webview()->DisableAutoResizeMode(); |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 2063 | |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2064 | if (!new_size.IsEmpty()) { |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 2065 | ResizeParams resize_params; |
jbroman | 5ff1030 | 2016-07-22 03:36:26 | [diff] [blame] | 2066 | resize_params.screen_info = screen_info_; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 2067 | resize_params.new_size = new_size; |
| 2068 | resize_params.physical_backing_size = physical_backing_size_; |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 2069 | resize_params.browser_controls_shrink_blink_size = |
| 2070 | browser_controls_shrink_blink_size_; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 2071 | resize_params.top_controls_height = top_controls_height_; |
| 2072 | resize_params.visible_viewport_size = visible_viewport_size_; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 2073 | resize_params.is_fullscreen_granted = is_fullscreen_granted(); |
| 2074 | resize_params.display_mode = display_mode_; |
| 2075 | resize_params.needs_resize_ack = false; |
| 2076 | Resize(resize_params); |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2077 | } |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 2078 | } |
| 2079 | |
[email protected] | 2bf834f | 2011-11-17 20:02:21 | [diff] [blame] | 2080 | void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 2081 | if (send_preferred_size_changes_) |
| 2082 | return; |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 2083 | send_preferred_size_changes_ = true; |
[email protected] | 770dd8b | 2010-05-24 18:11:39 | [diff] [blame] | 2084 | |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 2085 | // Start off with an initial preferred size notification (in case |
| 2086 | // |didUpdateLayout| was already called). |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2087 | DidUpdateLayout(); |
[email protected] | 0666aef | 2009-05-13 19:48:08 | [diff] [blame] | 2088 | } |
| 2089 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2090 | void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2091 | const gfx::Size& disable_scrollbar_size_limit) { |
| 2092 | disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
| 2093 | } |
| 2094 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2095 | void RenderViewImpl::OnSetRendererPrefs( |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2096 | const RendererPreferences& renderer_prefs) { |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 2097 | std::string old_accept_languages = renderer_preferences_.accept_languages; |
| 2098 | |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 2099 | renderer_preferences_ = renderer_prefs; |
ananta | 59b9fe7 | 2015-04-07 01:33:26 | [diff] [blame] | 2100 | |
[email protected] | 6e282c9 | 2009-07-24 01:19:37 | [diff] [blame] | 2101 | UpdateFontRenderingFromRendererPrefs(); |
scottmg | b92365e | 2016-08-30 20:54:40 | [diff] [blame] | 2102 | UpdateThemePrefs(); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2103 | blink::SetCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
[email protected] | 38a8571 | 2013-01-02 22:45:02 | [diff] [blame] | 2104 | |
brettw | 8a274fa | 2016-11-15 00:20:40 | [diff] [blame] | 2105 | #if BUILDFLAG(USE_DEFAULT_RENDER_THEME) |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2106 | if (renderer_prefs.use_custom_colors) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2107 | blink::SetFocusRingColor(renderer_prefs.focus_ring_color); |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2108 | |
| 2109 | if (webview()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2110 | webview()->SetSelectionColors(renderer_prefs.active_selection_bg_color, |
| 2111 | renderer_prefs.active_selection_fg_color, |
| 2112 | renderer_prefs.inactive_selection_bg_color, |
| 2113 | renderer_prefs.inactive_selection_fg_color); |
| 2114 | webview()->ThemeChanged(); |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2115 | } |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 2116 | } |
brettw | 8a274fa | 2016-11-15 00:20:40 | [diff] [blame] | 2117 | #endif // BUILDFLAG(USE_DEFAULT_RENDER_THEME) |
[email protected] | d299d97 | 2012-03-23 02:26:55 | [diff] [blame] | 2118 | |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 2119 | if (webview() && |
| 2120 | old_accept_languages != renderer_preferences_.accept_languages) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2121 | webview()->AcceptLanguagesChanged(); |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 2122 | } |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 2123 | } |
| 2124 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2125 | void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
| 2126 | const WebMediaPlayerAction& action) { |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 2127 | if (webview()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2128 | webview()->PerformMediaPlayerAction(action, location); |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 2129 | } |
| 2130 | |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 2131 | void RenderViewImpl::OnPluginActionAt(const gfx::Point& location, |
| 2132 | const WebPluginAction& action) { |
| 2133 | if (webview()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2134 | webview()->PerformPluginAction(action, location); |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 2135 | } |
| 2136 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2137 | void RenderViewImpl::OnClosePage() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2138 | // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 2139 | // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 2140 | // in the onunload handler from appearing. For now, we're bypassing that and |
| 2141 | // calling the FrameLoader's CloseURL method directly. This should be |
| 2142 | // revisited to avoid having two ways to close a page. Having a single way |
| 2143 | // to close that can run onunload is also useful for fixing |
| 2144 | // http://b/issue?id=753080. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2145 | webview()->MainFrame()->DispatchUnloadEvent(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2146 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2147 | Send(new ViewHostMsg_ClosePage_ACK(GetRoutingID())); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2148 | } |
| 2149 | |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 2150 | void RenderViewImpl::OnClose() { |
| 2151 | if (closing_) |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2152 | RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 2153 | RenderWidget::OnClose(); |
| 2154 | } |
| 2155 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2156 | void RenderViewImpl::OnMoveOrResizeStarted() { |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2157 | if (webview()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2158 | webview()->HidePopups(); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2159 | } |
| 2160 | |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 2161 | void RenderViewImpl::ResizeWebWidget() { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2162 | webview()->ResizeWithBrowserControls(GetSizeForWebWidget(), |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 2163 | top_controls_height_, |
| 2164 | browser_controls_shrink_blink_size_); |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 2165 | } |
| 2166 | |
fsamuel | 664e8b6 | 2016-01-20 19:54:01 | [diff] [blame] | 2167 | void RenderViewImpl::OnResize(const ResizeParams& params) { |
[email protected] | 189a886 | 2014-07-18 00:27:53 | [diff] [blame] | 2168 | TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2169 | if (webview()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2170 | webview()->HidePopups(); |
kenrb | 5fd60fb8 | 2016-06-10 17:27:57 | [diff] [blame] | 2171 | if (send_preferred_size_changes_ && |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2172 | webview()->MainFrame()->IsWebLocalFrame()) { |
lukasza | 302fcdd | 2017-06-02 20:40:35 | [diff] [blame] | 2173 | webview()->MainFrame()->ToWebLocalFrame()->SetCanHaveScrollbars( |
| 2174 | ShouldDisplayScrollbars(params.new_size.width(), |
| 2175 | params.new_size.height())); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2176 | } |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 2177 | if (display_mode_ != params.display_mode) { |
| 2178 | display_mode_ = params.display_mode; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2179 | webview()->SetDisplayMode(display_mode_); |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 2180 | } |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2181 | } |
| 2182 | |
[email protected] | cbbdeef | 2014-05-26 15:57:36 | [diff] [blame] | 2183 | gfx::Size old_visible_viewport_size = visible_viewport_size_; |
| 2184 | |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 2185 | browser_controls_shrink_blink_size_ = |
| 2186 | params.browser_controls_shrink_blink_size; |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 2187 | top_controls_height_ = params.top_controls_height; |
| 2188 | |
[email protected] | 0fdd501 | 2013-05-29 08:05:56 | [diff] [blame] | 2189 | RenderWidget::OnResize(params); |
[email protected] | cbbdeef | 2014-05-26 15:57:36 | [diff] [blame] | 2190 | |
| 2191 | if (old_visible_viewport_size != visible_viewport_size_) |
| 2192 | has_scrolled_focused_editable_node_into_rect_ = false; |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2193 | } |
[email protected] | 0aa477bd | 2009-03-23 22:21:43 | [diff] [blame] | 2194 | |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 2195 | void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
eseckler | f2bd55f7 | 2017-03-31 09:11:57 | [diff] [blame] | 2196 | if (!frame_widget_) |
| 2197 | return; |
| 2198 | |
| 2199 | if (opaque) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2200 | frame_widget_->ClearBaseBackgroundColorOverride(); |
| 2201 | frame_widget_->ClearBackgroundColorOverride(); |
eseckler | f2bd55f7 | 2017-03-31 09:11:57 | [diff] [blame] | 2202 | } else { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2203 | frame_widget_->SetBaseBackgroundColorOverride(SK_ColorTRANSPARENT); |
| 2204 | frame_widget_->SetBackgroundColorOverride(SK_ColorTRANSPARENT); |
eseckler | f2bd55f7 | 2017-03-31 09:11:57 | [diff] [blame] | 2205 | } |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 2206 | } |
| 2207 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2208 | void RenderViewImpl::OnSetActive(bool active) { |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 2209 | if (webview()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2210 | webview()->SetIsActive(active); |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 2211 | } |
| 2212 | |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 2213 | blink::WebWidget* RenderViewImpl::GetWebWidget() const { |
| 2214 | if (frame_widget_) |
| 2215 | return frame_widget_; |
| 2216 | |
| 2217 | return RenderWidget::GetWebWidget(); |
| 2218 | } |
| 2219 | |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 2220 | void RenderViewImpl::CloseForFrame() { |
| 2221 | DCHECK(frame_widget_); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2222 | frame_widget_->Close(); |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 2223 | frame_widget_ = nullptr; |
| 2224 | } |
| 2225 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2226 | void RenderViewImpl::Close() { |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 2227 | // We need to grab a pointer to the doomed WebView before we destroy it. |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 2228 | WebView* doomed = webview_; |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 2229 | RenderWidget::Close(); |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 2230 | webview_ = nullptr; |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 2231 | g_view_map.Get().erase(doomed); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2232 | g_routing_id_view_map.Get().erase(GetRoutingID()); |
| 2233 | RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 2234 | } |
| 2235 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2236 | void RenderViewImpl::OnPageWasHidden() { |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2237 | #if defined(OS_ANDROID) |
| 2238 | SuspendVideoCaptureDevices(true); |
| 2239 | #if BUILDFLAG(ENABLE_WEBRTC) |
[email protected] | e976c3c5 | 2014-07-24 17:41:55 | [diff] [blame] | 2240 | if (speech_recognition_dispatcher_) |
| 2241 | speech_recognition_dispatcher_->AbortAllRecognitions(); |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 2242 | #endif |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2243 | #endif |
[email protected] | 2d7b82c | 2012-06-01 05:57:50 | [diff] [blame] | 2244 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2245 | if (webview()) { |
| 2246 | // TODO(lfg): It's not correct to defer the page visibility to the main |
| 2247 | // frame. Currently, this is done because the main frame may override the |
| 2248 | // visibility of the page when prerendering. In order to fix this, |
| 2249 | // prerendering must be made aware of OOPIFs. https://crbug.com/440544 |
| 2250 | blink::WebPageVisibilityState visibilityState = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2251 | GetMainRenderFrame() ? GetMainRenderFrame()->VisibilityState() |
| 2252 | : blink::kWebPageVisibilityStateHidden; |
| 2253 | webview()->SetVisibilityState(visibilityState, false); |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2254 | } |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 2255 | } |
| 2256 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2257 | void RenderViewImpl::OnPageWasShown() { |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2258 | #if defined(OS_ANDROID) |
| 2259 | SuspendVideoCaptureDevices(false); |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 2260 | #endif |
| 2261 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2262 | if (webview()) { |
| 2263 | blink::WebPageVisibilityState visibilityState = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2264 | GetMainRenderFrame() ? GetMainRenderFrame()->VisibilityState() |
| 2265 | : blink::kWebPageVisibilityStateVisible; |
| 2266 | webview()->SetVisibilityState(visibilityState, false); |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2267 | } |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 2268 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 2269 | |
lfg | 8d649cc | 2017-04-28 18:04:30 | [diff] [blame] | 2270 | void RenderViewImpl::OnUpdateScreenInfo(const ScreenInfo& screen_info) { |
| 2271 | // This IPC only updates the screen info on RenderViews that have a remote |
| 2272 | // main frame. For local main frames, the ScreenInfo is updated in |
| 2273 | // ViewMsg_Resize. |
| 2274 | if (!main_render_frame_) |
| 2275 | screen_info_ = screen_info; |
| 2276 | } |
| 2277 | |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 2278 | GURL RenderViewImpl::GetURLForGraphicsContext3D() { |
| 2279 | DCHECK(webview()); |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2280 | if (webview()->MainFrame()->IsWebLocalFrame()) |
| 2281 | return GURL(webview()->MainFrame()->GetDocument().Url()); |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 2282 | else |
| 2283 | return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 2284 | } |
| 2285 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2286 | void RenderViewImpl::OnSetFocus(bool enable) { |
nasko | c6edf7e | 2015-10-16 01:48:45 | [diff] [blame] | 2287 | // This message must always be received when the main frame is a |
| 2288 | // WebLocalFrame. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2289 | CHECK(webview()->MainFrame()->IsWebLocalFrame()); |
alexmos | 3fcd0ca | 2015-10-23 18:18:33 | [diff] [blame] | 2290 | SetFocus(enable); |
| 2291 | } |
alexmos | 7fac9aeb | 2015-10-16 22:39:49 | [diff] [blame] | 2292 | |
alexmos | 3fcd0ca | 2015-10-23 18:18:33 | [diff] [blame] | 2293 | void RenderViewImpl::SetFocus(bool enable) { |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 2294 | RenderWidget::OnSetFocus(enable); |
| 2295 | |
[email protected] | 32103299 | 2012-11-08 01:01:27 | [diff] [blame] | 2296 | // Notify all BrowserPlugins of the RenderView's focus state. |
fsamuel | 6c1dfeb | 2014-12-18 19:21:33 | [diff] [blame] | 2297 | if (BrowserPluginManager::Get()) |
| 2298 | BrowserPluginManager::Get()->UpdateFocusState(); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 2299 | } |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 2300 | |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 2301 | void RenderViewImpl::DidCompletePageScaleAnimation() { |
ekaramad | 27ca69b1 | 2017-04-20 18:34:29 | [diff] [blame] | 2302 | if (auto* focused_frame = GetWebView()->FocusedFrame()) { |
| 2303 | if (focused_frame->AutofillClient()) |
| 2304 | focused_frame->AutofillClient()->DidCompleteFocusChangeInFrame(); |
| 2305 | } |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 2306 | } |
| 2307 | |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 2308 | void RenderViewImpl::OnDeviceScaleFactorChanged() { |
| 2309 | RenderWidget::OnDeviceScaleFactorChanged(); |
| 2310 | UpdateWebViewWithDeviceScaleFactor(); |
| 2311 | if (auto_resize_mode_) |
| 2312 | AutoResizeCompositor(); |
| 2313 | } |
| 2314 | |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 2315 | void RenderViewImpl::SetScreenMetricsEmulationParameters( |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 2316 | bool enabled, |
| 2317 | const blink::WebDeviceEmulationParams& params) { |
[email protected] | 404630b | 2014-07-03 19:33:03 | [diff] [blame] | 2318 | if (webview() && compositor()) { |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 2319 | if (enabled) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2320 | webview()->EnableDeviceEmulation(params); |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 2321 | else |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2322 | webview()->DisableDeviceEmulation(); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 2323 | } |
| 2324 | } |
| 2325 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2326 | blink::WebSpeechRecognizer* RenderViewImpl::SpeechRecognizer() { |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 2327 | if (!speech_recognition_dispatcher_) |
| 2328 | speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 2329 | return speech_recognition_dispatcher_; |
| 2330 | } |
| 2331 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2332 | void RenderViewImpl::ZoomLimitsChanged(double minimum_level, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2333 | double maximum_level) { |
a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 2334 | // Round the double to avoid returning incorrect minimum/maximum zoom |
| 2335 | // percentages. |
| 2336 | int minimum_percent = round( |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 2337 | ZoomLevelToZoomFactor(minimum_level) * 100); |
a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 2338 | int maximum_percent = round( |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 2339 | ZoomLevelToZoomFactor(maximum_level) * 100); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2340 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2341 | Send(new ViewHostMsg_UpdateZoomLimits(GetRoutingID(), minimum_percent, |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2342 | maximum_percent)); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2343 | } |
| 2344 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2345 | void RenderViewImpl::PageScaleFactorChanged() { |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2346 | if (!webview()) |
| 2347 | return; |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 2348 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2349 | Send(new ViewHostMsg_PageScaleFactorChanged(GetRoutingID(), |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2350 | webview()->PageScaleFactor())); |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2351 | } |
| 2352 | |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 2353 | double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { |
| 2354 | return ZoomLevelToZoomFactor(zoom_level); |
| 2355 | } |
| 2356 | |
| 2357 | double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { |
| 2358 | return ZoomFactorToZoomLevel(factor); |
| 2359 | } |
| 2360 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2361 | void RenderViewImpl::DraggableRegionsChanged() { |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 2362 | for (auto& observer : observers_) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2363 | observer.DraggableRegionsChanged(webview()->MainFrame()); |
[email protected] | a0629af9 | 2012-08-08 00:39:37 | [diff] [blame] | 2364 | } |
| 2365 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2366 | void RenderViewImpl::PageImportanceSignalsChanged() { |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 2367 | if (!webview() || !main_render_frame_) |
| 2368 | return; |
| 2369 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2370 | auto* web_signals = webview()->PageImportanceSignals(); |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 2371 | |
| 2372 | PageImportanceSignals signals; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2373 | signals.had_form_interaction = web_signals->HadFormInteraction(); |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 2374 | |
| 2375 | main_render_frame_->Send(new FrameHostMsg_UpdatePageImportanceSignals( |
| 2376 | main_render_frame_->GetRoutingID(), signals)); |
| 2377 | } |
| 2378 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2379 | #if defined(OS_ANDROID) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2380 | bool RenderViewImpl::OpenDateTimeChooser( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2381 | const blink::WebDateTimeChooserParams& params, |
| 2382 | blink::WebDateTimeChooserCompletion* completion) { |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 2383 | // JavaScript may try to open a date time chooser while one is already open. |
| 2384 | if (date_time_picker_client_) |
| 2385 | return false; |
[email protected] | b18583c | 2012-12-18 06:55:27 | [diff] [blame] | 2386 | date_time_picker_client_.reset( |
| 2387 | new RendererDateTimePicker(this, params, completion)); |
| 2388 | return date_time_picker_client_->Open(); |
| 2389 | } |
| 2390 | |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 2391 | void RenderViewImpl::DismissDateTimeDialog() { |
| 2392 | DCHECK(date_time_picker_client_); |
| 2393 | date_time_picker_client_.reset(NULL); |
| 2394 | } |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 2395 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2396 | bool RenderViewImpl::DidTapMultipleTargets( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2397 | const WebSize& inner_viewport_offset, |
| 2398 | const WebRect& touch_rect, |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2399 | const WebVector<WebRect>& target_rects) { |
[email protected] | 8d3dfee6 | 2013-06-19 05:50:33 | [diff] [blame] | 2400 | // Never show a disambiguation popup when accessibility is enabled, |
| 2401 | // as this interferes with "touch exploration". |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 2402 | AccessibilityMode accessibility_mode = |
mostynb | c3335323 | 2014-09-12 09:38:31 | [diff] [blame] | 2403 | GetMainRenderFrame()->accessibility_mode(); |
dougt | cd3dad73 | 2017-03-14 03:26:23 | [diff] [blame] | 2404 | if (accessibility_mode == kAccessibilityModeComplete) |
[email protected] | 8d3dfee6 | 2013-06-19 05:50:33 | [diff] [blame] | 2405 | return false; |
| 2406 | |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2407 | // The touch_rect, target_rects and zoom_rect are in the outer viewport |
| 2408 | // reference frame. |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2409 | gfx::Rect zoom_rect; |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 2410 | float new_total_scale = |
| 2411 | DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2412 | touch_rect, target_rects, GetSize(), |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2413 | gfx::Rect(webview()->MainFrame()->VisibleContentRect()).size(), |
| 2414 | device_scale_factor_ * webview()->PageScaleFactor(), &zoom_rect); |
jbauman | 0ed0918 | 2015-01-30 22:33:49 | [diff] [blame] | 2415 | if (!new_total_scale || zoom_rect.IsEmpty()) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2416 | return false; |
| 2417 | |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 2418 | bool handled = false; |
| 2419 | switch (renderer_preferences_.tap_multiple_targets_strategy) { |
| 2420 | case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2421 | handled = webview()->ZoomToMultipleTargetsRect(zoom_rect); |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 2422 | break; |
| 2423 | case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: { |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2424 | gfx::Size canvas_size = |
danakj | ddaec91 | 2015-09-25 19:38:40 | [diff] [blame] | 2425 | gfx::ScaleToCeiledSize(zoom_rect.size(), new_total_scale); |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2426 | cc::SharedBitmapManager* manager = |
| 2427 | RenderThreadImpl::current()->shared_bitmap_manager(); |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 2428 | std::unique_ptr<cc::SharedBitmap> shared_bitmap = |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2429 | manager->AllocateSharedBitmap(canvas_size); |
jbauman | 0ed0918 | 2015-01-30 22:33:49 | [diff] [blame] | 2430 | CHECK(!!shared_bitmap); |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2431 | { |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2432 | SkBitmap bitmap; |
| 2433 | SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(), |
| 2434 | canvas_size.height()); |
| 2435 | bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes()); |
enne | 98c9f805 | 2017-03-15 19:38:22 | [diff] [blame] | 2436 | cc::SkiaPaintCanvas canvas(bitmap); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2437 | |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2438 | // TODO(trchen): Cleanup the device scale factor mess. |
| 2439 | // device scale will be applied in WebKit |
| 2440 | // --> zoom_rect doesn't include device scale, |
| 2441 | // but WebKit will still draw on zoom_rect * device_scale_factor_ |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2442 | canvas.scale(new_total_scale / device_scale_factor_, |
| 2443 | new_total_scale / device_scale_factor_); |
| 2444 | canvas.translate(-zoom_rect.x() * device_scale_factor_, |
| 2445 | -zoom_rect.y() * device_scale_factor_); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2446 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2447 | DCHECK(webview_->IsAcceleratedCompositingActive()); |
| 2448 | webview_->PaintIgnoringCompositing(&canvas, zoom_rect); |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2449 | } |
| 2450 | |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2451 | gfx::Rect zoom_rect_in_screen = |
| 2452 | zoom_rect - gfx::Vector2d(inner_viewport_offset.width, |
| 2453 | inner_viewport_offset.height); |
| 2454 | |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2455 | gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2456 | ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect_in_screen))); |
| 2457 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2458 | Send(new ViewHostMsg_ShowDisambiguationPopup( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2459 | GetRoutingID(), physical_window_zoom_rect, canvas_size, |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2460 | shared_bitmap->id())); |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2461 | cc::SharedBitmapId id = shared_bitmap->id(); |
| 2462 | disambiguation_bitmaps_[id] = shared_bitmap.release(); |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 2463 | handled = true; |
| 2464 | break; |
| 2465 | } |
| 2466 | case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: |
| 2467 | // No-op. |
| 2468 | break; |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2469 | } |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 2470 | |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 2471 | return handled; |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2472 | } |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2473 | |
| 2474 | void RenderViewImpl::SuspendVideoCaptureDevices(bool suspend) { |
tsunghung | a86cde7 | 2017-04-10 22:27:13 | [diff] [blame] | 2475 | #if BUILDFLAG(ENABLE_WEBRTC) |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2476 | if (!main_render_frame_) |
| 2477 | return; |
| 2478 | |
| 2479 | MediaStreamDispatcher* media_stream_dispatcher = |
| 2480 | main_render_frame_->GetMediaStreamDispatcher(); |
| 2481 | if (!media_stream_dispatcher) |
| 2482 | return; |
| 2483 | |
| 2484 | StreamDeviceInfoArray video_array = |
| 2485 | media_stream_dispatcher->GetNonScreenCaptureDevices(); |
| 2486 | RenderThreadImpl::current()->video_capture_impl_manager()->SuspendDevices( |
| 2487 | video_array, suspend); |
tsunghung | a86cde7 | 2017-04-10 22:27:13 | [diff] [blame] | 2488 | #endif // BUILDFLAG(ENABLE_WEBRTC) |
braveyao | 1d8ee7b | 2017-03-29 21:10:04 | [diff] [blame] | 2489 | } |
estade | 6b9696bd | 2016-05-04 23:51:36 | [diff] [blame] | 2490 | #endif // defined(OS_ANDROID) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2491 | |
[email protected] | b283d29 | 2013-02-21 08:40:34 | [diff] [blame] | 2492 | unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| 2493 | return history_list_length_; |
| 2494 | } |
| 2495 | |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 2496 | void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { |
| 2497 | if (enable) { |
| 2498 | if (has_focus()) |
| 2499 | return; |
| 2500 | OnSetActive(true); |
| 2501 | OnSetFocus(true); |
| 2502 | } else { |
| 2503 | if (!has_focus()) |
| 2504 | return; |
| 2505 | OnSetFocus(false); |
| 2506 | OnSetActive(false); |
| 2507 | } |
| 2508 | } |
| 2509 | |
[email protected] | 3a1c8a803 | 2013-03-18 22:35:32 | [diff] [blame] | 2510 | void RenderViewImpl::SetDeviceScaleFactorForTesting(float factor) { |
fsamuel | 664e8b6 | 2016-01-20 19:54:01 | [diff] [blame] | 2511 | ResizeParams params; |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 2512 | params.screen_info = screen_info_; |
ccameron | 2f45153 | 2016-09-07 21:49:27 | [diff] [blame] | 2513 | params.screen_info.device_scale_factor = factor; |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 2514 | params.new_size = size(); |
bokan | f0fd241 | 2014-10-30 15:28:55 | [diff] [blame] | 2515 | params.visible_viewport_size = visible_viewport_size_; |
danakj | ddaec91 | 2015-09-25 19:38:40 | [diff] [blame] | 2516 | params.physical_backing_size = gfx::ScaleToCeiledSize(size(), factor); |
mdjones | 2ee41afd | 2016-10-27 16:50:20 | [diff] [blame] | 2517 | params.browser_controls_shrink_blink_size = false; |
dtrainor | cb7779b8 | 2014-12-04 01:08:02 | [diff] [blame] | 2518 | params.top_controls_height = 0.f; |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 2519 | params.is_fullscreen_granted = is_fullscreen_granted(); |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 2520 | params.display_mode = display_mode_; |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 2521 | OnResize(params); |
[email protected] | 3a1c8a803 | 2013-03-18 22:35:32 | [diff] [blame] | 2522 | } |
| 2523 | |
mlamouri | afca06dd | 2017-01-27 23:35:18 | [diff] [blame] | 2524 | void RenderViewImpl::SetDeviceColorProfileForTesting( |
| 2525 | const gfx::ICCProfile& icc_profile) { |
| 2526 | if (webview()) |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2527 | webview()->SetDeviceColorProfile(icc_profile); |
mlamouri | afca06dd | 2017-01-27 23:35:18 | [diff] [blame] | 2528 | |
| 2529 | ResizeParams params; |
| 2530 | params.screen_info = screen_info_; |
| 2531 | params.screen_info.icc_profile = icc_profile; |
| 2532 | params.new_size = size(); |
| 2533 | params.visible_viewport_size = visible_viewport_size_; |
| 2534 | params.physical_backing_size = physical_backing_size_; |
| 2535 | params.browser_controls_shrink_blink_size = false; |
| 2536 | params.top_controls_height = 0.f; |
| 2537 | params.is_fullscreen_granted = is_fullscreen_granted(); |
| 2538 | params.display_mode = display_mode_; |
| 2539 | OnResize(params); |
| 2540 | } |
| 2541 | |
[email protected] | 9265016 | 2013-10-30 03:31:02 | [diff] [blame] | 2542 | void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2543 | gfx::Rect new_window_rect(RootWindowRect().x, RootWindowRect().y, |
| 2544 | new_size.width(), new_size.height()); |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 2545 | SetWindowRectSynchronously(new_window_rect); |
[email protected] | 9265016 | 2013-10-30 03:31:02 | [diff] [blame] | 2546 | } |
| 2547 | |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 2548 | void RenderViewImpl::UseSynchronousResizeModeForTesting(bool enable) { |
| 2549 | resizing_mode_selector_->set_is_synchronous_mode(enable); |
| 2550 | } |
| 2551 | |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2552 | void RenderViewImpl::EnableAutoResizeForTesting(const gfx::Size& min_size, |
| 2553 | const gfx::Size& max_size) { |
| 2554 | OnEnableAutoResize(min_size, max_size); |
| 2555 | } |
| 2556 | |
| 2557 | void RenderViewImpl::DisableAutoResizeForTesting(const gfx::Size& new_size) { |
| 2558 | OnDisableAutoResize(new_size); |
| 2559 | } |
| 2560 | |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2561 | void RenderViewImpl::OnReleaseDisambiguationPopupBitmap( |
| 2562 | const cc::SharedBitmapId& id) { |
| 2563 | BitmapMap::iterator it = disambiguation_bitmaps_.find(id); |
| 2564 | DCHECK(it != disambiguation_bitmaps_.end()); |
| 2565 | delete it->second; |
| 2566 | disambiguation_bitmaps_.erase(it); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2567 | } |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2568 | |
aelias | 1b55156e5 | 2017-04-01 00:46:05 | [diff] [blame] | 2569 | void RenderViewImpl::OnResolveTapDisambiguation(double timestamp_seconds, |
| 2570 | gfx::Point tap_viewport_offset, |
| 2571 | bool is_long_press) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2572 | webview()->ResolveTapDisambiguation(timestamp_seconds, tap_viewport_offset, |
aelias | 1b55156e5 | 2017-04-01 00:46:05 | [diff] [blame] | 2573 | is_long_press); |
| 2574 | } |
| 2575 | |
[email protected] | 6fceb91 | 2013-02-15 06:24:15 | [diff] [blame] | 2576 | void RenderViewImpl::DidCommitCompositorFrame() { |
| 2577 | RenderWidget::DidCommitCompositorFrame(); |
ericwilligers | 88e6974 | 2016-10-17 19:29:55 | [diff] [blame] | 2578 | for (auto& observer : observers_) |
| 2579 | observer.DidCommitCompositorFrame(); |
[email protected] | 6fceb91 | 2013-02-15 06:24:15 | [diff] [blame] | 2580 | } |
| 2581 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2582 | void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) { |
| 2583 | if (!urls.empty()) |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2584 | Send(new ViewHostMsg_UpdateFaviconURL(GetRoutingID(), urls)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2585 | } |
| 2586 | |
| 2587 | void RenderViewImpl::DidStopLoadingIcons() { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2588 | int icon_types = WebIconURL::kTypeFavicon | |
| 2589 | WebIconURL::kTypeTouchPrecomposed | WebIconURL::kTypeTouch; |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2590 | |
nasko | 2411ba37 | 2014-10-13 17:45:41 | [diff] [blame] | 2591 | // Favicons matter only for the top-level frame. If it is a WebRemoteFrame, |
| 2592 | // just return early. |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2593 | if (webview()->MainFrame()->IsWebRemoteFrame()) |
nasko | 2411ba37 | 2014-10-13 17:45:41 | [diff] [blame] | 2594 | return; |
| 2595 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2596 | WebVector<WebIconURL> icon_urls = |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2597 | webview()->MainFrame()->IconURLs(icon_types); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2598 | |
| 2599 | std::vector<FaviconURL> urls; |
| 2600 | for (size_t i = 0; i < icon_urls.size(); i++) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2601 | WebURL url = icon_urls[i].GetIconURL(); |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 2602 | std::vector<gfx::Size> sizes; |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2603 | ConvertToFaviconSizes(icon_urls[i].Sizes(), &sizes); |
| 2604 | if (!url.IsEmpty()) |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 2605 | urls.push_back( |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2606 | FaviconURL(url, ToFaviconType(icon_urls[i].IconType()), sizes)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2607 | } |
| 2608 | SendUpdateFaviconURL(urls); |
| 2609 | } |
| 2610 | |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 2611 | void RenderViewImpl::UpdateWebViewWithDeviceScaleFactor() { |
| 2612 | if (!webview()) |
| 2613 | return; |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 2614 | if (IsUseZoomForDSFEnabled()) { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2615 | webview()->SetZoomFactorForDeviceScaleFactor(device_scale_factor_); |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 2616 | } else { |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2617 | webview()->SetDeviceScaleFactor(device_scale_factor_); |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 2618 | } |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2619 | webview()->GetSettings()->SetPreferCompositingToLCDTextEnabled( |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 2620 | PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 2621 | } |
| 2622 | |
dtapuska | 1b0fcc32 | 2016-10-28 18:08:28 | [diff] [blame] | 2623 | void RenderViewImpl::OnDiscardInputEvent( |
| 2624 | const blink::WebInputEvent* input_event, |
nzolghadr | 5d859650 | 2017-01-23 22:59:35 | [diff] [blame] | 2625 | const std::vector<const blink::WebInputEvent*>& coalesced_events, |
dtapuska | 1b0fcc32 | 2016-10-28 18:08:28 | [diff] [blame] | 2626 | const ui::LatencyInfo& latency_info, |
| 2627 | InputEventDispatchType dispatch_type) { |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 2628 | if (!input_event || dispatch_type == DISPATCH_TYPE_NON_BLOCKING) { |
dtapuska | 1b0fcc32 | 2016-10-28 18:08:28 | [diff] [blame] | 2629 | return; |
| 2630 | } |
| 2631 | |
Blink Reformat | 1c4d759e | 2017-04-09 16:34:54 | [diff] [blame] | 2632 | std::unique_ptr<InputEventAck> ack(new InputEventAck( |
| 2633 | InputEventAckSource::MAIN_THREAD, input_event->GetType(), |
| 2634 | INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
dtapuska | 1b0fcc32 | 2016-10-28 18:08:28 | [diff] [blame] | 2635 | OnInputEventAck(std::move(ack)); |
| 2636 | } |
| 2637 | |
dtapuska | 9ec1a91 | 2017-04-21 15:18:31 | [diff] [blame] | 2638 | InputEventAckState RenderViewImpl::HandleInputEvent( |
| 2639 | const blink::WebCoalescedInputEvent& input_event, |
| 2640 | const ui::LatencyInfo& latency_info, |
| 2641 | InputEventDispatchType dispatch_type) { |
| 2642 | if (is_swapped_out_) { |
| 2643 | OnDiscardInputEvent(&input_event.Event(), |
| 2644 | input_event.GetCoalescedEventsPointers(), latency_info, |
| 2645 | dispatch_type); |
| 2646 | return INPUT_EVENT_ACK_STATE_NOT_CONSUMED; |
| 2647 | } |
| 2648 | idle_user_detector_->ActivityDetected(); |
| 2649 | return RenderWidget::HandleInputEvent(input_event, latency_info, |
| 2650 | dispatch_type); |
| 2651 | } |
| 2652 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2653 | } // namespace content |