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