[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" |
creis | 9f7248b | 2016-01-27 20:27:39 | [diff] [blame] | 17 | #include "base/debug/crash_logging.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" |
[email protected] | a8cb3b73b | 2013-08-12 05:50:50 | [diff] [blame] | 41 | #include "content/child/appcache/appcache_dispatcher.h" |
| 42 | #include "content/child/appcache/web_application_cache_host_impl.h" |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 43 | #include "content/child/child_shared_bitmap_manager.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" |
nick | ac60e7547 | 2015-07-31 00:44:35 | [diff] [blame] | 56 | #include "content/common/site_isolation_policy.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 57 | #include "content/common/view_messages.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] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 63 | #include "content/public/common/drop_data.h" |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 64 | #include "content/public/common/favicon_url.h" |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 65 | #include "content/public/common/page_importance_signals.h" |
clamy | da97e832 | 2014-10-07 21:57:25 | [diff] [blame] | 66 | #include "content/public/common/page_state.h" |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 67 | #include "content/public/common/page_zoom.h" |
[email protected] | 818915cd | 2012-11-20 13:14:11 | [diff] [blame] | 68 | #include "content/public/common/three_d_api_types.h" |
[email protected] | a1d2916 | 2011-10-14 17:14:03 | [diff] [blame] | 69 | #include "content/public/common/url_constants.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 70 | #include "content/public/common/web_preferences.h" |
[email protected] | d344114c | 2011-10-01 01:24:34 | [diff] [blame] | 71 | #include "content/public/renderer/content_renderer_client.h" |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 72 | #include "content/public/renderer/document_state.h" |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 73 | #include "content/public/renderer/navigation_state.h" |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 74 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 75 | #include "content/public/renderer/render_view_visitor.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] | d473498 | 2014-04-15 02:05:55 | [diff] [blame] | 81 | #include "content/renderer/history_controller.h" |
[email protected] | dc06435 | 2014-04-25 08:36:38 | [diff] [blame] | 82 | #include "content/renderer/history_serialization.h" |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 83 | #include "content/renderer/idle_user_detector.h" |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 84 | #include "content/renderer/ime_event_guard.h" |
[email protected] | 7a72d45 | 2013-12-13 10:01:13 | [diff] [blame] | 85 | #include "content/renderer/input/input_handler_manager.h" |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 86 | #include "content/renderer/internal_document_state_data.h" |
[email protected] | 4a91488 | 2013-01-10 00:43:48 | [diff] [blame] | 87 | #include "content/renderer/media/audio_device_factory.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" |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 98 | #include "content/renderer/speech_recognition_dispatcher.h" |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 99 | #include "content/renderer/web_ui_extension_data.h" |
[email protected] | 6f51608 | 2011-03-17 19:15:35 | [diff] [blame] | 100 | #include "content/renderer/websharedworker_proxy.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" |
servolk | f54f5c8f | 2015-02-24 20:32:39 | [diff] [blame] | 103 | #include "media/renderers/audio_renderer_impl.h" |
servolk | 8b3b39b | 2015-03-03 19:08:18 | [diff] [blame] | 104 | #include "media/renderers/gpu_video_accelerator_factories.h" |
[email protected] | d1ef81d | 2012-07-24 11:39:36 | [diff] [blame] | 105 | #include "net/base/data_url.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 106 | #include "net/base/escape.h" |
| 107 | #include "net/base/net_errors.h" |
[email protected] | 18fb7a77 | 2012-09-20 19:25:09 | [diff] [blame] | 108 | #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 109 | #include "net/http/http_util.h" |
luken | b171b53 | 2014-09-24 05:50:38 | [diff] [blame] | 110 | #include "skia/ext/platform_canvas.h" |
kinuko | b473f00 | 2016-02-22 05:23:19 | [diff] [blame] | 111 | #include "third_party/WebKit/public/platform/FilePathConversion.h" |
brettw | dfbcc3b | 2016-01-20 01:49:17 | [diff] [blame] | 112 | #include "third_party/WebKit/public/platform/URLConversion.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 113 | #include "third_party/WebKit/public/platform/WebConnectionType.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 114 | #include "third_party/WebKit/public/platform/WebDragData.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 115 | #include "third_party/WebKit/public/platform/WebHTTPBody.h" |
| 116 | #include "third_party/WebKit/public/platform/WebImage.h" |
| 117 | #include "third_party/WebKit/public/platform/WebMessagePortChannel.h" |
| 118 | #include "third_party/WebKit/public/platform/WebPoint.h" |
| 119 | #include "third_party/WebKit/public/platform/WebRect.h" |
| 120 | #include "third_party/WebKit/public/platform/WebSize.h" |
[email protected] | ec173b52 | 2013-11-14 11:01:18 | [diff] [blame] | 121 | #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 122 | #include "third_party/WebKit/public/platform/WebString.h" |
| 123 | #include "third_party/WebKit/public/platform/WebURL.h" |
| 124 | #include "third_party/WebKit/public/platform/WebURLError.h" |
| 125 | #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 126 | #include "third_party/WebKit/public/platform/WebURLResponse.h" |
| 127 | #include "third_party/WebKit/public/platform/WebVector.h" |
[email protected] | 10760e4a | 2013-09-04 23:32:20 | [diff] [blame] | 128 | #include "third_party/WebKit/public/web/WebAXObject.h" |
[email protected] | 8bc5ff0 | 2013-11-29 06:34:03 | [diff] [blame] | 129 | #include "third_party/WebKit/public/web/WebColorSuggestion.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 130 | #include "third_party/WebKit/public/web/WebDOMEvent.h" |
| 131 | #include "third_party/WebKit/public/web/WebDOMMessageEvent.h" |
| 132 | #include "third_party/WebKit/public/web/WebDataSource.h" |
| 133 | #include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h" |
| 134 | #include "third_party/WebKit/public/web/WebDateTimeChooserParams.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 135 | #include "third_party/WebKit/public/web/WebDocument.h" |
| 136 | #include "third_party/WebKit/public/web/WebElement.h" |
| 137 | #include "third_party/WebKit/public/web/WebFileChooserParams.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 138 | #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 139 | #include "third_party/WebKit/public/web/WebFormElement.h" |
| 140 | #include "third_party/WebKit/public/web/WebFrame.h" |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 141 | #include "third_party/WebKit/public/web/WebFrameContentDumper.h" |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 142 | #include "third_party/WebKit/public/web/WebFrameWidget.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 143 | #include "third_party/WebKit/public/web/WebHistoryItem.h" |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 144 | #include "third_party/WebKit/public/web/WebHitTestResult.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 145 | #include "third_party/WebKit/public/web/WebInputElement.h" |
| 146 | #include "third_party/WebKit/public/web/WebInputEvent.h" |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 147 | #include "third_party/WebKit/public/web/WebLocalFrame.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 148 | #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |
| 149 | #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 150 | #include "third_party/WebKit/public/web/WebPageImportanceSignals.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 151 | #include "third_party/WebKit/public/web/WebPlugin.h" |
| 152 | #include "third_party/WebKit/public/web/WebPluginAction.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 153 | #include "third_party/WebKit/public/web/WebRange.h" |
ellyjones | 8ae1769 | 2016-08-05 15:19:21 | [diff] [blame] | 154 | #include "third_party/WebKit/public/web/WebRenderTheme.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 155 | #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 156 | #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 157 | #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 158 | #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 159 | #include "third_party/WebKit/public/web/WebSettings.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 160 | #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 161 | #include "third_party/WebKit/public/web/WebView.h" |
| 162 | #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 163 | #include "third_party/icu/source/common/unicode/uchar.h" |
| 164 | #include "third_party/icu/source/common/unicode/uscript.h" |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 165 | #include "ui/base/clipboard/clipboard.h" |
[email protected] | 1400e6dc | 2013-04-27 02:36:27 | [diff] [blame] | 166 | #include "ui/base/ui_base_switches_util.h" |
Nico Weber | 9d6e1294 | 2016-04-19 18:51:09 | [diff] [blame] | 167 | #include "ui/events/latency_info.h" |
tfarina | 655f81d | 2014-12-23 02:38:50 | [diff] [blame] | 168 | #include "ui/gfx/geometry/point.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 169 | #include "ui/gfx/geometry/rect.h" |
| 170 | #include "ui/gfx/geometry/rect_conversions.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 171 | #include "ui/gfx/geometry/size_conversions.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 172 | #include "ui/gfx/native_widget_types.h" |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 173 | #include "url/url_constants.h" |
[email protected] | c4a9e93 | 2011-03-05 04:05:55 | [diff] [blame] | 174 | #include "v8/include/v8.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 175 | |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 176 | #if defined(OS_ANDROID) |
[email protected] | befe5478 | 2013-04-23 00:49:25 | [diff] [blame] | 177 | #include <cpu-features.h> |
| 178 | |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 179 | #include "base/android/build_info.h" |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 180 | #include "content/renderer/android/address_detector.h" |
| 181 | #include "content/renderer/android/content_detector.h" |
estade | 6b9696bd | 2016-05-04 23:51:36 | [diff] [blame] | 182 | #include "content/renderer/android/disambiguation_popup_helper.h" |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 183 | #include "content/renderer/android/email_detector.h" |
| 184 | #include "content/renderer/android/phone_number_detector.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 185 | #include "ui/gfx/geometry/rect_f.h" |
[email protected] | e69bb06 | 2013-06-03 13:05:40 | [diff] [blame] | 186 | |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 187 | #elif defined(OS_MACOSX) |
| 188 | #include "skia/ext/skia_utils_mac.h" |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 189 | #endif |
| 190 | |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 191 | #if defined(ENABLE_PLUGINS) |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 192 | #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 193 | #include "content/renderer/pepper/pepper_plugin_registry.h" |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 194 | #endif |
| 195 | |
[email protected] | 9ac667e | 2013-09-09 12:49:21 | [diff] [blame] | 196 | #if defined(ENABLE_WEBRTC) |
| 197 | #include "content/renderer/media/rtc_peer_connection_handler.h" |
[email protected] | 22fe91d | 2014-08-12 17:07:12 | [diff] [blame] | 198 | #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
[email protected] | 9ac667e | 2013-09-09 12:49:21 | [diff] [blame] | 199 | #endif |
| 200 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 201 | using blink::WebAXObject; |
| 202 | using blink::WebApplicationCacheHost; |
| 203 | using blink::WebApplicationCacheHostClient; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 204 | using blink::WebColor; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 205 | using blink::WebConsoleMessage; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 206 | using blink::WebData; |
| 207 | using blink::WebDataSource; |
| 208 | using blink::WebDocument; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 209 | using blink::WebDragData; |
| 210 | using blink::WebDragOperation; |
| 211 | using blink::WebDragOperationsMask; |
| 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::WebPeerConnection00Handler; |
| 233 | using blink::WebPeerConnection00HandlerClient; |
| 234 | using blink::WebPeerConnectionHandler; |
| 235 | using blink::WebPeerConnectionHandlerClient; |
| 236 | using blink::WebPluginAction; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 237 | using blink::WebPoint; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 238 | using blink::WebRect; |
| 239 | using blink::WebReferrerPolicy; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 240 | using blink::WebScriptSource; |
| 241 | using blink::WebSearchableFormData; |
| 242 | using blink::WebSecurityOrigin; |
| 243 | using blink::WebSecurityPolicy; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 244 | using blink::WebSettings; |
| 245 | using blink::WebSize; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 246 | using blink::WebStorageNamespace; |
| 247 | using blink::WebStorageQuotaCallbacks; |
| 248 | using blink::WebStorageQuotaError; |
| 249 | using blink::WebStorageQuotaType; |
| 250 | using blink::WebString; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 251 | using blink::WebTextDirection; |
| 252 | using blink::WebTouchEvent; |
| 253 | using blink::WebURL; |
| 254 | using blink::WebURLError; |
| 255 | using blink::WebURLRequest; |
| 256 | using blink::WebURLResponse; |
| 257 | using blink::WebUserGestureIndicator; |
| 258 | using blink::WebVector; |
| 259 | using blink::WebView; |
| 260 | using blink::WebWidget; |
| 261 | using blink::WebWindowFeatures; |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 262 | using blink::WebRuntimeFeatures; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 263 | using base::Time; |
| 264 | using base::TimeDelta; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 265 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 266 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 267 | namespace content { |
| 268 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 269 | //----------------------------------------------------------------------------- |
| 270 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 271 | typedef std::map<blink::WebView*, RenderViewImpl*> ViewMap; |
[email protected] | 6de0fd1d | 2011-11-15 13:31:49 | [diff] [blame] | 272 | static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 273 | typedef std::map<int32_t, RenderViewImpl*> RoutingIDViewMap; |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 274 | static base::LazyInstance<RoutingIDViewMap> g_routing_id_view_map = |
| 275 | LAZY_INSTANCE_INITIALIZER; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 276 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 277 | // Time, in seconds, we delay before sending content state changes (such as form |
| 278 | // state and scroll position) to the browser. We delay sending changes to avoid |
| 279 | // spamming the browser. |
| 280 | // To avoid having tab/session restore require sending a message to get the |
| 281 | // current content state during tab closing we use a shorter timeout for the |
| 282 | // foreground renderer. This means there is a small window of time from which |
| 283 | // content state is modified and not sent to session restore, but this is |
| 284 | // better than having to wake up all renderers during shutdown. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 285 | const int kDelaySecondsForContentStateSyncHidden = 5; |
| 286 | const int kDelaySecondsForContentStateSync = 1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 287 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 288 | #if defined(OS_ANDROID) |
| 289 | // Delay between tapping in content and launching the associated android intent. |
| 290 | // Used to allow users see what has been recognized as content. |
[email protected] | 9afc14e2 | 2013-09-25 22:34:14 | [diff] [blame] | 291 | const size_t kContentIntentDelayMilliseconds = 700; |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 292 | #endif |
| 293 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 294 | static RenderViewImpl* (*g_create_render_view_impl)( |
| 295 | CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 296 | const mojom::CreateViewParams&) = nullptr; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 297 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 298 | // static |
[email protected] | e507045d | 2013-07-24 15:23:44 | [diff] [blame] | 299 | Referrer RenderViewImpl::GetReferrerFromRequest( |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 300 | WebFrame* frame, |
| 301 | const WebURLRequest& request) { |
brettw | dfbcc3b | 2016-01-20 01:49:17 | [diff] [blame] | 302 | return Referrer( |
| 303 | blink::WebStringToGURL(request.httpHeaderField( |
| 304 | WebString::fromUTF8("Referer"))), |
| 305 | request.referrerPolicy()); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 306 | } |
| 307 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 308 | // static |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 309 | WindowOpenDisposition RenderViewImpl::NavigationPolicyToDisposition( |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 310 | WebNavigationPolicy policy) { |
| 311 | switch (policy) { |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 312 | case blink::WebNavigationPolicyIgnore: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 313 | return WindowOpenDisposition::IGNORE_ACTION; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 314 | case blink::WebNavigationPolicyDownload: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 315 | return WindowOpenDisposition::SAVE_TO_DISK; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 316 | case blink::WebNavigationPolicyCurrentTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 317 | return WindowOpenDisposition::CURRENT_TAB; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 318 | case blink::WebNavigationPolicyNewBackgroundTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 319 | return WindowOpenDisposition::NEW_BACKGROUND_TAB; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 320 | case blink::WebNavigationPolicyNewForegroundTab: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 321 | return WindowOpenDisposition::NEW_FOREGROUND_TAB; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 322 | case blink::WebNavigationPolicyNewWindow: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 323 | return WindowOpenDisposition::NEW_WINDOW; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 324 | case blink::WebNavigationPolicyNewPopup: |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 325 | return WindowOpenDisposition::NEW_POPUP; |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 326 | default: |
| 327 | NOTREACHED() << "Unexpected WebNavigationPolicy"; |
nick | 3b04f32 | 2016-08-31 19:29:19 | [diff] [blame] | 328 | return WindowOpenDisposition::IGNORE_ACTION; |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 332 | // Returns true if the device scale is high enough that losing subpixel |
| 333 | // antialiasing won't have a noticeable effect on text quality. |
| 334 | static bool DeviceScaleEnsuresTextQuality(float device_scale_factor) { |
| 335 | #if defined(OS_ANDROID) |
| 336 | // On Android, we never have subpixel antialiasing. |
| 337 | return true; |
| 338 | #else |
jdduke | 7d452b4a | 2015-08-19 21:25:21 | [diff] [blame] | 339 | // 1.5 is a common touchscreen tablet device scale factor. For such |
| 340 | // devices main thread antialiasing is a heavy burden. |
| 341 | return device_scale_factor >= 1.5f; |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 342 | #endif |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 343 | } |
| 344 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 345 | static bool PreferCompositingToLCDText(CompositorDependencies* compositor_deps, |
| 346 | float device_scale_factor) { |
avi | 83883c8 | 2014-12-23 00:08:49 | [diff] [blame] | 347 | const base::CommandLine& command_line = |
| 348 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | b8ec111 | 2014-08-17 20:09:10 | [diff] [blame] | 349 | if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) |
[email protected] | fb85419 | 2013-02-06 01:30:04 | [diff] [blame] | 350 | return false; |
[email protected] | b8ec111 | 2014-08-17 20:09:10 | [diff] [blame] | 351 | if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) |
[email protected] | fb85419 | 2013-02-06 01:30:04 | [diff] [blame] | 352 | return true; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 353 | if (!compositor_deps->IsLcdTextEnabled()) |
[email protected] | 10c1973 | 2014-08-18 19:39:23 | [diff] [blame] | 354 | return true; |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 355 | return DeviceScaleEnsuresTextQuality(device_scale_factor); |
| 356 | } |
| 357 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 358 | static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 359 | switch (type) { |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 360 | case blink::WebIconURL::TypeFavicon: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 361 | return FaviconURL::FAVICON; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 362 | case blink::WebIconURL::TypeTouch: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 363 | return FaviconURL::TOUCH_ICON; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 364 | case blink::WebIconURL::TypeTouchPrecomposed: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 365 | return FaviconURL::TOUCH_PRECOMPOSED_ICON; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 366 | case blink::WebIconURL::TypeInvalid: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 367 | return FaviconURL::INVALID_ICON; |
| 368 | } |
| 369 | return FaviconURL::INVALID_ICON; |
| 370 | } |
| 371 | |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 372 | static void ConvertToFaviconSizes( |
| 373 | const blink::WebVector<blink::WebSize>& web_sizes, |
| 374 | std::vector<gfx::Size>* sizes) { |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 375 | DCHECK(sizes->empty()); |
| 376 | sizes->reserve(web_sizes.size()); |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 377 | for (size_t i = 0; i < web_sizes.size(); ++i) |
| 378 | sizes->push_back(gfx::Size(web_sizes[i])); |
| 379 | } |
| 380 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 381 | /////////////////////////////////////////////////////////////////////////////// |
| 382 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 383 | namespace { |
| 384 | |
hush | 8915b50 | 2016-06-15 19:32:23 | [diff] [blame] | 385 | WebDragData DropMetaDataToWebDragData( |
| 386 | const std::vector<DropData::Metadata>& drop_meta_data) { |
| 387 | std::vector<WebDragData::Item> item_list; |
| 388 | for (const auto& meta_data_item : drop_meta_data) { |
| 389 | if (meta_data_item.kind == DropData::Kind::STRING) { |
| 390 | WebDragData::Item item; |
| 391 | item.storageType = WebDragData::Item::StorageTypeString; |
| 392 | item.stringType = meta_data_item.mime_type; |
| 393 | // Have to pass a dummy URL here instead of an empty URL because the |
| 394 | // DropData received by browser_plugins goes through a round trip: |
| 395 | // DropData::MetaData --> WebDragData-->DropData. In the end, DropData |
| 396 | // will contain an empty URL (which means no URL is dragged) if the URL in |
| 397 | // WebDragData is empty. |
| 398 | if (base::EqualsASCII(meta_data_item.mime_type, |
| 399 | ui::Clipboard::kMimeTypeURIList)) { |
| 400 | item.stringData = WebString::fromUTF8("about:dragdrop-placeholder"); |
| 401 | } |
| 402 | item_list.push_back(item); |
| 403 | continue; |
| 404 | } |
| 405 | |
| 406 | // TODO(hush): crbug.com/584789. Blink needs to support creating a file with |
| 407 | // just the mimetype. This is needed to drag files to WebView on Android |
| 408 | // platform. |
| 409 | if ((meta_data_item.kind == DropData::Kind::FILENAME) && |
| 410 | !meta_data_item.filename.empty()) { |
| 411 | WebDragData::Item item; |
| 412 | item.storageType = WebDragData::Item::StorageTypeFilename; |
| 413 | item.filenameData = meta_data_item.filename.AsUTF16Unsafe(); |
| 414 | item_list.push_back(item); |
| 415 | continue; |
| 416 | } |
| 417 | |
| 418 | if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) { |
| 419 | WebDragData::Item item; |
| 420 | item.storageType = WebDragData::Item::StorageTypeFileSystemFile; |
| 421 | item.fileSystemURL = meta_data_item.file_system_url; |
| 422 | item_list.push_back(item); |
| 423 | continue; |
| 424 | } |
| 425 | } |
| 426 | |
| 427 | WebDragData result; |
| 428 | result.initialize(); |
| 429 | result.setItems(item_list); |
| 430 | return result; |
| 431 | } |
| 432 | |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 433 | WebDragData DropDataToWebDragData(const DropData& drop_data) { |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 434 | std::vector<WebDragData::Item> item_list; |
| 435 | |
| 436 | // These fields are currently unused when dragging into WebKit. |
| 437 | DCHECK(drop_data.download_metadata.empty()); |
| 438 | DCHECK(drop_data.file_contents.empty()); |
| 439 | DCHECK(drop_data.file_description_filename.empty()); |
| 440 | |
| 441 | if (!drop_data.text.is_null()) { |
| 442 | WebDragData::Item item; |
| 443 | item.storageType = WebDragData::Item::StorageTypeString; |
| 444 | item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); |
| 445 | item.stringData = drop_data.text.string(); |
| 446 | item_list.push_back(item); |
| 447 | } |
| 448 | |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 449 | if (!drop_data.url.is_empty()) { |
| 450 | WebDragData::Item item; |
| 451 | item.storageType = WebDragData::Item::StorageTypeString; |
| 452 | item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); |
| 453 | item.stringData = WebString::fromUTF8(drop_data.url.spec()); |
| 454 | item.title = drop_data.url_title; |
| 455 | item_list.push_back(item); |
| 456 | } |
| 457 | |
| 458 | if (!drop_data.html.is_null()) { |
| 459 | WebDragData::Item item; |
| 460 | item.storageType = WebDragData::Item::StorageTypeString; |
| 461 | item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML); |
| 462 | item.stringData = drop_data.html.string(); |
| 463 | item.baseURL = drop_data.html_base_url; |
| 464 | item_list.push_back(item); |
| 465 | } |
| 466 | |
[email protected] | 17ea0ae2 | 2014-03-28 21:54:46 | [diff] [blame] | 467 | for (std::vector<ui::FileInfo>::const_iterator it = |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 468 | drop_data.filenames.begin(); |
| 469 | it != drop_data.filenames.end(); |
| 470 | ++it) { |
| 471 | WebDragData::Item item; |
| 472 | item.storageType = WebDragData::Item::StorageTypeFilename; |
[email protected] | 17ea0ae2 | 2014-03-28 21:54:46 | [diff] [blame] | 473 | item.filenameData = it->path.AsUTF16Unsafe(); |
| 474 | item.displayNameData = it->display_name.AsUTF16Unsafe(); |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 475 | item_list.push_back(item); |
| 476 | } |
| 477 | |
[email protected] | 60ed95f | 2014-04-23 12:19:48 | [diff] [blame] | 478 | for (std::vector<DropData::FileSystemFileInfo>::const_iterator it = |
| 479 | drop_data.file_system_files.begin(); |
| 480 | it != drop_data.file_system_files.end(); |
| 481 | ++it) { |
| 482 | WebDragData::Item item; |
| 483 | item.storageType = WebDragData::Item::StorageTypeFileSystemFile; |
| 484 | item.fileSystemURL = it->url; |
| 485 | item.fileSystemFileSize = it->size; |
| 486 | item_list.push_back(item); |
| 487 | } |
| 488 | |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 489 | for (std::map<base::string16, base::string16>::const_iterator it = |
| 490 | drop_data.custom_data.begin(); |
| 491 | it != drop_data.custom_data.end(); |
| 492 | ++it) { |
| 493 | WebDragData::Item item; |
| 494 | item.storageType = WebDragData::Item::StorageTypeString; |
| 495 | item.stringType = it->first; |
| 496 | item.stringData = it->second; |
| 497 | item_list.push_back(item); |
| 498 | } |
| 499 | |
| 500 | WebDragData result; |
| 501 | result.initialize(); |
| 502 | result.setItems(item_list); |
| 503 | result.setFilesystemId(drop_data.filesystem_id); |
| 504 | return result; |
| 505 | } |
| 506 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 507 | typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, |
| 508 | const base::string16&, |
| 509 | UScriptCode); |
| 510 | |
| 511 | void SetStandardFontFamilyWrapper(WebSettings* settings, |
| 512 | const base::string16& font, |
| 513 | UScriptCode script) { |
| 514 | settings->setStandardFontFamily(font, script); |
| 515 | } |
| 516 | |
| 517 | void SetFixedFontFamilyWrapper(WebSettings* settings, |
| 518 | const base::string16& font, |
| 519 | UScriptCode script) { |
| 520 | settings->setFixedFontFamily(font, script); |
| 521 | } |
| 522 | |
| 523 | void SetSerifFontFamilyWrapper(WebSettings* settings, |
| 524 | const base::string16& font, |
| 525 | UScriptCode script) { |
| 526 | settings->setSerifFontFamily(font, script); |
| 527 | } |
| 528 | |
| 529 | void SetSansSerifFontFamilyWrapper(WebSettings* settings, |
| 530 | const base::string16& font, |
| 531 | UScriptCode script) { |
| 532 | settings->setSansSerifFontFamily(font, script); |
| 533 | } |
| 534 | |
| 535 | void SetCursiveFontFamilyWrapper(WebSettings* settings, |
| 536 | const base::string16& font, |
| 537 | UScriptCode script) { |
| 538 | settings->setCursiveFontFamily(font, script); |
| 539 | } |
| 540 | |
| 541 | void SetFantasyFontFamilyWrapper(WebSettings* settings, |
| 542 | const base::string16& font, |
| 543 | UScriptCode script) { |
| 544 | settings->setFantasyFontFamily(font, script); |
| 545 | } |
| 546 | |
| 547 | void SetPictographFontFamilyWrapper(WebSettings* settings, |
| 548 | const base::string16& font, |
| 549 | UScriptCode script) { |
| 550 | settings->setPictographFontFamily(font, script); |
| 551 | } |
| 552 | |
| 553 | // If |scriptCode| is a member of a family of "similar" script codes, returns |
| 554 | // the script code in that family that is used by WebKit for font selection |
| 555 | // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are |
| 556 | // considered equivalent for the purposes of font selection. WebKit uses the |
| 557 | // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is |
| 558 | // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit |
| 559 | // uses different scripts than the ones in Chrome pref names because the version |
| 560 | // of ICU included on certain ports does not have some of the newer scripts. If |
| 561 | // |scriptCode| is not a member of such a family, returns |scriptCode|. |
| 562 | UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) { |
| 563 | switch (scriptCode) { |
| 564 | case USCRIPT_HIRAGANA: |
| 565 | case USCRIPT_KATAKANA: |
| 566 | case USCRIPT_JAPANESE: |
| 567 | return USCRIPT_KATAKANA_OR_HIRAGANA; |
| 568 | case USCRIPT_KOREAN: |
| 569 | return USCRIPT_HANGUL; |
| 570 | default: |
| 571 | return scriptCode; |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | void ApplyFontsFromMap(const ScriptFontFamilyMap& map, |
| 576 | SetFontFamilyWrapper setter, |
| 577 | WebSettings* settings) { |
| 578 | for (ScriptFontFamilyMap::const_iterator it = map.begin(); it != map.end(); |
| 579 | ++it) { |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 580 | int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 581 | if (script >= 0 && script < USCRIPT_CODE_LIMIT) { |
| 582 | UScriptCode code = static_cast<UScriptCode>(script); |
| 583 | (*setter)(settings, it->second, GetScriptForWebSettings(code)); |
| 584 | } |
| 585 | } |
| 586 | } |
| 587 | |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 588 | void ApplyBlinkSettings(const base::CommandLine& command_line, |
| 589 | WebSettings* settings) { |
| 590 | if (!command_line.HasSwitch(switches::kBlinkSettings)) |
| 591 | return; |
| 592 | |
brettw | 26dab8f0 | 2015-08-08 00:28:47 | [diff] [blame] | 593 | std::vector<std::string> blink_settings = base::SplitString( |
| 594 | command_line.GetSwitchValueASCII(switches::kBlinkSettings), |
| 595 | ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 596 | for (const std::string& setting : blink_settings) { |
| 597 | size_t pos = setting.find('='); |
| 598 | settings->setFromStrings( |
| 599 | blink::WebString::fromLatin1(setting.substr(0, pos)), |
| 600 | blink::WebString::fromLatin1( |
| 601 | pos == std::string::npos ? "" : setting.substr(pos + 1))); |
| 602 | } |
| 603 | } |
| 604 | |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 605 | WebSettings::V8CacheStrategiesForCacheStorage |
| 606 | GetV8CacheStrategiesForCacheStorage() { |
| 607 | const base::CommandLine& command_line = |
| 608 | *base::CommandLine::ForCurrentProcess(); |
| 609 | std::string v8_cache_strategies = command_line.GetSwitchValueASCII( |
| 610 | switches::kV8CacheStrategiesForCacheStorage); |
horo | e0ff13d | 2016-05-27 14:47:22 | [diff] [blame] | 611 | if (v8_cache_strategies.empty()) { |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 612 | v8_cache_strategies = |
| 613 | base::FieldTrialList::FindFullName("V8CacheStrategiesForCacheStorage"); |
horo | e0ff13d | 2016-05-27 14:47:22 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | if (base::StartsWith(v8_cache_strategies, "none", |
| 617 | base::CompareCase::SENSITIVE)) { |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 618 | return WebSettings::V8CacheStrategiesForCacheStorage::None; |
horo | e0ff13d | 2016-05-27 14:47:22 | [diff] [blame] | 619 | } else if (base::StartsWith(v8_cache_strategies, "normal", |
| 620 | base::CompareCase::SENSITIVE)) { |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 621 | return WebSettings::V8CacheStrategiesForCacheStorage::Normal; |
horo | e0ff13d | 2016-05-27 14:47:22 | [diff] [blame] | 622 | } else if (base::StartsWith(v8_cache_strategies, "aggressive", |
| 623 | base::CompareCase::SENSITIVE)) { |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 624 | return WebSettings::V8CacheStrategiesForCacheStorage::Aggressive; |
| 625 | } else { |
| 626 | return WebSettings::V8CacheStrategiesForCacheStorage::Default; |
| 627 | } |
| 628 | } |
| 629 | |
svartmetal | 751af1f9 | 2016-08-13 11:47:33 | [diff] [blame] | 630 | // This class represents promise which is robust to (will not be broken by) |
| 631 | // |DidNotSwapReason::SWAP_FAILS| events. |
| 632 | class AlwaysDrawSwapPromise : public cc::SwapPromise { |
| 633 | public: |
| 634 | explicit AlwaysDrawSwapPromise(const ui::LatencyInfo& latency_info) |
| 635 | : latency_info_(latency_info) {} |
| 636 | |
| 637 | ~AlwaysDrawSwapPromise() override = default; |
| 638 | |
| 639 | void DidActivate() override {} |
| 640 | |
| 641 | void DidSwap(cc::CompositorFrameMetadata* metadata) override { |
| 642 | DCHECK(!latency_info_.terminated()); |
| 643 | metadata->latency_info.push_back(latency_info_); |
| 644 | } |
| 645 | |
| 646 | DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override { |
| 647 | return reason == DidNotSwapReason::SWAP_FAILS |
| 648 | ? DidNotSwapAction::KEEP_ACTIVE |
| 649 | : DidNotSwapAction::BREAK_PROMISE; |
| 650 | } |
| 651 | |
| 652 | void OnCommit() override {} |
| 653 | |
| 654 | int64_t TraceId() const override { return latency_info_.trace_id(); } |
| 655 | |
| 656 | private: |
| 657 | ui::LatencyInfo latency_info_; |
| 658 | }; |
| 659 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 660 | } // namespace |
| 661 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 662 | RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 663 | const mojom::CreateViewParams& params) |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 664 | : RenderWidget(compositor_deps, |
| 665 | blink::WebPopupTypeNone, |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 666 | params.initial_size.screen_info, |
| 667 | params.swapped_out, |
| 668 | params.hidden, |
| 669 | params.never_visible), |
| 670 | webkit_preferences_(params.web_preferences), |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 671 | send_content_state_immediately_(false), |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 672 | enabled_bindings_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 673 | send_preferred_size_changes_(false), |
[email protected] | e75cb49e | 2009-01-05 23:13:21 | [diff] [blame] | 674 | navigation_gesture_(NavigationGestureUnknown), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 675 | opened_by_user_gesture_(true), |
[email protected] | 81a3441 | 2009-01-05 19:17:24 | [diff] [blame] | 676 | page_id_(-1), |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 677 | next_page_id_(params.next_page_id), |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 678 | history_list_offset_(-1), |
| 679 | history_list_length_(0), |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 680 | frames_in_progress_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 681 | target_url_status_(TARGET_NONE), |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 682 | uses_temporary_zoom_level_(false), |
[email protected] | bbc8856d | 2013-06-14 10:37:04 | [diff] [blame] | 683 | #if defined(OS_ANDROID) |
majidvp | fb80e43 | 2015-02-23 14:15:50 | [diff] [blame] | 684 | top_controls_constraints_(TOP_CONTROLS_STATE_BOTH), |
[email protected] | bbc8856d | 2013-06-14 10:37:04 | [diff] [blame] | 685 | #endif |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 686 | top_controls_shrink_blink_size_(false), |
| 687 | top_controls_height_(0.f), |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 688 | webview_(nullptr), |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 689 | has_scrolled_focused_editable_node_into_rect_(false), |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 690 | page_zoom_level_(params.page_zoom_level), |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 691 | main_render_frame_(nullptr), |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 692 | frame_widget_(nullptr), |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 693 | speech_recognition_dispatcher_(NULL), |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 694 | #if defined(OS_ANDROID) |
| 695 | expected_content_intent_id_(0), |
[email protected] | a756427 | 2013-04-19 14:24:46 | [diff] [blame] | 696 | #endif |
[email protected] | 8a67aa35 | 2013-02-20 02:58:29 | [diff] [blame] | 697 | enumeration_completion_id_(0), |
changwan | d659e20 | 2016-06-13 02:39:12 | [diff] [blame] | 698 | session_storage_namespace_id_(params.session_storage_namespace_id), |
| 699 | has_added_input_handler_(false) { |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 700 | GetWidget()->set_owner_delegate(this); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 701 | } |
| 702 | |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 703 | void RenderViewImpl::Initialize(const mojom::CreateViewParams& params, |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 704 | bool was_created_by_renderer) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 705 | SetRoutingID(params.view_id); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 706 | |
| 707 | int opener_view_routing_id; |
alexmos | 9573300 | 2015-08-24 16:38:09 | [diff] [blame] | 708 | WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( |
| 709 | params.opener_frame_route_id, &opener_view_routing_id); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 710 | if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) |
| 711 | opener_id_ = opener_view_routing_id; |
| 712 | |
thestig | 6057a6b2 | 2015-11-12 23:01:33 | [diff] [blame] | 713 | display_mode_ = params.initial_size.display_mode; |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 714 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 715 | // Ensure we start with a valid next_page_id_ from the browser. |
| 716 | DCHECK_GE(next_page_id_, 0); |
| 717 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 718 | webview_ = |
| 719 | WebView::create(this, is_hidden() ? blink::WebPageVisibilityStateHidden |
| 720 | : blink::WebPageVisibilityStateVisible); |
lfg | bee1e0a | 2016-06-08 21:24:21 | [diff] [blame] | 721 | RenderWidget::DoInit(MSG_ROUTING_NONE, webview_->widget(), nullptr); |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 722 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 723 | g_view_map.Get().insert(std::make_pair(webview(), this)); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 724 | g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this)); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 725 | |
avi | 83883c8 | 2014-12-23 00:08:49 | [diff] [blame] | 726 | const base::CommandLine& command_line = |
| 727 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 728 | |
[email protected] | 27c521a | 2013-05-29 20:44:32 | [diff] [blame] | 729 | if (command_line.HasSwitch(switches::kStatsCollectionController)) |
| 730 | stats_collection_observer_.reset(new StatsCollectionObserver(this)); |
| 731 | |
creis | 9f7248b | 2016-01-27 20:27:39 | [diff] [blame] | 732 | // Debug cases of https://crbug.com/575245. |
| 733 | base::debug::SetCrashKeyValue("rvinit_view_id", |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 734 | base::IntToString(GetRoutingID())); |
creis | 9f7248b | 2016-01-27 20:27:39 | [diff] [blame] | 735 | base::debug::SetCrashKeyValue("rvinit_proxy_id", |
| 736 | base::IntToString(params.proxy_routing_id)); |
| 737 | base::debug::SetCrashKeyValue( |
| 738 | "rvinit_main_frame_id", base::IntToString(params.main_frame_routing_id)); |
| 739 | |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 740 | webview()->setDisplayMode(display_mode_); |
| 741 | webview()->settings()->setPreferCompositingToLCDTextEnabled( |
| 742 | PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
| 743 | webview()->settings()->setThreadedScrollingEnabled( |
| 744 | !command_line.HasSwitch(switches::kDisableThreadedScrolling)); |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 745 | webview()->setShowFPSCounter( |
| 746 | command_line.HasSwitch(cc::switches::kShowFPSCounter)); |
ccameron | 41495f25 | 2016-09-02 02:37:32 | [diff] [blame] | 747 | |
| 748 | if (auto overridden_color_profile = |
| 749 | GetContentClient()->renderer()->GetImageDecodeColorProfile()) { |
| 750 | webview()->setDeviceColorProfile(overridden_color_profile->GetData()); |
| 751 | } else { |
| 752 | webview()->setDeviceColorProfile(params.image_decode_color_space.GetData()); |
| 753 | } |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 754 | |
| 755 | ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_); |
| 756 | |
| 757 | if (switches::IsTouchDragDropEnabled()) |
| 758 | webview()->settings()->setTouchDragDropEnabled(true); |
| 759 | |
arthursonzogni | c517fc3 | 2016-08-11 11:04:24 | [diff] [blame] | 760 | webview()->settings()->setBrowserSideNavigationEnabled( |
| 761 | IsBrowserSideNavigationEnabled()); |
| 762 | |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 763 | WebSettings::SelectionStrategyType selection_strategy = |
| 764 | WebSettings::SelectionStrategyType::Character; |
| 765 | const std::string selection_strategy_str = |
| 766 | base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 767 | switches::kTouchTextSelectionStrategy); |
| 768 | if (selection_strategy_str == "direction") |
| 769 | selection_strategy = WebSettings::SelectionStrategyType::Direction; |
| 770 | webview()->settings()->setSelectionStrategy(selection_strategy); |
| 771 | |
dtapuska | f65650b | 2016-05-13 17:21:34 | [diff] [blame] | 772 | std::string passiveListenersDefault = |
| 773 | command_line.GetSwitchValueASCII(switches::kPassiveListenersDefault); |
| 774 | if (!passiveListenersDefault.empty()) { |
| 775 | WebSettings::PassiveEventListenerDefault passiveDefault = |
| 776 | WebSettings::PassiveEventListenerDefault::False; |
dtapuska | acc2fb2 | 2016-07-06 23:26:23 | [diff] [blame] | 777 | if (passiveListenersDefault == "true") |
dtapuska | f65650b | 2016-05-13 17:21:34 | [diff] [blame] | 778 | passiveDefault = WebSettings::PassiveEventListenerDefault::True; |
| 779 | else if (passiveListenersDefault == "forcealltrue") |
| 780 | passiveDefault = WebSettings::PassiveEventListenerDefault::ForceAllTrue; |
| 781 | webview()->settings()->setPassiveEventListenerDefault(passiveDefault); |
| 782 | } |
| 783 | |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 784 | ApplyBlinkSettings(command_line, webview()->settings()); |
| 785 | |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 786 | if (params.main_frame_routing_id != MSG_ROUTING_NONE) { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 787 | main_render_frame_ = RenderFrameImpl::CreateMainFrame( |
| 788 | this, params.main_frame_routing_id, params.main_frame_widget_routing_id, |
dcheng | 9e24bd35 | 2016-03-01 19:15:51 | [diff] [blame] | 789 | params.hidden, screen_info(), compositor_deps_, opener_frame); |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 790 | } |
| 791 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 792 | if (params.proxy_routing_id != MSG_ROUTING_NONE) { |
| 793 | CHECK(params.swapped_out); |
nasko | b3041b98a4 | 2016-03-12 04:43:06 | [diff] [blame] | 794 | RenderFrameProxy::CreateFrameProxy( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 795 | params.proxy_routing_id, GetRoutingID(), params.opener_frame_route_id, |
nasko | b3041b98a4 | 2016-03-12 04:43:06 | [diff] [blame] | 796 | MSG_ROUTING_NONE, params.replicated_frame_state); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 797 | } |
| 798 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 799 | if (main_render_frame_) |
| 800 | main_render_frame_->Initialize(); |
| 801 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 802 | #if defined(OS_ANDROID) |
ricea | 29649b9 | 2016-08-31 09:30:21 | [diff] [blame] | 803 | content_detectors_.push_back(base::MakeUnique<AddressDetector>()); |
qinmin | c6a739f9 | 2015-03-31 17:46:11 | [diff] [blame] | 804 | const std::string& contry_iso = |
| 805 | params.renderer_preferences.network_contry_iso; |
| 806 | if (!contry_iso.empty()) { |
limasdf | 81d962e | 2015-11-20 08:39:18 | [diff] [blame] | 807 | content_detectors_.push_back( |
ricea | 29649b9 | 2016-08-31 09:30:21 | [diff] [blame] | 808 | base::MakeUnique<PhoneNumberDetector>(contry_iso)); |
qinmin | 0d5560df | 2014-11-12 19:03:39 | [diff] [blame] | 809 | } |
ricea | 29649b9 | 2016-08-31 09:30:21 | [diff] [blame] | 810 | content_detectors_.push_back(base::MakeUnique<EmailDetector>()); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 811 | #endif |
| 812 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 813 | // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 814 | // completing initialization. Otherwise, we can finish it now. |
piman | c4af307 | 2015-10-02 03:45:59 | [diff] [blame] | 815 | if (opener_id_ == MSG_ROUTING_NONE) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 816 | did_show_ = true; |
mfomitchev | 5ad034ec | 2015-04-24 21:57:27 | [diff] [blame] | 817 | |
alexmos | 35799be | 2015-07-02 08:59:50 | [diff] [blame] | 818 | // Set the main frame's name. Only needs to be done for WebLocalFrames, |
| 819 | // since the remote case was handled as part of SetReplicatedState on the |
| 820 | // proxy above. |
| 821 | if (!params.replicated_frame_state.name.empty() && |
| 822 | webview()->mainFrame()->isWebLocalFrame()) { |
alexmos | 3448b55 | 2015-06-26 07:49:13 | [diff] [blame] | 823 | webview()->mainFrame()->setName( |
| 824 | blink::WebString::fromUTF8(params.replicated_frame_state.name)); |
| 825 | } |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 826 | |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 827 | // TODO(davidben): Move this state from Blink into content. |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 828 | if (params.window_was_created_with_opener) |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 829 | webview()->setOpenedByDOM(); |
| 830 | |
dcheng | 0ff94cfc | 2016-03-15 21:50:51 | [diff] [blame] | 831 | UpdateWebViewWithDeviceScaleFactor(); |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 832 | OnSetRendererPrefs(params.renderer_preferences); |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 833 | |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 834 | if (!params.enable_auto_resize) { |
| 835 | OnResize(params.initial_size); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 836 | } else { |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 837 | OnEnableAutoResize(params.min_size, params.max_size); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 838 | } |
| 839 | |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 840 | // We don't use HistoryController in OOPIF-enabled modes. |
| 841 | if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 842 | history_controller_.reset(new HistoryController(this)); |
[email protected] | d473498 | 2014-04-15 02:05:55 | [diff] [blame] | 843 | |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 844 | new IdleUserDetector(this); |
| 845 | |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 846 | if (command_line.HasSwitch(switches::kDomAutomationController)) |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 847 | enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
[email protected] | 27c521a | 2013-05-29 20:44:32 | [diff] [blame] | 848 | if (command_line.HasSwitch(switches::kStatsCollectionController)) |
| 849 | enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 850 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 851 | GetContentClient()->renderer()->RenderViewCreated(this); |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 852 | |
dcheng | 9e24bd35 | 2016-03-01 19:15:51 | [diff] [blame] | 853 | // Ensure that sandbox flags are inherited from an opener in a different |
| 854 | // process. In that case, the browser process will set any inherited sandbox |
| 855 | // flags in |replicated_frame_state|, so apply them here. |
alexmos | f5fb519 | 2016-04-11 22:09:04 | [diff] [blame] | 856 | if (!was_created_by_renderer && webview()->mainFrame()->isWebLocalFrame()) { |
dcheng | 9e24bd35 | 2016-03-01 19:15:51 | [diff] [blame] | 857 | webview()->mainFrame()->toWebLocalFrame()->forceSandboxFlags( |
| 858 | params.replicated_frame_state.sandbox_flags); |
alexmos | aedfc6f | 2016-01-21 23:57:38 | [diff] [blame] | 859 | } |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 860 | |
| 861 | page_zoom_level_ = params.page_zoom_level; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 862 | } |
| 863 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 864 | RenderViewImpl::~RenderViewImpl() { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 865 | DCHECK(!frame_widget_); |
| 866 | |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 867 | for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); |
| 868 | it != disambiguation_bitmaps_.end(); |
| 869 | ++it) |
| 870 | delete it->second; |
[email protected] | 91a2aea | 2013-07-08 23:14:39 | [diff] [blame] | 871 | |
[email protected] | 8ed1d3f | 2013-02-20 11:45:55 | [diff] [blame] | 872 | #if defined(OS_ANDROID) |
davve | 17e025e1 | 2016-05-23 15:30:20 | [diff] [blame] | 873 | // The date/time picker client is both a std::unique_ptr member of this class |
| 874 | // and a RenderViewObserver. Reset it to prevent double deletion. |
[email protected] | 8ed1d3f | 2013-02-20 11:45:55 | [diff] [blame] | 875 | date_time_picker_client_.reset(); |
| 876 | #endif |
| 877 | |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 878 | #ifndef NDEBUG |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 879 | // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap. |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 880 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 881 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 882 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 883 | RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer(); |
| 884 | for (RoutingIDViewMap::iterator it = routing_id_views->begin(); |
| 885 | it != routing_id_views->end(); ++it) |
| 886 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 887 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 888 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 889 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 890 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 891 | } |
| 892 | |
| 893 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 894 | RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 895 | ViewMap* views = g_view_map.Pointer(); |
| 896 | ViewMap::iterator it = views->find(webview); |
| 897 | return it == views->end() ? NULL : it->second; |
| 898 | } |
| 899 | |
| 900 | /*static*/ |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 901 | RenderView* RenderView::FromWebView(blink::WebView* webview) { |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 902 | return RenderViewImpl::FromWebView(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 903 | } |
| 904 | |
| 905 | /*static*/ |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 906 | RenderViewImpl* RenderViewImpl::FromRoutingID(int32_t routing_id) { |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 907 | RoutingIDViewMap* views = g_routing_id_view_map.Pointer(); |
| 908 | RoutingIDViewMap::iterator it = views->find(routing_id); |
| 909 | return it == views->end() ? NULL : it->second; |
| 910 | } |
| 911 | |
| 912 | /*static*/ |
| 913 | RenderView* RenderView::FromRoutingID(int routing_id) { |
| 914 | return RenderViewImpl::FromRoutingID(routing_id); |
| 915 | } |
| 916 | |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 917 | /* static */ |
jochen | 9c7b8f24 | 2015-06-01 15:32:02 | [diff] [blame] | 918 | size_t RenderView::GetRenderViewCount() { |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 919 | return g_view_map.Get().size(); |
| 920 | } |
| 921 | |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 922 | /*static*/ |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 923 | void RenderView::ForEach(RenderViewVisitor* visitor) { |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 924 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 925 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 926 | if (!visitor->Visit(it->second)) |
| 927 | return; |
| 928 | } |
| 929 | } |
| 930 | |
| 931 | /*static*/ |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 932 | void RenderView::ApplyWebPreferences(const WebPreferences& prefs, |
| 933 | WebView* web_view) { |
| 934 | WebSettings* settings = web_view->settings(); |
| 935 | ApplyFontsFromMap(prefs.standard_font_family_map, |
| 936 | SetStandardFontFamilyWrapper, settings); |
| 937 | ApplyFontsFromMap(prefs.fixed_font_family_map, |
| 938 | SetFixedFontFamilyWrapper, settings); |
| 939 | ApplyFontsFromMap(prefs.serif_font_family_map, |
| 940 | SetSerifFontFamilyWrapper, settings); |
| 941 | ApplyFontsFromMap(prefs.sans_serif_font_family_map, |
| 942 | SetSansSerifFontFamilyWrapper, settings); |
| 943 | ApplyFontsFromMap(prefs.cursive_font_family_map, |
| 944 | SetCursiveFontFamilyWrapper, settings); |
| 945 | ApplyFontsFromMap(prefs.fantasy_font_family_map, |
| 946 | SetFantasyFontFamilyWrapper, settings); |
| 947 | ApplyFontsFromMap(prefs.pictograph_font_family_map, |
| 948 | SetPictographFontFamilyWrapper, settings); |
| 949 | settings->setDefaultFontSize(prefs.default_font_size); |
| 950 | settings->setDefaultFixedFontSize(prefs.default_fixed_font_size); |
| 951 | settings->setMinimumFontSize(prefs.minimum_font_size); |
| 952 | settings->setMinimumLogicalFontSize(prefs.minimum_logical_font_size); |
| 953 | settings->setDefaultTextEncodingName( |
| 954 | base::ASCIIToUTF16(prefs.default_encoding)); |
| 955 | settings->setJavaScriptEnabled(prefs.javascript_enabled); |
| 956 | settings->setWebSecurityEnabled(prefs.web_security_enabled); |
| 957 | settings->setJavaScriptCanOpenWindowsAutomatically( |
| 958 | prefs.javascript_can_open_windows_automatically); |
| 959 | settings->setLoadsImagesAutomatically(prefs.loads_images_automatically); |
| 960 | settings->setImagesEnabled(prefs.images_enabled); |
| 961 | settings->setPluginsEnabled(prefs.plugins_enabled); |
| 962 | settings->setDOMPasteAllowed(prefs.dom_paste_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 963 | settings->setTextAreasAreResizable(prefs.text_areas_are_resizable); |
| 964 | settings->setAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows); |
| 965 | settings->setDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled); |
| 966 | settings->setJavaScriptCanAccessClipboard( |
| 967 | prefs.javascript_can_access_clipboard); |
| 968 | WebRuntimeFeatures::enableXSLT(prefs.xslt_enabled); |
| 969 | settings->setXSSAuditorEnabled(prefs.xss_auditor_enabled); |
| 970 | settings->setDNSPrefetchingEnabled(prefs.dns_prefetching_enabled); |
Ben Greenstein | 49878f5 | 2015-12-18 19:13:21 | [diff] [blame] | 971 | settings->setDataSaverEnabled(prefs.data_saver_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 972 | settings->setLocalStorageEnabled(prefs.local_storage_enabled); |
| 973 | settings->setSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled); |
| 974 | WebRuntimeFeatures::enableDatabase(prefs.databases_enabled); |
| 975 | settings->setOfflineWebApplicationCacheEnabled( |
| 976 | prefs.application_cache_enabled); |
japhet | 5018fe6 | 2016-09-14 19:14:04 | [diff] [blame] | 977 | settings->setHistoryEntryRequiresUserGesture( |
| 978 | prefs.history_entry_requires_user_gesture); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 979 | settings->setHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled); |
| 980 | settings->setCookieEnabled(prefs.cookie_enabled); |
| 981 | settings->setNavigateOnDragDrop(prefs.navigate_on_drag_drop); |
| 982 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 983 | // By default, allow_universal_access_from_file_urls is set to false and thus |
| 984 | // we mitigate attacks from local HTML files by not granting file:// URLs |
| 985 | // universal access. Only test shell will enable this. |
| 986 | settings->setAllowUniversalAccessFromFileURLs( |
| 987 | prefs.allow_universal_access_from_file_urls); |
| 988 | settings->setAllowFileAccessFromFileURLs( |
| 989 | prefs.allow_file_access_from_file_urls); |
| 990 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 991 | // Enable experimental WebGL support if requested on command line |
| 992 | // and support is compiled in. |
| 993 | settings->setExperimentalWebGLEnabled(prefs.experimental_webgl_enabled); |
| 994 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 995 | // Enable WebGL errors to the JS console if requested. |
| 996 | settings->setWebGLErrorsToConsoleEnabled( |
| 997 | prefs.webgl_errors_to_console_enabled); |
| 998 | |
| 999 | // Uses the mock theme engine for scrollbars. |
| 1000 | settings->setMockScrollbarsEnabled(prefs.mock_scrollbars_enabled); |
| 1001 | |
eseckler | 61ff914 | 2016-09-23 22:57:59 | [diff] [blame] | 1002 | settings->setHideScrollbars(prefs.hide_scrollbars); |
| 1003 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1004 | // Enable gpu-accelerated 2d canvas if requested on the command line. |
junov | 524668f2 | 2016-08-08 20:16:52 | [diff] [blame] | 1005 | WebRuntimeFeatures::enableAccelerated2dCanvas( |
| 1006 | prefs.accelerated_2d_canvas_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1007 | |
| 1008 | settings->setMinimumAccelerated2dCanvasSize( |
| 1009 | prefs.minimum_accelerated_2d_canvas_size); |
| 1010 | |
| 1011 | // Disable antialiasing for 2d canvas if requested on the command line. |
| 1012 | settings->setAntialiased2dCanvasEnabled( |
| 1013 | !prefs.antialiased_2d_canvas_disabled); |
boliu | cfcae41 | 2016-02-11 22:16:38 | [diff] [blame] | 1014 | WebRuntimeFeatures::forceDisable2dCanvasCopyOnWrite( |
| 1015 | prefs.disable_2d_canvas_copy_on_write); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1016 | |
zakerinasab | 20ebca0 | 2016-09-27 14:22:34 | [diff] [blame] | 1017 | // Disable antialiasing of clips for 2d canvas if requested on the command |
robertphillips | e25137b | 2014-10-20 13:44:34 | [diff] [blame] | 1018 | // line. |
| 1019 | settings->setAntialiasedClips2dCanvasEnabled( |
| 1020 | prefs.antialiased_clips_2d_canvas_enabled); |
| 1021 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1022 | // Set MSAA sample count for 2d canvas if requested on the command line (or |
| 1023 | // default value if not). |
| 1024 | settings->setAccelerated2dCanvasMSAASampleCount( |
| 1025 | prefs.accelerated_2d_canvas_msaa_sample_count); |
| 1026 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1027 | // Tabs to link is not part of the settings. WebCore calls |
| 1028 | // ChromeClient::tabsToLinks which is part of the glue code. |
| 1029 | web_view->setTabsToLinks(prefs.tabs_to_links); |
| 1030 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1031 | settings->setAllowRunningOfInsecureContent( |
| 1032 | prefs.allow_running_insecure_content); |
mkwst | 772ce814 | 2015-01-16 13:28:07 | [diff] [blame] | 1033 | settings->setDisableReadingFromCanvas(prefs.disable_reading_from_canvas); |
mkwst | 2fc2c4f | 2015-01-08 08:29:18 | [diff] [blame] | 1034 | settings->setStrictMixedContentChecking(prefs.strict_mixed_content_checking); |
mkwst | 2384c822 | 2015-07-30 07:26:47 | [diff] [blame] | 1035 | |
| 1036 | settings->setStrictlyBlockBlockableMixedContent( |
| 1037 | prefs.strictly_block_blockable_mixed_content); |
| 1038 | |
mkwst | 0d233e5 | 2015-08-10 09:33:14 | [diff] [blame] | 1039 | settings->setStrictMixedContentCheckingForPlugin( |
| 1040 | prefs.block_mixed_plugin_content); |
| 1041 | |
mkwst | 673a452f | 2015-01-10 14:41:50 | [diff] [blame] | 1042 | settings->setStrictPowerfulFeatureRestrictions( |
| 1043 | prefs.strict_powerful_feature_restrictions); |
jww | 9d4ca2d | 2016-01-19 20:58:59 | [diff] [blame] | 1044 | settings->setAllowGeolocationOnInsecureOrigins( |
| 1045 | prefs.allow_geolocation_on_insecure_origins); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1046 | settings->setPasswordEchoEnabled(prefs.password_echo_enabled); |
| 1047 | settings->setShouldPrintBackgrounds(prefs.should_print_backgrounds); |
| 1048 | settings->setShouldClearDocumentBackground( |
| 1049 | prefs.should_clear_document_background); |
| 1050 | settings->setEnableScrollAnimator(prefs.enable_scroll_animator); |
| 1051 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1052 | WebRuntimeFeatures::enableTouch(prefs.touch_enabled); |
| 1053 | settings->setMaxTouchPoints(prefs.pointer_events_max_touch_points); |
mustaq | 29eb709 | 2014-11-14 00:32:12 | [diff] [blame] | 1054 | settings->setAvailablePointerTypes(prefs.available_pointer_types); |
| 1055 | settings->setPrimaryPointerType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 1056 | static_cast<blink::PointerType>(prefs.primary_pointer_type)); |
mustaq | 29eb709 | 2014-11-14 00:32:12 | [diff] [blame] | 1057 | settings->setAvailableHoverTypes(prefs.available_hover_types); |
| 1058 | settings->setPrimaryHoverType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 1059 | static_cast<blink::HoverType>(prefs.primary_hover_type)); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1060 | settings->setDeviceSupportsTouch(prefs.device_supports_touch); |
| 1061 | settings->setDeviceSupportsMouse(prefs.device_supports_mouse); |
| 1062 | settings->setEnableTouchAdjustment(prefs.touch_adjustment_enabled); |
| 1063 | |
ccameron | 7c4df6c2 | 2016-08-11 03:03:15 | [diff] [blame] | 1064 | WebRuntimeFeatures::enableColorCorrectRendering( |
| 1065 | prefs.color_correct_rendering_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1066 | settings->setShouldRespectImageOrientation( |
| 1067 | prefs.should_respect_image_orientation); |
| 1068 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1069 | settings->setEditingBehavior( |
| 1070 | static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior)); |
| 1071 | |
| 1072 | settings->setSupportsMultipleWindows(prefs.supports_multiple_windows); |
| 1073 | |
ymalik | 835268c2 | 2016-02-22 16:28:12 | [diff] [blame] | 1074 | settings->setInertVisualViewport(prefs.inert_visual_viewport); |
| 1075 | |
khushalsagar | 2da2b23 | 2016-03-23 22:11:35 | [diff] [blame] | 1076 | settings->setMainFrameClipsContent(!prefs.record_whole_document); |
| 1077 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1078 | settings->setSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled); |
| 1079 | |
| 1080 | settings->setSpatialNavigationEnabled(prefs.spatial_navigation_enabled); |
| 1081 | |
| 1082 | settings->setSelectionIncludesAltImageText(true); |
| 1083 | |
[email protected] | 35103c0 | 2014-08-12 15:08:47 | [diff] [blame] | 1084 | settings->setV8CacheOptions( |
| 1085 | static_cast<WebSettings::V8CacheOptions>(prefs.v8_cache_options)); |
| 1086 | |
horo | dbcbef4 | 2016-05-10 17:02:47 | [diff] [blame] | 1087 | settings->setV8CacheStrategiesForCacheStorage( |
| 1088 | GetV8CacheStrategiesForCacheStorage()); |
| 1089 | |
je_julie.kim | 7fbb5a1a | 2015-02-09 17:26:05 | [diff] [blame] | 1090 | settings->setImageAnimationPolicy( |
| 1091 | static_cast<WebSettings::ImageAnimationPolicy>(prefs.animation_policy)); |
| 1092 | |
zqzhang | 1215ad42 | 2016-02-10 13:27:22 | [diff] [blame] | 1093 | settings->setPresentationRequiresUserGesture( |
| 1094 | prefs.user_gesture_required_for_presentation); |
| 1095 | |
halliwell | 4002be4 | 2016-03-18 18:33:40 | [diff] [blame] | 1096 | settings->setTextTrackMarginPercentage(prefs.text_track_margin_percentage); |
| 1097 | |
dcheng | 5ae8ca36 | 2015-02-05 04:03:47 | [diff] [blame] | 1098 | // Needs to happen before setIgnoreVIewportTagScaleLimits below. |
| 1099 | web_view->setDefaultPageScaleLimits( |
| 1100 | prefs.default_minimum_page_scale_factor, |
| 1101 | prefs.default_maximum_page_scale_factor); |
| 1102 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1103 | #if defined(OS_ANDROID) |
| 1104 | settings->setAllowCustomScrollbarInMainFrame(false); |
| 1105 | settings->setTextAutosizingEnabled(prefs.text_autosizing_enabled); |
| 1106 | settings->setAccessibilityFontScaleFactor(prefs.font_scale_factor); |
| 1107 | settings->setDeviceScaleAdjustment(prefs.device_scale_adjustment); |
[email protected] | 023fed31 | 2014-08-11 16:13:05 | [diff] [blame] | 1108 | settings->setFullscreenSupported(prefs.fullscreen_supported); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1109 | web_view->setIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); |
| 1110 | settings->setAutoZoomFocusedNodeToLegibleScale(true); |
| 1111 | settings->setDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled); |
| 1112 | settings->setMediaControlsOverlayPlayButtonEnabled(true); |
| 1113 | settings->setMediaPlaybackRequiresUserGesture( |
| 1114 | prefs.user_gesture_required_for_media_playback); |
| 1115 | settings->setDefaultVideoPosterURL( |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 1116 | base::ASCIIToUTF16(prefs.default_video_poster_url.spec())); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1117 | settings->setSupportDeprecatedTargetDensityDPI( |
| 1118 | prefs.support_deprecated_target_density_dpi); |
| 1119 | settings->setUseLegacyBackgroundSizeShorthandBehavior( |
| 1120 | prefs.use_legacy_background_size_shorthand_behavior); |
| 1121 | settings->setWideViewportQuirkEnabled(prefs.wide_viewport_quirk); |
| 1122 | settings->setUseWideViewport(prefs.use_wide_viewport); |
[email protected] | 9954ea9 | 2014-08-12 15:48:45 | [diff] [blame] | 1123 | settings->setForceZeroLayoutHeight(prefs.force_zero_layout_height); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1124 | settings->setViewportMetaLayoutSizeQuirk( |
| 1125 | prefs.viewport_meta_layout_size_quirk); |
| 1126 | settings->setViewportMetaMergeContentQuirk( |
| 1127 | prefs.viewport_meta_merge_content_quirk); |
| 1128 | settings->setViewportMetaNonUserScalableQuirk( |
| 1129 | prefs.viewport_meta_non_user_scalable_quirk); |
| 1130 | settings->setViewportMetaZeroValuesQuirk( |
| 1131 | prefs.viewport_meta_zero_values_quirk); |
| 1132 | settings->setClobberUserAgentInitialScaleQuirk( |
| 1133 | prefs.clobber_user_agent_initial_scale_quirk); |
| 1134 | settings->setIgnoreMainFrameOverflowHiddenQuirk( |
| 1135 | prefs.ignore_main_frame_overflow_hidden_quirk); |
| 1136 | settings->setReportScreenSizeInPhysicalPixelsQuirk( |
| 1137 | prefs.report_screen_size_in_physical_pixels_quirk); |
boliu | 1a00f26 | 2016-04-06 19:08:46 | [diff] [blame] | 1138 | settings->setShouldReuseGlobalForUnownedMainFrame( |
| 1139 | prefs.resue_global_for_unowned_main_frame); |
japhet | 98e9bd8 | 2016-06-28 23:48:45 | [diff] [blame] | 1140 | settings->setProgressBarCompletion( |
| 1141 | static_cast<WebSettings::ProgressBarCompletion>( |
| 1142 | prefs.progress_bar_completion)); |
liberato | 2f1a7e0 | 2015-08-10 16:01:41 | [diff] [blame] | 1143 | settings->setPreferHiddenVolumeControls(true); |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 1144 | |
| 1145 | // Force preload=none and disable autoplay on older or low end Android |
| 1146 | // platforms because their media pipelines are not stable enough to handle |
| 1147 | // concurrent elements. See http://crbug.com/612909, http://crbug.com/622826. |
| 1148 | const bool is_low_end_device = |
| 1149 | base::android::BuildInfo::GetInstance()->sdk_int() <= |
| 1150 | base::android::SDK_VERSION_JELLY_BEAN_MR2 || |
| 1151 | base::SysInfo::IsLowEndDevice(); |
| 1152 | settings->setForcePreloadNoneForMediaElements(is_low_end_device); |
avayvod | b28c363 | 2016-06-09 11:19:06 | [diff] [blame] | 1153 | WebRuntimeFeatures::enableAutoplayMutedVideos( |
dalecurtis | cd97125 | 2016-09-21 16:09:00 | [diff] [blame] | 1154 | prefs.autoplay_muted_videos_enabled && !is_low_end_device); |
timvolodine | db19519 | 2016-10-05 13:52:45 | [diff] [blame] | 1155 | settings->setSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default); |
liberato | 9e93489 | 2016-05-03 19:00:27 | [diff] [blame] | 1156 | #endif |
| 1157 | |
liberato | 6524fa4 | 2015-09-14 23:26:08 | [diff] [blame] | 1158 | settings->setAutoplayExperimentMode( |
| 1159 | blink::WebString::fromUTF8(prefs.autoplay_experiment_mode)); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1160 | |
yoav | a1a508b4 | 2015-10-20 12:03:21 | [diff] [blame] | 1161 | settings->setViewportEnabled(prefs.viewport_enabled); |
yoav | a1a508b4 | 2015-10-20 12:03:21 | [diff] [blame] | 1162 | settings->setViewportMetaEnabled(prefs.viewport_meta_enabled); |
mlliu | b27b45c6 | 2016-06-10 19:30:09 | [diff] [blame] | 1163 | settings->setShrinksViewportContentToFit( |
| 1164 | prefs.shrinks_viewport_contents_to_fit); |
alokp | 5d56696 | 2016-04-19 00:54:16 | [diff] [blame] | 1165 | settings->setViewportStyle( |
| 1166 | static_cast<blink::WebViewportStyle>(prefs.viewport_style)); |
| 1167 | |
| 1168 | settings->setLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale); |
yoav | a1a508b4 | 2015-10-20 12:03:21 | [diff] [blame] | 1169 | settings->setMainFrameResizesAreOrientationChanges( |
| 1170 | prefs.main_frame_resizes_are_orientation_changes); |
| 1171 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1172 | settings->setPinchOverlayScrollbarThickness( |
| 1173 | prefs.pinch_overlay_scrollbar_thickness); |
| 1174 | settings->setUseSolidColorScrollbars(prefs.use_solid_color_scrollbars); |
jinho.bang | 8f11ffa | 2014-12-04 06:03:03 | [diff] [blame] | 1175 | |
arjanl | 9880491 | 2015-03-04 09:23:04 | [diff] [blame] | 1176 | settings->setShowContextMenuOnMouseUp(prefs.context_menu_on_mouse_up); |
amaralp | 547e419 | 2016-06-03 19:17:35 | [diff] [blame] | 1177 | settings->setAlwaysShowContextMenuOnTouch( |
| 1178 | prefs.always_show_context_menu_on_touch); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1179 | |
| 1180 | #if defined(OS_MACOSX) |
| 1181 | settings->setDoubleTapToZoomEnabled(true); |
ccameron | f29a780 | 2015-02-20 22:11:25 | [diff] [blame] | 1182 | web_view->setMaximumLegibleScale(prefs.default_maximum_page_scale_factor); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1183 | #endif |
sunyunjia | 87f287b | 2016-09-09 00:38:13 | [diff] [blame] | 1184 | |
| 1185 | #if defined(OS_WIN) |
| 1186 | WebRuntimeFeatures::enableMiddleClickAutoscroll(true); |
| 1187 | #endif |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1188 | } |
| 1189 | |
| 1190 | /*static*/ |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1191 | RenderViewImpl* RenderViewImpl::Create(CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 1192 | const mojom::CreateViewParams& params, |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 1193 | bool was_created_by_renderer) { |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1194 | DCHECK(params.view_id != MSG_ROUTING_NONE); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1195 | RenderViewImpl* render_view = NULL; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1196 | if (g_create_render_view_impl) |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1197 | render_view = g_create_render_view_impl(compositor_deps, params); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1198 | else |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1199 | render_view = new RenderViewImpl(compositor_deps, params); |
[email protected] | 0287e76 | 2014-04-11 13:07:58 | [diff] [blame] | 1200 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1201 | render_view->Initialize(params, was_created_by_renderer); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1202 | return render_view; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | // static |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1206 | void RenderViewImpl::InstallCreateHook(RenderViewImpl* ( |
| 1207 | *create_render_view_impl)(CompositorDependencies* compositor_deps, |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 1208 | const mojom::CreateViewParams&)) { |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1209 | CHECK(!g_create_render_view_impl); |
| 1210 | g_create_render_view_impl = create_render_view_impl; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1211 | } |
| 1212 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1213 | void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1214 | observers_.AddObserver(observer); |
| 1215 | } |
| 1216 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1217 | void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 1218 | observer->RenderViewGone(); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1219 | observers_.RemoveObserver(observer); |
| 1220 | } |
| 1221 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1222 | blink::WebView* RenderViewImpl::webview() const { |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 1223 | return webview_; |
[email protected] | 4d51d5bf | 2010-07-26 18:48:26 | [diff] [blame] | 1224 | } |
| 1225 | |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 1226 | #if defined(ENABLE_PLUGINS) |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 1227 | |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 1228 | #if defined(OS_MACOSX) |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1229 | void RenderViewImpl::OnGetRenderedText() { |
| 1230 | if (!webview()) |
| 1231 | return; |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 1232 | |
| 1233 | if (!webview()->mainFrame()->isWebLocalFrame()) |
| 1234 | return; |
| 1235 | |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1236 | // Get rendered text from WebLocalFrame. |
| 1237 | // TODO: Currently IPC truncates any data that has a |
| 1238 | // size > kMaximumMessageSize. May be split the text into smaller chunks and |
| 1239 | // send back using multiple IPC. See http://crbug.com/393444. |
| 1240 | static const size_t kMaximumMessageSize = 8 * 1024 * 1024; |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 1241 | // TODO(dglazkov): Using this API is wrong. It's not OOPIF-compatible and |
| 1242 | // sends text in the wrong order. See http://crbug.com/584798. |
| 1243 | // TODO(dglazkov): WebFrameContentDumper should only be used for |
| 1244 | // testing purposes. See http://crbug.com/585164. |
| 1245 | std::string text = |
dglazkov | 2f8c7fc | 2016-04-17 19:46:20 | [diff] [blame] | 1246 | WebFrameContentDumper::dumpWebViewAsText(webview(), kMaximumMessageSize) |
dglazkov | 0322349 | 2016-02-08 22:16:03 | [diff] [blame] | 1247 | .utf8(); |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1248 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1249 | Send(new ViewMsg_GetRenderedTextCompleted(GetRoutingID(), text)); |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1250 | } |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 1251 | #endif // defined(OS_MACOSX) |
| 1252 | |
| 1253 | #endif // ENABLE_PLUGINS |
| 1254 | |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 1255 | void RenderViewImpl::TransferActiveWheelFlingAnimation( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1256 | const blink::WebActiveWheelFlingParameters& params) { |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 1257 | if (webview()) |
| 1258 | webview()->transferActiveWheelFlingAnimation(params); |
| 1259 | } |
| 1260 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1261 | // RenderWidgetInputHandlerDelegate ----------------------------------------- |
| 1262 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1263 | void RenderViewImpl::RenderWidgetFocusChangeComplete() { |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1264 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); |
| 1265 | } |
| 1266 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1267 | bool RenderViewImpl::DoesRenderWidgetHaveTouchEventHandlersAt( |
| 1268 | const gfx::Point& point) const { |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1269 | if (!webview()) |
| 1270 | return false; |
| 1271 | return webview()->hasTouchEventHandlersAt(point); |
| 1272 | } |
| 1273 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1274 | bool RenderViewImpl::RenderWidgetWillHandleGestureEvent( |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1275 | const blink::WebGestureEvent& event) { |
| 1276 | possible_drag_event_info_.event_source = |
| 1277 | ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
| 1278 | possible_drag_event_info_.event_location = |
| 1279 | gfx::Point(event.globalX, event.globalY); |
| 1280 | return false; |
| 1281 | } |
| 1282 | |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1283 | bool RenderViewImpl::RenderWidgetWillHandleMouseEvent( |
| 1284 | const blink::WebMouseEvent& event) { |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1285 | possible_drag_event_info_.event_source = |
| 1286 | ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; |
| 1287 | possible_drag_event_info_.event_location = |
| 1288 | gfx::Point(event.globalX, event.globalY); |
| 1289 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1290 | // If the mouse is locked, only the current owner of the mouse lock can |
| 1291 | // process mouse events. |
| 1292 | return mouse_lock_dispatcher_->WillHandleMouseEvent(event); |
| 1293 | } |
| 1294 | |
| 1295 | // IPC::Listener implementation ---------------------------------------------- |
| 1296 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1297 | bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1298 | WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 1299 | if (main_frame && main_frame->isWebLocalFrame()) |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1300 | GetContentClient()->SetActiveURL(main_frame->document().url()); |
[email protected] | f8b6b6f | 2009-03-10 16:48:26 | [diff] [blame] | 1301 | |
nasko | c6edf7e | 2015-10-16 01:48:45 | [diff] [blame] | 1302 | // Input IPC messages must not be processed if the RenderView is in |
| 1303 | // swapped out state. |
| 1304 | if (is_swapped_out_ && IPC_MESSAGE_ID_CLASS(message.type()) == InputMsgStart) |
| 1305 | return false; |
| 1306 | |
dcheng | a2d442c2 | 2016-10-13 15:39:21 | [diff] [blame^] | 1307 | for (auto& observer : observers_) { |
| 1308 | if (observer.OnMessageReceived(message)) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1309 | return true; |
dcheng | a2d442c2 | 2016-10-13 15:39:21 | [diff] [blame^] | 1310 | } |
[email protected] | b2abac7 | 2009-02-26 12:39:28 | [diff] [blame] | 1311 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1312 | bool handled = true; |
[email protected] | e44d134 | 2014-05-16 21:29:33 | [diff] [blame] | 1313 | IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1314 | IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 1315 | IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1316 | IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
| 1317 | OnScrollFocusedEditableNodeIntoRect) |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 1318 | IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
[email protected] | 630e26b | 2008-10-14 22:55:17 | [diff] [blame] | 1319 | IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
scottmg | 3ea1571 | 2016-08-09 16:46:41 | [diff] [blame] | 1320 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 1321 | OnSetZoomLevelForLoadingURL) |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 1322 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 1323 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 1324 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 1325 | IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
[email protected] | 7a6d773f | 2014-04-04 01:25:09 | [diff] [blame] | 1326 | IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded) |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 1327 | IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
| 1328 | OnDragSourceSystemDragEnded) |
[email protected] | 18cb257 | 2008-08-21 20:34:45 | [diff] [blame] | 1329 | IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1330 | IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1331 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 1332 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 1333 | IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 1334 | OnEnumerateDirectoryResponse) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1335 | IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 1336 | IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
[email protected] | ab6c911 | 2014-02-27 00:20:58 | [diff] [blame] | 1337 | IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 1338 | IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
[email protected] | ab32b16c | 2009-10-16 14:57:25 | [diff] [blame] | 1339 | IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1340 | OnEnablePreferredSizeChangedMode) |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 1341 | IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 1342 | IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 1343 | IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 1344 | OnDisableScrollbarsForSmallWindows) |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1345 | IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 1346 | IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1347 | IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 1348 | IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
[email protected] | 4782226 | 2013-04-23 17:22:36 | [diff] [blame] | 1349 | IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 1350 | IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
| 1351 | OnReleaseDisambiguationPopupBitmap) |
[email protected] | 506563d | 2014-06-23 12:22:41 | [diff] [blame] | 1352 | IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1353 | IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1354 | |
| 1355 | // Page messages. |
lfg | db5c4ed | 2016-03-04 23:09:07 | [diff] [blame] | 1356 | IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, |
| 1357 | OnUpdateWindowScreenRect) |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1358 | IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) |
wjmaclean | 8a795f3 | 2016-08-11 23:49:58 | [diff] [blame] | 1359 | IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor); |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 1360 | IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) |
| 1361 | IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) |
alexmos | 136fd6e6 | 2016-08-15 20:58:41 | [diff] [blame] | 1362 | IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, |
| 1363 | OnSetHistoryOffsetAndLength) |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 1364 | |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1365 | #if defined(OS_ANDROID) |
[email protected] | 452b4a9 | 2013-03-28 21:24:38 | [diff] [blame] | 1366 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
| 1367 | OnUpdateTopControlsState) |
[email protected] | c4790dcb | 2013-12-27 22:08:02 | [diff] [blame] | 1368 | IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1369 | #elif defined(OS_MACOSX) |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1370 | IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, |
| 1371 | OnGetRenderedText) |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 1372 | IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1373 | #endif |
[email protected] | a794f3a | 2013-10-30 17:00:32 | [diff] [blame] | 1374 | // Adding a new message? Add platform independent ones first, then put the |
| 1375 | // platform specific ones at the end. |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1376 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1377 | // Have the super handle all other messages. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1378 | IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1379 | IPC_END_MESSAGE_MAP() |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 1380 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1381 | return handled; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1382 | } |
| 1383 | |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1384 | void RenderViewImpl::OnSelectWordAroundCaret() { |
| 1385 | if (!webview()) |
| 1386 | return; |
| 1387 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1388 | input_handler_->set_handling_input_event(true); |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1389 | webview()->focusedFrame()->selectWordAroundCaret(); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1390 | input_handler_->set_handling_input_event(false); |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1391 | } |
| 1392 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1393 | void RenderViewImpl::OnUpdateTargetURLAck() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1394 | // Check if there is a targeturl waiting to be sent. |
avi | 450ce00e | 2014-09-24 01:58:52 | [diff] [blame] | 1395 | if (target_url_status_ == TARGET_PENDING) |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1396 | Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), pending_target_url_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1397 | |
| 1398 | target_url_status_ = TARGET_NONE; |
| 1399 | } |
| 1400 | |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1401 | void RenderViewImpl::OnExecuteEditCommand(const std::string& name, |
| 1402 | const std::string& value) { |
| 1403 | if (!webview() || !webview()->focusedFrame()) |
| 1404 | return; |
| 1405 | |
| 1406 | webview()->focusedFrame()->executeCommand( |
| 1407 | WebString::fromUTF8(name), WebString::fromUTF8(value)); |
| 1408 | } |
| 1409 | |
| 1410 | void RenderViewImpl::OnMoveCaret(const gfx::Point& point) { |
| 1411 | if (!webview()) |
| 1412 | return; |
| 1413 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1414 | Send(new InputHostMsg_MoveCaret_ACK(GetRoutingID())); |
oshima | 93b827d9 | 2016-03-01 18:58:41 | [diff] [blame] | 1415 | webview()->focusedFrame()->moveCaretSelection( |
| 1416 | ConvertWindowPointToViewport(point)); |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1417 | } |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1418 | |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1419 | void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1420 | const gfx::Rect& rect) { |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1421 | if (has_scrolled_focused_editable_node_into_rect_ && |
| 1422 | rect == rect_for_scrolled_focused_editable_node_) { |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1423 | GetWidget()->FocusChangeComplete(); |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1424 | return; |
| 1425 | } |
| 1426 | |
dglazkov | 4969a3e | 2016-05-20 21:13:51 | [diff] [blame] | 1427 | if (!webview()->scrollFocusedEditableElementIntoRect(rect)) |
| 1428 | return; |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 1429 | |
dglazkov | 4969a3e | 2016-05-20 21:13:51 | [diff] [blame] | 1430 | rect_for_scrolled_focused_editable_node_ = rect; |
| 1431 | has_scrolled_focused_editable_node_into_rect_ = true; |
| 1432 | if (!compositor()->hasPendingPageScaleAnimation()) |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 1433 | GetWidget()->FocusChangeComplete(); |
[email protected] | 25bcc8f | 2013-01-09 02:49:25 | [diff] [blame] | 1434 | } |
| 1435 | |
avi | 2b17759 | 2014-12-10 02:08:02 | [diff] [blame] | 1436 | void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
| 1437 | int history_length) { |
| 1438 | DCHECK_GE(history_offset, -1); |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 1439 | DCHECK_GE(history_length, 0); |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1440 | |
avi | 2b17759 | 2014-12-10 02:08:02 | [diff] [blame] | 1441 | history_list_offset_ = history_offset; |
| 1442 | history_list_length_ = history_length; |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1443 | } |
| 1444 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1445 | void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1446 | if (!webview()) |
| 1447 | return; |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1448 | webview()->setInitialFocus(reverse); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1449 | } |
| 1450 | |
lfg | db5c4ed | 2016-03-04 23:09:07 | [diff] [blame] | 1451 | void RenderViewImpl::OnUpdateWindowScreenRect(gfx::Rect window_screen_rect) { |
| 1452 | RenderWidget::OnUpdateWindowScreenRect(window_screen_rect); |
| 1453 | } |
| 1454 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1455 | /////////////////////////////////////////////////////////////////////////////// |
| 1456 | |
avi | 137dc95 | 2015-07-24 23:19:14 | [diff] [blame] | 1457 | void RenderViewImpl::SendUpdateState() { |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1458 | // We don't use this path in OOPIF-enabled modes. |
| 1459 | DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); |
creis | ae7ce9a | 2015-11-02 20:52:19 | [diff] [blame] | 1460 | |
avi | 137dc95 | 2015-07-24 23:19:14 | [diff] [blame] | 1461 | HistoryEntry* entry = history_controller_->GetCurrentEntry(); |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1462 | if (!entry) |
| 1463 | return; |
| 1464 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1465 | Send(new ViewHostMsg_UpdateState(GetRoutingID(), page_id_, |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1466 | HistoryEntryToPageState(entry))); |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1467 | } |
| 1468 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1469 | void RenderViewImpl::SendFrameStateUpdates() { |
| 1470 | // We only use this path in OOPIF-enabled modes. |
| 1471 | DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 1472 | |
| 1473 | // Tell each frame with pending state to send its UpdateState message. |
| 1474 | for (int render_frame_routing_id : frames_with_pending_state_) { |
| 1475 | RenderFrameImpl* frame = |
| 1476 | RenderFrameImpl::FromRoutingID(render_frame_routing_id); |
| 1477 | if (frame) |
| 1478 | frame->SendUpdateState(); |
| 1479 | } |
| 1480 | frames_with_pending_state_.clear(); |
| 1481 | } |
| 1482 | |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 1483 | void RenderViewImpl::ApplyWebPreferencesInternal( |
| 1484 | const WebPreferences& prefs, |
| 1485 | blink::WebView* web_view, |
| 1486 | CompositorDependencies* compositor_deps) { |
| 1487 | ApplyWebPreferences(prefs, web_view); |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 1488 | } |
| 1489 | |
svartmetal | 751af1f9 | 2016-08-13 11:47:33 | [diff] [blame] | 1490 | void RenderViewImpl::OnForceRedraw(const ui::LatencyInfo& latency_info) { |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 1491 | if (RenderWidgetCompositor* rwc = compositor()) { |
svartmetal | 751af1f9 | 2016-08-13 11:47:33 | [diff] [blame] | 1492 | rwc->QueueSwapPromise( |
| 1493 | base::MakeUnique<AlwaysDrawSwapPromise>(latency_info)); |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 1494 | } |
| 1495 | ScheduleCompositeWithForcedRedraw(); |
[email protected] | c9bc8f1 | 2012-12-15 22:20:09 | [diff] [blame] | 1496 | } |
| 1497 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1498 | // blink::WebViewClient ------------------------------------------------------ |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1499 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 1500 | WebView* RenderViewImpl::createView(WebLocalFrame* creator, |
| 1501 | const WebURLRequest& request, |
| 1502 | const WebWindowFeatures& features, |
| 1503 | const WebString& frame_name, |
| 1504 | WebNavigationPolicy policy, |
| 1505 | bool suppress_opener) { |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1506 | mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New(); |
| 1507 | params->opener_id = GetRoutingID(); |
| 1508 | params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
[email protected] | 00323f0 | 2013-07-24 15:47:41 | [diff] [blame] | 1509 | if (GetContentClient()->renderer()->AllowPopup()) |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1510 | params->user_gesture = true; |
| 1511 | params->window_container_type = WindowFeaturesToContainerType(features); |
| 1512 | params->session_storage_namespace_id = session_storage_namespace_id_; |
[email protected] | 5cef23d | 2013-02-27 13:11:21 | [diff] [blame] | 1513 | if (frame_name != "_blank") |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1514 | params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name)); |
| 1515 | params->opener_render_frame_id = |
[email protected] | 501052ff | 2014-02-21 22:19:07 | [diff] [blame] | 1516 | RenderFrameImpl::FromWebFrame(creator)->GetRoutingID(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1517 | params->opener_url = creator->document().url(); |
alexmos | a97d5c5 | 2015-06-19 22:19:09 | [diff] [blame] | 1518 | |
| 1519 | // The browser process uses the top frame's URL for a content settings check |
| 1520 | // to determine whether the popup is allowed. If the top frame is remote, |
| 1521 | // its URL is not available, so use its replicated origin instead. |
| 1522 | // |
| 1523 | // TODO(alexmos): This works fine for regular origins but may break path |
| 1524 | // matching for file URLs with OOP subframes that open popups. This should |
| 1525 | // be fixed by either moving this lookup to the browser process or removing |
| 1526 | // path-based matching for file URLs from content settings. See |
| 1527 | // https://crbug.com/466297. |
| 1528 | if (creator->top()->isWebLocalFrame()) { |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1529 | params->opener_top_level_frame_url = creator->top()->document().url(); |
alexmos | a97d5c5 | 2015-06-19 22:19:09 | [diff] [blame] | 1530 | } else { |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1531 | params->opener_top_level_frame_url = |
Dana Jansens | 7133125 | 2016-03-09 20:57:22 | [diff] [blame] | 1532 | blink::WebStringToGURL(creator->top()->getSecurityOrigin().toString()); |
alexmos | a97d5c5 | 2015-06-19 22:19:09 | [diff] [blame] | 1533 | } |
| 1534 | |
brettw | dfbcc3b | 2016-01-20 01:49:17 | [diff] [blame] | 1535 | GURL security_url(blink::WebStringToGURL( |
Dana Jansens | 7133125 | 2016-03-09 20:57:22 | [diff] [blame] | 1536 | creator->document().getSecurityOrigin().toString())); |
[email protected] | 7f48b71 | 2013-01-25 01:48:30 | [diff] [blame] | 1537 | if (!security_url.is_valid()) |
| 1538 | security_url = GURL(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1539 | params->opener_security_origin = security_url; |
| 1540 | params->opener_suppressed = suppress_opener; |
| 1541 | params->disposition = NavigationPolicyToDisposition(policy); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 1542 | if (!request.isNull()) { |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1543 | params->target_url = request.url(); |
| 1544 | params->referrer = GetReferrerFromRequest(creator, request); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 1545 | } |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1546 | params->features = features; |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1547 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1548 | // We preserve this information before sending the message since |params| is |
| 1549 | // moved on send. |
| 1550 | bool is_background_tab = |
| 1551 | params->disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB; |
| 1552 | bool opened_by_user_gesture = params->user_gesture; |
[email protected] | 22217ed3 | 2013-11-18 18:40:23 | [diff] [blame] | 1553 | |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1554 | mojom::CreateNewWindowReplyPtr reply; |
| 1555 | RenderThreadImpl::current_render_message_filter()->CreateNewWindow( |
| 1556 | std::move(params), &reply); |
| 1557 | if (reply->route_id == MSG_ROUTING_NONE) |
| 1558 | return nullptr; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1559 | |
[email protected] | af15bf2 | 2013-03-08 01:18:17 | [diff] [blame] | 1560 | WebUserGestureIndicator::consumeUserGesture(); |
[email protected] | c5926242 | 2012-11-30 21:20:52 | [diff] [blame] | 1561 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 1562 | // While this view may be a background extension page, it can spawn a visible |
| 1563 | // render view. So we just assume that the new one is not another background |
| 1564 | // page instead of passing on our own value. |
| 1565 | // TODO(vangelis): Can we tell if the new view will be a background page? |
| 1566 | bool never_visible = false; |
[email protected] | 9115d5f | 2013-03-24 04:37:41 | [diff] [blame] | 1567 | |
fsamuel | 664e8b6 | 2016-01-20 19:54:01 | [diff] [blame] | 1568 | ResizeParams initial_size = ResizeParams(); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 1569 | initial_size.screen_info = screen_info_; |
| 1570 | |
[email protected] | d6fa88f | 2013-10-18 16:00:43 | [diff] [blame] | 1571 | // The initial hidden state for the RenderViewImpl here has to match what the |
| 1572 | // browser will eventually decide for the given disposition. Since we have to |
| 1573 | // return from this call synchronously, we just have to make our best guess |
| 1574 | // and rely on the browser sending a WasHidden / WasShown message if it |
| 1575 | // disagrees. |
rockot | 067ca55f | 2016-09-30 22:00:15 | [diff] [blame] | 1576 | mojom::CreateViewParams view_params; |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1577 | |
| 1578 | RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
| 1579 | view_params.opener_frame_route_id = creator_frame->GetRoutingID(); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1580 | DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID()); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1581 | |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1582 | view_params.window_was_created_with_opener = true; |
| 1583 | view_params.renderer_preferences = renderer_preferences_; |
| 1584 | view_params.web_preferences = webkit_preferences_; |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1585 | view_params.view_id = reply->route_id; |
| 1586 | view_params.main_frame_routing_id = reply->main_frame_route_id; |
| 1587 | view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1588 | view_params.session_storage_namespace_id = |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1589 | reply->cloned_session_storage_namespace_id; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1590 | view_params.swapped_out = false; |
alexmos | 3448b55 | 2015-06-26 07:49:13 | [diff] [blame] | 1591 | // WebCore will take care of setting the correct name. |
alexmos | bc7eafa | 2014-12-06 01:38:09 | [diff] [blame] | 1592 | view_params.replicated_frame_state = FrameReplicationState(); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1593 | view_params.hidden = is_background_tab; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1594 | view_params.never_visible = never_visible; |
| 1595 | view_params.next_page_id = 1; |
| 1596 | view_params.initial_size = initial_size; |
| 1597 | view_params.enable_auto_resize = false; |
| 1598 | view_params.min_size = gfx::Size(); |
| 1599 | view_params.max_size = gfx::Size(); |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1600 | view_params.page_zoom_level = page_zoom_level_; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1601 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 1602 | RenderViewImpl* view = |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1603 | RenderViewImpl::Create(compositor_deps_, view_params, true); |
rockot | 5c478a7 | 2016-09-28 23:14:18 | [diff] [blame] | 1604 | view->opened_by_user_gesture_ = opened_by_user_gesture; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1605 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1606 | return view->webview(); |
| 1607 | } |
| 1608 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1609 | WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1610 | RenderWidget* widget = RenderWidget::Create(GetRoutingID(), compositor_deps_, |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 1611 | popup_type, screen_info_); |
[email protected] | 3b78ec1 | 2014-03-04 05:18:28 | [diff] [blame] | 1612 | if (!widget) |
| 1613 | return NULL; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 1614 | if (screen_metrics_emulator_) { |
| 1615 | widget->SetPopupOriginAdjustmentsForEmulation( |
| 1616 | screen_metrics_emulator_.get()); |
| 1617 | } |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 1618 | return widget->GetWebWidget(); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1619 | } |
| 1620 | |
[email protected] | 2336748 | 2013-06-27 21:06:54 | [diff] [blame] | 1621 | WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 1622 | CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
[email protected] | 1910fe8 | 2012-05-10 00:04:10 | [diff] [blame] | 1623 | return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1624 | } |
| 1625 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 1626 | void RenderViewImpl::printPage(WebLocalFrame* frame) { |
nasko | e440d8c | 2016-10-12 23:07:56 | [diff] [blame] | 1627 | UMA_HISTOGRAM_BOOLEAN("PrintPreview.InitiatedByScript", |
| 1628 | frame->top() == frame); |
| 1629 | |
| 1630 | // Logging whether the top frame is remote is sufficient in this case. If |
| 1631 | // the top frame is local, the printing code will function correctly and |
| 1632 | // the frame itself will be printed, so the cases this histogram tracks is |
| 1633 | // where printing of a subframe will fail as of now. |
| 1634 | UMA_HISTOGRAM_BOOLEAN("PrintPreview.OutOfProcessSubframe", |
| 1635 | frame->top()->isWebRemoteFrame()); |
| 1636 | |
[email protected] | b0553c7e | 2012-09-19 21:36:11 | [diff] [blame] | 1637 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1638 | PrintPage(frame, input_handler().handling_input_event())); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1639 | } |
| 1640 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1641 | bool RenderViewImpl::enumerateChosenDirectory( |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1642 | const WebString& path, |
| 1643 | WebFileChooserCompletion* chooser_completion) { |
| 1644 | int id = enumeration_completion_id_++; |
| 1645 | enumeration_completions_[id] = chooser_completion; |
| 1646 | return Send(new ViewHostMsg_EnumerateDirectory( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1647 | GetRoutingID(), id, blink::WebStringToFilePath(path))); |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1648 | } |
| 1649 | |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1650 | void RenderViewImpl::FrameDidStartLoading(WebFrame* frame) { |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1651 | DCHECK_GE(frames_in_progress_, 0); |
| 1652 | if (frames_in_progress_ == 0) |
| 1653 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); |
| 1654 | frames_in_progress_++; |
[email protected] | 6dd5c32 | 2014-03-12 07:58:46 | [diff] [blame] | 1655 | } |
| 1656 | |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1657 | void RenderViewImpl::FrameDidStopLoading(WebFrame* frame) { |
[email protected] | eb47377 | 2014-04-11 20:54:33 | [diff] [blame] | 1658 | // TODO(japhet): This should be a DCHECK, but the pdf plugin sometimes |
| 1659 | // calls DidStopLoading() without a matching DidStartLoading(). |
| 1660 | if (frames_in_progress_ == 0) |
| 1661 | return; |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1662 | frames_in_progress_--; |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1663 | if (frames_in_progress_ == 0) { |
| 1664 | DidStopLoadingIcons(); |
| 1665 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
| 1666 | } |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1667 | } |
| 1668 | |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 1669 | void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 1670 | // The previous WebFrameWidget must already be detached by CloseForFrame(). |
| 1671 | DCHECK(!frame_widget_); |
| 1672 | frame_widget_ = frame_widget; |
| 1673 | } |
| 1674 | |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 1675 | void RenderViewImpl::SetZoomLevel(double zoom_level) { |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 1676 | // If we change the zoom level for the view, make sure any subsequent subframe |
| 1677 | // loads reflect the current zoom level. |
| 1678 | page_zoom_level_ = zoom_level; |
| 1679 | |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 1680 | webview()->setZoomLevel(zoom_level); |
| 1681 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); |
| 1682 | } |
| 1683 | |
[email protected] | 550b0c9 | 2013-02-04 05:09:15 | [diff] [blame] | 1684 | void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1685 | Send(new InputHostMsg_ImeCancelComposition(GetRoutingID())); |
[email protected] | 550b0c9 | 2013-02-04 05:09:15 | [diff] [blame] | 1686 | } |
| 1687 | |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1688 | void RenderViewImpl::SetValidationMessageDirection( |
| 1689 | base::string16* wrapped_main_text, |
| 1690 | blink::WebTextDirection main_text_hint, |
| 1691 | base::string16* wrapped_sub_text, |
| 1692 | blink::WebTextDirection sub_text_hint) { |
| 1693 | if (main_text_hint == blink::WebTextDirectionLeftToRight) { |
| 1694 | *wrapped_main_text = |
| 1695 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text); |
| 1696 | } else if (main_text_hint == blink::WebTextDirectionRightToLeft && |
| 1697 | !base::i18n::IsRTL()) { |
| 1698 | base::i18n::WrapStringWithRTLFormatting(wrapped_main_text); |
| 1699 | } |
| 1700 | |
| 1701 | if (!wrapped_sub_text->empty()) { |
| 1702 | if (sub_text_hint == blink::WebTextDirectionLeftToRight) { |
| 1703 | *wrapped_sub_text = |
| 1704 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_sub_text); |
| 1705 | } else if (sub_text_hint == blink::WebTextDirectionRightToLeft) { |
| 1706 | base::i18n::WrapStringWithRTLFormatting(wrapped_sub_text); |
| 1707 | } |
| 1708 | } |
| 1709 | } |
| 1710 | |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1711 | void RenderViewImpl::showValidationMessage( |
bokan | 72a7e34 | 2015-12-03 15:46:28 | [diff] [blame] | 1712 | const blink::WebRect& anchor_in_viewport, |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1713 | const blink::WebString& main_text, |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1714 | blink::WebTextDirection main_text_hint, |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1715 | const blink::WebString& sub_text, |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1716 | blink::WebTextDirection sub_text_hint) { |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1717 | base::string16 wrapped_main_text = main_text; |
| 1718 | base::string16 wrapped_sub_text = sub_text; |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1719 | |
| 1720 | SetValidationMessageDirection( |
| 1721 | &wrapped_main_text, main_text_hint, &wrapped_sub_text, sub_text_hint); |
| 1722 | |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1723 | Send(new ViewHostMsg_ShowValidationMessage( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1724 | GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport), |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 1725 | wrapped_main_text, wrapped_sub_text)); |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1726 | } |
| 1727 | |
| 1728 | void RenderViewImpl::hideValidationMessage() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1729 | Send(new ViewHostMsg_HideValidationMessage(GetRoutingID())); |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1730 | } |
| 1731 | |
| 1732 | void RenderViewImpl::moveValidationMessage( |
bokan | 72a7e34 | 2015-12-03 15:46:28 | [diff] [blame] | 1733 | const blink::WebRect& anchor_in_viewport) { |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 1734 | Send(new ViewHostMsg_MoveValidationMessage( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1735 | GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport))); |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1736 | } |
| 1737 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1738 | void RenderViewImpl::setStatusText(const WebString& text) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1739 | } |
| 1740 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1741 | void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 1742 | const GURL& fallback_url) { |
[email protected] | aa6b90b3 | 2010-04-26 15:49:58 | [diff] [blame] | 1743 | GURL latest_url = url.is_empty() ? fallback_url : url; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1744 | if (latest_url == target_url_) |
| 1745 | return; |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1746 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1747 | // Tell the browser to display a destination link. |
| 1748 | if (target_url_status_ == TARGET_INFLIGHT || |
| 1749 | target_url_status_ == TARGET_PENDING) { |
| 1750 | // If we have a request in-flight, save the URL to be sent when we |
| 1751 | // receive an ACK to the in-flight request. We can happily overwrite |
| 1752 | // any existing pending sends. |
| 1753 | pending_target_url_ = latest_url; |
| 1754 | target_url_status_ = TARGET_PENDING; |
| 1755 | } else { |
mnaganov | bf08742 | 2015-12-16 05:10:03 | [diff] [blame] | 1756 | // URLs larger than |kMaxURLChars| cannot be sent through IPC - |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1757 | // see |ParamTraits<GURL>|. |
markdittmer | 67b71ea | 2016-03-03 22:40:03 | [diff] [blame] | 1758 | if (latest_url.possibly_invalid_spec().size() > url::kMaxURLChars) |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1759 | latest_url = GURL(); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1760 | Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), latest_url)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1761 | target_url_ = latest_url; |
| 1762 | target_url_status_ = TARGET_INFLIGHT; |
| 1763 | } |
| 1764 | } |
| 1765 | |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 1766 | gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( |
| 1767 | const gfx::RectF& rect) const { |
| 1768 | gfx::RectF window_rect = rect; |
| 1769 | window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); |
| 1770 | return window_rect; |
| 1771 | } |
| 1772 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1773 | void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { |
| 1774 | // In OOPIF modes, keep track of which frames have pending updates. |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1775 | if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1776 | frames_with_pending_state_.insert(frame->GetRoutingID()); |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1777 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1778 | int delay; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1779 | if (send_content_state_immediately_) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1780 | delay = 0; |
| 1781 | else if (is_hidden()) |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1782 | delay = kDelaySecondsForContentStateSyncHidden; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1783 | else |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1784 | delay = kDelaySecondsForContentStateSync; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1785 | |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1786 | if (nav_state_sync_timer_.IsRunning()) { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1787 | // The timer is already running. If the delay of the timer maches the amount |
| 1788 | // we want to delay by, then return. Otherwise stop the timer so that it |
| 1789 | // gets started with the right delay. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1790 | if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1791 | return; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1792 | nav_state_sync_timer_.Stop(); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1793 | } |
| 1794 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1795 | if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 1796 | // In OOPIF modes, tell each frame with pending state to inform the browser. |
| 1797 | nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
| 1798 | &RenderViewImpl::SendFrameStateUpdates); |
| 1799 | } else { |
| 1800 | // By default, send an UpdateState for the current history item. |
| 1801 | nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
| 1802 | &RenderViewImpl::SendUpdateState); |
| 1803 | } |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1804 | } |
| 1805 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1806 | void RenderViewImpl::setMouseOverURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1807 | mouse_over_url_ = GURL(url); |
| 1808 | UpdateTargetURL(mouse_over_url_, focus_url_); |
| 1809 | } |
| 1810 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1811 | void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1812 | focus_url_ = GURL(url); |
| 1813 | UpdateTargetURL(focus_url_, mouse_over_url_); |
| 1814 | } |
| 1815 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 1816 | void RenderViewImpl::startDragging(WebLocalFrame* frame, |
[email protected] | 0407e42 | 2012-05-18 19:51:25 | [diff] [blame] | 1817 | const WebDragData& data, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1818 | WebDragOperationsMask mask, |
| 1819 | const WebImage& image, |
[email protected] | ceb36f7d | 2012-10-31 18:33:24 | [diff] [blame] | 1820 | const WebPoint& webImageOffset) { |
oshima | b331323 | 2016-01-28 01:13:22 | [diff] [blame] | 1821 | blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0); |
danakj | dea2efb | 2016-03-10 19:13:17 | [diff] [blame] | 1822 | ConvertViewportToWindowViaWidget(&offset_in_window); |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 1823 | DropData drop_data(DropDataBuilder::Build(data)); |
[email protected] | b67151d | 2012-05-25 23:23:24 | [diff] [blame] | 1824 | drop_data.referrer_policy = frame->document().referrerPolicy(); |
oshima | b331323 | 2016-01-28 01:13:22 | [diff] [blame] | 1825 | gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1826 | Send(new DragHostMsg_StartDragging(GetRoutingID(), drop_data, mask, |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1827 | image.getSkBitmap(), imageOffset, |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 1828 | possible_drag_event_info_)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1829 | } |
| 1830 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1831 | bool RenderViewImpl::acceptsLoadDrops() { |
[email protected] | 28b92df | 2009-09-25 17:35:45 | [diff] [blame] | 1832 | return renderer_preferences_.can_accept_load_drops; |
| 1833 | } |
| 1834 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1835 | void RenderViewImpl::focusNext() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1836 | Send(new ViewHostMsg_TakeFocus(GetRoutingID(), false)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1837 | } |
| 1838 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1839 | void RenderViewImpl::focusPrevious() { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1840 | Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1841 | } |
| 1842 | |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1843 | // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1844 | void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode, |
| 1845 | const WebNode& toNode) { |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1846 | has_scrolled_focused_editable_node_into_rect_ = false; |
| 1847 | |
jennyz | 399d6e6 | 2014-12-16 01:40:05 | [diff] [blame] | 1848 | gfx::Rect node_bounds; |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1849 | bool is_editable = false; |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1850 | if (!toNode.isNull() && toNode.isElementNode()) { |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1851 | WebElement element = const_cast<WebNode&>(toNode).to<WebElement>(); |
oshima | e2b3b40 | 2015-12-04 04:27:24 | [diff] [blame] | 1852 | blink::WebRect rect = element.boundsInViewport(); |
danakj | dea2efb | 2016-03-10 19:13:17 | [diff] [blame] | 1853 | ConvertViewportToWindowViaWidget(&rect); |
oshima | e2b3b40 | 2015-12-04 04:27:24 | [diff] [blame] | 1854 | node_bounds = gfx::Rect(rect); |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1855 | is_editable = element.isEditable(); |
jennyz | 399d6e6 | 2014-12-16 01:40:05 | [diff] [blame] | 1856 | } |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1857 | Send(new ViewHostMsg_FocusedNodeChanged(GetRoutingID(), is_editable, |
jennyz | 399d6e6 | 2014-12-16 01:40:05 | [diff] [blame] | 1858 | node_bounds)); |
[email protected] | a4b103b | 2010-10-05 18:46:07 | [diff] [blame] | 1859 | |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1860 | // TODO(estade): remove. |
| 1861 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(toNode)); |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 1862 | |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1863 | RenderFrameImpl* previous_frame = nullptr; |
| 1864 | if (!fromNode.isNull()) |
| 1865 | previous_frame = RenderFrameImpl::FromWebFrame(fromNode.document().frame()); |
| 1866 | RenderFrameImpl* new_frame = nullptr; |
| 1867 | if (!toNode.isNull()) |
| 1868 | new_frame = RenderFrameImpl::FromWebFrame(toNode.document().frame()); |
| 1869 | |
| 1870 | if (previous_frame && previous_frame != new_frame) |
| 1871 | previous_frame->FocusedNodeChanged(WebNode()); |
| 1872 | if (new_frame) |
| 1873 | new_frame->FocusedNodeChanged(toNode); |
| 1874 | |
| 1875 | // TODO(dmazzoni): remove once there's a separate a11y tree per frame. |
nasko | e8d11575 | 2015-08-07 00:43:13 | [diff] [blame] | 1876 | if (main_render_frame_) |
| 1877 | main_render_frame_->FocusedNodeChangedForAccessibility(toNode); |
[email protected] | 08e9e13 | 2010-06-01 16:58:49 | [diff] [blame] | 1878 | } |
| 1879 | |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 1880 | void RenderViewImpl::didUpdateLayout() { |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 1881 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); |
| 1882 | |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 1883 | // We don't always want to set up a timer, only if we've been put in that |
| 1884 | // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 1885 | // message. |
| 1886 | if (!send_preferred_size_changes_ || !webview()) |
| 1887 | return; |
| 1888 | |
| 1889 | if (check_preferred_size_timer_.IsRunning()) |
| 1890 | return; |
| 1891 | check_preferred_size_timer_.Start(FROM_HERE, |
| 1892 | TimeDelta::FromMilliseconds(0), this, |
| 1893 | &RenderViewImpl::CheckPreferredSize); |
| 1894 | } |
| 1895 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1896 | void RenderViewImpl::navigateBackForwardSoon(int offset) { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1897 | Send(new ViewHostMsg_GoToEntryAtOffset(GetRoutingID(), offset)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1898 | } |
| 1899 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1900 | int RenderViewImpl::historyBackListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1901 | return history_list_offset_ < 0 ? 0 : history_list_offset_; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1902 | } |
| 1903 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1904 | int RenderViewImpl::historyForwardListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1905 | return history_list_length_ - historyBackListCount() - 1; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1906 | } |
| 1907 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1908 | // blink::WebWidgetClient ---------------------------------------------------- |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1909 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1910 | void RenderViewImpl::didFocus() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 1911 | // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 1912 | // we won't have to test for user gesture anymore and we can |
| 1913 | // move that code back to render_widget.cc |
[email protected] | af15bf2 | 2013-03-08 01:18:17 | [diff] [blame] | 1914 | if (WebUserGestureIndicator::isProcessingUserGesture() && |
[email protected] | 70dee7e | 2013-05-29 18:28:30 | [diff] [blame] | 1915 | !RenderThreadImpl::current()->layout_test_mode()) { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1916 | Send(new ViewHostMsg_Focus(GetRoutingID())); |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 1917 | } |
| 1918 | } |
| 1919 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1920 | // We are supposed to get a single call to Show for a newly created RenderView |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1921 | // that was created via RenderViewImpl::CreateWebView. So, we wait until this |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1922 | // point to dispatch the ShowView message. |
| 1923 | // |
| 1924 | // This method provides us with the information about how to display the newly |
[email protected] | 5f9de588 | 2011-09-30 23:36:28 | [diff] [blame] | 1925 | // created RenderView (i.e., as a blocked popup or as a new tab). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1926 | // |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1927 | void RenderViewImpl::show(WebNavigationPolicy policy) { |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 1928 | if (did_show_) { |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 1929 | // When supports_multiple_windows is disabled, popups are reusing |
| 1930 | // the same view. In some scenarios, this makes WebKit to call show() twice. |
[email protected] | c9edabd | 2013-05-23 13:56:24 | [diff] [blame] | 1931 | if (webkit_preferences_.supports_multiple_windows) |
| 1932 | NOTREACHED() << "received extraneous Show call"; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1933 | return; |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 1934 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1935 | did_show_ = true; |
| 1936 | |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 1937 | DCHECK(opener_id_ != MSG_ROUTING_NONE); |
| 1938 | |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 1939 | // NOTE: initial_rect_ may still have its default values at this point, but |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1940 | // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the |
| 1941 | // browser process will impose a default position otherwise. |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1942 | Send(new ViewHostMsg_ShowView(opener_id_, GetRoutingID(), |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1943 | NavigationPolicyToDisposition(policy), |
| 1944 | initial_rect_, opened_by_user_gesture_)); |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 1945 | SetPendingWindowRect(initial_rect_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1946 | } |
| 1947 | |
miletus | e8d28ba | 2015-06-19 04:52:04 | [diff] [blame] | 1948 | void RenderViewImpl::onMouseDown(const WebNode& mouse_down_node) { |
| 1949 | FOR_EACH_OBSERVER( |
| 1950 | RenderViewObserver, observers_, OnMouseDown(mouse_down_node)); |
| 1951 | } |
| 1952 | |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 1953 | void RenderViewImpl::didHandleGestureEvent( |
| 1954 | const WebGestureEvent& event, |
| 1955 | bool event_cancelled) { |
| 1956 | RenderWidget::didHandleGestureEvent(event, event_cancelled); |
[email protected] | bb37b65 | 2013-11-27 23:47:11 | [diff] [blame] | 1957 | |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 1958 | if (!event_cancelled) { |
| 1959 | FOR_EACH_OBSERVER( |
| 1960 | RenderViewObserver, observers_, DidHandleGestureEvent(event)); |
| 1961 | } |
| 1962 | |
jdduke | 45762d2 | 2014-10-07 04:19:08 | [diff] [blame] | 1963 | // TODO(ananta): Piggyback off existing IPCs to communicate this information, |
| 1964 | // crbug/420130. |
| 1965 | #if defined(OS_WIN) |
[email protected] | bb37b65 | 2013-11-27 23:47:11 | [diff] [blame] | 1966 | if (event.type != blink::WebGestureEvent::GestureTap) |
| 1967 | return; |
| 1968 | |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 1969 | // TODO(estade): hit test the event against focused node to make sure |
| 1970 | // the tap actually hit the focused node. |
jdduke | 3bf083fe | 2015-09-29 23:40:53 | [diff] [blame] | 1971 | blink::WebTextInputType text_input_type = GetWebView()->textInputType(); |
[email protected] | bb37b65 | 2013-11-27 23:47:11 | [diff] [blame] | 1972 | |
| 1973 | Send(new ViewHostMsg_FocusedNodeTouched( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 1974 | GetRoutingID(), text_input_type != blink::WebTextInputTypeNone)); |
jdduke | 45762d2 | 2014-10-07 04:19:08 | [diff] [blame] | 1975 | #endif |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 1976 | } |
| 1977 | |
[email protected] | 6e89eb7 | 2013-07-23 13:28:22 | [diff] [blame] | 1978 | void RenderViewImpl::initializeLayerTreeView() { |
| 1979 | RenderWidget::initializeLayerTreeView(); |
| 1980 | RenderWidgetCompositor* rwc = compositor(); |
[email protected] | 9f7638f4 | 2014-05-30 01:51:16 | [diff] [blame] | 1981 | if (!rwc) |
[email protected] | 6e89eb7 | 2013-07-23 13:28:22 | [diff] [blame] | 1982 | return; |
[email protected] | 9f7638f4 | 2014-05-30 01:51:16 | [diff] [blame] | 1983 | |
ccameron | 1f89c00 | 2014-10-21 06:19:05 | [diff] [blame] | 1984 | bool use_threaded_event_handling = true; |
jam | e1f453c | 2016-03-21 15:51:34 | [diff] [blame] | 1985 | #if defined(OS_MACOSX) |
ccameron | a764475 | 2014-12-30 01:16:31 | [diff] [blame] | 1986 | // Disable threaded event handling if content is not handling the elastic |
| 1987 | // overscroll effect. This includes the cases where the elastic overscroll |
| 1988 | // effect is being handled by Blink (because of command line flags) and older |
| 1989 | // operating system versions which do not have an elastic overscroll effect |
| 1990 | // (SnowLeopard, which has Aqua scrollbars which need synchronous updates). |
| 1991 | use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled(); |
[email protected] | 9f7638f4 | 2014-05-30 01:51:16 | [diff] [blame] | 1992 | #endif |
changwan | d659e20 | 2016-06-13 02:39:12 | [diff] [blame] | 1993 | if (!use_threaded_event_handling) |
| 1994 | return; |
| 1995 | |
| 1996 | RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1997 | // render_thread may be NULL in tests. |
| 1998 | InputHandlerManager* input_handler_manager = |
| 1999 | render_thread ? render_thread->input_handler_manager() : NULL; |
| 2000 | if (input_handler_manager) { |
| 2001 | input_handler_manager->AddInputHandler( |
| 2002 | GetRoutingID(), rwc->GetInputHandler(), AsWeakPtr(), |
| 2003 | webkit_preferences_.enable_scroll_animator); |
| 2004 | has_added_input_handler_ = true; |
ccameron | 1f89c00 | 2014-10-21 06:19:05 | [diff] [blame] | 2005 | } |
[email protected] | 6e89eb7 | 2013-07-23 13:28:22 | [diff] [blame] | 2006 | } |
| 2007 | |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 2008 | void RenderViewImpl::closeWidgetSoon() { |
| 2009 | RenderWidget::closeWidgetSoon(); |
| 2010 | } |
| 2011 | |
| 2012 | void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) { |
| 2013 | RenderWidget::convertViewportToWindow(rect); |
| 2014 | } |
| 2015 | |
| 2016 | void RenderViewImpl::convertWindowToViewport(blink::WebFloatRect* rect) { |
| 2017 | RenderWidget::convertWindowToViewport(rect); |
| 2018 | } |
| 2019 | |
| 2020 | void RenderViewImpl::didAutoResize(const blink::WebSize& newSize) { |
lfg | b00fcad | 2016-07-14 14:16:33 | [diff] [blame] | 2021 | RenderWidget::DidAutoResize(newSize); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 2022 | } |
| 2023 | |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 2024 | void RenderViewImpl::didOverscroll( |
| 2025 | const blink::WebFloatSize& overscrollDelta, |
| 2026 | const blink::WebFloatSize& accumulatedOverscroll, |
| 2027 | const blink::WebFloatPoint& positionInViewport, |
| 2028 | const blink::WebFloatSize& velocityInViewport) { |
| 2029 | RenderWidget::didOverscroll(overscrollDelta, accumulatedOverscroll, |
| 2030 | positionInViewport, velocityInViewport); |
| 2031 | } |
| 2032 | |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 2033 | void RenderViewImpl::hasTouchEventHandlers(bool has_handlers) { |
| 2034 | RenderWidget::hasTouchEventHandlers(has_handlers); |
| 2035 | } |
| 2036 | |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 2037 | void RenderViewImpl::resetInputMethod() { |
| 2038 | RenderWidget::resetInputMethod(); |
| 2039 | } |
| 2040 | |
| 2041 | blink::WebRect RenderViewImpl::rootWindowRect() { |
bokan | 6b08cd2 | 2016-10-05 00:55:21 | [diff] [blame] | 2042 | return RenderWidget::windowRect(); |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 2043 | } |
| 2044 | |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 2045 | blink::WebScreenInfo RenderViewImpl::screenInfo() { |
| 2046 | return RenderWidget::screenInfo(); |
| 2047 | } |
| 2048 | |
| 2049 | void RenderViewImpl::setToolTipText(const blink::WebString& text, |
| 2050 | blink::WebTextDirection hint) { |
| 2051 | RenderWidget::setToolTipText(text, hint); |
| 2052 | } |
| 2053 | |
| 2054 | void RenderViewImpl::setTouchAction(blink::WebTouchAction touchAction) { |
| 2055 | RenderWidget::setTouchAction(touchAction); |
| 2056 | } |
| 2057 | |
lfg | 2230bce | 2016-04-28 18:37:04 | [diff] [blame] | 2058 | void RenderViewImpl::showImeIfNeeded() { |
| 2059 | RenderWidget::showImeIfNeeded(); |
| 2060 | } |
| 2061 | |
| 2062 | void RenderViewImpl::showUnhandledTapUIIfNeeded( |
| 2063 | const blink::WebPoint& tappedPosition, |
| 2064 | const blink::WebNode& tappedNode, |
| 2065 | bool pageChanged) { |
| 2066 | RenderWidget::showUnhandledTapUIIfNeeded(tappedPosition, tappedNode, |
| 2067 | pageChanged); |
| 2068 | } |
| 2069 | |
lfg | 0f44062 | 2016-07-20 04:27:14 | [diff] [blame] | 2070 | blink::WebWidgetClient* RenderViewImpl::widgetClient() { |
| 2071 | return static_cast<RenderWidget*>(this); |
| 2072 | } |
| 2073 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2074 | // blink::WebFrameClient ----------------------------------------------------- |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2075 | |
[email protected] | 5e92282f | 2012-08-17 08:11:57 | [diff] [blame] | 2076 | void RenderViewImpl::Repaint(const gfx::Size& size) { |
[email protected] | 3d9ec505 | 2013-01-02 22:05:25 | [diff] [blame] | 2077 | OnRepaint(size); |
[email protected] | 5e92282f | 2012-08-17 08:11:57 | [diff] [blame] | 2078 | } |
| 2079 | |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 2080 | void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name, |
| 2081 | const std::string& value) { |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 2082 | GetWidget()->SetEditCommandForNextKeyEvent(name, value); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 2083 | } |
| 2084 | |
| 2085 | void RenderViewImpl::ClearEditCommands() { |
alexmos | 5656749 | 2016-09-13 00:52:46 | [diff] [blame] | 2086 | GetWidget()->ClearEditCommands(); |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 2087 | } |
| 2088 | |
[email protected] | b38806a | 2013-10-04 16:01:38 | [diff] [blame] | 2089 | const std::string& RenderViewImpl::GetAcceptLanguages() const { |
| 2090 | return renderer_preferences_.accept_languages; |
| 2091 | } |
| 2092 | |
danakj | dea2efb | 2016-03-10 19:13:17 | [diff] [blame] | 2093 | void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) { |
| 2094 | convertViewportToWindow(rect); |
oshima | e2b3b40 | 2015-12-04 04:27:24 | [diff] [blame] | 2095 | } |
| 2096 | |
huangs | 2a34235 | 2015-12-15 16:59:24 | [diff] [blame] | 2097 | gfx::RectF RenderViewImpl::ElementBoundsInWindow( |
| 2098 | const blink::WebElement& element) { |
| 2099 | blink::WebRect bounding_box_in_window = element.boundsInViewport(); |
danakj | dea2efb | 2016-03-10 19:13:17 | [diff] [blame] | 2100 | ConvertViewportToWindowViaWidget(&bounding_box_in_window); |
huangs | 2a34235 | 2015-12-15 16:59:24 | [diff] [blame] | 2101 | return gfx::RectF(bounding_box_in_window); |
| 2102 | } |
| 2103 | |
changwan | d659e20 | 2016-06-13 02:39:12 | [diff] [blame] | 2104 | bool RenderViewImpl::HasAddedInputHandler() const { |
| 2105 | return has_added_input_handler_; |
| 2106 | } |
| 2107 | |
oshima | 4300f52e9 | 2016-02-18 21:51:04 | [diff] [blame] | 2108 | gfx::Point RenderViewImpl::ConvertWindowPointToViewport( |
| 2109 | const gfx::Point& point) { |
| 2110 | blink::WebFloatRect point_in_viewport(point.x(), point.y(), 0, 0); |
| 2111 | convertWindowToViewport(&point_in_viewport); |
| 2112 | return gfx::Point(point_in_viewport.x, point_in_viewport.y); |
| 2113 | } |
| 2114 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 2115 | void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2116 | WebIconURL::Type icon_type) { |
| 2117 | if (frame->parent()) |
| 2118 | return; |
| 2119 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2120 | WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); |
| 2121 | std::vector<FaviconURL> urls; |
| 2122 | for (size_t i = 0; i < icon_urls.size(); i++) { |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 2123 | std::vector<gfx::Size> sizes; |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 2124 | ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 2125 | urls.push_back(FaviconURL( |
| 2126 | icon_urls[i].iconURL(), ToFaviconType(icon_urls[i].iconType()), sizes)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2127 | } |
| 2128 | SendUpdateFaviconURL(urls); |
[email protected] | 5019ef1 | 2010-04-27 17:26:58 | [diff] [blame] | 2129 | } |
| 2130 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2131 | void RenderViewImpl::CheckPreferredSize() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 2132 | // We don't always want to send the change messages over IPC, only if we've |
| 2133 | // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 2134 | // message. |
| 2135 | if (!send_preferred_size_changes_ || !webview()) |
| 2136 | return; |
| 2137 | |
[email protected] | e76b797 | 2013-06-06 02:58:48 | [diff] [blame] | 2138 | gfx::Size size = webview()->contentsPreferredMinimumSize(); |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2139 | if (size == preferred_size_) |
| 2140 | return; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 2141 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2142 | preferred_size_ = size; |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2143 | Send(new ViewHostMsg_DidContentsPreferredSizeChange(GetRoutingID(), |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2144 | preferred_size_)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2145 | } |
| 2146 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2147 | blink::WebString RenderViewImpl::acceptLanguages() { |
[email protected] | 9982c80 | 2013-06-12 15:22:06 | [diff] [blame] | 2148 | return WebString::fromUTF8(renderer_preferences_.accept_languages); |
| 2149 | } |
| 2150 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2151 | // RenderView implementation --------------------------------------------------- |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2152 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2153 | bool RenderViewImpl::Send(IPC::Message* message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2154 | return RenderWidget::Send(message); |
| 2155 | } |
| 2156 | |
avi | 8a45c109 | 2016-03-01 16:12:34 | [diff] [blame] | 2157 | RenderWidget* RenderViewImpl::GetWidget() const { |
| 2158 | return const_cast<RenderWidget*>(static_cast<const RenderWidget*>(this)); |
| 2159 | } |
| 2160 | |
mostynb | c3335323 | 2014-09-12 09:38:31 | [diff] [blame] | 2161 | RenderFrameImpl* RenderViewImpl::GetMainRenderFrame() { |
nasko | 77de231 | 2015-05-12 03:09:16 | [diff] [blame] | 2162 | return main_render_frame_; |
[email protected] | b849847b | 2013-12-10 21:57:58 | [diff] [blame] | 2163 | } |
| 2164 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2165 | int RenderViewImpl::GetRoutingID() const { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2166 | return routing_id(); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2167 | } |
| 2168 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2169 | gfx::Size RenderViewImpl::GetSize() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2170 | return size(); |
| 2171 | } |
| 2172 | |
oshima | 129b75e | 2016-01-14 09:15:14 | [diff] [blame] | 2173 | float RenderViewImpl::GetDeviceScaleFactor() const { |
| 2174 | return device_scale_factor_; |
| 2175 | } |
| 2176 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2177 | WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2178 | return webkit_preferences_; |
| 2179 | } |
| 2180 | |
[email protected] | 324825d | 2012-11-30 12:37:15 | [diff] [blame] | 2181 | void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { |
| 2182 | OnUpdateWebPreferences(preferences); |
| 2183 | } |
| 2184 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2185 | blink::WebView* RenderViewImpl::GetWebView() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2186 | return webview(); |
| 2187 | } |
| 2188 | |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 2189 | blink::WebFrameWidget* RenderViewImpl::GetWebFrameWidget() { |
| 2190 | return frame_widget_; |
| 2191 | } |
| 2192 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2193 | bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2194 | return (!send_preferred_size_changes_ || |
| 2195 | (disable_scrollbars_size_limit_.width() <= width || |
| 2196 | disable_scrollbars_size_limit_.height() <= height)); |
| 2197 | } |
| 2198 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2199 | int RenderViewImpl::GetEnabledBindings() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2200 | return enabled_bindings_; |
| 2201 | } |
| 2202 | |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 2203 | bool RenderViewImpl::GetContentStateImmediately() const { |
| 2204 | return send_content_state_immediately_; |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2205 | } |
| 2206 | |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 2207 | void RenderViewImpl::OnSetPageScale(float page_scale_factor) { |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2208 | if (!webview()) |
| 2209 | return; |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 2210 | webview()->setPageScaleFactor(page_scale_factor); |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2211 | } |
| 2212 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2213 | void RenderViewImpl::OnZoom(PageZoom zoom) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 2214 | if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 2215 | return; |
| 2216 | |
[email protected] | 258d3112 | 2010-05-09 10:59:41 | [diff] [blame] | 2217 | webview()->hidePopups(); |
[email protected] | 854ab546 | 2011-11-22 20:48:10 | [diff] [blame] | 2218 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2219 | double old_zoom_level = webview()->zoomLevel(); |
| 2220 | double zoom_level; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2221 | if (zoom == PAGE_ZOOM_RESET) { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2222 | zoom_level = 0; |
| 2223 | } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
| 2224 | // Previous zoom level is a whole number, so just increment/decrement. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 2225 | zoom_level = old_zoom_level + zoom; |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2226 | } else { |
| 2227 | // Either the user hit the zoom factor limit and thus the zoom level is now |
| 2228 | // not a whole number, or a plugin changed it to a custom value. We want |
| 2229 | // to go to the next whole number so that the user can always get back to |
| 2230 | // 100% with the keyboard/menu. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 2231 | if ((old_zoom_level > 1 && zoom > 0) || |
| 2232 | (old_zoom_level < 1 && zoom < 0)) { |
| 2233 | zoom_level = static_cast<int>(old_zoom_level + zoom); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2234 | } else { |
| 2235 | // We're going towards 100%, so first go to the next whole number. |
| 2236 | zoom_level = static_cast<int>(old_zoom_level); |
| 2237 | } |
| 2238 | } |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 2239 | SetZoomLevel(zoom_level); |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 2240 | zoomLevelChanged(); |
| 2241 | } |
| 2242 | |
scottmg | 3ea1571 | 2016-08-09 16:46:41 | [diff] [blame] | 2243 | void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
| 2244 | double zoom_level) { |
| 2245 | // TODO(wjmaclean): We should see if this restriction is really necessary, |
| 2246 | // since it isn't enforced in other parts of the page zoom system (e.g. |
| 2247 | // when a users changes the zoom of a currently displayed page). Android |
| 2248 | // has no UI for this, so in theory the following code would normally just use |
| 2249 | // the default zoom anyways. |
| 2250 | #if !defined(OS_ANDROID) |
| 2251 | // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
| 2252 | // for legacy WebView text scaling emulation. Thus, the code that resets |
| 2253 | // the zoom level from this map will be effectively resetting text zoom level. |
| 2254 | host_zoom_levels_[url] = zoom_level; |
| 2255 | #endif |
| 2256 | } |
| 2257 | |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 2258 | void RenderViewImpl::OnSetZoomLevel( |
| 2259 | PageMsg_SetZoomLevel_Command command, |
| 2260 | double zoom_level) { |
| 2261 | switch (command) { |
| 2262 | case PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY: |
| 2263 | uses_temporary_zoom_level_ = false; |
| 2264 | break; |
| 2265 | case PageMsg_SetZoomLevel_Command::SET_TEMPORARY: |
| 2266 | uses_temporary_zoom_level_ = true; |
| 2267 | break; |
| 2268 | case PageMsg_SetZoomLevel_Command::USE_CURRENT_TEMPORARY_MODE: |
| 2269 | // Don't override a temporary zoom level without an explicit SET. |
| 2270 | if (uses_temporary_zoom_level_) |
| 2271 | return; |
| 2272 | break; |
| 2273 | default: |
| 2274 | NOTIMPLEMENTED(); |
| 2275 | } |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 2276 | webview()->hidePopups(); |
wjmaclean | 6495190 | 2016-04-29 20:59:12 | [diff] [blame] | 2277 | SetZoomLevel(zoom_level); |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 2278 | } |
| 2279 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2280 | void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 2281 | if ((enabled_bindings_flags & BINDINGS_POLICY_WEB_UI) && |
| 2282 | !(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) { |
[email protected] | 69a0a13 | 2014-03-26 16:45:02 | [diff] [blame] | 2283 | // WebUIExtensionData deletes itself when we're destroyed. |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 2284 | new WebUIExtensionData(this); |
| 2285 | } |
| 2286 | |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 2287 | enabled_bindings_ |= enabled_bindings_flags; |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2288 | |
| 2289 | // Keep track of the total bindings accumulated in this process. |
| 2290 | RenderProcess::current()->AddBindings(enabled_bindings_flags); |
sammc | e2f9998 | 2016-03-14 22:38:12 | [diff] [blame] | 2291 | |
| 2292 | if (main_render_frame_) |
| 2293 | main_render_frame_->MaybeEnableMojoBindings(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2294 | } |
| 2295 | |
hush | 8915b50 | 2016-06-15 19:32:23 | [diff] [blame] | 2296 | void RenderViewImpl::OnDragTargetDragEnter( |
| 2297 | const std::vector<DropData::Metadata>& drop_meta_data, |
| 2298 | const gfx::Point& client_point, |
| 2299 | const gfx::Point& screen_point, |
| 2300 | WebDragOperationsMask ops, |
| 2301 | int key_modifiers) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2302 | WebDragOperation operation = webview()->dragTargetDragEnter( |
hush | 8915b50 | 2016-06-15 19:32:23 | [diff] [blame] | 2303 | DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point, |
| 2304 | ops, key_modifiers); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2305 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2306 | Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2307 | } |
| 2308 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2309 | void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
| 2310 | const gfx::Point& screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 2311 | WebDragOperationsMask ops, |
| 2312 | int key_modifiers) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2313 | WebDragOperation operation = webview()->dragTargetDragOver( |
oshima | 4300f52e9 | 2016-02-18 21:51:04 | [diff] [blame] | 2314 | ConvertWindowPointToViewport(client_point), |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2315 | screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 2316 | ops, |
| 2317 | key_modifiers); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2318 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2319 | Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation)); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2320 | } |
| 2321 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2322 | void RenderViewImpl::OnDragTargetDragLeave() { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2323 | webview()->dragTargetDragLeave(); |
| 2324 | } |
| 2325 | |
hush | 8915b50 | 2016-06-15 19:32:23 | [diff] [blame] | 2326 | void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data, |
| 2327 | const gfx::Point& client_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 2328 | const gfx::Point& screen_point, |
| 2329 | int key_modifiers) { |
bsep | 9d8c853 | 2016-09-27 18:19:23 | [diff] [blame] | 2330 | webview()->dragTargetDrop(DropDataToWebDragData(drop_data), |
| 2331 | ConvertWindowPointToViewport(client_point), |
hush | 8915b50 | 2016-06-15 19:32:23 | [diff] [blame] | 2332 | screen_point, key_modifiers); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2333 | } |
| 2334 | |
[email protected] | 7a6d773f | 2014-04-04 01:25:09 | [diff] [blame] | 2335 | void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, |
| 2336 | const gfx::Point& screen_point, |
| 2337 | WebDragOperation op) { |
oshima | 4300f52e9 | 2016-02-18 21:51:04 | [diff] [blame] | 2338 | webview()->dragSourceEndedAt( |
| 2339 | ConvertWindowPointToViewport(client_point), screen_point, op); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2340 | } |
| 2341 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2342 | void RenderViewImpl::OnDragSourceSystemDragEnded() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2343 | webview()->dragSourceSystemDragEnded(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2344 | } |
| 2345 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2346 | void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 2347 | webkit_preferences_ = prefs; |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 2348 | ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2349 | } |
| 2350 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2351 | void RenderViewImpl::OnEnumerateDirectoryResponse( |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2352 | int id, |
[email protected] | c42de73 | 2013-02-16 06:26:31 | [diff] [blame] | 2353 | const std::vector<base::FilePath>& paths) { |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2354 | if (!enumeration_completions_[id]) |
| 2355 | return; |
| 2356 | |
| 2357 | WebVector<WebString> ws_file_names(paths.size()); |
| 2358 | for (size_t i = 0; i < paths.size(); ++i) |
[email protected] | 728c2ee | 2013-06-25 04:01:07 | [diff] [blame] | 2359 | ws_file_names[i] = paths[i].AsUTF16Unsafe(); |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2360 | |
| 2361 | enumeration_completions_[id]->didChooseFile(ws_file_names); |
| 2362 | enumeration_completions_.erase(id); |
| 2363 | } |
| 2364 | |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 2365 | void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, |
| 2366 | const gfx::Size& max_size) { |
| 2367 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 2368 | if (!webview()) |
| 2369 | return; |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2370 | |
[email protected] | 97e1bf7 | 2013-03-06 14:06:05 | [diff] [blame] | 2371 | auto_resize_mode_ = true; |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2372 | if (IsUseZoomForDSFEnabled()) { |
| 2373 | webview()->enableAutoResizeMode( |
| 2374 | gfx::ScaleToCeiledSize(min_size, device_scale_factor_), |
| 2375 | gfx::ScaleToCeiledSize(max_size, device_scale_factor_)); |
| 2376 | } else { |
| 2377 | webview()->enableAutoResizeMode(min_size, max_size); |
| 2378 | } |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 2379 | } |
| 2380 | |
| 2381 | void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) { |
| 2382 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 2383 | if (!webview()) |
| 2384 | return; |
[email protected] | 97e1bf7 | 2013-03-06 14:06:05 | [diff] [blame] | 2385 | auto_resize_mode_ = false; |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 2386 | webview()->disableAutoResizeMode(); |
| 2387 | |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2388 | if (!new_size.IsEmpty()) { |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 2389 | ResizeParams resize_params; |
jbroman | 5ff1030 | 2016-07-22 03:36:26 | [diff] [blame] | 2390 | resize_params.screen_info = screen_info_; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 2391 | resize_params.new_size = new_size; |
| 2392 | resize_params.physical_backing_size = physical_backing_size_; |
| 2393 | resize_params.top_controls_shrink_blink_size = |
| 2394 | top_controls_shrink_blink_size_; |
| 2395 | resize_params.top_controls_height = top_controls_height_; |
| 2396 | resize_params.visible_viewport_size = visible_viewport_size_; |
mfomitchev | 2600fd7c | 2016-02-17 20:53:39 | [diff] [blame] | 2397 | resize_params.is_fullscreen_granted = is_fullscreen_granted(); |
| 2398 | resize_params.display_mode = display_mode_; |
| 2399 | resize_params.needs_resize_ack = false; |
| 2400 | Resize(resize_params); |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2401 | } |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 2402 | } |
| 2403 | |
[email protected] | 2bf834f | 2011-11-17 20:02:21 | [diff] [blame] | 2404 | void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 2405 | if (send_preferred_size_changes_) |
| 2406 | return; |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 2407 | send_preferred_size_changes_ = true; |
[email protected] | 770dd8b | 2010-05-24 18:11:39 | [diff] [blame] | 2408 | |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 2409 | // Start off with an initial preferred size notification (in case |
| 2410 | // |didUpdateLayout| was already called). |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 2411 | didUpdateLayout(); |
[email protected] | 0666aef | 2009-05-13 19:48:08 | [diff] [blame] | 2412 | } |
| 2413 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2414 | void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2415 | const gfx::Size& disable_scrollbar_size_limit) { |
| 2416 | disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
| 2417 | } |
| 2418 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2419 | void RenderViewImpl::OnSetRendererPrefs( |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2420 | const RendererPreferences& renderer_prefs) { |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 2421 | std::string old_accept_languages = renderer_preferences_.accept_languages; |
| 2422 | |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 2423 | renderer_preferences_ = renderer_prefs; |
ananta | 59b9fe7 | 2015-04-07 01:33:26 | [diff] [blame] | 2424 | |
[email protected] | 6e282c9 | 2009-07-24 01:19:37 | [diff] [blame] | 2425 | UpdateFontRenderingFromRendererPrefs(); |
scottmg | b92365e | 2016-08-30 20:54:40 | [diff] [blame] | 2426 | UpdateThemePrefs(); |
ellyjones | 8ae1769 | 2016-08-05 15:19:21 | [diff] [blame] | 2427 | blink::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
[email protected] | 38a8571 | 2013-01-02 22:45:02 | [diff] [blame] | 2428 | |
[email protected] | dcc29777 | 2014-04-10 22:20:52 | [diff] [blame] | 2429 | #if defined(USE_DEFAULT_RENDER_THEME) |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2430 | if (renderer_prefs.use_custom_colors) { |
esprehn | 021507d | 2015-11-13 23:35:01 | [diff] [blame] | 2431 | blink::setFocusRingColor(renderer_prefs.focus_ring_color); |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2432 | |
| 2433 | if (webview()) { |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2434 | webview()->setSelectionColors( |
| 2435 | renderer_prefs.active_selection_bg_color, |
| 2436 | renderer_prefs.active_selection_fg_color, |
| 2437 | renderer_prefs.inactive_selection_bg_color, |
| 2438 | renderer_prefs.inactive_selection_fg_color); |
| 2439 | webview()->themeChanged(); |
| 2440 | } |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 2441 | } |
[email protected] | c997bc4 | 2014-04-11 18:25:58 | [diff] [blame] | 2442 | #endif // defined(USE_DEFAULT_RENDER_THEME) |
[email protected] | d299d97 | 2012-03-23 02:26:55 | [diff] [blame] | 2443 | |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 2444 | if (webview() && |
| 2445 | old_accept_languages != renderer_preferences_.accept_languages) { |
| 2446 | webview()->acceptLanguagesChanged(); |
| 2447 | } |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 2448 | } |
| 2449 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2450 | void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
| 2451 | const WebMediaPlayerAction& action) { |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 2452 | if (webview()) |
| 2453 | webview()->performMediaPlayerAction(action, location); |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 2454 | } |
| 2455 | |
[email protected] | fcdc564 | 2014-05-09 14:32:24 | [diff] [blame] | 2456 | void RenderViewImpl::OnOrientationChange() { |
japhet | e20ec7c | 2015-03-18 19:16:18 | [diff] [blame] | 2457 | if (webview() && webview()->mainFrame()->isWebLocalFrame()) |
| 2458 | webview()->mainFrame()->toWebLocalFrame()->sendOrientationChangeEvent(); |
[email protected] | 7782964 | 2012-05-15 14:47:17 | [diff] [blame] | 2459 | } |
| 2460 | |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 2461 | void RenderViewImpl::OnPluginActionAt(const gfx::Point& location, |
| 2462 | const WebPluginAction& action) { |
| 2463 | if (webview()) |
| 2464 | webview()->performPluginAction(action, location); |
| 2465 | } |
| 2466 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2467 | void RenderViewImpl::OnClosePage() { |
[email protected] | 77fc9b9 | 2011-10-15 16:20:37 | [diff] [blame] | 2468 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2469 | // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 2470 | // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 2471 | // in the onunload handler from appearing. For now, we're bypassing that and |
| 2472 | // calling the FrameLoader's CloseURL method directly. This should be |
| 2473 | // revisited to avoid having two ways to close a page. Having a single way |
| 2474 | // to close that can run onunload is also useful for fixing |
| 2475 | // http://b/issue?id=753080. |
[email protected] | 11fd5db | 2014-04-02 03:49:46 | [diff] [blame] | 2476 | webview()->mainFrame()->dispatchUnloadEvent(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2477 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2478 | Send(new ViewHostMsg_ClosePage_ACK(GetRoutingID())); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2479 | } |
| 2480 | |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 2481 | void RenderViewImpl::OnClose() { |
| 2482 | if (closing_) |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2483 | RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 2484 | RenderWidget::OnClose(); |
| 2485 | } |
| 2486 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2487 | void RenderViewImpl::OnMoveOrResizeStarted() { |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2488 | if (webview()) |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 2489 | webview()->hidePopups(); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2490 | } |
| 2491 | |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 2492 | void RenderViewImpl::ResizeWebWidget() { |
| 2493 | webview()->resizeWithTopControls(GetSizeForWebWidget(), |
| 2494 | top_controls_height_, |
| 2495 | top_controls_shrink_blink_size_); |
| 2496 | } |
| 2497 | |
fsamuel | 664e8b6 | 2016-01-20 19:54:01 | [diff] [blame] | 2498 | void RenderViewImpl::OnResize(const ResizeParams& params) { |
[email protected] | 189a886 | 2014-07-18 00:27:53 | [diff] [blame] | 2499 | TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2500 | if (webview()) { |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 2501 | webview()->hidePopups(); |
kenrb | 5fd60fb8 | 2016-06-10 17:27:57 | [diff] [blame] | 2502 | if (send_preferred_size_changes_ && |
| 2503 | webview()->mainFrame()->isWebLocalFrame()) { |
[email protected] | 7339cd2 | 2010-10-27 00:11:20 | [diff] [blame] | 2504 | webview()->mainFrame()->setCanHaveScrollbars( |
[email protected] | 0fdd501 | 2013-05-29 08:05:56 | [diff] [blame] | 2505 | ShouldDisplayScrollbars(params.new_size.width(), |
| 2506 | params.new_size.height())); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2507 | } |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 2508 | if (display_mode_ != params.display_mode) { |
| 2509 | display_mode_ = params.display_mode; |
| 2510 | webview()->setDisplayMode(display_mode_); |
| 2511 | } |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2512 | } |
| 2513 | |
[email protected] | cbbdeef | 2014-05-26 15:57:36 | [diff] [blame] | 2514 | gfx::Size old_visible_viewport_size = visible_viewport_size_; |
| 2515 | |
bokan | c63441c | 2016-04-27 15:49:12 | [diff] [blame] | 2516 | top_controls_shrink_blink_size_ = params.top_controls_shrink_blink_size; |
| 2517 | top_controls_height_ = params.top_controls_height; |
| 2518 | |
[email protected] | 0fdd501 | 2013-05-29 08:05:56 | [diff] [blame] | 2519 | RenderWidget::OnResize(params); |
[email protected] | cbbdeef | 2014-05-26 15:57:36 | [diff] [blame] | 2520 | |
| 2521 | if (old_visible_viewport_size != visible_viewport_size_) |
| 2522 | has_scrolled_focused_editable_node_into_rect_ = false; |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2523 | } |
[email protected] | 0aa477bd | 2009-03-23 22:21:43 | [diff] [blame] | 2524 | |
avi | b9dbd97 | 2016-03-08 18:19:32 | [diff] [blame] | 2525 | void RenderViewImpl::RenderWidgetDidFlushPaint() { |
[email protected] | 5b1dec8c | 2012-02-07 04:35:38 | [diff] [blame] | 2526 | // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
| 2527 | // See crbug.com/112921. |
| 2528 | if (!webview()) |
| 2529 | return; |
| 2530 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2531 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2532 | for (WebFrame* frame = main_frame; frame; |
| 2533 | frame = frame->traverseNext(false)) { |
pmeenan | dcc725b | 2014-10-22 18:04:11 | [diff] [blame] | 2534 | // TODO(nasko): This is a hack for the case in which the top-level |
| 2535 | // frame is being rendered in another process. It will not |
| 2536 | // behave correctly for out of process iframes. |
| 2537 | if (frame->isWebLocalFrame()) { |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2538 | main_frame = frame; |
pmeenan | dcc725b | 2014-10-22 18:04:11 | [diff] [blame] | 2539 | break; |
| 2540 | } |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2541 | } |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2542 | |
alexmos | 6806d18 | 2015-07-28 00:04:19 | [diff] [blame] | 2543 | // There's nothing to do if there are no local frames in this RenderView's |
| 2544 | // frame tree. This can happen if DidFlushPaint is called after the |
| 2545 | // RenderView's local main frame is swapped to a remote frame. See |
| 2546 | // http://crbug.com/513552. |
| 2547 | if (main_frame->isWebRemoteFrame()) |
| 2548 | return; |
| 2549 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2550 | // If we have a provisional frame we are between the start and commit stages |
| 2551 | // of loading and we don't want to save stats. |
| 2552 | if (!main_frame->provisionalDataSource()) { |
| 2553 | WebDataSource* ds = main_frame->dataSource(); |
enne | 9548660 | 2015-04-30 23:41:10 | [diff] [blame] | 2554 | if (!ds) |
| 2555 | return; |
| 2556 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2557 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 2558 | |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2559 | // TODO(jar): The following code should all be inside a method, probably in |
| 2560 | // NavigatorState. |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2561 | Time now = Time::Now(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2562 | if (document_state->first_paint_time().is_null()) { |
| 2563 | document_state->set_first_paint_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2564 | } |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2565 | if (document_state->first_paint_after_load_time().is_null() && |
| 2566 | !document_state->finish_load_time().is_null()) { |
| 2567 | document_state->set_first_paint_after_load_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2568 | } |
| 2569 | } |
| 2570 | } |
| 2571 | |
[email protected] | ab6c911 | 2014-02-27 00:20:58 | [diff] [blame] | 2572 | void RenderViewImpl::OnClearFocusedElement() { |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 2573 | if (webview()) |
[email protected] | ab6c911 | 2014-02-27 00:20:58 | [diff] [blame] | 2574 | webview()->clearFocusedElement(); |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 2575 | } |
| 2576 | |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 2577 | void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
lfg | caab514 | 2016-02-26 19:06:52 | [diff] [blame] | 2578 | if (frame_widget_) |
| 2579 | frame_widget_->setIsTransparent(!opaque); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 2580 | if (compositor_) |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 2581 | compositor_->setHasTransparentBackground(!opaque); |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 2582 | } |
| 2583 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2584 | void RenderViewImpl::OnSetActive(bool active) { |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 2585 | if (webview()) |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 2586 | webview()->setIsActive(active); |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 2587 | } |
| 2588 | |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 2589 | blink::WebWidget* RenderViewImpl::GetWebWidget() const { |
| 2590 | if (frame_widget_) |
| 2591 | return frame_widget_; |
| 2592 | |
| 2593 | return RenderWidget::GetWebWidget(); |
| 2594 | } |
| 2595 | |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 2596 | void RenderViewImpl::CloseForFrame() { |
| 2597 | DCHECK(frame_widget_); |
| 2598 | frame_widget_->close(); |
| 2599 | frame_widget_ = nullptr; |
| 2600 | } |
| 2601 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2602 | void RenderViewImpl::Close() { |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 2603 | // We need to grab a pointer to the doomed WebView before we destroy it. |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 2604 | WebView* doomed = webview_; |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 2605 | RenderWidget::Close(); |
lfg | 4fa48da | 2016-05-09 18:25:13 | [diff] [blame] | 2606 | webview_ = nullptr; |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 2607 | g_view_map.Get().erase(doomed); |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2608 | g_routing_id_view_map.Get().erase(GetRoutingID()); |
| 2609 | RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID())); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 2610 | } |
| 2611 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2612 | void RenderViewImpl::OnPageWasHidden() { |
[email protected] | 68877c28 | 2013-09-20 05:52:42 | [diff] [blame] | 2613 | #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 2614 | RenderThreadImpl::current()->video_capture_impl_manager()-> |
| 2615 | SuspendDevices(true); |
[email protected] | e976c3c5 | 2014-07-24 17:41:55 | [diff] [blame] | 2616 | if (speech_recognition_dispatcher_) |
| 2617 | speech_recognition_dispatcher_->AbortAllRecognitions(); |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 2618 | #endif |
[email protected] | 2d7b82c | 2012-06-01 05:57:50 | [diff] [blame] | 2619 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2620 | if (webview()) { |
| 2621 | // TODO(lfg): It's not correct to defer the page visibility to the main |
| 2622 | // frame. Currently, this is done because the main frame may override the |
| 2623 | // visibility of the page when prerendering. In order to fix this, |
| 2624 | // prerendering must be made aware of OOPIFs. https://crbug.com/440544 |
| 2625 | blink::WebPageVisibilityState visibilityState = |
| 2626 | GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() |
| 2627 | : blink::WebPageVisibilityStateHidden; |
| 2628 | webview()->setVisibilityState(visibilityState, false); |
| 2629 | } |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 2630 | } |
| 2631 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2632 | void RenderViewImpl::OnPageWasShown() { |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 2633 | #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 2634 | RenderThreadImpl::current()->video_capture_impl_manager()-> |
| 2635 | SuspendDevices(false); |
| 2636 | #endif |
| 2637 | |
lfg | 71715407 | 2016-06-30 15:04:16 | [diff] [blame] | 2638 | if (webview()) { |
| 2639 | blink::WebPageVisibilityState visibilityState = |
| 2640 | GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState() |
| 2641 | : blink::WebPageVisibilityStateVisible; |
| 2642 | webview()->setVisibilityState(visibilityState, false); |
| 2643 | } |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 2644 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 2645 | |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 2646 | GURL RenderViewImpl::GetURLForGraphicsContext3D() { |
| 2647 | DCHECK(webview()); |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2648 | if (webview()->mainFrame()->isWebLocalFrame()) |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 2649 | return GURL(webview()->mainFrame()->document().url()); |
| 2650 | else |
| 2651 | return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 2652 | } |
| 2653 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2654 | void RenderViewImpl::OnSetFocus(bool enable) { |
nasko | c6edf7e | 2015-10-16 01:48:45 | [diff] [blame] | 2655 | // This message must always be received when the main frame is a |
| 2656 | // WebLocalFrame. |
| 2657 | CHECK(webview()->mainFrame()->isWebLocalFrame()); |
alexmos | 3fcd0ca | 2015-10-23 18:18:33 | [diff] [blame] | 2658 | SetFocus(enable); |
| 2659 | } |
alexmos | 7fac9aeb | 2015-10-16 22:39:49 | [diff] [blame] | 2660 | |
alexmos | 3fcd0ca | 2015-10-23 18:18:33 | [diff] [blame] | 2661 | void RenderViewImpl::SetFocus(bool enable) { |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 2662 | RenderWidget::OnSetFocus(enable); |
| 2663 | |
[email protected] | 32103299 | 2012-11-08 01:01:27 | [diff] [blame] | 2664 | // Notify all BrowserPlugins of the RenderView's focus state. |
fsamuel | 6c1dfeb | 2014-12-18 19:21:33 | [diff] [blame] | 2665 | if (BrowserPluginManager::Get()) |
| 2666 | BrowserPluginManager::Get()->UpdateFocusState(); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 2667 | } |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 2668 | |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 2669 | void RenderViewImpl::RenderWidgetDidSetColorProfile( |
[email protected] | 28ed6b3 | 2014-06-08 02:16:27 | [diff] [blame] | 2670 | const std::vector<char>& profile) { |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 2671 | if (webview()) { |
ccameron | 7c4df6c2 | 2016-08-11 03:03:15 | [diff] [blame] | 2672 | WebVector<char> colorProfile = profile; |
| 2673 | webview()->setDeviceColorProfile(colorProfile); |
avi | 40b5be7a | 2016-03-03 21:13:44 | [diff] [blame] | 2674 | } |
noel | db4df15 | 2014-09-16 17:45:20 | [diff] [blame] | 2675 | } |
| 2676 | |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 2677 | void RenderViewImpl::DidCompletePageScaleAnimation() { |
avi | d7d6b2e | 2016-03-04 19:41:17 | [diff] [blame] | 2678 | GetWidget()->FocusChangeComplete(); |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 2679 | } |
| 2680 | |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 2681 | void RenderViewImpl::OnDeviceScaleFactorChanged() { |
| 2682 | RenderWidget::OnDeviceScaleFactorChanged(); |
| 2683 | UpdateWebViewWithDeviceScaleFactor(); |
| 2684 | if (auto_resize_mode_) |
| 2685 | AutoResizeCompositor(); |
| 2686 | } |
| 2687 | |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 2688 | void RenderViewImpl::SetScreenMetricsEmulationParameters( |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 2689 | bool enabled, |
| 2690 | const blink::WebDeviceEmulationParams& params) { |
[email protected] | 404630b | 2014-07-03 19:33:03 | [diff] [blame] | 2691 | if (webview() && compositor()) { |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 2692 | if (enabled) |
| 2693 | webview()->enableDeviceEmulation(params); |
| 2694 | else |
| 2695 | webview()->disableDeviceEmulation(); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 2696 | } |
| 2697 | } |
| 2698 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2699 | blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 2700 | if (!speech_recognition_dispatcher_) |
| 2701 | speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 2702 | return speech_recognition_dispatcher_; |
| 2703 | } |
| 2704 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2705 | void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
| 2706 | double maximum_level) { |
a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 2707 | // Round the double to avoid returning incorrect minimum/maximum zoom |
| 2708 | // percentages. |
| 2709 | int minimum_percent = round( |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 2710 | ZoomLevelToZoomFactor(minimum_level) * 100); |
a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 2711 | int maximum_percent = round( |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 2712 | ZoomLevelToZoomFactor(maximum_level) * 100); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2713 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2714 | Send(new ViewHostMsg_UpdateZoomLimits(GetRoutingID(), minimum_percent, |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2715 | maximum_percent)); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2716 | } |
| 2717 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2718 | void RenderViewImpl::zoomLevelChanged() { |
[email protected] | 54b8e18 | 2014-05-02 18:08:29 | [diff] [blame] | 2719 | double zoom_level = webview()->zoomLevel(); |
[email protected] | 2b942c33 | 2012-04-25 16:26:26 | [diff] [blame] | 2720 | |
[email protected] | 54b8e18 | 2014-05-02 18:08:29 | [diff] [blame] | 2721 | // Do not send empty URLs to the browser when we are just setting the default |
| 2722 | // zoom level (from RendererPreferences) before the first navigation. |
| 2723 | if (!webview()->mainFrame()->document().url().isEmpty()) { |
| 2724 | // Tell the browser which url got zoomed so it can update the menu and the |
| 2725 | // saved values if necessary |
| 2726 | Send(new ViewHostMsg_DidZoomURL( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2727 | GetRoutingID(), zoom_level, |
[email protected] | 54b8e18 | 2014-05-02 18:08:29 | [diff] [blame] | 2728 | GURL(webview()->mainFrame()->document().url()))); |
| 2729 | } |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2730 | } |
| 2731 | |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2732 | void RenderViewImpl::pageScaleFactorChanged() { |
| 2733 | if (!webview()) |
| 2734 | return; |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 2735 | |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2736 | Send(new ViewHostMsg_PageScaleFactorChanged(GetRoutingID(), |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 2737 | webview()->pageScaleFactor())); |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2738 | } |
| 2739 | |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 2740 | double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { |
| 2741 | return ZoomLevelToZoomFactor(zoom_level); |
| 2742 | } |
| 2743 | |
| 2744 | double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { |
| 2745 | return ZoomFactorToZoomLevel(factor); |
| 2746 | } |
| 2747 | |
[email protected] | a0629af9 | 2012-08-08 00:39:37 | [diff] [blame] | 2748 | void RenderViewImpl::draggableRegionsChanged() { |
| 2749 | FOR_EACH_OBSERVER( |
| 2750 | RenderViewObserver, |
| 2751 | observers_, |
| 2752 | DraggableRegionsChanged(webview()->mainFrame())); |
| 2753 | } |
| 2754 | |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 2755 | void RenderViewImpl::pageImportanceSignalsChanged() { |
| 2756 | if (!webview() || !main_render_frame_) |
| 2757 | return; |
| 2758 | |
vmpstr | 10e0d5f | 2016-07-21 23:46:09 | [diff] [blame] | 2759 | auto* web_signals = webview()->pageImportanceSignals(); |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 2760 | |
| 2761 | PageImportanceSignals signals; |
| 2762 | signals.had_form_interaction = web_signals->hadFormInteraction(); |
| 2763 | |
| 2764 | main_render_frame_->Send(new FrameHostMsg_UpdatePageImportanceSignals( |
| 2765 | main_render_frame_->GetRoutingID(), signals)); |
| 2766 | } |
| 2767 | |
dglazkov | 8d0c21dd | 2016-08-06 15:56:36 | [diff] [blame] | 2768 | // TODO(dglazkov): Remove this ifdef. The content detection code |
| 2769 | // should not be platform-specific. |
| 2770 | // See http://crbug.com/635214 for details. |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2771 | #if defined(OS_ANDROID) |
dglazkov | 8d0c21dd | 2016-08-06 15:56:36 | [diff] [blame] | 2772 | WebURL RenderViewImpl::detectContentIntentAt( |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2773 | const WebHitTestResult& touch_hit) { |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2774 | DCHECK(touch_hit.node().isTextNode()); |
| 2775 | |
| 2776 | // Process the position with all the registered content detectors until |
| 2777 | // a match is found. Priority is provided by their relative order. |
limasdf | 81d962e | 2015-11-20 08:39:18 | [diff] [blame] | 2778 | for (const auto& detector : content_detectors_) { |
dglazkov | 0d073cb | 2016-08-07 19:46:46 | [diff] [blame] | 2779 | WebURL intent = detector->FindTappedContent(touch_hit); |
| 2780 | if (intent.isValid()) { |
| 2781 | return intent; |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2782 | } |
| 2783 | } |
dglazkov | 8d0c21dd | 2016-08-06 15:56:36 | [diff] [blame] | 2784 | return WebURL(); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2785 | } |
| 2786 | |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 2787 | void RenderViewImpl::scheduleContentIntent(const WebURL& intent, |
| 2788 | bool is_main_frame) { |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2789 | // Introduce a short delay so that the user can notice the content. |
fdoray | 7a8954a4 | 2016-06-07 04:28:38 | [diff] [blame] | 2790 | base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2791 | FROM_HERE, |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 2792 | base::Bind(&RenderViewImpl::LaunchAndroidContentIntent, AsWeakPtr(), |
| 2793 | intent, expected_content_intent_id_, is_main_frame), |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2794 | base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds)); |
| 2795 | } |
| 2796 | |
| 2797 | void RenderViewImpl::cancelScheduledContentIntents() { |
| 2798 | ++expected_content_intent_id_; |
| 2799 | } |
| 2800 | |
| 2801 | void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 2802 | size_t request_id, |
| 2803 | bool is_main_frame) { |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2804 | if (request_id != expected_content_intent_id_) |
qinmin | 0d5560df | 2014-11-12 19:03:39 | [diff] [blame] | 2805 | return; |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2806 | |
| 2807 | // Remove the content highlighting if any. |
jdduke | 491a3f0c | 2015-06-15 23:30:26 | [diff] [blame] | 2808 | ScheduleComposite(); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2809 | |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 2810 | if (!intent.is_empty()) { |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2811 | Send(new ViewHostMsg_StartContentIntent(GetRoutingID(), intent, |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2812 | is_main_frame)); |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 2813 | } |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2814 | } |
[email protected] | b18583c | 2012-12-18 06:55:27 | [diff] [blame] | 2815 | |
| 2816 | bool RenderViewImpl::openDateTimeChooser( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2817 | const blink::WebDateTimeChooserParams& params, |
| 2818 | blink::WebDateTimeChooserCompletion* completion) { |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 2819 | // JavaScript may try to open a date time chooser while one is already open. |
| 2820 | if (date_time_picker_client_) |
| 2821 | return false; |
[email protected] | b18583c | 2012-12-18 06:55:27 | [diff] [blame] | 2822 | date_time_picker_client_.reset( |
| 2823 | new RendererDateTimePicker(this, params, completion)); |
| 2824 | return date_time_picker_client_->Open(); |
| 2825 | } |
| 2826 | |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 2827 | void RenderViewImpl::DismissDateTimeDialog() { |
| 2828 | DCHECK(date_time_picker_client_); |
| 2829 | date_time_picker_client_.reset(NULL); |
| 2830 | } |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 2831 | |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 2832 | #endif // defined(OS_ANDROID) |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 2833 | |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 2834 | void RenderViewImpl::OnShowContextMenu( |
| 2835 | ui::MenuSourceType source_type, const gfx::Point& location) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2836 | input_handler_->set_context_menu_source_type(source_type); |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 2837 | has_host_context_menu_location_ = true; |
| 2838 | host_context_menu_location_ = location; |
[email protected] | 4782226 | 2013-04-23 17:22:36 | [diff] [blame] | 2839 | if (webview()) |
| 2840 | webview()->showContextMenu(); |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 2841 | has_host_context_menu_location_ = false; |
[email protected] | 4782226 | 2013-04-23 17:22:36 | [diff] [blame] | 2842 | } |
| 2843 | |
estade | 6b9696bd | 2016-05-04 23:51:36 | [diff] [blame] | 2844 | #if defined(OS_ANDROID) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2845 | bool RenderViewImpl::didTapMultipleTargets( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2846 | const WebSize& inner_viewport_offset, |
| 2847 | const WebRect& touch_rect, |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2848 | const WebVector<WebRect>& target_rects) { |
[email protected] | 8d3dfee6 | 2013-06-19 05:50:33 | [diff] [blame] | 2849 | // Never show a disambiguation popup when accessibility is enabled, |
| 2850 | // as this interferes with "touch exploration". |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 2851 | AccessibilityMode accessibility_mode = |
mostynb | c3335323 | 2014-09-12 09:38:31 | [diff] [blame] | 2852 | GetMainRenderFrame()->accessibility_mode(); |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 2853 | bool matches_accessibility_mode_complete = |
| 2854 | (accessibility_mode & AccessibilityModeComplete) == |
| 2855 | AccessibilityModeComplete; |
| 2856 | if (matches_accessibility_mode_complete) |
[email protected] | 8d3dfee6 | 2013-06-19 05:50:33 | [diff] [blame] | 2857 | return false; |
| 2858 | |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2859 | // The touch_rect, target_rects and zoom_rect are in the outer viewport |
| 2860 | // reference frame. |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2861 | gfx::Rect zoom_rect; |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 2862 | float new_total_scale = |
| 2863 | DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2864 | touch_rect, target_rects, GetSize(), |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 2865 | gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
| 2866 | device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); |
jbauman | 0ed0918 | 2015-01-30 22:33:49 | [diff] [blame] | 2867 | if (!new_total_scale || zoom_rect.IsEmpty()) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2868 | return false; |
| 2869 | |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 2870 | bool handled = false; |
| 2871 | switch (renderer_preferences_.tap_multiple_targets_strategy) { |
| 2872 | case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: |
| 2873 | handled = webview()->zoomToMultipleTargetsRect(zoom_rect); |
| 2874 | break; |
| 2875 | case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: { |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2876 | gfx::Size canvas_size = |
danakj | ddaec91 | 2015-09-25 19:38:40 | [diff] [blame] | 2877 | gfx::ScaleToCeiledSize(zoom_rect.size(), new_total_scale); |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2878 | cc::SharedBitmapManager* manager = |
| 2879 | RenderThreadImpl::current()->shared_bitmap_manager(); |
dcheng | cedca561 | 2016-04-09 01:40:15 | [diff] [blame] | 2880 | std::unique_ptr<cc::SharedBitmap> shared_bitmap = |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2881 | manager->AllocateSharedBitmap(canvas_size); |
jbauman | 0ed0918 | 2015-01-30 22:33:49 | [diff] [blame] | 2882 | CHECK(!!shared_bitmap); |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2883 | { |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2884 | SkBitmap bitmap; |
| 2885 | SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(), |
| 2886 | canvas_size.height()); |
| 2887 | bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes()); |
| 2888 | SkCanvas canvas(bitmap); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2889 | |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2890 | // TODO(trchen): Cleanup the device scale factor mess. |
| 2891 | // device scale will be applied in WebKit |
| 2892 | // --> zoom_rect doesn't include device scale, |
| 2893 | // but WebKit will still draw on zoom_rect * device_scale_factor_ |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2894 | canvas.scale(new_total_scale / device_scale_factor_, |
| 2895 | new_total_scale / device_scale_factor_); |
| 2896 | canvas.translate(-zoom_rect.x() * device_scale_factor_, |
| 2897 | -zoom_rect.y() * device_scale_factor_); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2898 | |
lfg | 8ff3391 | 2016-09-13 20:59:21 | [diff] [blame] | 2899 | DCHECK(webview_->isAcceleratedCompositingActive()); |
| 2900 | webview_->paintIgnoringCompositing(&canvas, zoom_rect); |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2901 | } |
| 2902 | |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2903 | gfx::Rect zoom_rect_in_screen = |
| 2904 | zoom_rect - gfx::Vector2d(inner_viewport_offset.width, |
| 2905 | inner_viewport_offset.height); |
| 2906 | |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 2907 | gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 2908 | ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect_in_screen))); |
| 2909 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2910 | Send(new ViewHostMsg_ShowDisambiguationPopup( |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2911 | GetRoutingID(), physical_window_zoom_rect, canvas_size, |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2912 | shared_bitmap->id())); |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2913 | cc::SharedBitmapId id = shared_bitmap->id(); |
| 2914 | disambiguation_bitmaps_[id] = shared_bitmap.release(); |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 2915 | handled = true; |
| 2916 | break; |
| 2917 | } |
| 2918 | case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: |
| 2919 | // No-op. |
| 2920 | break; |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2921 | } |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 2922 | |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 2923 | return handled; |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2924 | } |
estade | 6b9696bd | 2016-05-04 23:51:36 | [diff] [blame] | 2925 | #endif // defined(OS_ANDROID) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2926 | |
[email protected] | b283d29 | 2013-02-21 08:40:34 | [diff] [blame] | 2927 | unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| 2928 | return history_list_length_; |
| 2929 | } |
| 2930 | |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 2931 | void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { |
| 2932 | if (enable) { |
| 2933 | if (has_focus()) |
| 2934 | return; |
| 2935 | OnSetActive(true); |
| 2936 | OnSetFocus(true); |
| 2937 | } else { |
| 2938 | if (!has_focus()) |
| 2939 | return; |
| 2940 | OnSetFocus(false); |
| 2941 | OnSetActive(false); |
| 2942 | } |
| 2943 | } |
| 2944 | |
[email protected] | 3a1c8a803 | 2013-03-18 22:35:32 | [diff] [blame] | 2945 | void RenderViewImpl::SetDeviceScaleFactorForTesting(float factor) { |
fsamuel | 664e8b6 | 2016-01-20 19:54:01 | [diff] [blame] | 2946 | ResizeParams params; |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 2947 | params.screen_info = screen_info_; |
ccameron | 2f45153 | 2016-09-07 21:49:27 | [diff] [blame] | 2948 | params.screen_info.device_scale_factor = factor; |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 2949 | params.new_size = size(); |
bokan | f0fd241 | 2014-10-30 15:28:55 | [diff] [blame] | 2950 | params.visible_viewport_size = visible_viewport_size_; |
danakj | ddaec91 | 2015-09-25 19:38:40 | [diff] [blame] | 2951 | params.physical_backing_size = gfx::ScaleToCeiledSize(size(), factor); |
dtrainor | cb7779b8 | 2014-12-04 01:08:02 | [diff] [blame] | 2952 | params.top_controls_shrink_blink_size = false; |
| 2953 | params.top_controls_height = 0.f; |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 2954 | params.is_fullscreen_granted = is_fullscreen_granted(); |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 2955 | params.display_mode = display_mode_; |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 2956 | OnResize(params); |
[email protected] | 3a1c8a803 | 2013-03-18 22:35:32 | [diff] [blame] | 2957 | } |
| 2958 | |
[email protected] | 9265016 | 2013-10-30 03:31:02 | [diff] [blame] | 2959 | void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 2960 | gfx::Rect new_window_rect(rootWindowRect().x, |
| 2961 | rootWindowRect().y, |
| 2962 | new_size.width(), |
| 2963 | new_size.height()); |
| 2964 | SetWindowRectSynchronously(new_window_rect); |
[email protected] | 9265016 | 2013-10-30 03:31:02 | [diff] [blame] | 2965 | } |
| 2966 | |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 2967 | void RenderViewImpl::UseSynchronousResizeModeForTesting(bool enable) { |
| 2968 | resizing_mode_selector_->set_is_synchronous_mode(enable); |
| 2969 | } |
| 2970 | |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2971 | void RenderViewImpl::EnableAutoResizeForTesting(const gfx::Size& min_size, |
| 2972 | const gfx::Size& max_size) { |
| 2973 | OnEnableAutoResize(min_size, max_size); |
| 2974 | } |
| 2975 | |
| 2976 | void RenderViewImpl::DisableAutoResizeForTesting(const gfx::Size& new_size) { |
| 2977 | OnDisableAutoResize(new_size); |
| 2978 | } |
| 2979 | |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 2980 | void RenderViewImpl::OnReleaseDisambiguationPopupBitmap( |
| 2981 | const cc::SharedBitmapId& id) { |
| 2982 | BitmapMap::iterator it = disambiguation_bitmaps_.find(id); |
| 2983 | DCHECK(it != disambiguation_bitmaps_.end()); |
| 2984 | delete it->second; |
| 2985 | disambiguation_bitmaps_.erase(it); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 2986 | } |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2987 | |
[email protected] | 6fceb91 | 2013-02-15 06:24:15 | [diff] [blame] | 2988 | void RenderViewImpl::DidCommitCompositorFrame() { |
| 2989 | RenderWidget::DidCommitCompositorFrame(); |
| 2990 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); |
| 2991 | } |
| 2992 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2993 | void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) { |
| 2994 | if (!urls.empty()) |
avi | a3dca18 | 2016-03-19 01:09:52 | [diff] [blame] | 2995 | Send(new ViewHostMsg_UpdateFaviconURL(GetRoutingID(), urls)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2996 | } |
| 2997 | |
| 2998 | void RenderViewImpl::DidStopLoadingIcons() { |
huangs | dde9aceb | 2015-03-17 21:26:16 | [diff] [blame] | 2999 | int icon_types = WebIconURL::TypeFavicon | WebIconURL::TypeTouchPrecomposed | |
| 3000 | WebIconURL::TypeTouch; |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3001 | |
nasko | 2411ba37 | 2014-10-13 17:45:41 | [diff] [blame] | 3002 | // Favicons matter only for the top-level frame. If it is a WebRemoteFrame, |
| 3003 | // just return early. |
| 3004 | if (webview()->mainFrame()->isWebRemoteFrame()) |
| 3005 | return; |
| 3006 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3007 | WebVector<WebIconURL> icon_urls = |
| 3008 | webview()->mainFrame()->iconURLs(icon_types); |
| 3009 | |
| 3010 | std::vector<FaviconURL> urls; |
| 3011 | for (size_t i = 0; i < icon_urls.size(); i++) { |
| 3012 | WebURL url = icon_urls[i].iconURL(); |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 3013 | std::vector<gfx::Size> sizes; |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 3014 | ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3015 | if (!url.isEmpty()) |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 3016 | urls.push_back( |
| 3017 | FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3018 | } |
| 3019 | SendUpdateFaviconURL(urls); |
| 3020 | } |
| 3021 | |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 3022 | void RenderViewImpl::UpdateWebViewWithDeviceScaleFactor() { |
| 3023 | if (!webview()) |
| 3024 | return; |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 3025 | if (IsUseZoomForDSFEnabled()) { |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 3026 | webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 3027 | } else { |
| 3028 | webview()->setDeviceScaleFactor(device_scale_factor_); |
| 3029 | } |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 3030 | webview()->settings()->setPreferCompositingToLCDTextEnabled( |
| 3031 | PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 3032 | } |
| 3033 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 3034 | } // namespace content |