blob: 42fc1eb2c8ad1f72481875b43052f7309dc4e589 [file] [log] [blame]
[email protected]b553edd52012-01-10 12:15:231// Copyright (c) 2012 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
[email protected]310ebd6302011-10-10 19:06:285#include "content/renderer/render_view_impl.h"
initial.commit09911bf2008-07-26 23:55:296
7#include <algorithm>
[email protected]b75b8292010-10-01 07:28:258#include <cmath>
dchengcedca5612016-04-09 01:40:159#include <memory>
initial.commit09911bf2008-07-26 23:55:2910
[email protected]5d4e36d2013-02-15 15:18:2011#include "base/auto_reset.h"
[email protected]6e806822011-11-19 01:51:0812#include "base/bind.h"
13#include "base/bind_helpers.h"
initial.commit09911bf2008-07-26 23:55:2914#include "base/command_line.h"
[email protected]bb063b72009-03-27 23:18:5015#include "base/compiler_specific.h"
[email protected]2132d6b2013-06-05 00:15:4316#include "base/debug/alias.h"
creis9f7248b2016-01-27 20:27:3917#include "base/debug/crash_logging.h"
[email protected]728c2ee2013-06-25 04:01:0718#include "base/files/file_path.h"
[email protected]edc3af82013-12-12 21:24:0719#include "base/i18n/rtl.h"
[email protected]b1cf3372011-04-20 21:28:1020#include "base/json/json_writer.h"
[email protected]625332e02010-12-14 07:48:4921#include "base/lazy_instance.h"
fdoray7a8954a42016-06-07 04:28:3822#include "base/location.h"
dchengcedca5612016-04-09 01:40:1523#include "base/memory/ptr_util.h"
[email protected]f29efe6b2014-06-09 05:01:5124#include "base/metrics/field_trial.h"
asvitkine8d51e9d2016-09-02 23:55:4325#include "base/metrics/histogram_macros.h"
[email protected]d3b4ee22013-07-24 22:50:0626#include "base/process/kill.h"
[email protected]7d08a9352013-10-15 08:24:5627#include "base/process/process.h"
fdoray7a8954a42016-06-07 04:28:3828#include "base/single_thread_task_runner.h"
[email protected]21aa99682013-06-11 07:17:0129#include "base/strings/string_number_conversions.h"
[email protected]b9e7c479f2013-04-12 04:33:2430#include "base/strings/string_piece.h"
[email protected]27c05732013-02-15 21:55:4931#include "base/strings/string_split.h"
[email protected]21aa99682013-06-11 07:17:0132#include "base/strings/string_util.h"
[email protected]40d11e02013-03-28 17:43:1433#include "base/strings/sys_string_conversions.h"
[email protected]74ebfb12013-06-07 20:48:0034#include "base/strings/utf_string_conversions.h"
dalecurtiscd971252016-09-21 16:09:0035#include "base/sys_info.h"
fdoray7a8954a42016-06-07 04:28:3836#include "base/threading/thread_task_runner_handle.h"
[email protected]abb522162013-06-28 01:54:1637#include "base/time/time.h"
primiano9e38d552015-01-28 04:18:0138#include "base/trace_event/trace_event.h"
avi1023d012015-12-25 02:39:1439#include "build/build_config.h"
dongseong.hwange095dfa2016-02-04 11:21:3940#include "cc/base/switches.h"
[email protected]a8cb3b73b2013-08-12 05:50:5041#include "content/child/appcache/appcache_dispatcher.h"
42#include "content/child/appcache/web_application_cache_host_impl.h"
[email protected]cb189e062014-04-23 00:57:0143#include "content/child/child_shared_bitmap_manager.h"
[email protected]541b7b02013-06-07 00:59:3444#include "content/child/request_extra_data.h"
mek87e0ab52015-02-13 01:18:2645#include "content/child/v8_value_converter_impl.h"
[email protected]10208ea2013-06-06 20:08:0346#include "content/child/webmessageportchannel_impl.h"
jinho.bang632a1a722014-09-18 03:02:5647#include "content/common/content_constants_internal.h"
oshima750cb4342015-10-31 00:59:0148#include "content/common/content_switches_internal.h"
[email protected]5f2aa722013-08-07 16:59:4149#include "content/common/dom_storage/dom_storage_types.h"
[email protected]59f4f2fa2011-03-23 01:00:5550#include "content/common/drag_messages.h"
[email protected]c6bc20332014-02-28 18:30:3951#include "content/common/frame_messages.h"
alexmosbc7eafa2014-12-06 01:38:0952#include "content/common/frame_replication_state.h"
[email protected]c084330e02013-04-27 01:08:1553#include "content/common/input_messages.h"
lfgdb5c4ed2016-03-04 23:09:0754#include "content/common/page_messages.h"
rockot5c478a72016-09-28 23:14:1855#include "content/common/render_message_filter.mojom.h"
nickac60e75472015-07-31 00:44:3556#include "content/common/site_isolation_policy.h"
[email protected]778574e2011-03-21 22:03:5057#include "content/common/view_messages.h"
[email protected]e091df82011-10-11 18:13:2158#include "content/public/common/bindings_policy.h"
arthursonzognic517fc32016-08-11 11:04:2459#include "content/public/common/browser_side_navigation_policy.h"
[email protected]744c2a22012-03-15 18:42:0460#include "content/public/common/content_client.h"
[email protected]54087fe2011-10-28 22:02:4861#include "content/public/common/content_constants.h"
[email protected]c08950d22011-10-13 22:20:2962#include "content/public/common/content_switches.h"
[email protected]dc293a72013-07-01 11:11:2263#include "content/public/common/drop_data.h"
[email protected]41225fe2013-03-29 05:32:0264#include "content/public/common/favicon_url.h"
kouhei40f03cb2015-09-24 07:47:0165#include "content/public/common/page_importance_signals.h"
clamyda97e8322014-10-07 21:57:2566#include "content/public/common/page_state.h"
[email protected]7940b8e2013-07-25 23:08:4967#include "content/public/common/page_zoom.h"
[email protected]818915cd2012-11-20 13:14:1168#include "content/public/common/three_d_api_types.h"
[email protected]a1d29162011-10-14 17:14:0369#include "content/public/common/url_constants.h"
[email protected]b3a97b52014-07-09 06:25:0570#include "content/public/common/web_preferences.h"
[email protected]d344114c2011-10-01 01:24:3471#include "content/public/renderer/content_renderer_client.h"
[email protected]007733c2011-11-17 00:34:0772#include "content/public/renderer/document_state.h"
[email protected]82ddba1c2011-10-04 00:15:3273#include "content/public/renderer/navigation_state.h"
[email protected]3a034ebb2011-10-03 19:19:4474#include "content/public/renderer/render_view_observer.h"
[email protected]64ffa0442011-10-03 22:08:3675#include "content/public/renderer/render_view_visitor.h"
[email protected]e6e56752012-08-10 00:46:0676#include "content/renderer/browser_plugin/browser_plugin.h"
77#include "content/renderer/browser_plugin/browser_plugin_manager.h"
[email protected]1910fe82012-05-10 00:04:1078#include "content/renderer/dom_storage/webstoragenamespace_impl.h"
[email protected]dc293a72013-07-01 11:11:2279#include "content/renderer/drop_data_builder.h"
[email protected]ba91a792013-02-06 09:48:2880#include "content/renderer/gpu/render_widget_compositor.h"
[email protected]d4734982014-04-15 02:05:5581#include "content/renderer/history_controller.h"
[email protected]dc064352014-04-25 08:36:3882#include "content/renderer/history_serialization.h"
[email protected]1784b2f2011-11-24 10:53:4883#include "content/renderer/idle_user_detector.h"
[email protected]66fca5bc2013-05-23 06:58:2984#include "content/renderer/ime_event_guard.h"
[email protected]7a72d452013-12-13 10:01:1385#include "content/renderer/input/input_handler_manager.h"
[email protected]92d457802013-04-01 19:18:4986#include "content/renderer/internal_document_state_data.h"
[email protected]4a914882013-01-10 00:43:4887#include "content/renderer/media/audio_device_factory.h"
[email protected]6392d982013-04-16 16:59:2288#include "content/renderer/media/video_capture_impl_manager.h"
clamy5f342202015-03-18 13:47:5689#include "content/renderer/navigation_state_impl.h"
[email protected]227692c52013-05-31 22:43:0490#include "content/renderer/render_frame_impl.h"
[email protected]5a7100d2014-05-19 01:29:0491#include "content/renderer/render_frame_proxy.h"
[email protected]8704f89b2011-04-15 00:30:0592#include "content/renderer/render_process.h"
[email protected]f1a29a02011-10-06 23:08:4493#include "content/renderer/render_thread_impl.h"
[email protected]2cff0052011-03-18 16:51:4494#include "content/renderer/render_widget_fullscreen_pepper.h"
[email protected]663bd9e2011-03-21 01:07:0195#include "content/renderer/renderer_webapplicationcachehost_impl.h"
[email protected]5b45ad42013-10-25 00:42:0496#include "content/renderer/resizing_mode_selector.h"
[email protected]12a936d2013-05-15 04:55:4997#include "content/renderer/savable_resources.h"
[email protected]64d09222012-05-25 10:10:3498#include "content/renderer/speech_recognition_dispatcher.h"
[email protected]940ed1d2012-11-27 21:03:2199#include "content/renderer/web_ui_extension_data.h"
[email protected]6f516082011-03-17 19:15:35100#include "content/renderer/websharedworker_proxy.h"
[email protected]f5961142013-04-17 23:09:42101#include "media/audio/audio_output_device.h"
[email protected]ee68378a2010-08-10 01:05:41102#include "media/base/media_switches.h"
servolkf54f5c8f2015-02-24 20:32:39103#include "media/renderers/audio_renderer_impl.h"
servolk8b3b39b2015-03-03 19:08:18104#include "media/renderers/gpu_video_accelerator_factories.h"
[email protected]d1ef81d2012-07-24 11:39:36105#include "net/base/data_url.h"
initial.commit09911bf2008-07-26 23:55:29106#include "net/base/escape.h"
107#include "net/base/net_errors.h"
[email protected]18fb7a772012-09-20 19:25:09108#include "net/base/registry_controlled_domains/registry_controlled_domain.h"
[email protected]52c68652010-12-07 17:47:04109#include "net/http/http_util.h"
lukenb171b532014-09-24 05:50:38110#include "skia/ext/platform_canvas.h"
kinukob473f002016-02-22 05:23:19111#include "third_party/WebKit/public/platform/FilePathConversion.h"
brettwdfbcc3b2016-01-20 01:49:17112#include "third_party/WebKit/public/platform/URLConversion.h"
[email protected]b3a97b52014-07-09 06:25:05113#include "third_party/WebKit/public/platform/WebConnectionType.h"
[email protected]d0fcff72013-07-23 02:45:43114#include "third_party/WebKit/public/platform/WebDragData.h"
[email protected]d0fcff72013-07-23 02:45:43115#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]ec173b522013-11-14 11:01:18121#include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h"
[email protected]d0fcff72013-07-23 02:45:43122#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]10760e4a2013-09-04 23:32:20128#include "third_party/WebKit/public/web/WebAXObject.h"
[email protected]8bc5ff02013-11-29 06:34:03129#include "third_party/WebKit/public/web/WebColorSuggestion.h"
[email protected]2255a9332013-06-17 05:12:31130#include "third_party/WebKit/public/web/WebDOMEvent.h"
131#include "third_party/WebKit/public/web/WebDOMMessageEvent.h"
132#include "third_party/WebKit/public/web/WebDataSource.h"
133#include "third_party/WebKit/public/web/WebDateTimeChooserCompletion.h"
134#include "third_party/WebKit/public/web/WebDateTimeChooserParams.h"
[email protected]2255a9332013-06-17 05:12:31135#include "third_party/WebKit/public/web/WebDocument.h"
136#include "third_party/WebKit/public/web/WebElement.h"
137#include "third_party/WebKit/public/web/WebFileChooserParams.h"
[email protected]2255a9332013-06-17 05:12:31138#include "third_party/WebKit/public/web/WebFormControlElement.h"
139#include "third_party/WebKit/public/web/WebFormElement.h"
140#include "third_party/WebKit/public/web/WebFrame.h"
dglazkov03223492016-02-08 22:16:03141#include "third_party/WebKit/public/web/WebFrameContentDumper.h"
lfgcaab5142016-02-26 19:06:52142#include "third_party/WebKit/public/web/WebFrameWidget.h"
[email protected]2255a9332013-06-17 05:12:31143#include "third_party/WebKit/public/web/WebHistoryItem.h"
[email protected]91dcc6d32014-07-30 00:01:33144#include "third_party/WebKit/public/web/WebHitTestResult.h"
[email protected]2255a9332013-06-17 05:12:31145#include "third_party/WebKit/public/web/WebInputElement.h"
146#include "third_party/WebKit/public/web/WebInputEvent.h"
[email protected]35b2a972014-04-04 15:50:22147#include "third_party/WebKit/public/web/WebLocalFrame.h"
[email protected]2255a9332013-06-17 05:12:31148#include "third_party/WebKit/public/web/WebMediaPlayerAction.h"
149#include "third_party/WebKit/public/web/WebNavigationPolicy.h"
kouhei40f03cb2015-09-24 07:47:01150#include "third_party/WebKit/public/web/WebPageImportanceSignals.h"
[email protected]2255a9332013-06-17 05:12:31151#include "third_party/WebKit/public/web/WebPlugin.h"
152#include "third_party/WebKit/public/web/WebPluginAction.h"
[email protected]2255a9332013-06-17 05:12:31153#include "third_party/WebKit/public/web/WebRange.h"
ellyjones8ae17692016-08-05 15:19:21154#include "third_party/WebKit/public/web/WebRenderTheme.h"
[email protected]b3a97b52014-07-09 06:25:05155#include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
[email protected]2255a9332013-06-17 05:12:31156#include "third_party/WebKit/public/web/WebScriptSource.h"
157#include "third_party/WebKit/public/web/WebSearchableFormData.h"
[email protected]2255a9332013-06-17 05:12:31158#include "third_party/WebKit/public/web/WebSecurityPolicy.h"
[email protected]2255a9332013-06-17 05:12:31159#include "third_party/WebKit/public/web/WebSettings.h"
[email protected]2255a9332013-06-17 05:12:31160#include "third_party/WebKit/public/web/WebUserGestureIndicator.h"
[email protected]2255a9332013-06-17 05:12:31161#include "third_party/WebKit/public/web/WebView.h"
162#include "third_party/WebKit/public/web/WebWindowFeatures.h"
[email protected]b3a97b52014-07-09 06:25:05163#include "third_party/icu/source/common/unicode/uchar.h"
164#include "third_party/icu/source/common/unicode/uscript.h"
[email protected]4ee64622014-03-21 22:34:15165#include "ui/base/clipboard/clipboard.h"
[email protected]1400e6dc2013-04-27 02:36:27166#include "ui/base/ui_base_switches_util.h"
Nico Weber9d6e12942016-04-19 18:51:09167#include "ui/events/latency_info.h"
tfarina655f81d2014-12-23 02:38:50168#include "ui/gfx/geometry/point.h"
tfarina3b0452d2014-12-31 15:20:09169#include "ui/gfx/geometry/rect.h"
170#include "ui/gfx/geometry/rect_conversions.h"
tfarinaebe974f02015-01-03 04:25:32171#include "ui/gfx/geometry/size_conversions.h"
[email protected]08397d52011-02-05 01:53:38172#include "ui/gfx/native_widget_types.h"
markdittmer67b71ea2016-03-03 22:40:03173#include "url/url_constants.h"
[email protected]c4a9e932011-03-05 04:05:55174#include "v8/include/v8.h"
initial.commit09911bf2008-07-26 23:55:29175
[email protected]25fb9b32012-04-27 03:21:55176#if defined(OS_ANDROID)
[email protected]befe54782013-04-23 00:49:25177#include <cpu-features.h>
178
dalecurtiscd971252016-09-21 16:09:00179#include "base/android/build_info.h"
[email protected]20657a82012-08-21 20:23:03180#include "content/renderer/android/address_detector.h"
181#include "content/renderer/android/content_detector.h"
estade6b9696bd2016-05-04 23:51:36182#include "content/renderer/android/disambiguation_popup_helper.h"
[email protected]20657a82012-08-21 20:23:03183#include "content/renderer/android/email_detector.h"
184#include "content/renderer/android/phone_number_detector.h"
tfarina3b0452d2014-12-31 15:20:09185#include "ui/gfx/geometry/rect_f.h"
[email protected]e69bb062013-06-03 13:05:40186
[email protected]78043bdd2010-04-05 18:45:33187#elif defined(OS_MACOSX)
188#include "skia/ext/skia_utils_mac.h"
[email protected]6c8afae52009-01-22 02:24:57189#endif
190
[email protected]ea2fb972013-08-07 05:44:26191#if defined(ENABLE_PLUGINS)
[email protected]ea2fb972013-08-07 05:44:26192#include "content/renderer/pepper/pepper_plugin_instance_impl.h"
193#include "content/renderer/pepper/pepper_plugin_registry.h"
[email protected]ea2fb972013-08-07 05:44:26194#endif
195
[email protected]9ac667e2013-09-09 12:49:21196#if defined(ENABLE_WEBRTC)
197#include "content/renderer/media/rtc_peer_connection_handler.h"
[email protected]22fe91d2014-08-12 17:07:12198#include "content/renderer/media/webrtc/peer_connection_dependency_factory.h"
[email protected]9ac667e2013-09-09 12:49:21199#endif
200
[email protected]180ef242013-11-07 06:50:46201using blink::WebAXObject;
202using blink::WebApplicationCacheHost;
203using blink::WebApplicationCacheHostClient;
[email protected]180ef242013-11-07 06:50:46204using blink::WebColor;
[email protected]180ef242013-11-07 06:50:46205using blink::WebConsoleMessage;
[email protected]180ef242013-11-07 06:50:46206using blink::WebData;
207using blink::WebDataSource;
208using blink::WebDocument;
[email protected]180ef242013-11-07 06:50:46209using blink::WebDragData;
210using blink::WebDragOperation;
211using blink::WebDragOperationsMask;
212using blink::WebElement;
[email protected]180ef242013-11-07 06:50:46213using blink::WebFileChooserCompletion;
[email protected]180ef242013-11-07 06:50:46214using blink::WebFormControlElement;
215using blink::WebFormElement;
216using blink::WebFrame;
dglazkov03223492016-02-08 22:16:03217using blink::WebFrameContentDumper;
[email protected]180ef242013-11-07 06:50:46218using blink::WebGestureEvent;
219using blink::WebHistoryItem;
220using blink::WebHTTPBody;
dglazkov8d0c21dd2016-08-06 15:56:36221using blink::WebHitTestResult;
[email protected]180ef242013-11-07 06:50:46222using blink::WebIconURL;
223using blink::WebImage;
224using blink::WebInputElement;
225using blink::WebInputEvent;
[email protected]35b2a972014-04-04 15:50:22226using blink::WebLocalFrame;
[email protected]180ef242013-11-07 06:50:46227using blink::WebMediaPlayerAction;
[email protected]180ef242013-11-07 06:50:46228using blink::WebMouseEvent;
229using blink::WebNavigationPolicy;
230using blink::WebNavigationType;
231using blink::WebNode;
[email protected]180ef242013-11-07 06:50:46232using blink::WebPeerConnection00Handler;
233using blink::WebPeerConnection00HandlerClient;
234using blink::WebPeerConnectionHandler;
235using blink::WebPeerConnectionHandlerClient;
236using blink::WebPluginAction;
[email protected]180ef242013-11-07 06:50:46237using blink::WebPoint;
[email protected]180ef242013-11-07 06:50:46238using blink::WebRect;
239using blink::WebReferrerPolicy;
[email protected]180ef242013-11-07 06:50:46240using blink::WebScriptSource;
241using blink::WebSearchableFormData;
242using blink::WebSecurityOrigin;
243using blink::WebSecurityPolicy;
[email protected]180ef242013-11-07 06:50:46244using blink::WebSettings;
245using blink::WebSize;
[email protected]180ef242013-11-07 06:50:46246using blink::WebStorageNamespace;
247using blink::WebStorageQuotaCallbacks;
248using blink::WebStorageQuotaError;
249using blink::WebStorageQuotaType;
250using blink::WebString;
[email protected]180ef242013-11-07 06:50:46251using blink::WebTextDirection;
252using blink::WebTouchEvent;
253using blink::WebURL;
254using blink::WebURLError;
255using blink::WebURLRequest;
256using blink::WebURLResponse;
257using blink::WebUserGestureIndicator;
258using blink::WebVector;
259using blink::WebView;
260using blink::WebWidget;
261using blink::WebWindowFeatures;
[email protected]b3a97b52014-07-09 06:25:05262using blink::WebRuntimeFeatures;
[email protected]6fdd4182010-10-14 23:59:26263using base::Time;
264using base::TimeDelta;
[email protected]e1acf6f2008-10-27 20:43:33265
[email protected]20657a82012-08-21 20:23:03266
[email protected]e9ff79c2012-10-19 21:31:26267namespace content {
268
initial.commit09911bf2008-07-26 23:55:29269//-----------------------------------------------------------------------------
270
[email protected]180ef242013-11-07 06:50:46271typedef std::map<blink::WebView*, RenderViewImpl*> ViewMap;
[email protected]6de0fd1d2011-11-15 13:31:49272static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER;
avi1023d012015-12-25 02:39:14273typedef std::map<int32_t, RenderViewImpl*> RoutingIDViewMap;
[email protected]058561b2012-12-03 06:48:22274static base::LazyInstance<RoutingIDViewMap> g_routing_id_view_map =
275 LAZY_INSTANCE_INITIALIZER;
[email protected]3354d3e2010-06-10 19:53:02276
[email protected]882daa92009-11-05 16:31:31277// Time, in seconds, we delay before sending content state changes (such as form
278// state and scroll position) to the browser. We delay sending changes to avoid
279// spamming the browser.
280// To avoid having tab/session restore require sending a message to get the
281// current content state during tab closing we use a shorter timeout for the
282// foreground renderer. This means there is a small window of time from which
283// content state is modified and not sent to session restore, but this is
284// better than having to wake up all renderers during shutdown.
avif937e1d2014-11-02 18:13:07285const int kDelaySecondsForContentStateSyncHidden = 5;
286const int kDelaySecondsForContentStateSync = 1;
initial.commit09911bf2008-07-26 23:55:29287
[email protected]20657a82012-08-21 20:23:03288#if defined(OS_ANDROID)
289// Delay between tapping in content and launching the associated android intent.
290// Used to allow users see what has been recognized as content.
[email protected]9afc14e22013-09-25 22:34:14291const size_t kContentIntentDelayMilliseconds = 700;
[email protected]20657a82012-08-21 20:23:03292#endif
293
dcheng35d31c112015-07-22 00:17:36294static RenderViewImpl* (*g_create_render_view_impl)(
295 CompositorDependencies* compositor_deps,
rockot067ca55f2016-09-30 22:00:15296 const mojom::CreateViewParams&) = nullptr;
[email protected]8d41d7612012-11-14 20:32:19297
[email protected]c6bc20332014-02-28 18:30:39298// static
[email protected]e507045d2013-07-24 15:23:44299Referrer RenderViewImpl::GetReferrerFromRequest(
[email protected]44e55b012013-07-23 14:21:56300 WebFrame* frame,
301 const WebURLRequest& request) {
brettwdfbcc3b2016-01-20 01:49:17302 return Referrer(
303 blink::WebStringToGURL(request.httpHeaderField(
304 WebString::fromUTF8("Referer"))),
305 request.referrerPolicy());
[email protected]44e55b012013-07-23 14:21:56306}
307
[email protected]c6bc20332014-02-28 18:30:39308// static
[email protected]65920f332014-03-04 21:14:18309WindowOpenDisposition RenderViewImpl::NavigationPolicyToDisposition(
[email protected]48861e22013-01-09 00:27:32310 WebNavigationPolicy policy) {
311 switch (policy) {
[email protected]180ef242013-11-07 06:50:46312 case blink::WebNavigationPolicyIgnore:
nick3b04f322016-08-31 19:29:19313 return WindowOpenDisposition::IGNORE_ACTION;
[email protected]180ef242013-11-07 06:50:46314 case blink::WebNavigationPolicyDownload:
nick3b04f322016-08-31 19:29:19315 return WindowOpenDisposition::SAVE_TO_DISK;
[email protected]180ef242013-11-07 06:50:46316 case blink::WebNavigationPolicyCurrentTab:
nick3b04f322016-08-31 19:29:19317 return WindowOpenDisposition::CURRENT_TAB;
[email protected]180ef242013-11-07 06:50:46318 case blink::WebNavigationPolicyNewBackgroundTab:
nick3b04f322016-08-31 19:29:19319 return WindowOpenDisposition::NEW_BACKGROUND_TAB;
[email protected]180ef242013-11-07 06:50:46320 case blink::WebNavigationPolicyNewForegroundTab:
nick3b04f322016-08-31 19:29:19321 return WindowOpenDisposition::NEW_FOREGROUND_TAB;
[email protected]180ef242013-11-07 06:50:46322 case blink::WebNavigationPolicyNewWindow:
nick3b04f322016-08-31 19:29:19323 return WindowOpenDisposition::NEW_WINDOW;
[email protected]180ef242013-11-07 06:50:46324 case blink::WebNavigationPolicyNewPopup:
nick3b04f322016-08-31 19:29:19325 return WindowOpenDisposition::NEW_POPUP;
[email protected]48861e22013-01-09 00:27:32326 default:
327 NOTREACHED() << "Unexpected WebNavigationPolicy";
nick3b04f322016-08-31 19:29:19328 return WindowOpenDisposition::IGNORE_ACTION;
[email protected]48861e22013-01-09 00:27:32329 }
330}
331
[email protected]d8221b22013-05-23 05:35:43332// Returns true if the device scale is high enough that losing subpixel
333// antialiasing won't have a noticeable effect on text quality.
334static bool DeviceScaleEnsuresTextQuality(float device_scale_factor) {
335#if defined(OS_ANDROID)
336 // On Android, we never have subpixel antialiasing.
337 return true;
338#else
jdduke7d452b4a2015-08-19 21:25:21339 // 1.5 is a common touchscreen tablet device scale factor. For such
340 // devices main thread antialiasing is a heavy burden.
341 return device_scale_factor >= 1.5f;
[email protected]d8221b22013-05-23 05:35:43342#endif
[email protected]d8221b22013-05-23 05:35:43343}
344
danakj6e3bf8012014-12-16 18:27:53345static bool PreferCompositingToLCDText(CompositorDependencies* compositor_deps,
346 float device_scale_factor) {
avi83883c82014-12-23 00:08:49347 const base::CommandLine& command_line =
348 *base::CommandLine::ForCurrentProcess();
[email protected]b8ec1112014-08-17 20:09:10349 if (command_line.HasSwitch(switches::kDisablePreferCompositingToLCDText))
[email protected]fb854192013-02-06 01:30:04350 return false;
[email protected]b8ec1112014-08-17 20:09:10351 if (command_line.HasSwitch(switches::kEnablePreferCompositingToLCDText))
[email protected]fb854192013-02-06 01:30:04352 return true;
danakj6e3bf8012014-12-16 18:27:53353 if (!compositor_deps->IsLcdTextEnabled())
[email protected]10c19732014-08-18 19:39:23354 return true;
[email protected]d8221b22013-05-23 05:35:43355 return DeviceScaleEnsuresTextQuality(device_scale_factor);
356}
357
[email protected]180ef242013-11-07 06:50:46358static FaviconURL::IconType ToFaviconType(blink::WebIconURL::Type type) {
[email protected]41225fe2013-03-29 05:32:02359 switch (type) {
[email protected]180ef242013-11-07 06:50:46360 case blink::WebIconURL::TypeFavicon:
[email protected]41225fe2013-03-29 05:32:02361 return FaviconURL::FAVICON;
[email protected]180ef242013-11-07 06:50:46362 case blink::WebIconURL::TypeTouch:
[email protected]41225fe2013-03-29 05:32:02363 return FaviconURL::TOUCH_ICON;
[email protected]180ef242013-11-07 06:50:46364 case blink::WebIconURL::TypeTouchPrecomposed:
[email protected]41225fe2013-03-29 05:32:02365 return FaviconURL::TOUCH_PRECOMPOSED_ICON;
[email protected]180ef242013-11-07 06:50:46366 case blink::WebIconURL::TypeInvalid:
[email protected]41225fe2013-03-29 05:32:02367 return FaviconURL::INVALID_ICON;
368 }
369 return FaviconURL::INVALID_ICON;
370}
371
[email protected]f34ac132014-03-20 23:02:05372static void ConvertToFaviconSizes(
373 const blink::WebVector<blink::WebSize>& web_sizes,
374 std::vector<gfx::Size>* sizes) {
[email protected]2bd262b2014-04-16 05:31:23375 DCHECK(sizes->empty());
376 sizes->reserve(web_sizes.size());
[email protected]f34ac132014-03-20 23:02:05377 for (size_t i = 0; i < web_sizes.size(); ++i)
378 sizes->push_back(gfx::Size(web_sizes[i]));
379}
380
initial.commit09911bf2008-07-26 23:55:29381///////////////////////////////////////////////////////////////////////////////
382
[email protected]217690d2012-01-27 07:33:11383namespace {
384
hush8915b502016-06-15 19:32:23385WebDragData DropMetaDataToWebDragData(
386 const std::vector<DropData::Metadata>& drop_meta_data) {
387 std::vector<WebDragData::Item> item_list;
388 for (const auto& meta_data_item : drop_meta_data) {
389 if (meta_data_item.kind == DropData::Kind::STRING) {
390 WebDragData::Item item;
391 item.storageType = WebDragData::Item::StorageTypeString;
392 item.stringType = meta_data_item.mime_type;
393 // Have to pass a dummy URL here instead of an empty URL because the
394 // DropData received by browser_plugins goes through a round trip:
395 // DropData::MetaData --> WebDragData-->DropData. In the end, DropData
396 // will contain an empty URL (which means no URL is dragged) if the URL in
397 // WebDragData is empty.
398 if (base::EqualsASCII(meta_data_item.mime_type,
399 ui::Clipboard::kMimeTypeURIList)) {
400 item.stringData = WebString::fromUTF8("about:dragdrop-placeholder");
401 }
402 item_list.push_back(item);
403 continue;
404 }
405
406 // TODO(hush): crbug.com/584789. Blink needs to support creating a file with
407 // just the mimetype. This is needed to drag files to WebView on Android
408 // platform.
409 if ((meta_data_item.kind == DropData::Kind::FILENAME) &&
410 !meta_data_item.filename.empty()) {
411 WebDragData::Item item;
412 item.storageType = WebDragData::Item::StorageTypeFilename;
413 item.filenameData = meta_data_item.filename.AsUTF16Unsafe();
414 item_list.push_back(item);
415 continue;
416 }
417
418 if (meta_data_item.kind == DropData::Kind::FILESYSTEMFILE) {
419 WebDragData::Item item;
420 item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
421 item.fileSystemURL = meta_data_item.file_system_url;
422 item_list.push_back(item);
423 continue;
424 }
425 }
426
427 WebDragData result;
428 result.initialize();
429 result.setItems(item_list);
430 return result;
431}
432
[email protected]dc293a72013-07-01 11:11:22433WebDragData DropDataToWebDragData(const DropData& drop_data) {
[email protected]c10680312013-05-31 15:22:05434 std::vector<WebDragData::Item> item_list;
435
436 // These fields are currently unused when dragging into WebKit.
437 DCHECK(drop_data.download_metadata.empty());
438 DCHECK(drop_data.file_contents.empty());
439 DCHECK(drop_data.file_description_filename.empty());
440
441 if (!drop_data.text.is_null()) {
442 WebDragData::Item item;
443 item.storageType = WebDragData::Item::StorageTypeString;
444 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeText);
445 item.stringData = drop_data.text.string();
446 item_list.push_back(item);
447 }
448
[email protected]c10680312013-05-31 15:22:05449 if (!drop_data.url.is_empty()) {
450 WebDragData::Item item;
451 item.storageType = WebDragData::Item::StorageTypeString;
452 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeURIList);
453 item.stringData = WebString::fromUTF8(drop_data.url.spec());
454 item.title = drop_data.url_title;
455 item_list.push_back(item);
456 }
457
458 if (!drop_data.html.is_null()) {
459 WebDragData::Item item;
460 item.storageType = WebDragData::Item::StorageTypeString;
461 item.stringType = WebString::fromUTF8(ui::Clipboard::kMimeTypeHTML);
462 item.stringData = drop_data.html.string();
463 item.baseURL = drop_data.html_base_url;
464 item_list.push_back(item);
465 }
466
[email protected]17ea0ae22014-03-28 21:54:46467 for (std::vector<ui::FileInfo>::const_iterator it =
[email protected]c10680312013-05-31 15:22:05468 drop_data.filenames.begin();
469 it != drop_data.filenames.end();
470 ++it) {
471 WebDragData::Item item;
472 item.storageType = WebDragData::Item::StorageTypeFilename;
[email protected]17ea0ae22014-03-28 21:54:46473 item.filenameData = it->path.AsUTF16Unsafe();
474 item.displayNameData = it->display_name.AsUTF16Unsafe();
[email protected]c10680312013-05-31 15:22:05475 item_list.push_back(item);
476 }
477
[email protected]60ed95f2014-04-23 12:19:48478 for (std::vector<DropData::FileSystemFileInfo>::const_iterator it =
479 drop_data.file_system_files.begin();
480 it != drop_data.file_system_files.end();
481 ++it) {
482 WebDragData::Item item;
483 item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
484 item.fileSystemURL = it->url;
485 item.fileSystemFileSize = it->size;
486 item_list.push_back(item);
487 }
488
[email protected]c10680312013-05-31 15:22:05489 for (std::map<base::string16, base::string16>::const_iterator it =
490 drop_data.custom_data.begin();
491 it != drop_data.custom_data.end();
492 ++it) {
493 WebDragData::Item item;
494 item.storageType = WebDragData::Item::StorageTypeString;
495 item.stringType = it->first;
496 item.stringData = it->second;
497 item_list.push_back(item);
498 }
499
500 WebDragData result;
501 result.initialize();
502 result.setItems(item_list);
503 result.setFilesystemId(drop_data.filesystem_id);
504 return result;
505}
506
[email protected]b3a97b52014-07-09 06:25:05507typedef void (*SetFontFamilyWrapper)(blink::WebSettings*,
508 const base::string16&,
509 UScriptCode);
510
511void SetStandardFontFamilyWrapper(WebSettings* settings,
512 const base::string16& font,
513 UScriptCode script) {
514 settings->setStandardFontFamily(font, script);
515}
516
517void SetFixedFontFamilyWrapper(WebSettings* settings,
518 const base::string16& font,
519 UScriptCode script) {
520 settings->setFixedFontFamily(font, script);
521}
522
523void SetSerifFontFamilyWrapper(WebSettings* settings,
524 const base::string16& font,
525 UScriptCode script) {
526 settings->setSerifFontFamily(font, script);
527}
528
529void SetSansSerifFontFamilyWrapper(WebSettings* settings,
530 const base::string16& font,
531 UScriptCode script) {
532 settings->setSansSerifFontFamily(font, script);
533}
534
535void SetCursiveFontFamilyWrapper(WebSettings* settings,
536 const base::string16& font,
537 UScriptCode script) {
538 settings->setCursiveFontFamily(font, script);
539}
540
541void SetFantasyFontFamilyWrapper(WebSettings* settings,
542 const base::string16& font,
543 UScriptCode script) {
544 settings->setFantasyFontFamily(font, script);
545}
546
547void SetPictographFontFamilyWrapper(WebSettings* settings,
548 const base::string16& font,
549 UScriptCode script) {
550 settings->setPictographFontFamily(font, script);
551}
552
553// If |scriptCode| is a member of a family of "similar" script codes, returns
554// the script code in that family that is used by WebKit for font selection
555// purposes. For example, USCRIPT_KATAKANA_OR_HIRAGANA and USCRIPT_JAPANESE are
556// considered equivalent for the purposes of font selection. WebKit uses the
557// script code USCRIPT_KATAKANA_OR_HIRAGANA. So, if |scriptCode| is
558// USCRIPT_JAPANESE, the function returns USCRIPT_KATAKANA_OR_HIRAGANA. WebKit
559// uses different scripts than the ones in Chrome pref names because the version
560// of ICU included on certain ports does not have some of the newer scripts. If
561// |scriptCode| is not a member of such a family, returns |scriptCode|.
562UScriptCode GetScriptForWebSettings(UScriptCode scriptCode) {
563 switch (scriptCode) {
564 case USCRIPT_HIRAGANA:
565 case USCRIPT_KATAKANA:
566 case USCRIPT_JAPANESE:
567 return USCRIPT_KATAKANA_OR_HIRAGANA;
568 case USCRIPT_KOREAN:
569 return USCRIPT_HANGUL;
570 default:
571 return scriptCode;
572 }
573}
574
575void ApplyFontsFromMap(const ScriptFontFamilyMap& map,
576 SetFontFamilyWrapper setter,
577 WebSettings* settings) {
578 for (ScriptFontFamilyMap::const_iterator it = map.begin(); it != map.end();
579 ++it) {
avi1023d012015-12-25 02:39:14580 int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, (it->first).c_str());
[email protected]b3a97b52014-07-09 06:25:05581 if (script >= 0 && script < USCRIPT_CODE_LIMIT) {
582 UScriptCode code = static_cast<UScriptCode>(script);
583 (*setter)(settings, it->second, GetScriptForWebSettings(code));
584 }
585 }
586}
587
wangxianzhu3bf39be52015-04-10 23:56:41588void ApplyBlinkSettings(const base::CommandLine& command_line,
589 WebSettings* settings) {
590 if (!command_line.HasSwitch(switches::kBlinkSettings))
591 return;
592
brettw26dab8f02015-08-08 00:28:47593 std::vector<std::string> blink_settings = base::SplitString(
594 command_line.GetSwitchValueASCII(switches::kBlinkSettings),
595 ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
wangxianzhu3bf39be52015-04-10 23:56:41596 for (const std::string& setting : blink_settings) {
597 size_t pos = setting.find('=');
598 settings->setFromStrings(
599 blink::WebString::fromLatin1(setting.substr(0, pos)),
600 blink::WebString::fromLatin1(
601 pos == std::string::npos ? "" : setting.substr(pos + 1)));
602 }
603}
604
horodbcbef42016-05-10 17:02:47605WebSettings::V8CacheStrategiesForCacheStorage
606GetV8CacheStrategiesForCacheStorage() {
607 const base::CommandLine& command_line =
608 *base::CommandLine::ForCurrentProcess();
609 std::string v8_cache_strategies = command_line.GetSwitchValueASCII(
610 switches::kV8CacheStrategiesForCacheStorage);
horoe0ff13d2016-05-27 14:47:22611 if (v8_cache_strategies.empty()) {
horodbcbef42016-05-10 17:02:47612 v8_cache_strategies =
613 base::FieldTrialList::FindFullName("V8CacheStrategiesForCacheStorage");
horoe0ff13d2016-05-27 14:47:22614 }
615
616 if (base::StartsWith(v8_cache_strategies, "none",
617 base::CompareCase::SENSITIVE)) {
horodbcbef42016-05-10 17:02:47618 return WebSettings::V8CacheStrategiesForCacheStorage::None;
horoe0ff13d2016-05-27 14:47:22619 } else if (base::StartsWith(v8_cache_strategies, "normal",
620 base::CompareCase::SENSITIVE)) {
horodbcbef42016-05-10 17:02:47621 return WebSettings::V8CacheStrategiesForCacheStorage::Normal;
horoe0ff13d2016-05-27 14:47:22622 } else if (base::StartsWith(v8_cache_strategies, "aggressive",
623 base::CompareCase::SENSITIVE)) {
horodbcbef42016-05-10 17:02:47624 return WebSettings::V8CacheStrategiesForCacheStorage::Aggressive;
625 } else {
626 return WebSettings::V8CacheStrategiesForCacheStorage::Default;
627 }
628}
629
svartmetal751af1f92016-08-13 11:47:33630// This class represents promise which is robust to (will not be broken by)
631// |DidNotSwapReason::SWAP_FAILS| events.
632class AlwaysDrawSwapPromise : public cc::SwapPromise {
633 public:
634 explicit AlwaysDrawSwapPromise(const ui::LatencyInfo& latency_info)
635 : latency_info_(latency_info) {}
636
637 ~AlwaysDrawSwapPromise() override = default;
638
639 void DidActivate() override {}
640
641 void DidSwap(cc::CompositorFrameMetadata* metadata) override {
642 DCHECK(!latency_info_.terminated());
643 metadata->latency_info.push_back(latency_info_);
644 }
645
646 DidNotSwapAction DidNotSwap(DidNotSwapReason reason) override {
647 return reason == DidNotSwapReason::SWAP_FAILS
648 ? DidNotSwapAction::KEEP_ACTIVE
649 : DidNotSwapAction::BREAK_PROMISE;
650 }
651
652 void OnCommit() override {}
653
654 int64_t TraceId() const override { return latency_info_.trace_id(); }
655
656 private:
657 ui::LatencyInfo latency_info_;
658};
659
[email protected]217690d2012-01-27 07:33:11660} // namespace
661
dcheng35d31c112015-07-22 00:17:36662RenderViewImpl::RenderViewImpl(CompositorDependencies* compositor_deps,
rockot067ca55f2016-09-30 22:00:15663 const mojom::CreateViewParams& params)
dcheng35d31c112015-07-22 00:17:36664 : RenderWidget(compositor_deps,
665 blink::WebPopupTypeNone,
naskobd911332014-11-25 01:13:36666 params.initial_size.screen_info,
667 params.swapped_out,
668 params.hidden,
669 params.never_visible),
670 webkit_preferences_(params.web_preferences),
avif937e1d2014-11-02 18:13:07671 send_content_state_immediately_(false),
[email protected]81e63782009-02-27 19:35:09672 enabled_bindings_(0),
[email protected]3354d3e2010-06-10 19:53:02673 send_preferred_size_changes_(false),
[email protected]e75cb49e2009-01-05 23:13:21674 navigation_gesture_(NavigationGestureUnknown),
[email protected]3354d3e2010-06-10 19:53:02675 opened_by_user_gesture_(true),
[email protected]3cc72b12010-03-18 23:03:00676 history_list_offset_(-1),
677 history_list_length_(0),
[email protected]7e9523b2014-03-25 03:02:42678 frames_in_progress_(0),
[email protected]3354d3e2010-06-10 19:53:02679 target_url_status_(TARGET_NONE),
[email protected]d42bf472014-06-14 01:49:38680 uses_temporary_zoom_level_(false),
[email protected]bbc8856d2013-06-14 10:37:04681#if defined(OS_ANDROID)
majidvpfb80e432015-02-23 14:15:50682 top_controls_constraints_(TOP_CONTROLS_STATE_BOTH),
[email protected]bbc8856d2013-06-14 10:37:04683#endif
bokanc63441c2016-04-27 15:49:12684 top_controls_shrink_blink_size_(false),
685 top_controls_height_(0.f),
lfg4fa48da2016-05-09 18:25:13686 webview_(nullptr),
[email protected]1875bc02014-03-14 06:33:59687 has_scrolled_focused_editable_node_into_rect_(false),
wjmaclean64951902016-04-29 20:59:12688 page_zoom_level_(params.page_zoom_level),
nasko4c0feb62015-06-05 18:37:06689 main_render_frame_(nullptr),
dcheng3ce04b62015-10-26 23:30:55690 frame_widget_(nullptr),
[email protected]64d09222012-05-25 10:10:34691 speech_recognition_dispatcher_(NULL),
[email protected]20657a82012-08-21 20:23:03692#if defined(OS_ANDROID)
693 expected_content_intent_id_(0),
[email protected]a7564272013-04-19 14:24:46694#endif
[email protected]8a67aa352013-02-20 02:58:29695 enumeration_completion_id_(0),
changwand659e202016-06-13 02:39:12696 session_storage_namespace_id_(params.session_storage_namespace_id),
697 has_added_input_handler_(false) {
avi40b5be7a2016-03-03 21:13:44698 GetWidget()->set_owner_delegate(this);
[email protected]075366912013-02-18 07:13:24699}
700
rockot067ca55f2016-09-30 22:00:15701void RenderViewImpl::Initialize(const mojom::CreateViewParams& params,
danakj6e3bf8012014-12-16 18:27:53702 bool was_created_by_renderer) {
fsamuele8326c742016-01-12 00:49:39703 SetRoutingID(params.view_id);
alexmos5ac402d2015-07-09 07:51:10704
705 int opener_view_routing_id;
alexmos95733002015-08-24 16:38:09706 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener(
707 params.opener_frame_route_id, &opener_view_routing_id);
alexmos5ac402d2015-07-09 07:51:10708 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer)
709 opener_id_ = opener_view_routing_id;
710
thestig6057a6b22015-11-12 23:01:33711 display_mode_ = params.initial_size.display_mode;
[email protected]676126f72011-01-15 00:03:51712
lfg717154072016-06-30 15:04:16713 webview_ =
714 WebView::create(this, is_hidden() ? blink::WebPageVisibilityStateHidden
715 : blink::WebPageVisibilityStateVisible);
lfgbee1e0a2016-06-08 21:24:21716 RenderWidget::DoInit(MSG_ROUTING_NONE, webview_->widget(), nullptr);
[email protected]11fee2332011-03-29 20:36:35717
nasko4c0feb62015-06-05 18:37:06718 g_view_map.Get().insert(std::make_pair(webview(), this));
avia3dca182016-03-19 01:09:52719 g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this));
nasko4c0feb62015-06-05 18:37:06720
avi83883c82014-12-23 00:08:49721 const base::CommandLine& command_line =
722 *base::CommandLine::ForCurrentProcess();
[email protected]20657a82012-08-21 20:23:03723
[email protected]27c521a2013-05-29 20:44:32724 if (command_line.HasSwitch(switches::kStatsCollectionController))
725 stats_collection_observer_.reset(new StatsCollectionObserver(this));
726
creis9f7248b2016-01-27 20:27:39727 // Debug cases of https://crbug.com/575245.
728 base::debug::SetCrashKeyValue("rvinit_view_id",
avia3dca182016-03-19 01:09:52729 base::IntToString(GetRoutingID()));
creis9f7248b2016-01-27 20:27:39730 base::debug::SetCrashKeyValue("rvinit_proxy_id",
731 base::IntToString(params.proxy_routing_id));
732 base::debug::SetCrashKeyValue(
733 "rvinit_main_frame_id", base::IntToString(params.main_frame_routing_id));
734
dcheng0ff94cfc2016-03-15 21:50:51735 webview()->setDisplayMode(display_mode_);
736 webview()->settings()->setPreferCompositingToLCDTextEnabled(
737 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
738 webview()->settings()->setThreadedScrollingEnabled(
739 !command_line.HasSwitch(switches::kDisableThreadedScrolling));
dcheng0ff94cfc2016-03-15 21:50:51740 webview()->setShowFPSCounter(
741 command_line.HasSwitch(cc::switches::kShowFPSCounter));
ccameron41495f252016-09-02 02:37:32742
743 if (auto overridden_color_profile =
744 GetContentClient()->renderer()->GetImageDecodeColorProfile()) {
745 webview()->setDeviceColorProfile(overridden_color_profile->GetData());
746 } else {
747 webview()->setDeviceColorProfile(params.image_decode_color_space.GetData());
748 }
dcheng0ff94cfc2016-03-15 21:50:51749
750 ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_);
751
752 if (switches::IsTouchDragDropEnabled())
753 webview()->settings()->setTouchDragDropEnabled(true);
754
arthursonzognic517fc32016-08-11 11:04:24755 webview()->settings()->setBrowserSideNavigationEnabled(
756 IsBrowserSideNavigationEnabled());
757
dcheng0ff94cfc2016-03-15 21:50:51758 WebSettings::SelectionStrategyType selection_strategy =
759 WebSettings::SelectionStrategyType::Character;
760 const std::string selection_strategy_str =
761 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
762 switches::kTouchTextSelectionStrategy);
763 if (selection_strategy_str == "direction")
764 selection_strategy = WebSettings::SelectionStrategyType::Direction;
765 webview()->settings()->setSelectionStrategy(selection_strategy);
766
dtapuskaf65650b2016-05-13 17:21:34767 std::string passiveListenersDefault =
768 command_line.GetSwitchValueASCII(switches::kPassiveListenersDefault);
769 if (!passiveListenersDefault.empty()) {
770 WebSettings::PassiveEventListenerDefault passiveDefault =
771 WebSettings::PassiveEventListenerDefault::False;
dtapuskaacc2fb22016-07-06 23:26:23772 if (passiveListenersDefault == "true")
dtapuskaf65650b2016-05-13 17:21:34773 passiveDefault = WebSettings::PassiveEventListenerDefault::True;
774 else if (passiveListenersDefault == "forcealltrue")
775 passiveDefault = WebSettings::PassiveEventListenerDefault::ForceAllTrue;
776 webview()->settings()->setPassiveEventListenerDefault(passiveDefault);
777 }
778
dcheng0ff94cfc2016-03-15 21:50:51779 ApplyBlinkSettings(command_line, webview()->settings());
780
dchengc5ef1a52015-08-26 20:58:30781 if (params.main_frame_routing_id != MSG_ROUTING_NONE) {
dcheng3ce04b62015-10-26 23:30:55782 main_render_frame_ = RenderFrameImpl::CreateMainFrame(
783 this, params.main_frame_routing_id, params.main_frame_widget_routing_id,
dcheng9e24bd352016-03-01 19:15:51784 params.hidden, screen_info(), compositor_deps_, opener_frame);
dchengc5ef1a52015-08-26 20:58:30785 }
786
nasko4c0feb62015-06-05 18:37:06787 if (params.proxy_routing_id != MSG_ROUTING_NONE) {
788 CHECK(params.swapped_out);
naskob3041b98a42016-03-12 04:43:06789 RenderFrameProxy::CreateFrameProxy(
avia3dca182016-03-19 01:09:52790 params.proxy_routing_id, GetRoutingID(), params.opener_frame_route_id,
naskob3041b98a42016-03-12 04:43:06791 MSG_ROUTING_NONE, params.replicated_frame_state);
nasko4c0feb62015-06-05 18:37:06792 }
793
nasko4c0feb62015-06-05 18:37:06794 if (main_render_frame_)
795 main_render_frame_->Initialize();
796
[email protected]20657a82012-08-21 20:23:03797#if defined(OS_ANDROID)
ricea29649b92016-08-31 09:30:21798 content_detectors_.push_back(base::MakeUnique<AddressDetector>());
qinminc6a739f92015-03-31 17:46:11799 const std::string& contry_iso =
800 params.renderer_preferences.network_contry_iso;
801 if (!contry_iso.empty()) {
limasdf81d962e2015-11-20 08:39:18802 content_detectors_.push_back(
ricea29649b92016-08-31 09:30:21803 base::MakeUnique<PhoneNumberDetector>(contry_iso));
qinmin0d5560df2014-11-12 19:03:39804 }
ricea29649b92016-08-31 09:30:21805 content_detectors_.push_back(base::MakeUnique<EmailDetector>());
[email protected]20657a82012-08-21 20:23:03806#endif
807
[email protected]676126f72011-01-15 00:03:51808 // If this is a popup, we must wait for the CreatingNew_ACK message before
809 // completing initialization. Otherwise, we can finish it now.
pimanc4af3072015-10-02 03:45:59810 if (opener_id_ == MSG_ROUTING_NONE)
[email protected]676126f72011-01-15 00:03:51811 did_show_ = true;
mfomitchev5ad034ec2015-04-24 21:57:27812
alexmos35799be2015-07-02 08:59:50813 // Set the main frame's name. Only needs to be done for WebLocalFrames,
814 // since the remote case was handled as part of SetReplicatedState on the
815 // proxy above.
816 if (!params.replicated_frame_state.name.empty() &&
817 webview()->mainFrame()->isWebLocalFrame()) {
alexmos3448b552015-06-26 07:49:13818 webview()->mainFrame()->setName(
819 blink::WebString::fromUTF8(params.replicated_frame_state.name));
820 }
[email protected]34c61bd52011-05-02 19:38:33821
[email protected]c7c0d822014-04-16 20:19:49822 // TODO(davidben): Move this state from Blink into content.
naskobd911332014-11-25 01:13:36823 if (params.window_was_created_with_opener)
[email protected]c7c0d822014-04-16 20:19:49824 webview()->setOpenedByDOM();
825
dcheng0ff94cfc2016-03-15 21:50:51826 UpdateWebViewWithDeviceScaleFactor();
naskobd911332014-11-25 01:13:36827 OnSetRendererPrefs(params.renderer_preferences);
[email protected]34c61bd52011-05-02 19:38:33828
naskobd911332014-11-25 01:13:36829 if (!params.enable_auto_resize) {
830 OnResize(params.initial_size);
mkosiba58fa72f02014-11-12 01:21:36831 } else {
naskobd911332014-11-25 01:13:36832 OnEnableAutoResize(params.min_size, params.max_size);
mkosiba58fa72f02014-11-12 01:21:36833 }
834
creis8eb8ef22015-11-04 22:51:38835 // We don't use HistoryController in OOPIF-enabled modes.
836 if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
837 history_controller_.reset(new HistoryController(this));
[email protected]d4734982014-04-15 02:05:55838
[email protected]1784b2f2011-11-24 10:53:48839 new IdleUserDetector(this);
840
[email protected]766a7082012-02-03 23:39:15841 if (command_line.HasSwitch(switches::kDomAutomationController))
[email protected]e9ff79c2012-10-19 21:31:26842 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION;
[email protected]27c521a2013-05-29 20:44:32843 if (command_line.HasSwitch(switches::kStatsCollectionController))
844 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION;
[email protected]766a7082012-02-03 23:39:15845
[email protected]e9ff79c2012-10-19 21:31:26846 GetContentClient()->renderer()->RenderViewCreated(this);
[email protected]14392a52012-05-02 20:28:44847
dcheng9e24bd352016-03-01 19:15:51848 // Ensure that sandbox flags are inherited from an opener in a different
849 // process. In that case, the browser process will set any inherited sandbox
850 // flags in |replicated_frame_state|, so apply them here.
alexmosf5fb5192016-04-11 22:09:04851 if (!was_created_by_renderer && webview()->mainFrame()->isWebLocalFrame()) {
dcheng9e24bd352016-03-01 19:15:51852 webview()->mainFrame()->toWebLocalFrame()->forceSandboxFlags(
853 params.replicated_frame_state.sandbox_flags);
alexmosaedfc6f2016-01-21 23:57:38854 }
wjmaclean64951902016-04-29 20:59:12855
856 page_zoom_level_ = params.page_zoom_level;
initial.commit09911bf2008-07-26 23:55:29857}
858
[email protected]310ebd6302011-10-10 19:06:28859RenderViewImpl::~RenderViewImpl() {
dcheng3ce04b62015-10-26 23:30:55860 DCHECK(!frame_widget_);
861
[email protected]cb189e062014-04-23 00:57:01862 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin();
863 it != disambiguation_bitmaps_.end();
864 ++it)
865 delete it->second;
[email protected]91a2aea2013-07-08 23:14:39866
[email protected]8ed1d3f2013-02-20 11:45:55867#if defined(OS_ANDROID)
davve17e025e12016-05-23 15:30:20868 // The date/time picker client is both a std::unique_ptr member of this class
869 // and a RenderViewObserver. Reset it to prevent double deletion.
[email protected]8ed1d3f2013-02-20 11:45:55870 date_time_picker_client_.reset();
871#endif
872
[email protected]60c42a8c72009-10-09 04:08:59873#ifndef NDEBUG
[email protected]058561b2012-12-03 06:48:22874 // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap.
[email protected]625332e02010-12-14 07:48:49875 ViewMap* views = g_view_map.Pointer();
[email protected]60c42a8c72009-10-09 04:08:59876 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it)
877 DCHECK_NE(this, it->second) << "Failed to call Close?";
[email protected]058561b2012-12-03 06:48:22878 RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer();
879 for (RoutingIDViewMap::iterator it = routing_id_views->begin();
880 it != routing_id_views->end(); ++it)
881 DCHECK_NE(this, it->second) << "Failed to call Close?";
[email protected]60c42a8c72009-10-09 04:08:59882#endif
[email protected]676126f72011-01-15 00:03:51883
[email protected]310ebd6302011-10-10 19:06:28884 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone());
[email protected]676126f72011-01-15 00:03:51885 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct());
[email protected]60c42a8c72009-10-09 04:08:59886}
887
888/*static*/
[email protected]310ebd6302011-10-10 19:06:28889RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) {
[email protected]a2ef54c2011-10-10 16:20:31890 ViewMap* views = g_view_map.Pointer();
891 ViewMap::iterator it = views->find(webview);
892 return it == views->end() ? NULL : it->second;
893}
894
895/*static*/
[email protected]180ef242013-11-07 06:50:46896RenderView* RenderView::FromWebView(blink::WebView* webview) {
[email protected]310ebd6302011-10-10 19:06:28897 return RenderViewImpl::FromWebView(webview);
[email protected]a2ef54c2011-10-10 16:20:31898}
899
900/*static*/
avi1023d012015-12-25 02:39:14901RenderViewImpl* RenderViewImpl::FromRoutingID(int32_t routing_id) {
[email protected]640e303c2012-12-05 01:36:07902 RoutingIDViewMap* views = g_routing_id_view_map.Pointer();
903 RoutingIDViewMap::iterator it = views->find(routing_id);
904 return it == views->end() ? NULL : it->second;
905}
906
907/*static*/
908RenderView* RenderView::FromRoutingID(int routing_id) {
909 return RenderViewImpl::FromRoutingID(routing_id);
910}
911
[email protected]f3a95312014-06-12 16:46:58912/* static */
jochen9c7b8f242015-06-01 15:32:02913size_t RenderView::GetRenderViewCount() {
[email protected]f3a95312014-06-12 16:46:58914 return g_view_map.Get().size();
915}
916
[email protected]640e303c2012-12-05 01:36:07917/*static*/
[email protected]e9ff79c2012-10-19 21:31:26918void RenderView::ForEach(RenderViewVisitor* visitor) {
[email protected]625332e02010-12-14 07:48:49919 ViewMap* views = g_view_map.Pointer();
[email protected]60c42a8c72009-10-09 04:08:59920 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) {
921 if (!visitor->Visit(it->second))
922 return;
923 }
924}
925
926/*static*/
[email protected]b3a97b52014-07-09 06:25:05927void RenderView::ApplyWebPreferences(const WebPreferences& prefs,
928 WebView* web_view) {
929 WebSettings* settings = web_view->settings();
930 ApplyFontsFromMap(prefs.standard_font_family_map,
931 SetStandardFontFamilyWrapper, settings);
932 ApplyFontsFromMap(prefs.fixed_font_family_map,
933 SetFixedFontFamilyWrapper, settings);
934 ApplyFontsFromMap(prefs.serif_font_family_map,
935 SetSerifFontFamilyWrapper, settings);
936 ApplyFontsFromMap(prefs.sans_serif_font_family_map,
937 SetSansSerifFontFamilyWrapper, settings);
938 ApplyFontsFromMap(prefs.cursive_font_family_map,
939 SetCursiveFontFamilyWrapper, settings);
940 ApplyFontsFromMap(prefs.fantasy_font_family_map,
941 SetFantasyFontFamilyWrapper, settings);
942 ApplyFontsFromMap(prefs.pictograph_font_family_map,
943 SetPictographFontFamilyWrapper, settings);
944 settings->setDefaultFontSize(prefs.default_font_size);
945 settings->setDefaultFixedFontSize(prefs.default_fixed_font_size);
946 settings->setMinimumFontSize(prefs.minimum_font_size);
947 settings->setMinimumLogicalFontSize(prefs.minimum_logical_font_size);
948 settings->setDefaultTextEncodingName(
949 base::ASCIIToUTF16(prefs.default_encoding));
950 settings->setJavaScriptEnabled(prefs.javascript_enabled);
951 settings->setWebSecurityEnabled(prefs.web_security_enabled);
952 settings->setJavaScriptCanOpenWindowsAutomatically(
953 prefs.javascript_can_open_windows_automatically);
954 settings->setLoadsImagesAutomatically(prefs.loads_images_automatically);
955 settings->setImagesEnabled(prefs.images_enabled);
956 settings->setPluginsEnabled(prefs.plugins_enabled);
957 settings->setDOMPasteAllowed(prefs.dom_paste_enabled);
[email protected]b3a97b52014-07-09 06:25:05958 settings->setTextAreasAreResizable(prefs.text_areas_are_resizable);
959 settings->setAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows);
960 settings->setDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled);
961 settings->setJavaScriptCanAccessClipboard(
962 prefs.javascript_can_access_clipboard);
963 WebRuntimeFeatures::enableXSLT(prefs.xslt_enabled);
964 settings->setXSSAuditorEnabled(prefs.xss_auditor_enabled);
965 settings->setDNSPrefetchingEnabled(prefs.dns_prefetching_enabled);
Ben Greenstein49878f52015-12-18 19:13:21966 settings->setDataSaverEnabled(prefs.data_saver_enabled);
[email protected]b3a97b52014-07-09 06:25:05967 settings->setLocalStorageEnabled(prefs.local_storage_enabled);
968 settings->setSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled);
969 WebRuntimeFeatures::enableDatabase(prefs.databases_enabled);
970 settings->setOfflineWebApplicationCacheEnabled(
971 prefs.application_cache_enabled);
japhet5018fe62016-09-14 19:14:04972 settings->setHistoryEntryRequiresUserGesture(
973 prefs.history_entry_requires_user_gesture);
[email protected]b3a97b52014-07-09 06:25:05974 settings->setHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled);
975 settings->setCookieEnabled(prefs.cookie_enabled);
976 settings->setNavigateOnDragDrop(prefs.navigate_on_drag_drop);
977
[email protected]b3a97b52014-07-09 06:25:05978 // By default, allow_universal_access_from_file_urls is set to false and thus
979 // we mitigate attacks from local HTML files by not granting file:// URLs
980 // universal access. Only test shell will enable this.
981 settings->setAllowUniversalAccessFromFileURLs(
982 prefs.allow_universal_access_from_file_urls);
983 settings->setAllowFileAccessFromFileURLs(
984 prefs.allow_file_access_from_file_urls);
985
[email protected]b3a97b52014-07-09 06:25:05986 // Enable experimental WebGL support if requested on command line
987 // and support is compiled in.
988 settings->setExperimentalWebGLEnabled(prefs.experimental_webgl_enabled);
989
[email protected]b3a97b52014-07-09 06:25:05990 // Enable WebGL errors to the JS console if requested.
991 settings->setWebGLErrorsToConsoleEnabled(
992 prefs.webgl_errors_to_console_enabled);
993
994 // Uses the mock theme engine for scrollbars.
995 settings->setMockScrollbarsEnabled(prefs.mock_scrollbars_enabled);
996
eseckler61ff9142016-09-23 22:57:59997 settings->setHideScrollbars(prefs.hide_scrollbars);
998
[email protected]b3a97b52014-07-09 06:25:05999 // Enable gpu-accelerated 2d canvas if requested on the command line.
junov524668f22016-08-08 20:16:521000 WebRuntimeFeatures::enableAccelerated2dCanvas(
1001 prefs.accelerated_2d_canvas_enabled);
[email protected]b3a97b52014-07-09 06:25:051002
1003 settings->setMinimumAccelerated2dCanvasSize(
1004 prefs.minimum_accelerated_2d_canvas_size);
1005
1006 // Disable antialiasing for 2d canvas if requested on the command line.
1007 settings->setAntialiased2dCanvasEnabled(
1008 !prefs.antialiased_2d_canvas_disabled);
boliucfcae412016-02-11 22:16:381009 WebRuntimeFeatures::forceDisable2dCanvasCopyOnWrite(
1010 prefs.disable_2d_canvas_copy_on_write);
[email protected]b3a97b52014-07-09 06:25:051011
zakerinasab20ebca02016-09-27 14:22:341012 // Disable antialiasing of clips for 2d canvas if requested on the command
robertphillipse25137b2014-10-20 13:44:341013 // line.
1014 settings->setAntialiasedClips2dCanvasEnabled(
1015 prefs.antialiased_clips_2d_canvas_enabled);
1016
[email protected]b3a97b52014-07-09 06:25:051017 // Set MSAA sample count for 2d canvas if requested on the command line (or
1018 // default value if not).
1019 settings->setAccelerated2dCanvasMSAASampleCount(
1020 prefs.accelerated_2d_canvas_msaa_sample_count);
1021
[email protected]b3a97b52014-07-09 06:25:051022 // Tabs to link is not part of the settings. WebCore calls
1023 // ChromeClient::tabsToLinks which is part of the glue code.
1024 web_view->setTabsToLinks(prefs.tabs_to_links);
1025
[email protected]b3a97b52014-07-09 06:25:051026 settings->setAllowRunningOfInsecureContent(
1027 prefs.allow_running_insecure_content);
mkwst772ce8142015-01-16 13:28:071028 settings->setDisableReadingFromCanvas(prefs.disable_reading_from_canvas);
mkwst2fc2c4f2015-01-08 08:29:181029 settings->setStrictMixedContentChecking(prefs.strict_mixed_content_checking);
mkwst2384c8222015-07-30 07:26:471030
1031 settings->setStrictlyBlockBlockableMixedContent(
1032 prefs.strictly_block_blockable_mixed_content);
1033
mkwst0d233e52015-08-10 09:33:141034 settings->setStrictMixedContentCheckingForPlugin(
1035 prefs.block_mixed_plugin_content);
1036
mkwst673a452f2015-01-10 14:41:501037 settings->setStrictPowerfulFeatureRestrictions(
1038 prefs.strict_powerful_feature_restrictions);
jww9d4ca2d2016-01-19 20:58:591039 settings->setAllowGeolocationOnInsecureOrigins(
1040 prefs.allow_geolocation_on_insecure_origins);
[email protected]b3a97b52014-07-09 06:25:051041 settings->setPasswordEchoEnabled(prefs.password_echo_enabled);
1042 settings->setShouldPrintBackgrounds(prefs.should_print_backgrounds);
1043 settings->setShouldClearDocumentBackground(
1044 prefs.should_clear_document_background);
1045 settings->setEnableScrollAnimator(prefs.enable_scroll_animator);
1046
[email protected]b3a97b52014-07-09 06:25:051047 WebRuntimeFeatures::enableTouch(prefs.touch_enabled);
1048 settings->setMaxTouchPoints(prefs.pointer_events_max_touch_points);
mustaq29eb7092014-11-14 00:32:121049 settings->setAvailablePointerTypes(prefs.available_pointer_types);
1050 settings->setPrimaryPointerType(
nzolghadrc0d1663c2015-11-26 21:15:241051 static_cast<blink::PointerType>(prefs.primary_pointer_type));
mustaq29eb7092014-11-14 00:32:121052 settings->setAvailableHoverTypes(prefs.available_hover_types);
1053 settings->setPrimaryHoverType(
nzolghadrc0d1663c2015-11-26 21:15:241054 static_cast<blink::HoverType>(prefs.primary_hover_type));
[email protected]b3a97b52014-07-09 06:25:051055 settings->setDeviceSupportsTouch(prefs.device_supports_touch);
1056 settings->setDeviceSupportsMouse(prefs.device_supports_mouse);
1057 settings->setEnableTouchAdjustment(prefs.touch_adjustment_enabled);
1058
ccameron7c4df6c22016-08-11 03:03:151059 WebRuntimeFeatures::enableColorCorrectRendering(
1060 prefs.color_correct_rendering_enabled);
[email protected]b3a97b52014-07-09 06:25:051061 settings->setShouldRespectImageOrientation(
1062 prefs.should_respect_image_orientation);
1063
[email protected]b3a97b52014-07-09 06:25:051064 settings->setEditingBehavior(
1065 static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior));
1066
1067 settings->setSupportsMultipleWindows(prefs.supports_multiple_windows);
1068
ymalik835268c22016-02-22 16:28:121069 settings->setInertVisualViewport(prefs.inert_visual_viewport);
1070
khushalsagar2da2b232016-03-23 22:11:351071 settings->setMainFrameClipsContent(!prefs.record_whole_document);
1072
[email protected]b3a97b52014-07-09 06:25:051073 settings->setSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled);
1074
1075 settings->setSpatialNavigationEnabled(prefs.spatial_navigation_enabled);
1076
1077 settings->setSelectionIncludesAltImageText(true);
1078
[email protected]35103c02014-08-12 15:08:471079 settings->setV8CacheOptions(
1080 static_cast<WebSettings::V8CacheOptions>(prefs.v8_cache_options));
1081
horodbcbef42016-05-10 17:02:471082 settings->setV8CacheStrategiesForCacheStorage(
1083 GetV8CacheStrategiesForCacheStorage());
1084
je_julie.kim7fbb5a1a2015-02-09 17:26:051085 settings->setImageAnimationPolicy(
1086 static_cast<WebSettings::ImageAnimationPolicy>(prefs.animation_policy));
1087
zqzhang1215ad422016-02-10 13:27:221088 settings->setPresentationRequiresUserGesture(
1089 prefs.user_gesture_required_for_presentation);
1090
halliwell4002be42016-03-18 18:33:401091 settings->setTextTrackMarginPercentage(prefs.text_track_margin_percentage);
1092
dcheng5ae8ca362015-02-05 04:03:471093 // Needs to happen before setIgnoreVIewportTagScaleLimits below.
1094 web_view->setDefaultPageScaleLimits(
1095 prefs.default_minimum_page_scale_factor,
1096 prefs.default_maximum_page_scale_factor);
1097
[email protected]b3a97b52014-07-09 06:25:051098#if defined(OS_ANDROID)
1099 settings->setAllowCustomScrollbarInMainFrame(false);
1100 settings->setTextAutosizingEnabled(prefs.text_autosizing_enabled);
1101 settings->setAccessibilityFontScaleFactor(prefs.font_scale_factor);
1102 settings->setDeviceScaleAdjustment(prefs.device_scale_adjustment);
[email protected]023fed312014-08-11 16:13:051103 settings->setFullscreenSupported(prefs.fullscreen_supported);
[email protected]b3a97b52014-07-09 06:25:051104 web_view->setIgnoreViewportTagScaleLimits(prefs.force_enable_zoom);
1105 settings->setAutoZoomFocusedNodeToLegibleScale(true);
1106 settings->setDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled);
1107 settings->setMediaControlsOverlayPlayButtonEnabled(true);
1108 settings->setMediaPlaybackRequiresUserGesture(
1109 prefs.user_gesture_required_for_media_playback);
1110 settings->setDefaultVideoPosterURL(
dalecurtiscd971252016-09-21 16:09:001111 base::ASCIIToUTF16(prefs.default_video_poster_url.spec()));
[email protected]b3a97b52014-07-09 06:25:051112 settings->setSupportDeprecatedTargetDensityDPI(
1113 prefs.support_deprecated_target_density_dpi);
1114 settings->setUseLegacyBackgroundSizeShorthandBehavior(
1115 prefs.use_legacy_background_size_shorthand_behavior);
1116 settings->setWideViewportQuirkEnabled(prefs.wide_viewport_quirk);
1117 settings->setUseWideViewport(prefs.use_wide_viewport);
[email protected]9954ea92014-08-12 15:48:451118 settings->setForceZeroLayoutHeight(prefs.force_zero_layout_height);
[email protected]b3a97b52014-07-09 06:25:051119 settings->setViewportMetaLayoutSizeQuirk(
1120 prefs.viewport_meta_layout_size_quirk);
1121 settings->setViewportMetaMergeContentQuirk(
1122 prefs.viewport_meta_merge_content_quirk);
1123 settings->setViewportMetaNonUserScalableQuirk(
1124 prefs.viewport_meta_non_user_scalable_quirk);
1125 settings->setViewportMetaZeroValuesQuirk(
1126 prefs.viewport_meta_zero_values_quirk);
1127 settings->setClobberUserAgentInitialScaleQuirk(
1128 prefs.clobber_user_agent_initial_scale_quirk);
1129 settings->setIgnoreMainFrameOverflowHiddenQuirk(
1130 prefs.ignore_main_frame_overflow_hidden_quirk);
1131 settings->setReportScreenSizeInPhysicalPixelsQuirk(
1132 prefs.report_screen_size_in_physical_pixels_quirk);
boliu1a00f262016-04-06 19:08:461133 settings->setShouldReuseGlobalForUnownedMainFrame(
1134 prefs.resue_global_for_unowned_main_frame);
japhet98e9bd82016-06-28 23:48:451135 settings->setProgressBarCompletion(
1136 static_cast<WebSettings::ProgressBarCompletion>(
1137 prefs.progress_bar_completion));
liberato2f1a7e02015-08-10 16:01:411138 settings->setPreferHiddenVolumeControls(true);
dalecurtiscd971252016-09-21 16:09:001139
1140 // Force preload=none and disable autoplay on older or low end Android
1141 // platforms because their media pipelines are not stable enough to handle
1142 // concurrent elements. See http://crbug.com/612909, http://crbug.com/622826.
1143 const bool is_low_end_device =
1144 base::android::BuildInfo::GetInstance()->sdk_int() <=
1145 base::android::SDK_VERSION_JELLY_BEAN_MR2 ||
1146 base::SysInfo::IsLowEndDevice();
1147 settings->setForcePreloadNoneForMediaElements(is_low_end_device);
avayvodb28c3632016-06-09 11:19:061148 WebRuntimeFeatures::enableAutoplayMutedVideos(
dalecurtiscd971252016-09-21 16:09:001149 prefs.autoplay_muted_videos_enabled && !is_low_end_device);
timvolodinedb195192016-10-05 13:52:451150 settings->setSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default);
liberato9e934892016-05-03 19:00:271151#endif
1152
liberato6524fa42015-09-14 23:26:081153 settings->setAutoplayExperimentMode(
1154 blink::WebString::fromUTF8(prefs.autoplay_experiment_mode));
[email protected]b3a97b52014-07-09 06:25:051155
yoava1a508b42015-10-20 12:03:211156 settings->setViewportEnabled(prefs.viewport_enabled);
yoava1a508b42015-10-20 12:03:211157 settings->setViewportMetaEnabled(prefs.viewport_meta_enabled);
mlliub27b45c62016-06-10 19:30:091158 settings->setShrinksViewportContentToFit(
1159 prefs.shrinks_viewport_contents_to_fit);
alokp5d566962016-04-19 00:54:161160 settings->setViewportStyle(
1161 static_cast<blink::WebViewportStyle>(prefs.viewport_style));
1162
1163 settings->setLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale);
yoava1a508b42015-10-20 12:03:211164 settings->setMainFrameResizesAreOrientationChanges(
1165 prefs.main_frame_resizes_are_orientation_changes);
1166
[email protected]b3a97b52014-07-09 06:25:051167 settings->setPinchOverlayScrollbarThickness(
1168 prefs.pinch_overlay_scrollbar_thickness);
1169 settings->setUseSolidColorScrollbars(prefs.use_solid_color_scrollbars);
jinho.bang8f11ffa2014-12-04 06:03:031170
arjanl98804912015-03-04 09:23:041171 settings->setShowContextMenuOnMouseUp(prefs.context_menu_on_mouse_up);
amaralp547e4192016-06-03 19:17:351172 settings->setAlwaysShowContextMenuOnTouch(
1173 prefs.always_show_context_menu_on_touch);
ccameron2fd70de72015-02-19 00:40:401174
1175#if defined(OS_MACOSX)
1176 settings->setDoubleTapToZoomEnabled(true);
ccameronf29a7802015-02-20 22:11:251177 web_view->setMaximumLegibleScale(prefs.default_maximum_page_scale_factor);
ccameron2fd70de72015-02-19 00:40:401178#endif
sunyunjia87f287b2016-09-09 00:38:131179
1180#if defined(OS_WIN)
1181 WebRuntimeFeatures::enableMiddleClickAutoscroll(true);
1182#endif
[email protected]b3a97b52014-07-09 06:25:051183}
1184
1185/*static*/
dcheng35d31c112015-07-22 00:17:361186RenderViewImpl* RenderViewImpl::Create(CompositorDependencies* compositor_deps,
rockot067ca55f2016-09-30 22:00:151187 const mojom::CreateViewParams& params,
danakj6e3bf8012014-12-16 18:27:531188 bool was_created_by_renderer) {
naskobd911332014-11-25 01:13:361189 DCHECK(params.view_id != MSG_ROUTING_NONE);
[email protected]075366912013-02-18 07:13:241190 RenderViewImpl* render_view = NULL;
[email protected]8d41d7612012-11-14 20:32:191191 if (g_create_render_view_impl)
dcheng35d31c112015-07-22 00:17:361192 render_view = g_create_render_view_impl(compositor_deps, params);
[email protected]075366912013-02-18 07:13:241193 else
dcheng35d31c112015-07-22 00:17:361194 render_view = new RenderViewImpl(compositor_deps, params);
[email protected]0287e762014-04-11 13:07:581195
dcheng35d31c112015-07-22 00:17:361196 render_view->Initialize(params, was_created_by_renderer);
[email protected]075366912013-02-18 07:13:241197 return render_view;
[email protected]8d41d7612012-11-14 20:32:191198}
1199
1200// static
dcheng35d31c112015-07-22 00:17:361201void RenderViewImpl::InstallCreateHook(RenderViewImpl* (
1202 *create_render_view_impl)(CompositorDependencies* compositor_deps,
rockot067ca55f2016-09-30 22:00:151203 const mojom::CreateViewParams&)) {
[email protected]8d41d7612012-11-14 20:32:191204 CHECK(!g_create_render_view_impl);
1205 g_create_render_view_impl = create_render_view_impl;
initial.commit09911bf2008-07-26 23:55:291206}
1207
[email protected]310ebd6302011-10-10 19:06:281208void RenderViewImpl::AddObserver(RenderViewObserver* observer) {
[email protected]676126f72011-01-15 00:03:511209 observers_.AddObserver(observer);
1210}
1211
[email protected]310ebd6302011-10-10 19:06:281212void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) {
1213 observer->RenderViewGone();
[email protected]676126f72011-01-15 00:03:511214 observers_.RemoveObserver(observer);
1215}
1216
[email protected]180ef242013-11-07 06:50:461217blink::WebView* RenderViewImpl::webview() const {
lfg4fa48da2016-05-09 18:25:131218 return webview_;
[email protected]4d51d5bf2010-07-26 18:48:261219}
1220
[email protected]ea2fb972013-08-07 05:44:261221#if defined(ENABLE_PLUGINS)
[email protected]a99a38802014-01-14 15:46:571222
[email protected]784ea1ab2010-09-18 00:02:341223#if defined(OS_MACOSX)
[email protected]7411a3c2014-08-15 05:20:191224void RenderViewImpl::OnGetRenderedText() {
1225 if (!webview())
1226 return;
dglazkov03223492016-02-08 22:16:031227
1228 if (!webview()->mainFrame()->isWebLocalFrame())
1229 return;
1230
[email protected]7411a3c2014-08-15 05:20:191231 // Get rendered text from WebLocalFrame.
1232 // TODO: Currently IPC truncates any data that has a
1233 // size > kMaximumMessageSize. May be split the text into smaller chunks and
1234 // send back using multiple IPC. See http://crbug.com/393444.
1235 static const size_t kMaximumMessageSize = 8 * 1024 * 1024;
dglazkov03223492016-02-08 22:16:031236 // TODO(dglazkov): Using this API is wrong. It's not OOPIF-compatible and
1237 // sends text in the wrong order. See http://crbug.com/584798.
1238 // TODO(dglazkov): WebFrameContentDumper should only be used for
1239 // testing purposes. See http://crbug.com/585164.
1240 std::string text =
dglazkov2f8c7fc2016-04-17 19:46:201241 WebFrameContentDumper::dumpWebViewAsText(webview(), kMaximumMessageSize)
dglazkov03223492016-02-08 22:16:031242 .utf8();
[email protected]7411a3c2014-08-15 05:20:191243
avia3dca182016-03-19 01:09:521244 Send(new ViewMsg_GetRenderedTextCompleted(GetRoutingID(), text));
[email protected]7411a3c2014-08-15 05:20:191245}
[email protected]a80af12e2013-08-07 23:36:131246#endif // defined(OS_MACOSX)
1247
1248#endif // ENABLE_PLUGINS
1249
[email protected]7a1ec28a2012-03-28 21:10:241250void RenderViewImpl::TransferActiveWheelFlingAnimation(
[email protected]180ef242013-11-07 06:50:461251 const blink::WebActiveWheelFlingParameters& params) {
[email protected]7a1ec28a2012-03-28 21:10:241252 if (webview())
1253 webview()->transferActiveWheelFlingAnimation(params);
1254}
1255
fsamuel72464894f2015-12-15 06:59:311256// RenderWidgetInputHandlerDelegate -----------------------------------------
1257
avid7d6b2e2016-03-04 19:41:171258void RenderViewImpl::RenderWidgetFocusChangeComplete() {
fsamuel72464894f2015-12-15 06:59:311259 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete());
1260}
1261
avid7d6b2e2016-03-04 19:41:171262bool RenderViewImpl::DoesRenderWidgetHaveTouchEventHandlersAt(
1263 const gfx::Point& point) const {
fsamuel72464894f2015-12-15 06:59:311264 if (!webview())
1265 return false;
1266 return webview()->hasTouchEventHandlersAt(point);
1267}
1268
avid7d6b2e2016-03-04 19:41:171269bool RenderViewImpl::RenderWidgetWillHandleGestureEvent(
fsamuel72464894f2015-12-15 06:59:311270 const blink::WebGestureEvent& event) {
1271 possible_drag_event_info_.event_source =
1272 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH;
1273 possible_drag_event_info_.event_location =
1274 gfx::Point(event.globalX, event.globalY);
1275 return false;
1276}
1277
avid7d6b2e2016-03-04 19:41:171278bool RenderViewImpl::RenderWidgetWillHandleMouseEvent(
1279 const blink::WebMouseEvent& event) {
fsamuel72464894f2015-12-15 06:59:311280 possible_drag_event_info_.event_source =
1281 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE;
1282 possible_drag_event_info_.event_location =
1283 gfx::Point(event.globalX, event.globalY);
1284
fsamuel72464894f2015-12-15 06:59:311285 // If the mouse is locked, only the current owner of the mouse lock can
1286 // process mouse events.
1287 return mouse_lock_dispatcher_->WillHandleMouseEvent(event);
1288}
1289
1290// IPC::Listener implementation ----------------------------------------------
1291
[email protected]310ebd6302011-10-10 19:06:281292bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
[email protected]26aa0482009-09-30 16:55:271293 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL;
[email protected]82307f6b2014-08-07 03:30:121294 if (main_frame && main_frame->isWebLocalFrame())
[email protected]e9ff79c2012-10-19 21:31:261295 GetContentClient()->SetActiveURL(main_frame->document().url());
[email protected]f8b6b6f2009-03-10 16:48:261296
naskoc6edf7e2015-10-16 01:48:451297 // Input IPC messages must not be processed if the RenderView is in
1298 // swapped out state.
1299 if (is_swapped_out_ && IPC_MESSAGE_ID_CLASS(message.type()) == InputMsgStart)
1300 return false;
1301
dchenga2d442c22016-10-13 15:39:211302 for (auto& observer : observers_) {
1303 if (observer.OnMessageReceived(message))
[email protected]676126f72011-01-15 00:03:511304 return true;
dchenga2d442c22016-10-13 15:39:211305 }
[email protected]b2abac72009-02-26 12:39:281306
[email protected]a95986a82010-12-24 06:19:281307 bool handled = true;
[email protected]e44d1342014-05-16 21:29:331308 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message)
[email protected]c084330e02013-04-27 01:08:151309 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand)
1310 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret)
[email protected]c084330e02013-04-27 01:08:151311 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect,
1312 OnScrollFocusedEditableNodeIntoRect)
mcnee432e47d2015-11-09 19:37:461313 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale)
[email protected]630e26b2008-10-14 22:55:171314 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
scottmg3ea15712016-08-09 16:46:411315 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
1316 OnSetZoomLevelForLoadingURL)
[email protected]59f4f2fa2011-03-23 01:00:551317 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
1318 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
1319 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
1320 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
[email protected]7a6d773f2014-04-04 01:25:091321 IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded)
[email protected]59f4f2fa2011-03-23 01:00:551322 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded,
1323 OnDragSourceSystemDragEnded)
[email protected]18cb2572008-08-21 20:34:451324 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
initial.commit09911bf2008-07-26 23:55:291325 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus)
initial.commit09911bf2008-07-26 23:55:291326 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
1327 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
[email protected]600ea402011-04-12 00:01:511328 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse,
1329 OnEnumerateDirectoryResponse)
initial.commit09911bf2008-07-26 23:55:291330 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
[email protected]30f75e62009-02-25 22:01:001331 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
[email protected]ab6c9112014-02-27 00:20:581332 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement)
[email protected]61f91832014-05-13 01:24:421333 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque)
[email protected]ab32b16c2009-10-16 14:57:251334 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode,
1335 OnEnablePreferredSizeChangedMode)
[email protected]244ac1892011-12-02 17:04:471336 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize)
[email protected]61e2b3cc2012-03-02 16:13:341337 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize)
[email protected]cda45c02010-02-25 19:28:101338 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows,
1339 OnDisableScrollbarsForSmallWindows)
[email protected]80d96fa2009-06-10 22:34:511340 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs)
[email protected]581b87eb2009-07-23 23:06:561341 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
[email protected]81375e872012-01-11 21:40:361342 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
[email protected]8c66c5a2009-07-22 17:26:341343 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
[email protected]47822262013-04-23 17:22:361344 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu)
[email protected]cb189e062014-04-23 00:57:011345 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1346 OnReleaseDisambiguationPopupBitmap)
[email protected]506563d2014-06-23 12:22:411347 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
[email protected]4dda6a6c2014-05-17 15:35:041348 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
wjmaclean64951902016-04-29 20:59:121349
1350 // Page messages.
lfgdb5c4ed2016-03-04 23:09:071351 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect,
1352 OnUpdateWindowScreenRect)
wjmaclean64951902016-04-29 20:59:121353 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel)
wjmaclean8a795f32016-08-11 23:49:581354 IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor);
lfg717154072016-06-30 15:04:161355 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden)
1356 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown)
alexmos136fd6e62016-08-15 20:58:411357 IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength,
1358 OnSetHistoryOffsetAndLength)
lfg717154072016-06-30 15:04:161359
[email protected]55750b32012-09-21 14:05:031360#if defined(OS_ANDROID)
[email protected]452b4a92013-03-28 21:24:381361 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
1362 OnUpdateTopControlsState)
[email protected]c4790dcb2013-12-27 22:08:021363 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData)
[email protected]55750b32012-09-21 14:05:031364#elif defined(OS_MACOSX)
[email protected]7411a3c2014-08-15 05:20:191365 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText,
1366 OnGetRenderedText)
naskoc288745f2015-05-01 22:54:211367 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
[email protected]55750b32012-09-21 14:05:031368#endif
[email protected]a794f3a2013-10-30 17:00:321369 // Adding a new message? Add platform independent ones first, then put the
1370 // platform specific ones at the end.
[email protected]9e1ad4b2011-08-14 16:49:191371
initial.commit09911bf2008-07-26 23:55:291372 // Have the super handle all other messages.
[email protected]a95986a82010-12-24 06:19:281373 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
initial.commit09911bf2008-07-26 23:55:291374 IPC_END_MESSAGE_MAP()
[email protected]ffc906f2011-10-04 22:55:401375
[email protected]a95986a82010-12-24 06:19:281376 return handled;
initial.commit09911bf2008-07-26 23:55:291377}
1378
[email protected]4dda6a6c2014-05-17 15:35:041379void RenderViewImpl::OnSelectWordAroundCaret() {
1380 if (!webview())
1381 return;
1382
fsamuele8326c742016-01-12 00:49:391383 input_handler_->set_handling_input_event(true);
[email protected]4dda6a6c2014-05-17 15:35:041384 webview()->focusedFrame()->selectWordAroundCaret();
fsamuele8326c742016-01-12 00:49:391385 input_handler_->set_handling_input_event(false);
[email protected]4dda6a6c2014-05-17 15:35:041386}
1387
[email protected]310ebd6302011-10-10 19:06:281388void RenderViewImpl::OnUpdateTargetURLAck() {
initial.commit09911bf2008-07-26 23:55:291389 // Check if there is a targeturl waiting to be sent.
avi450ce00e2014-09-24 01:58:521390 if (target_url_status_ == TARGET_PENDING)
avia3dca182016-03-19 01:09:521391 Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), pending_target_url_));
initial.commit09911bf2008-07-26 23:55:291392
1393 target_url_status_ = TARGET_NONE;
1394}
1395
[email protected]c084330e02013-04-27 01:08:151396void RenderViewImpl::OnExecuteEditCommand(const std::string& name,
1397 const std::string& value) {
1398 if (!webview() || !webview()->focusedFrame())
1399 return;
1400
1401 webview()->focusedFrame()->executeCommand(
1402 WebString::fromUTF8(name), WebString::fromUTF8(value));
1403}
1404
1405void RenderViewImpl::OnMoveCaret(const gfx::Point& point) {
1406 if (!webview())
1407 return;
1408
avia3dca182016-03-19 01:09:521409 Send(new InputHostMsg_MoveCaret_ACK(GetRoutingID()));
oshima93b827d92016-03-01 18:58:411410 webview()->focusedFrame()->moveCaretSelection(
1411 ConvertWindowPointToViewport(point));
[email protected]c084330e02013-04-27 01:08:151412}
[email protected]a954bf72009-09-12 07:30:351413
[email protected]c084330e02013-04-27 01:08:151414void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect(
1415 const gfx::Rect& rect) {
[email protected]1875bc02014-03-14 06:33:591416 if (has_scrolled_focused_editable_node_into_rect_ &&
1417 rect == rect_for_scrolled_focused_editable_node_) {
avid7d6b2e2016-03-04 19:41:171418 GetWidget()->FocusChangeComplete();
[email protected]1875bc02014-03-14 06:33:591419 return;
1420 }
1421
dglazkov4969a3e2016-05-20 21:13:511422 if (!webview()->scrollFocusedEditableElementIntoRect(rect))
1423 return;
rouslanf7ebd8832015-01-22 01:54:141424
dglazkov4969a3e2016-05-20 21:13:511425 rect_for_scrolled_focused_editable_node_ = rect;
1426 has_scrolled_focused_editable_node_into_rect_ = true;
1427 if (!compositor()->hasPendingPageScaleAnimation())
avid7d6b2e2016-03-04 19:41:171428 GetWidget()->FocusChangeComplete();
[email protected]25bcc8f2013-01-09 02:49:251429}
1430
avi2b177592014-12-10 02:08:021431void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset,
1432 int history_length) {
1433 DCHECK_GE(history_offset, -1);
[email protected]e1ed5a12012-08-08 19:57:441434 DCHECK_GE(history_length, 0);
[email protected]9e1ad4b2011-08-14 16:49:191435
avi2b177592014-12-10 02:08:021436 history_list_offset_ = history_offset;
1437 history_list_length_ = history_length;
[email protected]9e1ad4b2011-08-14 16:49:191438}
1439
[email protected]310ebd6302011-10-10 19:06:281440void RenderViewImpl::OnSetInitialFocus(bool reverse) {
initial.commit09911bf2008-07-26 23:55:291441 if (!webview())
1442 return;
[email protected]26aa0482009-09-30 16:55:271443 webview()->setInitialFocus(reverse);
initial.commit09911bf2008-07-26 23:55:291444}
1445
lfgdb5c4ed2016-03-04 23:09:071446void RenderViewImpl::OnUpdateWindowScreenRect(gfx::Rect window_screen_rect) {
1447 RenderWidget::OnUpdateWindowScreenRect(window_screen_rect);
1448}
1449
initial.commit09911bf2008-07-26 23:55:291450///////////////////////////////////////////////////////////////////////////////
1451
avi137dc952015-07-24 23:19:141452void RenderViewImpl::SendUpdateState() {
creis8eb8ef22015-11-04 22:51:381453 // We don't use this path in OOPIF-enabled modes.
1454 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries());
creisae7ce9a2015-11-02 20:52:191455
avi137dc952015-07-24 23:19:141456 HistoryEntry* entry = history_controller_->GetCurrentEntry();
avif937e1d2014-11-02 18:13:071457 if (!entry)
1458 return;
1459
avi1edc8552016-10-13 21:37:161460 Send(new ViewHostMsg_UpdateState(GetRoutingID(),
fsamuele8326c742016-01-12 00:49:391461 HistoryEntryToPageState(entry)));
avif937e1d2014-11-02 18:13:071462}
1463
creis69b184a472015-11-26 05:29:511464void RenderViewImpl::SendFrameStateUpdates() {
1465 // We only use this path in OOPIF-enabled modes.
1466 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries());
1467
1468 // Tell each frame with pending state to send its UpdateState message.
1469 for (int render_frame_routing_id : frames_with_pending_state_) {
1470 RenderFrameImpl* frame =
1471 RenderFrameImpl::FromRoutingID(render_frame_routing_id);
1472 if (frame)
1473 frame->SendUpdateState();
1474 }
1475 frames_with_pending_state_.clear();
1476}
1477
sataya.mf405d0e2015-07-07 16:51:111478void RenderViewImpl::ApplyWebPreferencesInternal(
1479 const WebPreferences& prefs,
1480 blink::WebView* web_view,
1481 CompositorDependencies* compositor_deps) {
1482 ApplyWebPreferences(prefs, web_view);
sataya.mf405d0e2015-07-07 16:51:111483}
1484
svartmetal751af1f92016-08-13 11:47:331485void RenderViewImpl::OnForceRedraw(const ui::LatencyInfo& latency_info) {
[email protected]7d08a9352013-10-15 08:24:561486 if (RenderWidgetCompositor* rwc = compositor()) {
svartmetal751af1f92016-08-13 11:47:331487 rwc->QueueSwapPromise(
1488 base::MakeUnique<AlwaysDrawSwapPromise>(latency_info));
[email protected]7d08a9352013-10-15 08:24:561489 }
1490 ScheduleCompositeWithForcedRedraw();
[email protected]c9bc8f12012-12-15 22:20:091491}
1492
[email protected]180ef242013-11-07 06:50:461493// blink::WebViewClient ------------------------------------------------------
[email protected]48c9cf2d2009-09-16 16:47:521494
[email protected]35b2a972014-04-04 15:50:221495WebView* RenderViewImpl::createView(WebLocalFrame* creator,
1496 const WebURLRequest& request,
1497 const WebWindowFeatures& features,
1498 const WebString& frame_name,
1499 WebNavigationPolicy policy,
1500 bool suppress_opener) {
rockot5c478a72016-09-28 23:14:181501 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New();
1502 params->opener_id = GetRoutingID();
1503 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
[email protected]00323f02013-07-24 15:47:411504 if (GetContentClient()->renderer()->AllowPopup())
rockot5c478a72016-09-28 23:14:181505 params->user_gesture = true;
1506 params->window_container_type = WindowFeaturesToContainerType(features);
1507 params->session_storage_namespace_id = session_storage_namespace_id_;
[email protected]5cef23d2013-02-27 13:11:211508 if (frame_name != "_blank")
rockot5c478a72016-09-28 23:14:181509 params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name));
1510 params->opener_render_frame_id =
[email protected]501052ff2014-02-21 22:19:071511 RenderFrameImpl::FromWebFrame(creator)->GetRoutingID();
rockot5c478a72016-09-28 23:14:181512 params->opener_url = creator->document().url();
alexmosa97d5c52015-06-19 22:19:091513
1514 // The browser process uses the top frame's URL for a content settings check
1515 // to determine whether the popup is allowed. If the top frame is remote,
1516 // its URL is not available, so use its replicated origin instead.
1517 //
1518 // TODO(alexmos): This works fine for regular origins but may break path
1519 // matching for file URLs with OOP subframes that open popups. This should
1520 // be fixed by either moving this lookup to the browser process or removing
1521 // path-based matching for file URLs from content settings. See
1522 // https://crbug.com/466297.
1523 if (creator->top()->isWebLocalFrame()) {
rockot5c478a72016-09-28 23:14:181524 params->opener_top_level_frame_url = creator->top()->document().url();
alexmosa97d5c52015-06-19 22:19:091525 } else {
rockot5c478a72016-09-28 23:14:181526 params->opener_top_level_frame_url =
Dana Jansens71331252016-03-09 20:57:221527 blink::WebStringToGURL(creator->top()->getSecurityOrigin().toString());
alexmosa97d5c52015-06-19 22:19:091528 }
1529
brettwdfbcc3b2016-01-20 01:49:171530 GURL security_url(blink::WebStringToGURL(
Dana Jansens71331252016-03-09 20:57:221531 creator->document().getSecurityOrigin().toString()));
[email protected]7f48b712013-01-25 01:48:301532 if (!security_url.is_valid())
1533 security_url = GURL();
rockot5c478a72016-09-28 23:14:181534 params->opener_security_origin = security_url;
1535 params->opener_suppressed = suppress_opener;
1536 params->disposition = NavigationPolicyToDisposition(policy);
[email protected]44e55b012013-07-23 14:21:561537 if (!request.isNull()) {
rockot5c478a72016-09-28 23:14:181538 params->target_url = request.url();
1539 params->referrer = GetReferrerFromRequest(creator, request);
[email protected]44e55b012013-07-23 14:21:561540 }
rockot5c478a72016-09-28 23:14:181541 params->features = features;
[email protected]8ab04652010-06-12 02:47:261542
rockot5c478a72016-09-28 23:14:181543 // We preserve this information before sending the message since |params| is
1544 // moved on send.
1545 bool is_background_tab =
1546 params->disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB;
1547 bool opened_by_user_gesture = params->user_gesture;
[email protected]22217ed32013-11-18 18:40:231548
rockot5c478a72016-09-28 23:14:181549 mojom::CreateNewWindowReplyPtr reply;
1550 RenderThreadImpl::current_render_message_filter()->CreateNewWindow(
1551 std::move(params), &reply);
1552 if (reply->route_id == MSG_ROUTING_NONE)
1553 return nullptr;
[email protected]48c9cf2d2009-09-16 16:47:521554
[email protected]af15bf22013-03-08 01:18:171555 WebUserGestureIndicator::consumeUserGesture();
[email protected]c59262422012-11-30 21:20:521556
[email protected]7912e822014-04-16 02:37:031557 // While this view may be a background extension page, it can spawn a visible
1558 // render view. So we just assume that the new one is not another background
1559 // page instead of passing on our own value.
1560 // TODO(vangelis): Can we tell if the new view will be a background page?
1561 bool never_visible = false;
[email protected]9115d5f2013-03-24 04:37:411562
fsamuel664e8b62016-01-20 19:54:011563 ResizeParams initial_size = ResizeParams();
mkosiba58fa72f02014-11-12 01:21:361564 initial_size.screen_info = screen_info_;
1565
[email protected]d6fa88f2013-10-18 16:00:431566 // The initial hidden state for the RenderViewImpl here has to match what the
1567 // browser will eventually decide for the given disposition. Since we have to
1568 // return from this call synchronously, we just have to make our best guess
1569 // and rely on the browser sending a WasHidden / WasShown message if it
1570 // disagrees.
rockot067ca55f2016-09-30 22:00:151571 mojom::CreateViewParams view_params;
alexmos5ac402d2015-07-09 07:51:101572
1573 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator);
1574 view_params.opener_frame_route_id = creator_frame->GetRoutingID();
avia3dca182016-03-19 01:09:521575 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID());
alexmos5ac402d2015-07-09 07:51:101576
naskobd911332014-11-25 01:13:361577 view_params.window_was_created_with_opener = true;
1578 view_params.renderer_preferences = renderer_preferences_;
1579 view_params.web_preferences = webkit_preferences_;
rockot5c478a72016-09-28 23:14:181580 view_params.view_id = reply->route_id;
1581 view_params.main_frame_routing_id = reply->main_frame_route_id;
1582 view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id;
naskobd911332014-11-25 01:13:361583 view_params.session_storage_namespace_id =
rockot5c478a72016-09-28 23:14:181584 reply->cloned_session_storage_namespace_id;
naskobd911332014-11-25 01:13:361585 view_params.swapped_out = false;
alexmos3448b552015-06-26 07:49:131586 // WebCore will take care of setting the correct name.
alexmosbc7eafa2014-12-06 01:38:091587 view_params.replicated_frame_state = FrameReplicationState();
rockot5c478a72016-09-28 23:14:181588 view_params.hidden = is_background_tab;
naskobd911332014-11-25 01:13:361589 view_params.never_visible = never_visible;
naskobd911332014-11-25 01:13:361590 view_params.initial_size = initial_size;
1591 view_params.enable_auto_resize = false;
1592 view_params.min_size = gfx::Size();
1593 view_params.max_size = gfx::Size();
wjmaclean64951902016-04-29 20:59:121594 view_params.page_zoom_level = page_zoom_level_;
naskobd911332014-11-25 01:13:361595
danakj6e3bf8012014-12-16 18:27:531596 RenderViewImpl* view =
dcheng35d31c112015-07-22 00:17:361597 RenderViewImpl::Create(compositor_deps_, view_params, true);
rockot5c478a72016-09-28 23:14:181598 view->opened_by_user_gesture_ = opened_by_user_gesture;
[email protected]48c9cf2d2009-09-16 16:47:521599
[email protected]48c9cf2d2009-09-16 16:47:521600 return view->webview();
1601}
1602
[email protected]180ef242013-11-07 06:50:461603WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) {
avia3dca182016-03-19 01:09:521604 RenderWidget* widget = RenderWidget::Create(GetRoutingID(), compositor_deps_,
danakj6e3bf8012014-12-16 18:27:531605 popup_type, screen_info_);
[email protected]3b78ec12014-03-04 05:18:281606 if (!widget)
1607 return NULL;
[email protected]b2e4c70132013-10-03 02:07:511608 if (screen_metrics_emulator_) {
1609 widget->SetPopupOriginAdjustmentsForEmulation(
1610 screen_metrics_emulator_.get());
1611 }
lfg8ff33912016-09-13 20:59:211612 return widget->GetWebWidget();
[email protected]48c9cf2d2009-09-16 16:47:521613}
1614
[email protected]23367482013-06-27 21:06:541615WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() {
[email protected]5f2aa722013-08-07 16:59:411616 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId);
[email protected]1910fe82012-05-10 00:04:101617 return new WebStorageNamespaceImpl(session_storage_namespace_id_);
[email protected]bd92c3a2010-01-13 05:02:341618}
1619
[email protected]35b2a972014-04-04 15:50:221620void RenderViewImpl::printPage(WebLocalFrame* frame) {
naskoe440d8c2016-10-12 23:07:561621 UMA_HISTOGRAM_BOOLEAN("PrintPreview.InitiatedByScript",
1622 frame->top() == frame);
1623
1624 // Logging whether the top frame is remote is sufficient in this case. If
1625 // the top frame is local, the printing code will function correctly and
1626 // the frame itself will be printed, so the cases this histogram tracks is
1627 // where printing of a subframe will fail as of now.
1628 UMA_HISTOGRAM_BOOLEAN("PrintPreview.OutOfProcessSubframe",
1629 frame->top()->isWebRemoteFrame());
1630
[email protected]b0553c7e2012-09-19 21:36:111631 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
fsamuel72464894f2015-12-15 06:59:311632 PrintPage(frame, input_handler().handling_input_event()));
[email protected]48c9cf2d2009-09-16 16:47:521633}
1634
[email protected]310ebd6302011-10-10 19:06:281635bool RenderViewImpl::enumerateChosenDirectory(
[email protected]8a58c1c2011-04-19 18:40:121636 const WebString& path,
1637 WebFileChooserCompletion* chooser_completion) {
1638 int id = enumeration_completion_id_++;
1639 enumeration_completions_[id] = chooser_completion;
1640 return Send(new ViewHostMsg_EnumerateDirectory(
avia3dca182016-03-19 01:09:521641 GetRoutingID(), id, blink::WebStringToFilePath(path)));
[email protected]8a58c1c2011-04-19 18:40:121642}
1643
[email protected]7e9523b2014-03-25 03:02:421644void RenderViewImpl::FrameDidStartLoading(WebFrame* frame) {
[email protected]7e9523b2014-03-25 03:02:421645 DCHECK_GE(frames_in_progress_, 0);
1646 if (frames_in_progress_ == 0)
1647 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading());
1648 frames_in_progress_++;
[email protected]6dd5c322014-03-12 07:58:461649}
1650
[email protected]7e9523b2014-03-25 03:02:421651void RenderViewImpl::FrameDidStopLoading(WebFrame* frame) {
[email protected]eb473772014-04-11 20:54:331652 // TODO(japhet): This should be a DCHECK, but the pdf plugin sometimes
1653 // calls DidStopLoading() without a matching DidStartLoading().
1654 if (frames_in_progress_ == 0)
1655 return;
[email protected]7e9523b2014-03-25 03:02:421656 frames_in_progress_--;
[email protected]7e9523b2014-03-25 03:02:421657 if (frames_in_progress_ == 0) {
1658 DidStopLoadingIcons();
1659 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading());
1660 }
[email protected]48c9cf2d2009-09-16 16:47:521661}
1662
lfgcaab5142016-02-26 19:06:521663void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) {
dcheng3ce04b62015-10-26 23:30:551664 // The previous WebFrameWidget must already be detached by CloseForFrame().
1665 DCHECK(!frame_widget_);
1666 frame_widget_ = frame_widget;
1667}
1668
tommycli8aad3ba2015-08-12 17:57:591669void RenderViewImpl::SetZoomLevel(double zoom_level) {
wjmaclean64951902016-04-29 20:59:121670 // If we change the zoom level for the view, make sure any subsequent subframe
1671 // loads reflect the current zoom level.
1672 page_zoom_level_ = zoom_level;
1673
tommycli8aad3ba2015-08-12 17:57:591674 webview()->setZoomLevel(zoom_level);
1675 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged());
1676}
1677
[email protected]550b0c92013-02-04 05:09:151678void RenderViewImpl::didCancelCompositionOnSelectionChange() {
avia3dca182016-03-19 01:09:521679 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID()));
[email protected]550b0c92013-02-04 05:09:151680}
1681
habib.virji597255e2014-09-09 00:30:181682void RenderViewImpl::SetValidationMessageDirection(
1683 base::string16* wrapped_main_text,
1684 blink::WebTextDirection main_text_hint,
1685 base::string16* wrapped_sub_text,
1686 blink::WebTextDirection sub_text_hint) {
1687 if (main_text_hint == blink::WebTextDirectionLeftToRight) {
1688 *wrapped_main_text =
1689 base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text);
1690 } else if (main_text_hint == blink::WebTextDirectionRightToLeft &&
1691 !base::i18n::IsRTL()) {
1692 base::i18n::WrapStringWithRTLFormatting(wrapped_main_text);
1693 }
1694
1695 if (!wrapped_sub_text->empty()) {
1696 if (sub_text_hint == blink::WebTextDirectionLeftToRight) {
1697 *wrapped_sub_text =
1698 base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_sub_text);
1699 } else if (sub_text_hint == blink::WebTextDirectionRightToLeft) {
1700 base::i18n::WrapStringWithRTLFormatting(wrapped_sub_text);
1701 }
1702 }
1703}
1704
[email protected]edc3af82013-12-12 21:24:071705void RenderViewImpl::showValidationMessage(
bokan72a7e342015-12-03 15:46:281706 const blink::WebRect& anchor_in_viewport,
[email protected]edc3af82013-12-12 21:24:071707 const blink::WebString& main_text,
habib.virji597255e2014-09-09 00:30:181708 blink::WebTextDirection main_text_hint,
[email protected]edc3af82013-12-12 21:24:071709 const blink::WebString& sub_text,
habib.virji597255e2014-09-09 00:30:181710 blink::WebTextDirection sub_text_hint) {
[email protected]edc3af82013-12-12 21:24:071711 base::string16 wrapped_main_text = main_text;
1712 base::string16 wrapped_sub_text = sub_text;
habib.virji597255e2014-09-09 00:30:181713
1714 SetValidationMessageDirection(
1715 &wrapped_main_text, main_text_hint, &wrapped_sub_text, sub_text_hint);
1716
[email protected]edc3af82013-12-12 21:24:071717 Send(new ViewHostMsg_ShowValidationMessage(
avia3dca182016-03-19 01:09:521718 GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport),
[email protected]2d6836f42014-07-02 17:25:311719 wrapped_main_text, wrapped_sub_text));
[email protected]edc3af82013-12-12 21:24:071720}
1721
1722void RenderViewImpl::hideValidationMessage() {
avia3dca182016-03-19 01:09:521723 Send(new ViewHostMsg_HideValidationMessage(GetRoutingID()));
[email protected]edc3af82013-12-12 21:24:071724}
1725
1726void RenderViewImpl::moveValidationMessage(
bokan72a7e342015-12-03 15:46:281727 const blink::WebRect& anchor_in_viewport) {
[email protected]2d6836f42014-07-02 17:25:311728 Send(new ViewHostMsg_MoveValidationMessage(
avia3dca182016-03-19 01:09:521729 GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport)));
[email protected]edc3af82013-12-12 21:24:071730}
1731
[email protected]310ebd6302011-10-10 19:06:281732void RenderViewImpl::setStatusText(const WebString& text) {
[email protected]48c9cf2d2009-09-16 16:47:521733}
1734
[email protected]310ebd6302011-10-10 19:06:281735void RenderViewImpl::UpdateTargetURL(const GURL& url,
1736 const GURL& fallback_url) {
[email protected]aa6b90b32010-04-26 15:49:581737 GURL latest_url = url.is_empty() ? fallback_url : url;
[email protected]48c9cf2d2009-09-16 16:47:521738 if (latest_url == target_url_)
1739 return;
[email protected]163f8242009-10-30 20:19:551740
[email protected]48c9cf2d2009-09-16 16:47:521741 // Tell the browser to display a destination link.
1742 if (target_url_status_ == TARGET_INFLIGHT ||
1743 target_url_status_ == TARGET_PENDING) {
1744 // If we have a request in-flight, save the URL to be sent when we
1745 // receive an ACK to the in-flight request. We can happily overwrite
1746 // any existing pending sends.
1747 pending_target_url_ = latest_url;
1748 target_url_status_ = TARGET_PENDING;
1749 } else {
mnaganovbf087422015-12-16 05:10:031750 // URLs larger than |kMaxURLChars| cannot be sent through IPC -
[email protected]c85f0212011-11-04 16:54:411751 // see |ParamTraits<GURL>|.
markdittmer67b71ea2016-03-03 22:40:031752 if (latest_url.possibly_invalid_spec().size() > url::kMaxURLChars)
[email protected]c85f0212011-11-04 16:54:411753 latest_url = GURL();
avia3dca182016-03-19 01:09:521754 Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), latest_url));
[email protected]48c9cf2d2009-09-16 16:47:521755 target_url_ = latest_url;
1756 target_url_status_ = TARGET_INFLIGHT;
1757 }
1758}
1759
[email protected]70221f02013-01-31 22:17:071760gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect(
1761 const gfx::RectF& rect) const {
1762 gfx::RectF window_rect = rect;
1763 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor());
1764 return window_rect;
1765}
1766
creis69b184a472015-11-26 05:29:511767void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) {
1768 // In OOPIF modes, keep track of which frames have pending updates.
creis8eb8ef22015-11-04 22:51:381769 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
creis69b184a472015-11-26 05:29:511770 frames_with_pending_state_.insert(frame->GetRoutingID());
creis8eb8ef22015-11-04 22:51:381771
[email protected]882daa92009-11-05 16:31:311772 int delay;
avif937e1d2014-11-02 18:13:071773 if (send_content_state_immediately_)
[email protected]882daa92009-11-05 16:31:311774 delay = 0;
1775 else if (is_hidden())
avif937e1d2014-11-02 18:13:071776 delay = kDelaySecondsForContentStateSyncHidden;
[email protected]882daa92009-11-05 16:31:311777 else
avif937e1d2014-11-02 18:13:071778 delay = kDelaySecondsForContentStateSync;
[email protected]882daa92009-11-05 16:31:311779
avif937e1d2014-11-02 18:13:071780 if (nav_state_sync_timer_.IsRunning()) {
[email protected]882daa92009-11-05 16:31:311781 // The timer is already running. If the delay of the timer maches the amount
1782 // we want to delay by, then return. Otherwise stop the timer so that it
1783 // gets started with the right delay.
avif937e1d2014-11-02 18:13:071784 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay)
[email protected]882daa92009-11-05 16:31:311785 return;
avif937e1d2014-11-02 18:13:071786 nav_state_sync_timer_.Stop();
[email protected]882daa92009-11-05 16:31:311787 }
1788
creis69b184a472015-11-26 05:29:511789 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1790 // In OOPIF modes, tell each frame with pending state to inform the browser.
1791 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this,
1792 &RenderViewImpl::SendFrameStateUpdates);
1793 } else {
1794 // By default, send an UpdateState for the current history item.
1795 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this,
1796 &RenderViewImpl::SendUpdateState);
1797 }
[email protected]882daa92009-11-05 16:31:311798}
1799
[email protected]310ebd6302011-10-10 19:06:281800void RenderViewImpl::setMouseOverURL(const WebURL& url) {
[email protected]163f8242009-10-30 20:19:551801 mouse_over_url_ = GURL(url);
1802 UpdateTargetURL(mouse_over_url_, focus_url_);
1803}
1804
[email protected]310ebd6302011-10-10 19:06:281805void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) {
[email protected]163f8242009-10-30 20:19:551806 focus_url_ = GURL(url);
1807 UpdateTargetURL(focus_url_, mouse_over_url_);
1808}
1809
[email protected]35b2a972014-04-04 15:50:221810void RenderViewImpl::startDragging(WebLocalFrame* frame,
[email protected]0407e422012-05-18 19:51:251811 const WebDragData& data,
[email protected]310ebd6302011-10-10 19:06:281812 WebDragOperationsMask mask,
1813 const WebImage& image,
[email protected]ceb36f7d2012-10-31 18:33:241814 const WebPoint& webImageOffset) {
oshimab3313232016-01-28 01:13:221815 blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0);
danakjdea2efb2016-03-10 19:13:171816 ConvertViewportToWindowViaWidget(&offset_in_window);
[email protected]dc293a72013-07-01 11:11:221817 DropData drop_data(DropDataBuilder::Build(data));
[email protected]b67151d2012-05-25 23:23:241818 drop_data.referrer_policy = frame->document().referrerPolicy();
oshimab3313232016-01-28 01:13:221819 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y);
avia3dca182016-03-19 01:09:521820 Send(new DragHostMsg_StartDragging(GetRoutingID(), drop_data, mask,
fsamuele8326c742016-01-12 00:49:391821 image.getSkBitmap(), imageOffset,
[email protected]41d86852012-11-07 12:23:241822 possible_drag_event_info_));
[email protected]48c9cf2d2009-09-16 16:47:521823}
1824
[email protected]310ebd6302011-10-10 19:06:281825bool RenderViewImpl::acceptsLoadDrops() {
[email protected]28b92df2009-09-25 17:35:451826 return renderer_preferences_.can_accept_load_drops;
1827}
1828
[email protected]310ebd6302011-10-10 19:06:281829void RenderViewImpl::focusNext() {
avia3dca182016-03-19 01:09:521830 Send(new ViewHostMsg_TakeFocus(GetRoutingID(), false));
[email protected]48c9cf2d2009-09-16 16:47:521831}
1832
[email protected]310ebd6302011-10-10 19:06:281833void RenderViewImpl::focusPrevious() {
avia3dca182016-03-19 01:09:521834 Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true));
[email protected]48c9cf2d2009-09-16 16:47:521835}
1836
esprehn3d4471a2015-09-17 07:13:201837// TODO(esprehn): Blink only ever passes Elements, this should take WebElement.
estade31c54342015-01-23 03:34:361838void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode,
1839 const WebNode& toNode) {
[email protected]1875bc02014-03-14 06:33:591840 has_scrolled_focused_editable_node_into_rect_ = false;
1841
jennyz399d6e62014-12-16 01:40:051842 gfx::Rect node_bounds;
esprehn3d4471a2015-09-17 07:13:201843 bool is_editable = false;
estade31c54342015-01-23 03:34:361844 if (!toNode.isNull() && toNode.isElementNode()) {
esprehn3d4471a2015-09-17 07:13:201845 WebElement element = const_cast<WebNode&>(toNode).to<WebElement>();
oshimae2b3b402015-12-04 04:27:241846 blink::WebRect rect = element.boundsInViewport();
danakjdea2efb2016-03-10 19:13:171847 ConvertViewportToWindowViaWidget(&rect);
oshimae2b3b402015-12-04 04:27:241848 node_bounds = gfx::Rect(rect);
esprehn3d4471a2015-09-17 07:13:201849 is_editable = element.isEditable();
jennyz399d6e62014-12-16 01:40:051850 }
avia3dca182016-03-19 01:09:521851 Send(new ViewHostMsg_FocusedNodeChanged(GetRoutingID(), is_editable,
jennyz399d6e62014-12-16 01:40:051852 node_bounds));
[email protected]a4b103b2010-10-05 18:46:071853
estade31c54342015-01-23 03:34:361854 // TODO(estade): remove.
1855 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(toNode));
[email protected]95640212014-07-26 18:14:301856
estade31c54342015-01-23 03:34:361857 RenderFrameImpl* previous_frame = nullptr;
1858 if (!fromNode.isNull())
1859 previous_frame = RenderFrameImpl::FromWebFrame(fromNode.document().frame());
1860 RenderFrameImpl* new_frame = nullptr;
1861 if (!toNode.isNull())
1862 new_frame = RenderFrameImpl::FromWebFrame(toNode.document().frame());
1863
1864 if (previous_frame && previous_frame != new_frame)
1865 previous_frame->FocusedNodeChanged(WebNode());
1866 if (new_frame)
1867 new_frame->FocusedNodeChanged(toNode);
1868
1869 // TODO(dmazzoni): remove once there's a separate a11y tree per frame.
naskoe8d115752015-08-07 00:43:131870 if (main_render_frame_)
1871 main_render_frame_->FocusedNodeChangedForAccessibility(toNode);
[email protected]08e9e132010-06-01 16:58:491872}
1873
[email protected]169d4282011-11-30 19:33:591874void RenderViewImpl::didUpdateLayout() {
[email protected]d01b2a62013-09-18 23:21:331875 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout());
1876
[email protected]169d4282011-11-30 19:33:591877 // We don't always want to set up a timer, only if we've been put in that
1878 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
1879 // message.
1880 if (!send_preferred_size_changes_ || !webview())
1881 return;
1882
1883 if (check_preferred_size_timer_.IsRunning())
1884 return;
1885 check_preferred_size_timer_.Start(FROM_HERE,
1886 TimeDelta::FromMilliseconds(0), this,
1887 &RenderViewImpl::CheckPreferredSize);
1888}
1889
[email protected]310ebd6302011-10-10 19:06:281890void RenderViewImpl::navigateBackForwardSoon(int offset) {
avia3dca182016-03-19 01:09:521891 Send(new ViewHostMsg_GoToEntryAtOffset(GetRoutingID(), offset));
[email protected]48c9cf2d2009-09-16 16:47:521892}
1893
[email protected]310ebd6302011-10-10 19:06:281894int RenderViewImpl::historyBackListCount() {
[email protected]3cc72b12010-03-18 23:03:001895 return history_list_offset_ < 0 ? 0 : history_list_offset_;
[email protected]48c9cf2d2009-09-16 16:47:521896}
1897
[email protected]310ebd6302011-10-10 19:06:281898int RenderViewImpl::historyForwardListCount() {
[email protected]3cc72b12010-03-18 23:03:001899 return history_list_length_ - historyBackListCount() - 1;
[email protected]48c9cf2d2009-09-16 16:47:521900}
1901
[email protected]180ef242013-11-07 06:50:461902// blink::WebWidgetClient ----------------------------------------------------
[email protected]79dbc662009-09-04 05:42:511903
[email protected]310ebd6302011-10-10 19:06:281904void RenderViewImpl::didFocus() {
[email protected]ea42e7782010-08-23 23:58:121905 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed
1906 // we won't have to test for user gesture anymore and we can
1907 // move that code back to render_widget.cc
[email protected]af15bf22013-03-08 01:18:171908 if (WebUserGestureIndicator::isProcessingUserGesture() &&
[email protected]70dee7e2013-05-29 18:28:301909 !RenderThreadImpl::current()->layout_test_mode()) {
avia3dca182016-03-19 01:09:521910 Send(new ViewHostMsg_Focus(GetRoutingID()));
[email protected]ea42e7782010-08-23 23:58:121911 }
1912}
1913
initial.commit09911bf2008-07-26 23:55:291914// We are supposed to get a single call to Show for a newly created RenderView
[email protected]310ebd6302011-10-10 19:06:281915// that was created via RenderViewImpl::CreateWebView. So, we wait until this
initial.commit09911bf2008-07-26 23:55:291916// point to dispatch the ShowView message.
1917//
1918// This method provides us with the information about how to display the newly
[email protected]5f9de5882011-09-30 23:36:281919// created RenderView (i.e., as a blocked popup or as a new tab).
initial.commit09911bf2008-07-26 23:55:291920//
[email protected]310ebd6302011-10-10 19:06:281921void RenderViewImpl::show(WebNavigationPolicy policy) {
[email protected]b2142e962012-10-30 13:59:251922 if (did_show_) {
[email protected]b2142e962012-10-30 13:59:251923 // When supports_multiple_windows is disabled, popups are reusing
1924 // the same view. In some scenarios, this makes WebKit to call show() twice.
[email protected]c9edabd2013-05-23 13:56:241925 if (webkit_preferences_.supports_multiple_windows)
1926 NOTREACHED() << "received extraneous Show call";
initial.commit09911bf2008-07-26 23:55:291927 return;
[email protected]b2142e962012-10-30 13:59:251928 }
initial.commit09911bf2008-07-26 23:55:291929 did_show_ = true;
1930
[email protected]b2142e962012-10-30 13:59:251931 DCHECK(opener_id_ != MSG_ROUTING_NONE);
1932
bokanc007c3a2015-02-03 07:15:561933 // NOTE: initial_rect_ may still have its default values at this point, but
initial.commit09911bf2008-07-26 23:55:291934 // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the
1935 // browser process will impose a default position otherwise.
avia3dca182016-03-19 01:09:521936 Send(new ViewHostMsg_ShowView(opener_id_, GetRoutingID(),
fsamuele8326c742016-01-12 00:49:391937 NavigationPolicyToDisposition(policy),
1938 initial_rect_, opened_by_user_gesture_));
bokanc007c3a2015-02-03 07:15:561939 SetPendingWindowRect(initial_rect_);
initial.commit09911bf2008-07-26 23:55:291940}
1941
miletuse8d28ba2015-06-19 04:52:041942void RenderViewImpl::onMouseDown(const WebNode& mouse_down_node) {
1943 FOR_EACH_OBSERVER(
1944 RenderViewObserver, observers_, OnMouseDown(mouse_down_node));
1945}
1946
[email protected]c68c3e4e2013-01-24 00:36:561947void RenderViewImpl::didHandleGestureEvent(
1948 const WebGestureEvent& event,
1949 bool event_cancelled) {
1950 RenderWidget::didHandleGestureEvent(event, event_cancelled);
[email protected]bb37b652013-11-27 23:47:111951
[email protected]91dcc6d32014-07-30 00:01:331952 if (!event_cancelled) {
1953 FOR_EACH_OBSERVER(
1954 RenderViewObserver, observers_, DidHandleGestureEvent(event));
1955 }
1956
jdduke45762d22014-10-07 04:19:081957 // TODO(ananta): Piggyback off existing IPCs to communicate this information,
1958 // crbug/420130.
1959#if defined(OS_WIN)
[email protected]bb37b652013-11-27 23:47:111960 if (event.type != blink::WebGestureEvent::GestureTap)
1961 return;
1962
[email protected]91dcc6d32014-07-30 00:01:331963 // TODO(estade): hit test the event against focused node to make sure
1964 // the tap actually hit the focused node.
jdduke3bf083fe2015-09-29 23:40:531965 blink::WebTextInputType text_input_type = GetWebView()->textInputType();
[email protected]bb37b652013-11-27 23:47:111966
1967 Send(new ViewHostMsg_FocusedNodeTouched(
avia3dca182016-03-19 01:09:521968 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone));
jdduke45762d22014-10-07 04:19:081969#endif
[email protected]c68c3e4e2013-01-24 00:36:561970}
1971
[email protected]6e89eb72013-07-23 13:28:221972void RenderViewImpl::initializeLayerTreeView() {
1973 RenderWidget::initializeLayerTreeView();
1974 RenderWidgetCompositor* rwc = compositor();
[email protected]9f7638f42014-05-30 01:51:161975 if (!rwc)
[email protected]6e89eb72013-07-23 13:28:221976 return;
[email protected]9f7638f42014-05-30 01:51:161977
ccameron1f89c002014-10-21 06:19:051978 bool use_threaded_event_handling = true;
jame1f453c2016-03-21 15:51:341979#if defined(OS_MACOSX)
ccamerona7644752014-12-30 01:16:311980 // Disable threaded event handling if content is not handling the elastic
1981 // overscroll effect. This includes the cases where the elastic overscroll
1982 // effect is being handled by Blink (because of command line flags) and older
1983 // operating system versions which do not have an elastic overscroll effect
1984 // (SnowLeopard, which has Aqua scrollbars which need synchronous updates).
1985 use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled();
[email protected]9f7638f42014-05-30 01:51:161986#endif
changwand659e202016-06-13 02:39:121987 if (!use_threaded_event_handling)
1988 return;
1989
1990 RenderThreadImpl* render_thread = RenderThreadImpl::current();
1991 // render_thread may be NULL in tests.
1992 InputHandlerManager* input_handler_manager =
1993 render_thread ? render_thread->input_handler_manager() : NULL;
1994 if (input_handler_manager) {
1995 input_handler_manager->AddInputHandler(
1996 GetRoutingID(), rwc->GetInputHandler(), AsWeakPtr(),
1997 webkit_preferences_.enable_scroll_animator);
1998 has_added_input_handler_ = true;
ccameron1f89c002014-10-21 06:19:051999 }
[email protected]6e89eb72013-07-23 13:28:222000}
2001
lfg2230bce2016-04-28 18:37:042002void RenderViewImpl::closeWidgetSoon() {
2003 RenderWidget::closeWidgetSoon();
2004}
2005
2006void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) {
2007 RenderWidget::convertViewportToWindow(rect);
2008}
2009
2010void RenderViewImpl::convertWindowToViewport(blink::WebFloatRect* rect) {
2011 RenderWidget::convertWindowToViewport(rect);
2012}
2013
2014void RenderViewImpl::didAutoResize(const blink::WebSize& newSize) {
lfgb00fcad2016-07-14 14:16:332015 RenderWidget::DidAutoResize(newSize);
lfg2230bce2016-04-28 18:37:042016}
2017
lfg2230bce2016-04-28 18:37:042018void RenderViewImpl::didOverscroll(
2019 const blink::WebFloatSize& overscrollDelta,
2020 const blink::WebFloatSize& accumulatedOverscroll,
2021 const blink::WebFloatPoint& positionInViewport,
2022 const blink::WebFloatSize& velocityInViewport) {
2023 RenderWidget::didOverscroll(overscrollDelta, accumulatedOverscroll,
2024 positionInViewport, velocityInViewport);
2025}
2026
lfg2230bce2016-04-28 18:37:042027void RenderViewImpl::hasTouchEventHandlers(bool has_handlers) {
2028 RenderWidget::hasTouchEventHandlers(has_handlers);
2029}
2030
lfg2230bce2016-04-28 18:37:042031void RenderViewImpl::resetInputMethod() {
2032 RenderWidget::resetInputMethod();
2033}
2034
2035blink::WebRect RenderViewImpl::rootWindowRect() {
bokan6b08cd22016-10-05 00:55:212036 return RenderWidget::windowRect();
lfg2230bce2016-04-28 18:37:042037}
2038
lfg2230bce2016-04-28 18:37:042039blink::WebScreenInfo RenderViewImpl::screenInfo() {
2040 return RenderWidget::screenInfo();
2041}
2042
2043void RenderViewImpl::setToolTipText(const blink::WebString& text,
2044 blink::WebTextDirection hint) {
2045 RenderWidget::setToolTipText(text, hint);
2046}
2047
2048void RenderViewImpl::setTouchAction(blink::WebTouchAction touchAction) {
2049 RenderWidget::setTouchAction(touchAction);
2050}
2051
lfg2230bce2016-04-28 18:37:042052void RenderViewImpl::showImeIfNeeded() {
2053 RenderWidget::showImeIfNeeded();
2054}
2055
2056void RenderViewImpl::showUnhandledTapUIIfNeeded(
2057 const blink::WebPoint& tappedPosition,
2058 const blink::WebNode& tappedNode,
2059 bool pageChanged) {
2060 RenderWidget::showUnhandledTapUIIfNeeded(tappedPosition, tappedNode,
2061 pageChanged);
2062}
2063
lfg0f440622016-07-20 04:27:142064blink::WebWidgetClient* RenderViewImpl::widgetClient() {
2065 return static_cast<RenderWidget*>(this);
2066}
2067
[email protected]180ef242013-11-07 06:50:462068// blink::WebFrameClient -----------------------------------------------------
[email protected]3d9689372009-09-10 04:29:172069
[email protected]5e92282f2012-08-17 08:11:572070void RenderViewImpl::Repaint(const gfx::Size& size) {
[email protected]3d9ec5052013-01-02 22:05:252071 OnRepaint(size);
[email protected]5e92282f2012-08-17 08:11:572072}
2073
[email protected]b2324b092012-11-01 10:34:112074void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name,
2075 const std::string& value) {
alexmos56567492016-09-13 00:52:462076 GetWidget()->SetEditCommandForNextKeyEvent(name, value);
[email protected]b2324b092012-11-01 10:34:112077}
2078
2079void RenderViewImpl::ClearEditCommands() {
alexmos56567492016-09-13 00:52:462080 GetWidget()->ClearEditCommands();
[email protected]b2324b092012-11-01 10:34:112081}
2082
[email protected]b38806a2013-10-04 16:01:382083const std::string& RenderViewImpl::GetAcceptLanguages() const {
2084 return renderer_preferences_.accept_languages;
2085}
2086
danakjdea2efb2016-03-10 19:13:172087void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) {
2088 convertViewportToWindow(rect);
oshimae2b3b402015-12-04 04:27:242089}
2090
huangs2a342352015-12-15 16:59:242091gfx::RectF RenderViewImpl::ElementBoundsInWindow(
2092 const blink::WebElement& element) {
2093 blink::WebRect bounding_box_in_window = element.boundsInViewport();
danakjdea2efb2016-03-10 19:13:172094 ConvertViewportToWindowViaWidget(&bounding_box_in_window);
huangs2a342352015-12-15 16:59:242095 return gfx::RectF(bounding_box_in_window);
2096}
2097
changwand659e202016-06-13 02:39:122098bool RenderViewImpl::HasAddedInputHandler() const {
2099 return has_added_input_handler_;
2100}
2101
oshima4300f52e92016-02-18 21:51:042102gfx::Point RenderViewImpl::ConvertWindowPointToViewport(
2103 const gfx::Point& point) {
2104 blink::WebFloatRect point_in_viewport(point.x(), point.y(), 0, 0);
2105 convertWindowToViewport(&point_in_viewport);
2106 return gfx::Point(point_in_viewport.x, point_in_viewport.y);
2107}
2108
[email protected]35b2a972014-04-04 15:50:222109void RenderViewImpl::didChangeIcon(WebLocalFrame* frame,
[email protected]41225fe2013-03-29 05:32:022110 WebIconURL::Type icon_type) {
2111 if (frame->parent())
2112 return;
2113
[email protected]41225fe2013-03-29 05:32:022114 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type);
2115 std::vector<FaviconURL> urls;
2116 for (size_t i = 0; i < icon_urls.size(); i++) {
[email protected]2bd262b2014-04-16 05:31:232117 std::vector<gfx::Size> sizes;
[email protected]f34ac132014-03-20 23:02:052118 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
2119 urls.push_back(FaviconURL(
2120 icon_urls[i].iconURL(), ToFaviconType(icon_urls[i].iconType()), sizes));
[email protected]41225fe2013-03-29 05:32:022121 }
2122 SendUpdateFaviconURL(urls);
[email protected]5019ef12010-04-27 17:26:582123}
2124
[email protected]310ebd6302011-10-10 19:06:282125void RenderViewImpl::CheckPreferredSize() {
[email protected]d812fd12011-05-27 23:05:072126 // We don't always want to send the change messages over IPC, only if we've
2127 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
2128 // message.
2129 if (!send_preferred_size_changes_ || !webview())
2130 return;
2131
[email protected]e76b7972013-06-06 02:58:482132 gfx::Size size = webview()->contentsPreferredMinimumSize();
[email protected]705243f2010-05-05 19:58:072133 if (size == preferred_size_)
2134 return;
[email protected]c27324b2009-11-19 22:44:292135
[email protected]705243f2010-05-05 19:58:072136 preferred_size_ = size;
avia3dca182016-03-19 01:09:522137 Send(new ViewHostMsg_DidContentsPreferredSizeChange(GetRoutingID(),
[email protected]705243f2010-05-05 19:58:072138 preferred_size_));
[email protected]3d9689372009-09-10 04:29:172139}
2140
[email protected]180ef242013-11-07 06:50:462141blink::WebString RenderViewImpl::acceptLanguages() {
[email protected]9982c802013-06-12 15:22:062142 return WebString::fromUTF8(renderer_preferences_.accept_languages);
2143}
2144
[email protected]e9ff79c2012-10-19 21:31:262145// RenderView implementation ---------------------------------------------------
[email protected]a2ef54c2011-10-10 16:20:312146
[email protected]310ebd6302011-10-10 19:06:282147bool RenderViewImpl::Send(IPC::Message* message) {
[email protected]a2ef54c2011-10-10 16:20:312148 return RenderWidget::Send(message);
2149}
2150
avi8a45c1092016-03-01 16:12:342151RenderWidget* RenderViewImpl::GetWidget() const {
2152 return const_cast<RenderWidget*>(static_cast<const RenderWidget*>(this));
2153}
2154
mostynbc33353232014-09-12 09:38:312155RenderFrameImpl* RenderViewImpl::GetMainRenderFrame() {
nasko77de2312015-05-12 03:09:162156 return main_render_frame_;
[email protected]b849847b2013-12-10 21:57:582157}
2158
[email protected]82114f52012-03-20 22:53:412159int RenderViewImpl::GetRoutingID() const {
fsamuele8326c742016-01-12 00:49:392160 return routing_id();
[email protected]a2ef54c2011-10-10 16:20:312161}
2162
[email protected]82114f52012-03-20 22:53:412163gfx::Size RenderViewImpl::GetSize() const {
[email protected]a2ef54c2011-10-10 16:20:312164 return size();
2165}
2166
oshima129b75e2016-01-14 09:15:142167float RenderViewImpl::GetDeviceScaleFactor() const {
2168 return device_scale_factor_;
2169}
2170
[email protected]82114f52012-03-20 22:53:412171WebPreferences& RenderViewImpl::GetWebkitPreferences() {
[email protected]a2ef54c2011-10-10 16:20:312172 return webkit_preferences_;
2173}
2174
[email protected]324825d2012-11-30 12:37:152175void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) {
2176 OnUpdateWebPreferences(preferences);
2177}
2178
[email protected]180ef242013-11-07 06:50:462179blink::WebView* RenderViewImpl::GetWebView() {
[email protected]a2ef54c2011-10-10 16:20:312180 return webview();
2181}
2182
lfgcaab5142016-02-26 19:06:522183blink::WebFrameWidget* RenderViewImpl::GetWebFrameWidget() {
2184 return frame_widget_;
2185}
2186
[email protected]310ebd6302011-10-10 19:06:282187bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const {
[email protected]a2ef54c2011-10-10 16:20:312188 return (!send_preferred_size_changes_ ||
2189 (disable_scrollbars_size_limit_.width() <= width ||
2190 disable_scrollbars_size_limit_.height() <= height));
2191}
2192
[email protected]82114f52012-03-20 22:53:412193int RenderViewImpl::GetEnabledBindings() const {
[email protected]a2ef54c2011-10-10 16:20:312194 return enabled_bindings_;
2195}
2196
avif937e1d2014-11-02 18:13:072197bool RenderViewImpl::GetContentStateImmediately() const {
2198 return send_content_state_immediately_;
[email protected]a2ef54c2011-10-10 16:20:312199}
2200
mcnee432e47d2015-11-09 19:37:462201void RenderViewImpl::OnSetPageScale(float page_scale_factor) {
ccameronb7c1d6c2015-03-09 17:08:242202 if (!webview())
2203 return;
mcnee432e47d2015-11-09 19:37:462204 webview()->setPageScaleFactor(page_scale_factor);
ccameronb7c1d6c2015-03-09 17:08:242205}
2206
[email protected]e9ff79c2012-10-19 21:31:262207void RenderViewImpl::OnZoom(PageZoom zoom) {
[email protected]40bd6582009-12-04 23:49:512208 if (!webview()) // Not sure if this can happen, but no harm in being safe.
2209 return;
2210
[email protected]258d31122010-05-09 10:59:412211 webview()->hidePopups();
[email protected]854ab5462011-11-22 20:48:102212
[email protected]b75b8292010-10-01 07:28:252213 double old_zoom_level = webview()->zoomLevel();
2214 double zoom_level;
[email protected]e9ff79c2012-10-19 21:31:262215 if (zoom == PAGE_ZOOM_RESET) {
[email protected]b75b8292010-10-01 07:28:252216 zoom_level = 0;
2217 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) {
2218 // Previous zoom level is a whole number, so just increment/decrement.
[email protected]54087fe2011-10-28 22:02:482219 zoom_level = old_zoom_level + zoom;
[email protected]b75b8292010-10-01 07:28:252220 } else {
2221 // Either the user hit the zoom factor limit and thus the zoom level is now
2222 // not a whole number, or a plugin changed it to a custom value. We want
2223 // to go to the next whole number so that the user can always get back to
2224 // 100% with the keyboard/menu.
[email protected]54087fe2011-10-28 22:02:482225 if ((old_zoom_level > 1 && zoom > 0) ||
2226 (old_zoom_level < 1 && zoom < 0)) {
2227 zoom_level = static_cast<int>(old_zoom_level + zoom);
[email protected]b75b8292010-10-01 07:28:252228 } else {
2229 // We're going towards 100%, so first go to the next whole number.
2230 zoom_level = static_cast<int>(old_zoom_level);
2231 }
2232 }
tommycli8aad3ba2015-08-12 17:57:592233 SetZoomLevel(zoom_level);
[email protected]47578fa02011-11-02 19:34:412234 zoomLevelChanged();
2235}
2236
scottmg3ea15712016-08-09 16:46:412237void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url,
2238 double zoom_level) {
2239 // TODO(wjmaclean): We should see if this restriction is really necessary,
2240 // since it isn't enforced in other parts of the page zoom system (e.g.
2241 // when a users changes the zoom of a currently displayed page). Android
2242 // has no UI for this, so in theory the following code would normally just use
2243 // the default zoom anyways.
2244#if !defined(OS_ANDROID)
2245 // On Android, page zoom isn't used, and in case of WebView, text zoom is used
2246 // for legacy WebView text scaling emulation. Thus, the code that resets
2247 // the zoom level from this map will be effectively resetting text zoom level.
2248 host_zoom_levels_[url] = zoom_level;
2249#endif
2250}
2251
wjmaclean64951902016-04-29 20:59:122252void RenderViewImpl::OnSetZoomLevel(
2253 PageMsg_SetZoomLevel_Command command,
2254 double zoom_level) {
2255 switch (command) {
2256 case PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY:
2257 uses_temporary_zoom_level_ = false;
2258 break;
2259 case PageMsg_SetZoomLevel_Command::SET_TEMPORARY:
2260 uses_temporary_zoom_level_ = true;
2261 break;
2262 case PageMsg_SetZoomLevel_Command::USE_CURRENT_TEMPORARY_MODE:
2263 // Don't override a temporary zoom level without an explicit SET.
2264 if (uses_temporary_zoom_level_)
2265 return;
2266 break;
2267 default:
2268 NOTIMPLEMENTED();
2269 }
[email protected]d42bf472014-06-14 01:49:382270 webview()->hidePopups();
wjmaclean64951902016-04-29 20:59:122271 SetZoomLevel(zoom_level);
[email protected]d42bf472014-06-14 01:49:382272}
2273
[email protected]310ebd6302011-10-10 19:06:282274void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) {
[email protected]940ed1d2012-11-27 21:03:212275 if ((enabled_bindings_flags & BINDINGS_POLICY_WEB_UI) &&
2276 !(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) {
[email protected]69a0a132014-03-26 16:45:022277 // WebUIExtensionData deletes itself when we're destroyed.
[email protected]940ed1d2012-11-27 21:03:212278 new WebUIExtensionData(this);
2279 }
2280
[email protected]81e63782009-02-27 19:35:092281 enabled_bindings_ |= enabled_bindings_flags;
[email protected]744c2a22012-03-15 18:42:042282
2283 // Keep track of the total bindings accumulated in this process.
2284 RenderProcess::current()->AddBindings(enabled_bindings_flags);
sammce2f99982016-03-14 22:38:122285
2286 if (main_render_frame_)
2287 main_render_frame_->MaybeEnableMojoBindings();
initial.commit09911bf2008-07-26 23:55:292288}
2289
hush8915b502016-06-15 19:32:232290void RenderViewImpl::OnDragTargetDragEnter(
2291 const std::vector<DropData::Metadata>& drop_meta_data,
2292 const gfx::Point& client_point,
2293 const gfx::Point& screen_point,
2294 WebDragOperationsMask ops,
2295 int key_modifiers) {
[email protected]59f4f2fa2011-03-23 01:00:552296 WebDragOperation operation = webview()->dragTargetDragEnter(
hush8915b502016-06-15 19:32:232297 DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point,
2298 ops, key_modifiers);
[email protected]59f4f2fa2011-03-23 01:00:552299
avia3dca182016-03-19 01:09:522300 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
[email protected]59f4f2fa2011-03-23 01:00:552301}
2302
[email protected]310ebd6302011-10-10 19:06:282303void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point,
2304 const gfx::Point& screen_point,
[email protected]1f2230b2012-05-17 23:43:422305 WebDragOperationsMask ops,
2306 int key_modifiers) {
[email protected]59f4f2fa2011-03-23 01:00:552307 WebDragOperation operation = webview()->dragTargetDragOver(
oshima4300f52e92016-02-18 21:51:042308 ConvertWindowPointToViewport(client_point),
[email protected]59f4f2fa2011-03-23 01:00:552309 screen_point,
[email protected]1f2230b2012-05-17 23:43:422310 ops,
2311 key_modifiers);
[email protected]59f4f2fa2011-03-23 01:00:552312
avia3dca182016-03-19 01:09:522313 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
[email protected]59f4f2fa2011-03-23 01:00:552314}
2315
[email protected]310ebd6302011-10-10 19:06:282316void RenderViewImpl::OnDragTargetDragLeave() {
[email protected]59f4f2fa2011-03-23 01:00:552317 webview()->dragTargetDragLeave();
2318}
2319
hush8915b502016-06-15 19:32:232320void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data,
2321 const gfx::Point& client_point,
[email protected]1f2230b2012-05-17 23:43:422322 const gfx::Point& screen_point,
2323 int key_modifiers) {
bsep9d8c8532016-09-27 18:19:232324 webview()->dragTargetDrop(DropDataToWebDragData(drop_data),
2325 ConvertWindowPointToViewport(client_point),
hush8915b502016-06-15 19:32:232326 screen_point, key_modifiers);
[email protected]59f4f2fa2011-03-23 01:00:552327}
2328
[email protected]7a6d773f2014-04-04 01:25:092329void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point,
2330 const gfx::Point& screen_point,
2331 WebDragOperation op) {
oshima4300f52e92016-02-18 21:51:042332 webview()->dragSourceEndedAt(
2333 ConvertWindowPointToViewport(client_point), screen_point, op);
initial.commit09911bf2008-07-26 23:55:292334}
2335
[email protected]310ebd6302011-10-10 19:06:282336void RenderViewImpl::OnDragSourceSystemDragEnded() {
[email protected]26aa0482009-09-30 16:55:272337 webview()->dragSourceSystemDragEnded();
initial.commit09911bf2008-07-26 23:55:292338}
2339
[email protected]310ebd6302011-10-10 19:06:282340void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) {
[email protected]2fab253a2009-08-17 23:00:592341 webkit_preferences_ = prefs;
sataya.mf405d0e2015-07-07 16:51:112342 ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_);
initial.commit09911bf2008-07-26 23:55:292343}
2344
[email protected]310ebd6302011-10-10 19:06:282345void RenderViewImpl::OnEnumerateDirectoryResponse(
[email protected]600ea402011-04-12 00:01:512346 int id,
[email protected]c42de732013-02-16 06:26:312347 const std::vector<base::FilePath>& paths) {
[email protected]600ea402011-04-12 00:01:512348 if (!enumeration_completions_[id])
2349 return;
2350
2351 WebVector<WebString> ws_file_names(paths.size());
2352 for (size_t i = 0; i < paths.size(); ++i)
[email protected]728c2ee2013-06-25 04:01:072353 ws_file_names[i] = paths[i].AsUTF16Unsafe();
[email protected]600ea402011-04-12 00:01:512354
2355 enumeration_completions_[id]->didChooseFile(ws_file_names);
2356 enumeration_completions_.erase(id);
2357}
2358
[email protected]244ac1892011-12-02 17:04:472359void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size,
2360 const gfx::Size& max_size) {
2361 DCHECK(disable_scrollbars_size_limit_.IsEmpty());
2362 if (!webview())
2363 return;
oshima33ec97cd2015-12-14 19:40:242364
[email protected]97e1bf72013-03-06 14:06:052365 auto_resize_mode_ = true;
oshima33ec97cd2015-12-14 19:40:242366 if (IsUseZoomForDSFEnabled()) {
2367 webview()->enableAutoResizeMode(
2368 gfx::ScaleToCeiledSize(min_size, device_scale_factor_),
2369 gfx::ScaleToCeiledSize(max_size, device_scale_factor_));
2370 } else {
2371 webview()->enableAutoResizeMode(min_size, max_size);
2372 }
[email protected]61e2b3cc2012-03-02 16:13:342373}
2374
2375void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) {
2376 DCHECK(disable_scrollbars_size_limit_.IsEmpty());
2377 if (!webview())
2378 return;
[email protected]97e1bf72013-03-06 14:06:052379 auto_resize_mode_ = false;
[email protected]61e2b3cc2012-03-02 16:13:342380 webview()->disableAutoResizeMode();
2381
[email protected]eac2b362013-05-22 07:01:452382 if (!new_size.IsEmpty()) {
mfomitchev2600fd7c2016-02-17 20:53:392383 ResizeParams resize_params;
jbroman5ff10302016-07-22 03:36:262384 resize_params.screen_info = screen_info_;
mfomitchev2600fd7c2016-02-17 20:53:392385 resize_params.new_size = new_size;
2386 resize_params.physical_backing_size = physical_backing_size_;
2387 resize_params.top_controls_shrink_blink_size =
2388 top_controls_shrink_blink_size_;
2389 resize_params.top_controls_height = top_controls_height_;
2390 resize_params.visible_viewport_size = visible_viewport_size_;
mfomitchev2600fd7c2016-02-17 20:53:392391 resize_params.is_fullscreen_granted = is_fullscreen_granted();
2392 resize_params.display_mode = display_mode_;
2393 resize_params.needs_resize_ack = false;
2394 Resize(resize_params);
[email protected]eac2b362013-05-22 07:01:452395 }
[email protected]244ac1892011-12-02 17:04:472396}
2397
[email protected]2bf834f2011-11-17 20:02:212398void RenderViewImpl::OnEnablePreferredSizeChangedMode() {
[email protected]9fb325e2010-05-06 18:23:242399 if (send_preferred_size_changes_)
2400 return;
[email protected]9fb325e2010-05-06 18:23:242401 send_preferred_size_changes_ = true;
[email protected]770dd8b2010-05-24 18:11:392402
[email protected]d812fd12011-05-27 23:05:072403 // Start off with an initial preferred size notification (in case
2404 // |didUpdateLayout| was already called).
[email protected]169d4282011-11-30 19:33:592405 didUpdateLayout();
[email protected]0666aef2009-05-13 19:48:082406}
2407
[email protected]310ebd6302011-10-10 19:06:282408void RenderViewImpl::OnDisableScrollbarsForSmallWindows(
[email protected]cda45c02010-02-25 19:28:102409 const gfx::Size& disable_scrollbar_size_limit) {
2410 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit;
2411}
2412
[email protected]310ebd6302011-10-10 19:06:282413void RenderViewImpl::OnSetRendererPrefs(
[email protected]e9ff79c2012-10-19 21:31:262414 const RendererPreferences& renderer_prefs) {
[email protected]ebd5ea52014-05-28 14:51:152415 std::string old_accept_languages = renderer_preferences_.accept_languages;
2416
[email protected]80d96fa2009-06-10 22:34:512417 renderer_preferences_ = renderer_prefs;
ananta59b9fe72015-04-07 01:33:262418
[email protected]6e282c92009-07-24 01:19:372419 UpdateFontRenderingFromRendererPrefs();
scottmgb92365e2016-08-30 20:54:402420 UpdateThemePrefs();
ellyjones8ae17692016-08-05 15:19:212421 blink::setCaretBlinkInterval(renderer_prefs.caret_blink_interval);
[email protected]38a85712013-01-02 22:45:022422
[email protected]dcc297772014-04-10 22:20:522423#if defined(USE_DEFAULT_RENDER_THEME)
[email protected]1596efb2013-01-17 22:13:012424 if (renderer_prefs.use_custom_colors) {
esprehn021507d2015-11-13 23:35:012425 blink::setFocusRingColor(renderer_prefs.focus_ring_color);
[email protected]1596efb2013-01-17 22:13:012426
2427 if (webview()) {
[email protected]1596efb2013-01-17 22:13:012428 webview()->setSelectionColors(
2429 renderer_prefs.active_selection_bg_color,
2430 renderer_prefs.active_selection_fg_color,
2431 renderer_prefs.inactive_selection_bg_color,
2432 renderer_prefs.inactive_selection_fg_color);
2433 webview()->themeChanged();
2434 }
[email protected]644d77e2010-01-27 01:03:102435 }
[email protected]c997bc42014-04-11 18:25:582436#endif // defined(USE_DEFAULT_RENDER_THEME)
[email protected]d299d972012-03-23 02:26:552437
[email protected]ebd5ea52014-05-28 14:51:152438 if (webview() &&
2439 old_accept_languages != renderer_preferences_.accept_languages) {
2440 webview()->acceptLanguagesChanged();
2441 }
[email protected]80d96fa2009-06-10 22:34:512442}
2443
[email protected]310ebd6302011-10-10 19:06:282444void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location,
2445 const WebMediaPlayerAction& action) {
[email protected]952cb702009-10-07 05:50:282446 if (webview())
2447 webview()->performMediaPlayerAction(action, location);
[email protected]581b87eb2009-07-23 23:06:562448}
2449
[email protected]fcdc5642014-05-09 14:32:242450void RenderViewImpl::OnOrientationChange() {
japhete20ec7c2015-03-18 19:16:182451 if (webview() && webview()->mainFrame()->isWebLocalFrame())
2452 webview()->mainFrame()->toWebLocalFrame()->sendOrientationChangeEvent();
[email protected]77829642012-05-15 14:47:172453}
2454
[email protected]81375e872012-01-11 21:40:362455void RenderViewImpl::OnPluginActionAt(const gfx::Point& location,
2456 const WebPluginAction& action) {
2457 if (webview())
2458 webview()->performPluginAction(action, location);
2459}
2460
[email protected]310ebd6302011-10-10 19:06:282461void RenderViewImpl::OnClosePage() {
[email protected]77fc9b92011-10-15 16:20:372462 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage());
initial.commit09911bf2008-07-26 23:55:292463 // TODO(creis): We'd rather use webview()->Close() here, but that currently
2464 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs
2465 // in the onunload handler from appearing. For now, we're bypassing that and
2466 // calling the FrameLoader's CloseURL method directly. This should be
2467 // revisited to avoid having two ways to close a page. Having a single way
2468 // to close that can run onunload is also useful for fixing
2469 // http://b/issue?id=753080.
[email protected]11fd5db2014-04-02 03:49:462470 webview()->mainFrame()->dispatchUnloadEvent();
initial.commit09911bf2008-07-26 23:55:292471
avia3dca182016-03-19 01:09:522472 Send(new ViewHostMsg_ClosePage_ACK(GetRoutingID()));
initial.commit09911bf2008-07-26 23:55:292473}
2474
naskoc288745f2015-05-01 22:54:212475void RenderViewImpl::OnClose() {
2476 if (closing_)
avia3dca182016-03-19 01:09:522477 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID()));
naskoc288745f2015-05-01 22:54:212478 RenderWidget::OnClose();
2479}
2480
[email protected]310ebd6302011-10-10 19:06:282481void RenderViewImpl::OnMoveOrResizeStarted() {
[email protected]30f75e62009-02-25 22:01:002482 if (webview())
[email protected]a72a1fa2010-05-03 22:18:472483 webview()->hidePopups();
[email protected]30f75e62009-02-25 22:01:002484}
2485
bokanc63441c2016-04-27 15:49:122486void RenderViewImpl::ResizeWebWidget() {
2487 webview()->resizeWithTopControls(GetSizeForWebWidget(),
2488 top_controls_height_,
2489 top_controls_shrink_blink_size_);
2490}
2491
fsamuel664e8b62016-01-20 19:54:012492void RenderViewImpl::OnResize(const ResizeParams& params) {
[email protected]189a8862014-07-18 00:27:532493 TRACE_EVENT0("renderer", "RenderViewImpl::OnResize");
[email protected]cda45c02010-02-25 19:28:102494 if (webview()) {
[email protected]a72a1fa2010-05-03 22:18:472495 webview()->hidePopups();
kenrb5fd60fb82016-06-10 17:27:572496 if (send_preferred_size_changes_ &&
2497 webview()->mainFrame()->isWebLocalFrame()) {
[email protected]7339cd22010-10-27 00:11:202498 webview()->mainFrame()->setCanHaveScrollbars(
[email protected]0fdd5012013-05-29 08:05:562499 ShouldDisplayScrollbars(params.new_size.width(),
2500 params.new_size.height()));
[email protected]cda45c02010-02-25 19:28:102501 }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:122502 if (display_mode_ != params.display_mode) {
2503 display_mode_ = params.display_mode;
2504 webview()->setDisplayMode(display_mode_);
2505 }
[email protected]cda45c02010-02-25 19:28:102506 }
2507
[email protected]cbbdeef2014-05-26 15:57:362508 gfx::Size old_visible_viewport_size = visible_viewport_size_;
2509
bokanc63441c2016-04-27 15:49:122510 top_controls_shrink_blink_size_ = params.top_controls_shrink_blink_size;
2511 top_controls_height_ = params.top_controls_height;
2512
[email protected]0fdd5012013-05-29 08:05:562513 RenderWidget::OnResize(params);
[email protected]cbbdeef2014-05-26 15:57:362514
2515 if (old_visible_viewport_size != visible_viewport_size_)
2516 has_scrolled_focused_editable_node_into_rect_ = false;
[email protected]30f75e62009-02-25 22:01:002517}
[email protected]0aa477bd2009-03-23 22:21:432518
avib9dbd972016-03-08 18:19:322519void RenderViewImpl::RenderWidgetDidFlushPaint() {
[email protected]5b1dec8c2012-02-07 04:35:382520 // If the RenderWidget is closing down then early-exit, otherwise we'll crash.
2521 // See crbug.com/112921.
2522 if (!webview())
2523 return;
2524
[email protected]00c39612010-03-06 02:53:282525 WebFrame* main_frame = webview()->mainFrame();
[email protected]82307f6b2014-08-07 03:30:122526 for (WebFrame* frame = main_frame; frame;
2527 frame = frame->traverseNext(false)) {
pmeenandcc725b2014-10-22 18:04:112528 // TODO(nasko): This is a hack for the case in which the top-level
2529 // frame is being rendered in another process. It will not
2530 // behave correctly for out of process iframes.
2531 if (frame->isWebLocalFrame()) {
[email protected]82307f6b2014-08-07 03:30:122532 main_frame = frame;
pmeenandcc725b2014-10-22 18:04:112533 break;
2534 }
[email protected]82307f6b2014-08-07 03:30:122535 }
[email protected]00c39612010-03-06 02:53:282536
alexmos6806d182015-07-28 00:04:192537 // There's nothing to do if there are no local frames in this RenderView's
2538 // frame tree. This can happen if DidFlushPaint is called after the
2539 // RenderView's local main frame is swapped to a remote frame. See
2540 // http://crbug.com/513552.
2541 if (main_frame->isWebRemoteFrame())
2542 return;
2543
[email protected]00c39612010-03-06 02:53:282544 // If we have a provisional frame we are between the start and commit stages
2545 // of loading and we don't want to save stats.
2546 if (!main_frame->provisionalDataSource()) {
2547 WebDataSource* ds = main_frame->dataSource();
enne95486602015-04-30 23:41:102548 if (!ds)
2549 return;
2550
[email protected]007733c2011-11-17 00:34:072551 DocumentState* document_state = DocumentState::FromDataSource(ds);
[email protected]92d457802013-04-01 19:18:492552
[email protected]05c8e502010-08-15 15:13:522553 // TODO(jar): The following code should all be inside a method, probably in
2554 // NavigatorState.
[email protected]00c39612010-03-06 02:53:282555 Time now = Time::Now();
[email protected]007733c2011-11-17 00:34:072556 if (document_state->first_paint_time().is_null()) {
2557 document_state->set_first_paint_time(now);
[email protected]00c39612010-03-06 02:53:282558 }
[email protected]007733c2011-11-17 00:34:072559 if (document_state->first_paint_after_load_time().is_null() &&
2560 !document_state->finish_load_time().is_null()) {
2561 document_state->set_first_paint_after_load_time(now);
[email protected]00c39612010-03-06 02:53:282562 }
2563 }
2564}
2565
[email protected]ab6c9112014-02-27 00:20:582566void RenderViewImpl::OnClearFocusedElement() {
[email protected]05d478752009-04-08 23:38:162567 if (webview())
[email protected]ab6c9112014-02-27 00:20:582568 webview()->clearFocusedElement();
[email protected]05d478752009-04-08 23:38:162569}
2570
[email protected]61f91832014-05-13 01:24:422571void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) {
lfgcaab5142016-02-26 19:06:522572 if (frame_widget_)
2573 frame_widget_->setIsTransparent(!opaque);
[email protected]ba91a792013-02-06 09:48:282574 if (compositor_)
[email protected]61f91832014-05-13 01:24:422575 compositor_->setHasTransparentBackground(!opaque);
[email protected]699ab0d2009-04-23 23:19:142576}
2577
[email protected]310ebd6302011-10-10 19:06:282578void RenderViewImpl::OnSetActive(bool active) {
[email protected]8c66c5a2009-07-22 17:26:342579 if (webview())
[email protected]b4bb2502009-10-01 22:35:272580 webview()->setIsActive(active);
[email protected]8c66c5a2009-07-22 17:26:342581}
2582
lfg8ff33912016-09-13 20:59:212583blink::WebWidget* RenderViewImpl::GetWebWidget() const {
2584 if (frame_widget_)
2585 return frame_widget_;
2586
2587 return RenderWidget::GetWebWidget();
2588}
2589
dcheng3ce04b62015-10-26 23:30:552590void RenderViewImpl::CloseForFrame() {
2591 DCHECK(frame_widget_);
2592 frame_widget_->close();
2593 frame_widget_ = nullptr;
2594}
2595
[email protected]310ebd6302011-10-10 19:06:282596void RenderViewImpl::Close() {
[email protected]60c42a8c72009-10-09 04:08:592597 // We need to grab a pointer to the doomed WebView before we destroy it.
lfg4fa48da2016-05-09 18:25:132598 WebView* doomed = webview_;
[email protected]60c42a8c72009-10-09 04:08:592599 RenderWidget::Close();
lfg4fa48da2016-05-09 18:25:132600 webview_ = nullptr;
[email protected]625332e02010-12-14 07:48:492601 g_view_map.Get().erase(doomed);
avia3dca182016-03-19 01:09:522602 g_routing_id_view_map.Get().erase(GetRoutingID());
2603 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID()));
[email protected]60c42a8c72009-10-09 04:08:592604}
2605
lfg717154072016-06-30 15:04:162606void RenderViewImpl::OnPageWasHidden() {
[email protected]68877c282013-09-20 05:52:422607#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
[email protected]6392d982013-04-16 16:59:222608 RenderThreadImpl::current()->video_capture_impl_manager()->
2609 SuspendDevices(true);
[email protected]e976c3c52014-07-24 17:41:552610 if (speech_recognition_dispatcher_)
2611 speech_recognition_dispatcher_->AbortAllRecognitions();
[email protected]6392d982013-04-16 16:59:222612#endif
[email protected]2d7b82c2012-06-01 05:57:502613
lfg717154072016-06-30 15:04:162614 if (webview()) {
2615 // TODO(lfg): It's not correct to defer the page visibility to the main
2616 // frame. Currently, this is done because the main frame may override the
2617 // visibility of the page when prerendering. In order to fix this,
2618 // prerendering must be made aware of OOPIFs. https://crbug.com/440544
2619 blink::WebPageVisibilityState visibilityState =
2620 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2621 : blink::WebPageVisibilityStateHidden;
2622 webview()->setVisibilityState(visibilityState, false);
2623 }
[email protected]941e4552010-02-01 21:23:432624}
2625
lfg717154072016-06-30 15:04:162626void RenderViewImpl::OnPageWasShown() {
[email protected]6392d982013-04-16 16:59:222627#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
2628 RenderThreadImpl::current()->video_capture_impl_manager()->
2629 SuspendDevices(false);
2630#endif
2631
lfg717154072016-06-30 15:04:162632 if (webview()) {
2633 blink::WebPageVisibilityState visibilityState =
2634 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2635 : blink::WebPageVisibilityStateVisible;
2636 webview()->setVisibilityState(visibilityState, false);
2637 }
[email protected]a6939ca42011-02-18 17:58:072638}
[email protected]1e6e3c992010-02-08 15:52:132639
[email protected]ed7defa2013-03-12 21:29:592640GURL RenderViewImpl::GetURLForGraphicsContext3D() {
2641 DCHECK(webview());
[email protected]82307f6b2014-08-07 03:30:122642 if (webview()->mainFrame()->isWebLocalFrame())
[email protected]ed7defa2013-03-12 21:29:592643 return GURL(webview()->mainFrame()->document().url());
2644 else
2645 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D");
[email protected]65225772011-05-12 21:10:242646}
2647
[email protected]310ebd6302011-10-10 19:06:282648void RenderViewImpl::OnSetFocus(bool enable) {
naskoc6edf7e2015-10-16 01:48:452649 // This message must always be received when the main frame is a
2650 // WebLocalFrame.
2651 CHECK(webview()->mainFrame()->isWebLocalFrame());
alexmos3fcd0ca2015-10-23 18:18:332652 SetFocus(enable);
2653}
alexmos7fac9aeb2015-10-16 22:39:492654
alexmos3fcd0ca2015-10-23 18:18:332655void RenderViewImpl::SetFocus(bool enable) {
[email protected]1e6e3c992010-02-08 15:52:132656 RenderWidget::OnSetFocus(enable);
2657
[email protected]321032992012-11-08 01:01:272658 // Notify all BrowserPlugins of the RenderView's focus state.
fsamuel6c1dfeb2014-12-18 19:21:332659 if (BrowserPluginManager::Get())
2660 BrowserPluginManager::Get()->UpdateFocusState();
[email protected]1e6e3c992010-02-08 15:52:132661}
[email protected]941e4552010-02-01 21:23:432662
avi40b5be7a2016-03-03 21:13:442663void RenderViewImpl::RenderWidgetDidSetColorProfile(
[email protected]28ed6b32014-06-08 02:16:272664 const std::vector<char>& profile) {
avi40b5be7a2016-03-03 21:13:442665 if (webview()) {
ccameron7c4df6c22016-08-11 03:03:152666 WebVector<char> colorProfile = profile;
2667 webview()->setDeviceColorProfile(colorProfile);
avi40b5be7a2016-03-03 21:13:442668 }
noeldb4df152014-09-16 17:45:202669}
2670
rouslanf7ebd8832015-01-22 01:54:142671void RenderViewImpl::DidCompletePageScaleAnimation() {
avid7d6b2e2016-03-04 19:41:172672 GetWidget()->FocusChangeComplete();
rouslanf7ebd8832015-01-22 01:54:142673}
2674
oshimad5279032015-12-16 18:22:332675void RenderViewImpl::OnDeviceScaleFactorChanged() {
2676 RenderWidget::OnDeviceScaleFactorChanged();
2677 UpdateWebViewWithDeviceScaleFactor();
2678 if (auto_resize_mode_)
2679 AutoResizeCompositor();
2680}
2681
[email protected]b2e4c70132013-10-03 02:07:512682void RenderViewImpl::SetScreenMetricsEmulationParameters(
dgozman9260b0a12015-03-16 13:45:202683 bool enabled,
2684 const blink::WebDeviceEmulationParams& params) {
[email protected]404630b2014-07-03 19:33:032685 if (webview() && compositor()) {
dgozman9260b0a12015-03-16 13:45:202686 if (enabled)
2687 webview()->enableDeviceEmulation(params);
2688 else
2689 webview()->disableDeviceEmulation();
[email protected]b2e4c70132013-10-03 02:07:512690 }
2691}
2692
[email protected]180ef242013-11-07 06:50:462693blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() {
[email protected]64d09222012-05-25 10:10:342694 if (!speech_recognition_dispatcher_)
2695 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this);
[email protected]64d09222012-05-25 10:10:342696 return speech_recognition_dispatcher_;
2697}
2698
[email protected]310ebd6302011-10-10 19:06:282699void RenderViewImpl::zoomLimitsChanged(double minimum_level,
2700 double maximum_level) {
a.sarkar.arundaadc712015-02-26 05:39:082701 // Round the double to avoid returning incorrect minimum/maximum zoom
2702 // percentages.
2703 int minimum_percent = round(
[email protected]7940b8e2013-07-25 23:08:492704 ZoomLevelToZoomFactor(minimum_level) * 100);
a.sarkar.arundaadc712015-02-26 05:39:082705 int maximum_percent = round(
[email protected]7940b8e2013-07-25 23:08:492706 ZoomLevelToZoomFactor(maximum_level) * 100);
[email protected]b75b8292010-10-01 07:28:252707
avia3dca182016-03-19 01:09:522708 Send(new ViewHostMsg_UpdateZoomLimits(GetRoutingID(), minimum_percent,
fsamuele8326c742016-01-12 00:49:392709 maximum_percent));
[email protected]b75b8292010-10-01 07:28:252710}
2711
[email protected]310ebd6302011-10-10 19:06:282712void RenderViewImpl::zoomLevelChanged() {
[email protected]54b8e182014-05-02 18:08:292713 double zoom_level = webview()->zoomLevel();
[email protected]2b942c332012-04-25 16:26:262714
[email protected]54b8e182014-05-02 18:08:292715 // Do not send empty URLs to the browser when we are just setting the default
2716 // zoom level (from RendererPreferences) before the first navigation.
2717 if (!webview()->mainFrame()->document().url().isEmpty()) {
2718 // Tell the browser which url got zoomed so it can update the menu and the
2719 // saved values if necessary
2720 Send(new ViewHostMsg_DidZoomURL(
avia3dca182016-03-19 01:09:522721 GetRoutingID(), zoom_level,
[email protected]54b8e182014-05-02 18:08:292722 GURL(webview()->mainFrame()->document().url())));
2723 }
[email protected]b75b8292010-10-01 07:28:252724}
2725
ccameronb7c1d6c2015-03-09 17:08:242726void RenderViewImpl::pageScaleFactorChanged() {
2727 if (!webview())
2728 return;
mcnee432e47d2015-11-09 19:37:462729
avia3dca182016-03-19 01:09:522730 Send(new ViewHostMsg_PageScaleFactorChanged(GetRoutingID(),
mcnee432e47d2015-11-09 19:37:462731 webview()->pageScaleFactor()));
ccameronb7c1d6c2015-03-09 17:08:242732}
2733
[email protected]7940b8e2013-07-25 23:08:492734double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
2735 return ZoomLevelToZoomFactor(zoom_level);
2736}
2737
2738double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
2739 return ZoomFactorToZoomLevel(factor);
2740}
2741
[email protected]a0629af92012-08-08 00:39:372742void RenderViewImpl::draggableRegionsChanged() {
2743 FOR_EACH_OBSERVER(
2744 RenderViewObserver,
2745 observers_,
2746 DraggableRegionsChanged(webview()->mainFrame()));
2747}
2748
kouhei40f03cb2015-09-24 07:47:012749void RenderViewImpl::pageImportanceSignalsChanged() {
2750 if (!webview() || !main_render_frame_)
2751 return;
2752
vmpstr10e0d5f2016-07-21 23:46:092753 auto* web_signals = webview()->pageImportanceSignals();
kouhei40f03cb2015-09-24 07:47:012754
2755 PageImportanceSignals signals;
2756 signals.had_form_interaction = web_signals->hadFormInteraction();
2757
2758 main_render_frame_->Send(new FrameHostMsg_UpdatePageImportanceSignals(
2759 main_render_frame_->GetRoutingID(), signals));
2760}
2761
dglazkov8d0c21dd2016-08-06 15:56:362762// TODO(dglazkov): Remove this ifdef. The content detection code
2763// should not be platform-specific.
2764// See http://crbug.com/635214 for details.
[email protected]20657a82012-08-21 20:23:032765#if defined(OS_ANDROID)
dglazkov8d0c21dd2016-08-06 15:56:362766WebURL RenderViewImpl::detectContentIntentAt(
[email protected]20657a82012-08-21 20:23:032767 const WebHitTestResult& touch_hit) {
[email protected]20657a82012-08-21 20:23:032768 DCHECK(touch_hit.node().isTextNode());
2769
2770 // Process the position with all the registered content detectors until
2771 // a match is found. Priority is provided by their relative order.
limasdf81d962e2015-11-20 08:39:182772 for (const auto& detector : content_detectors_) {
dglazkov0d073cb2016-08-07 19:46:462773 WebURL intent = detector->FindTappedContent(touch_hit);
2774 if (intent.isValid()) {
2775 return intent;
[email protected]20657a82012-08-21 20:23:032776 }
2777 }
dglazkov8d0c21dd2016-08-06 15:56:362778 return WebURL();
[email protected]20657a82012-08-21 20:23:032779}
2780
mnaganov42d9e372015-11-02 23:27:412781void RenderViewImpl::scheduleContentIntent(const WebURL& intent,
2782 bool is_main_frame) {
[email protected]20657a82012-08-21 20:23:032783 // Introduce a short delay so that the user can notice the content.
fdoray7a8954a42016-06-07 04:28:382784 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
[email protected]20657a82012-08-21 20:23:032785 FROM_HERE,
mnaganov42d9e372015-11-02 23:27:412786 base::Bind(&RenderViewImpl::LaunchAndroidContentIntent, AsWeakPtr(),
2787 intent, expected_content_intent_id_, is_main_frame),
[email protected]20657a82012-08-21 20:23:032788 base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds));
2789}
2790
2791void RenderViewImpl::cancelScheduledContentIntents() {
2792 ++expected_content_intent_id_;
2793}
2794
2795void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent,
mnaganov42d9e372015-11-02 23:27:412796 size_t request_id,
2797 bool is_main_frame) {
[email protected]20657a82012-08-21 20:23:032798 if (request_id != expected_content_intent_id_)
qinmin0d5560df2014-11-12 19:03:392799 return;
[email protected]20657a82012-08-21 20:23:032800
2801 // Remove the content highlighting if any.
jdduke491a3f0c2015-06-15 23:30:262802 ScheduleComposite();
[email protected]20657a82012-08-21 20:23:032803
mnaganov42d9e372015-11-02 23:27:412804 if (!intent.is_empty()) {
avia3dca182016-03-19 01:09:522805 Send(new ViewHostMsg_StartContentIntent(GetRoutingID(), intent,
fsamuele8326c742016-01-12 00:49:392806 is_main_frame));
mnaganov42d9e372015-11-02 23:27:412807 }
[email protected]20657a82012-08-21 20:23:032808}
[email protected]b18583c2012-12-18 06:55:272809
2810bool RenderViewImpl::openDateTimeChooser(
[email protected]180ef242013-11-07 06:50:462811 const blink::WebDateTimeChooserParams& params,
2812 blink::WebDateTimeChooserCompletion* completion) {
[email protected]e8072562013-12-04 06:04:132813 // JavaScript may try to open a date time chooser while one is already open.
2814 if (date_time_picker_client_)
2815 return false;
[email protected]b18583c2012-12-18 06:55:272816 date_time_picker_client_.reset(
2817 new RendererDateTimePicker(this, params, completion));
2818 return date_time_picker_client_->Open();
2819}
2820
[email protected]e8072562013-12-04 06:04:132821void RenderViewImpl::DismissDateTimeDialog() {
2822 DCHECK(date_time_picker_client_);
2823 date_time_picker_client_.reset(NULL);
2824}
[email protected]e8072562013-12-04 06:04:132825
[email protected]6d17f6392012-12-05 05:24:542826#endif // defined(OS_ANDROID)
[email protected]20657a82012-08-21 20:23:032827
[email protected]be1af0662014-07-29 19:55:512828void RenderViewImpl::OnShowContextMenu(
2829 ui::MenuSourceType source_type, const gfx::Point& location) {
fsamuele8326c742016-01-12 00:49:392830 input_handler_->set_context_menu_source_type(source_type);
[email protected]be1af0662014-07-29 19:55:512831 has_host_context_menu_location_ = true;
2832 host_context_menu_location_ = location;
[email protected]47822262013-04-23 17:22:362833 if (webview())
2834 webview()->showContextMenu();
[email protected]be1af0662014-07-29 19:55:512835 has_host_context_menu_location_ = false;
[email protected]47822262013-04-23 17:22:362836}
2837
estade6b9696bd2016-05-04 23:51:362838#if defined(OS_ANDROID)
[email protected]f9526d12012-10-18 01:55:032839bool RenderViewImpl::didTapMultipleTargets(
timav29a8d0f62014-09-25 20:45:532840 const WebSize& inner_viewport_offset,
2841 const WebRect& touch_rect,
[email protected]f9526d12012-10-18 01:55:032842 const WebVector<WebRect>& target_rects) {
[email protected]8d3dfee62013-06-19 05:50:332843 // Never show a disambiguation popup when accessibility is enabled,
2844 // as this interferes with "touch exploration".
[email protected]95640212014-07-26 18:14:302845 AccessibilityMode accessibility_mode =
mostynbc33353232014-09-12 09:38:312846 GetMainRenderFrame()->accessibility_mode();
[email protected]95640212014-07-26 18:14:302847 bool matches_accessibility_mode_complete =
2848 (accessibility_mode & AccessibilityModeComplete) ==
2849 AccessibilityModeComplete;
2850 if (matches_accessibility_mode_complete)
[email protected]8d3dfee62013-06-19 05:50:332851 return false;
2852
timav29a8d0f62014-09-25 20:45:532853 // The touch_rect, target_rects and zoom_rect are in the outer viewport
2854 // reference frame.
[email protected]f9526d12012-10-18 01:55:032855 gfx::Rect zoom_rect;
[email protected]70221f02013-01-31 22:17:072856 float new_total_scale =
2857 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
timav29a8d0f62014-09-25 20:45:532858 touch_rect, target_rects, GetSize(),
[email protected]70221f02013-01-31 22:17:072859 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(),
2860 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect);
jbauman0ed09182015-01-30 22:33:492861 if (!new_total_scale || zoom_rect.IsEmpty())
[email protected]f9526d12012-10-18 01:55:032862 return false;
2863
[email protected]4ded1dbf2013-08-28 21:11:032864 bool handled = false;
2865 switch (renderer_preferences_.tap_multiple_targets_strategy) {
2866 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM:
2867 handled = webview()->zoomToMultipleTargetsRect(zoom_rect);
2868 break;
2869 case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: {
[email protected]bc2804d2013-08-06 07:45:492870 gfx::Size canvas_size =
danakjddaec912015-09-25 19:38:402871 gfx::ScaleToCeiledSize(zoom_rect.size(), new_total_scale);
[email protected]cb189e062014-04-23 00:57:012872 cc::SharedBitmapManager* manager =
2873 RenderThreadImpl::current()->shared_bitmap_manager();
dchengcedca5612016-04-09 01:40:152874 std::unique_ptr<cc::SharedBitmap> shared_bitmap =
[email protected]cb189e062014-04-23 00:57:012875 manager->AllocateSharedBitmap(canvas_size);
jbauman0ed09182015-01-30 22:33:492876 CHECK(!!shared_bitmap);
[email protected]bc2804d2013-08-06 07:45:492877 {
[email protected]cb189e062014-04-23 00:57:012878 SkBitmap bitmap;
2879 SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(),
2880 canvas_size.height());
2881 bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes());
2882 SkCanvas canvas(bitmap);
[email protected]f9526d12012-10-18 01:55:032883
[email protected]bc2804d2013-08-06 07:45:492884 // TODO(trchen): Cleanup the device scale factor mess.
2885 // device scale will be applied in WebKit
2886 // --> zoom_rect doesn't include device scale,
2887 // but WebKit will still draw on zoom_rect * device_scale_factor_
[email protected]cb189e062014-04-23 00:57:012888 canvas.scale(new_total_scale / device_scale_factor_,
2889 new_total_scale / device_scale_factor_);
2890 canvas.translate(-zoom_rect.x() * device_scale_factor_,
2891 -zoom_rect.y() * device_scale_factor_);
[email protected]f9526d12012-10-18 01:55:032892
lfg8ff33912016-09-13 20:59:212893 DCHECK(webview_->isAcceleratedCompositingActive());
2894 webview_->paintIgnoringCompositing(&canvas, zoom_rect);
[email protected]bc2804d2013-08-06 07:45:492895 }
2896
timav29a8d0f62014-09-25 20:45:532897 gfx::Rect zoom_rect_in_screen =
2898 zoom_rect - gfx::Vector2d(inner_viewport_offset.width,
2899 inner_viewport_offset.height);
2900
[email protected]bc2804d2013-08-06 07:45:492901 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect(
timav29a8d0f62014-09-25 20:45:532902 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect_in_screen)));
2903
fsamuele8326c742016-01-12 00:49:392904 Send(new ViewHostMsg_ShowDisambiguationPopup(
avia3dca182016-03-19 01:09:522905 GetRoutingID(), physical_window_zoom_rect, canvas_size,
fsamuele8326c742016-01-12 00:49:392906 shared_bitmap->id()));
[email protected]cb189e062014-04-23 00:57:012907 cc::SharedBitmapId id = shared_bitmap->id();
2908 disambiguation_bitmaps_[id] = shared_bitmap.release();
[email protected]4ded1dbf2013-08-28 21:11:032909 handled = true;
2910 break;
2911 }
2912 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE:
2913 // No-op.
2914 break;
[email protected]f9526d12012-10-18 01:55:032915 }
[email protected]70221f02013-01-31 22:17:072916
[email protected]4ded1dbf2013-08-28 21:11:032917 return handled;
[email protected]f9526d12012-10-18 01:55:032918}
estade6b9696bd2016-05-04 23:51:362919#endif // defined(OS_ANDROID)
[email protected]f9526d12012-10-18 01:55:032920
[email protected]b283d292013-02-21 08:40:342921unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const {
2922 return history_list_length_;
2923}
2924
[email protected]cc290f902013-03-04 20:06:022925void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) {
2926 if (enable) {
2927 if (has_focus())
2928 return;
2929 OnSetActive(true);
2930 OnSetFocus(true);
2931 } else {
2932 if (!has_focus())
2933 return;
2934 OnSetFocus(false);
2935 OnSetActive(false);
2936 }
2937}
2938
[email protected]3a1c8a8032013-03-18 22:35:322939void RenderViewImpl::SetDeviceScaleFactorForTesting(float factor) {
fsamuel664e8b62016-01-20 19:54:012940 ResizeParams params;
[email protected]b54fe452013-06-07 14:01:532941 params.screen_info = screen_info_;
ccameron2f451532016-09-07 21:49:272942 params.screen_info.device_scale_factor = factor;
[email protected]b54fe452013-06-07 14:01:532943 params.new_size = size();
bokanf0fd2412014-10-30 15:28:552944 params.visible_viewport_size = visible_viewport_size_;
danakjddaec912015-09-25 19:38:402945 params.physical_backing_size = gfx::ScaleToCeiledSize(size(), factor);
dtrainorcb7779b82014-12-04 01:08:022946 params.top_controls_shrink_blink_size = false;
2947 params.top_controls_height = 0.f;
mikhail.pozdnyakovf2c902a2015-04-14 08:09:122948 params.is_fullscreen_granted = is_fullscreen_granted();
mikhail.pozdnyakovc0e251b2015-04-15 06:51:122949 params.display_mode = display_mode_;
[email protected]b54fe452013-06-07 14:01:532950 OnResize(params);
[email protected]3a1c8a8032013-03-18 22:35:322951}
2952
[email protected]92650162013-10-30 03:31:022953void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) {
bokanc007c3a2015-02-03 07:15:562954 gfx::Rect new_window_rect(rootWindowRect().x,
2955 rootWindowRect().y,
2956 new_size.width(),
2957 new_size.height());
2958 SetWindowRectSynchronously(new_window_rect);
[email protected]92650162013-10-30 03:31:022959}
2960
[email protected]5b45ad42013-10-25 00:42:042961void RenderViewImpl::UseSynchronousResizeModeForTesting(bool enable) {
2962 resizing_mode_selector_->set_is_synchronous_mode(enable);
2963}
2964
[email protected]eac2b362013-05-22 07:01:452965void RenderViewImpl::EnableAutoResizeForTesting(const gfx::Size& min_size,
2966 const gfx::Size& max_size) {
2967 OnEnableAutoResize(min_size, max_size);
2968}
2969
2970void RenderViewImpl::DisableAutoResizeForTesting(const gfx::Size& new_size) {
2971 OnDisableAutoResize(new_size);
2972}
2973
[email protected]cb189e062014-04-23 00:57:012974void RenderViewImpl::OnReleaseDisambiguationPopupBitmap(
2975 const cc::SharedBitmapId& id) {
2976 BitmapMap::iterator it = disambiguation_bitmaps_.find(id);
2977 DCHECK(it != disambiguation_bitmaps_.end());
2978 delete it->second;
2979 disambiguation_bitmaps_.erase(it);
[email protected]f9526d12012-10-18 01:55:032980}
[email protected]e9ff79c2012-10-19 21:31:262981
[email protected]6fceb912013-02-15 06:24:152982void RenderViewImpl::DidCommitCompositorFrame() {
2983 RenderWidget::DidCommitCompositorFrame();
2984 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame());
2985}
2986
[email protected]41225fe2013-03-29 05:32:022987void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) {
2988 if (!urls.empty())
avia3dca182016-03-19 01:09:522989 Send(new ViewHostMsg_UpdateFaviconURL(GetRoutingID(), urls));
[email protected]41225fe2013-03-29 05:32:022990}
2991
2992void RenderViewImpl::DidStopLoadingIcons() {
huangsdde9aceb2015-03-17 21:26:162993 int icon_types = WebIconURL::TypeFavicon | WebIconURL::TypeTouchPrecomposed |
2994 WebIconURL::TypeTouch;
[email protected]41225fe2013-03-29 05:32:022995
nasko2411ba372014-10-13 17:45:412996 // Favicons matter only for the top-level frame. If it is a WebRemoteFrame,
2997 // just return early.
2998 if (webview()->mainFrame()->isWebRemoteFrame())
2999 return;
3000
[email protected]41225fe2013-03-29 05:32:023001 WebVector<WebIconURL> icon_urls =
3002 webview()->mainFrame()->iconURLs(icon_types);
3003
3004 std::vector<FaviconURL> urls;
3005 for (size_t i = 0; i < icon_urls.size(); i++) {
3006 WebURL url = icon_urls[i].iconURL();
[email protected]2bd262b2014-04-16 05:31:233007 std::vector<gfx::Size> sizes;
[email protected]f34ac132014-03-20 23:02:053008 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
[email protected]41225fe2013-03-29 05:32:023009 if (!url.isEmpty())
[email protected]f34ac132014-03-20 23:02:053010 urls.push_back(
3011 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
[email protected]41225fe2013-03-29 05:32:023012 }
3013 SendUpdateFaviconURL(urls);
3014}
3015
oshimad5279032015-12-16 18:22:333016void RenderViewImpl::UpdateWebViewWithDeviceScaleFactor() {
3017 if (!webview())
3018 return;
oshima750cb4342015-10-31 00:59:013019 if (IsUseZoomForDSFEnabled()) {
oshimad5279032015-12-16 18:22:333020 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_);
oshima750cb4342015-10-31 00:59:013021 } else {
3022 webview()->setDeviceScaleFactor(device_scale_factor_);
3023 }
oshimad5279032015-12-16 18:22:333024 webview()->settings()->setPreferCompositingToLCDTextEnabled(
3025 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
oshima750cb4342015-10-31 00:59:013026}
3027
[email protected]e9ff79c2012-10-19 21:31:263028} // namespace content