[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> |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 9 | |
[email protected] | 5d4e36d | 2013-02-15 15:18:20 | [diff] [blame] | 10 | #include "base/auto_reset.h" |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 11 | #include "base/bind.h" |
| 12 | #include "base/bind_helpers.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 13 | #include "base/command_line.h" |
[email protected] | bb063b7 | 2009-03-27 23:18:50 | [diff] [blame] | 14 | #include "base/compiler_specific.h" |
[email protected] | 2132d6b | 2013-06-05 00:15:43 | [diff] [blame] | 15 | #include "base/debug/alias.h" |
[email protected] | 728c2ee | 2013-06-25 04:01:07 | [diff] [blame] | 16 | #include "base/files/file_path.h" |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 17 | #include "base/i18n/rtl.h" |
[email protected] | b1cf337 | 2011-04-20 21:28:10 | [diff] [blame] | 18 | #include "base/json/json_writer.h" |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 19 | #include "base/lazy_instance.h" |
[email protected] | cffd752 | 2012-10-23 19:10:58 | [diff] [blame] | 20 | #include "base/memory/scoped_ptr.h" |
[email protected] | f29efe6b | 2014-06-09 05:01:51 | [diff] [blame] | 21 | #include "base/metrics/field_trial.h" |
[email protected] | 835d7c8 | 2010-10-14 04:38:38 | [diff] [blame] | 22 | #include "base/metrics/histogram.h" |
[email protected] | d3b4ee2 | 2013-07-24 22:50:06 | [diff] [blame] | 23 | #include "base/process/kill.h" |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 24 | #include "base/process/process.h" |
[email protected] | 21aa9968 | 2013-06-11 07:17:01 | [diff] [blame] | 25 | #include "base/strings/string_number_conversions.h" |
[email protected] | b9e7c479f | 2013-04-12 04:33:24 | [diff] [blame] | 26 | #include "base/strings/string_piece.h" |
[email protected] | 27c0573 | 2013-02-15 21:55:49 | [diff] [blame] | 27 | #include "base/strings/string_split.h" |
[email protected] | 21aa9968 | 2013-06-11 07:17:01 | [diff] [blame] | 28 | #include "base/strings/string_util.h" |
[email protected] | 40d11e0 | 2013-03-28 17:43:14 | [diff] [blame] | 29 | #include "base/strings/sys_string_conversions.h" |
[email protected] | 74ebfb1 | 2013-06-07 20:48:00 | [diff] [blame] | 30 | #include "base/strings/utf_string_conversions.h" |
[email protected] | abb52216 | 2013-06-28 01:54:16 | [diff] [blame] | 31 | #include "base/time/time.h" |
primiano | 9e38d55 | 2015-01-28 04:18:01 | [diff] [blame] | 32 | #include "base/trace_event/trace_event.h" |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 33 | #include "build/build_config.h" |
[email protected] | a8cb3b73b | 2013-08-12 05:50:50 | [diff] [blame] | 34 | #include "content/child/appcache/appcache_dispatcher.h" |
| 35 | #include "content/child/appcache/web_application_cache_host_impl.h" |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 36 | #include "content/child/child_shared_bitmap_manager.h" |
[email protected] | 29e2fb4 | 2013-07-19 01:13:47 | [diff] [blame] | 37 | #include "content/child/npapi/webplugin_delegate_impl.h" |
[email protected] | 541b7b0 | 2013-06-07 00:59:34 | [diff] [blame] | 38 | #include "content/child/request_extra_data.h" |
mek | 87e0ab5 | 2015-02-13 01:18:26 | [diff] [blame] | 39 | #include "content/child/v8_value_converter_impl.h" |
[email protected] | 10208ea | 2013-06-06 20:08:03 | [diff] [blame] | 40 | #include "content/child/webmessageportchannel_impl.h" |
jinho.bang | 632a1a72 | 2014-09-18 03:02:56 | [diff] [blame] | 41 | #include "content/common/content_constants_internal.h" |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 42 | #include "content/common/content_switches_internal.h" |
[email protected] | 37666cf | 2011-03-13 21:51:42 | [diff] [blame] | 43 | #include "content/common/database_messages.h" |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 44 | #include "content/common/dom_storage/dom_storage_types.h" |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 45 | #include "content/common/drag_messages.h" |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 46 | #include "content/common/frame_messages.h" |
alexmos | bc7eafa | 2014-12-06 01:38:09 | [diff] [blame] | 47 | #include "content/common/frame_replication_state.h" |
[email protected] | c26ad88 | 2012-02-07 06:41:20 | [diff] [blame] | 48 | #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 49 | #include "content/common/input_messages.h" |
[email protected] | 127dd58 | 2011-03-16 21:32:10 | [diff] [blame] | 50 | #include "content/common/pepper_messages.h" |
nick | ac60e7547 | 2015-07-31 00:44:35 | [diff] [blame] | 51 | #include "content/common/site_isolation_policy.h" |
[email protected] | e449521 | 2012-12-06 03:09:12 | [diff] [blame] | 52 | #include "content/common/ssl_status_serialization.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 53 | #include "content/common/view_messages.h" |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 54 | #include "content/public/common/bindings_policy.h" |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 55 | #include "content/public/common/content_client.h" |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 56 | #include "content/public/common/content_constants.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 57 | #include "content/public/common/content_switches.h" |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 58 | #include "content/public/common/drop_data.h" |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 59 | #include "content/public/common/favicon_url.h" |
hirono | 570357bd | 2014-10-08 12:39:27 | [diff] [blame] | 60 | #include "content/public/common/file_chooser_file_info.h" |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 61 | #include "content/public/common/file_chooser_params.h" |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 62 | #include "content/public/common/page_importance_signals.h" |
clamy | da97e832 | 2014-10-07 21:57:25 | [diff] [blame] | 63 | #include "content/public/common/page_state.h" |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 64 | #include "content/public/common/page_zoom.h" |
[email protected] | e449521 | 2012-12-06 03:09:12 | [diff] [blame] | 65 | #include "content/public/common/ssl_status.h" |
[email protected] | 818915cd | 2012-11-20 13:14:11 | [diff] [blame] | 66 | #include "content/public/common/three_d_api_types.h" |
[email protected] | a1d2916 | 2011-10-14 17:14:03 | [diff] [blame] | 67 | #include "content/public/common/url_constants.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 68 | #include "content/public/common/web_preferences.h" |
[email protected] | d344114c | 2011-10-01 01:24:34 | [diff] [blame] | 69 | #include "content/public/renderer/content_renderer_client.h" |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 70 | #include "content/public/renderer/document_state.h" |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 71 | #include "content/public/renderer/navigation_state.h" |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 72 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 73 | #include "content/public/renderer/render_view_visitor.h" |
[email protected] | e6e5675 | 2012-08-10 00:46:06 | [diff] [blame] | 74 | #include "content/renderer/browser_plugin/browser_plugin.h" |
| 75 | #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 76 | #include "content/renderer/disambiguation_popup_helper.h" |
[email protected] | 1910fe8 | 2012-05-10 00:04:10 | [diff] [blame] | 77 | #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 78 | #include "content/renderer/drop_data_builder.h" |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 79 | #include "content/renderer/gpu/render_widget_compositor.h" |
[email protected] | d473498 | 2014-04-15 02:05:55 | [diff] [blame] | 80 | #include "content/renderer/history_controller.h" |
[email protected] | dc06435 | 2014-04-25 08:36:38 | [diff] [blame] | 81 | #include "content/renderer/history_serialization.h" |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 82 | #include "content/renderer/idle_user_detector.h" |
[email protected] | 66fca5bc | 2013-05-23 06:58:29 | [diff] [blame] | 83 | #include "content/renderer/ime_event_guard.h" |
[email protected] | 7a72d45 | 2013-12-13 10:01:13 | [diff] [blame] | 84 | #include "content/renderer/input/input_handler_manager.h" |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 85 | #include "content/renderer/internal_document_state_data.h" |
[email protected] | 4a91488 | 2013-01-10 00:43:48 | [diff] [blame] | 86 | #include "content/renderer/media/audio_device_factory.h" |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 87 | #include "content/renderer/media/video_capture_impl_manager.h" |
clamy | 5f34220 | 2015-03-18 13:47:56 | [diff] [blame] | 88 | #include "content/renderer/navigation_state_impl.h" |
[email protected] | 227692c5 | 2013-05-31 22:43:04 | [diff] [blame] | 89 | #include "content/renderer/render_frame_impl.h" |
[email protected] | 5a7100d | 2014-05-19 01:29:04 | [diff] [blame] | 90 | #include "content/renderer/render_frame_proxy.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 91 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 92 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 8905450 | 2012-06-03 10:29:24 | [diff] [blame] | 93 | #include "content/renderer/render_view_mouse_lock_dispatcher.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] | 86a7d3c | 2011-09-12 16:45:32 | [diff] [blame] | 99 | #include "content/renderer/text_input_client_observer.h" |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 100 | #include "content/renderer/web_ui_extension_data.h" |
[email protected] | 6f51608 | 2011-03-17 19:15:35 | [diff] [blame] | 101 | #include "content/renderer/websharedworker_proxy.h" |
[email protected] | f596114 | 2013-04-17 23:09:42 | [diff] [blame] | 102 | #include "media/audio/audio_output_device.h" |
[email protected] | ee68378a | 2010-08-10 01:05:41 | [diff] [blame] | 103 | #include "media/base/media_switches.h" |
servolk | f54f5c8f | 2015-02-24 20:32:39 | [diff] [blame] | 104 | #include "media/renderers/audio_renderer_impl.h" |
servolk | 8b3b39b | 2015-03-03 19:08:18 | [diff] [blame] | 105 | #include "media/renderers/gpu_video_accelerator_factories.h" |
[email protected] | d1ef81d | 2012-07-24 11:39:36 | [diff] [blame] | 106 | #include "net/base/data_url.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 107 | #include "net/base/escape.h" |
| 108 | #include "net/base/net_errors.h" |
[email protected] | 18fb7a77 | 2012-09-20 19:25:09 | [diff] [blame] | 109 | #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 110 | #include "net/http/http_util.h" |
luken | b171b53 | 2014-09-24 05:50:38 | [diff] [blame] | 111 | #include "skia/ext/platform_canvas.h" |
[email protected] | d0fcff7 | 2013-07-23 02:45:43 | [diff] [blame] | 112 | #include "third_party/WebKit/public/platform/WebCString.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/WebFindOptions.h" |
| 139 | #include "third_party/WebKit/public/web/WebFormControlElement.h" |
| 140 | #include "third_party/WebKit/public/web/WebFormElement.h" |
| 141 | #include "third_party/WebKit/public/web/WebFrame.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 142 | #include "third_party/WebKit/public/web/WebHistoryItem.h" |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 143 | #include "third_party/WebKit/public/web/WebHitTestResult.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 144 | #include "third_party/WebKit/public/web/WebInputElement.h" |
| 145 | #include "third_party/WebKit/public/web/WebInputEvent.h" |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 146 | #include "third_party/WebKit/public/web/WebLocalFrame.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 147 | #include "third_party/WebKit/public/web/WebMediaPlayerAction.h" |
| 148 | #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 149 | #include "third_party/WebKit/public/web/WebPageImportanceSignals.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 150 | #include "third_party/WebKit/public/web/WebPlugin.h" |
| 151 | #include "third_party/WebKit/public/web/WebPluginAction.h" |
| 152 | #include "third_party/WebKit/public/web/WebPluginContainer.h" |
| 153 | #include "third_party/WebKit/public/web/WebPluginDocument.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 154 | #include "third_party/WebKit/public/web/WebRange.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" |
| 158 | #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 159 | #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 160 | #include "third_party/WebKit/public/web/WebSettings.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 161 | #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
[email protected] | 2255a933 | 2013-06-17 05:12:31 | [diff] [blame] | 162 | #include "third_party/WebKit/public/web/WebView.h" |
| 163 | #include "third_party/WebKit/public/web/WebWindowFeatures.h" |
| 164 | #include "third_party/WebKit/public/web/default/WebRenderTheme.h" |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 165 | #include "third_party/icu/source/common/unicode/uchar.h" |
| 166 | #include "third_party/icu/source/common/unicode/uscript.h" |
[email protected] | 4ee6462 | 2014-03-21 22:34:15 | [diff] [blame] | 167 | #include "ui/base/clipboard/clipboard.h" |
[email protected] | 1400e6dc | 2013-04-27 02:36:27 | [diff] [blame] | 168 | #include "ui/base/ui_base_switches_util.h" |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 169 | #include "ui/events/latency_info.h" |
tfarina | 655f81d | 2014-12-23 02:38:50 | [diff] [blame] | 170 | #include "ui/gfx/geometry/point.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 171 | #include "ui/gfx/geometry/rect.h" |
| 172 | #include "ui/gfx/geometry/rect_conversions.h" |
tfarina | ebe974f0 | 2015-01-03 04:25:32 | [diff] [blame] | 173 | #include "ui/gfx/geometry/size_conversions.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 174 | #include "ui/gfx/native_widget_types.h" |
[email protected] | c4a9e93 | 2011-03-05 04:05:55 | [diff] [blame] | 175 | #include "v8/include/v8.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 176 | |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 177 | #if defined(OS_ANDROID) |
[email protected] | befe5478 | 2013-04-23 00:49:25 | [diff] [blame] | 178 | #include <cpu-features.h> |
| 179 | |
[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" |
| 182 | #include "content/renderer/android/email_detector.h" |
| 183 | #include "content/renderer/android/phone_number_detector.h" |
[email protected] | 5c30b5e0 | 2013-05-30 03:46:08 | [diff] [blame] | 184 | #include "third_party/WebKit/public/platform/WebFloatPoint.h" |
| 185 | #include "third_party/WebKit/public/platform/WebFloatRect.h" |
tfarina | 3b0452d | 2014-12-31 15:20:09 | [diff] [blame] | 186 | #include "ui/gfx/geometry/rect_f.h" |
[email protected] | e69bb06 | 2013-06-03 13:05:40 | [diff] [blame] | 187 | |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 188 | #elif defined(OS_WIN) |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 189 | // TODO(port): these files are currently Windows only because they concern: |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 190 | // * theming |
[email protected] | 990e622 | 2012-11-16 13:31:18 | [diff] [blame] | 191 | #include "ui/native_theme/native_theme_win.h" |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 192 | #elif defined(USE_X11) |
[email protected] | 990e622 | 2012-11-16 13:31:18 | [diff] [blame] | 193 | #include "ui/native_theme/native_theme.h" |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 194 | #elif defined(OS_MACOSX) |
| 195 | #include "skia/ext/skia_utils_mac.h" |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 196 | #endif |
| 197 | |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 198 | #if defined(ENABLE_PLUGINS) |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 199 | #include "content/renderer/npapi/webplugin_delegate_proxy.h" |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 200 | #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 201 | #include "content/renderer/pepper/pepper_plugin_registry.h" |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 202 | #endif |
| 203 | |
[email protected] | 9ac667e | 2013-09-09 12:49:21 | [diff] [blame] | 204 | #if defined(ENABLE_WEBRTC) |
| 205 | #include "content/renderer/media/rtc_peer_connection_handler.h" |
[email protected] | 22fe91d | 2014-08-12 17:07:12 | [diff] [blame] | 206 | #include "content/renderer/media/webrtc/peer_connection_dependency_factory.h" |
[email protected] | 9ac667e | 2013-09-09 12:49:21 | [diff] [blame] | 207 | #endif |
| 208 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 209 | using blink::WebAXObject; |
| 210 | using blink::WebApplicationCacheHost; |
| 211 | using blink::WebApplicationCacheHostClient; |
| 212 | using blink::WebCString; |
| 213 | using blink::WebColor; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 214 | using blink::WebConsoleMessage; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 215 | using blink::WebData; |
| 216 | using blink::WebDataSource; |
| 217 | using blink::WebDocument; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 218 | using blink::WebDragData; |
| 219 | using blink::WebDragOperation; |
| 220 | using blink::WebDragOperationsMask; |
| 221 | using blink::WebElement; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 222 | using blink::WebFileChooserCompletion; |
| 223 | using blink::WebFindOptions; |
| 224 | using blink::WebFormControlElement; |
| 225 | using blink::WebFormElement; |
| 226 | using blink::WebFrame; |
| 227 | using blink::WebGestureEvent; |
| 228 | using blink::WebHistoryItem; |
| 229 | using blink::WebHTTPBody; |
| 230 | using blink::WebIconURL; |
| 231 | using blink::WebImage; |
| 232 | using blink::WebInputElement; |
| 233 | using blink::WebInputEvent; |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 234 | using blink::WebLocalFrame; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 235 | using blink::WebMediaPlayerAction; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 236 | using blink::WebMouseEvent; |
| 237 | using blink::WebNavigationPolicy; |
| 238 | using blink::WebNavigationType; |
| 239 | using blink::WebNode; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 240 | using blink::WebPeerConnection00Handler; |
| 241 | using blink::WebPeerConnection00HandlerClient; |
| 242 | using blink::WebPeerConnectionHandler; |
| 243 | using blink::WebPeerConnectionHandlerClient; |
| 244 | using blink::WebPluginAction; |
| 245 | using blink::WebPluginContainer; |
| 246 | using blink::WebPluginDocument; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 247 | using blink::WebPoint; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 248 | using blink::WebRange; |
| 249 | using blink::WebRect; |
| 250 | using blink::WebReferrerPolicy; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 251 | using blink::WebScriptSource; |
| 252 | using blink::WebSearchableFormData; |
| 253 | using blink::WebSecurityOrigin; |
| 254 | using blink::WebSecurityPolicy; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 255 | using blink::WebSettings; |
| 256 | using blink::WebSize; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 257 | using blink::WebStorageNamespace; |
| 258 | using blink::WebStorageQuotaCallbacks; |
| 259 | using blink::WebStorageQuotaError; |
| 260 | using blink::WebStorageQuotaType; |
| 261 | using blink::WebString; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 262 | using blink::WebTextDirection; |
| 263 | using blink::WebTouchEvent; |
| 264 | using blink::WebURL; |
| 265 | using blink::WebURLError; |
| 266 | using blink::WebURLRequest; |
| 267 | using blink::WebURLResponse; |
| 268 | using blink::WebUserGestureIndicator; |
| 269 | using blink::WebVector; |
| 270 | using blink::WebView; |
| 271 | using blink::WebWidget; |
| 272 | using blink::WebWindowFeatures; |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 273 | using blink::WebRuntimeFeatures; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 274 | using base::Time; |
| 275 | using base::TimeDelta; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 276 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 277 | #if defined(OS_ANDROID) |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 278 | using blink::WebContentDetectionResult; |
| 279 | using blink::WebFloatPoint; |
| 280 | using blink::WebFloatRect; |
| 281 | using blink::WebHitTestResult; |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 282 | #endif |
| 283 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 284 | namespace content { |
| 285 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 286 | //----------------------------------------------------------------------------- |
| 287 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 288 | typedef std::map<blink::WebView*, RenderViewImpl*> ViewMap; |
[email protected] | 6de0fd1d | 2011-11-15 13:31:49 | [diff] [blame] | 289 | static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 290 | typedef std::map<int32_t, RenderViewImpl*> RoutingIDViewMap; |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 291 | static base::LazyInstance<RoutingIDViewMap> g_routing_id_view_map = |
| 292 | LAZY_INSTANCE_INITIALIZER; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 293 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 294 | // Time, in seconds, we delay before sending content state changes (such as form |
| 295 | // state and scroll position) to the browser. We delay sending changes to avoid |
| 296 | // spamming the browser. |
| 297 | // To avoid having tab/session restore require sending a message to get the |
| 298 | // current content state during tab closing we use a shorter timeout for the |
| 299 | // foreground renderer. This means there is a small window of time from which |
| 300 | // content state is modified and not sent to session restore, but this is |
| 301 | // better than having to wake up all renderers during shutdown. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 302 | const int kDelaySecondsForContentStateSyncHidden = 5; |
| 303 | const int kDelaySecondsForContentStateSync = 1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 304 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 305 | #if defined(OS_ANDROID) |
| 306 | // Delay between tapping in content and launching the associated android intent. |
| 307 | // Used to allow users see what has been recognized as content. |
[email protected] | 9afc14e2 | 2013-09-25 22:34:14 | [diff] [blame] | 308 | const size_t kContentIntentDelayMilliseconds = 700; |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 309 | #endif |
| 310 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 311 | static RenderViewImpl* (*g_create_render_view_impl)( |
| 312 | CompositorDependencies* compositor_deps, |
| 313 | const ViewMsg_New_Params&) = nullptr; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 314 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 315 | // static |
[email protected] | e507045d | 2013-07-24 15:23:44 | [diff] [blame] | 316 | Referrer RenderViewImpl::GetReferrerFromRequest( |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 317 | WebFrame* frame, |
| 318 | const WebURLRequest& request) { |
| 319 | return Referrer(GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
[email protected] | cacbd7a | 2014-02-04 01:26:02 | [diff] [blame] | 320 | request.referrerPolicy()); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 321 | } |
| 322 | |
[email protected] | c6bc2033 | 2014-02-28 18:30:39 | [diff] [blame] | 323 | // static |
[email protected] | 65920f33 | 2014-03-04 21:14:18 | [diff] [blame] | 324 | WindowOpenDisposition RenderViewImpl::NavigationPolicyToDisposition( |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 325 | WebNavigationPolicy policy) { |
| 326 | switch (policy) { |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 327 | case blink::WebNavigationPolicyIgnore: |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 328 | return IGNORE_ACTION; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 329 | case blink::WebNavigationPolicyDownload: |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 330 | return SAVE_TO_DISK; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 331 | case blink::WebNavigationPolicyCurrentTab: |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 332 | return CURRENT_TAB; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 333 | case blink::WebNavigationPolicyNewBackgroundTab: |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 334 | return NEW_BACKGROUND_TAB; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 335 | case blink::WebNavigationPolicyNewForegroundTab: |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 336 | return NEW_FOREGROUND_TAB; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 337 | case blink::WebNavigationPolicyNewWindow: |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 338 | return NEW_WINDOW; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 339 | case blink::WebNavigationPolicyNewPopup: |
[email protected] | 48861e2 | 2013-01-09 00:27:32 | [diff] [blame] | 340 | return NEW_POPUP; |
| 341 | default: |
| 342 | NOTREACHED() << "Unexpected WebNavigationPolicy"; |
| 343 | return IGNORE_ACTION; |
| 344 | } |
| 345 | } |
| 346 | |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 347 | // Returns true if the device scale is high enough that losing subpixel |
| 348 | // antialiasing won't have a noticeable effect on text quality. |
| 349 | static bool DeviceScaleEnsuresTextQuality(float device_scale_factor) { |
| 350 | #if defined(OS_ANDROID) |
| 351 | // On Android, we never have subpixel antialiasing. |
| 352 | return true; |
| 353 | #else |
jdduke | 7d452b4a | 2015-08-19 21:25:21 | [diff] [blame] | 354 | // 1.5 is a common touchscreen tablet device scale factor. For such |
| 355 | // devices main thread antialiasing is a heavy burden. |
| 356 | return device_scale_factor >= 1.5f; |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 357 | #endif |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 358 | } |
| 359 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 360 | static bool PreferCompositingToLCDText(CompositorDependencies* compositor_deps, |
| 361 | float device_scale_factor) { |
avi | 83883c8 | 2014-12-23 00:08:49 | [diff] [blame] | 362 | const base::CommandLine& command_line = |
| 363 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | b8ec111 | 2014-08-17 20:09:10 | [diff] [blame] | 364 | if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText)) |
[email protected] | fb85419 | 2013-02-06 01:30:04 | [diff] [blame] | 365 | return false; |
[email protected] | b8ec111 | 2014-08-17 20:09:10 | [diff] [blame] | 366 | if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText)) |
[email protected] | fb85419 | 2013-02-06 01:30:04 | [diff] [blame] | 367 | return true; |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 368 | if (!compositor_deps->IsLcdTextEnabled()) |
[email protected] | 10c1973 | 2014-08-18 19:39:23 | [diff] [blame] | 369 | return true; |
[email protected] | d8221b2 | 2013-05-23 05:35:43 | [diff] [blame] | 370 | return DeviceScaleEnsuresTextQuality(device_scale_factor); |
| 371 | } |
| 372 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 373 | static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) { |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 374 | switch (type) { |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 375 | case blink::WebIconURL::TypeFavicon: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 376 | return FaviconURL::FAVICON; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 377 | case blink::WebIconURL::TypeTouch: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 378 | return FaviconURL::TOUCH_ICON; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 379 | case blink::WebIconURL::TypeTouchPrecomposed: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 380 | return FaviconURL::TOUCH_PRECOMPOSED_ICON; |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 381 | case blink::WebIconURL::TypeInvalid: |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 382 | return FaviconURL::INVALID_ICON; |
| 383 | } |
| 384 | return FaviconURL::INVALID_ICON; |
| 385 | } |
| 386 | |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 387 | static void ConvertToFaviconSizes( |
| 388 | const blink::WebVector<blink::WebSize>& web_sizes, |
| 389 | std::vector<gfx::Size>* sizes) { |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 390 | DCHECK(sizes->empty()); |
| 391 | sizes->reserve(web_sizes.size()); |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 392 | for (size_t i = 0; i < web_sizes.size(); ++i) |
| 393 | sizes->push_back(gfx::Size(web_sizes[i])); |
| 394 | } |
| 395 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 396 | /////////////////////////////////////////////////////////////////////////////// |
| 397 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 398 | struct RenderViewImpl::PendingFileChooser { |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 399 | PendingFileChooser(const FileChooserParams& p, WebFileChooserCompletion* c) |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 400 | : params(p), |
| 401 | completion(c) { |
| 402 | } |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 403 | FileChooserParams params; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 404 | WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
| 405 | }; |
| 406 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 407 | namespace { |
| 408 | |
| 409 | class WebWidgetLockTarget : public MouseLockDispatcher::LockTarget { |
| 410 | public: |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 411 | explicit WebWidgetLockTarget(blink::WebWidget* webwidget) |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 412 | : webwidget_(webwidget) {} |
| 413 | |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 414 | void OnLockMouseACK(bool succeeded) override { |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 415 | if (succeeded) |
| 416 | webwidget_->didAcquirePointerLock(); |
| 417 | else |
| 418 | webwidget_->didNotAcquirePointerLock(); |
| 419 | } |
| 420 | |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 421 | void OnMouseLockLost() override { webwidget_->didLosePointerLock(); } |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 422 | |
dcheng | 6d18e40 | 2014-10-21 12:32:52 | [diff] [blame] | 423 | bool HandleMouseLockedInputEvent(const blink::WebMouseEvent& event) override { |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 424 | // The WebWidget handles mouse lock in WebKit's handleInputEvent(). |
| 425 | return false; |
| 426 | } |
| 427 | |
| 428 | private: |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 429 | blink::WebWidget* webwidget_; |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 430 | }; |
| 431 | |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 432 | WebDragData DropDataToWebDragData(const DropData& drop_data) { |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 433 | std::vector<WebDragData::Item> item_list; |
| 434 | |
| 435 | // These fields are currently unused when dragging into WebKit. |
| 436 | DCHECK(drop_data.download_metadata.empty()); |
| 437 | DCHECK(drop_data.file_contents.empty()); |
| 438 | DCHECK(drop_data.file_description_filename.empty()); |
| 439 | |
| 440 | if (!drop_data.text.is_null()) { |
| 441 | WebDragData::Item item; |
| 442 | item.storageType = WebDragData::Item::StorageTypeString; |
| 443 | item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText); |
| 444 | item.stringData = drop_data.text.string(); |
| 445 | item_list.push_back(item); |
| 446 | } |
| 447 | |
| 448 | // TODO(dcheng): Do we need to distinguish between null and empty URLs? Is it |
| 449 | // meaningful to write an empty URL to the clipboard? |
| 450 | if (!drop_data.url.is_empty()) { |
| 451 | WebDragData::Item item; |
| 452 | item.storageType = WebDragData::Item::StorageTypeString; |
| 453 | item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList); |
| 454 | item.stringData = WebString::fromUTF8(drop_data.url.spec()); |
| 455 | item.title = drop_data.url_title; |
| 456 | item_list.push_back(item); |
| 457 | } |
| 458 | |
| 459 | if (!drop_data.html.is_null()) { |
| 460 | WebDragData::Item item; |
| 461 | item.storageType = WebDragData::Item::StorageTypeString; |
| 462 | item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML); |
| 463 | item.stringData = drop_data.html.string(); |
| 464 | item.baseURL = drop_data.html_base_url; |
| 465 | item_list.push_back(item); |
| 466 | } |
| 467 | |
[email protected] | 17ea0ae2 | 2014-03-28 21:54:46 | [diff] [blame] | 468 | for (std::vector<ui::FileInfo>::const_iterator it = |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 469 | drop_data.filenames.begin(); |
| 470 | it != drop_data.filenames.end(); |
| 471 | ++it) { |
| 472 | WebDragData::Item item; |
| 473 | item.storageType = WebDragData::Item::StorageTypeFilename; |
[email protected] | 17ea0ae2 | 2014-03-28 21:54:46 | [diff] [blame] | 474 | item.filenameData = it->path.AsUTF16Unsafe(); |
| 475 | item.displayNameData = it->display_name.AsUTF16Unsafe(); |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 476 | item_list.push_back(item); |
| 477 | } |
| 478 | |
[email protected] | 60ed95f | 2014-04-23 12:19:48 | [diff] [blame] | 479 | for (std::vector<DropData::FileSystemFileInfo>::const_iterator it = |
| 480 | drop_data.file_system_files.begin(); |
| 481 | it != drop_data.file_system_files.end(); |
| 482 | ++it) { |
| 483 | WebDragData::Item item; |
| 484 | item.storageType = WebDragData::Item::StorageTypeFileSystemFile; |
| 485 | item.fileSystemURL = it->url; |
| 486 | item.fileSystemFileSize = it->size; |
| 487 | item_list.push_back(item); |
| 488 | } |
| 489 | |
[email protected] | c1068031 | 2013-05-31 15:22:05 | [diff] [blame] | 490 | for (std::map<base::string16, base::string16>::const_iterator it = |
| 491 | drop_data.custom_data.begin(); |
| 492 | it != drop_data.custom_data.end(); |
| 493 | ++it) { |
| 494 | WebDragData::Item item; |
| 495 | item.storageType = WebDragData::Item::StorageTypeString; |
| 496 | item.stringType = it->first; |
| 497 | item.stringData = it->second; |
| 498 | item_list.push_back(item); |
| 499 | } |
| 500 | |
| 501 | WebDragData result; |
| 502 | result.initialize(); |
| 503 | result.setItems(item_list); |
| 504 | result.setFilesystemId(drop_data.filesystem_id); |
| 505 | return result; |
| 506 | } |
| 507 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 508 | typedef void (*SetFontFamilyWrapper)(blink::WebSettings*, |
| 509 | const base::string16&, |
| 510 | UScriptCode); |
| 511 | |
| 512 | void SetStandardFontFamilyWrapper(WebSettings* settings, |
| 513 | const base::string16& font, |
| 514 | UScriptCode script) { |
| 515 | settings->setStandardFontFamily(font, script); |
| 516 | } |
| 517 | |
| 518 | void SetFixedFontFamilyWrapper(WebSettings* settings, |
| 519 | const base::string16& font, |
| 520 | UScriptCode script) { |
| 521 | settings->setFixedFontFamily(font, script); |
| 522 | } |
| 523 | |
| 524 | void SetSerifFontFamilyWrapper(WebSettings* settings, |
| 525 | const base::string16& font, |
| 526 | UScriptCode script) { |
| 527 | settings->setSerifFontFamily(font, script); |
| 528 | } |
| 529 | |
| 530 | void SetSansSerifFontFamilyWrapper(WebSettings* settings, |
| 531 | const base::string16& font, |
| 532 | UScriptCode script) { |
| 533 | settings->setSansSerifFontFamily(font, script); |
| 534 | } |
| 535 | |
| 536 | void SetCursiveFontFamilyWrapper(WebSettings* settings, |
| 537 | const base::string16& font, |
| 538 | UScriptCode script) { |
| 539 | settings->setCursiveFontFamily(font, script); |
| 540 | } |
| 541 | |
| 542 | void SetFantasyFontFamilyWrapper(WebSettings* settings, |
| 543 | const base::string16& font, |
| 544 | UScriptCode script) { |
| 545 | settings->setFantasyFontFamily(font, script); |
| 546 | } |
| 547 | |
| 548 | void SetPictographFontFamilyWrapper(WebSettings* settings, |
| 549 | const base::string16& font, |
| 550 | UScriptCode script) { |
| 551 | settings->setPictographFontFamily(font, script); |
| 552 | } |
| 553 | |
| 554 | // If |scriptCode| is a member of a family of "similar" script codes, returns |
| 555 | // the script code in that family that is used by WebKit for font selection |
| 556 | // purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are |
| 557 | // considered equivalent for the purposes of font selection. WebKit uses the |
| 558 | // script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is |
| 559 | // USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit |
| 560 | // uses different scripts than the ones in Chrome pref names because the version |
| 561 | // of ICU included on certain ports does not have some of the newer scripts. If |
| 562 | // |scriptCode| is not a member of such a family, returns |scriptCode|. |
| 563 | UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) { |
| 564 | switch (scriptCode) { |
| 565 | case USCRIPT_HIRAGANA: |
| 566 | case USCRIPT_KATAKANA: |
| 567 | case USCRIPT_JAPANESE: |
| 568 | return USCRIPT_KATAKANA_OR_HIRAGANA; |
| 569 | case USCRIPT_KOREAN: |
| 570 | return USCRIPT_HANGUL; |
| 571 | default: |
| 572 | return scriptCode; |
| 573 | } |
| 574 | } |
| 575 | |
| 576 | void ApplyFontsFromMap(const ScriptFontFamilyMap& map, |
| 577 | SetFontFamilyWrapper setter, |
| 578 | WebSettings* settings) { |
| 579 | for (ScriptFontFamilyMap::const_iterator it = map.begin(); it != map.end(); |
| 580 | ++it) { |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 581 | int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str()); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 582 | if (script >= 0 && script < USCRIPT_CODE_LIMIT) { |
| 583 | UScriptCode code = static_cast<UScriptCode>(script); |
| 584 | (*setter)(settings, it->second, GetScriptForWebSettings(code)); |
| 585 | } |
| 586 | } |
| 587 | } |
| 588 | |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 589 | void ApplyBlinkSettings(const base::CommandLine& command_line, |
| 590 | WebSettings* settings) { |
| 591 | if (!command_line.HasSwitch(switches::kBlinkSettings)) |
| 592 | return; |
| 593 | |
brettw | 26dab8f0 | 2015-08-08 00:28:47 | [diff] [blame] | 594 | std::vector<std::string> blink_settings = base::SplitString( |
| 595 | command_line.GetSwitchValueASCII(switches::kBlinkSettings), |
| 596 | ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 597 | for (const std::string& setting : blink_settings) { |
| 598 | size_t pos = setting.find('='); |
| 599 | settings->setFromStrings( |
| 600 | blink::WebString::fromLatin1(setting.substr(0, pos)), |
| 601 | blink::WebString::fromLatin1( |
| 602 | pos == std::string::npos ? "" : setting.substr(pos + 1))); |
| 603 | } |
| 604 | } |
| 605 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 606 | } // namespace |
| 607 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 608 | RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps, |
| 609 | const ViewMsg_New_Params& params) |
| 610 | : RenderWidget(compositor_deps, |
| 611 | blink::WebPopupTypeNone, |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 612 | params.initial_size.screen_info, |
| 613 | params.swapped_out, |
| 614 | params.hidden, |
| 615 | params.never_visible), |
| 616 | webkit_preferences_(params.web_preferences), |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 617 | send_content_state_immediately_(false), |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 618 | enabled_bindings_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 619 | send_preferred_size_changes_(false), |
[email protected] | e75cb49e | 2009-01-05 23:13:21 | [diff] [blame] | 620 | navigation_gesture_(NavigationGestureUnknown), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 621 | opened_by_user_gesture_(true), |
| 622 | opener_suppressed_(false), |
[email protected] | 88f10a2 | 2013-11-06 21:22:12 | [diff] [blame] | 623 | suppress_dialogs_until_swap_out_(false), |
[email protected] | 81a3441 | 2009-01-05 19:17:24 | [diff] [blame] | 624 | page_id_(-1), |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 625 | next_page_id_(params.next_page_id), |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 626 | history_list_offset_(-1), |
| 627 | history_list_length_(0), |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 628 | frames_in_progress_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 629 | target_url_status_(TARGET_NONE), |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 630 | uses_temporary_zoom_level_(false), |
[email protected] | bbc8856d | 2013-06-14 10:37:04 | [diff] [blame] | 631 | #if defined(OS_ANDROID) |
majidvp | fb80e43 | 2015-02-23 14:15:50 | [diff] [blame] | 632 | top_controls_constraints_(TOP_CONTROLS_STATE_BOTH), |
[email protected] | bbc8856d | 2013-06-14 10:37:04 | [diff] [blame] | 633 | #endif |
alexmos | 7fac9aeb | 2015-10-16 22:39:49 | [diff] [blame] | 634 | has_focus_(false), |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 635 | has_scrolled_focused_editable_node_into_rect_(false), |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 636 | main_render_frame_(nullptr), |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 637 | frame_widget_(nullptr), |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 638 | speech_recognition_dispatcher_(NULL), |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 639 | mouse_lock_dispatcher_(NULL), |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 640 | #if defined(OS_ANDROID) |
| 641 | expected_content_intent_id_(0), |
[email protected] | a756427 | 2013-04-19 14:24:46 | [diff] [blame] | 642 | #endif |
| 643 | #if defined(OS_WIN) |
| 644 | focused_plugin_id_(-1), |
| 645 | #endif |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 646 | #if defined(ENABLE_PLUGINS) |
[email protected] | 54ea9ff | 2014-03-20 00:27:54 | [diff] [blame] | 647 | plugin_find_handler_(NULL), |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 648 | focused_pepper_plugin_(NULL), |
| 649 | pepper_last_mouse_event_target_(NULL), |
| 650 | #endif |
[email protected] | 8a67aa35 | 2013-02-20 02:58:29 | [diff] [blame] | 651 | enumeration_completion_id_(0), |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 652 | session_storage_namespace_id_(params.session_storage_namespace_id) { |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 653 | } |
| 654 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 655 | void RenderViewImpl::Initialize(const ViewMsg_New_Params& params, |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 656 | bool was_created_by_renderer) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 657 | SetRoutingID(params.view_id); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 658 | |
| 659 | int opener_view_routing_id; |
alexmos | 9573300 | 2015-08-24 16:38:09 | [diff] [blame] | 660 | WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( |
| 661 | params.opener_frame_route_id, &opener_view_routing_id); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 662 | if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer) |
| 663 | opener_id_ = opener_view_routing_id; |
| 664 | |
thestig | 6057a6b2 | 2015-11-12 23:01:33 | [diff] [blame] | 665 | display_mode_ = params.initial_size.display_mode; |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 666 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 667 | // Ensure we start with a valid next_page_id_ from the browser. |
| 668 | DCHECK_GE(next_page_id_, 0); |
| 669 | |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 670 | webwidget_ = WebView::create(this); |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 671 | webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 672 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 673 | g_view_map.Get().insert(std::make_pair(webview(), this)); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 674 | g_routing_id_view_map.Get().insert(std::make_pair(routing_id(), this)); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 675 | |
avi | 83883c8 | 2014-12-23 00:08:49 | [diff] [blame] | 676 | const base::CommandLine& command_line = |
| 677 | *base::CommandLine::ForCurrentProcess(); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 678 | |
[email protected] | 27c521a | 2013-05-29 20:44:32 | [diff] [blame] | 679 | if (command_line.HasSwitch(switches::kStatsCollectionController)) |
| 680 | stats_collection_observer_.reset(new StatsCollectionObserver(this)); |
| 681 | |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 682 | if (params.main_frame_routing_id != MSG_ROUTING_NONE) { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 683 | main_render_frame_ = RenderFrameImpl::CreateMainFrame( |
| 684 | this, params.main_frame_routing_id, params.main_frame_widget_routing_id, |
| 685 | params.hidden, screen_info(), compositor_deps_); |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 686 | } |
| 687 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 688 | if (params.proxy_routing_id != MSG_ROUTING_NONE) { |
| 689 | CHECK(params.swapped_out); |
| 690 | if (main_render_frame_) { |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 691 | DCHECK(!SiteIsolationPolicy::IsSwappedOutStateForbidden()); |
| 692 | RenderFrameProxy* proxy = RenderFrameProxy::CreateProxyToReplaceFrame( |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 693 | main_render_frame_, params.proxy_routing_id, |
| 694 | blink::WebTreeScopeType::Document); |
| 695 | main_render_frame_->set_render_frame_proxy(proxy); |
| 696 | } else { |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 697 | DCHECK(SiteIsolationPolicy::IsSwappedOutStateForbidden()); |
alexmos | a181efc | 2015-09-03 00:39:04 | [diff] [blame] | 698 | // Pass MSG_ROUTING_NONE for opener, since actual opener (if any) will be |
| 699 | // set separately below. |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 700 | RenderFrameProxy::CreateFrameProxy(params.proxy_routing_id, routing_id(), |
alexmos | a181efc | 2015-09-03 00:39:04 | [diff] [blame] | 701 | MSG_ROUTING_NONE, MSG_ROUTING_NONE, |
dcheng | c5ef1a5 | 2015-08-26 20:58:30 | [diff] [blame] | 702 | params.replicated_frame_state); |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 703 | } |
| 704 | } |
| 705 | |
nasko | 4c0feb6 | 2015-06-05 18:37:06 | [diff] [blame] | 706 | if (main_render_frame_) |
| 707 | main_render_frame_->Initialize(); |
| 708 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 709 | #if defined(OS_ANDROID) |
limasdf | 81d962e | 2015-11-20 08:39:18 | [diff] [blame] | 710 | content_detectors_.push_back(make_scoped_ptr(new AddressDetector())); |
qinmin | c6a739f9 | 2015-03-31 17:46:11 | [diff] [blame] | 711 | const std::string& contry_iso = |
| 712 | params.renderer_preferences.network_contry_iso; |
| 713 | if (!contry_iso.empty()) { |
limasdf | 81d962e | 2015-11-20 08:39:18 | [diff] [blame] | 714 | content_detectors_.push_back( |
| 715 | make_scoped_ptr(new PhoneNumberDetector(contry_iso))); |
qinmin | 0d5560df | 2014-11-12 19:03:39 | [diff] [blame] | 716 | } |
limasdf | 81d962e | 2015-11-20 08:39:18 | [diff] [blame] | 717 | content_detectors_.push_back(make_scoped_ptr(new EmailDetector())); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 718 | #endif |
| 719 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 720 | RenderThread::Get()->AddRoute(routing_id(), this); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 721 | // Take a reference on behalf of the RenderThread. This will be balanced |
lfg | e208fa4 | 2015-04-17 20:29:18 | [diff] [blame] | 722 | // when we receive ViewMsg_Close in the RenderWidget (which RenderView |
| 723 | // inherits from). |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 724 | AddRef(); |
[email protected] | b2db927 | 2014-01-10 17:42:00 | [diff] [blame] | 725 | if (RenderThreadImpl::current()) { |
| 726 | RenderThreadImpl::current()->WidgetCreated(); |
| 727 | if (is_hidden_) |
| 728 | RenderThreadImpl::current()->WidgetHidden(); |
| 729 | } |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 730 | |
| 731 | // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 732 | // completing initialization. Otherwise, we can finish it now. |
piman | c4af307 | 2015-10-02 03:45:59 | [diff] [blame] | 733 | if (opener_id_ == MSG_ROUTING_NONE) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 734 | did_show_ = true; |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 735 | UpdateWebViewWithDeviceScaleFactor(); |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 736 | webview()->setDisplayMode(display_mode_); |
[email protected] | b8ec111 | 2014-08-17 20:09:10 | [diff] [blame] | 737 | webview()->settings()->setPreferCompositingToLCDTextEnabled( |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 738 | PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
jdduke | 2eee6cb | 2014-09-25 17:02:21 | [diff] [blame] | 739 | webview()->settings()->setThreadedScrollingEnabled( |
| 740 | !command_line.HasSwitch(switches::kDisableThreadedScrolling)); |
skobes | 92ed7d46 | 2014-11-05 22:05:23 | [diff] [blame] | 741 | webview()->settings()->setRootLayerScrolls( |
| 742 | command_line.HasSwitch(switches::kRootLayerScrolls)); |
[email protected] | fb85419 | 2013-02-06 01:30:04 | [diff] [blame] | 743 | |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 744 | ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_); |
[email protected] | 9b159a5 | 2013-10-03 17:24:55 | [diff] [blame] | 745 | |
[email protected] | 1400e6dc | 2013-04-27 02:36:27 | [diff] [blame] | 746 | if (switches::IsTouchDragDropEnabled()) |
[email protected] | edbea62 | 2012-11-28 20:39:38 | [diff] [blame] | 747 | webview()->settings()->setTouchDragDropEnabled(true); |
| 748 | |
mfomitchev | 5ad034ec | 2015-04-24 21:57:27 | [diff] [blame] | 749 | WebSettings::SelectionStrategyType selection_strategy = |
jdduke | 9a6cbec | 2015-05-13 22:00:03 | [diff] [blame] | 750 | WebSettings::SelectionStrategyType::Character; |
mfomitchev | 5ad034ec | 2015-04-24 21:57:27 | [diff] [blame] | 751 | const std::string selection_strategy_str = |
| 752 | base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 753 | switches::kTouchTextSelectionStrategy); |
jdduke | 9a6cbec | 2015-05-13 22:00:03 | [diff] [blame] | 754 | if (selection_strategy_str == "direction") |
mfomitchev | 5ad034ec | 2015-04-24 21:57:27 | [diff] [blame] | 755 | selection_strategy = WebSettings::SelectionStrategyType::Direction; |
| 756 | webview()->settings()->setSelectionStrategy(selection_strategy); |
| 757 | |
alexmos | 35799be | 2015-07-02 08:59:50 | [diff] [blame] | 758 | // Set the main frame's name. Only needs to be done for WebLocalFrames, |
| 759 | // since the remote case was handled as part of SetReplicatedState on the |
| 760 | // proxy above. |
| 761 | if (!params.replicated_frame_state.name.empty() && |
| 762 | webview()->mainFrame()->isWebLocalFrame()) { |
alexmos | 3448b55 | 2015-06-26 07:49:13 | [diff] [blame] | 763 | webview()->mainFrame()->setName( |
| 764 | blink::WebString::fromUTF8(params.replicated_frame_state.name)); |
| 765 | } |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 766 | |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 767 | // TODO(davidben): Move this state from Blink into content. |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 768 | if (params.window_was_created_with_opener) |
[email protected] | c7c0d82 | 2014-04-16 20:19:49 | [diff] [blame] | 769 | webview()->setOpenedByDOM(); |
| 770 | |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 771 | OnSetRendererPrefs(params.renderer_preferences); |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 772 | |
wangxianzhu | 3bf39be5 | 2015-04-10 23:56:41 | [diff] [blame] | 773 | ApplyBlinkSettings(command_line, webview()->settings()); |
| 774 | |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 775 | if (!params.enable_auto_resize) { |
| 776 | OnResize(params.initial_size); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 777 | } else { |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 778 | OnEnableAutoResize(params.min_size, params.max_size); |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 779 | } |
| 780 | |
[email protected] | 86a7d3c | 2011-09-12 16:45:32 | [diff] [blame] | 781 | #if defined(OS_MACOSX) |
| 782 | new TextInputClientObserver(this); |
| 783 | #endif // defined(OS_MACOSX) |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 784 | |
dgozman | 358ba32 | 2015-03-26 15:05:30 | [diff] [blame] | 785 | // The next group of objects all implement RenderViewObserver, so are deleted |
| 786 | // along with the RenderView automatically. |
[email protected] | 8905450 | 2012-06-03 10:29:24 | [diff] [blame] | 787 | mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 788 | |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 789 | // We don't use HistoryController in OOPIF-enabled modes. |
| 790 | if (!SiteIsolationPolicy::UseSubframeNavigationEntries()) |
| 791 | history_controller_.reset(new HistoryController(this)); |
[email protected] | d473498 | 2014-04-15 02:05:55 | [diff] [blame] | 792 | |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 793 | new IdleUserDetector(this); |
| 794 | |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 795 | if (command_line.HasSwitch(switches::kDomAutomationController)) |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 796 | enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION; |
[email protected] | 27c521a | 2013-05-29 20:44:32 | [diff] [blame] | 797 | if (command_line.HasSwitch(switches::kStatsCollectionController)) |
| 798 | enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION; |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 799 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 800 | GetContentClient()->renderer()->RenderViewCreated(this); |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 801 | |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 802 | // If we have an opener_frame but we weren't created by a renderer, then it's |
| 803 | // the browser asking us to set our opener to another frame. |
| 804 | if (opener_frame && !was_created_by_renderer) |
| 805 | webview()->mainFrame()->setOpener(opener_frame); |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 806 | |
| 807 | // If we are initially swapped out, navigate to kSwappedOutURL. |
| 808 | // This ensures we are in a unique origin that others cannot script. |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 809 | if (is_swapped_out_ && webview()->mainFrame()->isWebLocalFrame()) |
nasko | 78f06bc | 2014-11-18 18:18:57 | [diff] [blame] | 810 | main_render_frame_->NavigateToSwappedOutURL(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 811 | } |
| 812 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 813 | RenderViewImpl::~RenderViewImpl() { |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 814 | DCHECK(!frame_widget_); |
| 815 | |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 816 | for (BitmapMap::iterator it = disambiguation_bitmaps_.begin(); |
| 817 | it != disambiguation_bitmaps_.end(); |
| 818 | ++it) |
| 819 | delete it->second; |
[email protected] | 91a2aea | 2013-07-08 23:14:39 | [diff] [blame] | 820 | |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 821 | // If file chooser is still waiting for answer, dispatch empty answer. |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 822 | while (!file_chooser_completions_.empty()) { |
| 823 | if (file_chooser_completions_.front()->completion) { |
| 824 | file_chooser_completions_.front()->completion->didChooseFile( |
| 825 | WebVector<WebString>()); |
| 826 | } |
| 827 | file_chooser_completions_.pop_front(); |
| 828 | } |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 829 | |
[email protected] | 8ed1d3f | 2013-02-20 11:45:55 | [diff] [blame] | 830 | #if defined(OS_ANDROID) |
| 831 | // The date/time picker client is both a scoped_ptr member of this class and |
| 832 | // a RenderViewObserver. Reset it to prevent double deletion. |
| 833 | date_time_picker_client_.reset(); |
| 834 | #endif |
| 835 | |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 836 | #ifndef NDEBUG |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 837 | // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap. |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 838 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 839 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 840 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 058561b | 2012-12-03 06:48:22 | [diff] [blame] | 841 | RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer(); |
| 842 | for (RoutingIDViewMap::iterator it = routing_id_views->begin(); |
| 843 | it != routing_id_views->end(); ++it) |
| 844 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 845 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 846 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 847 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 848 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 849 | } |
| 850 | |
| 851 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 852 | RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 853 | ViewMap* views = g_view_map.Pointer(); |
| 854 | ViewMap::iterator it = views->find(webview); |
| 855 | return it == views->end() ? NULL : it->second; |
| 856 | } |
| 857 | |
| 858 | /*static*/ |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 859 | RenderView* RenderView::FromWebView(blink::WebView* webview) { |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 860 | return RenderViewImpl::FromWebView(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 861 | } |
| 862 | |
| 863 | /*static*/ |
avi | 1023d01 | 2015-12-25 02:39:14 | [diff] [blame] | 864 | RenderViewImpl* RenderViewImpl::FromRoutingID(int32_t routing_id) { |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 865 | RoutingIDViewMap* views = g_routing_id_view_map.Pointer(); |
| 866 | RoutingIDViewMap::iterator it = views->find(routing_id); |
| 867 | return it == views->end() ? NULL : it->second; |
| 868 | } |
| 869 | |
| 870 | /*static*/ |
| 871 | RenderView* RenderView::FromRoutingID(int routing_id) { |
| 872 | return RenderViewImpl::FromRoutingID(routing_id); |
| 873 | } |
| 874 | |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 875 | /* static */ |
jochen | 9c7b8f24 | 2015-06-01 15:32:02 | [diff] [blame] | 876 | size_t RenderView::GetRenderViewCount() { |
[email protected] | f3a9531 | 2014-06-12 16:46:58 | [diff] [blame] | 877 | return g_view_map.Get().size(); |
| 878 | } |
| 879 | |
[email protected] | 640e303c | 2012-12-05 01:36:07 | [diff] [blame] | 880 | /*static*/ |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 881 | void RenderView::ForEach(RenderViewVisitor* visitor) { |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 882 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 883 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 884 | if (!visitor->Visit(it->second)) |
| 885 | return; |
| 886 | } |
| 887 | } |
| 888 | |
| 889 | /*static*/ |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 890 | void RenderView::ApplyWebPreferences(const WebPreferences& prefs, |
| 891 | WebView* web_view) { |
| 892 | WebSettings* settings = web_view->settings(); |
| 893 | ApplyFontsFromMap(prefs.standard_font_family_map, |
| 894 | SetStandardFontFamilyWrapper, settings); |
| 895 | ApplyFontsFromMap(prefs.fixed_font_family_map, |
| 896 | SetFixedFontFamilyWrapper, settings); |
| 897 | ApplyFontsFromMap(prefs.serif_font_family_map, |
| 898 | SetSerifFontFamilyWrapper, settings); |
| 899 | ApplyFontsFromMap(prefs.sans_serif_font_family_map, |
| 900 | SetSansSerifFontFamilyWrapper, settings); |
| 901 | ApplyFontsFromMap(prefs.cursive_font_family_map, |
| 902 | SetCursiveFontFamilyWrapper, settings); |
| 903 | ApplyFontsFromMap(prefs.fantasy_font_family_map, |
| 904 | SetFantasyFontFamilyWrapper, settings); |
| 905 | ApplyFontsFromMap(prefs.pictograph_font_family_map, |
| 906 | SetPictographFontFamilyWrapper, settings); |
| 907 | settings->setDefaultFontSize(prefs.default_font_size); |
| 908 | settings->setDefaultFixedFontSize(prefs.default_fixed_font_size); |
| 909 | settings->setMinimumFontSize(prefs.minimum_font_size); |
| 910 | settings->setMinimumLogicalFontSize(prefs.minimum_logical_font_size); |
| 911 | settings->setDefaultTextEncodingName( |
| 912 | base::ASCIIToUTF16(prefs.default_encoding)); |
| 913 | settings->setJavaScriptEnabled(prefs.javascript_enabled); |
| 914 | settings->setWebSecurityEnabled(prefs.web_security_enabled); |
| 915 | settings->setJavaScriptCanOpenWindowsAutomatically( |
| 916 | prefs.javascript_can_open_windows_automatically); |
| 917 | settings->setLoadsImagesAutomatically(prefs.loads_images_automatically); |
| 918 | settings->setImagesEnabled(prefs.images_enabled); |
| 919 | settings->setPluginsEnabled(prefs.plugins_enabled); |
| 920 | settings->setDOMPasteAllowed(prefs.dom_paste_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 921 | settings->setUsesEncodingDetector(prefs.uses_universal_detector); |
| 922 | settings->setTextAreasAreResizable(prefs.text_areas_are_resizable); |
| 923 | settings->setAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows); |
| 924 | settings->setDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled); |
| 925 | settings->setJavaScriptCanAccessClipboard( |
| 926 | prefs.javascript_can_access_clipboard); |
| 927 | WebRuntimeFeatures::enableXSLT(prefs.xslt_enabled); |
| 928 | settings->setXSSAuditorEnabled(prefs.xss_auditor_enabled); |
| 929 | settings->setDNSPrefetchingEnabled(prefs.dns_prefetching_enabled); |
Ben Greenstein | 49878f5 | 2015-12-18 19:13:21 | [diff] [blame] | 930 | settings->setDataSaverEnabled(prefs.data_saver_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 931 | settings->setLocalStorageEnabled(prefs.local_storage_enabled); |
| 932 | settings->setSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled); |
| 933 | WebRuntimeFeatures::enableDatabase(prefs.databases_enabled); |
| 934 | settings->setOfflineWebApplicationCacheEnabled( |
| 935 | prefs.application_cache_enabled); |
| 936 | settings->setCaretBrowsingEnabled(prefs.caret_browsing_enabled); |
| 937 | settings->setHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled); |
| 938 | settings->setCookieEnabled(prefs.cookie_enabled); |
| 939 | settings->setNavigateOnDragDrop(prefs.navigate_on_drag_drop); |
| 940 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 941 | // By default, allow_universal_access_from_file_urls is set to false and thus |
| 942 | // we mitigate attacks from local HTML files by not granting file:// URLs |
| 943 | // universal access. Only test shell will enable this. |
| 944 | settings->setAllowUniversalAccessFromFileURLs( |
| 945 | prefs.allow_universal_access_from_file_urls); |
| 946 | settings->setAllowFileAccessFromFileURLs( |
| 947 | prefs.allow_file_access_from_file_urls); |
| 948 | |
| 949 | // Enable the web audio API if requested on the command line. |
| 950 | settings->setWebAudioEnabled(prefs.webaudio_enabled); |
| 951 | |
| 952 | // Enable experimental WebGL support if requested on command line |
| 953 | // and support is compiled in. |
| 954 | settings->setExperimentalWebGLEnabled(prefs.experimental_webgl_enabled); |
| 955 | |
| 956 | // Disable GL multisampling if requested on command line. |
| 957 | settings->setOpenGLMultisamplingEnabled(prefs.gl_multisampling_enabled); |
| 958 | |
| 959 | // Enable WebGL errors to the JS console if requested. |
| 960 | settings->setWebGLErrorsToConsoleEnabled( |
| 961 | prefs.webgl_errors_to_console_enabled); |
| 962 | |
| 963 | // Uses the mock theme engine for scrollbars. |
| 964 | settings->setMockScrollbarsEnabled(prefs.mock_scrollbars_enabled); |
| 965 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 966 | // Enable gpu-accelerated 2d canvas if requested on the command line. |
| 967 | settings->setAccelerated2dCanvasEnabled(prefs.accelerated_2d_canvas_enabled); |
| 968 | |
| 969 | settings->setMinimumAccelerated2dCanvasSize( |
| 970 | prefs.minimum_accelerated_2d_canvas_size); |
| 971 | |
| 972 | // Disable antialiasing for 2d canvas if requested on the command line. |
| 973 | settings->setAntialiased2dCanvasEnabled( |
| 974 | !prefs.antialiased_2d_canvas_disabled); |
| 975 | |
robertphillips | e25137b | 2014-10-20 13:44:34 | [diff] [blame] | 976 | // Enabled antialiasing of clips for 2d canvas if requested on the command |
| 977 | // line. |
| 978 | settings->setAntialiasedClips2dCanvasEnabled( |
| 979 | prefs.antialiased_clips_2d_canvas_enabled); |
| 980 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 981 | // Set MSAA sample count for 2d canvas if requested on the command line (or |
| 982 | // default value if not). |
| 983 | settings->setAccelerated2dCanvasMSAASampleCount( |
| 984 | prefs.accelerated_2d_canvas_msaa_sample_count); |
| 985 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 986 | settings->setUnifiedTextCheckerEnabled(prefs.unified_textchecker_enabled); |
| 987 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 988 | // Tabs to link is not part of the settings. WebCore calls |
| 989 | // ChromeClient::tabsToLinks which is part of the glue code. |
| 990 | web_view->setTabsToLinks(prefs.tabs_to_links); |
| 991 | |
| 992 | settings->setAllowDisplayOfInsecureContent( |
| 993 | prefs.allow_displaying_insecure_content); |
| 994 | settings->setAllowRunningOfInsecureContent( |
| 995 | prefs.allow_running_insecure_content); |
mkwst | 772ce814 | 2015-01-16 13:28:07 | [diff] [blame] | 996 | settings->setDisableReadingFromCanvas(prefs.disable_reading_from_canvas); |
mkwst | 2fc2c4f | 2015-01-08 08:29:18 | [diff] [blame] | 997 | settings->setStrictMixedContentChecking(prefs.strict_mixed_content_checking); |
mkwst | 2384c822 | 2015-07-30 07:26:47 | [diff] [blame] | 998 | |
| 999 | settings->setStrictlyBlockBlockableMixedContent( |
| 1000 | prefs.strictly_block_blockable_mixed_content); |
| 1001 | |
mkwst | 0d233e5 | 2015-08-10 09:33:14 | [diff] [blame] | 1002 | settings->setStrictMixedContentCheckingForPlugin( |
| 1003 | prefs.block_mixed_plugin_content); |
| 1004 | |
mkwst | 673a452f | 2015-01-10 14:41:50 | [diff] [blame] | 1005 | settings->setStrictPowerfulFeatureRestrictions( |
| 1006 | prefs.strict_powerful_feature_restrictions); |
jww | 9d4ca2d | 2016-01-19 20:58:59 | [diff] [blame^] | 1007 | settings->setAllowGeolocationOnInsecureOrigins( |
| 1008 | prefs.allow_geolocation_on_insecure_origins); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1009 | settings->setPasswordEchoEnabled(prefs.password_echo_enabled); |
| 1010 | settings->setShouldPrintBackgrounds(prefs.should_print_backgrounds); |
| 1011 | settings->setShouldClearDocumentBackground( |
| 1012 | prefs.should_clear_document_background); |
| 1013 | settings->setEnableScrollAnimator(prefs.enable_scroll_animator); |
| 1014 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1015 | WebRuntimeFeatures::enableTouch(prefs.touch_enabled); |
| 1016 | settings->setMaxTouchPoints(prefs.pointer_events_max_touch_points); |
mustaq | 29eb709 | 2014-11-14 00:32:12 | [diff] [blame] | 1017 | settings->setAvailablePointerTypes(prefs.available_pointer_types); |
| 1018 | settings->setPrimaryPointerType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 1019 | static_cast<blink::PointerType>(prefs.primary_pointer_type)); |
mustaq | 29eb709 | 2014-11-14 00:32:12 | [diff] [blame] | 1020 | settings->setAvailableHoverTypes(prefs.available_hover_types); |
| 1021 | settings->setPrimaryHoverType( |
nzolghadr | c0d1663c | 2015-11-26 21:15:24 | [diff] [blame] | 1022 | static_cast<blink::HoverType>(prefs.primary_hover_type)); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1023 | settings->setDeviceSupportsTouch(prefs.device_supports_touch); |
| 1024 | settings->setDeviceSupportsMouse(prefs.device_supports_mouse); |
| 1025 | settings->setEnableTouchAdjustment(prefs.touch_adjustment_enabled); |
mustaq | 35bb250b | 2015-05-06 21:22:39 | [diff] [blame] | 1026 | settings->setMultiTargetTapNotificationEnabled( |
| 1027 | switches::IsLinkDisambiguationPopupEnabled()); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1028 | |
noel | f552c517 | 2014-11-05 22:53:21 | [diff] [blame] | 1029 | WebRuntimeFeatures::enableImageColorProfiles( |
| 1030 | prefs.image_color_profiles_enabled); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1031 | settings->setShouldRespectImageOrientation( |
| 1032 | prefs.should_respect_image_orientation); |
| 1033 | |
| 1034 | settings->setUnsafePluginPastingEnabled(false); |
| 1035 | settings->setEditingBehavior( |
| 1036 | static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior)); |
| 1037 | |
| 1038 | settings->setSupportsMultipleWindows(prefs.supports_multiple_windows); |
| 1039 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1040 | settings->setSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled); |
| 1041 | |
| 1042 | settings->setSpatialNavigationEnabled(prefs.spatial_navigation_enabled); |
| 1043 | |
| 1044 | settings->setSelectionIncludesAltImageText(true); |
| 1045 | |
[email protected] | 35103c0 | 2014-08-12 15:08:47 | [diff] [blame] | 1046 | settings->setV8CacheOptions( |
| 1047 | static_cast<WebSettings::V8CacheOptions>(prefs.v8_cache_options)); |
| 1048 | |
je_julie.kim | 7fbb5a1a | 2015-02-09 17:26:05 | [diff] [blame] | 1049 | settings->setImageAnimationPolicy( |
| 1050 | static_cast<WebSettings::ImageAnimationPolicy>(prefs.animation_policy)); |
| 1051 | |
dcheng | 5ae8ca36 | 2015-02-05 04:03:47 | [diff] [blame] | 1052 | // Needs to happen before setIgnoreVIewportTagScaleLimits below. |
| 1053 | web_view->setDefaultPageScaleLimits( |
| 1054 | prefs.default_minimum_page_scale_factor, |
| 1055 | prefs.default_maximum_page_scale_factor); |
| 1056 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1057 | #if defined(OS_ANDROID) |
| 1058 | settings->setAllowCustomScrollbarInMainFrame(false); |
| 1059 | settings->setTextAutosizingEnabled(prefs.text_autosizing_enabled); |
| 1060 | settings->setAccessibilityFontScaleFactor(prefs.font_scale_factor); |
| 1061 | settings->setDeviceScaleAdjustment(prefs.device_scale_adjustment); |
[email protected] | 023fed31 | 2014-08-11 16:13:05 | [diff] [blame] | 1062 | settings->setFullscreenSupported(prefs.fullscreen_supported); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1063 | web_view->setIgnoreViewportTagScaleLimits(prefs.force_enable_zoom); |
| 1064 | settings->setAutoZoomFocusedNodeToLegibleScale(true); |
| 1065 | settings->setDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled); |
| 1066 | settings->setMediaControlsOverlayPlayButtonEnabled(true); |
| 1067 | settings->setMediaPlaybackRequiresUserGesture( |
| 1068 | prefs.user_gesture_required_for_media_playback); |
| 1069 | settings->setDefaultVideoPosterURL( |
| 1070 | base::ASCIIToUTF16(prefs.default_video_poster_url.spec())); |
| 1071 | settings->setSupportDeprecatedTargetDensityDPI( |
| 1072 | prefs.support_deprecated_target_density_dpi); |
| 1073 | settings->setUseLegacyBackgroundSizeShorthandBehavior( |
| 1074 | prefs.use_legacy_background_size_shorthand_behavior); |
| 1075 | settings->setWideViewportQuirkEnabled(prefs.wide_viewport_quirk); |
| 1076 | settings->setUseWideViewport(prefs.use_wide_viewport); |
[email protected] | 9954ea9 | 2014-08-12 15:48:45 | [diff] [blame] | 1077 | settings->setForceZeroLayoutHeight(prefs.force_zero_layout_height); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1078 | settings->setViewportMetaLayoutSizeQuirk( |
| 1079 | prefs.viewport_meta_layout_size_quirk); |
| 1080 | settings->setViewportMetaMergeContentQuirk( |
| 1081 | prefs.viewport_meta_merge_content_quirk); |
| 1082 | settings->setViewportMetaNonUserScalableQuirk( |
| 1083 | prefs.viewport_meta_non_user_scalable_quirk); |
| 1084 | settings->setViewportMetaZeroValuesQuirk( |
| 1085 | prefs.viewport_meta_zero_values_quirk); |
| 1086 | settings->setClobberUserAgentInitialScaleQuirk( |
| 1087 | prefs.clobber_user_agent_initial_scale_quirk); |
| 1088 | settings->setIgnoreMainFrameOverflowHiddenQuirk( |
| 1089 | prefs.ignore_main_frame_overflow_hidden_quirk); |
| 1090 | settings->setReportScreenSizeInPhysicalPixelsQuirk( |
| 1091 | prefs.report_screen_size_in_physical_pixels_quirk); |
liberato | 2f1a7e0 | 2015-08-10 16:01:41 | [diff] [blame] | 1092 | settings->setPreferHiddenVolumeControls(true); |
boliu | 15ca265 | 2015-09-04 23:33:40 | [diff] [blame] | 1093 | settings->setMainFrameClipsContent(!prefs.record_whole_document); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1094 | settings->setShrinksViewportContentToFit(true); |
rune | d1677fd | 2015-03-12 09:01:53 | [diff] [blame] | 1095 | settings->setUseMobileViewportStyle(true); |
liberato | 6524fa4 | 2015-09-14 23:26:08 | [diff] [blame] | 1096 | settings->setAutoplayExperimentMode( |
| 1097 | blink::WebString::fromUTF8(prefs.autoplay_experiment_mode)); |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1098 | #endif |
| 1099 | |
yoav | a1a508b4 | 2015-10-20 12:03:21 | [diff] [blame] | 1100 | settings->setViewportEnabled(prefs.viewport_enabled); |
| 1101 | settings->setLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale); |
| 1102 | settings->setViewportMetaEnabled(prefs.viewport_meta_enabled); |
| 1103 | settings->setMainFrameResizesAreOrientationChanges( |
| 1104 | prefs.main_frame_resizes_are_orientation_changes); |
| 1105 | |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1106 | settings->setPinchOverlayScrollbarThickness( |
| 1107 | prefs.pinch_overlay_scrollbar_thickness); |
| 1108 | settings->setUseSolidColorScrollbars(prefs.use_solid_color_scrollbars); |
jinho.bang | 8f11ffa | 2014-12-04 06:03:03 | [diff] [blame] | 1109 | |
arjanl | 9880491 | 2015-03-04 09:23:04 | [diff] [blame] | 1110 | settings->setShowContextMenuOnMouseUp(prefs.context_menu_on_mouse_up); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1111 | |
| 1112 | #if defined(OS_MACOSX) |
| 1113 | settings->setDoubleTapToZoomEnabled(true); |
ccameron | f29a780 | 2015-02-20 22:11:25 | [diff] [blame] | 1114 | web_view->setMaximumLegibleScale(prefs.default_maximum_page_scale_factor); |
ccameron | 2fd70de7 | 2015-02-19 00:40:40 | [diff] [blame] | 1115 | #endif |
[email protected] | b3a97b5 | 2014-07-09 06:25:05 | [diff] [blame] | 1116 | } |
| 1117 | |
| 1118 | /*static*/ |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1119 | RenderViewImpl* RenderViewImpl::Create(CompositorDependencies* compositor_deps, |
| 1120 | const ViewMsg_New_Params& params, |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 1121 | bool was_created_by_renderer) { |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1122 | DCHECK(params.view_id != MSG_ROUTING_NONE); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1123 | RenderViewImpl* render_view = NULL; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1124 | if (g_create_render_view_impl) |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1125 | render_view = g_create_render_view_impl(compositor_deps, params); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1126 | else |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1127 | render_view = new RenderViewImpl(compositor_deps, params); |
[email protected] | 0287e76 | 2014-04-11 13:07:58 | [diff] [blame] | 1128 | |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1129 | render_view->Initialize(params, was_created_by_renderer); |
[email protected] | 07536691 | 2013-02-18 07:13:24 | [diff] [blame] | 1130 | return render_view; |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1131 | } |
| 1132 | |
| 1133 | // static |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1134 | void RenderViewImpl::InstallCreateHook(RenderViewImpl* ( |
| 1135 | *create_render_view_impl)(CompositorDependencies* compositor_deps, |
| 1136 | const ViewMsg_New_Params&)) { |
[email protected] | 8d41d761 | 2012-11-14 20:32:19 | [diff] [blame] | 1137 | CHECK(!g_create_render_view_impl); |
| 1138 | g_create_render_view_impl = create_render_view_impl; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1139 | } |
| 1140 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1141 | void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1142 | observers_.AddObserver(observer); |
| 1143 | } |
| 1144 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1145 | void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 1146 | observer->RenderViewGone(); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1147 | observers_.RemoveObserver(observer); |
| 1148 | } |
| 1149 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1150 | blink::WebView* RenderViewImpl::webview() const { |
| 1151 | return static_cast<blink::WebView*>(webwidget()); |
[email protected] | 4d51d5bf | 2010-07-26 18:48:26 | [diff] [blame] | 1152 | } |
| 1153 | |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 1154 | #if defined(ENABLE_PLUGINS) |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 1155 | void RenderViewImpl::PepperInstanceCreated( |
| 1156 | PepperPluginInstanceImpl* instance) { |
| 1157 | active_pepper_instances_.insert(instance); |
emaxx | e70f5e1 | 2015-05-29 11:26:00 | [diff] [blame] | 1158 | |
| 1159 | RenderFrameImpl* const render_frame = instance->render_frame(); |
| 1160 | render_frame->Send( |
| 1161 | new FrameHostMsg_PepperInstanceCreated(render_frame->GetRoutingID())); |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 1162 | } |
| 1163 | |
| 1164 | void RenderViewImpl::PepperInstanceDeleted( |
| 1165 | PepperPluginInstanceImpl* instance) { |
| 1166 | active_pepper_instances_.erase(instance); |
| 1167 | |
| 1168 | if (pepper_last_mouse_event_target_ == instance) |
| 1169 | pepper_last_mouse_event_target_ = NULL; |
| 1170 | if (focused_pepper_plugin_ == instance) |
| 1171 | PepperFocusChanged(instance, false); |
emaxx | e70f5e1 | 2015-05-29 11:26:00 | [diff] [blame] | 1172 | |
| 1173 | RenderFrameImpl* const render_frame = instance->render_frame(); |
| 1174 | if (render_frame) |
| 1175 | render_frame->Send( |
| 1176 | new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID())); |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 1177 | } |
| 1178 | |
| 1179 | void RenderViewImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, |
| 1180 | bool focused) { |
| 1181 | if (focused) |
| 1182 | focused_pepper_plugin_ = instance; |
| 1183 | else if (focused_pepper_plugin_ == instance) |
| 1184 | focused_pepper_plugin_ = NULL; |
| 1185 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1186 | UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME); |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 1187 | UpdateSelectionBounds(); |
| 1188 | } |
| 1189 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1190 | void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 1191 | plugin_delegates_.insert(delegate); |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 1192 | // If the renderer is visible, set initial visibility and focus state. |
| 1193 | if (!is_hidden()) { |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 1194 | #if defined(OS_MACOSX) |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 1195 | delegate->SetContainerVisibility(true); |
| 1196 | if (webview() && webview()->isActive()) |
| 1197 | delegate->SetWindowFocus(true); |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 1198 | #endif |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 1199 | } |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 1200 | // Plugins start assuming the content has focus (so that they work in |
| 1201 | // environments where RenderView isn't hosting them), so we always have to |
| 1202 | // set the initial state. See webplugin_delegate_impl.h for details. |
| 1203 | delegate->SetContentAreaFocus(has_focus()); |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 1204 | } |
| 1205 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1206 | void RenderViewImpl::UnregisterPluginDelegate( |
| 1207 | WebPluginDelegateProxy* delegate) { |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 1208 | plugin_delegates_.erase(delegate); |
| 1209 | } |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 1210 | |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 1211 | #if defined(OS_WIN) |
| 1212 | void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
| 1213 | if (focused) |
| 1214 | focused_plugin_id_ = plugin_id; |
| 1215 | else |
| 1216 | focused_plugin_id_ = -1; |
| 1217 | } |
| 1218 | #endif |
| 1219 | |
| 1220 | #if defined(OS_MACOSX) |
| 1221 | void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
| 1222 | Send(new ViewHostMsg_PluginFocusChanged(routing_id(), focused, plugin_id)); |
| 1223 | } |
| 1224 | |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1225 | void RenderViewImpl::OnGetRenderedText() { |
| 1226 | if (!webview()) |
| 1227 | return; |
| 1228 | // Get rendered text from WebLocalFrame. |
| 1229 | // TODO: Currently IPC truncates any data that has a |
| 1230 | // size > kMaximumMessageSize. May be split the text into smaller chunks and |
| 1231 | // send back using multiple IPC. See http://crbug.com/393444. |
| 1232 | static const size_t kMaximumMessageSize = 8 * 1024 * 1024; |
| 1233 | std::string text = webview()->mainFrame()->contentAsText( |
| 1234 | kMaximumMessageSize).utf8(); |
| 1235 | |
| 1236 | Send(new ViewMsg_GetRenderedTextCompleted(routing_id(), text)); |
| 1237 | } |
| 1238 | |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 1239 | void RenderViewImpl::StartPluginIme() { |
| 1240 | IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); |
| 1241 | // This message can be sent during event-handling, and needs to be delivered |
| 1242 | // within that context. |
| 1243 | msg->set_unblock(true); |
| 1244 | Send(msg); |
| 1245 | } |
| 1246 | #endif // defined(OS_MACOSX) |
| 1247 | |
| 1248 | #endif // ENABLE_PLUGINS |
| 1249 | |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 1250 | void RenderViewImpl::TransferActiveWheelFlingAnimation( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1251 | const blink::WebActiveWheelFlingParameters& params) { |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 1252 | if (webview()) |
| 1253 | webview()->transferActiveWheelFlingAnimation(params); |
| 1254 | } |
| 1255 | |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1256 | // RenderWidgetInputHandlerDelegate ----------------------------------------- |
| 1257 | |
| 1258 | void RenderViewImpl::FocusChangeComplete() { |
| 1259 | RenderWidget::FocusChangeComplete(); |
| 1260 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete()); |
| 1261 | } |
| 1262 | |
| 1263 | bool RenderViewImpl::HasTouchEventHandlersAt(const gfx::Point& point) const { |
| 1264 | if (!webview()) |
| 1265 | return false; |
| 1266 | return webview()->hasTouchEventHandlersAt(point); |
| 1267 | } |
| 1268 | |
| 1269 | void RenderViewImpl::OnDidHandleKeyEvent() { |
| 1270 | ClearEditCommands(); |
| 1271 | } |
| 1272 | |
| 1273 | bool RenderViewImpl::WillHandleGestureEvent( |
| 1274 | const blink::WebGestureEvent& event) { |
| 1275 | possible_drag_event_info_.event_source = |
| 1276 | ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH; |
| 1277 | possible_drag_event_info_.event_location = |
| 1278 | gfx::Point(event.globalX, event.globalY); |
| 1279 | return false; |
| 1280 | } |
| 1281 | |
| 1282 | bool RenderViewImpl::WillHandleMouseEvent(const blink::WebMouseEvent& event) { |
| 1283 | possible_drag_event_info_.event_source = |
| 1284 | ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE; |
| 1285 | possible_drag_event_info_.event_location = |
| 1286 | gfx::Point(event.globalX, event.globalY); |
| 1287 | |
| 1288 | #if defined(ENABLE_PLUGINS) |
| 1289 | // This method is called for every mouse event that the render view receives. |
| 1290 | // And then the mouse event is forwarded to WebKit, which dispatches it to the |
| 1291 | // event target. Potentially a Pepper plugin will receive the event. |
| 1292 | // In order to tell whether a plugin gets the last mouse event and which it |
| 1293 | // is, we set |pepper_last_mouse_event_target_| to NULL here. If a plugin gets |
| 1294 | // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 1295 | // |pepper_last_mouse_event_target_|. |
| 1296 | pepper_last_mouse_event_target_ = NULL; |
| 1297 | #endif |
| 1298 | |
| 1299 | // If the mouse is locked, only the current owner of the mouse lock can |
| 1300 | // process mouse events. |
| 1301 | return mouse_lock_dispatcher_->WillHandleMouseEvent(event); |
| 1302 | } |
| 1303 | |
| 1304 | // IPC::Listener implementation ---------------------------------------------- |
| 1305 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1306 | bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1307 | WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 1308 | if (main_frame && main_frame->isWebLocalFrame()) |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1309 | GetContentClient()->SetActiveURL(main_frame->document().url()); |
[email protected] | f8b6b6f | 2009-03-10 16:48:26 | [diff] [blame] | 1310 | |
nasko | c6edf7e | 2015-10-16 01:48:45 | [diff] [blame] | 1311 | // Input IPC messages must not be processed if the RenderView is in |
| 1312 | // swapped out state. |
| 1313 | if (is_swapped_out_ && IPC_MESSAGE_ID_CLASS(message.type()) == InputMsgStart) |
| 1314 | return false; |
| 1315 | |
brettw | 5a1613dc | 2015-06-02 05:34:43 | [diff] [blame] | 1316 | base::ObserverListBase<RenderViewObserver>::Iterator it(&observers_); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1317 | RenderViewObserver* observer; |
| 1318 | while ((observer = it.GetNext()) != NULL) |
| 1319 | if (observer->OnMessageReceived(message)) |
| 1320 | return true; |
[email protected] | b2abac7 | 2009-02-26 12:39:28 | [diff] [blame] | 1321 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1322 | bool handled = true; |
[email protected] | e44d134 | 2014-05-16 21:29:33 | [diff] [blame] | 1323 | IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1324 | IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand) |
| 1325 | IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1326 | IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect, |
| 1327 | OnScrollFocusedEditableNodeIntoRect) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1328 | IPC_MESSAGE_HANDLER(InputMsg_SetEditCommandsForNextKeyEvent, |
| 1329 | OnSetEditCommandsForNextKeyEvent) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1330 | IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
[email protected] | 6a6fa3e | 2014-05-09 06:57:18 | [diff] [blame] | 1331 | IPC_MESSAGE_HANDLER(ViewMsg_SaveImageAt, OnSaveImageAt) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1332 | IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 1333 | IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 1334 | IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale) |
[email protected] | 630e26b | 2008-10-14 22:55:17 | [diff] [blame] | 1335 | IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 1336 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 1337 | OnSetZoomLevelForLoadingURL) |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 1338 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForView, |
| 1339 | OnSetZoomLevelForView) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1340 | IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
[email protected] | a697f4c | 2009-09-14 22:30:18 | [diff] [blame] | 1341 | IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 1342 | OnResetPageEncodingToDefault) |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 1343 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 1344 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 1345 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 1346 | IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
[email protected] | 7a6d773f | 2014-04-04 01:25:09 | [diff] [blame] | 1347 | IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded) |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 1348 | IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
| 1349 | OnDragSourceSystemDragEnded) |
[email protected] | 18cb257 | 2008-08-21 20:34:45 | [diff] [blame] | 1350 | IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1351 | IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1352 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 1353 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 1354 | IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 1355 | OnEnumerateDirectoryResponse) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1356 | IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
[email protected] | 88f10a2 | 2013-11-06 21:22:12 | [diff] [blame] | 1357 | IPC_MESSAGE_HANDLER(ViewMsg_SuppressDialogsUntilSwapOut, |
| 1358 | OnSuppressDialogsUntilSwapOut) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1359 | IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 1360 | IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 1361 | IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
[email protected] | ab6c911 | 2014-02-27 00:20:58 | [diff] [blame] | 1362 | IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement) |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 1363 | IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque) |
[email protected] | ab32b16c | 2009-10-16 14:57:25 | [diff] [blame] | 1364 | IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1365 | OnEnablePreferredSizeChangedMode) |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 1366 | IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 1367 | IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 1368 | IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 1369 | OnDisableScrollbarsForSmallWindows) |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1370 | IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 1371 | IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1372 | IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 1373 | IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
[email protected] | 4782226 | 2013-04-23 17:22:36 | [diff] [blame] | 1374 | IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu) |
[email protected] | f055793 | 2011-01-25 20:20:51 | [diff] [blame] | 1375 | // TODO(viettrungluu): Move to a separate message filter. |
avi | 2b17759 | 2014-12-10 02:08:02 | [diff] [blame] | 1376 | IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryOffsetAndLength, |
| 1377 | OnSetHistoryOffsetAndLength) |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 1378 | IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 1379 | IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, |
| 1380 | OnReleaseDisambiguationPopupBitmap) |
[email protected] | 506563d | 2014-06-23 12:22:41 | [diff] [blame] | 1381 | IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1382 | IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1383 | #if defined(OS_ANDROID) |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1384 | IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1385 | OnActivateNearestFindResult) |
| 1386 | IPC_MESSAGE_HANDLER(ViewMsg_FindMatchRects, OnFindMatchRects) |
[email protected] | 452b4a9 | 2013-03-28 21:24:38 | [diff] [blame] | 1387 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState, |
| 1388 | OnUpdateTopControlsState) |
[email protected] | c4790dcb | 2013-12-27 22:08:02 | [diff] [blame] | 1389 | IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1390 | #elif defined(OS_MACOSX) |
[email protected] | 7411a3c | 2014-08-15 05:20:19 | [diff] [blame] | 1391 | IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText, |
| 1392 | OnGetRenderedText) |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1393 | IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
| 1394 | OnPluginImeCompositionCompleted) |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 1395 | IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 1396 | IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 1397 | IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) |
| 1398 | IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
| 1399 | #endif |
[email protected] | a794f3a | 2013-10-30 17:00:32 | [diff] [blame] | 1400 | // Adding a new message? Add platform independent ones first, then put the |
| 1401 | // platform specific ones at the end. |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1402 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1403 | // Have the super handle all other messages. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1404 | IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1405 | IPC_END_MESSAGE_MAP() |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 1406 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1407 | return handled; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1408 | } |
| 1409 | |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1410 | void RenderViewImpl::OnSelectWordAroundCaret() { |
| 1411 | if (!webview()) |
| 1412 | return; |
| 1413 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1414 | input_handler_->set_handling_input_event(true); |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1415 | webview()->focusedFrame()->selectWordAroundCaret(); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1416 | input_handler_->set_handling_input_event(false); |
[email protected] | 4dda6a6c | 2014-05-17 15:35:04 | [diff] [blame] | 1417 | } |
| 1418 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1419 | void RenderViewImpl::OnCopyImageAt(int x, int y) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1420 | webview()->copyImageAt(WebPoint(x, y)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1421 | } |
| 1422 | |
[email protected] | 6a6fa3e | 2014-05-09 06:57:18 | [diff] [blame] | 1423 | void RenderViewImpl::OnSaveImageAt(int x, int y) { |
| 1424 | webview()->saveImageAt(WebPoint(x, y)); |
| 1425 | } |
| 1426 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1427 | void RenderViewImpl::OnUpdateTargetURLAck() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1428 | // Check if there is a targeturl waiting to be sent. |
avi | 450ce00e | 2014-09-24 01:58:52 | [diff] [blame] | 1429 | if (target_url_status_ == TARGET_PENDING) |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1430 | Send(new ViewHostMsg_UpdateTargetURL(routing_id(), pending_target_url_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1431 | |
| 1432 | target_url_status_ = TARGET_NONE; |
| 1433 | } |
| 1434 | |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1435 | void RenderViewImpl::OnExecuteEditCommand(const std::string& name, |
| 1436 | const std::string& value) { |
| 1437 | if (!webview() || !webview()->focusedFrame()) |
| 1438 | return; |
| 1439 | |
| 1440 | webview()->focusedFrame()->executeCommand( |
| 1441 | WebString::fromUTF8(name), WebString::fromUTF8(value)); |
| 1442 | } |
| 1443 | |
| 1444 | void RenderViewImpl::OnMoveCaret(const gfx::Point& point) { |
| 1445 | if (!webview()) |
| 1446 | return; |
| 1447 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1448 | Send(new InputHostMsg_MoveCaret_ACK(routing_id())); |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1449 | |
[email protected] | b74d4064d | 2013-11-27 01:45:09 | [diff] [blame] | 1450 | webview()->focusedFrame()->moveCaretSelection(point); |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1451 | } |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1452 | |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1453 | void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1454 | const gfx::Rect& rect) { |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1455 | if (has_scrolled_focused_editable_node_into_rect_ && |
| 1456 | rect == rect_for_scrolled_focused_editable_node_) { |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 1457 | FocusChangeComplete(); |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1458 | return; |
| 1459 | } |
| 1460 | |
[email protected] | c39f744 | 2014-02-27 03:33:17 | [diff] [blame] | 1461 | blink::WebElement element = GetFocusedElement(); |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 1462 | bool will_animate = false; |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1463 | if (!element.isNull() && element.isEditable()) { |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1464 | rect_for_scrolled_focused_editable_node_ = rect; |
| 1465 | has_scrolled_focused_editable_node_into_rect_ = true; |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 1466 | will_animate = webview()->scrollFocusedNodeIntoRect(rect); |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1467 | } |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 1468 | |
| 1469 | if (!will_animate) |
| 1470 | FocusChangeComplete(); |
[email protected] | 25bcc8f | 2013-01-09 02:49:25 | [diff] [blame] | 1471 | } |
| 1472 | |
[email protected] | c084330e0 | 2013-04-27 01:08:15 | [diff] [blame] | 1473 | void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( |
| 1474 | const EditCommands& edit_commands) { |
| 1475 | edit_commands_ = edit_commands; |
| 1476 | } |
| 1477 | |
avi | 2b17759 | 2014-12-10 02:08:02 | [diff] [blame] | 1478 | void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset, |
| 1479 | int history_length) { |
| 1480 | DCHECK_GE(history_offset, -1); |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 1481 | DCHECK_GE(history_length, 0); |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1482 | |
avi | 2b17759 | 2014-12-10 02:08:02 | [diff] [blame] | 1483 | history_list_offset_ = history_offset; |
| 1484 | history_list_length_ = history_length; |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1485 | } |
| 1486 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1487 | void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1488 | if (!webview()) |
| 1489 | return; |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1490 | webview()->setInitialFocus(reverse); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1491 | } |
| 1492 | |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1493 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1494 | void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) { |
[email protected] | 4274b3e | 2011-08-09 19:09:33 | [diff] [blame] | 1495 | if (!webview()) |
| 1496 | return; |
| 1497 | if (in_live_resize) |
| 1498 | webview()->willStartLiveResize(); |
| 1499 | else |
| 1500 | webview()->willEndLiveResize(); |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1501 | } |
| 1502 | #endif |
| 1503 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1504 | /////////////////////////////////////////////////////////////////////////////// |
| 1505 | |
avi | 137dc95 | 2015-07-24 23:19:14 | [diff] [blame] | 1506 | void RenderViewImpl::SendUpdateState() { |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1507 | // We don't use this path in OOPIF-enabled modes. |
| 1508 | DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); |
creis | ae7ce9a | 2015-11-02 20:52:19 | [diff] [blame] | 1509 | |
avi | 137dc95 | 2015-07-24 23:19:14 | [diff] [blame] | 1510 | HistoryEntry* entry = history_controller_->GetCurrentEntry(); |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1511 | if (!entry) |
| 1512 | return; |
| 1513 | |
| 1514 | // Don't send state updates for kSwappedOutURL. |
esprehn | af92a8f9 | 2015-12-12 05:08:01 | [diff] [blame] | 1515 | if (entry->root().urlString() == kSwappedOutURL) |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1516 | return; |
| 1517 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1518 | Send(new ViewHostMsg_UpdateState(routing_id(), page_id_, |
| 1519 | HistoryEntryToPageState(entry))); |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1520 | } |
| 1521 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1522 | void RenderViewImpl::SendFrameStateUpdates() { |
| 1523 | // We only use this path in OOPIF-enabled modes. |
| 1524 | DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 1525 | |
| 1526 | // Tell each frame with pending state to send its UpdateState message. |
| 1527 | for (int render_frame_routing_id : frames_with_pending_state_) { |
| 1528 | RenderFrameImpl* frame = |
| 1529 | RenderFrameImpl::FromRoutingID(render_frame_routing_id); |
| 1530 | if (frame) |
| 1531 | frame->SendUpdateState(); |
| 1532 | } |
| 1533 | frames_with_pending_state_.clear(); |
| 1534 | } |
| 1535 | |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 1536 | void RenderViewImpl::ApplyWebPreferencesInternal( |
| 1537 | const WebPreferences& prefs, |
| 1538 | blink::WebView* web_view, |
| 1539 | CompositorDependencies* compositor_deps) { |
| 1540 | ApplyWebPreferences(prefs, web_view); |
| 1541 | #if defined(OS_MACOSX) && !defined(OS_IOS) |
| 1542 | DCHECK(compositor_deps); |
| 1543 | bool is_elastic_overscroll_enabled = |
| 1544 | compositor_deps->IsElasticOverscrollEnabled(); |
| 1545 | web_view->settings()->setReportWheelOverscroll(is_elastic_overscroll_enabled); |
| 1546 | #endif |
| 1547 | } |
| 1548 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1549 | bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1550 | // Before WebKit asks us to show an alert (etc.), it takes care of doing the |
| 1551 | // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog |
| 1552 | // it is particularly important that we do not call willEnterModalLoop as |
| 1553 | // that would defer resource loads for the dialog itself. |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 1554 | if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 1555 | RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1556 | |
| 1557 | message->EnableMessagePumping(); // Runs a nested message loop. |
| 1558 | return Send(message); |
| 1559 | } |
| 1560 | |
[email protected] | 506563d | 2014-06-23 12:22:41 | [diff] [blame] | 1561 | void RenderViewImpl::OnForceRedraw(int id) { |
| 1562 | ui::LatencyInfo latency_info; |
[email protected] | f9f3fac | 2014-08-05 00:47:59 | [diff] [blame] | 1563 | if (id) { |
| 1564 | latency_info.AddLatencyNumber(ui::WINDOW_SNAPSHOT_FRAME_NUMBER_COMPONENT, |
| 1565 | 0, |
| 1566 | id); |
| 1567 | } |
[email protected] | 6be422b | 2013-12-08 06:47:31 | [diff] [blame] | 1568 | scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor; |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 1569 | if (RenderWidgetCompositor* rwc = compositor()) { |
[email protected] | 6be422b | 2013-12-08 06:47:31 | [diff] [blame] | 1570 | latency_info_swap_promise_monitor = |
dcheng | 07945f63 | 2015-12-26 07:59:32 | [diff] [blame] | 1571 | rwc->CreateLatencyInfoSwapPromiseMonitor(&latency_info); |
[email protected] | 7d08a935 | 2013-10-15 08:24:56 | [diff] [blame] | 1572 | } |
| 1573 | ScheduleCompositeWithForcedRedraw(); |
[email protected] | c9bc8f1 | 2012-12-15 22:20:09 | [diff] [blame] | 1574 | } |
| 1575 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1576 | // blink::WebViewClient ------------------------------------------------------ |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1577 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 1578 | WebView* RenderViewImpl::createView(WebLocalFrame* creator, |
| 1579 | const WebURLRequest& request, |
| 1580 | const WebWindowFeatures& features, |
| 1581 | const WebString& frame_name, |
| 1582 | WebNavigationPolicy policy, |
| 1583 | bool suppress_opener) { |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1584 | ViewHostMsg_CreateWindow_Params params; |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1585 | params.opener_id = routing_id(); |
[email protected] | af15bf2 | 2013-03-08 01:18:17 | [diff] [blame] | 1586 | params.user_gesture = WebUserGestureIndicator::isProcessingUserGesture(); |
[email protected] | 00323f0 | 2013-07-24 15:47:41 | [diff] [blame] | 1587 | if (GetContentClient()->renderer()->AllowPopup()) |
| 1588 | params.user_gesture = true; |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1589 | params.window_container_type = WindowFeaturesToContainerType(features); |
| 1590 | params.session_storage_namespace_id = session_storage_namespace_id_; |
[email protected] | 5cef23d | 2013-02-27 13:11:21 | [diff] [blame] | 1591 | if (frame_name != "_blank") |
brettw | 717861b6 | 2015-07-24 19:09:09 | [diff] [blame] | 1592 | params.frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name)); |
[email protected] | a7531d77 | 2014-03-25 16:15:07 | [diff] [blame] | 1593 | params.opener_render_frame_id = |
[email protected] | 501052ff | 2014-02-21 22:19:07 | [diff] [blame] | 1594 | RenderFrameImpl::FromWebFrame(creator)->GetRoutingID(); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1595 | params.opener_url = creator->document().url(); |
alexmos | a97d5c5 | 2015-06-19 22:19:09 | [diff] [blame] | 1596 | |
| 1597 | // The browser process uses the top frame's URL for a content settings check |
| 1598 | // to determine whether the popup is allowed. If the top frame is remote, |
| 1599 | // its URL is not available, so use its replicated origin instead. |
| 1600 | // |
| 1601 | // TODO(alexmos): This works fine for regular origins but may break path |
| 1602 | // matching for file URLs with OOP subframes that open popups. This should |
| 1603 | // be fixed by either moving this lookup to the browser process or removing |
| 1604 | // path-based matching for file URLs from content settings. See |
| 1605 | // https://crbug.com/466297. |
| 1606 | if (creator->top()->isWebLocalFrame()) { |
| 1607 | params.opener_top_level_frame_url = creator->top()->document().url(); |
| 1608 | } else { |
| 1609 | params.opener_top_level_frame_url = |
| 1610 | GURL(creator->top()->securityOrigin().toString()); |
| 1611 | } |
| 1612 | |
[email protected] | 6c53a7f | 2014-03-31 16:56:28 | [diff] [blame] | 1613 | GURL security_url(creator->document().securityOrigin().toString()); |
[email protected] | 7f48b71 | 2013-01-25 01:48:30 | [diff] [blame] | 1614 | if (!security_url.is_valid()) |
| 1615 | security_url = GURL(); |
| 1616 | params.opener_security_origin = security_url; |
[email protected] | 147b2bf | 2013-11-05 04:00:04 | [diff] [blame] | 1617 | params.opener_suppressed = suppress_opener; |
[email protected] | f92ce2b | 2012-03-06 18:02:59 | [diff] [blame] | 1618 | params.disposition = NavigationPolicyToDisposition(policy); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 1619 | if (!request.isNull()) { |
[email protected] | 41e6550 | 2011-01-21 09:29:11 | [diff] [blame] | 1620 | params.target_url = request.url(); |
[email protected] | 44e55b01 | 2013-07-23 14:21:56 | [diff] [blame] | 1621 | params.referrer = GetReferrerFromRequest(creator, request); |
| 1622 | } |
[email protected] | 453c1b2 | 2013-07-23 09:31:48 | [diff] [blame] | 1623 | params.features = features; |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1624 | |
[email protected] | 22217ed3 | 2013-11-18 18:40:23 | [diff] [blame] | 1625 | for (size_t i = 0; i < features.additionalFeatures.size(); ++i) |
| 1626 | params.additional_features.push_back(features.additionalFeatures[i]); |
| 1627 | |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 1628 | ViewHostMsg_CreateWindow_Reply reply; |
| 1629 | RenderThread::Get()->Send(new ViewHostMsg_CreateWindow(params, &reply)); |
| 1630 | if (reply.route_id == MSG_ROUTING_NONE) |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1631 | return NULL; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1632 | |
[email protected] | af15bf2 | 2013-03-08 01:18:17 | [diff] [blame] | 1633 | WebUserGestureIndicator::consumeUserGesture(); |
[email protected] | c5926242 | 2012-11-30 21:20:52 | [diff] [blame] | 1634 | |
[email protected] | 7912e82 | 2014-04-16 02:37:03 | [diff] [blame] | 1635 | // While this view may be a background extension page, it can spawn a visible |
| 1636 | // render view. So we just assume that the new one is not another background |
| 1637 | // page instead of passing on our own value. |
| 1638 | // TODO(vangelis): Can we tell if the new view will be a background page? |
| 1639 | bool never_visible = false; |
[email protected] | 9115d5f | 2013-03-24 04:37:41 | [diff] [blame] | 1640 | |
mkosiba | 58fa72f0 | 2014-11-12 01:21:36 | [diff] [blame] | 1641 | ViewMsg_Resize_Params initial_size = ViewMsg_Resize_Params(); |
| 1642 | initial_size.screen_info = screen_info_; |
| 1643 | |
[email protected] | d6fa88f | 2013-10-18 16:00:43 | [diff] [blame] | 1644 | // The initial hidden state for the RenderViewImpl here has to match what the |
| 1645 | // browser will eventually decide for the given disposition. Since we have to |
| 1646 | // return from this call synchronously, we just have to make our best guess |
| 1647 | // and rely on the browser sending a WasHidden / WasShown message if it |
| 1648 | // disagrees. |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1649 | ViewMsg_New_Params view_params; |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1650 | |
| 1651 | RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator); |
| 1652 | view_params.opener_frame_route_id = creator_frame->GetRoutingID(); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1653 | DCHECK_EQ(routing_id(), creator_frame->render_view()->GetRoutingID()); |
alexmos | 5ac402d | 2015-07-09 07:51:10 | [diff] [blame] | 1654 | |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1655 | view_params.window_was_created_with_opener = true; |
| 1656 | view_params.renderer_preferences = renderer_preferences_; |
| 1657 | view_params.web_preferences = webkit_preferences_; |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 1658 | view_params.view_id = reply.route_id; |
| 1659 | view_params.main_frame_routing_id = reply.main_frame_route_id; |
| 1660 | view_params.main_frame_widget_routing_id = reply.main_frame_widget_route_id; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1661 | view_params.session_storage_namespace_id = |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 1662 | reply.cloned_session_storage_namespace_id; |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1663 | view_params.swapped_out = false; |
alexmos | 3448b55 | 2015-06-26 07:49:13 | [diff] [blame] | 1664 | // WebCore will take care of setting the correct name. |
alexmos | bc7eafa | 2014-12-06 01:38:09 | [diff] [blame] | 1665 | view_params.replicated_frame_state = FrameReplicationState(); |
nasko | bd91133 | 2014-11-25 01:13:36 | [diff] [blame] | 1666 | view_params.hidden = (params.disposition == NEW_BACKGROUND_TAB); |
| 1667 | view_params.never_visible = never_visible; |
| 1668 | view_params.next_page_id = 1; |
| 1669 | view_params.initial_size = initial_size; |
| 1670 | view_params.enable_auto_resize = false; |
| 1671 | view_params.min_size = gfx::Size(); |
| 1672 | view_params.max_size = gfx::Size(); |
| 1673 | |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 1674 | RenderViewImpl* view = |
dcheng | 35d31c11 | 2015-07-22 00:17:36 | [diff] [blame] | 1675 | RenderViewImpl::Create(compositor_deps_, view_params, true); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1676 | view->opened_by_user_gesture_ = params.user_gesture; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1677 | |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 1678 | // Record whether the creator frame is trying to suppress the opener field. |
[email protected] | f92ce2b | 2012-03-06 18:02:59 | [diff] [blame] | 1679 | view->opener_suppressed_ = params.opener_suppressed; |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 1680 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1681 | return view->webview(); |
| 1682 | } |
| 1683 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1684 | WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1685 | RenderWidget* widget = RenderWidget::Create(routing_id(), compositor_deps_, |
danakj | 6e3bf801 | 2014-12-16 18:27:53 | [diff] [blame] | 1686 | popup_type, screen_info_); |
[email protected] | 3b78ec1 | 2014-03-04 05:18:28 | [diff] [blame] | 1687 | if (!widget) |
| 1688 | return NULL; |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 1689 | if (screen_metrics_emulator_) { |
| 1690 | widget->SetPopupOriginAdjustmentsForEmulation( |
| 1691 | screen_metrics_emulator_.get()); |
| 1692 | } |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1693 | return widget->webwidget(); |
| 1694 | } |
| 1695 | |
[email protected] | 2336748 | 2013-06-27 21:06:54 | [diff] [blame] | 1696 | WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() { |
[email protected] | 5f2aa72 | 2013-08-07 16:59:41 | [diff] [blame] | 1697 | CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
[email protected] | 1910fe8 | 2012-05-10 00:04:10 | [diff] [blame] | 1698 | return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1699 | } |
| 1700 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 1701 | void RenderViewImpl::printPage(WebLocalFrame* frame) { |
[email protected] | b0553c7e | 2012-09-19 21:36:11 | [diff] [blame] | 1702 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
fsamuel | 72464894f | 2015-12-15 06:59:31 | [diff] [blame] | 1703 | PrintPage(frame, input_handler().handling_input_event())); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1704 | } |
| 1705 | |
jinho.bang | 632a1a72 | 2014-09-18 03:02:56 | [diff] [blame] | 1706 | void RenderViewImpl::saveImageFromDataURL(const blink::WebString& data_url) { |
| 1707 | // Note: We should basically send GURL but we use size-limited string instead |
| 1708 | // in order to send a larger data url to save a image for <canvas> or <img>. |
| 1709 | if (data_url.length() < kMaxLengthOfDataURLString) |
rdsmith | 6e60c08 | 2015-08-24 19:43:48 | [diff] [blame] | 1710 | Send(new ViewHostMsg_SaveImageFromDataURL( |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1711 | routing_id(), GetMainRenderFrame()->GetRoutingID(), data_url.utf8())); |
jinho.bang | 632a1a72 | 2014-09-18 03:02:56 | [diff] [blame] | 1712 | } |
| 1713 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1714 | bool RenderViewImpl::enumerateChosenDirectory( |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1715 | const WebString& path, |
| 1716 | WebFileChooserCompletion* chooser_completion) { |
| 1717 | int id = enumeration_completion_id_++; |
| 1718 | enumeration_completions_[id] = chooser_completion; |
| 1719 | return Send(new ViewHostMsg_EnumerateDirectory( |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1720 | routing_id(), id, base::FilePath::FromUTF16Unsafe(path))); |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1721 | } |
| 1722 | |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1723 | void RenderViewImpl::FrameDidStartLoading(WebFrame* frame) { |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1724 | DCHECK_GE(frames_in_progress_, 0); |
| 1725 | if (frames_in_progress_ == 0) |
| 1726 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); |
| 1727 | frames_in_progress_++; |
[email protected] | 6dd5c32 | 2014-03-12 07:58:46 | [diff] [blame] | 1728 | } |
| 1729 | |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1730 | void RenderViewImpl::FrameDidStopLoading(WebFrame* frame) { |
[email protected] | eb47377 | 2014-04-11 20:54:33 | [diff] [blame] | 1731 | // TODO(japhet): This should be a DCHECK, but the pdf plugin sometimes |
| 1732 | // calls DidStopLoading() without a matching DidStartLoading(). |
| 1733 | if (frames_in_progress_ == 0) |
| 1734 | return; |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1735 | frames_in_progress_--; |
[email protected] | 7e9523b | 2014-03-25 03:02:42 | [diff] [blame] | 1736 | if (frames_in_progress_ == 0) { |
| 1737 | DidStopLoadingIcons(); |
| 1738 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
| 1739 | } |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1740 | } |
| 1741 | |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 1742 | void RenderViewImpl::AttachWebFrameWidget(blink::WebWidget* frame_widget) { |
| 1743 | // The previous WebFrameWidget must already be detached by CloseForFrame(). |
| 1744 | DCHECK(!frame_widget_); |
| 1745 | frame_widget_ = frame_widget; |
| 1746 | } |
| 1747 | |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 1748 | void RenderViewImpl::SetZoomLevel(double zoom_level) { |
| 1749 | webview()->setZoomLevel(zoom_level); |
| 1750 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged()); |
| 1751 | } |
| 1752 | |
[email protected] | 550b0c9 | 2013-02-04 05:09:15 | [diff] [blame] | 1753 | void RenderViewImpl::didCancelCompositionOnSelectionChange() { |
[email protected] | a2214eb | 2014-06-23 18:31:22 | [diff] [blame] | 1754 | Send(new InputHostMsg_ImeCancelComposition(routing_id())); |
[email protected] | 550b0c9 | 2013-02-04 05:09:15 | [diff] [blame] | 1755 | } |
| 1756 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1757 | bool RenderViewImpl::handleCurrentKeyboardEvent() { |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1758 | if (edit_commands_.empty()) |
| 1759 | return false; |
| 1760 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1761 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1762 | if (!frame) |
| 1763 | return false; |
| 1764 | |
| 1765 | EditCommands::iterator it = edit_commands_.begin(); |
| 1766 | EditCommands::iterator end = edit_commands_.end(); |
| 1767 | |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1768 | bool did_execute_command = false; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1769 | for (; it != end; ++it) { |
[email protected] | e6e1501 | 2009-09-30 14:59:33 | [diff] [blame] | 1770 | // In gtk and cocoa, it's possible to bind multiple edit commands to one |
| 1771 | // key (but it's the exception). Once one edit command is not executed, it |
| 1772 | // seems safest to not execute the rest. |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1773 | if (!frame->executeCommand(WebString::fromUTF8(it->name), |
[email protected] | b77fac5 | 2013-06-01 01:03:46 | [diff] [blame] | 1774 | WebString::fromUTF8(it->value), |
[email protected] | c39f744 | 2014-02-27 03:33:17 | [diff] [blame] | 1775 | GetFocusedElement())) |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1776 | break; |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1777 | did_execute_command = true; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1778 | } |
| 1779 | |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1780 | return did_execute_command; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1781 | } |
| 1782 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1783 | bool RenderViewImpl::runFileChooser( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 1784 | const blink::WebFileChooserParams& params, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1785 | WebFileChooserCompletion* chooser_completion) { |
[email protected] | 7ef03e0 | 2010-10-23 11:58:35 | [diff] [blame] | 1786 | // Do not open the file dialog in a hidden RenderView. |
| 1787 | if (is_hidden()) |
| 1788 | return false; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1789 | FileChooserParams ipc_params; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1790 | if (params.directory) |
[email protected] | 6bedbef | 2013-07-31 06:33:49 | [diff] [blame] | 1791 | ipc_params.mode = FileChooserParams::UploadFolder; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1792 | else if (params.multiSelect) |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1793 | ipc_params.mode = FileChooserParams::OpenMultiple; |
[email protected] | 459fba8 | 2011-10-13 02:48:50 | [diff] [blame] | 1794 | else if (params.saveAs) |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1795 | ipc_params.mode = FileChooserParams::Save; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1796 | else |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 1797 | ipc_params.mode = FileChooserParams::Open; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1798 | ipc_params.title = params.title; |
| 1799 | ipc_params.default_file_name = |
wfh | 815c487 | 2015-02-25 21:01:31 | [diff] [blame] | 1800 | base::FilePath::FromUTF16Unsafe(params.initialValue).BaseName(); |
[email protected] | f9a4c41a | 2012-05-30 00:05:32 | [diff] [blame] | 1801 | ipc_params.accept_types.reserve(params.acceptTypes.size()); |
| 1802 | for (size_t i = 0; i < params.acceptTypes.size(); ++i) |
| 1803 | ipc_params.accept_types.push_back(params.acceptTypes[i]); |
hirono | e9f2732b | 2014-10-22 08:06:41 | [diff] [blame] | 1804 | ipc_params.need_local_path = params.needLocalPath; |
[email protected] | 2fdf235 | 2012-11-01 19:23:02 | [diff] [blame] | 1805 | #if defined(OS_ANDROID) |
[email protected] | b7b4beb | 2013-07-09 14:06:50 | [diff] [blame] | 1806 | ipc_params.capture = params.useMediaCapture; |
[email protected] | 2fdf235 | 2012-11-01 19:23:02 | [diff] [blame] | 1807 | #endif |
asanka | 1cbf4981 | 2015-11-03 18:28:15 | [diff] [blame] | 1808 | ipc_params.requestor = params.requestor; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1809 | |
| 1810 | return ScheduleFileChooser(ipc_params, chooser_completion); |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 1811 | } |
| 1812 | |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1813 | void RenderViewImpl::SetValidationMessageDirection( |
| 1814 | base::string16* wrapped_main_text, |
| 1815 | blink::WebTextDirection main_text_hint, |
| 1816 | base::string16* wrapped_sub_text, |
| 1817 | blink::WebTextDirection sub_text_hint) { |
| 1818 | if (main_text_hint == blink::WebTextDirectionLeftToRight) { |
| 1819 | *wrapped_main_text = |
| 1820 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text); |
| 1821 | } else if (main_text_hint == blink::WebTextDirectionRightToLeft && |
| 1822 | !base::i18n::IsRTL()) { |
| 1823 | base::i18n::WrapStringWithRTLFormatting(wrapped_main_text); |
| 1824 | } |
| 1825 | |
| 1826 | if (!wrapped_sub_text->empty()) { |
| 1827 | if (sub_text_hint == blink::WebTextDirectionLeftToRight) { |
| 1828 | *wrapped_sub_text = |
| 1829 | base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_sub_text); |
| 1830 | } else if (sub_text_hint == blink::WebTextDirectionRightToLeft) { |
| 1831 | base::i18n::WrapStringWithRTLFormatting(wrapped_sub_text); |
| 1832 | } |
| 1833 | } |
| 1834 | } |
| 1835 | |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1836 | void RenderViewImpl::showValidationMessage( |
bokan | 72a7e34 | 2015-12-03 15:46:28 | [diff] [blame] | 1837 | const blink::WebRect& anchor_in_viewport, |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1838 | const blink::WebString& main_text, |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1839 | blink::WebTextDirection main_text_hint, |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1840 | const blink::WebString& sub_text, |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1841 | blink::WebTextDirection sub_text_hint) { |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1842 | base::string16 wrapped_main_text = main_text; |
| 1843 | base::string16 wrapped_sub_text = sub_text; |
habib.virji | 597255e | 2014-09-09 00:30:18 | [diff] [blame] | 1844 | |
| 1845 | SetValidationMessageDirection( |
| 1846 | &wrapped_main_text, main_text_hint, &wrapped_sub_text, sub_text_hint); |
| 1847 | |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1848 | Send(new ViewHostMsg_ShowValidationMessage( |
bokan | 72a7e34 | 2015-12-03 15:46:28 | [diff] [blame] | 1849 | routing_id(), AdjustValidationMessageAnchor(anchor_in_viewport), |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 1850 | wrapped_main_text, wrapped_sub_text)); |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1851 | } |
| 1852 | |
| 1853 | void RenderViewImpl::hideValidationMessage() { |
| 1854 | Send(new ViewHostMsg_HideValidationMessage(routing_id())); |
| 1855 | } |
| 1856 | |
| 1857 | void RenderViewImpl::moveValidationMessage( |
bokan | 72a7e34 | 2015-12-03 15:46:28 | [diff] [blame] | 1858 | const blink::WebRect& anchor_in_viewport) { |
[email protected] | 2d6836f4 | 2014-07-02 17:25:31 | [diff] [blame] | 1859 | Send(new ViewHostMsg_MoveValidationMessage( |
bokan | 72a7e34 | 2015-12-03 15:46:28 | [diff] [blame] | 1860 | routing_id(), AdjustValidationMessageAnchor(anchor_in_viewport))); |
[email protected] | edc3af8 | 2013-12-12 21:24:07 | [diff] [blame] | 1861 | } |
| 1862 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1863 | void RenderViewImpl::setStatusText(const WebString& text) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1864 | } |
| 1865 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1866 | void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 1867 | const GURL& fallback_url) { |
[email protected] | aa6b90b3 | 2010-04-26 15:49:58 | [diff] [blame] | 1868 | GURL latest_url = url.is_empty() ? fallback_url : url; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1869 | if (latest_url == target_url_) |
| 1870 | return; |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1871 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1872 | // Tell the browser to display a destination link. |
| 1873 | if (target_url_status_ == TARGET_INFLIGHT || |
| 1874 | target_url_status_ == TARGET_PENDING) { |
| 1875 | // If we have a request in-flight, save the URL to be sent when we |
| 1876 | // receive an ACK to the in-flight request. We can happily overwrite |
| 1877 | // any existing pending sends. |
| 1878 | pending_target_url_ = latest_url; |
| 1879 | target_url_status_ = TARGET_PENDING; |
| 1880 | } else { |
mnaganov | bf08742 | 2015-12-16 05:10:03 | [diff] [blame] | 1881 | // URLs larger than |kMaxURLChars| cannot be sent through IPC - |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1882 | // see |ParamTraits<GURL>|. |
mnaganov | bf08742 | 2015-12-16 05:10:03 | [diff] [blame] | 1883 | if (latest_url.possibly_invalid_spec().size() > kMaxURLChars) |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1884 | latest_url = GURL(); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1885 | Send(new ViewHostMsg_UpdateTargetURL(routing_id(), latest_url)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1886 | target_url_ = latest_url; |
| 1887 | target_url_status_ = TARGET_INFLIGHT; |
| 1888 | } |
| 1889 | } |
| 1890 | |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 1891 | gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect( |
| 1892 | const gfx::RectF& rect) const { |
| 1893 | gfx::RectF window_rect = rect; |
| 1894 | window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor()); |
| 1895 | return window_rect; |
| 1896 | } |
| 1897 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1898 | void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) { |
| 1899 | // In OOPIF modes, keep track of which frames have pending updates. |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1900 | if (SiteIsolationPolicy::UseSubframeNavigationEntries()) |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1901 | frames_with_pending_state_.insert(frame->GetRoutingID()); |
creis | 8eb8ef2 | 2015-11-04 22:51:38 | [diff] [blame] | 1902 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1903 | int delay; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1904 | if (send_content_state_immediately_) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1905 | delay = 0; |
| 1906 | else if (is_hidden()) |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1907 | delay = kDelaySecondsForContentStateSyncHidden; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1908 | else |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1909 | delay = kDelaySecondsForContentStateSync; |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1910 | |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1911 | if (nav_state_sync_timer_.IsRunning()) { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1912 | // The timer is already running. If the delay of the timer maches the amount |
| 1913 | // we want to delay by, then return. Otherwise stop the timer so that it |
| 1914 | // gets started with the right delay. |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1915 | if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1916 | return; |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 1917 | nav_state_sync_timer_.Stop(); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1918 | } |
| 1919 | |
creis | 69b184a47 | 2015-11-26 05:29:51 | [diff] [blame] | 1920 | if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { |
| 1921 | // In OOPIF modes, tell each frame with pending state to inform the browser. |
| 1922 | nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
| 1923 | &RenderViewImpl::SendFrameStateUpdates); |
| 1924 | } else { |
| 1925 | // By default, send an UpdateState for the current history item. |
| 1926 | nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
| 1927 | &RenderViewImpl::SendUpdateState); |
| 1928 | } |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1929 | } |
| 1930 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1931 | void RenderViewImpl::setMouseOverURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1932 | mouse_over_url_ = GURL(url); |
| 1933 | UpdateTargetURL(mouse_over_url_, focus_url_); |
| 1934 | } |
| 1935 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1936 | void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1937 | focus_url_ = GURL(url); |
| 1938 | UpdateTargetURL(focus_url_, mouse_over_url_); |
| 1939 | } |
| 1940 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 1941 | void RenderViewImpl::startDragging(WebLocalFrame* frame, |
[email protected] | 0407e42 | 2012-05-18 19:51:25 | [diff] [blame] | 1942 | const WebDragData& data, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1943 | WebDragOperationsMask mask, |
| 1944 | const WebImage& image, |
[email protected] | ceb36f7d | 2012-10-31 18:33:24 | [diff] [blame] | 1945 | const WebPoint& webImageOffset) { |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 1946 | DropData drop_data(DropDataBuilder::Build(data)); |
[email protected] | b67151d | 2012-05-25 23:23:24 | [diff] [blame] | 1947 | drop_data.referrer_policy = frame->document().referrerPolicy(); |
[email protected] | ceb36f7d | 2012-10-31 18:33:24 | [diff] [blame] | 1948 | gfx::Vector2d imageOffset(webImageOffset.x, webImageOffset.y); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1949 | Send(new DragHostMsg_StartDragging(routing_id(), drop_data, mask, |
| 1950 | image.getSkBitmap(), imageOffset, |
[email protected] | 41d8685 | 2012-11-07 12:23:24 | [diff] [blame] | 1951 | possible_drag_event_info_)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1952 | } |
| 1953 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1954 | bool RenderViewImpl::acceptsLoadDrops() { |
[email protected] | 28b92df | 2009-09-25 17:35:45 | [diff] [blame] | 1955 | return renderer_preferences_.can_accept_load_drops; |
| 1956 | } |
| 1957 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1958 | void RenderViewImpl::focusNext() { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1959 | Send(new ViewHostMsg_TakeFocus(routing_id(), false)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1960 | } |
| 1961 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1962 | void RenderViewImpl::focusPrevious() { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1963 | Send(new ViewHostMsg_TakeFocus(routing_id(), true)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1964 | } |
| 1965 | |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1966 | // TODO(esprehn): Blink only ever passes Elements, this should take WebElement. |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1967 | void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode, |
| 1968 | const WebNode& toNode) { |
[email protected] | 1875bc0 | 2014-03-14 06:33:59 | [diff] [blame] | 1969 | has_scrolled_focused_editable_node_into_rect_ = false; |
| 1970 | |
jennyz | 399d6e6 | 2014-12-16 01:40:05 | [diff] [blame] | 1971 | gfx::Rect node_bounds; |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1972 | bool is_editable = false; |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1973 | if (!toNode.isNull() && toNode.isElementNode()) { |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1974 | WebElement element = const_cast<WebNode&>(toNode).to<WebElement>(); |
oshima | e2b3b40 | 2015-12-04 04:27:24 | [diff] [blame] | 1975 | blink::WebRect rect = element.boundsInViewport(); |
| 1976 | convertViewportToWindow(&rect); |
| 1977 | node_bounds = gfx::Rect(rect); |
esprehn | 3d4471a | 2015-09-17 07:13:20 | [diff] [blame] | 1978 | is_editable = element.isEditable(); |
jennyz | 399d6e6 | 2014-12-16 01:40:05 | [diff] [blame] | 1979 | } |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 1980 | Send(new ViewHostMsg_FocusedNodeChanged(routing_id(), is_editable, |
jennyz | 399d6e6 | 2014-12-16 01:40:05 | [diff] [blame] | 1981 | node_bounds)); |
[email protected] | a4b103b | 2010-10-05 18:46:07 | [diff] [blame] | 1982 | |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1983 | // TODO(estade): remove. |
| 1984 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(toNode)); |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 1985 | |
estade | 31c5434 | 2015-01-23 03:34:36 | [diff] [blame] | 1986 | RenderFrameImpl* previous_frame = nullptr; |
| 1987 | if (!fromNode.isNull()) |
| 1988 | previous_frame = RenderFrameImpl::FromWebFrame(fromNode.document().frame()); |
| 1989 | RenderFrameImpl* new_frame = nullptr; |
| 1990 | if (!toNode.isNull()) |
| 1991 | new_frame = RenderFrameImpl::FromWebFrame(toNode.document().frame()); |
| 1992 | |
| 1993 | if (previous_frame && previous_frame != new_frame) |
| 1994 | previous_frame->FocusedNodeChanged(WebNode()); |
| 1995 | if (new_frame) |
| 1996 | new_frame->FocusedNodeChanged(toNode); |
| 1997 | |
| 1998 | // TODO(dmazzoni): remove once there's a separate a11y tree per frame. |
nasko | e8d11575 | 2015-08-07 00:43:13 | [diff] [blame] | 1999 | if (main_render_frame_) |
| 2000 | main_render_frame_->FocusedNodeChangedForAccessibility(toNode); |
[email protected] | 08e9e13 | 2010-06-01 16:58:49 | [diff] [blame] | 2001 | } |
| 2002 | |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 2003 | void RenderViewImpl::didUpdateLayout() { |
[email protected] | d01b2a6 | 2013-09-18 23:21:33 | [diff] [blame] | 2004 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout()); |
| 2005 | |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 2006 | // We don't always want to set up a timer, only if we've been put in that |
| 2007 | // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 2008 | // message. |
| 2009 | if (!send_preferred_size_changes_ || !webview()) |
| 2010 | return; |
| 2011 | |
| 2012 | if (check_preferred_size_timer_.IsRunning()) |
| 2013 | return; |
| 2014 | check_preferred_size_timer_.Start(FROM_HERE, |
| 2015 | TimeDelta::FromMilliseconds(0), this, |
| 2016 | &RenderViewImpl::CheckPreferredSize); |
| 2017 | } |
| 2018 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2019 | void RenderViewImpl::navigateBackForwardSoon(int offset) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2020 | Send(new ViewHostMsg_GoToEntryAtOffset(routing_id(), offset)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2021 | } |
| 2022 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2023 | int RenderViewImpl::historyBackListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 2024 | return history_list_offset_ < 0 ? 0 : history_list_offset_; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2025 | } |
| 2026 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2027 | int RenderViewImpl::historyForwardListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 2028 | return history_list_length_ - historyBackListCount() - 1; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2029 | } |
| 2030 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2031 | // blink::WebWidgetClient ---------------------------------------------------- |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 2032 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2033 | void RenderViewImpl::didFocus() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 2034 | // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 2035 | // we won't have to test for user gesture anymore and we can |
| 2036 | // move that code back to render_widget.cc |
[email protected] | af15bf2 | 2013-03-08 01:18:17 | [diff] [blame] | 2037 | if (WebUserGestureIndicator::isProcessingUserGesture() && |
[email protected] | 70dee7e | 2013-05-29 18:28:30 | [diff] [blame] | 2038 | !RenderThreadImpl::current()->layout_test_mode()) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2039 | Send(new ViewHostMsg_Focus(routing_id())); |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 2040 | } |
| 2041 | } |
| 2042 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2043 | // 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] | 2044 | // that was created via RenderViewImpl::CreateWebView. So, we wait until this |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2045 | // point to dispatch the ShowView message. |
| 2046 | // |
| 2047 | // This method provides us with the information about how to display the newly |
[email protected] | 5f9de588 | 2011-09-30 23:36:28 | [diff] [blame] | 2048 | // created RenderView (i.e., as a blocked popup or as a new tab). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2049 | // |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2050 | void RenderViewImpl::show(WebNavigationPolicy policy) { |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 2051 | if (did_show_) { |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 2052 | // When supports_multiple_windows is disabled, popups are reusing |
| 2053 | // the same view. In some scenarios, this makes WebKit to call show() twice. |
[email protected] | c9edabd | 2013-05-23 13:56:24 | [diff] [blame] | 2054 | if (webkit_preferences_.supports_multiple_windows) |
| 2055 | NOTREACHED() << "received extraneous Show call"; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2056 | return; |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 2057 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2058 | did_show_ = true; |
| 2059 | |
[email protected] | b2142e96 | 2012-10-30 13:59:25 | [diff] [blame] | 2060 | DCHECK(opener_id_ != MSG_ROUTING_NONE); |
| 2061 | |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 2062 | // NOTE: initial_rect_ may still have its default values at this point, but |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2063 | // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the |
| 2064 | // browser process will impose a default position otherwise. |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2065 | Send(new ViewHostMsg_ShowView(opener_id_, routing_id(), |
| 2066 | NavigationPolicyToDisposition(policy), |
| 2067 | initial_rect_, opened_by_user_gesture_)); |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 2068 | SetPendingWindowRect(initial_rect_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2069 | } |
| 2070 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 2071 | bool RenderViewImpl::requestPointerLock() { |
| 2072 | return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get()); |
| 2073 | } |
| 2074 | |
| 2075 | void RenderViewImpl::requestPointerUnlock() { |
| 2076 | mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2077 | } |
| 2078 | |
| 2079 | bool RenderViewImpl::isPointerLocked() { |
| 2080 | return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2081 | webwidget_mouse_lock_target_.get()); |
| 2082 | } |
| 2083 | |
miletus | e8d28ba | 2015-06-19 04:52:04 | [diff] [blame] | 2084 | void RenderViewImpl::onMouseDown(const WebNode& mouse_down_node) { |
| 2085 | FOR_EACH_OBSERVER( |
| 2086 | RenderViewObserver, observers_, OnMouseDown(mouse_down_node)); |
| 2087 | } |
| 2088 | |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 2089 | void RenderViewImpl::didHandleGestureEvent( |
| 2090 | const WebGestureEvent& event, |
| 2091 | bool event_cancelled) { |
| 2092 | RenderWidget::didHandleGestureEvent(event, event_cancelled); |
[email protected] | bb37b65 | 2013-11-27 23:47:11 | [diff] [blame] | 2093 | |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 2094 | if (!event_cancelled) { |
| 2095 | FOR_EACH_OBSERVER( |
| 2096 | RenderViewObserver, observers_, DidHandleGestureEvent(event)); |
| 2097 | } |
| 2098 | |
jdduke | 45762d2 | 2014-10-07 04:19:08 | [diff] [blame] | 2099 | // TODO(ananta): Piggyback off existing IPCs to communicate this information, |
| 2100 | // crbug/420130. |
| 2101 | #if defined(OS_WIN) |
[email protected] | bb37b65 | 2013-11-27 23:47:11 | [diff] [blame] | 2102 | if (event.type != blink::WebGestureEvent::GestureTap) |
| 2103 | return; |
| 2104 | |
[email protected] | 91dcc6d3 | 2014-07-30 00:01:33 | [diff] [blame] | 2105 | // TODO(estade): hit test the event against focused node to make sure |
| 2106 | // the tap actually hit the focused node. |
jdduke | 3bf083fe | 2015-09-29 23:40:53 | [diff] [blame] | 2107 | blink::WebTextInputType text_input_type = GetWebView()->textInputType(); |
[email protected] | bb37b65 | 2013-11-27 23:47:11 | [diff] [blame] | 2108 | |
| 2109 | Send(new ViewHostMsg_FocusedNodeTouched( |
| 2110 | routing_id(), text_input_type != blink::WebTextInputTypeNone)); |
jdduke | 45762d2 | 2014-10-07 04:19:08 | [diff] [blame] | 2111 | #endif |
[email protected] | c68c3e4e | 2013-01-24 00:36:56 | [diff] [blame] | 2112 | } |
| 2113 | |
[email protected] | 6e89eb7 | 2013-07-23 13:28:22 | [diff] [blame] | 2114 | void RenderViewImpl::initializeLayerTreeView() { |
| 2115 | RenderWidget::initializeLayerTreeView(); |
| 2116 | RenderWidgetCompositor* rwc = compositor(); |
[email protected] | 9f7638f4 | 2014-05-30 01:51:16 | [diff] [blame] | 2117 | if (!rwc) |
[email protected] | 6e89eb7 | 2013-07-23 13:28:22 | [diff] [blame] | 2118 | return; |
[email protected] | 9f7638f4 | 2014-05-30 01:51:16 | [diff] [blame] | 2119 | |
ccameron | 1f89c00 | 2014-10-21 06:19:05 | [diff] [blame] | 2120 | bool use_threaded_event_handling = true; |
| 2121 | #if defined(OS_MACOSX) && !defined(OS_IOS) |
ccameron | a764475 | 2014-12-30 01:16:31 | [diff] [blame] | 2122 | // Disable threaded event handling if content is not handling the elastic |
| 2123 | // overscroll effect. This includes the cases where the elastic overscroll |
| 2124 | // effect is being handled by Blink (because of command line flags) and older |
| 2125 | // operating system versions which do not have an elastic overscroll effect |
| 2126 | // (SnowLeopard, which has Aqua scrollbars which need synchronous updates). |
| 2127 | use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled(); |
[email protected] | 9f7638f4 | 2014-05-30 01:51:16 | [diff] [blame] | 2128 | #endif |
ccameron | 1f89c00 | 2014-10-21 06:19:05 | [diff] [blame] | 2129 | if (use_threaded_event_handling) { |
| 2130 | RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 2131 | // render_thread may be NULL in tests. |
| 2132 | InputHandlerManager* input_handler_manager = |
| 2133 | render_thread ? render_thread->input_handler_manager() : NULL; |
| 2134 | if (input_handler_manager) { |
| 2135 | input_handler_manager->AddInputHandler( |
ymalik | fb8b964 | 2016-01-12 05:24:22 | [diff] [blame] | 2136 | routing_id(), rwc->GetInputHandler(), AsWeakPtr(), |
| 2137 | webkit_preferences_.enable_scroll_animator); |
ccameron | 1f89c00 | 2014-10-21 06:19:05 | [diff] [blame] | 2138 | } |
| 2139 | } |
[email protected] | 6e89eb7 | 2013-07-23 13:28:22 | [diff] [blame] | 2140 | } |
| 2141 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2142 | // blink::WebFrameClient ----------------------------------------------------- |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2143 | |
[email protected] | 5e92282f | 2012-08-17 08:11:57 | [diff] [blame] | 2144 | void RenderViewImpl::Repaint(const gfx::Size& size) { |
[email protected] | 3d9ec505 | 2013-01-02 22:05:25 | [diff] [blame] | 2145 | OnRepaint(size); |
[email protected] | 5e92282f | 2012-08-17 08:11:57 | [diff] [blame] | 2146 | } |
| 2147 | |
[email protected] | b2324b09 | 2012-11-01 10:34:11 | [diff] [blame] | 2148 | void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name, |
| 2149 | const std::string& value) { |
| 2150 | EditCommands edit_commands; |
| 2151 | edit_commands.push_back(EditCommand(name, value)); |
| 2152 | OnSetEditCommandsForNextKeyEvent(edit_commands); |
| 2153 | } |
| 2154 | |
| 2155 | void RenderViewImpl::ClearEditCommands() { |
| 2156 | edit_commands_.clear(); |
| 2157 | } |
| 2158 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2159 | SSLStatus RenderViewImpl::GetSSLStatusOfFrame(blink::WebFrame* frame) const { |
[email protected] | 83c0abca | 2013-07-23 20:09:42 | [diff] [blame] | 2160 | std::string security_info; |
| 2161 | if (frame && frame->dataSource()) |
| 2162 | security_info = frame->dataSource()->response().securityInfo(); |
| 2163 | |
estark | a5635c4 | 2015-07-14 00:06:53 | [diff] [blame] | 2164 | SSLStatus result; |
| 2165 | CHECK(DeserializeSecurityInfo(security_info, &result)); |
| 2166 | return result; |
[email protected] | e449521 | 2012-12-06 03:09:12 | [diff] [blame] | 2167 | } |
| 2168 | |
[email protected] | b38806a | 2013-10-04 16:01:38 | [diff] [blame] | 2169 | const std::string& RenderViewImpl::GetAcceptLanguages() const { |
| 2170 | return renderer_preferences_.accept_languages; |
| 2171 | } |
| 2172 | |
oshima | e2b3b40 | 2015-12-04 04:27:24 | [diff] [blame] | 2173 | void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) { |
oshima | f866dab | 2015-12-05 00:41:54 | [diff] [blame] | 2174 | RenderWidget::convertViewportToWindow(rect); |
oshima | e2b3b40 | 2015-12-04 04:27:24 | [diff] [blame] | 2175 | } |
| 2176 | |
huangs | 2a34235 | 2015-12-15 16:59:24 | [diff] [blame] | 2177 | gfx::RectF RenderViewImpl::ElementBoundsInWindow( |
| 2178 | const blink::WebElement& element) { |
| 2179 | blink::WebRect bounding_box_in_window = element.boundsInViewport(); |
| 2180 | convertViewportToWindow(&bounding_box_in_window); |
| 2181 | return gfx::RectF(bounding_box_in_window); |
| 2182 | } |
| 2183 | |
oshima | c059194c | 2016-01-12 19:40:15 | [diff] [blame] | 2184 | float RenderViewImpl::GetDeviceScaleFactorForTest() const { |
| 2185 | return device_scale_factor_; |
| 2186 | } |
| 2187 | |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 2188 | void RenderViewImpl::didChangeIcon(WebLocalFrame* frame, |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2189 | WebIconURL::Type icon_type) { |
| 2190 | if (frame->parent()) |
| 2191 | return; |
| 2192 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2193 | WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type); |
| 2194 | std::vector<FaviconURL> urls; |
| 2195 | for (size_t i = 0; i < icon_urls.size(); i++) { |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 2196 | std::vector<gfx::Size> sizes; |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 2197 | ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
| 2198 | urls.push_back(FaviconURL( |
| 2199 | icon_urls[i].iconURL(), ToFaviconType(icon_urls[i].iconType()), sizes)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 2200 | } |
| 2201 | SendUpdateFaviconURL(urls); |
[email protected] | 5019ef1 | 2010-04-27 17:26:58 | [diff] [blame] | 2202 | } |
| 2203 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2204 | void RenderViewImpl::CheckPreferredSize() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 2205 | // We don't always want to send the change messages over IPC, only if we've |
| 2206 | // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 2207 | // message. |
| 2208 | if (!send_preferred_size_changes_ || !webview()) |
| 2209 | return; |
| 2210 | |
[email protected] | e76b797 | 2013-06-06 02:58:48 | [diff] [blame] | 2211 | gfx::Size size = webview()->contentsPreferredMinimumSize(); |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2212 | if (size == preferred_size_) |
| 2213 | return; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 2214 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2215 | preferred_size_ = size; |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2216 | Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id(), |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2217 | preferred_size_)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2218 | } |
| 2219 | |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 2220 | void RenderViewImpl::SendFindReply(int request_id, |
| 2221 | int match_count, |
| 2222 | int ordinal, |
| 2223 | const WebRect& selection_rect, |
| 2224 | bool final_status_update) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2225 | Send(new ViewHostMsg_Find_Reply(routing_id(), request_id, match_count, |
| 2226 | selection_rect, ordinal, |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 2227 | final_status_update)); |
| 2228 | } |
| 2229 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2230 | blink::WebString RenderViewImpl::acceptLanguages() { |
[email protected] | 9982c80 | 2013-06-12 15:22:06 | [diff] [blame] | 2231 | return WebString::fromUTF8(renderer_preferences_.accept_languages); |
| 2232 | } |
| 2233 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2234 | // RenderView implementation --------------------------------------------------- |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2235 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2236 | bool RenderViewImpl::Send(IPC::Message* message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2237 | return RenderWidget::Send(message); |
| 2238 | } |
| 2239 | |
mostynb | c3335323 | 2014-09-12 09:38:31 | [diff] [blame] | 2240 | RenderFrameImpl* RenderViewImpl::GetMainRenderFrame() { |
nasko | 77de231 | 2015-05-12 03:09:16 | [diff] [blame] | 2241 | return main_render_frame_; |
[email protected] | b849847b | 2013-12-10 21:57:58 | [diff] [blame] | 2242 | } |
| 2243 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2244 | int RenderViewImpl::GetRoutingID() const { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2245 | return routing_id(); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2246 | } |
| 2247 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2248 | gfx::Size RenderViewImpl::GetSize() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2249 | return size(); |
| 2250 | } |
| 2251 | |
oshima | 129b75e | 2016-01-14 09:15:14 | [diff] [blame] | 2252 | float RenderViewImpl::GetDeviceScaleFactor() const { |
| 2253 | return device_scale_factor_; |
| 2254 | } |
| 2255 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2256 | WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2257 | return webkit_preferences_; |
| 2258 | } |
| 2259 | |
[email protected] | 324825d | 2012-11-30 12:37:15 | [diff] [blame] | 2260 | void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) { |
| 2261 | OnUpdateWebPreferences(preferences); |
| 2262 | } |
| 2263 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2264 | blink::WebView* RenderViewImpl::GetWebView() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2265 | return webview(); |
| 2266 | } |
| 2267 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2268 | bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2269 | return (!send_preferred_size_changes_ || |
| 2270 | (disable_scrollbars_size_limit_.width() <= width || |
| 2271 | disable_scrollbars_size_limit_.height() <= height)); |
| 2272 | } |
| 2273 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2274 | int RenderViewImpl::GetEnabledBindings() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2275 | return enabled_bindings_; |
| 2276 | } |
| 2277 | |
avi | f937e1d | 2014-11-02 18:13:07 | [diff] [blame] | 2278 | bool RenderViewImpl::GetContentStateImmediately() const { |
| 2279 | return send_content_state_immediately_; |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2280 | } |
| 2281 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2282 | blink::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2283 | return visibilityState(); |
| 2284 | } |
| 2285 | |
[email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 2286 | void RenderViewImpl::DidStartLoading() { |
[email protected] | 6dd5c32 | 2014-03-12 07:58:46 | [diff] [blame] | 2287 | main_render_frame_->didStartLoading(true); |
[email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 2288 | } |
| 2289 | |
| 2290 | void RenderViewImpl::DidStopLoading() { |
[email protected] | 6dd5c32 | 2014-03-12 07:58:46 | [diff] [blame] | 2291 | main_render_frame_->didStopLoading(); |
[email protected] | 3c71576ce | 2013-07-23 02:00:01 | [diff] [blame] | 2292 | } |
| 2293 | |
estade | 78d655f8 | 2015-01-30 01:55:08 | [diff] [blame] | 2294 | blink::WebElement RenderViewImpl::GetFocusedElement() const { |
| 2295 | if (!webview()) |
| 2296 | return WebElement(); |
| 2297 | WebFrame* focused_frame = webview()->focusedFrame(); |
| 2298 | if (focused_frame) { |
| 2299 | WebDocument doc = focused_frame->document(); |
| 2300 | if (!doc.isNull()) |
| 2301 | return doc.focusedElement(); |
| 2302 | } |
| 2303 | |
| 2304 | return WebElement(); |
| 2305 | } |
| 2306 | |
[email protected] | 54ea9ff | 2014-03-20 00:27:54 | [diff] [blame] | 2307 | blink::WebPlugin* RenderViewImpl::GetWebPluginForFind() { |
| 2308 | if (!webview()) |
| 2309 | return NULL; |
| 2310 | |
| 2311 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2312 | if (main_frame->isWebLocalFrame() && |
| 2313 | main_frame->document().isPluginDocument()) |
[email protected] | 54ea9ff | 2014-03-20 00:27:54 | [diff] [blame] | 2314 | return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
| 2315 | |
| 2316 | #if defined(ENABLE_PLUGINS) |
| 2317 | if (plugin_find_handler_) |
| 2318 | return plugin_find_handler_->container()->plugin(); |
| 2319 | #endif |
| 2320 | |
| 2321 | return NULL; |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2322 | } |
| 2323 | |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 2324 | void RenderViewImpl::OnFind(int request_id, |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 2325 | const base::string16& search_text, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2326 | const WebFindOptions& options) { |
thestig | 6057a6b2 | 2015-11-12 23:01:33 | [diff] [blame] | 2327 | DCHECK(!search_text.empty()); |
| 2328 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2329 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | 54ea9ff | 2014-03-20 00:27:54 | [diff] [blame] | 2330 | blink::WebPlugin* plugin = GetWebPluginForFind(); |
[email protected] | 87254253 | 2011-06-23 00:43:16 | [diff] [blame] | 2331 | // Check if the plugin still exists in the document. |
[email protected] | 54ea9ff | 2014-03-20 00:27:54 | [diff] [blame] | 2332 | if (plugin) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2333 | if (options.findNext) { |
| 2334 | // Just navigate back/forward. |
[email protected] | 54ea9ff | 2014-03-20 00:27:54 | [diff] [blame] | 2335 | plugin->selectFindResult(options.forward); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2336 | } else { |
[email protected] | 54ea9ff | 2014-03-20 00:27:54 | [diff] [blame] | 2337 | if (!plugin->startFind( |
[email protected] | afdbd14 | 2010-07-10 08:01:23 | [diff] [blame] | 2338 | search_text, options.matchCase, request_id)) { |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 2339 | // Send "no results". |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 2340 | SendFindReply(request_id, 0, 0, gfx::Rect(), true); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2341 | } |
| 2342 | } |
| 2343 | return; |
| 2344 | } |
| 2345 | |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 2346 | WebFrame* frame_after_main = main_frame->traverseNext(true); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2347 | WebFrame* focused_frame = webview()->focusedFrame(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2348 | WebFrame* search_frame = focused_frame; // start searching focused frame. |
| 2349 | |
| 2350 | bool multi_frame = (frame_after_main != main_frame); |
| 2351 | |
| 2352 | // If we have multiple frames, we don't want to wrap the search within the |
| 2353 | // frame, so we check here if we only have main_frame in the chain. |
| 2354 | bool wrap_within_frame = !multi_frame; |
| 2355 | |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 2356 | WebRect selection_rect; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2357 | bool result = false; |
| 2358 | |
[email protected] | 7830da3e | 2009-11-06 16:27:26 | [diff] [blame] | 2359 | // If something is selected when we start searching it means we cannot just |
| 2360 | // increment the current match ordinal; we need to re-generate it. |
| 2361 | WebRange current_selection = focused_frame->selectionRange(); |
| 2362 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2363 | do { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 2364 | result = search_frame->find( |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 2365 | request_id, search_text, options, wrap_within_frame, &selection_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2366 | |
| 2367 | if (!result) { |
| 2368 | // don't leave text selected as you move to the next frame. |
[email protected] | 6dd17a8a | 2013-05-01 05:50:10 | [diff] [blame] | 2369 | search_frame->executeCommand(WebString::fromUTF8("Unselect"), |
[email protected] | c39f744 | 2014-02-27 03:33:17 | [diff] [blame] | 2370 | GetFocusedElement()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2371 | |
| 2372 | // Find the next frame, but skip the invisible ones. |
| 2373 | do { |
| 2374 | // What is the next frame to search? (we might be going backwards). Note |
| 2375 | // that we specify wrap=true so that search_frame never becomes NULL. |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 2376 | search_frame = options.forward ? |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 2377 | search_frame->traverseNext(true) : |
| 2378 | search_frame->traversePrevious(true); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 2379 | } while (!search_frame->hasVisibleContent() && |
| 2380 | search_frame != focused_frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2381 | |
[email protected] | 884db41 | 2008-11-24 23:46:50 | [diff] [blame] | 2382 | // Make sure selection doesn't affect the search operation in new frame. |
[email protected] | 6dd17a8a | 2013-05-01 05:50:10 | [diff] [blame] | 2383 | search_frame->executeCommand(WebString::fromUTF8("Unselect"), |
[email protected] | c39f744 | 2014-02-27 03:33:17 | [diff] [blame] | 2384 | GetFocusedElement()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2385 | |
| 2386 | // If we have multiple frames and we have wrapped back around to the |
| 2387 | // focused frame, we need to search it once more allowing wrap within |
| 2388 | // the frame, otherwise it will report 'no match' if the focused frame has |
| 2389 | // reported matches, but no frames after the focused_frame contain a |
| 2390 | // match for the search word(s). |
| 2391 | if (multi_frame && search_frame == focused_frame) { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 2392 | result = search_frame->find( |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 2393 | request_id, search_text, options, true, // Force wrapping. |
| 2394 | &selection_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2395 | } |
| 2396 | } |
| 2397 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2398 | webview()->setFocusedFrame(search_frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2399 | } while (!result && search_frame != focused_frame); |
| 2400 | |
[email protected] | 7830da3e | 2009-11-06 16:27:26 | [diff] [blame] | 2401 | if (options.findNext && current_selection.isNull()) { |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 2402 | // Force the main_frame to report the actual count. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 2403 | main_frame->increaseMatchCount(0, request_id); |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 2404 | } else { |
| 2405 | // If nothing is found, set result to "0 of 0", otherwise, set it to |
| 2406 | // "-1 of 1" to indicate that we found at least one item, but we don't know |
| 2407 | // yet what is active. |
| 2408 | int ordinal = result ? -1 : 0; // -1 here means, we might know more later. |
| 2409 | int match_count = result ? 1 : 0; // 1 here means possibly more coming. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2410 | |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 2411 | // If we find no matches then this will be our last status update. |
| 2412 | // Otherwise the scoping effort will send more results. |
| 2413 | bool final_status_update = !result; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2414 | |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 2415 | SendFindReply(request_id, match_count, ordinal, selection_rect, |
| 2416 | final_status_update); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2417 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2418 | // Scoping effort begins, starting with the mainframe. |
| 2419 | search_frame = main_frame; |
| 2420 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 2421 | main_frame->resetMatchCount(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2422 | |
| 2423 | do { |
| 2424 | // Cancel all old scoping requests before starting a new one. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 2425 | search_frame->cancelPendingScopingEffort(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2426 | |
| 2427 | // We don't start another scoping effort unless at least one match has |
| 2428 | // been found. |
| 2429 | if (result) { |
| 2430 | // Start new scoping request. If the scoping function determines that it |
| 2431 | // needs to scope, it will defer until later. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 2432 | search_frame->scopeStringMatches(request_id, |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 2433 | search_text, |
| 2434 | options, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2435 | true); // reset the tickmarks |
| 2436 | } |
| 2437 | |
| 2438 | // Iterate to the next frame. The frame will not necessarily scope, for |
| 2439 | // example if it is not visible. |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 2440 | search_frame = search_frame->traverseNext(true); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2441 | } while (search_frame != main_frame); |
| 2442 | } |
| 2443 | } |
| 2444 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2445 | void RenderViewImpl::OnStopFinding(StopFindAction action) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2446 | WebView* view = webview(); |
| 2447 | if (!view) |
| 2448 | return; |
| 2449 | |
[email protected] | 54ea9ff | 2014-03-20 00:27:54 | [diff] [blame] | 2450 | blink::WebPlugin* plugin = GetWebPluginForFind(); |
| 2451 | if (plugin) { |
| 2452 | plugin->stopFind(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2453 | return; |
| 2454 | } |
| 2455 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2456 | bool clear_selection = action == STOP_FIND_ACTION_CLEAR_SELECTION; |
[email protected] | 6dd17a8a | 2013-05-01 05:50:10 | [diff] [blame] | 2457 | if (clear_selection) { |
| 2458 | view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"), |
[email protected] | c39f744 | 2014-02-27 03:33:17 | [diff] [blame] | 2459 | GetFocusedElement()); |
[email protected] | 6dd17a8a | 2013-05-01 05:50:10 | [diff] [blame] | 2460 | } |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2461 | |
| 2462 | WebFrame* frame = view->mainFrame(); |
| 2463 | while (frame) { |
| 2464 | frame->stopFinding(clear_selection); |
| 2465 | frame = frame->traverseNext(false); |
| 2466 | } |
| 2467 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2468 | if (action == STOP_FIND_ACTION_ACTIVATE_SELECTION) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2469 | WebFrame* focused_frame = view->focusedFrame(); |
| 2470 | if (focused_frame) { |
| 2471 | WebDocument doc = focused_frame->document(); |
| 2472 | if (!doc.isNull()) { |
[email protected] | c39f744 | 2014-02-27 03:33:17 | [diff] [blame] | 2473 | WebElement element = doc.focusedElement(); |
| 2474 | if (!element.isNull()) |
| 2475 | element.simulateClick(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 2476 | } |
| 2477 | } |
| 2478 | } |
| 2479 | } |
| 2480 | |
[email protected] | 59363fc9 | 2012-09-05 03:46:31 | [diff] [blame] | 2481 | #if defined(OS_ANDROID) |
| 2482 | void RenderViewImpl::OnActivateNearestFindResult(int request_id, |
| 2483 | float x, float y) { |
| 2484 | if (!webview()) |
| 2485 | return; |
| 2486 | |
| 2487 | WebFrame* main_frame = webview()->mainFrame(); |
| 2488 | WebRect selection_rect; |
| 2489 | int ordinal = main_frame->selectNearestFindMatch(WebFloatPoint(x, y), |
| 2490 | &selection_rect); |
| 2491 | if (ordinal == -1) { |
| 2492 | // Something went wrong, so send a no-op reply (force the main_frame to |
| 2493 | // report the current match count) in case the host is waiting for a |
| 2494 | // response due to rate-limiting). |
| 2495 | main_frame->increaseMatchCount(0, request_id); |
| 2496 | return; |
| 2497 | } |
| 2498 | |
[email protected] | 55750b3 | 2012-09-21 14:05:03 | [diff] [blame] | 2499 | SendFindReply(request_id, |
| 2500 | -1 /* number_of_matches */, |
| 2501 | ordinal, |
| 2502 | selection_rect, |
| 2503 | true /* final_update */); |
[email protected] | 59363fc9 | 2012-09-05 03:46:31 | [diff] [blame] | 2504 | } |
| 2505 | |
| 2506 | void RenderViewImpl::OnFindMatchRects(int current_version) { |
| 2507 | if (!webview()) |
| 2508 | return; |
| 2509 | |
| 2510 | WebFrame* main_frame = webview()->mainFrame(); |
| 2511 | std::vector<gfx::RectF> match_rects; |
| 2512 | |
| 2513 | int rects_version = main_frame->findMatchMarkersVersion(); |
| 2514 | if (current_version != rects_version) { |
| 2515 | WebVector<WebFloatRect> web_match_rects; |
| 2516 | main_frame->findMatchRects(web_match_rects); |
| 2517 | match_rects.reserve(web_match_rects.size()); |
| 2518 | for (size_t i = 0; i < web_match_rects.size(); ++i) |
| 2519 | match_rects.push_back(gfx::RectF(web_match_rects[i])); |
| 2520 | } |
| 2521 | |
| 2522 | gfx::RectF active_rect = main_frame->activeFindMatchRect(); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2523 | Send(new ViewHostMsg_FindMatchRects_Reply(routing_id(), rects_version, |
| 2524 | match_rects, active_rect)); |
[email protected] | 59363fc9 | 2012-09-05 03:46:31 | [diff] [blame] | 2525 | } |
| 2526 | #endif |
| 2527 | |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 2528 | void RenderViewImpl::OnSetPageScale(float page_scale_factor) { |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2529 | if (!webview()) |
| 2530 | return; |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 2531 | webview()->setPageScaleFactor(page_scale_factor); |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 2532 | } |
| 2533 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2534 | void RenderViewImpl::OnZoom(PageZoom zoom) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 2535 | if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 2536 | return; |
| 2537 | |
[email protected] | 258d3112 | 2010-05-09 10:59:41 | [diff] [blame] | 2538 | webview()->hidePopups(); |
[email protected] | 854ab546 | 2011-11-22 20:48:10 | [diff] [blame] | 2539 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2540 | double old_zoom_level = webview()->zoomLevel(); |
| 2541 | double zoom_level; |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2542 | if (zoom == PAGE_ZOOM_RESET) { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2543 | zoom_level = 0; |
| 2544 | } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
| 2545 | // Previous zoom level is a whole number, so just increment/decrement. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 2546 | zoom_level = old_zoom_level + zoom; |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2547 | } else { |
| 2548 | // Either the user hit the zoom factor limit and thus the zoom level is now |
| 2549 | // not a whole number, or a plugin changed it to a custom value. We want |
| 2550 | // to go to the next whole number so that the user can always get back to |
| 2551 | // 100% with the keyboard/menu. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 2552 | if ((old_zoom_level > 1 && zoom > 0) || |
| 2553 | (old_zoom_level < 1 && zoom < 0)) { |
| 2554 | zoom_level = static_cast<int>(old_zoom_level + zoom); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 2555 | } else { |
| 2556 | // We're going towards 100%, so first go to the next whole number. |
| 2557 | zoom_level = static_cast<int>(old_zoom_level); |
| 2558 | } |
| 2559 | } |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 2560 | SetZoomLevel(zoom_level); |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 2561 | zoomLevelChanged(); |
| 2562 | } |
| 2563 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2564 | void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
| 2565 | double zoom_level) { |
[email protected] | cbe55d2 | 2013-02-14 17:04:33 | [diff] [blame] | 2566 | #if !defined(OS_ANDROID) |
| 2567 | // On Android, page zoom isn't used, and in case of WebView, text zoom is used |
| 2568 | // for legacy WebView text scaling emulation. Thus, the code that resets |
| 2569 | // the zoom level from this map will be effectively resetting text zoom level. |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 2570 | host_zoom_levels_[url] = zoom_level; |
[email protected] | cbe55d2 | 2013-02-14 17:04:33 | [diff] [blame] | 2571 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2572 | } |
| 2573 | |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 2574 | void RenderViewImpl::OnSetZoomLevelForView(bool uses_temporary_zoom_level, |
| 2575 | double level) { |
| 2576 | uses_temporary_zoom_level_ = uses_temporary_zoom_level; |
| 2577 | |
| 2578 | webview()->hidePopups(); |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 2579 | SetZoomLevel(level); |
[email protected] | d42bf47 | 2014-06-14 01:49:38 | [diff] [blame] | 2580 | } |
| 2581 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2582 | void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2583 | webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2584 | } |
| 2585 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2586 | void RenderViewImpl::OnResetPageEncodingToDefault() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2587 | WebString no_encoding; |
| 2588 | webview()->setPageEncoding(no_encoding); |
[email protected] | a697f4c | 2009-09-14 22:30:18 | [diff] [blame] | 2589 | } |
| 2590 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2591 | void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 2592 | if ((enabled_bindings_flags & BINDINGS_POLICY_WEB_UI) && |
| 2593 | !(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) { |
[email protected] | 69a0a13 | 2014-03-26 16:45:02 | [diff] [blame] | 2594 | // WebUIExtensionData deletes itself when we're destroyed. |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 2595 | new WebUIExtensionData(this); |
nasko | 1fa0fb6 | 2015-12-09 01:49:57 | [diff] [blame] | 2596 | |
| 2597 | if (main_render_frame_) |
| 2598 | main_render_frame_->EnableMojoBindings(); |
[email protected] | 940ed1d | 2012-11-27 21:03:21 | [diff] [blame] | 2599 | } |
| 2600 | |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 2601 | enabled_bindings_ |= enabled_bindings_flags; |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2602 | |
| 2603 | // Keep track of the total bindings accumulated in this process. |
| 2604 | RenderProcess::current()->AddBindings(enabled_bindings_flags); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2605 | } |
| 2606 | |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 2607 | void RenderViewImpl::OnDragTargetDragEnter(const DropData& drop_data, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2608 | const gfx::Point& client_point, |
| 2609 | const gfx::Point& screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 2610 | WebDragOperationsMask ops, |
| 2611 | int key_modifiers) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2612 | WebDragOperation operation = webview()->dragTargetDragEnter( |
[email protected] | dc293a7 | 2013-07-01 11:11:22 | [diff] [blame] | 2613 | DropDataToWebDragData(drop_data), |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2614 | client_point, |
| 2615 | screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 2616 | ops, |
| 2617 | key_modifiers); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2618 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2619 | Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation)); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2620 | } |
| 2621 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2622 | void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
| 2623 | const gfx::Point& screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 2624 | WebDragOperationsMask ops, |
| 2625 | int key_modifiers) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2626 | WebDragOperation operation = webview()->dragTargetDragOver( |
| 2627 | client_point, |
| 2628 | screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 2629 | ops, |
| 2630 | key_modifiers); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2631 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2632 | Send(new DragHostMsg_UpdateDragCursor(routing_id(), operation)); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2633 | } |
| 2634 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2635 | void RenderViewImpl::OnDragTargetDragLeave() { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2636 | webview()->dragTargetDragLeave(); |
| 2637 | } |
| 2638 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2639 | void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 2640 | const gfx::Point& screen_point, |
| 2641 | int key_modifiers) { |
| 2642 | webview()->dragTargetDrop(client_point, screen_point, key_modifiers); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2643 | } |
| 2644 | |
[email protected] | 7a6d773f | 2014-04-04 01:25:09 | [diff] [blame] | 2645 | void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point, |
| 2646 | const gfx::Point& screen_point, |
| 2647 | WebDragOperation op) { |
| 2648 | webview()->dragSourceEndedAt(client_point, screen_point, op); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2649 | } |
| 2650 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2651 | void RenderViewImpl::OnDragSourceSystemDragEnded() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2652 | webview()->dragSourceSystemDragEnded(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2653 | } |
| 2654 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2655 | void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 2656 | webkit_preferences_ = prefs; |
sataya.m | f405d0e | 2015-07-07 16:51:11 | [diff] [blame] | 2657 | ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2658 | } |
| 2659 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2660 | void RenderViewImpl::OnEnumerateDirectoryResponse( |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2661 | int id, |
[email protected] | c42de73 | 2013-02-16 06:26:31 | [diff] [blame] | 2662 | const std::vector<base::FilePath>& paths) { |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2663 | if (!enumeration_completions_[id]) |
| 2664 | return; |
| 2665 | |
| 2666 | WebVector<WebString> ws_file_names(paths.size()); |
| 2667 | for (size_t i = 0; i < paths.size(); ++i) |
[email protected] | 728c2ee | 2013-06-25 04:01:07 | [diff] [blame] | 2668 | ws_file_names[i] = paths[i].AsUTF16Unsafe(); |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 2669 | |
| 2670 | enumeration_completions_[id]->didChooseFile(ws_file_names); |
| 2671 | enumeration_completions_.erase(id); |
| 2672 | } |
| 2673 | |
[email protected] | fb11b6a4 | 2012-03-14 07:25:12 | [diff] [blame] | 2674 | void RenderViewImpl::OnFileChooserResponse( |
hirono | 570357bd | 2014-10-08 12:39:27 | [diff] [blame] | 2675 | const std::vector<content::FileChooserFileInfo>& files) { |
[email protected] | 8029f567 | 2009-03-20 22:33:36 | [diff] [blame] | 2676 | // This could happen if we navigated to a different page before the user |
| 2677 | // closed the chooser. |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 2678 | if (file_chooser_completions_.empty()) |
[email protected] | 8029f567 | 2009-03-20 22:33:36 | [diff] [blame] | 2679 | return; |
| 2680 | |
[email protected] | b518852 | 2012-03-15 00:18:04 | [diff] [blame] | 2681 | // Convert Chrome's SelectedFileInfo list to WebKit's. |
| 2682 | WebVector<WebFileChooserCompletion::SelectedFileInfo> selected_files( |
| 2683 | files.size()); |
| 2684 | for (size_t i = 0; i < files.size(); ++i) { |
| 2685 | WebFileChooserCompletion::SelectedFileInfo selected_file; |
hirono | 570357bd | 2014-10-08 12:39:27 | [diff] [blame] | 2686 | selected_file.path = files[i].file_path.AsUTF16Unsafe(); |
[email protected] | 728c2ee | 2013-06-25 04:01:07 | [diff] [blame] | 2687 | selected_file.displayName = |
| 2688 | base::FilePath(files[i].display_name).AsUTF16Unsafe(); |
hirono | e9f2732b | 2014-10-22 08:06:41 | [diff] [blame] | 2689 | if (files[i].file_system_url.is_valid()) { |
| 2690 | selected_file.fileSystemURL = files[i].file_system_url; |
| 2691 | selected_file.length = files[i].length; |
| 2692 | selected_file.modificationTime = files[i].modification_time.ToDoubleT(); |
| 2693 | selected_file.isDirectory = files[i].is_directory; |
| 2694 | } |
[email protected] | b518852 | 2012-03-15 00:18:04 | [diff] [blame] | 2695 | selected_files[i] = selected_file; |
| 2696 | } |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 2697 | |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 2698 | if (file_chooser_completions_.front()->completion) |
[email protected] | b518852 | 2012-03-15 00:18:04 | [diff] [blame] | 2699 | file_chooser_completions_.front()->completion->didChooseFile( |
| 2700 | selected_files); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 2701 | file_chooser_completions_.pop_front(); |
| 2702 | |
| 2703 | // If there are more pending file chooser requests, schedule one now. |
| 2704 | if (!file_chooser_completions_.empty()) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2705 | Send(new ViewHostMsg_RunFileChooser( |
| 2706 | routing_id(), file_chooser_completions_.front()->params)); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 2707 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2708 | } |
| 2709 | |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 2710 | void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, |
| 2711 | const gfx::Size& max_size) { |
| 2712 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 2713 | if (!webview()) |
| 2714 | return; |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2715 | |
[email protected] | 97e1bf7 | 2013-03-06 14:06:05 | [diff] [blame] | 2716 | auto_resize_mode_ = true; |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 2717 | if (IsUseZoomForDSFEnabled()) { |
| 2718 | webview()->enableAutoResizeMode( |
| 2719 | gfx::ScaleToCeiledSize(min_size, device_scale_factor_), |
| 2720 | gfx::ScaleToCeiledSize(max_size, device_scale_factor_)); |
| 2721 | } else { |
| 2722 | webview()->enableAutoResizeMode(min_size, max_size); |
| 2723 | } |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 2724 | } |
| 2725 | |
| 2726 | void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) { |
| 2727 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 2728 | if (!webview()) |
| 2729 | return; |
[email protected] | 97e1bf7 | 2013-03-06 14:06:05 | [diff] [blame] | 2730 | auto_resize_mode_ = false; |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 2731 | webview()->disableAutoResizeMode(); |
| 2732 | |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2733 | if (!new_size.IsEmpty()) { |
| 2734 | Resize(new_size, |
| 2735 | physical_backing_size_, |
dtrainor | cb7779b8 | 2014-12-04 01:08:02 | [diff] [blame] | 2736 | top_controls_shrink_blink_size_, |
| 2737 | top_controls_height_, |
[email protected] | bb6378fe | 2014-04-28 21:19:44 | [diff] [blame] | 2738 | visible_viewport_size_, |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2739 | resizer_rect_, |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 2740 | is_fullscreen_granted_, |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 2741 | display_mode_, |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 2742 | NO_RESIZE_ACK); |
| 2743 | } |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 2744 | } |
| 2745 | |
[email protected] | 2bf834f | 2011-11-17 20:02:21 | [diff] [blame] | 2746 | void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 2747 | if (send_preferred_size_changes_) |
| 2748 | return; |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 2749 | send_preferred_size_changes_ = true; |
[email protected] | 770dd8b | 2010-05-24 18:11:39 | [diff] [blame] | 2750 | |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 2751 | // Start off with an initial preferred size notification (in case |
| 2752 | // |didUpdateLayout| was already called). |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 2753 | didUpdateLayout(); |
[email protected] | 0666aef | 2009-05-13 19:48:08 | [diff] [blame] | 2754 | } |
| 2755 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2756 | void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2757 | const gfx::Size& disable_scrollbar_size_limit) { |
| 2758 | disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
| 2759 | } |
| 2760 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2761 | void RenderViewImpl::OnSetRendererPrefs( |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2762 | const RendererPreferences& renderer_prefs) { |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 2763 | double old_zoom_level = renderer_preferences_.default_zoom_level; |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 2764 | std::string old_accept_languages = renderer_preferences_.accept_languages; |
| 2765 | |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 2766 | renderer_preferences_ = renderer_prefs; |
ananta | 59b9fe7 | 2015-04-07 01:33:26 | [diff] [blame] | 2767 | |
[email protected] | 6e282c9 | 2009-07-24 01:19:37 | [diff] [blame] | 2768 | UpdateFontRenderingFromRendererPrefs(); |
ananta | 59b9fe7 | 2015-04-07 01:33:26 | [diff] [blame] | 2769 | UpdateThemePrefs(); |
[email protected] | 38a8571 | 2013-01-02 22:45:02 | [diff] [blame] | 2770 | |
[email protected] | dcc29777 | 2014-04-10 22:20:52 | [diff] [blame] | 2771 | #if defined(USE_DEFAULT_RENDER_THEME) |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2772 | if (renderer_prefs.use_custom_colors) { |
esprehn | 021507d | 2015-11-13 23:35:01 | [diff] [blame] | 2773 | blink::setFocusRingColor(renderer_prefs.focus_ring_color); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 2774 | blink::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2775 | |
| 2776 | if (webview()) { |
[email protected] | 1596efb | 2013-01-17 22:13:01 | [diff] [blame] | 2777 | webview()->setSelectionColors( |
| 2778 | renderer_prefs.active_selection_bg_color, |
| 2779 | renderer_prefs.active_selection_fg_color, |
| 2780 | renderer_prefs.inactive_selection_bg_color, |
| 2781 | renderer_prefs.inactive_selection_fg_color); |
| 2782 | webview()->themeChanged(); |
| 2783 | } |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 2784 | } |
[email protected] | c997bc4 | 2014-04-11 18:25:58 | [diff] [blame] | 2785 | #endif // defined(USE_DEFAULT_RENDER_THEME) |
[email protected] | d299d97 | 2012-03-23 02:26:55 | [diff] [blame] | 2786 | |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 2787 | // If the zoom level for this page matches the old zoom default, and this |
| 2788 | // is not a plugin, update the zoom level to match the new default. |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2789 | if (webview() && webview()->mainFrame()->isWebLocalFrame() && |
| 2790 | !webview()->mainFrame()->document().isPluginDocument() && |
[email protected] | cbe55d2 | 2013-02-14 17:04:33 | [diff] [blame] | 2791 | !ZoomValuesEqual(old_zoom_level, |
| 2792 | renderer_preferences_.default_zoom_level) && |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 2793 | ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { |
tommycli | 8aad3ba | 2015-08-12 17:57:59 | [diff] [blame] | 2794 | SetZoomLevel(renderer_preferences_.default_zoom_level); |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 2795 | zoomLevelChanged(); |
| 2796 | } |
[email protected] | ebd5ea5 | 2014-05-28 14:51:15 | [diff] [blame] | 2797 | |
| 2798 | if (webview() && |
| 2799 | old_accept_languages != renderer_preferences_.accept_languages) { |
| 2800 | webview()->acceptLanguagesChanged(); |
| 2801 | } |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 2802 | } |
| 2803 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2804 | void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
| 2805 | const WebMediaPlayerAction& action) { |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 2806 | if (webview()) |
| 2807 | webview()->performMediaPlayerAction(action, location); |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 2808 | } |
| 2809 | |
[email protected] | fcdc564 | 2014-05-09 14:32:24 | [diff] [blame] | 2810 | void RenderViewImpl::OnOrientationChange() { |
japhet | e20ec7c | 2015-03-18 19:16:18 | [diff] [blame] | 2811 | if (webview() && webview()->mainFrame()->isWebLocalFrame()) |
| 2812 | webview()->mainFrame()->toWebLocalFrame()->sendOrientationChangeEvent(); |
[email protected] | 7782964 | 2012-05-15 14:47:17 | [diff] [blame] | 2813 | } |
| 2814 | |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 2815 | void RenderViewImpl::OnPluginActionAt(const gfx::Point& location, |
| 2816 | const WebPluginAction& action) { |
| 2817 | if (webview()) |
| 2818 | webview()->performPluginAction(action, location); |
| 2819 | } |
| 2820 | |
[email protected] | 88f10a2 | 2013-11-06 21:22:12 | [diff] [blame] | 2821 | void RenderViewImpl::OnSuppressDialogsUntilSwapOut() { |
| 2822 | // Don't show any more dialogs until we finish OnSwapOut. |
| 2823 | suppress_dialogs_until_swap_out_ = true; |
| 2824 | } |
| 2825 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2826 | void RenderViewImpl::OnClosePage() { |
[email protected] | 77fc9b9 | 2011-10-15 16:20:37 | [diff] [blame] | 2827 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2828 | // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 2829 | // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 2830 | // in the onunload handler from appearing. For now, we're bypassing that and |
| 2831 | // calling the FrameLoader's CloseURL method directly. This should be |
| 2832 | // revisited to avoid having two ways to close a page. Having a single way |
| 2833 | // to close that can run onunload is also useful for fixing |
| 2834 | // http://b/issue?id=753080. |
[email protected] | 11fd5db | 2014-04-02 03:49:46 | [diff] [blame] | 2835 | webview()->mainFrame()->dispatchUnloadEvent(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2836 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2837 | Send(new ViewHostMsg_ClosePage_ACK(routing_id())); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2838 | } |
| 2839 | |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 2840 | void RenderViewImpl::OnClose() { |
| 2841 | if (closing_) |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 2842 | RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(routing_id())); |
nasko | c288745f | 2015-05-01 22:54:21 | [diff] [blame] | 2843 | RenderWidget::OnClose(); |
| 2844 | } |
| 2845 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2846 | void RenderViewImpl::OnThemeChanged() { |
[email protected] | e8d6b9f | 2011-10-10 22:21:02 | [diff] [blame] | 2847 | #if defined(USE_AURA) |
| 2848 | // Aura doesn't care if we switch themes. |
| 2849 | #elif defined(OS_WIN) |
[email protected] | f78452f | 2012-05-15 02:07:52 | [diff] [blame] | 2850 | ui::NativeThemeWin::instance()->CloseHandles(); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 2851 | if (webview()) |
| 2852 | webview()->themeChanged(); |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 2853 | #else // defined(OS_WIN) |
| 2854 | // TODO(port): we don't support theming on non-Windows platforms yet |
| 2855 | NOTIMPLEMENTED(); |
| 2856 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2857 | } |
| 2858 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2859 | void RenderViewImpl::OnMoveOrResizeStarted() { |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2860 | if (webview()) |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 2861 | webview()->hidePopups(); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2862 | } |
| 2863 | |
[email protected] | 0fdd501 | 2013-05-29 08:05:56 | [diff] [blame] | 2864 | void RenderViewImpl::OnResize(const ViewMsg_Resize_Params& params) { |
[email protected] | 189a886 | 2014-07-18 00:27:53 | [diff] [blame] | 2865 | TRACE_EVENT0("renderer", "RenderViewImpl::OnResize"); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2866 | if (webview()) { |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 2867 | webview()->hidePopups(); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2868 | if (send_preferred_size_changes_) { |
[email protected] | 7339cd2 | 2010-10-27 00:11:20 | [diff] [blame] | 2869 | webview()->mainFrame()->setCanHaveScrollbars( |
[email protected] | 0fdd501 | 2013-05-29 08:05:56 | [diff] [blame] | 2870 | ShouldDisplayScrollbars(params.new_size.width(), |
| 2871 | params.new_size.height())); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2872 | } |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 2873 | if (display_mode_ != params.display_mode) { |
| 2874 | display_mode_ = params.display_mode; |
| 2875 | webview()->setDisplayMode(display_mode_); |
| 2876 | } |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 2877 | } |
| 2878 | |
[email protected] | cbbdeef | 2014-05-26 15:57:36 | [diff] [blame] | 2879 | gfx::Size old_visible_viewport_size = visible_viewport_size_; |
| 2880 | |
[email protected] | 0fdd501 | 2013-05-29 08:05:56 | [diff] [blame] | 2881 | RenderWidget::OnResize(params); |
[email protected] | cbbdeef | 2014-05-26 15:57:36 | [diff] [blame] | 2882 | |
| 2883 | if (old_visible_viewport_size != visible_viewport_size_) |
| 2884 | has_scrolled_focused_editable_node_into_rect_ = false; |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 2885 | } |
[email protected] | 0aa477bd | 2009-03-23 22:21:43 | [diff] [blame] | 2886 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2887 | void RenderViewImpl::DidInitiatePaint() { |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 2888 | #if defined(ENABLE_PLUGINS) |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 2889 | // Notify all instances that we painted. The same caveats apply as for |
| 2890 | // ViewFlushedPaint regarding instances closing themselves, so we take |
| 2891 | // similar precautions. |
| 2892 | PepperPluginSet plugins = active_pepper_instances_; |
| 2893 | for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) { |
| 2894 | if (active_pepper_instances_.find(*i) != active_pepper_instances_.end()) |
| 2895 | (*i)->ViewInitiatedPaint(); |
| 2896 | } |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 2897 | #endif |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2898 | } |
| 2899 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2900 | void RenderViewImpl::DidFlushPaint() { |
[email protected] | 5b1dec8c | 2012-02-07 04:35:38 | [diff] [blame] | 2901 | // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
| 2902 | // See crbug.com/112921. |
| 2903 | if (!webview()) |
| 2904 | return; |
| 2905 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2906 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2907 | for (WebFrame* frame = main_frame; frame; |
| 2908 | frame = frame->traverseNext(false)) { |
pmeenan | dcc725b | 2014-10-22 18:04:11 | [diff] [blame] | 2909 | // TODO(nasko): This is a hack for the case in which the top-level |
| 2910 | // frame is being rendered in another process. It will not |
| 2911 | // behave correctly for out of process iframes. |
| 2912 | if (frame->isWebLocalFrame()) { |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2913 | main_frame = frame; |
pmeenan | dcc725b | 2014-10-22 18:04:11 | [diff] [blame] | 2914 | break; |
| 2915 | } |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2916 | } |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2917 | |
alexmos | 6806d18 | 2015-07-28 00:04:19 | [diff] [blame] | 2918 | // There's nothing to do if there are no local frames in this RenderView's |
| 2919 | // frame tree. This can happen if DidFlushPaint is called after the |
| 2920 | // RenderView's local main frame is swapped to a remote frame. See |
| 2921 | // http://crbug.com/513552. |
| 2922 | if (main_frame->isWebRemoteFrame()) |
| 2923 | return; |
| 2924 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2925 | // If we have a provisional frame we are between the start and commit stages |
| 2926 | // of loading and we don't want to save stats. |
| 2927 | if (!main_frame->provisionalDataSource()) { |
| 2928 | WebDataSource* ds = main_frame->dataSource(); |
enne | 9548660 | 2015-04-30 23:41:10 | [diff] [blame] | 2929 | if (!ds) |
| 2930 | return; |
| 2931 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2932 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
[email protected] | 92d45780 | 2013-04-01 19:18:49 | [diff] [blame] | 2933 | |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2934 | // TODO(jar): The following code should all be inside a method, probably in |
| 2935 | // NavigatorState. |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2936 | Time now = Time::Now(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2937 | if (document_state->first_paint_time().is_null()) { |
| 2938 | document_state->set_first_paint_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2939 | } |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2940 | if (document_state->first_paint_after_load_time().is_null() && |
| 2941 | !document_state->finish_load_time().is_null()) { |
| 2942 | document_state->set_first_paint_after_load_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 2943 | } |
| 2944 | } |
| 2945 | } |
| 2946 | |
[email protected] | ceb36f7d | 2012-10-31 18:33:24 | [diff] [blame] | 2947 | gfx::Vector2d RenderViewImpl::GetScrollOffset() { |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 2948 | WebFrame* main_frame = webview()->mainFrame(); |
| 2949 | for (WebFrame* frame = main_frame; frame; |
| 2950 | frame = frame->traverseNext(false)) { |
| 2951 | // TODO(nasko): This is a hack for the case in which the top-level |
| 2952 | // frame is being rendered in another process. It will not |
| 2953 | // behave correctly for out of process iframes. |
| 2954 | if (frame->isWebLocalFrame()) { |
| 2955 | main_frame = frame; |
| 2956 | break; |
| 2957 | } |
| 2958 | } |
| 2959 | |
| 2960 | WebSize scroll_offset = main_frame->scrollOffset(); |
[email protected] | ceb36f7d | 2012-10-31 18:33:24 | [diff] [blame] | 2961 | return gfx::Vector2d(scroll_offset.width, scroll_offset.height); |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 2962 | } |
| 2963 | |
[email protected] | ab6c911 | 2014-02-27 00:20:58 | [diff] [blame] | 2964 | void RenderViewImpl::OnClearFocusedElement() { |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 2965 | if (webview()) |
[email protected] | ab6c911 | 2014-02-27 00:20:58 | [diff] [blame] | 2966 | webview()->clearFocusedElement(); |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 2967 | } |
| 2968 | |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 2969 | void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) { |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 2970 | if (webview()) |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 2971 | webview()->setIsTransparent(!opaque); |
[email protected] | ba91a79 | 2013-02-06 09:48:28 | [diff] [blame] | 2972 | if (compositor_) |
[email protected] | 61f9183 | 2014-05-13 01:24:42 | [diff] [blame] | 2973 | compositor_->setHasTransparentBackground(!opaque); |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 2974 | } |
| 2975 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2976 | void RenderViewImpl::OnSetActive(bool active) { |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 2977 | if (webview()) |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 2978 | webview()->setIsActive(active); |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 2979 | |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 2980 | #if defined(ENABLE_PLUGINS) && defined(OS_MACOSX) |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 2981 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 2982 | for (plugin_it = plugin_delegates_.begin(); |
| 2983 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 2984 | (*plugin_it)->SetWindowFocus(active); |
| 2985 | } |
| 2986 | #endif |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 2987 | } |
| 2988 | |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 2989 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2990 | void RenderViewImpl::OnSetWindowVisibility(bool visible) { |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 2991 | #if defined(ENABLE_PLUGINS) |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 2992 | // Inform plugins that their container has changed visibility. |
| 2993 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 2994 | for (plugin_it = plugin_delegates_.begin(); |
| 2995 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 2996 | (*plugin_it)->SetContainerVisibility(visible); |
| 2997 | } |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 2998 | #endif |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 2999 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 3000 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3001 | void RenderViewImpl::OnWindowFrameChanged(const gfx::Rect& window_frame, |
| 3002 | const gfx::Rect& view_frame) { |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 3003 | #if defined(ENABLE_PLUGINS) |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 3004 | // Inform plugins that their window's frame has changed. |
| 3005 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 3006 | for (plugin_it = plugin_delegates_.begin(); |
| 3007 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 3008 | (*plugin_it)->WindowFrameChanged(window_frame, view_frame); |
| 3009 | } |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 3010 | #endif |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 3011 | } |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 3012 | |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 3013 | void RenderViewImpl::OnPluginImeCompositionCompleted(const base::string16& text, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3014 | int plugin_id) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 3015 | // WebPluginDelegateProxy is responsible for figuring out if this event |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 3016 | // applies to it or not, so inform all the delegates. |
| 3017 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 3018 | for (plugin_it = plugin_delegates_.begin(); |
| 3019 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 3020 | (*plugin_it)->ImeCompositionCompleted(text, plugin_id); |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 3021 | } |
| 3022 | } |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 3023 | #endif // OS_MACOSX |
| 3024 | |
dcheng | 3ce04b6 | 2015-10-26 23:30:55 | [diff] [blame] | 3025 | void RenderViewImpl::CloseForFrame() { |
| 3026 | DCHECK(frame_widget_); |
| 3027 | frame_widget_->close(); |
| 3028 | frame_widget_ = nullptr; |
| 3029 | } |
| 3030 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3031 | void RenderViewImpl::Close() { |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 3032 | // We need to grab a pointer to the doomed WebView before we destroy it. |
| 3033 | WebView* doomed = webview(); |
| 3034 | RenderWidget::Close(); |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 3035 | g_view_map.Get().erase(doomed); |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3036 | g_routing_id_view_map.Get().erase(routing_id()); |
| 3037 | RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(routing_id())); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 3038 | } |
| 3039 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3040 | void RenderViewImpl::OnWasHidden() { |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 3041 | RenderWidget::OnWasHidden(); |
| 3042 | |
[email protected] | 68877c28 | 2013-09-20 05:52:42 | [diff] [blame] | 3043 | #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 3044 | RenderThreadImpl::current()->video_capture_impl_manager()-> |
| 3045 | SuspendDevices(true); |
[email protected] | e976c3c5 | 2014-07-24 17:41:55 | [diff] [blame] | 3046 | if (speech_recognition_dispatcher_) |
| 3047 | speech_recognition_dispatcher_->AbortAllRecognitions(); |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 3048 | #endif |
[email protected] | 2d7b82c | 2012-06-01 05:57:50 | [diff] [blame] | 3049 | |
[email protected] | 8869d39 | 2013-05-07 15:34:26 | [diff] [blame] | 3050 | if (webview()) |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 3051 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 3052 | |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3053 | #if defined(ENABLE_PLUGINS) |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 3054 | for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); |
| 3055 | i != active_pepper_instances_.end(); ++i) |
| 3056 | (*i)->PageVisibilityChanged(false); |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 3057 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 3058 | #if defined(OS_MACOSX) |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 3059 | // Inform NPAPI plugins that their container is no longer visible. |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 3060 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 3061 | for (plugin_it = plugin_delegates_.begin(); |
| 3062 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 3063 | (*plugin_it)->SetContainerVisibility(false); |
| 3064 | } |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 3065 | #endif // OS_MACOSX |
thestig | 6057a6b2 | 2015-11-12 23:01:33 | [diff] [blame] | 3066 | #endif // ENABLE_PLUGINS |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 3067 | } |
| 3068 | |
[email protected] | 3399dd82 | 2014-08-09 11:14:24 | [diff] [blame] | 3069 | void RenderViewImpl::OnWasShown(bool needs_repainting, |
| 3070 | const ui::LatencyInfo& latency_info) { |
| 3071 | RenderWidget::OnWasShown(needs_repainting, latency_info); |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 3072 | |
[email protected] | 6392d98 | 2013-04-16 16:59:22 | [diff] [blame] | 3073 | #if defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
| 3074 | RenderThreadImpl::current()->video_capture_impl_manager()-> |
| 3075 | SuspendDevices(false); |
| 3076 | #endif |
| 3077 | |
[email protected] | 8869d39 | 2013-05-07 15:34:26 | [diff] [blame] | 3078 | if (webview()) |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 3079 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 3080 | |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3081 | #if defined(ENABLE_PLUGINS) |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 3082 | for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); |
| 3083 | i != active_pepper_instances_.end(); ++i) |
| 3084 | (*i)->PageVisibilityChanged(true); |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 3085 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 3086 | #if defined(OS_MACOSX) |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 3087 | // Inform NPAPI plugins that their container is now visible. |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 3088 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 3089 | for (plugin_it = plugin_delegates_.begin(); |
| 3090 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 3091 | (*plugin_it)->SetContainerVisibility(true); |
| 3092 | } |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 3093 | #endif // OS_MACOSX |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 3094 | #endif // ENABLE_PLUGINS |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 3095 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 3096 | |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 3097 | GURL RenderViewImpl::GetURLForGraphicsContext3D() { |
| 3098 | DCHECK(webview()); |
[email protected] | 82307f6b | 2014-08-07 03:30:12 | [diff] [blame] | 3099 | if (webview()->mainFrame()->isWebLocalFrame()) |
[email protected] | ed7defa | 2013-03-12 21:29:59 | [diff] [blame] | 3100 | return GURL(webview()->mainFrame()->document().url()); |
| 3101 | else |
| 3102 | return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 3103 | } |
| 3104 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3105 | void RenderViewImpl::OnSetFocus(bool enable) { |
nasko | c6edf7e | 2015-10-16 01:48:45 | [diff] [blame] | 3106 | // This message must always be received when the main frame is a |
| 3107 | // WebLocalFrame. |
| 3108 | CHECK(webview()->mainFrame()->isWebLocalFrame()); |
alexmos | 3fcd0ca | 2015-10-23 18:18:33 | [diff] [blame] | 3109 | SetFocus(enable); |
| 3110 | } |
alexmos | 7fac9aeb | 2015-10-16 22:39:49 | [diff] [blame] | 3111 | |
alexmos | 3fcd0ca | 2015-10-23 18:18:33 | [diff] [blame] | 3112 | void RenderViewImpl::SetFocus(bool enable) { |
alexmos | 7fac9aeb | 2015-10-16 22:39:49 | [diff] [blame] | 3113 | has_focus_ = enable; |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 3114 | RenderWidget::OnSetFocus(enable); |
| 3115 | |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 3116 | #if defined(ENABLE_PLUGINS) |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 3117 | if (webview() && webview()->isActive()) { |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 3118 | // Notify all NPAPI plugins. |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 3119 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 3120 | for (plugin_it = plugin_delegates_.begin(); |
| 3121 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 3122 | #if defined(OS_MACOSX) |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 3123 | // RenderWidget's call to setFocus can cause the underlying webview's |
| 3124 | // activation state to change just like a call to setIsActive. |
| 3125 | if (enable) |
| 3126 | (*plugin_it)->SetWindowFocus(true); |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 3127 | #endif |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 3128 | (*plugin_it)->SetContentAreaFocus(enable); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 3129 | } |
| 3130 | } |
[email protected] | a99a3880 | 2014-01-14 15:46:57 | [diff] [blame] | 3131 | // Notify all Pepper plugins. |
| 3132 | for (PepperPluginSet::iterator i = active_pepper_instances_.begin(); |
| 3133 | i != active_pepper_instances_.end(); ++i) |
| 3134 | (*i)->SetContentAreaFocus(enable); |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3135 | #endif |
[email protected] | 32103299 | 2012-11-08 01:01:27 | [diff] [blame] | 3136 | // Notify all BrowserPlugins of the RenderView's focus state. |
fsamuel | 6c1dfeb | 2014-12-18 19:21:33 | [diff] [blame] | 3137 | if (BrowserPluginManager::Get()) |
| 3138 | BrowserPluginManager::Get()->UpdateFocusState(); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 3139 | } |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 3140 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3141 | void RenderViewImpl::OnImeSetComposition( |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 3142 | const base::string16& text, |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 3143 | const std::vector<blink::WebCompositionUnderline>& underlines, |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 3144 | int selection_start, |
| 3145 | int selection_end) { |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3146 | #if defined(ENABLE_PLUGINS) |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 3147 | if (focused_pepper_plugin_) { |
| 3148 | focused_pepper_plugin_->render_frame()->OnImeSetComposition( |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 3149 | text, underlines, selection_start, selection_end); |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3150 | return; |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 3151 | } |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3152 | |
| 3153 | #if defined(OS_WIN) |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 3154 | // When a plugin has focus, we create platform-specific IME data used by |
| 3155 | // our IME emulator and send it directly to the focused plugin, i.e. we |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3156 | // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its |
| 3157 | // instance ID is the same one as the specified ID.) |
| 3158 | if (focused_plugin_id_ >= 0) { |
| 3159 | std::vector<int> clauses; |
| 3160 | std::vector<int> target; |
| 3161 | for (size_t i = 0; i < underlines.size(); ++i) { |
| 3162 | clauses.push_back(underlines[i].startOffset); |
| 3163 | clauses.push_back(underlines[i].endOffset); |
| 3164 | if (underlines[i].thick) { |
| 3165 | target.clear(); |
| 3166 | target.push_back(underlines[i].startOffset); |
| 3167 | target.push_back(underlines[i].endOffset); |
| 3168 | } |
| 3169 | } |
| 3170 | std::set<WebPluginDelegateProxy*>::iterator it; |
| 3171 | for (it = plugin_delegates_.begin(); it != plugin_delegates_.end(); ++it) { |
| 3172 | (*it)->ImeCompositionUpdated(text, clauses, target, selection_end, |
| 3173 | focused_plugin_id_); |
| 3174 | } |
| 3175 | return; |
| 3176 | } |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 3177 | #endif // OS_WIN |
| 3178 | #endif // ENABLE_PLUGINS |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3179 | RenderWidget::OnImeSetComposition(text, |
| 3180 | underlines, |
| 3181 | selection_start, |
| 3182 | selection_end); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 3183 | } |
| 3184 | |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 3185 | void RenderViewImpl::OnImeConfirmComposition( |
[email protected] | fcf75d4 | 2013-12-03 20:11:26 | [diff] [blame] | 3186 | const base::string16& text, |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 3187 | const gfx::Range& replacement_range, |
| 3188 | bool keep_selection) { |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3189 | #if defined(ENABLE_PLUGINS) |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 3190 | if (focused_pepper_plugin_) { |
| 3191 | focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( |
[email protected] | 7a4e253 | 2013-12-02 21:30:02 | [diff] [blame] | 3192 | text, replacement_range, keep_selection); |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3193 | return; |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 3194 | } |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3195 | #if defined(OS_WIN) |
| 3196 | // Same as OnImeSetComposition(), we send the text from IMEs directly to |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 3197 | // plugins. When we send IME text directly to plugins, we should not send |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3198 | // it to WebKit to prevent WebKit from controlling IMEs. |
| 3199 | // TODO(thakis): Honor |replacement_range| for plugins? |
| 3200 | if (focused_plugin_id_ >= 0) { |
| 3201 | std::set<WebPluginDelegateProxy*>::iterator it; |
| 3202 | for (it = plugin_delegates_.begin(); |
| 3203 | it != plugin_delegates_.end(); ++it) { |
| 3204 | (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
| 3205 | } |
| 3206 | return; |
| 3207 | } |
[email protected] | a80af12e | 2013-08-07 23:36:13 | [diff] [blame] | 3208 | #endif // OS_WIN |
| 3209 | #endif // ENABLE_PLUGINS |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3210 | if (replacement_range.IsValid() && webview()) { |
| 3211 | // Select the text in |replacement_range|, it will then be replaced by |
| 3212 | // text added by the call to RenderWidget::OnImeConfirmComposition(). |
[email protected] | 35b2a97 | 2014-04-04 15:50:22 | [diff] [blame] | 3213 | if (WebLocalFrame* frame = webview()->focusedFrame()->toWebLocalFrame()) { |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3214 | WebRange webrange = WebRange::fromDocumentRange( |
| 3215 | frame, replacement_range.start(), replacement_range.length()); |
| 3216 | if (!webrange.isNull()) |
| 3217 | frame->selectRange(webrange); |
| 3218 | } |
| 3219 | } |
| 3220 | RenderWidget::OnImeConfirmComposition(text, |
| 3221 | replacement_range, |
| 3222 | keep_selection); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 3223 | } |
| 3224 | |
[email protected] | 28ed6b3 | 2014-06-08 02:16:27 | [diff] [blame] | 3225 | bool RenderViewImpl::SetDeviceColorProfile( |
| 3226 | const std::vector<char>& profile) { |
| 3227 | bool changed = RenderWidget::SetDeviceColorProfile(profile); |
| 3228 | if (changed && webview()) { |
noel | c76aa4c | 2014-09-25 01:08:56 | [diff] [blame] | 3229 | WebVector<char> colorProfile = profile; |
| 3230 | webview()->setDeviceColorProfile(colorProfile); |
[email protected] | 28ed6b3 | 2014-06-08 02:16:27 | [diff] [blame] | 3231 | } |
| 3232 | return changed; |
| 3233 | } |
| 3234 | |
noel | db4df15 | 2014-09-16 17:45:20 | [diff] [blame] | 3235 | void RenderViewImpl::ResetDeviceColorProfileForTesting() { |
| 3236 | RenderWidget::ResetDeviceColorProfileForTesting(); |
| 3237 | if (webview()) |
dominicc | 0b4687b | 2015-11-24 20:08:35 | [diff] [blame] | 3238 | webview()->resetDeviceColorProfileForTesting(); |
noel | db4df15 | 2014-09-16 17:45:20 | [diff] [blame] | 3239 | } |
| 3240 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3241 | ui::TextInputType RenderViewImpl::GetTextInputType() { |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3242 | #if defined(ENABLE_PLUGINS) |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 3243 | if (focused_pepper_plugin_) |
| 3244 | return focused_pepper_plugin_->text_input_type(); |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3245 | #endif |
| 3246 | return RenderWidget::GetTextInputType(); |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 3247 | } |
| 3248 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 3249 | void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3250 | #if defined(ENABLE_PLUGINS) |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 3251 | if (focused_pepper_plugin_) { |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 3252 | // TODO(kinaba) http://crbug.com/101101 |
| 3253 | // Current Pepper IME API does not handle selection bounds. So we simply |
| 3254 | // use the caret position as an empty range for now. It will be updated |
| 3255 | // after Pepper API equips features related to surrounding text retrieval. |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 3256 | blink::WebRect caret(focused_pepper_plugin_->GetCaretBounds()); |
| 3257 | convertViewportToWindow(&caret); |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 3258 | *start = caret; |
| 3259 | *end = caret; |
| 3260 | return; |
| 3261 | } |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3262 | #endif |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 3263 | RenderWidget::GetSelectionBounds(start, end); |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 3264 | } |
| 3265 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 3266 | void RenderViewImpl::GetCompositionCharacterBounds( |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 3267 | std::vector<gfx::Rect>* bounds_in_window) { |
| 3268 | DCHECK(bounds_in_window); |
| 3269 | bounds_in_window->clear(); |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 3270 | |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3271 | #if defined(ENABLE_PLUGINS) |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 3272 | if (focused_pepper_plugin_) { |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 3273 | return; |
| 3274 | } |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3275 | #endif |
| 3276 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 3277 | if (!webview()) |
| 3278 | return; |
| 3279 | size_t start_offset = 0; |
| 3280 | size_t character_count = 0; |
| 3281 | if (!webview()->compositionRange(&start_offset, &character_count)) |
| 3282 | return; |
| 3283 | if (character_count == 0) |
| 3284 | return; |
| 3285 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 3286 | blink::WebFrame* frame = webview()->focusedFrame(); |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 3287 | if (!frame) |
| 3288 | return; |
| 3289 | |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 3290 | bounds_in_window->reserve(character_count); |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 3291 | blink::WebRect webrect; |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 3292 | for (size_t i = 0; i < character_count; ++i) { |
| 3293 | if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { |
| 3294 | DLOG(ERROR) << "Could not retrieve character rectangle at " << i; |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 3295 | bounds_in_window->clear(); |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 3296 | return; |
| 3297 | } |
oshima | 33ec97cd | 2015-12-14 19:40:24 | [diff] [blame] | 3298 | convertViewportToWindow(&webrect); |
| 3299 | bounds_in_window->push_back(webrect); |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 3300 | } |
| 3301 | } |
| 3302 | |
[email protected] | db4fc1e | 2013-09-06 20:01:51 | [diff] [blame] | 3303 | void RenderViewImpl::GetCompositionRange(gfx::Range* range) { |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3304 | #if defined(ENABLE_PLUGINS) |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 3305 | if (focused_pepper_plugin_) { |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 3306 | return; |
| 3307 | } |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3308 | #endif |
[email protected] | 88dbe32f | 2013-06-20 23:31:36 | [diff] [blame] | 3309 | RenderWidget::GetCompositionRange(range); |
| 3310 | } |
| 3311 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3312 | bool RenderViewImpl::CanComposeInline() { |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3313 | #if defined(ENABLE_PLUGINS) |
[email protected] | e16c7a1 | 2013-12-05 16:30:08 | [diff] [blame] | 3314 | if (focused_pepper_plugin_) |
| 3315 | return focused_pepper_plugin_->IsPluginAcceptingCompositionEvents(); |
[email protected] | ea2fb97 | 2013-08-07 05:44:26 | [diff] [blame] | 3316 | #endif |
| 3317 | return true; |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 3318 | } |
| 3319 | |
rouslan | f7ebd883 | 2015-01-22 01:54:14 | [diff] [blame] | 3320 | void RenderViewImpl::DidCompletePageScaleAnimation() { |
| 3321 | FocusChangeComplete(); |
| 3322 | } |
| 3323 | |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 3324 | void RenderViewImpl::OnDeviceScaleFactorChanged() { |
| 3325 | RenderWidget::OnDeviceScaleFactorChanged(); |
| 3326 | UpdateWebViewWithDeviceScaleFactor(); |
| 3327 | if (auto_resize_mode_) |
| 3328 | AutoResizeCompositor(); |
| 3329 | } |
| 3330 | |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 3331 | void RenderViewImpl::SetScreenMetricsEmulationParameters( |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 3332 | bool enabled, |
| 3333 | const blink::WebDeviceEmulationParams& params) { |
[email protected] | 404630b | 2014-07-03 19:33:03 | [diff] [blame] | 3334 | if (webview() && compositor()) { |
dgozman | 9260b0a1 | 2015-03-16 13:45:20 | [diff] [blame] | 3335 | if (enabled) |
| 3336 | webview()->enableDeviceEmulation(params); |
| 3337 | else |
| 3338 | webview()->disableDeviceEmulation(); |
[email protected] | b2e4c7013 | 2013-10-03 02:07:51 | [diff] [blame] | 3339 | } |
| 3340 | } |
| 3341 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3342 | bool RenderViewImpl::ScheduleFileChooser( |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 3343 | const FileChooserParams& params, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 3344 | WebFileChooserCompletion* completion) { |
| 3345 | static const size_t kMaximumPendingFileChooseRequests = 4; |
| 3346 | if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { |
| 3347 | // This sanity check prevents too many file choose requests from getting |
| 3348 | // queued which could DoS the user. Getting these is most likely a |
| 3349 | // programming error (there are many ways to DoS the user so it's not |
| 3350 | // considered a "real" security check), either in JS requesting many file |
| 3351 | // choosers to pop up, or in a plugin. |
| 3352 | // |
| 3353 | // TODO(brettw) we might possibly want to require a user gesture to open |
| 3354 | // a file picker, which will address this issue in a better way. |
| 3355 | return false; |
| 3356 | } |
| 3357 | |
limasdf | 81d962e | 2015-11-20 08:39:18 | [diff] [blame] | 3358 | file_chooser_completions_.push_back( |
| 3359 | make_scoped_ptr(new PendingFileChooser(params, completion))); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 3360 | if (file_chooser_completions_.size() == 1) { |
| 3361 | // Actually show the browse dialog when this is the first request. |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3362 | Send(new ViewHostMsg_RunFileChooser(routing_id(), params)); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 3363 | } |
| 3364 | return true; |
| 3365 | } |
| 3366 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 3367 | blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 3368 | if (!speech_recognition_dispatcher_) |
| 3369 | speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 3370 | return speech_recognition_dispatcher_; |
| 3371 | } |
| 3372 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3373 | void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
| 3374 | double maximum_level) { |
a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 3375 | // Round the double to avoid returning incorrect minimum/maximum zoom |
| 3376 | // percentages. |
| 3377 | int minimum_percent = round( |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 3378 | ZoomLevelToZoomFactor(minimum_level) * 100); |
a.sarkar.arun | daadc71 | 2015-02-26 05:39:08 | [diff] [blame] | 3379 | int maximum_percent = round( |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 3380 | ZoomLevelToZoomFactor(maximum_level) * 100); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3381 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3382 | Send(new ViewHostMsg_UpdateZoomLimits(routing_id(), minimum_percent, |
| 3383 | maximum_percent)); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3384 | } |
| 3385 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3386 | void RenderViewImpl::zoomLevelChanged() { |
[email protected] | 54b8e18 | 2014-05-02 18:08:29 | [diff] [blame] | 3387 | double zoom_level = webview()->zoomLevel(); |
[email protected] | 2b942c33 | 2012-04-25 16:26:26 | [diff] [blame] | 3388 | |
[email protected] | 54b8e18 | 2014-05-02 18:08:29 | [diff] [blame] | 3389 | // Do not send empty URLs to the browser when we are just setting the default |
| 3390 | // zoom level (from RendererPreferences) before the first navigation. |
| 3391 | if (!webview()->mainFrame()->document().url().isEmpty()) { |
| 3392 | // Tell the browser which url got zoomed so it can update the menu and the |
| 3393 | // saved values if necessary |
| 3394 | Send(new ViewHostMsg_DidZoomURL( |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3395 | routing_id(), zoom_level, |
[email protected] | 54b8e18 | 2014-05-02 18:08:29 | [diff] [blame] | 3396 | GURL(webview()->mainFrame()->document().url()))); |
| 3397 | } |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3398 | } |
| 3399 | |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 3400 | void RenderViewImpl::pageScaleFactorChanged() { |
| 3401 | if (!webview()) |
| 3402 | return; |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 3403 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3404 | Send(new ViewHostMsg_PageScaleFactorChanged(routing_id(), |
mcnee | 432e47d | 2015-11-09 19:37:46 | [diff] [blame] | 3405 | webview()->pageScaleFactor())); |
ccameron | b7c1d6c | 2015-03-09 17:08:24 | [diff] [blame] | 3406 | } |
| 3407 | |
[email protected] | 7940b8e | 2013-07-25 23:08:49 | [diff] [blame] | 3408 | double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const { |
| 3409 | return ZoomLevelToZoomFactor(zoom_level); |
| 3410 | } |
| 3411 | |
| 3412 | double RenderViewImpl::zoomFactorToZoomLevel(double factor) const { |
| 3413 | return ZoomFactorToZoomLevel(factor); |
| 3414 | } |
| 3415 | |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 3416 | blink::WebPageVisibilityState RenderViewImpl::visibilityState() const { |
| 3417 | blink::WebPageVisibilityState current_state = is_hidden() ? |
| 3418 | blink::WebPageVisibilityStateHidden : |
| 3419 | blink::WebPageVisibilityStateVisible; |
| 3420 | blink::WebPageVisibilityState override_state = current_state; |
[email protected] | b849847b | 2013-12-10 21:57:58 | [diff] [blame] | 3421 | // TODO(jam): move this method to WebFrameClient. |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 3422 | if (GetContentClient()->renderer()-> |
nasko | 77de231 | 2015-05-12 03:09:16 | [diff] [blame] | 3423 | ShouldOverridePageVisibilityState(main_render_frame_, |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 3424 | &override_state)) |
| 3425 | return override_state; |
| 3426 | return current_state; |
[email protected] | 94dec93 | 2011-05-26 20:04:21 | [diff] [blame] | 3427 | } |
| 3428 | |
[email protected] | a0629af9 | 2012-08-08 00:39:37 | [diff] [blame] | 3429 | void RenderViewImpl::draggableRegionsChanged() { |
| 3430 | FOR_EACH_OBSERVER( |
| 3431 | RenderViewObserver, |
| 3432 | observers_, |
| 3433 | DraggableRegionsChanged(webview()->mainFrame())); |
| 3434 | } |
| 3435 | |
kouhei | 40f03cb | 2015-09-24 07:47:01 | [diff] [blame] | 3436 | void RenderViewImpl::pageImportanceSignalsChanged() { |
| 3437 | if (!webview() || !main_render_frame_) |
| 3438 | return; |
| 3439 | |
| 3440 | const auto& web_signals = webview()->pageImportanceSignals(); |
| 3441 | |
| 3442 | PageImportanceSignals signals; |
| 3443 | signals.had_form_interaction = web_signals->hadFormInteraction(); |
| 3444 | |
| 3445 | main_render_frame_->Send(new FrameHostMsg_UpdatePageImportanceSignals( |
| 3446 | main_render_frame_->GetRoutingID(), signals)); |
| 3447 | } |
| 3448 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3449 | #if defined(OS_ANDROID) |
| 3450 | WebContentDetectionResult RenderViewImpl::detectContentAround( |
| 3451 | const WebHitTestResult& touch_hit) { |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3452 | DCHECK(touch_hit.node().isTextNode()); |
| 3453 | |
| 3454 | // Process the position with all the registered content detectors until |
| 3455 | // a match is found. Priority is provided by their relative order. |
limasdf | 81d962e | 2015-11-20 08:39:18 | [diff] [blame] | 3456 | for (const auto& detector : content_detectors_) { |
| 3457 | ContentDetector::Result content = detector->FindTappedContent(touch_hit); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3458 | if (content.valid) { |
| 3459 | return WebContentDetectionResult(content.content_boundaries, |
[email protected] | 3295612 | 2013-12-25 07:29:24 | [diff] [blame] | 3460 | base::UTF8ToUTF16(content.text), content.intent_url); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3461 | } |
| 3462 | } |
| 3463 | return WebContentDetectionResult(); |
| 3464 | } |
| 3465 | |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 3466 | void RenderViewImpl::scheduleContentIntent(const WebURL& intent, |
| 3467 | bool is_main_frame) { |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3468 | // Introduce a short delay so that the user can notice the content. |
[email protected] | dd32b127 | 2013-05-04 14:17:11 | [diff] [blame] | 3469 | base::MessageLoop::current()->PostDelayedTask( |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3470 | FROM_HERE, |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 3471 | base::Bind(&RenderViewImpl::LaunchAndroidContentIntent, AsWeakPtr(), |
| 3472 | intent, expected_content_intent_id_, is_main_frame), |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3473 | base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds)); |
| 3474 | } |
| 3475 | |
| 3476 | void RenderViewImpl::cancelScheduledContentIntents() { |
| 3477 | ++expected_content_intent_id_; |
| 3478 | } |
| 3479 | |
| 3480 | void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 3481 | size_t request_id, |
| 3482 | bool is_main_frame) { |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3483 | if (request_id != expected_content_intent_id_) |
qinmin | 0d5560df | 2014-11-12 19:03:39 | [diff] [blame] | 3484 | return; |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3485 | |
| 3486 | // Remove the content highlighting if any. |
jdduke | 491a3f0c | 2015-06-15 23:30:26 | [diff] [blame] | 3487 | ScheduleComposite(); |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3488 | |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 3489 | if (!intent.is_empty()) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3490 | Send(new ViewHostMsg_StartContentIntent(routing_id(), intent, |
| 3491 | is_main_frame)); |
mnaganov | 42d9e37 | 2015-11-02 23:27:41 | [diff] [blame] | 3492 | } |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3493 | } |
[email protected] | b18583c | 2012-12-18 06:55:27 | [diff] [blame] | 3494 | |
| 3495 | bool RenderViewImpl::openDateTimeChooser( |
[email protected] | 180ef24 | 2013-11-07 06:50:46 | [diff] [blame] | 3496 | const blink::WebDateTimeChooserParams& params, |
| 3497 | blink::WebDateTimeChooserCompletion* completion) { |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 3498 | // JavaScript may try to open a date time chooser while one is already open. |
| 3499 | if (date_time_picker_client_) |
| 3500 | return false; |
[email protected] | b18583c | 2012-12-18 06:55:27 | [diff] [blame] | 3501 | date_time_picker_client_.reset( |
| 3502 | new RendererDateTimePicker(this, params, completion)); |
| 3503 | return date_time_picker_client_->Open(); |
| 3504 | } |
| 3505 | |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 3506 | void RenderViewImpl::DismissDateTimeDialog() { |
| 3507 | DCHECK(date_time_picker_client_); |
| 3508 | date_time_picker_client_.reset(NULL); |
| 3509 | } |
[email protected] | e807256 | 2013-12-04 06:04:13 | [diff] [blame] | 3510 | |
[email protected] | 6d17f639 | 2012-12-05 05:24:54 | [diff] [blame] | 3511 | #endif // defined(OS_ANDROID) |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 3512 | |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 3513 | void RenderViewImpl::OnShowContextMenu( |
| 3514 | ui::MenuSourceType source_type, const gfx::Point& location) { |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3515 | input_handler_->set_context_menu_source_type(source_type); |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 3516 | has_host_context_menu_location_ = true; |
| 3517 | host_context_menu_location_ = location; |
[email protected] | 4782226 | 2013-04-23 17:22:36 | [diff] [blame] | 3518 | if (webview()) |
| 3519 | webview()->showContextMenu(); |
[email protected] | be1af066 | 2014-07-29 19:55:51 | [diff] [blame] | 3520 | has_host_context_menu_location_ = false; |
[email protected] | 4782226 | 2013-04-23 17:22:36 | [diff] [blame] | 3521 | } |
| 3522 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3523 | void RenderViewImpl::OnEnableViewSourceMode() { |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 3524 | if (!webview()) |
| 3525 | return; |
| 3526 | WebFrame* main_frame = webview()->mainFrame(); |
| 3527 | if (!main_frame) |
| 3528 | return; |
| 3529 | main_frame->enableViewSourceMode(true); |
| 3530 | } |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 3531 | |
sadrul | 90f88a9b | 2015-06-16 16:22:04 | [diff] [blame] | 3532 | #if defined(OS_ANDROID) || defined(USE_AURA) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3533 | bool RenderViewImpl::didTapMultipleTargets( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 3534 | const WebSize& inner_viewport_offset, |
| 3535 | const WebRect& touch_rect, |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3536 | const WebVector<WebRect>& target_rects) { |
mustaq | 35bb250b | 2015-05-06 21:22:39 | [diff] [blame] | 3537 | DCHECK(switches::IsLinkDisambiguationPopupEnabled()); |
luken | e23094a | 2014-11-23 14:12:31 | [diff] [blame] | 3538 | |
[email protected] | 8d3dfee6 | 2013-06-19 05:50:33 | [diff] [blame] | 3539 | // Never show a disambiguation popup when accessibility is enabled, |
| 3540 | // as this interferes with "touch exploration". |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 3541 | AccessibilityMode accessibility_mode = |
mostynb | c3335323 | 2014-09-12 09:38:31 | [diff] [blame] | 3542 | GetMainRenderFrame()->accessibility_mode(); |
[email protected] | 9564021 | 2014-07-26 18:14:30 | [diff] [blame] | 3543 | bool matches_accessibility_mode_complete = |
| 3544 | (accessibility_mode & AccessibilityModeComplete) == |
| 3545 | AccessibilityModeComplete; |
| 3546 | if (matches_accessibility_mode_complete) |
[email protected] | 8d3dfee6 | 2013-06-19 05:50:33 | [diff] [blame] | 3547 | return false; |
| 3548 | |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 3549 | // The touch_rect, target_rects and zoom_rect are in the outer viewport |
| 3550 | // reference frame. |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3551 | gfx::Rect zoom_rect; |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 3552 | float new_total_scale = |
| 3553 | DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 3554 | touch_rect, target_rects, GetSize(), |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 3555 | gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(), |
| 3556 | device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect); |
jbauman | 0ed0918 | 2015-01-30 22:33:49 | [diff] [blame] | 3557 | if (!new_total_scale || zoom_rect.IsEmpty()) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3558 | return false; |
| 3559 | |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 3560 | bool handled = false; |
| 3561 | switch (renderer_preferences_.tap_multiple_targets_strategy) { |
| 3562 | case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM: |
| 3563 | handled = webview()->zoomToMultipleTargetsRect(zoom_rect); |
| 3564 | break; |
| 3565 | case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: { |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 3566 | gfx::Size canvas_size = |
danakj | ddaec91 | 2015-09-25 19:38:40 | [diff] [blame] | 3567 | gfx::ScaleToCeiledSize(zoom_rect.size(), new_total_scale); |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 3568 | cc::SharedBitmapManager* manager = |
| 3569 | RenderThreadImpl::current()->shared_bitmap_manager(); |
| 3570 | scoped_ptr<cc::SharedBitmap> shared_bitmap = |
| 3571 | manager->AllocateSharedBitmap(canvas_size); |
jbauman | 0ed0918 | 2015-01-30 22:33:49 | [diff] [blame] | 3572 | CHECK(!!shared_bitmap); |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 3573 | { |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 3574 | SkBitmap bitmap; |
| 3575 | SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(), |
| 3576 | canvas_size.height()); |
| 3577 | bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes()); |
| 3578 | SkCanvas canvas(bitmap); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3579 | |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 3580 | // TODO(trchen): Cleanup the device scale factor mess. |
| 3581 | // device scale will be applied in WebKit |
| 3582 | // --> zoom_rect doesn't include device scale, |
| 3583 | // but WebKit will still draw on zoom_rect * device_scale_factor_ |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 3584 | canvas.scale(new_total_scale / device_scale_factor_, |
| 3585 | new_total_scale / device_scale_factor_); |
| 3586 | canvas.translate(-zoom_rect.x() * device_scale_factor_, |
| 3587 | -zoom_rect.y() * device_scale_factor_); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3588 | |
[email protected] | bcb1f02 | 2014-05-06 01:54:17 | [diff] [blame] | 3589 | DCHECK(webwidget_->isAcceleratedCompositingActive()); |
| 3590 | // TODO(aelias): The disambiguation popup should be composited so we |
| 3591 | // don't have to call this method. |
| 3592 | webwidget_->paintCompositedDeprecated(&canvas, zoom_rect); |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 3593 | } |
| 3594 | |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 3595 | gfx::Rect zoom_rect_in_screen = |
| 3596 | zoom_rect - gfx::Vector2d(inner_viewport_offset.width, |
| 3597 | inner_viewport_offset.height); |
| 3598 | |
[email protected] | bc2804d | 2013-08-06 07:45:49 | [diff] [blame] | 3599 | gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect( |
timav | 29a8d0f6 | 2014-09-25 20:45:53 | [diff] [blame] | 3600 | ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect_in_screen))); |
| 3601 | |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3602 | Send(new ViewHostMsg_ShowDisambiguationPopup( |
| 3603 | routing_id(), physical_window_zoom_rect, canvas_size, |
| 3604 | shared_bitmap->id())); |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 3605 | cc::SharedBitmapId id = shared_bitmap->id(); |
| 3606 | disambiguation_bitmaps_[id] = shared_bitmap.release(); |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 3607 | handled = true; |
| 3608 | break; |
| 3609 | } |
| 3610 | case TAP_MULTIPLE_TARGETS_STRATEGY_NONE: |
| 3611 | // No-op. |
| 3612 | break; |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3613 | } |
[email protected] | 70221f0 | 2013-01-31 22:17:07 | [diff] [blame] | 3614 | |
[email protected] | 4ded1dbf | 2013-08-28 21:11:03 | [diff] [blame] | 3615 | return handled; |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3616 | } |
sadrul | 90f88a9b | 2015-06-16 16:22:04 | [diff] [blame] | 3617 | #endif // defined(OS_ANDROID) || defined(USE_AURA) |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3618 | |
[email protected] | b283d29 | 2013-02-21 08:40:34 | [diff] [blame] | 3619 | unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const { |
| 3620 | return history_list_length_; |
| 3621 | } |
| 3622 | |
[email protected] | cc290f90 | 2013-03-04 20:06:02 | [diff] [blame] | 3623 | void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) { |
| 3624 | if (enable) { |
| 3625 | if (has_focus()) |
| 3626 | return; |
| 3627 | OnSetActive(true); |
| 3628 | OnSetFocus(true); |
| 3629 | } else { |
| 3630 | if (!has_focus()) |
| 3631 | return; |
| 3632 | OnSetFocus(false); |
| 3633 | OnSetActive(false); |
| 3634 | } |
| 3635 | } |
| 3636 | |
[email protected] | 3a1c8a803 | 2013-03-18 22:35:32 | [diff] [blame] | 3637 | void RenderViewImpl::SetDeviceScaleFactorForTesting(float factor) { |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 3638 | ViewMsg_Resize_Params params; |
| 3639 | params.screen_info = screen_info_; |
| 3640 | params.screen_info.deviceScaleFactor = factor; |
| 3641 | params.new_size = size(); |
bokan | f0fd241 | 2014-10-30 15:28:55 | [diff] [blame] | 3642 | params.visible_viewport_size = visible_viewport_size_; |
danakj | ddaec91 | 2015-09-25 19:38:40 | [diff] [blame] | 3643 | params.physical_backing_size = gfx::ScaleToCeiledSize(size(), factor); |
dtrainor | cb7779b8 | 2014-12-04 01:08:02 | [diff] [blame] | 3644 | params.top_controls_shrink_blink_size = false; |
| 3645 | params.top_controls_height = 0.f; |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 3646 | params.resizer_rect = WebRect(); |
mikhail.pozdnyakov | f2c902a | 2015-04-14 08:09:12 | [diff] [blame] | 3647 | params.is_fullscreen_granted = is_fullscreen_granted(); |
mikhail.pozdnyakov | c0e251b | 2015-04-15 06:51:12 | [diff] [blame] | 3648 | params.display_mode = display_mode_; |
[email protected] | b54fe45 | 2013-06-07 14:01:53 | [diff] [blame] | 3649 | OnResize(params); |
[email protected] | 3a1c8a803 | 2013-03-18 22:35:32 | [diff] [blame] | 3650 | } |
| 3651 | |
[email protected] | 71e65230 | 2014-05-09 14:20:13 | [diff] [blame] | 3652 | void RenderViewImpl::SetDeviceColorProfileForTesting( |
| 3653 | const std::vector<char>& color_profile) { |
[email protected] | 28ed6b3 | 2014-06-08 02:16:27 | [diff] [blame] | 3654 | SetDeviceColorProfile(color_profile); |
[email protected] | 71e65230 | 2014-05-09 14:20:13 | [diff] [blame] | 3655 | } |
| 3656 | |
[email protected] | 9265016 | 2013-10-30 03:31:02 | [diff] [blame] | 3657 | void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) { |
bokan | c007c3a | 2015-02-03 07:15:56 | [diff] [blame] | 3658 | gfx::Rect new_window_rect(rootWindowRect().x, |
| 3659 | rootWindowRect().y, |
| 3660 | new_size.width(), |
| 3661 | new_size.height()); |
| 3662 | SetWindowRectSynchronously(new_window_rect); |
[email protected] | 9265016 | 2013-10-30 03:31:02 | [diff] [blame] | 3663 | } |
| 3664 | |
[email protected] | 5b45ad4 | 2013-10-25 00:42:04 | [diff] [blame] | 3665 | void RenderViewImpl::UseSynchronousResizeModeForTesting(bool enable) { |
| 3666 | resizing_mode_selector_->set_is_synchronous_mode(enable); |
| 3667 | } |
| 3668 | |
[email protected] | eac2b36 | 2013-05-22 07:01:45 | [diff] [blame] | 3669 | void RenderViewImpl::EnableAutoResizeForTesting(const gfx::Size& min_size, |
| 3670 | const gfx::Size& max_size) { |
| 3671 | OnEnableAutoResize(min_size, max_size); |
| 3672 | } |
| 3673 | |
| 3674 | void RenderViewImpl::DisableAutoResizeForTesting(const gfx::Size& new_size) { |
| 3675 | OnDisableAutoResize(new_size); |
| 3676 | } |
| 3677 | |
[email protected] | cb189e06 | 2014-04-23 00:57:01 | [diff] [blame] | 3678 | void RenderViewImpl::OnReleaseDisambiguationPopupBitmap( |
| 3679 | const cc::SharedBitmapId& id) { |
| 3680 | BitmapMap::iterator it = disambiguation_bitmaps_.find(id); |
| 3681 | DCHECK(it != disambiguation_bitmaps_.end()); |
| 3682 | delete it->second; |
| 3683 | disambiguation_bitmaps_.erase(it); |
[email protected] | f9526d1 | 2012-10-18 01:55:03 | [diff] [blame] | 3684 | } |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 3685 | |
[email protected] | 6fceb91 | 2013-02-15 06:24:15 | [diff] [blame] | 3686 | void RenderViewImpl::DidCommitCompositorFrame() { |
| 3687 | RenderWidget::DidCommitCompositorFrame(); |
| 3688 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame()); |
| 3689 | } |
| 3690 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3691 | void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) { |
| 3692 | if (!urls.empty()) |
fsamuel | e8326c74 | 2016-01-12 00:49:39 | [diff] [blame] | 3693 | Send(new ViewHostMsg_UpdateFaviconURL(routing_id(), urls)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3694 | } |
| 3695 | |
| 3696 | void RenderViewImpl::DidStopLoadingIcons() { |
huangs | dde9aceb | 2015-03-17 21:26:16 | [diff] [blame] | 3697 | int icon_types = WebIconURL::TypeFavicon | WebIconURL::TypeTouchPrecomposed | |
| 3698 | WebIconURL::TypeTouch; |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3699 | |
nasko | 2411ba37 | 2014-10-13 17:45:41 | [diff] [blame] | 3700 | // Favicons matter only for the top-level frame. If it is a WebRemoteFrame, |
| 3701 | // just return early. |
| 3702 | if (webview()->mainFrame()->isWebRemoteFrame()) |
| 3703 | return; |
| 3704 | |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3705 | WebVector<WebIconURL> icon_urls = |
| 3706 | webview()->mainFrame()->iconURLs(icon_types); |
| 3707 | |
| 3708 | std::vector<FaviconURL> urls; |
| 3709 | for (size_t i = 0; i < icon_urls.size(); i++) { |
| 3710 | WebURL url = icon_urls[i].iconURL(); |
[email protected] | 2bd262b | 2014-04-16 05:31:23 | [diff] [blame] | 3711 | std::vector<gfx::Size> sizes; |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 3712 | ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3713 | if (!url.isEmpty()) |
[email protected] | f34ac13 | 2014-03-20 23:02:05 | [diff] [blame] | 3714 | urls.push_back( |
| 3715 | FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes)); |
[email protected] | 41225fe | 2013-03-29 05:32:02 | [diff] [blame] | 3716 | } |
| 3717 | SendUpdateFaviconURL(urls); |
| 3718 | } |
| 3719 | |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 3720 | void RenderViewImpl::UpdateWebViewWithDeviceScaleFactor() { |
| 3721 | if (!webview()) |
| 3722 | return; |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 3723 | if (IsUseZoomForDSFEnabled()) { |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 3724 | webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_); |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 3725 | } else { |
| 3726 | webview()->setDeviceScaleFactor(device_scale_factor_); |
| 3727 | } |
oshima | d527903 | 2015-12-16 18:22:33 | [diff] [blame] | 3728 | webview()->settings()->setPreferCompositingToLCDTextEnabled( |
| 3729 | PreferCompositingToLCDText(compositor_deps_, device_scale_factor_)); |
oshima | 750cb434 | 2015-10-31 00:59:01 | [diff] [blame] | 3730 | } |
| 3731 | |
[email protected] | e9ff79c | 2012-10-19 21:31:26 | [diff] [blame] | 3732 | } // namespace content |