blob: 2cd7b9654ea707c03992644403f734ce49daaf97 [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]81a34412009-01-05 19:17:24676 page_id_(-1),
naskobd911332014-11-25 01:13:36677 next_page_id_(params.next_page_id),
[email protected]3cc72b12010-03-18 23:03:00678 history_list_offset_(-1),
679 history_list_length_(0),
[email protected]7e9523b2014-03-25 03:02:42680 frames_in_progress_(0),
[email protected]3354d3e2010-06-10 19:53:02681 target_url_status_(TARGET_NONE),
[email protected]d42bf472014-06-14 01:49:38682 uses_temporary_zoom_level_(false),
[email protected]bbc8856d2013-06-14 10:37:04683#if defined(OS_ANDROID)
majidvpfb80e432015-02-23 14:15:50684 top_controls_constraints_(TOP_CONTROLS_STATE_BOTH),
[email protected]bbc8856d2013-06-14 10:37:04685#endif
bokanc63441c2016-04-27 15:49:12686 top_controls_shrink_blink_size_(false),
687 top_controls_height_(0.f),
lfg4fa48da2016-05-09 18:25:13688 webview_(nullptr),
[email protected]1875bc02014-03-14 06:33:59689 has_scrolled_focused_editable_node_into_rect_(false),
wjmaclean64951902016-04-29 20:59:12690 page_zoom_level_(params.page_zoom_level),
nasko4c0feb62015-06-05 18:37:06691 main_render_frame_(nullptr),
dcheng3ce04b62015-10-26 23:30:55692 frame_widget_(nullptr),
[email protected]64d09222012-05-25 10:10:34693 speech_recognition_dispatcher_(NULL),
[email protected]20657a82012-08-21 20:23:03694#if defined(OS_ANDROID)
695 expected_content_intent_id_(0),
[email protected]a7564272013-04-19 14:24:46696#endif
[email protected]8a67aa352013-02-20 02:58:29697 enumeration_completion_id_(0),
changwand659e202016-06-13 02:39:12698 session_storage_namespace_id_(params.session_storage_namespace_id),
699 has_added_input_handler_(false) {
avi40b5be7a2016-03-03 21:13:44700 GetWidget()->set_owner_delegate(this);
[email protected]075366912013-02-18 07:13:24701}
702
rockot067ca55f2016-09-30 22:00:15703void RenderViewImpl::Initialize(const mojom::CreateViewParams& params,
danakj6e3bf8012014-12-16 18:27:53704 bool was_created_by_renderer) {
fsamuele8326c742016-01-12 00:49:39705 SetRoutingID(params.view_id);
alexmos5ac402d2015-07-09 07:51:10706
707 int opener_view_routing_id;
alexmos95733002015-08-24 16:38:09708 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener(
709 params.opener_frame_route_id, &opener_view_routing_id);
alexmos5ac402d2015-07-09 07:51:10710 if (opener_view_routing_id != MSG_ROUTING_NONE && was_created_by_renderer)
711 opener_id_ = opener_view_routing_id;
712
thestig6057a6b22015-11-12 23:01:33713 display_mode_ = params.initial_size.display_mode;
[email protected]676126f72011-01-15 00:03:51714
[email protected]74ce1ad2011-12-16 21:51:46715 // Ensure we start with a valid next_page_id_ from the browser.
716 DCHECK_GE(next_page_id_, 0);
717
lfg717154072016-06-30 15:04:16718 webview_ =
719 WebView::create(this, is_hidden() ? blink::WebPageVisibilityStateHidden
720 : blink::WebPageVisibilityStateVisible);
lfgbee1e0a2016-06-08 21:24:21721 RenderWidget::DoInit(MSG_ROUTING_NONE, webview_->widget(), nullptr);
[email protected]11fee2332011-03-29 20:36:35722
nasko4c0feb62015-06-05 18:37:06723 g_view_map.Get().insert(std::make_pair(webview(), this));
avia3dca182016-03-19 01:09:52724 g_routing_id_view_map.Get().insert(std::make_pair(GetRoutingID(), this));
nasko4c0feb62015-06-05 18:37:06725
avi83883c82014-12-23 00:08:49726 const base::CommandLine& command_line =
727 *base::CommandLine::ForCurrentProcess();
[email protected]20657a82012-08-21 20:23:03728
[email protected]27c521a2013-05-29 20:44:32729 if (command_line.HasSwitch(switches::kStatsCollectionController))
730 stats_collection_observer_.reset(new StatsCollectionObserver(this));
731
creis9f7248b2016-01-27 20:27:39732 // Debug cases of https://crbug.com/575245.
733 base::debug::SetCrashKeyValue("rvinit_view_id",
avia3dca182016-03-19 01:09:52734 base::IntToString(GetRoutingID()));
creis9f7248b2016-01-27 20:27:39735 base::debug::SetCrashKeyValue("rvinit_proxy_id",
736 base::IntToString(params.proxy_routing_id));
737 base::debug::SetCrashKeyValue(
738 "rvinit_main_frame_id", base::IntToString(params.main_frame_routing_id));
739
dcheng0ff94cfc2016-03-15 21:50:51740 webview()->setDisplayMode(display_mode_);
741 webview()->settings()->setPreferCompositingToLCDTextEnabled(
742 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
743 webview()->settings()->setThreadedScrollingEnabled(
744 !command_line.HasSwitch(switches::kDisableThreadedScrolling));
dcheng0ff94cfc2016-03-15 21:50:51745 webview()->setShowFPSCounter(
746 command_line.HasSwitch(cc::switches::kShowFPSCounter));
ccameron41495f252016-09-02 02:37:32747
748 if (auto overridden_color_profile =
749 GetContentClient()->renderer()->GetImageDecodeColorProfile()) {
750 webview()->setDeviceColorProfile(overridden_color_profile->GetData());
751 } else {
752 webview()->setDeviceColorProfile(params.image_decode_color_space.GetData());
753 }
dcheng0ff94cfc2016-03-15 21:50:51754
755 ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_);
756
757 if (switches::IsTouchDragDropEnabled())
758 webview()->settings()->setTouchDragDropEnabled(true);
759
arthursonzognic517fc32016-08-11 11:04:24760 webview()->settings()->setBrowserSideNavigationEnabled(
761 IsBrowserSideNavigationEnabled());
762
dcheng0ff94cfc2016-03-15 21:50:51763 WebSettings::SelectionStrategyType selection_strategy =
764 WebSettings::SelectionStrategyType::Character;
765 const std::string selection_strategy_str =
766 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
767 switches::kTouchTextSelectionStrategy);
768 if (selection_strategy_str == "direction")
769 selection_strategy = WebSettings::SelectionStrategyType::Direction;
770 webview()->settings()->setSelectionStrategy(selection_strategy);
771
dtapuskaf65650b2016-05-13 17:21:34772 std::string passiveListenersDefault =
773 command_line.GetSwitchValueASCII(switches::kPassiveListenersDefault);
774 if (!passiveListenersDefault.empty()) {
775 WebSettings::PassiveEventListenerDefault passiveDefault =
776 WebSettings::PassiveEventListenerDefault::False;
dtapuskaacc2fb22016-07-06 23:26:23777 if (passiveListenersDefault == "true")
dtapuskaf65650b2016-05-13 17:21:34778 passiveDefault = WebSettings::PassiveEventListenerDefault::True;
779 else if (passiveListenersDefault == "forcealltrue")
780 passiveDefault = WebSettings::PassiveEventListenerDefault::ForceAllTrue;
781 webview()->settings()->setPassiveEventListenerDefault(passiveDefault);
782 }
783
dcheng0ff94cfc2016-03-15 21:50:51784 ApplyBlinkSettings(command_line, webview()->settings());
785
dchengc5ef1a52015-08-26 20:58:30786 if (params.main_frame_routing_id != MSG_ROUTING_NONE) {
dcheng3ce04b62015-10-26 23:30:55787 main_render_frame_ = RenderFrameImpl::CreateMainFrame(
788 this, params.main_frame_routing_id, params.main_frame_widget_routing_id,
dcheng9e24bd352016-03-01 19:15:51789 params.hidden, screen_info(), compositor_deps_, opener_frame);
dchengc5ef1a52015-08-26 20:58:30790 }
791
nasko4c0feb62015-06-05 18:37:06792 if (params.proxy_routing_id != MSG_ROUTING_NONE) {
793 CHECK(params.swapped_out);
naskob3041b98a42016-03-12 04:43:06794 RenderFrameProxy::CreateFrameProxy(
avia3dca182016-03-19 01:09:52795 params.proxy_routing_id, GetRoutingID(), params.opener_frame_route_id,
naskob3041b98a42016-03-12 04:43:06796 MSG_ROUTING_NONE, params.replicated_frame_state);
nasko4c0feb62015-06-05 18:37:06797 }
798
nasko4c0feb62015-06-05 18:37:06799 if (main_render_frame_)
800 main_render_frame_->Initialize();
801
[email protected]20657a82012-08-21 20:23:03802#if defined(OS_ANDROID)
ricea29649b92016-08-31 09:30:21803 content_detectors_.push_back(base::MakeUnique<AddressDetector>());
qinminc6a739f92015-03-31 17:46:11804 const std::string& contry_iso =
805 params.renderer_preferences.network_contry_iso;
806 if (!contry_iso.empty()) {
limasdf81d962e2015-11-20 08:39:18807 content_detectors_.push_back(
ricea29649b92016-08-31 09:30:21808 base::MakeUnique<PhoneNumberDetector>(contry_iso));
qinmin0d5560df2014-11-12 19:03:39809 }
ricea29649b92016-08-31 09:30:21810 content_detectors_.push_back(base::MakeUnique<EmailDetector>());
[email protected]20657a82012-08-21 20:23:03811#endif
812
[email protected]676126f72011-01-15 00:03:51813 // If this is a popup, we must wait for the CreatingNew_ACK message before
814 // completing initialization. Otherwise, we can finish it now.
pimanc4af3072015-10-02 03:45:59815 if (opener_id_ == MSG_ROUTING_NONE)
[email protected]676126f72011-01-15 00:03:51816 did_show_ = true;
mfomitchev5ad034ec2015-04-24 21:57:27817
alexmos35799be2015-07-02 08:59:50818 // Set the main frame's name. Only needs to be done for WebLocalFrames,
819 // since the remote case was handled as part of SetReplicatedState on the
820 // proxy above.
821 if (!params.replicated_frame_state.name.empty() &&
822 webview()->mainFrame()->isWebLocalFrame()) {
alexmos3448b552015-06-26 07:49:13823 webview()->mainFrame()->setName(
824 blink::WebString::fromUTF8(params.replicated_frame_state.name));
825 }
[email protected]34c61bd52011-05-02 19:38:33826
[email protected]c7c0d822014-04-16 20:19:49827 // TODO(davidben): Move this state from Blink into content.
naskobd911332014-11-25 01:13:36828 if (params.window_was_created_with_opener)
[email protected]c7c0d822014-04-16 20:19:49829 webview()->setOpenedByDOM();
830
dcheng0ff94cfc2016-03-15 21:50:51831 UpdateWebViewWithDeviceScaleFactor();
naskobd911332014-11-25 01:13:36832 OnSetRendererPrefs(params.renderer_preferences);
[email protected]34c61bd52011-05-02 19:38:33833
naskobd911332014-11-25 01:13:36834 if (!params.enable_auto_resize) {
835 OnResize(params.initial_size);
mkosiba58fa72f02014-11-12 01:21:36836 } else {
naskobd911332014-11-25 01:13:36837 OnEnableAutoResize(params.min_size, params.max_size);
mkosiba58fa72f02014-11-12 01:21:36838 }
839
creis8eb8ef22015-11-04 22:51:38840 // We don't use HistoryController in OOPIF-enabled modes.
841 if (!SiteIsolationPolicy::UseSubframeNavigationEntries())
842 history_controller_.reset(new HistoryController(this));
[email protected]d4734982014-04-15 02:05:55843
[email protected]1784b2f2011-11-24 10:53:48844 new IdleUserDetector(this);
845
[email protected]766a7082012-02-03 23:39:15846 if (command_line.HasSwitch(switches::kDomAutomationController))
[email protected]e9ff79c2012-10-19 21:31:26847 enabled_bindings_ |= BINDINGS_POLICY_DOM_AUTOMATION;
[email protected]27c521a2013-05-29 20:44:32848 if (command_line.HasSwitch(switches::kStatsCollectionController))
849 enabled_bindings_ |= BINDINGS_POLICY_STATS_COLLECTION;
[email protected]766a7082012-02-03 23:39:15850
[email protected]e9ff79c2012-10-19 21:31:26851 GetContentClient()->renderer()->RenderViewCreated(this);
[email protected]14392a52012-05-02 20:28:44852
dcheng9e24bd352016-03-01 19:15:51853 // Ensure that sandbox flags are inherited from an opener in a different
854 // process. In that case, the browser process will set any inherited sandbox
855 // flags in |replicated_frame_state|, so apply them here.
alexmosf5fb5192016-04-11 22:09:04856 if (!was_created_by_renderer && webview()->mainFrame()->isWebLocalFrame()) {
dcheng9e24bd352016-03-01 19:15:51857 webview()->mainFrame()->toWebLocalFrame()->forceSandboxFlags(
858 params.replicated_frame_state.sandbox_flags);
alexmosaedfc6f2016-01-21 23:57:38859 }
wjmaclean64951902016-04-29 20:59:12860
861 page_zoom_level_ = params.page_zoom_level;
initial.commit09911bf2008-07-26 23:55:29862}
863
[email protected]310ebd6302011-10-10 19:06:28864RenderViewImpl::~RenderViewImpl() {
dcheng3ce04b62015-10-26 23:30:55865 DCHECK(!frame_widget_);
866
[email protected]cb189e062014-04-23 00:57:01867 for (BitmapMap::iterator it = disambiguation_bitmaps_.begin();
868 it != disambiguation_bitmaps_.end();
869 ++it)
870 delete it->second;
[email protected]91a2aea2013-07-08 23:14:39871
[email protected]8ed1d3f2013-02-20 11:45:55872#if defined(OS_ANDROID)
davve17e025e12016-05-23 15:30:20873 // The date/time picker client is both a std::unique_ptr member of this class
874 // and a RenderViewObserver. Reset it to prevent double deletion.
[email protected]8ed1d3f2013-02-20 11:45:55875 date_time_picker_client_.reset();
876#endif
877
[email protected]60c42a8c72009-10-09 04:08:59878#ifndef NDEBUG
[email protected]058561b2012-12-03 06:48:22879 // Make sure we are no longer referenced by the ViewMap or RoutingIDViewMap.
[email protected]625332e02010-12-14 07:48:49880 ViewMap* views = g_view_map.Pointer();
[email protected]60c42a8c72009-10-09 04:08:59881 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it)
882 DCHECK_NE(this, it->second) << "Failed to call Close?";
[email protected]058561b2012-12-03 06:48:22883 RoutingIDViewMap* routing_id_views = g_routing_id_view_map.Pointer();
884 for (RoutingIDViewMap::iterator it = routing_id_views->begin();
885 it != routing_id_views->end(); ++it)
886 DCHECK_NE(this, it->second) << "Failed to call Close?";
[email protected]60c42a8c72009-10-09 04:08:59887#endif
[email protected]676126f72011-01-15 00:03:51888
[email protected]310ebd6302011-10-10 19:06:28889 FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone());
[email protected]676126f72011-01-15 00:03:51890 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct());
[email protected]60c42a8c72009-10-09 04:08:59891}
892
893/*static*/
[email protected]310ebd6302011-10-10 19:06:28894RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) {
[email protected]a2ef54c2011-10-10 16:20:31895 ViewMap* views = g_view_map.Pointer();
896 ViewMap::iterator it = views->find(webview);
897 return it == views->end() ? NULL : it->second;
898}
899
900/*static*/
[email protected]180ef242013-11-07 06:50:46901RenderView* RenderView::FromWebView(blink::WebView* webview) {
[email protected]310ebd6302011-10-10 19:06:28902 return RenderViewImpl::FromWebView(webview);
[email protected]a2ef54c2011-10-10 16:20:31903}
904
905/*static*/
avi1023d012015-12-25 02:39:14906RenderViewImpl* RenderViewImpl::FromRoutingID(int32_t routing_id) {
[email protected]640e303c2012-12-05 01:36:07907 RoutingIDViewMap* views = g_routing_id_view_map.Pointer();
908 RoutingIDViewMap::iterator it = views->find(routing_id);
909 return it == views->end() ? NULL : it->second;
910}
911
912/*static*/
913RenderView* RenderView::FromRoutingID(int routing_id) {
914 return RenderViewImpl::FromRoutingID(routing_id);
915}
916
[email protected]f3a95312014-06-12 16:46:58917/* static */
jochen9c7b8f242015-06-01 15:32:02918size_t RenderView::GetRenderViewCount() {
[email protected]f3a95312014-06-12 16:46:58919 return g_view_map.Get().size();
920}
921
[email protected]640e303c2012-12-05 01:36:07922/*static*/
[email protected]e9ff79c2012-10-19 21:31:26923void RenderView::ForEach(RenderViewVisitor* visitor) {
[email protected]625332e02010-12-14 07:48:49924 ViewMap* views = g_view_map.Pointer();
[email protected]60c42a8c72009-10-09 04:08:59925 for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) {
926 if (!visitor->Visit(it->second))
927 return;
928 }
929}
930
931/*static*/
[email protected]b3a97b52014-07-09 06:25:05932void RenderView::ApplyWebPreferences(const WebPreferences& prefs,
933 WebView* web_view) {
934 WebSettings* settings = web_view->settings();
935 ApplyFontsFromMap(prefs.standard_font_family_map,
936 SetStandardFontFamilyWrapper, settings);
937 ApplyFontsFromMap(prefs.fixed_font_family_map,
938 SetFixedFontFamilyWrapper, settings);
939 ApplyFontsFromMap(prefs.serif_font_family_map,
940 SetSerifFontFamilyWrapper, settings);
941 ApplyFontsFromMap(prefs.sans_serif_font_family_map,
942 SetSansSerifFontFamilyWrapper, settings);
943 ApplyFontsFromMap(prefs.cursive_font_family_map,
944 SetCursiveFontFamilyWrapper, settings);
945 ApplyFontsFromMap(prefs.fantasy_font_family_map,
946 SetFantasyFontFamilyWrapper, settings);
947 ApplyFontsFromMap(prefs.pictograph_font_family_map,
948 SetPictographFontFamilyWrapper, settings);
949 settings->setDefaultFontSize(prefs.default_font_size);
950 settings->setDefaultFixedFontSize(prefs.default_fixed_font_size);
951 settings->setMinimumFontSize(prefs.minimum_font_size);
952 settings->setMinimumLogicalFontSize(prefs.minimum_logical_font_size);
953 settings->setDefaultTextEncodingName(
954 base::ASCIIToUTF16(prefs.default_encoding));
955 settings->setJavaScriptEnabled(prefs.javascript_enabled);
956 settings->setWebSecurityEnabled(prefs.web_security_enabled);
957 settings->setJavaScriptCanOpenWindowsAutomatically(
958 prefs.javascript_can_open_windows_automatically);
959 settings->setLoadsImagesAutomatically(prefs.loads_images_automatically);
960 settings->setImagesEnabled(prefs.images_enabled);
961 settings->setPluginsEnabled(prefs.plugins_enabled);
962 settings->setDOMPasteAllowed(prefs.dom_paste_enabled);
[email protected]b3a97b52014-07-09 06:25:05963 settings->setTextAreasAreResizable(prefs.text_areas_are_resizable);
964 settings->setAllowScriptsToCloseWindows(prefs.allow_scripts_to_close_windows);
965 settings->setDownloadableBinaryFontsEnabled(prefs.remote_fonts_enabled);
966 settings->setJavaScriptCanAccessClipboard(
967 prefs.javascript_can_access_clipboard);
968 WebRuntimeFeatures::enableXSLT(prefs.xslt_enabled);
969 settings->setXSSAuditorEnabled(prefs.xss_auditor_enabled);
970 settings->setDNSPrefetchingEnabled(prefs.dns_prefetching_enabled);
Ben Greenstein49878f52015-12-18 19:13:21971 settings->setDataSaverEnabled(prefs.data_saver_enabled);
[email protected]b3a97b52014-07-09 06:25:05972 settings->setLocalStorageEnabled(prefs.local_storage_enabled);
973 settings->setSyncXHRInDocumentsEnabled(prefs.sync_xhr_in_documents_enabled);
974 WebRuntimeFeatures::enableDatabase(prefs.databases_enabled);
975 settings->setOfflineWebApplicationCacheEnabled(
976 prefs.application_cache_enabled);
japhet5018fe62016-09-14 19:14:04977 settings->setHistoryEntryRequiresUserGesture(
978 prefs.history_entry_requires_user_gesture);
[email protected]b3a97b52014-07-09 06:25:05979 settings->setHyperlinkAuditingEnabled(prefs.hyperlink_auditing_enabled);
980 settings->setCookieEnabled(prefs.cookie_enabled);
981 settings->setNavigateOnDragDrop(prefs.navigate_on_drag_drop);
982
[email protected]b3a97b52014-07-09 06:25:05983 // By default, allow_universal_access_from_file_urls is set to false and thus
984 // we mitigate attacks from local HTML files by not granting file:// URLs
985 // universal access. Only test shell will enable this.
986 settings->setAllowUniversalAccessFromFileURLs(
987 prefs.allow_universal_access_from_file_urls);
988 settings->setAllowFileAccessFromFileURLs(
989 prefs.allow_file_access_from_file_urls);
990
[email protected]b3a97b52014-07-09 06:25:05991 // Enable experimental WebGL support if requested on command line
992 // and support is compiled in.
993 settings->setExperimentalWebGLEnabled(prefs.experimental_webgl_enabled);
994
[email protected]b3a97b52014-07-09 06:25:05995 // Enable WebGL errors to the JS console if requested.
996 settings->setWebGLErrorsToConsoleEnabled(
997 prefs.webgl_errors_to_console_enabled);
998
999 // Uses the mock theme engine for scrollbars.
1000 settings->setMockScrollbarsEnabled(prefs.mock_scrollbars_enabled);
1001
eseckler61ff9142016-09-23 22:57:591002 settings->setHideScrollbars(prefs.hide_scrollbars);
1003
[email protected]b3a97b52014-07-09 06:25:051004 // Enable gpu-accelerated 2d canvas if requested on the command line.
junov524668f22016-08-08 20:16:521005 WebRuntimeFeatures::enableAccelerated2dCanvas(
1006 prefs.accelerated_2d_canvas_enabled);
[email protected]b3a97b52014-07-09 06:25:051007
1008 settings->setMinimumAccelerated2dCanvasSize(
1009 prefs.minimum_accelerated_2d_canvas_size);
1010
1011 // Disable antialiasing for 2d canvas if requested on the command line.
1012 settings->setAntialiased2dCanvasEnabled(
1013 !prefs.antialiased_2d_canvas_disabled);
boliucfcae412016-02-11 22:16:381014 WebRuntimeFeatures::forceDisable2dCanvasCopyOnWrite(
1015 prefs.disable_2d_canvas_copy_on_write);
[email protected]b3a97b52014-07-09 06:25:051016
zakerinasab20ebca02016-09-27 14:22:341017 // Disable antialiasing of clips for 2d canvas if requested on the command
robertphillipse25137b2014-10-20 13:44:341018 // line.
1019 settings->setAntialiasedClips2dCanvasEnabled(
1020 prefs.antialiased_clips_2d_canvas_enabled);
1021
[email protected]b3a97b52014-07-09 06:25:051022 // Set MSAA sample count for 2d canvas if requested on the command line (or
1023 // default value if not).
1024 settings->setAccelerated2dCanvasMSAASampleCount(
1025 prefs.accelerated_2d_canvas_msaa_sample_count);
1026
[email protected]b3a97b52014-07-09 06:25:051027 // Tabs to link is not part of the settings. WebCore calls
1028 // ChromeClient::tabsToLinks which is part of the glue code.
1029 web_view->setTabsToLinks(prefs.tabs_to_links);
1030
[email protected]b3a97b52014-07-09 06:25:051031 settings->setAllowRunningOfInsecureContent(
1032 prefs.allow_running_insecure_content);
mkwst772ce8142015-01-16 13:28:071033 settings->setDisableReadingFromCanvas(prefs.disable_reading_from_canvas);
mkwst2fc2c4f2015-01-08 08:29:181034 settings->setStrictMixedContentChecking(prefs.strict_mixed_content_checking);
mkwst2384c8222015-07-30 07:26:471035
1036 settings->setStrictlyBlockBlockableMixedContent(
1037 prefs.strictly_block_blockable_mixed_content);
1038
mkwst0d233e52015-08-10 09:33:141039 settings->setStrictMixedContentCheckingForPlugin(
1040 prefs.block_mixed_plugin_content);
1041
mkwst673a452f2015-01-10 14:41:501042 settings->setStrictPowerfulFeatureRestrictions(
1043 prefs.strict_powerful_feature_restrictions);
jww9d4ca2d2016-01-19 20:58:591044 settings->setAllowGeolocationOnInsecureOrigins(
1045 prefs.allow_geolocation_on_insecure_origins);
[email protected]b3a97b52014-07-09 06:25:051046 settings->setPasswordEchoEnabled(prefs.password_echo_enabled);
1047 settings->setShouldPrintBackgrounds(prefs.should_print_backgrounds);
1048 settings->setShouldClearDocumentBackground(
1049 prefs.should_clear_document_background);
1050 settings->setEnableScrollAnimator(prefs.enable_scroll_animator);
1051
[email protected]b3a97b52014-07-09 06:25:051052 WebRuntimeFeatures::enableTouch(prefs.touch_enabled);
1053 settings->setMaxTouchPoints(prefs.pointer_events_max_touch_points);
mustaq29eb7092014-11-14 00:32:121054 settings->setAvailablePointerTypes(prefs.available_pointer_types);
1055 settings->setPrimaryPointerType(
nzolghadrc0d1663c2015-11-26 21:15:241056 static_cast<blink::PointerType>(prefs.primary_pointer_type));
mustaq29eb7092014-11-14 00:32:121057 settings->setAvailableHoverTypes(prefs.available_hover_types);
1058 settings->setPrimaryHoverType(
nzolghadrc0d1663c2015-11-26 21:15:241059 static_cast<blink::HoverType>(prefs.primary_hover_type));
[email protected]b3a97b52014-07-09 06:25:051060 settings->setDeviceSupportsTouch(prefs.device_supports_touch);
1061 settings->setDeviceSupportsMouse(prefs.device_supports_mouse);
1062 settings->setEnableTouchAdjustment(prefs.touch_adjustment_enabled);
1063
ccameron7c4df6c22016-08-11 03:03:151064 WebRuntimeFeatures::enableColorCorrectRendering(
1065 prefs.color_correct_rendering_enabled);
[email protected]b3a97b52014-07-09 06:25:051066 settings->setShouldRespectImageOrientation(
1067 prefs.should_respect_image_orientation);
1068
[email protected]b3a97b52014-07-09 06:25:051069 settings->setEditingBehavior(
1070 static_cast<WebSettings::EditingBehavior>(prefs.editing_behavior));
1071
1072 settings->setSupportsMultipleWindows(prefs.supports_multiple_windows);
1073
ymalik835268c22016-02-22 16:28:121074 settings->setInertVisualViewport(prefs.inert_visual_viewport);
1075
khushalsagar2da2b232016-03-23 22:11:351076 settings->setMainFrameClipsContent(!prefs.record_whole_document);
1077
[email protected]b3a97b52014-07-09 06:25:051078 settings->setSmartInsertDeleteEnabled(prefs.smart_insert_delete_enabled);
1079
1080 settings->setSpatialNavigationEnabled(prefs.spatial_navigation_enabled);
1081
1082 settings->setSelectionIncludesAltImageText(true);
1083
[email protected]35103c02014-08-12 15:08:471084 settings->setV8CacheOptions(
1085 static_cast<WebSettings::V8CacheOptions>(prefs.v8_cache_options));
1086
horodbcbef42016-05-10 17:02:471087 settings->setV8CacheStrategiesForCacheStorage(
1088 GetV8CacheStrategiesForCacheStorage());
1089
je_julie.kim7fbb5a1a2015-02-09 17:26:051090 settings->setImageAnimationPolicy(
1091 static_cast<WebSettings::ImageAnimationPolicy>(prefs.animation_policy));
1092
zqzhang1215ad422016-02-10 13:27:221093 settings->setPresentationRequiresUserGesture(
1094 prefs.user_gesture_required_for_presentation);
1095
halliwell4002be42016-03-18 18:33:401096 settings->setTextTrackMarginPercentage(prefs.text_track_margin_percentage);
1097
dcheng5ae8ca362015-02-05 04:03:471098 // Needs to happen before setIgnoreVIewportTagScaleLimits below.
1099 web_view->setDefaultPageScaleLimits(
1100 prefs.default_minimum_page_scale_factor,
1101 prefs.default_maximum_page_scale_factor);
1102
[email protected]b3a97b52014-07-09 06:25:051103#if defined(OS_ANDROID)
1104 settings->setAllowCustomScrollbarInMainFrame(false);
1105 settings->setTextAutosizingEnabled(prefs.text_autosizing_enabled);
1106 settings->setAccessibilityFontScaleFactor(prefs.font_scale_factor);
1107 settings->setDeviceScaleAdjustment(prefs.device_scale_adjustment);
[email protected]023fed312014-08-11 16:13:051108 settings->setFullscreenSupported(prefs.fullscreen_supported);
[email protected]b3a97b52014-07-09 06:25:051109 web_view->setIgnoreViewportTagScaleLimits(prefs.force_enable_zoom);
1110 settings->setAutoZoomFocusedNodeToLegibleScale(true);
1111 settings->setDoubleTapToZoomEnabled(prefs.double_tap_to_zoom_enabled);
1112 settings->setMediaControlsOverlayPlayButtonEnabled(true);
1113 settings->setMediaPlaybackRequiresUserGesture(
1114 prefs.user_gesture_required_for_media_playback);
1115 settings->setDefaultVideoPosterURL(
dalecurtiscd971252016-09-21 16:09:001116 base::ASCIIToUTF16(prefs.default_video_poster_url.spec()));
[email protected]b3a97b52014-07-09 06:25:051117 settings->setSupportDeprecatedTargetDensityDPI(
1118 prefs.support_deprecated_target_density_dpi);
1119 settings->setUseLegacyBackgroundSizeShorthandBehavior(
1120 prefs.use_legacy_background_size_shorthand_behavior);
1121 settings->setWideViewportQuirkEnabled(prefs.wide_viewport_quirk);
1122 settings->setUseWideViewport(prefs.use_wide_viewport);
[email protected]9954ea92014-08-12 15:48:451123 settings->setForceZeroLayoutHeight(prefs.force_zero_layout_height);
[email protected]b3a97b52014-07-09 06:25:051124 settings->setViewportMetaLayoutSizeQuirk(
1125 prefs.viewport_meta_layout_size_quirk);
1126 settings->setViewportMetaMergeContentQuirk(
1127 prefs.viewport_meta_merge_content_quirk);
1128 settings->setViewportMetaNonUserScalableQuirk(
1129 prefs.viewport_meta_non_user_scalable_quirk);
1130 settings->setViewportMetaZeroValuesQuirk(
1131 prefs.viewport_meta_zero_values_quirk);
1132 settings->setClobberUserAgentInitialScaleQuirk(
1133 prefs.clobber_user_agent_initial_scale_quirk);
1134 settings->setIgnoreMainFrameOverflowHiddenQuirk(
1135 prefs.ignore_main_frame_overflow_hidden_quirk);
1136 settings->setReportScreenSizeInPhysicalPixelsQuirk(
1137 prefs.report_screen_size_in_physical_pixels_quirk);
boliu1a00f262016-04-06 19:08:461138 settings->setShouldReuseGlobalForUnownedMainFrame(
1139 prefs.resue_global_for_unowned_main_frame);
japhet98e9bd82016-06-28 23:48:451140 settings->setProgressBarCompletion(
1141 static_cast<WebSettings::ProgressBarCompletion>(
1142 prefs.progress_bar_completion));
liberato2f1a7e02015-08-10 16:01:411143 settings->setPreferHiddenVolumeControls(true);
dalecurtiscd971252016-09-21 16:09:001144
1145 // Force preload=none and disable autoplay on older or low end Android
1146 // platforms because their media pipelines are not stable enough to handle
1147 // concurrent elements. See http://crbug.com/612909, http://crbug.com/622826.
1148 const bool is_low_end_device =
1149 base::android::BuildInfo::GetInstance()->sdk_int() <=
1150 base::android::SDK_VERSION_JELLY_BEAN_MR2 ||
1151 base::SysInfo::IsLowEndDevice();
1152 settings->setForcePreloadNoneForMediaElements(is_low_end_device);
avayvodb28c3632016-06-09 11:19:061153 WebRuntimeFeatures::enableAutoplayMutedVideos(
dalecurtiscd971252016-09-21 16:09:001154 prefs.autoplay_muted_videos_enabled && !is_low_end_device);
timvolodinedb195192016-10-05 13:52:451155 settings->setSpellCheckEnabledByDefault(prefs.spellcheck_enabled_by_default);
liberato9e934892016-05-03 19:00:271156#endif
1157
liberato6524fa42015-09-14 23:26:081158 settings->setAutoplayExperimentMode(
1159 blink::WebString::fromUTF8(prefs.autoplay_experiment_mode));
[email protected]b3a97b52014-07-09 06:25:051160
yoava1a508b42015-10-20 12:03:211161 settings->setViewportEnabled(prefs.viewport_enabled);
yoava1a508b42015-10-20 12:03:211162 settings->setViewportMetaEnabled(prefs.viewport_meta_enabled);
mlliub27b45c62016-06-10 19:30:091163 settings->setShrinksViewportContentToFit(
1164 prefs.shrinks_viewport_contents_to_fit);
alokp5d566962016-04-19 00:54:161165 settings->setViewportStyle(
1166 static_cast<blink::WebViewportStyle>(prefs.viewport_style));
1167
1168 settings->setLoadWithOverviewMode(prefs.initialize_at_minimum_page_scale);
yoava1a508b42015-10-20 12:03:211169 settings->setMainFrameResizesAreOrientationChanges(
1170 prefs.main_frame_resizes_are_orientation_changes);
1171
[email protected]b3a97b52014-07-09 06:25:051172 settings->setPinchOverlayScrollbarThickness(
1173 prefs.pinch_overlay_scrollbar_thickness);
1174 settings->setUseSolidColorScrollbars(prefs.use_solid_color_scrollbars);
jinho.bang8f11ffa2014-12-04 06:03:031175
arjanl98804912015-03-04 09:23:041176 settings->setShowContextMenuOnMouseUp(prefs.context_menu_on_mouse_up);
amaralp547e4192016-06-03 19:17:351177 settings->setAlwaysShowContextMenuOnTouch(
1178 prefs.always_show_context_menu_on_touch);
ccameron2fd70de72015-02-19 00:40:401179
1180#if defined(OS_MACOSX)
1181 settings->setDoubleTapToZoomEnabled(true);
ccameronf29a7802015-02-20 22:11:251182 web_view->setMaximumLegibleScale(prefs.default_maximum_page_scale_factor);
ccameron2fd70de72015-02-19 00:40:401183#endif
sunyunjia87f287b2016-09-09 00:38:131184
1185#if defined(OS_WIN)
1186 WebRuntimeFeatures::enableMiddleClickAutoscroll(true);
1187#endif
[email protected]b3a97b52014-07-09 06:25:051188}
1189
1190/*static*/
dcheng35d31c112015-07-22 00:17:361191RenderViewImpl* RenderViewImpl::Create(CompositorDependencies* compositor_deps,
rockot067ca55f2016-09-30 22:00:151192 const mojom::CreateViewParams& params,
danakj6e3bf8012014-12-16 18:27:531193 bool was_created_by_renderer) {
naskobd911332014-11-25 01:13:361194 DCHECK(params.view_id != MSG_ROUTING_NONE);
[email protected]075366912013-02-18 07:13:241195 RenderViewImpl* render_view = NULL;
[email protected]8d41d7612012-11-14 20:32:191196 if (g_create_render_view_impl)
dcheng35d31c112015-07-22 00:17:361197 render_view = g_create_render_view_impl(compositor_deps, params);
[email protected]075366912013-02-18 07:13:241198 else
dcheng35d31c112015-07-22 00:17:361199 render_view = new RenderViewImpl(compositor_deps, params);
[email protected]0287e762014-04-11 13:07:581200
dcheng35d31c112015-07-22 00:17:361201 render_view->Initialize(params, was_created_by_renderer);
[email protected]075366912013-02-18 07:13:241202 return render_view;
[email protected]8d41d7612012-11-14 20:32:191203}
1204
1205// static
dcheng35d31c112015-07-22 00:17:361206void RenderViewImpl::InstallCreateHook(RenderViewImpl* (
1207 *create_render_view_impl)(CompositorDependencies* compositor_deps,
rockot067ca55f2016-09-30 22:00:151208 const mojom::CreateViewParams&)) {
[email protected]8d41d7612012-11-14 20:32:191209 CHECK(!g_create_render_view_impl);
1210 g_create_render_view_impl = create_render_view_impl;
initial.commit09911bf2008-07-26 23:55:291211}
1212
[email protected]310ebd6302011-10-10 19:06:281213void RenderViewImpl::AddObserver(RenderViewObserver* observer) {
[email protected]676126f72011-01-15 00:03:511214 observers_.AddObserver(observer);
1215}
1216
[email protected]310ebd6302011-10-10 19:06:281217void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) {
1218 observer->RenderViewGone();
[email protected]676126f72011-01-15 00:03:511219 observers_.RemoveObserver(observer);
1220}
1221
[email protected]180ef242013-11-07 06:50:461222blink::WebView* RenderViewImpl::webview() const {
lfg4fa48da2016-05-09 18:25:131223 return webview_;
[email protected]4d51d5bf2010-07-26 18:48:261224}
1225
[email protected]ea2fb972013-08-07 05:44:261226#if defined(ENABLE_PLUGINS)
[email protected]a99a38802014-01-14 15:46:571227
[email protected]784ea1ab2010-09-18 00:02:341228#if defined(OS_MACOSX)
[email protected]7411a3c2014-08-15 05:20:191229void RenderViewImpl::OnGetRenderedText() {
1230 if (!webview())
1231 return;
dglazkov03223492016-02-08 22:16:031232
1233 if (!webview()->mainFrame()->isWebLocalFrame())
1234 return;
1235
[email protected]7411a3c2014-08-15 05:20:191236 // Get rendered text from WebLocalFrame.
1237 // TODO: Currently IPC truncates any data that has a
1238 // size > kMaximumMessageSize. May be split the text into smaller chunks and
1239 // send back using multiple IPC. See http://crbug.com/393444.
1240 static const size_t kMaximumMessageSize = 8 * 1024 * 1024;
dglazkov03223492016-02-08 22:16:031241 // TODO(dglazkov): Using this API is wrong. It's not OOPIF-compatible and
1242 // sends text in the wrong order. See http://crbug.com/584798.
1243 // TODO(dglazkov): WebFrameContentDumper should only be used for
1244 // testing purposes. See http://crbug.com/585164.
1245 std::string text =
dglazkov2f8c7fc2016-04-17 19:46:201246 WebFrameContentDumper::dumpWebViewAsText(webview(), kMaximumMessageSize)
dglazkov03223492016-02-08 22:16:031247 .utf8();
[email protected]7411a3c2014-08-15 05:20:191248
avia3dca182016-03-19 01:09:521249 Send(new ViewMsg_GetRenderedTextCompleted(GetRoutingID(), text));
[email protected]7411a3c2014-08-15 05:20:191250}
[email protected]a80af12e2013-08-07 23:36:131251#endif // defined(OS_MACOSX)
1252
1253#endif // ENABLE_PLUGINS
1254
[email protected]7a1ec28a2012-03-28 21:10:241255void RenderViewImpl::TransferActiveWheelFlingAnimation(
[email protected]180ef242013-11-07 06:50:461256 const blink::WebActiveWheelFlingParameters& params) {
[email protected]7a1ec28a2012-03-28 21:10:241257 if (webview())
1258 webview()->transferActiveWheelFlingAnimation(params);
1259}
1260
fsamuel72464894f2015-12-15 06:59:311261// RenderWidgetInputHandlerDelegate -----------------------------------------
1262
avid7d6b2e2016-03-04 19:41:171263void RenderViewImpl::RenderWidgetFocusChangeComplete() {
fsamuel72464894f2015-12-15 06:59:311264 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusChangeComplete());
1265}
1266
avid7d6b2e2016-03-04 19:41:171267bool RenderViewImpl::DoesRenderWidgetHaveTouchEventHandlersAt(
1268 const gfx::Point& point) const {
fsamuel72464894f2015-12-15 06:59:311269 if (!webview())
1270 return false;
1271 return webview()->hasTouchEventHandlersAt(point);
1272}
1273
avid7d6b2e2016-03-04 19:41:171274bool RenderViewImpl::RenderWidgetWillHandleGestureEvent(
fsamuel72464894f2015-12-15 06:59:311275 const blink::WebGestureEvent& event) {
1276 possible_drag_event_info_.event_source =
1277 ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH;
1278 possible_drag_event_info_.event_location =
1279 gfx::Point(event.globalX, event.globalY);
1280 return false;
1281}
1282
avid7d6b2e2016-03-04 19:41:171283bool RenderViewImpl::RenderWidgetWillHandleMouseEvent(
1284 const blink::WebMouseEvent& event) {
fsamuel72464894f2015-12-15 06:59:311285 possible_drag_event_info_.event_source =
1286 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE;
1287 possible_drag_event_info_.event_location =
1288 gfx::Point(event.globalX, event.globalY);
1289
fsamuel72464894f2015-12-15 06:59:311290 // If the mouse is locked, only the current owner of the mouse lock can
1291 // process mouse events.
1292 return mouse_lock_dispatcher_->WillHandleMouseEvent(event);
1293}
1294
1295// IPC::Listener implementation ----------------------------------------------
1296
[email protected]310ebd6302011-10-10 19:06:281297bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) {
[email protected]26aa0482009-09-30 16:55:271298 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL;
[email protected]82307f6b2014-08-07 03:30:121299 if (main_frame && main_frame->isWebLocalFrame())
[email protected]e9ff79c2012-10-19 21:31:261300 GetContentClient()->SetActiveURL(main_frame->document().url());
[email protected]f8b6b6f2009-03-10 16:48:261301
naskoc6edf7e2015-10-16 01:48:451302 // Input IPC messages must not be processed if the RenderView is in
1303 // swapped out state.
1304 if (is_swapped_out_ && IPC_MESSAGE_ID_CLASS(message.type()) == InputMsgStart)
1305 return false;
1306
dchenga2d442c22016-10-13 15:39:211307 for (auto& observer : observers_) {
1308 if (observer.OnMessageReceived(message))
[email protected]676126f72011-01-15 00:03:511309 return true;
dchenga2d442c22016-10-13 15:39:211310 }
[email protected]b2abac72009-02-26 12:39:281311
[email protected]a95986a82010-12-24 06:19:281312 bool handled = true;
[email protected]e44d1342014-05-16 21:29:331313 IPC_BEGIN_MESSAGE_MAP(RenderViewImpl, message)
[email protected]c084330e02013-04-27 01:08:151314 IPC_MESSAGE_HANDLER(InputMsg_ExecuteEditCommand, OnExecuteEditCommand)
1315 IPC_MESSAGE_HANDLER(InputMsg_MoveCaret, OnMoveCaret)
[email protected]c084330e02013-04-27 01:08:151316 IPC_MESSAGE_HANDLER(InputMsg_ScrollFocusedEditableNodeIntoRect,
1317 OnScrollFocusedEditableNodeIntoRect)
mcnee432e47d2015-11-09 19:37:461318 IPC_MESSAGE_HANDLER(ViewMsg_SetPageScale, OnSetPageScale)
[email protected]630e26b2008-10-14 22:55:171319 IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
scottmg3ea15712016-08-09 16:46:411320 IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL,
1321 OnSetZoomLevelForLoadingURL)
[email protected]59f4f2fa2011-03-23 01:00:551322 IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter)
1323 IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver)
1324 IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave)
1325 IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop)
[email protected]7a6d773f2014-04-04 01:25:091326 IPC_MESSAGE_HANDLER(DragMsg_SourceEnded, OnDragSourceEnded)
[email protected]59f4f2fa2011-03-23 01:00:551327 IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded,
1328 OnDragSourceSystemDragEnded)
[email protected]18cb2572008-08-21 20:34:451329 IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings)
initial.commit09911bf2008-07-26 23:55:291330 IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus)
initial.commit09911bf2008-07-26 23:55:291331 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck)
1332 IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences)
[email protected]600ea402011-04-12 00:01:511333 IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse,
1334 OnEnumerateDirectoryResponse)
initial.commit09911bf2008-07-26 23:55:291335 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage)
[email protected]30f75e62009-02-25 22:01:001336 IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted)
[email protected]ab6c9112014-02-27 00:20:581337 IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedElement, OnClearFocusedElement)
[email protected]61f91832014-05-13 01:24:421338 IPC_MESSAGE_HANDLER(ViewMsg_SetBackgroundOpaque, OnSetBackgroundOpaque)
[email protected]ab32b16c2009-10-16 14:57:251339 IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode,
1340 OnEnablePreferredSizeChangedMode)
[email protected]244ac1892011-12-02 17:04:471341 IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize)
[email protected]61e2b3cc2012-03-02 16:13:341342 IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize)
[email protected]cda45c02010-02-25 19:28:101343 IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows,
1344 OnDisableScrollbarsForSmallWindows)
[email protected]80d96fa2009-06-10 22:34:511345 IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs)
[email protected]581b87eb2009-07-23 23:06:561346 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt)
[email protected]81375e872012-01-11 21:40:361347 IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt)
[email protected]8c66c5a2009-07-22 17:26:341348 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive)
[email protected]47822262013-04-23 17:22:361349 IPC_MESSAGE_HANDLER(ViewMsg_ShowContextMenu, OnShowContextMenu)
[email protected]cb189e062014-04-23 00:57:011350 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1351 OnReleaseDisambiguationPopupBitmap)
[email protected]506563d2014-06-23 12:22:411352 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
[email protected]4dda6a6c2014-05-17 15:35:041353 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
wjmaclean64951902016-04-29 20:59:121354
1355 // Page messages.
lfgdb5c4ed2016-03-04 23:09:071356 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect,
1357 OnUpdateWindowScreenRect)
wjmaclean64951902016-04-29 20:59:121358 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel)
wjmaclean8a795f32016-08-11 23:49:581359 IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor);
lfg717154072016-06-30 15:04:161360 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden)
1361 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown)
alexmos136fd6e62016-08-15 20:58:411362 IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength,
1363 OnSetHistoryOffsetAndLength)
lfg717154072016-06-30 15:04:161364
[email protected]55750b32012-09-21 14:05:031365#if defined(OS_ANDROID)
[email protected]452b4a92013-03-28 21:24:381366 IPC_MESSAGE_HANDLER(ViewMsg_UpdateTopControlsState,
1367 OnUpdateTopControlsState)
[email protected]c4790dcb2013-12-27 22:08:021368 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData)
[email protected]55750b32012-09-21 14:05:031369#elif defined(OS_MACOSX)
[email protected]7411a3c2014-08-15 05:20:191370 IPC_MESSAGE_HANDLER(ViewMsg_GetRenderedText,
1371 OnGetRenderedText)
naskoc288745f2015-05-01 22:54:211372 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose)
[email protected]55750b32012-09-21 14:05:031373#endif
[email protected]a794f3a2013-10-30 17:00:321374 // Adding a new message? Add platform independent ones first, then put the
1375 // platform specific ones at the end.
[email protected]9e1ad4b2011-08-14 16:49:191376
initial.commit09911bf2008-07-26 23:55:291377 // Have the super handle all other messages.
[email protected]a95986a82010-12-24 06:19:281378 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
initial.commit09911bf2008-07-26 23:55:291379 IPC_END_MESSAGE_MAP()
[email protected]ffc906f2011-10-04 22:55:401380
[email protected]a95986a82010-12-24 06:19:281381 return handled;
initial.commit09911bf2008-07-26 23:55:291382}
1383
[email protected]4dda6a6c2014-05-17 15:35:041384void RenderViewImpl::OnSelectWordAroundCaret() {
1385 if (!webview())
1386 return;
1387
fsamuele8326c742016-01-12 00:49:391388 input_handler_->set_handling_input_event(true);
[email protected]4dda6a6c2014-05-17 15:35:041389 webview()->focusedFrame()->selectWordAroundCaret();
fsamuele8326c742016-01-12 00:49:391390 input_handler_->set_handling_input_event(false);
[email protected]4dda6a6c2014-05-17 15:35:041391}
1392
[email protected]310ebd6302011-10-10 19:06:281393void RenderViewImpl::OnUpdateTargetURLAck() {
initial.commit09911bf2008-07-26 23:55:291394 // Check if there is a targeturl waiting to be sent.
avi450ce00e2014-09-24 01:58:521395 if (target_url_status_ == TARGET_PENDING)
avia3dca182016-03-19 01:09:521396 Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), pending_target_url_));
initial.commit09911bf2008-07-26 23:55:291397
1398 target_url_status_ = TARGET_NONE;
1399}
1400
[email protected]c084330e02013-04-27 01:08:151401void RenderViewImpl::OnExecuteEditCommand(const std::string& name,
1402 const std::string& value) {
1403 if (!webview() || !webview()->focusedFrame())
1404 return;
1405
1406 webview()->focusedFrame()->executeCommand(
1407 WebString::fromUTF8(name), WebString::fromUTF8(value));
1408}
1409
1410void RenderViewImpl::OnMoveCaret(const gfx::Point& point) {
1411 if (!webview())
1412 return;
1413
avia3dca182016-03-19 01:09:521414 Send(new InputHostMsg_MoveCaret_ACK(GetRoutingID()));
oshima93b827d92016-03-01 18:58:411415 webview()->focusedFrame()->moveCaretSelection(
1416 ConvertWindowPointToViewport(point));
[email protected]c084330e02013-04-27 01:08:151417}
[email protected]a954bf72009-09-12 07:30:351418
[email protected]c084330e02013-04-27 01:08:151419void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect(
1420 const gfx::Rect& rect) {
[email protected]1875bc02014-03-14 06:33:591421 if (has_scrolled_focused_editable_node_into_rect_ &&
1422 rect == rect_for_scrolled_focused_editable_node_) {
avid7d6b2e2016-03-04 19:41:171423 GetWidget()->FocusChangeComplete();
[email protected]1875bc02014-03-14 06:33:591424 return;
1425 }
1426
dglazkov4969a3e2016-05-20 21:13:511427 if (!webview()->scrollFocusedEditableElementIntoRect(rect))
1428 return;
rouslanf7ebd8832015-01-22 01:54:141429
dglazkov4969a3e2016-05-20 21:13:511430 rect_for_scrolled_focused_editable_node_ = rect;
1431 has_scrolled_focused_editable_node_into_rect_ = true;
1432 if (!compositor()->hasPendingPageScaleAnimation())
avid7d6b2e2016-03-04 19:41:171433 GetWidget()->FocusChangeComplete();
[email protected]25bcc8f2013-01-09 02:49:251434}
1435
avi2b177592014-12-10 02:08:021436void RenderViewImpl::OnSetHistoryOffsetAndLength(int history_offset,
1437 int history_length) {
1438 DCHECK_GE(history_offset, -1);
[email protected]e1ed5a12012-08-08 19:57:441439 DCHECK_GE(history_length, 0);
[email protected]9e1ad4b2011-08-14 16:49:191440
avi2b177592014-12-10 02:08:021441 history_list_offset_ = history_offset;
1442 history_list_length_ = history_length;
[email protected]9e1ad4b2011-08-14 16:49:191443}
1444
[email protected]310ebd6302011-10-10 19:06:281445void RenderViewImpl::OnSetInitialFocus(bool reverse) {
initial.commit09911bf2008-07-26 23:55:291446 if (!webview())
1447 return;
[email protected]26aa0482009-09-30 16:55:271448 webview()->setInitialFocus(reverse);
initial.commit09911bf2008-07-26 23:55:291449}
1450
lfgdb5c4ed2016-03-04 23:09:071451void RenderViewImpl::OnUpdateWindowScreenRect(gfx::Rect window_screen_rect) {
1452 RenderWidget::OnUpdateWindowScreenRect(window_screen_rect);
1453}
1454
initial.commit09911bf2008-07-26 23:55:291455///////////////////////////////////////////////////////////////////////////////
1456
avi137dc952015-07-24 23:19:141457void RenderViewImpl::SendUpdateState() {
creis8eb8ef22015-11-04 22:51:381458 // We don't use this path in OOPIF-enabled modes.
1459 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries());
creisae7ce9a2015-11-02 20:52:191460
avi137dc952015-07-24 23:19:141461 HistoryEntry* entry = history_controller_->GetCurrentEntry();
avif937e1d2014-11-02 18:13:071462 if (!entry)
1463 return;
1464
avia3dca182016-03-19 01:09:521465 Send(new ViewHostMsg_UpdateState(GetRoutingID(), page_id_,
fsamuele8326c742016-01-12 00:49:391466 HistoryEntryToPageState(entry)));
avif937e1d2014-11-02 18:13:071467}
1468
creis69b184a472015-11-26 05:29:511469void RenderViewImpl::SendFrameStateUpdates() {
1470 // We only use this path in OOPIF-enabled modes.
1471 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries());
1472
1473 // Tell each frame with pending state to send its UpdateState message.
1474 for (int render_frame_routing_id : frames_with_pending_state_) {
1475 RenderFrameImpl* frame =
1476 RenderFrameImpl::FromRoutingID(render_frame_routing_id);
1477 if (frame)
1478 frame->SendUpdateState();
1479 }
1480 frames_with_pending_state_.clear();
1481}
1482
sataya.mf405d0e2015-07-07 16:51:111483void RenderViewImpl::ApplyWebPreferencesInternal(
1484 const WebPreferences& prefs,
1485 blink::WebView* web_view,
1486 CompositorDependencies* compositor_deps) {
1487 ApplyWebPreferences(prefs, web_view);
sataya.mf405d0e2015-07-07 16:51:111488}
1489
svartmetal751af1f92016-08-13 11:47:331490void RenderViewImpl::OnForceRedraw(const ui::LatencyInfo& latency_info) {
[email protected]7d08a9352013-10-15 08:24:561491 if (RenderWidgetCompositor* rwc = compositor()) {
svartmetal751af1f92016-08-13 11:47:331492 rwc->QueueSwapPromise(
1493 base::MakeUnique<AlwaysDrawSwapPromise>(latency_info));
[email protected]7d08a9352013-10-15 08:24:561494 }
1495 ScheduleCompositeWithForcedRedraw();
[email protected]c9bc8f12012-12-15 22:20:091496}
1497
[email protected]180ef242013-11-07 06:50:461498// blink::WebViewClient ------------------------------------------------------
[email protected]48c9cf2d2009-09-16 16:47:521499
[email protected]35b2a972014-04-04 15:50:221500WebView* RenderViewImpl::createView(WebLocalFrame* creator,
1501 const WebURLRequest& request,
1502 const WebWindowFeatures& features,
1503 const WebString& frame_name,
1504 WebNavigationPolicy policy,
1505 bool suppress_opener) {
rockot5c478a72016-09-28 23:14:181506 mojom::CreateNewWindowParamsPtr params = mojom::CreateNewWindowParams::New();
1507 params->opener_id = GetRoutingID();
1508 params->user_gesture = WebUserGestureIndicator::isProcessingUserGesture();
[email protected]00323f02013-07-24 15:47:411509 if (GetContentClient()->renderer()->AllowPopup())
rockot5c478a72016-09-28 23:14:181510 params->user_gesture = true;
1511 params->window_container_type = WindowFeaturesToContainerType(features);
1512 params->session_storage_namespace_id = session_storage_namespace_id_;
[email protected]5cef23d2013-02-27 13:11:211513 if (frame_name != "_blank")
rockot5c478a72016-09-28 23:14:181514 params->frame_name = base::UTF16ToUTF8(base::StringPiece16(frame_name));
1515 params->opener_render_frame_id =
[email protected]501052ff2014-02-21 22:19:071516 RenderFrameImpl::FromWebFrame(creator)->GetRoutingID();
rockot5c478a72016-09-28 23:14:181517 params->opener_url = creator->document().url();
alexmosa97d5c52015-06-19 22:19:091518
1519 // The browser process uses the top frame's URL for a content settings check
1520 // to determine whether the popup is allowed. If the top frame is remote,
1521 // its URL is not available, so use its replicated origin instead.
1522 //
1523 // TODO(alexmos): This works fine for regular origins but may break path
1524 // matching for file URLs with OOP subframes that open popups. This should
1525 // be fixed by either moving this lookup to the browser process or removing
1526 // path-based matching for file URLs from content settings. See
1527 // https://crbug.com/466297.
1528 if (creator->top()->isWebLocalFrame()) {
rockot5c478a72016-09-28 23:14:181529 params->opener_top_level_frame_url = creator->top()->document().url();
alexmosa97d5c52015-06-19 22:19:091530 } else {
rockot5c478a72016-09-28 23:14:181531 params->opener_top_level_frame_url =
Dana Jansens71331252016-03-09 20:57:221532 blink::WebStringToGURL(creator->top()->getSecurityOrigin().toString());
alexmosa97d5c52015-06-19 22:19:091533 }
1534
brettwdfbcc3b2016-01-20 01:49:171535 GURL security_url(blink::WebStringToGURL(
Dana Jansens71331252016-03-09 20:57:221536 creator->document().getSecurityOrigin().toString()));
[email protected]7f48b712013-01-25 01:48:301537 if (!security_url.is_valid())
1538 security_url = GURL();
rockot5c478a72016-09-28 23:14:181539 params->opener_security_origin = security_url;
1540 params->opener_suppressed = suppress_opener;
1541 params->disposition = NavigationPolicyToDisposition(policy);
[email protected]44e55b012013-07-23 14:21:561542 if (!request.isNull()) {
rockot5c478a72016-09-28 23:14:181543 params->target_url = request.url();
1544 params->referrer = GetReferrerFromRequest(creator, request);
[email protected]44e55b012013-07-23 14:21:561545 }
rockot5c478a72016-09-28 23:14:181546 params->features = features;
[email protected]8ab04652010-06-12 02:47:261547
rockot5c478a72016-09-28 23:14:181548 // We preserve this information before sending the message since |params| is
1549 // moved on send.
1550 bool is_background_tab =
1551 params->disposition == WindowOpenDisposition::NEW_BACKGROUND_TAB;
1552 bool opened_by_user_gesture = params->user_gesture;
[email protected]22217ed32013-11-18 18:40:231553
rockot5c478a72016-09-28 23:14:181554 mojom::CreateNewWindowReplyPtr reply;
1555 RenderThreadImpl::current_render_message_filter()->CreateNewWindow(
1556 std::move(params), &reply);
1557 if (reply->route_id == MSG_ROUTING_NONE)
1558 return nullptr;
[email protected]48c9cf2d2009-09-16 16:47:521559
[email protected]af15bf22013-03-08 01:18:171560 WebUserGestureIndicator::consumeUserGesture();
[email protected]c59262422012-11-30 21:20:521561
[email protected]7912e822014-04-16 02:37:031562 // While this view may be a background extension page, it can spawn a visible
1563 // render view. So we just assume that the new one is not another background
1564 // page instead of passing on our own value.
1565 // TODO(vangelis): Can we tell if the new view will be a background page?
1566 bool never_visible = false;
[email protected]9115d5f2013-03-24 04:37:411567
fsamuel664e8b62016-01-20 19:54:011568 ResizeParams initial_size = ResizeParams();
mkosiba58fa72f02014-11-12 01:21:361569 initial_size.screen_info = screen_info_;
1570
[email protected]d6fa88f2013-10-18 16:00:431571 // The initial hidden state for the RenderViewImpl here has to match what the
1572 // browser will eventually decide for the given disposition. Since we have to
1573 // return from this call synchronously, we just have to make our best guess
1574 // and rely on the browser sending a WasHidden / WasShown message if it
1575 // disagrees.
rockot067ca55f2016-09-30 22:00:151576 mojom::CreateViewParams view_params;
alexmos5ac402d2015-07-09 07:51:101577
1578 RenderFrameImpl* creator_frame = RenderFrameImpl::FromWebFrame(creator);
1579 view_params.opener_frame_route_id = creator_frame->GetRoutingID();
avia3dca182016-03-19 01:09:521580 DCHECK_EQ(GetRoutingID(), creator_frame->render_view()->GetRoutingID());
alexmos5ac402d2015-07-09 07:51:101581
naskobd911332014-11-25 01:13:361582 view_params.window_was_created_with_opener = true;
1583 view_params.renderer_preferences = renderer_preferences_;
1584 view_params.web_preferences = webkit_preferences_;
rockot5c478a72016-09-28 23:14:181585 view_params.view_id = reply->route_id;
1586 view_params.main_frame_routing_id = reply->main_frame_route_id;
1587 view_params.main_frame_widget_routing_id = reply->main_frame_widget_route_id;
naskobd911332014-11-25 01:13:361588 view_params.session_storage_namespace_id =
rockot5c478a72016-09-28 23:14:181589 reply->cloned_session_storage_namespace_id;
naskobd911332014-11-25 01:13:361590 view_params.swapped_out = false;
alexmos3448b552015-06-26 07:49:131591 // WebCore will take care of setting the correct name.
alexmosbc7eafa2014-12-06 01:38:091592 view_params.replicated_frame_state = FrameReplicationState();
rockot5c478a72016-09-28 23:14:181593 view_params.hidden = is_background_tab;
naskobd911332014-11-25 01:13:361594 view_params.never_visible = never_visible;
1595 view_params.next_page_id = 1;
1596 view_params.initial_size = initial_size;
1597 view_params.enable_auto_resize = false;
1598 view_params.min_size = gfx::Size();
1599 view_params.max_size = gfx::Size();
wjmaclean64951902016-04-29 20:59:121600 view_params.page_zoom_level = page_zoom_level_;
naskobd911332014-11-25 01:13:361601
danakj6e3bf8012014-12-16 18:27:531602 RenderViewImpl* view =
dcheng35d31c112015-07-22 00:17:361603 RenderViewImpl::Create(compositor_deps_, view_params, true);
rockot5c478a72016-09-28 23:14:181604 view->opened_by_user_gesture_ = opened_by_user_gesture;
[email protected]48c9cf2d2009-09-16 16:47:521605
[email protected]48c9cf2d2009-09-16 16:47:521606 return view->webview();
1607}
1608
[email protected]180ef242013-11-07 06:50:461609WebWidget* RenderViewImpl::createPopupMenu(blink::WebPopupType popup_type) {
avia3dca182016-03-19 01:09:521610 RenderWidget* widget = RenderWidget::Create(GetRoutingID(), compositor_deps_,
danakj6e3bf8012014-12-16 18:27:531611 popup_type, screen_info_);
[email protected]3b78ec12014-03-04 05:18:281612 if (!widget)
1613 return NULL;
[email protected]b2e4c70132013-10-03 02:07:511614 if (screen_metrics_emulator_) {
1615 widget->SetPopupOriginAdjustmentsForEmulation(
1616 screen_metrics_emulator_.get());
1617 }
lfg8ff33912016-09-13 20:59:211618 return widget->GetWebWidget();
[email protected]48c9cf2d2009-09-16 16:47:521619}
1620
[email protected]23367482013-06-27 21:06:541621WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace() {
[email protected]5f2aa722013-08-07 16:59:411622 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId);
[email protected]1910fe82012-05-10 00:04:101623 return new WebStorageNamespaceImpl(session_storage_namespace_id_);
[email protected]bd92c3a2010-01-13 05:02:341624}
1625
[email protected]35b2a972014-04-04 15:50:221626void RenderViewImpl::printPage(WebLocalFrame* frame) {
naskoe440d8c2016-10-12 23:07:561627 UMA_HISTOGRAM_BOOLEAN("PrintPreview.InitiatedByScript",
1628 frame->top() == frame);
1629
1630 // Logging whether the top frame is remote is sufficient in this case. If
1631 // the top frame is local, the printing code will function correctly and
1632 // the frame itself will be printed, so the cases this histogram tracks is
1633 // where printing of a subframe will fail as of now.
1634 UMA_HISTOGRAM_BOOLEAN("PrintPreview.OutOfProcessSubframe",
1635 frame->top()->isWebRemoteFrame());
1636
[email protected]b0553c7e2012-09-19 21:36:111637 FOR_EACH_OBSERVER(RenderViewObserver, observers_,
fsamuel72464894f2015-12-15 06:59:311638 PrintPage(frame, input_handler().handling_input_event()));
[email protected]48c9cf2d2009-09-16 16:47:521639}
1640
[email protected]310ebd6302011-10-10 19:06:281641bool RenderViewImpl::enumerateChosenDirectory(
[email protected]8a58c1c2011-04-19 18:40:121642 const WebString& path,
1643 WebFileChooserCompletion* chooser_completion) {
1644 int id = enumeration_completion_id_++;
1645 enumeration_completions_[id] = chooser_completion;
1646 return Send(new ViewHostMsg_EnumerateDirectory(
avia3dca182016-03-19 01:09:521647 GetRoutingID(), id, blink::WebStringToFilePath(path)));
[email protected]8a58c1c2011-04-19 18:40:121648}
1649
[email protected]7e9523b2014-03-25 03:02:421650void RenderViewImpl::FrameDidStartLoading(WebFrame* frame) {
[email protected]7e9523b2014-03-25 03:02:421651 DCHECK_GE(frames_in_progress_, 0);
1652 if (frames_in_progress_ == 0)
1653 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading());
1654 frames_in_progress_++;
[email protected]6dd5c322014-03-12 07:58:461655}
1656
[email protected]7e9523b2014-03-25 03:02:421657void RenderViewImpl::FrameDidStopLoading(WebFrame* frame) {
[email protected]eb473772014-04-11 20:54:331658 // TODO(japhet): This should be a DCHECK, but the pdf plugin sometimes
1659 // calls DidStopLoading() without a matching DidStartLoading().
1660 if (frames_in_progress_ == 0)
1661 return;
[email protected]7e9523b2014-03-25 03:02:421662 frames_in_progress_--;
[email protected]7e9523b2014-03-25 03:02:421663 if (frames_in_progress_ == 0) {
1664 DidStopLoadingIcons();
1665 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading());
1666 }
[email protected]48c9cf2d2009-09-16 16:47:521667}
1668
lfgcaab5142016-02-26 19:06:521669void RenderViewImpl::AttachWebFrameWidget(blink::WebFrameWidget* frame_widget) {
dcheng3ce04b62015-10-26 23:30:551670 // The previous WebFrameWidget must already be detached by CloseForFrame().
1671 DCHECK(!frame_widget_);
1672 frame_widget_ = frame_widget;
1673}
1674
tommycli8aad3ba2015-08-12 17:57:591675void RenderViewImpl::SetZoomLevel(double zoom_level) {
wjmaclean64951902016-04-29 20:59:121676 // If we change the zoom level for the view, make sure any subsequent subframe
1677 // loads reflect the current zoom level.
1678 page_zoom_level_ = zoom_level;
1679
tommycli8aad3ba2015-08-12 17:57:591680 webview()->setZoomLevel(zoom_level);
1681 FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnZoomLevelChanged());
1682}
1683
[email protected]550b0c92013-02-04 05:09:151684void RenderViewImpl::didCancelCompositionOnSelectionChange() {
avia3dca182016-03-19 01:09:521685 Send(new InputHostMsg_ImeCancelComposition(GetRoutingID()));
[email protected]550b0c92013-02-04 05:09:151686}
1687
habib.virji597255e2014-09-09 00:30:181688void RenderViewImpl::SetValidationMessageDirection(
1689 base::string16* wrapped_main_text,
1690 blink::WebTextDirection main_text_hint,
1691 base::string16* wrapped_sub_text,
1692 blink::WebTextDirection sub_text_hint) {
1693 if (main_text_hint == blink::WebTextDirectionLeftToRight) {
1694 *wrapped_main_text =
1695 base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_main_text);
1696 } else if (main_text_hint == blink::WebTextDirectionRightToLeft &&
1697 !base::i18n::IsRTL()) {
1698 base::i18n::WrapStringWithRTLFormatting(wrapped_main_text);
1699 }
1700
1701 if (!wrapped_sub_text->empty()) {
1702 if (sub_text_hint == blink::WebTextDirectionLeftToRight) {
1703 *wrapped_sub_text =
1704 base::i18n::GetDisplayStringInLTRDirectionality(*wrapped_sub_text);
1705 } else if (sub_text_hint == blink::WebTextDirectionRightToLeft) {
1706 base::i18n::WrapStringWithRTLFormatting(wrapped_sub_text);
1707 }
1708 }
1709}
1710
[email protected]edc3af82013-12-12 21:24:071711void RenderViewImpl::showValidationMessage(
bokan72a7e342015-12-03 15:46:281712 const blink::WebRect& anchor_in_viewport,
[email protected]edc3af82013-12-12 21:24:071713 const blink::WebString& main_text,
habib.virji597255e2014-09-09 00:30:181714 blink::WebTextDirection main_text_hint,
[email protected]edc3af82013-12-12 21:24:071715 const blink::WebString& sub_text,
habib.virji597255e2014-09-09 00:30:181716 blink::WebTextDirection sub_text_hint) {
[email protected]edc3af82013-12-12 21:24:071717 base::string16 wrapped_main_text = main_text;
1718 base::string16 wrapped_sub_text = sub_text;
habib.virji597255e2014-09-09 00:30:181719
1720 SetValidationMessageDirection(
1721 &wrapped_main_text, main_text_hint, &wrapped_sub_text, sub_text_hint);
1722
[email protected]edc3af82013-12-12 21:24:071723 Send(new ViewHostMsg_ShowValidationMessage(
avia3dca182016-03-19 01:09:521724 GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport),
[email protected]2d6836f42014-07-02 17:25:311725 wrapped_main_text, wrapped_sub_text));
[email protected]edc3af82013-12-12 21:24:071726}
1727
1728void RenderViewImpl::hideValidationMessage() {
avia3dca182016-03-19 01:09:521729 Send(new ViewHostMsg_HideValidationMessage(GetRoutingID()));
[email protected]edc3af82013-12-12 21:24:071730}
1731
1732void RenderViewImpl::moveValidationMessage(
bokan72a7e342015-12-03 15:46:281733 const blink::WebRect& anchor_in_viewport) {
[email protected]2d6836f42014-07-02 17:25:311734 Send(new ViewHostMsg_MoveValidationMessage(
avia3dca182016-03-19 01:09:521735 GetRoutingID(), AdjustValidationMessageAnchor(anchor_in_viewport)));
[email protected]edc3af82013-12-12 21:24:071736}
1737
[email protected]310ebd6302011-10-10 19:06:281738void RenderViewImpl::setStatusText(const WebString& text) {
[email protected]48c9cf2d2009-09-16 16:47:521739}
1740
[email protected]310ebd6302011-10-10 19:06:281741void RenderViewImpl::UpdateTargetURL(const GURL& url,
1742 const GURL& fallback_url) {
[email protected]aa6b90b32010-04-26 15:49:581743 GURL latest_url = url.is_empty() ? fallback_url : url;
[email protected]48c9cf2d2009-09-16 16:47:521744 if (latest_url == target_url_)
1745 return;
[email protected]163f8242009-10-30 20:19:551746
[email protected]48c9cf2d2009-09-16 16:47:521747 // Tell the browser to display a destination link.
1748 if (target_url_status_ == TARGET_INFLIGHT ||
1749 target_url_status_ == TARGET_PENDING) {
1750 // If we have a request in-flight, save the URL to be sent when we
1751 // receive an ACK to the in-flight request. We can happily overwrite
1752 // any existing pending sends.
1753 pending_target_url_ = latest_url;
1754 target_url_status_ = TARGET_PENDING;
1755 } else {
mnaganovbf087422015-12-16 05:10:031756 // URLs larger than |kMaxURLChars| cannot be sent through IPC -
[email protected]c85f0212011-11-04 16:54:411757 // see |ParamTraits<GURL>|.
markdittmer67b71ea2016-03-03 22:40:031758 if (latest_url.possibly_invalid_spec().size() > url::kMaxURLChars)
[email protected]c85f0212011-11-04 16:54:411759 latest_url = GURL();
avia3dca182016-03-19 01:09:521760 Send(new ViewHostMsg_UpdateTargetURL(GetRoutingID(), latest_url));
[email protected]48c9cf2d2009-09-16 16:47:521761 target_url_ = latest_url;
1762 target_url_status_ = TARGET_INFLIGHT;
1763 }
1764}
1765
[email protected]70221f02013-01-31 22:17:071766gfx::RectF RenderViewImpl::ClientRectToPhysicalWindowRect(
1767 const gfx::RectF& rect) const {
1768 gfx::RectF window_rect = rect;
1769 window_rect.Scale(device_scale_factor_ * webview()->pageScaleFactor());
1770 return window_rect;
1771}
1772
creis69b184a472015-11-26 05:29:511773void RenderViewImpl::StartNavStateSyncTimerIfNecessary(RenderFrameImpl* frame) {
1774 // In OOPIF modes, keep track of which frames have pending updates.
creis8eb8ef22015-11-04 22:51:381775 if (SiteIsolationPolicy::UseSubframeNavigationEntries())
creis69b184a472015-11-26 05:29:511776 frames_with_pending_state_.insert(frame->GetRoutingID());
creis8eb8ef22015-11-04 22:51:381777
[email protected]882daa92009-11-05 16:31:311778 int delay;
avif937e1d2014-11-02 18:13:071779 if (send_content_state_immediately_)
[email protected]882daa92009-11-05 16:31:311780 delay = 0;
1781 else if (is_hidden())
avif937e1d2014-11-02 18:13:071782 delay = kDelaySecondsForContentStateSyncHidden;
[email protected]882daa92009-11-05 16:31:311783 else
avif937e1d2014-11-02 18:13:071784 delay = kDelaySecondsForContentStateSync;
[email protected]882daa92009-11-05 16:31:311785
avif937e1d2014-11-02 18:13:071786 if (nav_state_sync_timer_.IsRunning()) {
[email protected]882daa92009-11-05 16:31:311787 // The timer is already running. If the delay of the timer maches the amount
1788 // we want to delay by, then return. Otherwise stop the timer so that it
1789 // gets started with the right delay.
avif937e1d2014-11-02 18:13:071790 if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay)
[email protected]882daa92009-11-05 16:31:311791 return;
avif937e1d2014-11-02 18:13:071792 nav_state_sync_timer_.Stop();
[email protected]882daa92009-11-05 16:31:311793 }
1794
creis69b184a472015-11-26 05:29:511795 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) {
1796 // In OOPIF modes, tell each frame with pending state to inform the browser.
1797 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this,
1798 &RenderViewImpl::SendFrameStateUpdates);
1799 } else {
1800 // By default, send an UpdateState for the current history item.
1801 nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this,
1802 &RenderViewImpl::SendUpdateState);
1803 }
[email protected]882daa92009-11-05 16:31:311804}
1805
[email protected]310ebd6302011-10-10 19:06:281806void RenderViewImpl::setMouseOverURL(const WebURL& url) {
[email protected]163f8242009-10-30 20:19:551807 mouse_over_url_ = GURL(url);
1808 UpdateTargetURL(mouse_over_url_, focus_url_);
1809}
1810
[email protected]310ebd6302011-10-10 19:06:281811void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) {
[email protected]163f8242009-10-30 20:19:551812 focus_url_ = GURL(url);
1813 UpdateTargetURL(focus_url_, mouse_over_url_);
1814}
1815
[email protected]35b2a972014-04-04 15:50:221816void RenderViewImpl::startDragging(WebLocalFrame* frame,
[email protected]0407e422012-05-18 19:51:251817 const WebDragData& data,
[email protected]310ebd6302011-10-10 19:06:281818 WebDragOperationsMask mask,
1819 const WebImage& image,
[email protected]ceb36f7d2012-10-31 18:33:241820 const WebPoint& webImageOffset) {
oshimab3313232016-01-28 01:13:221821 blink::WebRect offset_in_window(webImageOffset.x, webImageOffset.y, 0, 0);
danakjdea2efb2016-03-10 19:13:171822 ConvertViewportToWindowViaWidget(&offset_in_window);
[email protected]dc293a72013-07-01 11:11:221823 DropData drop_data(DropDataBuilder::Build(data));
[email protected]b67151d2012-05-25 23:23:241824 drop_data.referrer_policy = frame->document().referrerPolicy();
oshimab3313232016-01-28 01:13:221825 gfx::Vector2d imageOffset(offset_in_window.x, offset_in_window.y);
avia3dca182016-03-19 01:09:521826 Send(new DragHostMsg_StartDragging(GetRoutingID(), drop_data, mask,
fsamuele8326c742016-01-12 00:49:391827 image.getSkBitmap(), imageOffset,
[email protected]41d86852012-11-07 12:23:241828 possible_drag_event_info_));
[email protected]48c9cf2d2009-09-16 16:47:521829}
1830
[email protected]310ebd6302011-10-10 19:06:281831bool RenderViewImpl::acceptsLoadDrops() {
[email protected]28b92df2009-09-25 17:35:451832 return renderer_preferences_.can_accept_load_drops;
1833}
1834
[email protected]310ebd6302011-10-10 19:06:281835void RenderViewImpl::focusNext() {
avia3dca182016-03-19 01:09:521836 Send(new ViewHostMsg_TakeFocus(GetRoutingID(), false));
[email protected]48c9cf2d2009-09-16 16:47:521837}
1838
[email protected]310ebd6302011-10-10 19:06:281839void RenderViewImpl::focusPrevious() {
avia3dca182016-03-19 01:09:521840 Send(new ViewHostMsg_TakeFocus(GetRoutingID(), true));
[email protected]48c9cf2d2009-09-16 16:47:521841}
1842
esprehn3d4471a2015-09-17 07:13:201843// TODO(esprehn): Blink only ever passes Elements, this should take WebElement.
estade31c54342015-01-23 03:34:361844void RenderViewImpl::focusedNodeChanged(const WebNode& fromNode,
1845 const WebNode& toNode) {
[email protected]1875bc02014-03-14 06:33:591846 has_scrolled_focused_editable_node_into_rect_ = false;
1847
jennyz399d6e62014-12-16 01:40:051848 gfx::Rect node_bounds;
esprehn3d4471a2015-09-17 07:13:201849 bool is_editable = false;
estade31c54342015-01-23 03:34:361850 if (!toNode.isNull() && toNode.isElementNode()) {
esprehn3d4471a2015-09-17 07:13:201851 WebElement element = const_cast<WebNode&>(toNode).to<WebElement>();
oshimae2b3b402015-12-04 04:27:241852 blink::WebRect rect = element.boundsInViewport();
danakjdea2efb2016-03-10 19:13:171853 ConvertViewportToWindowViaWidget(&rect);
oshimae2b3b402015-12-04 04:27:241854 node_bounds = gfx::Rect(rect);
esprehn3d4471a2015-09-17 07:13:201855 is_editable = element.isEditable();
jennyz399d6e62014-12-16 01:40:051856 }
avia3dca182016-03-19 01:09:521857 Send(new ViewHostMsg_FocusedNodeChanged(GetRoutingID(), is_editable,
jennyz399d6e62014-12-16 01:40:051858 node_bounds));
[email protected]a4b103b2010-10-05 18:46:071859
estade31c54342015-01-23 03:34:361860 // TODO(estade): remove.
1861 FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(toNode));
[email protected]95640212014-07-26 18:14:301862
estade31c54342015-01-23 03:34:361863 RenderFrameImpl* previous_frame = nullptr;
1864 if (!fromNode.isNull())
1865 previous_frame = RenderFrameImpl::FromWebFrame(fromNode.document().frame());
1866 RenderFrameImpl* new_frame = nullptr;
1867 if (!toNode.isNull())
1868 new_frame = RenderFrameImpl::FromWebFrame(toNode.document().frame());
1869
1870 if (previous_frame && previous_frame != new_frame)
1871 previous_frame->FocusedNodeChanged(WebNode());
1872 if (new_frame)
1873 new_frame->FocusedNodeChanged(toNode);
1874
1875 // TODO(dmazzoni): remove once there's a separate a11y tree per frame.
naskoe8d115752015-08-07 00:43:131876 if (main_render_frame_)
1877 main_render_frame_->FocusedNodeChangedForAccessibility(toNode);
[email protected]08e9e132010-06-01 16:58:491878}
1879
[email protected]169d4282011-11-30 19:33:591880void RenderViewImpl::didUpdateLayout() {
[email protected]d01b2a62013-09-18 23:21:331881 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidUpdateLayout());
1882
[email protected]169d4282011-11-30 19:33:591883 // We don't always want to set up a timer, only if we've been put in that
1884 // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
1885 // message.
1886 if (!send_preferred_size_changes_ || !webview())
1887 return;
1888
1889 if (check_preferred_size_timer_.IsRunning())
1890 return;
1891 check_preferred_size_timer_.Start(FROM_HERE,
1892 TimeDelta::FromMilliseconds(0), this,
1893 &RenderViewImpl::CheckPreferredSize);
1894}
1895
[email protected]310ebd6302011-10-10 19:06:281896void RenderViewImpl::navigateBackForwardSoon(int offset) {
avia3dca182016-03-19 01:09:521897 Send(new ViewHostMsg_GoToEntryAtOffset(GetRoutingID(), offset));
[email protected]48c9cf2d2009-09-16 16:47:521898}
1899
[email protected]310ebd6302011-10-10 19:06:281900int RenderViewImpl::historyBackListCount() {
[email protected]3cc72b12010-03-18 23:03:001901 return history_list_offset_ < 0 ? 0 : history_list_offset_;
[email protected]48c9cf2d2009-09-16 16:47:521902}
1903
[email protected]310ebd6302011-10-10 19:06:281904int RenderViewImpl::historyForwardListCount() {
[email protected]3cc72b12010-03-18 23:03:001905 return history_list_length_ - historyBackListCount() - 1;
[email protected]48c9cf2d2009-09-16 16:47:521906}
1907
[email protected]180ef242013-11-07 06:50:461908// blink::WebWidgetClient ----------------------------------------------------
[email protected]79dbc662009-09-04 05:42:511909
[email protected]310ebd6302011-10-10 19:06:281910void RenderViewImpl::didFocus() {
[email protected]ea42e7782010-08-23 23:58:121911 // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed
1912 // we won't have to test for user gesture anymore and we can
1913 // move that code back to render_widget.cc
[email protected]af15bf22013-03-08 01:18:171914 if (WebUserGestureIndicator::isProcessingUserGesture() &&
[email protected]70dee7e2013-05-29 18:28:301915 !RenderThreadImpl::current()->layout_test_mode()) {
avia3dca182016-03-19 01:09:521916 Send(new ViewHostMsg_Focus(GetRoutingID()));
[email protected]ea42e7782010-08-23 23:58:121917 }
1918}
1919
initial.commit09911bf2008-07-26 23:55:291920// We are supposed to get a single call to Show for a newly created RenderView
[email protected]310ebd6302011-10-10 19:06:281921// that was created via RenderViewImpl::CreateWebView. So, we wait until this
initial.commit09911bf2008-07-26 23:55:291922// point to dispatch the ShowView message.
1923//
1924// This method provides us with the information about how to display the newly
[email protected]5f9de5882011-09-30 23:36:281925// created RenderView (i.e., as a blocked popup or as a new tab).
initial.commit09911bf2008-07-26 23:55:291926//
[email protected]310ebd6302011-10-10 19:06:281927void RenderViewImpl::show(WebNavigationPolicy policy) {
[email protected]b2142e962012-10-30 13:59:251928 if (did_show_) {
[email protected]b2142e962012-10-30 13:59:251929 // When supports_multiple_windows is disabled, popups are reusing
1930 // the same view. In some scenarios, this makes WebKit to call show() twice.
[email protected]c9edabd2013-05-23 13:56:241931 if (webkit_preferences_.supports_multiple_windows)
1932 NOTREACHED() << "received extraneous Show call";
initial.commit09911bf2008-07-26 23:55:291933 return;
[email protected]b2142e962012-10-30 13:59:251934 }
initial.commit09911bf2008-07-26 23:55:291935 did_show_ = true;
1936
[email protected]b2142e962012-10-30 13:59:251937 DCHECK(opener_id_ != MSG_ROUTING_NONE);
1938
bokanc007c3a2015-02-03 07:15:561939 // NOTE: initial_rect_ may still have its default values at this point, but
initial.commit09911bf2008-07-26 23:55:291940 // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the
1941 // browser process will impose a default position otherwise.
avia3dca182016-03-19 01:09:521942 Send(new ViewHostMsg_ShowView(opener_id_, GetRoutingID(),
fsamuele8326c742016-01-12 00:49:391943 NavigationPolicyToDisposition(policy),
1944 initial_rect_, opened_by_user_gesture_));
bokanc007c3a2015-02-03 07:15:561945 SetPendingWindowRect(initial_rect_);
initial.commit09911bf2008-07-26 23:55:291946}
1947
miletuse8d28ba2015-06-19 04:52:041948void RenderViewImpl::onMouseDown(const WebNode& mouse_down_node) {
1949 FOR_EACH_OBSERVER(
1950 RenderViewObserver, observers_, OnMouseDown(mouse_down_node));
1951}
1952
[email protected]c68c3e4e2013-01-24 00:36:561953void RenderViewImpl::didHandleGestureEvent(
1954 const WebGestureEvent& event,
1955 bool event_cancelled) {
1956 RenderWidget::didHandleGestureEvent(event, event_cancelled);
[email protected]bb37b652013-11-27 23:47:111957
[email protected]91dcc6d32014-07-30 00:01:331958 if (!event_cancelled) {
1959 FOR_EACH_OBSERVER(
1960 RenderViewObserver, observers_, DidHandleGestureEvent(event));
1961 }
1962
jdduke45762d22014-10-07 04:19:081963 // TODO(ananta): Piggyback off existing IPCs to communicate this information,
1964 // crbug/420130.
1965#if defined(OS_WIN)
[email protected]bb37b652013-11-27 23:47:111966 if (event.type != blink::WebGestureEvent::GestureTap)
1967 return;
1968
[email protected]91dcc6d32014-07-30 00:01:331969 // TODO(estade): hit test the event against focused node to make sure
1970 // the tap actually hit the focused node.
jdduke3bf083fe2015-09-29 23:40:531971 blink::WebTextInputType text_input_type = GetWebView()->textInputType();
[email protected]bb37b652013-11-27 23:47:111972
1973 Send(new ViewHostMsg_FocusedNodeTouched(
avia3dca182016-03-19 01:09:521974 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone));
jdduke45762d22014-10-07 04:19:081975#endif
[email protected]c68c3e4e2013-01-24 00:36:561976}
1977
[email protected]6e89eb72013-07-23 13:28:221978void RenderViewImpl::initializeLayerTreeView() {
1979 RenderWidget::initializeLayerTreeView();
1980 RenderWidgetCompositor* rwc = compositor();
[email protected]9f7638f42014-05-30 01:51:161981 if (!rwc)
[email protected]6e89eb72013-07-23 13:28:221982 return;
[email protected]9f7638f42014-05-30 01:51:161983
ccameron1f89c002014-10-21 06:19:051984 bool use_threaded_event_handling = true;
jame1f453c2016-03-21 15:51:341985#if defined(OS_MACOSX)
ccamerona7644752014-12-30 01:16:311986 // Disable threaded event handling if content is not handling the elastic
1987 // overscroll effect. This includes the cases where the elastic overscroll
1988 // effect is being handled by Blink (because of command line flags) and older
1989 // operating system versions which do not have an elastic overscroll effect
1990 // (SnowLeopard, which has Aqua scrollbars which need synchronous updates).
1991 use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled();
[email protected]9f7638f42014-05-30 01:51:161992#endif
changwand659e202016-06-13 02:39:121993 if (!use_threaded_event_handling)
1994 return;
1995
1996 RenderThreadImpl* render_thread = RenderThreadImpl::current();
1997 // render_thread may be NULL in tests.
1998 InputHandlerManager* input_handler_manager =
1999 render_thread ? render_thread->input_handler_manager() : NULL;
2000 if (input_handler_manager) {
2001 input_handler_manager->AddInputHandler(
2002 GetRoutingID(), rwc->GetInputHandler(), AsWeakPtr(),
2003 webkit_preferences_.enable_scroll_animator);
2004 has_added_input_handler_ = true;
ccameron1f89c002014-10-21 06:19:052005 }
[email protected]6e89eb72013-07-23 13:28:222006}
2007
lfg2230bce2016-04-28 18:37:042008void RenderViewImpl::closeWidgetSoon() {
2009 RenderWidget::closeWidgetSoon();
2010}
2011
2012void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) {
2013 RenderWidget::convertViewportToWindow(rect);
2014}
2015
2016void RenderViewImpl::convertWindowToViewport(blink::WebFloatRect* rect) {
2017 RenderWidget::convertWindowToViewport(rect);
2018}
2019
2020void RenderViewImpl::didAutoResize(const blink::WebSize& newSize) {
lfgb00fcad2016-07-14 14:16:332021 RenderWidget::DidAutoResize(newSize);
lfg2230bce2016-04-28 18:37:042022}
2023
lfg2230bce2016-04-28 18:37:042024void RenderViewImpl::didOverscroll(
2025 const blink::WebFloatSize& overscrollDelta,
2026 const blink::WebFloatSize& accumulatedOverscroll,
2027 const blink::WebFloatPoint& positionInViewport,
2028 const blink::WebFloatSize& velocityInViewport) {
2029 RenderWidget::didOverscroll(overscrollDelta, accumulatedOverscroll,
2030 positionInViewport, velocityInViewport);
2031}
2032
lfg2230bce2016-04-28 18:37:042033void RenderViewImpl::hasTouchEventHandlers(bool has_handlers) {
2034 RenderWidget::hasTouchEventHandlers(has_handlers);
2035}
2036
lfg2230bce2016-04-28 18:37:042037void RenderViewImpl::resetInputMethod() {
2038 RenderWidget::resetInputMethod();
2039}
2040
2041blink::WebRect RenderViewImpl::rootWindowRect() {
bokan6b08cd22016-10-05 00:55:212042 return RenderWidget::windowRect();
lfg2230bce2016-04-28 18:37:042043}
2044
lfg2230bce2016-04-28 18:37:042045blink::WebScreenInfo RenderViewImpl::screenInfo() {
2046 return RenderWidget::screenInfo();
2047}
2048
2049void RenderViewImpl::setToolTipText(const blink::WebString& text,
2050 blink::WebTextDirection hint) {
2051 RenderWidget::setToolTipText(text, hint);
2052}
2053
2054void RenderViewImpl::setTouchAction(blink::WebTouchAction touchAction) {
2055 RenderWidget::setTouchAction(touchAction);
2056}
2057
lfg2230bce2016-04-28 18:37:042058void RenderViewImpl::showImeIfNeeded() {
2059 RenderWidget::showImeIfNeeded();
2060}
2061
2062void RenderViewImpl::showUnhandledTapUIIfNeeded(
2063 const blink::WebPoint& tappedPosition,
2064 const blink::WebNode& tappedNode,
2065 bool pageChanged) {
2066 RenderWidget::showUnhandledTapUIIfNeeded(tappedPosition, tappedNode,
2067 pageChanged);
2068}
2069
lfg0f440622016-07-20 04:27:142070blink::WebWidgetClient* RenderViewImpl::widgetClient() {
2071 return static_cast<RenderWidget*>(this);
2072}
2073
[email protected]180ef242013-11-07 06:50:462074// blink::WebFrameClient -----------------------------------------------------
[email protected]3d9689372009-09-10 04:29:172075
[email protected]5e92282f2012-08-17 08:11:572076void RenderViewImpl::Repaint(const gfx::Size& size) {
[email protected]3d9ec5052013-01-02 22:05:252077 OnRepaint(size);
[email protected]5e92282f2012-08-17 08:11:572078}
2079
[email protected]b2324b092012-11-01 10:34:112080void RenderViewImpl::SetEditCommandForNextKeyEvent(const std::string& name,
2081 const std::string& value) {
alexmos56567492016-09-13 00:52:462082 GetWidget()->SetEditCommandForNextKeyEvent(name, value);
[email protected]b2324b092012-11-01 10:34:112083}
2084
2085void RenderViewImpl::ClearEditCommands() {
alexmos56567492016-09-13 00:52:462086 GetWidget()->ClearEditCommands();
[email protected]b2324b092012-11-01 10:34:112087}
2088
[email protected]b38806a2013-10-04 16:01:382089const std::string& RenderViewImpl::GetAcceptLanguages() const {
2090 return renderer_preferences_.accept_languages;
2091}
2092
danakjdea2efb2016-03-10 19:13:172093void RenderViewImpl::ConvertViewportToWindowViaWidget(blink::WebRect* rect) {
2094 convertViewportToWindow(rect);
oshimae2b3b402015-12-04 04:27:242095}
2096
huangs2a342352015-12-15 16:59:242097gfx::RectF RenderViewImpl::ElementBoundsInWindow(
2098 const blink::WebElement& element) {
2099 blink::WebRect bounding_box_in_window = element.boundsInViewport();
danakjdea2efb2016-03-10 19:13:172100 ConvertViewportToWindowViaWidget(&bounding_box_in_window);
huangs2a342352015-12-15 16:59:242101 return gfx::RectF(bounding_box_in_window);
2102}
2103
changwand659e202016-06-13 02:39:122104bool RenderViewImpl::HasAddedInputHandler() const {
2105 return has_added_input_handler_;
2106}
2107
oshima4300f52e92016-02-18 21:51:042108gfx::Point RenderViewImpl::ConvertWindowPointToViewport(
2109 const gfx::Point& point) {
2110 blink::WebFloatRect point_in_viewport(point.x(), point.y(), 0, 0);
2111 convertWindowToViewport(&point_in_viewport);
2112 return gfx::Point(point_in_viewport.x, point_in_viewport.y);
2113}
2114
[email protected]35b2a972014-04-04 15:50:222115void RenderViewImpl::didChangeIcon(WebLocalFrame* frame,
[email protected]41225fe2013-03-29 05:32:022116 WebIconURL::Type icon_type) {
2117 if (frame->parent())
2118 return;
2119
[email protected]41225fe2013-03-29 05:32:022120 WebVector<WebIconURL> icon_urls = frame->iconURLs(icon_type);
2121 std::vector<FaviconURL> urls;
2122 for (size_t i = 0; i < icon_urls.size(); i++) {
[email protected]2bd262b2014-04-16 05:31:232123 std::vector<gfx::Size> sizes;
[email protected]f34ac132014-03-20 23:02:052124 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
2125 urls.push_back(FaviconURL(
2126 icon_urls[i].iconURL(), ToFaviconType(icon_urls[i].iconType()), sizes));
[email protected]41225fe2013-03-29 05:32:022127 }
2128 SendUpdateFaviconURL(urls);
[email protected]5019ef12010-04-27 17:26:582129}
2130
[email protected]310ebd6302011-10-10 19:06:282131void RenderViewImpl::CheckPreferredSize() {
[email protected]d812fd12011-05-27 23:05:072132 // We don't always want to send the change messages over IPC, only if we've
2133 // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode|
2134 // message.
2135 if (!send_preferred_size_changes_ || !webview())
2136 return;
2137
[email protected]e76b7972013-06-06 02:58:482138 gfx::Size size = webview()->contentsPreferredMinimumSize();
[email protected]705243f2010-05-05 19:58:072139 if (size == preferred_size_)
2140 return;
[email protected]c27324b2009-11-19 22:44:292141
[email protected]705243f2010-05-05 19:58:072142 preferred_size_ = size;
avia3dca182016-03-19 01:09:522143 Send(new ViewHostMsg_DidContentsPreferredSizeChange(GetRoutingID(),
[email protected]705243f2010-05-05 19:58:072144 preferred_size_));
[email protected]3d9689372009-09-10 04:29:172145}
2146
[email protected]180ef242013-11-07 06:50:462147blink::WebString RenderViewImpl::acceptLanguages() {
[email protected]9982c802013-06-12 15:22:062148 return WebString::fromUTF8(renderer_preferences_.accept_languages);
2149}
2150
[email protected]e9ff79c2012-10-19 21:31:262151// RenderView implementation ---------------------------------------------------
[email protected]a2ef54c2011-10-10 16:20:312152
[email protected]310ebd6302011-10-10 19:06:282153bool RenderViewImpl::Send(IPC::Message* message) {
[email protected]a2ef54c2011-10-10 16:20:312154 return RenderWidget::Send(message);
2155}
2156
avi8a45c1092016-03-01 16:12:342157RenderWidget* RenderViewImpl::GetWidget() const {
2158 return const_cast<RenderWidget*>(static_cast<const RenderWidget*>(this));
2159}
2160
mostynbc33353232014-09-12 09:38:312161RenderFrameImpl* RenderViewImpl::GetMainRenderFrame() {
nasko77de2312015-05-12 03:09:162162 return main_render_frame_;
[email protected]b849847b2013-12-10 21:57:582163}
2164
[email protected]82114f52012-03-20 22:53:412165int RenderViewImpl::GetRoutingID() const {
fsamuele8326c742016-01-12 00:49:392166 return routing_id();
[email protected]a2ef54c2011-10-10 16:20:312167}
2168
[email protected]82114f52012-03-20 22:53:412169gfx::Size RenderViewImpl::GetSize() const {
[email protected]a2ef54c2011-10-10 16:20:312170 return size();
2171}
2172
oshima129b75e2016-01-14 09:15:142173float RenderViewImpl::GetDeviceScaleFactor() const {
2174 return device_scale_factor_;
2175}
2176
[email protected]82114f52012-03-20 22:53:412177WebPreferences& RenderViewImpl::GetWebkitPreferences() {
[email protected]a2ef54c2011-10-10 16:20:312178 return webkit_preferences_;
2179}
2180
[email protected]324825d2012-11-30 12:37:152181void RenderViewImpl::SetWebkitPreferences(const WebPreferences& preferences) {
2182 OnUpdateWebPreferences(preferences);
2183}
2184
[email protected]180ef242013-11-07 06:50:462185blink::WebView* RenderViewImpl::GetWebView() {
[email protected]a2ef54c2011-10-10 16:20:312186 return webview();
2187}
2188
lfgcaab5142016-02-26 19:06:522189blink::WebFrameWidget* RenderViewImpl::GetWebFrameWidget() {
2190 return frame_widget_;
2191}
2192
[email protected]310ebd6302011-10-10 19:06:282193bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const {
[email protected]a2ef54c2011-10-10 16:20:312194 return (!send_preferred_size_changes_ ||
2195 (disable_scrollbars_size_limit_.width() <= width ||
2196 disable_scrollbars_size_limit_.height() <= height));
2197}
2198
[email protected]82114f52012-03-20 22:53:412199int RenderViewImpl::GetEnabledBindings() const {
[email protected]a2ef54c2011-10-10 16:20:312200 return enabled_bindings_;
2201}
2202
avif937e1d2014-11-02 18:13:072203bool RenderViewImpl::GetContentStateImmediately() const {
2204 return send_content_state_immediately_;
[email protected]a2ef54c2011-10-10 16:20:312205}
2206
mcnee432e47d2015-11-09 19:37:462207void RenderViewImpl::OnSetPageScale(float page_scale_factor) {
ccameronb7c1d6c2015-03-09 17:08:242208 if (!webview())
2209 return;
mcnee432e47d2015-11-09 19:37:462210 webview()->setPageScaleFactor(page_scale_factor);
ccameronb7c1d6c2015-03-09 17:08:242211}
2212
[email protected]e9ff79c2012-10-19 21:31:262213void RenderViewImpl::OnZoom(PageZoom zoom) {
[email protected]40bd6582009-12-04 23:49:512214 if (!webview()) // Not sure if this can happen, but no harm in being safe.
2215 return;
2216
[email protected]258d31122010-05-09 10:59:412217 webview()->hidePopups();
[email protected]854ab5462011-11-22 20:48:102218
[email protected]b75b8292010-10-01 07:28:252219 double old_zoom_level = webview()->zoomLevel();
2220 double zoom_level;
[email protected]e9ff79c2012-10-19 21:31:262221 if (zoom == PAGE_ZOOM_RESET) {
[email protected]b75b8292010-10-01 07:28:252222 zoom_level = 0;
2223 } else if (static_cast<int>(old_zoom_level) == old_zoom_level) {
2224 // Previous zoom level is a whole number, so just increment/decrement.
[email protected]54087fe2011-10-28 22:02:482225 zoom_level = old_zoom_level + zoom;
[email protected]b75b8292010-10-01 07:28:252226 } else {
2227 // Either the user hit the zoom factor limit and thus the zoom level is now
2228 // not a whole number, or a plugin changed it to a custom value. We want
2229 // to go to the next whole number so that the user can always get back to
2230 // 100% with the keyboard/menu.
[email protected]54087fe2011-10-28 22:02:482231 if ((old_zoom_level > 1 && zoom > 0) ||
2232 (old_zoom_level < 1 && zoom < 0)) {
2233 zoom_level = static_cast<int>(old_zoom_level + zoom);
[email protected]b75b8292010-10-01 07:28:252234 } else {
2235 // We're going towards 100%, so first go to the next whole number.
2236 zoom_level = static_cast<int>(old_zoom_level);
2237 }
2238 }
tommycli8aad3ba2015-08-12 17:57:592239 SetZoomLevel(zoom_level);
[email protected]47578fa02011-11-02 19:34:412240 zoomLevelChanged();
2241}
2242
scottmg3ea15712016-08-09 16:46:412243void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url,
2244 double zoom_level) {
2245 // TODO(wjmaclean): We should see if this restriction is really necessary,
2246 // since it isn't enforced in other parts of the page zoom system (e.g.
2247 // when a users changes the zoom of a currently displayed page). Android
2248 // has no UI for this, so in theory the following code would normally just use
2249 // the default zoom anyways.
2250#if !defined(OS_ANDROID)
2251 // On Android, page zoom isn't used, and in case of WebView, text zoom is used
2252 // for legacy WebView text scaling emulation. Thus, the code that resets
2253 // the zoom level from this map will be effectively resetting text zoom level.
2254 host_zoom_levels_[url] = zoom_level;
2255#endif
2256}
2257
wjmaclean64951902016-04-29 20:59:122258void RenderViewImpl::OnSetZoomLevel(
2259 PageMsg_SetZoomLevel_Command command,
2260 double zoom_level) {
2261 switch (command) {
2262 case PageMsg_SetZoomLevel_Command::CLEAR_TEMPORARY:
2263 uses_temporary_zoom_level_ = false;
2264 break;
2265 case PageMsg_SetZoomLevel_Command::SET_TEMPORARY:
2266 uses_temporary_zoom_level_ = true;
2267 break;
2268 case PageMsg_SetZoomLevel_Command::USE_CURRENT_TEMPORARY_MODE:
2269 // Don't override a temporary zoom level without an explicit SET.
2270 if (uses_temporary_zoom_level_)
2271 return;
2272 break;
2273 default:
2274 NOTIMPLEMENTED();
2275 }
[email protected]d42bf472014-06-14 01:49:382276 webview()->hidePopups();
wjmaclean64951902016-04-29 20:59:122277 SetZoomLevel(zoom_level);
[email protected]d42bf472014-06-14 01:49:382278}
2279
[email protected]310ebd6302011-10-10 19:06:282280void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) {
[email protected]940ed1d2012-11-27 21:03:212281 if ((enabled_bindings_flags & BINDINGS_POLICY_WEB_UI) &&
2282 !(enabled_bindings_ & BINDINGS_POLICY_WEB_UI)) {
[email protected]69a0a132014-03-26 16:45:022283 // WebUIExtensionData deletes itself when we're destroyed.
[email protected]940ed1d2012-11-27 21:03:212284 new WebUIExtensionData(this);
2285 }
2286
[email protected]81e63782009-02-27 19:35:092287 enabled_bindings_ |= enabled_bindings_flags;
[email protected]744c2a22012-03-15 18:42:042288
2289 // Keep track of the total bindings accumulated in this process.
2290 RenderProcess::current()->AddBindings(enabled_bindings_flags);
sammce2f99982016-03-14 22:38:122291
2292 if (main_render_frame_)
2293 main_render_frame_->MaybeEnableMojoBindings();
initial.commit09911bf2008-07-26 23:55:292294}
2295
hush8915b502016-06-15 19:32:232296void RenderViewImpl::OnDragTargetDragEnter(
2297 const std::vector<DropData::Metadata>& drop_meta_data,
2298 const gfx::Point& client_point,
2299 const gfx::Point& screen_point,
2300 WebDragOperationsMask ops,
2301 int key_modifiers) {
[email protected]59f4f2fa2011-03-23 01:00:552302 WebDragOperation operation = webview()->dragTargetDragEnter(
hush8915b502016-06-15 19:32:232303 DropMetaDataToWebDragData(drop_meta_data), client_point, screen_point,
2304 ops, key_modifiers);
[email protected]59f4f2fa2011-03-23 01:00:552305
avia3dca182016-03-19 01:09:522306 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
[email protected]59f4f2fa2011-03-23 01:00:552307}
2308
[email protected]310ebd6302011-10-10 19:06:282309void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point,
2310 const gfx::Point& screen_point,
[email protected]1f2230b2012-05-17 23:43:422311 WebDragOperationsMask ops,
2312 int key_modifiers) {
[email protected]59f4f2fa2011-03-23 01:00:552313 WebDragOperation operation = webview()->dragTargetDragOver(
oshima4300f52e92016-02-18 21:51:042314 ConvertWindowPointToViewport(client_point),
[email protected]59f4f2fa2011-03-23 01:00:552315 screen_point,
[email protected]1f2230b2012-05-17 23:43:422316 ops,
2317 key_modifiers);
[email protected]59f4f2fa2011-03-23 01:00:552318
avia3dca182016-03-19 01:09:522319 Send(new DragHostMsg_UpdateDragCursor(GetRoutingID(), operation));
[email protected]59f4f2fa2011-03-23 01:00:552320}
2321
[email protected]310ebd6302011-10-10 19:06:282322void RenderViewImpl::OnDragTargetDragLeave() {
[email protected]59f4f2fa2011-03-23 01:00:552323 webview()->dragTargetDragLeave();
2324}
2325
hush8915b502016-06-15 19:32:232326void RenderViewImpl::OnDragTargetDrop(const DropData& drop_data,
2327 const gfx::Point& client_point,
[email protected]1f2230b2012-05-17 23:43:422328 const gfx::Point& screen_point,
2329 int key_modifiers) {
bsep9d8c8532016-09-27 18:19:232330 webview()->dragTargetDrop(DropDataToWebDragData(drop_data),
2331 ConvertWindowPointToViewport(client_point),
hush8915b502016-06-15 19:32:232332 screen_point, key_modifiers);
[email protected]59f4f2fa2011-03-23 01:00:552333}
2334
[email protected]7a6d773f2014-04-04 01:25:092335void RenderViewImpl::OnDragSourceEnded(const gfx::Point& client_point,
2336 const gfx::Point& screen_point,
2337 WebDragOperation op) {
oshima4300f52e92016-02-18 21:51:042338 webview()->dragSourceEndedAt(
2339 ConvertWindowPointToViewport(client_point), screen_point, op);
initial.commit09911bf2008-07-26 23:55:292340}
2341
[email protected]310ebd6302011-10-10 19:06:282342void RenderViewImpl::OnDragSourceSystemDragEnded() {
[email protected]26aa0482009-09-30 16:55:272343 webview()->dragSourceSystemDragEnded();
initial.commit09911bf2008-07-26 23:55:292344}
2345
[email protected]310ebd6302011-10-10 19:06:282346void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) {
[email protected]2fab253a2009-08-17 23:00:592347 webkit_preferences_ = prefs;
sataya.mf405d0e2015-07-07 16:51:112348 ApplyWebPreferencesInternal(webkit_preferences_, webview(), compositor_deps_);
initial.commit09911bf2008-07-26 23:55:292349}
2350
[email protected]310ebd6302011-10-10 19:06:282351void RenderViewImpl::OnEnumerateDirectoryResponse(
[email protected]600ea402011-04-12 00:01:512352 int id,
[email protected]c42de732013-02-16 06:26:312353 const std::vector<base::FilePath>& paths) {
[email protected]600ea402011-04-12 00:01:512354 if (!enumeration_completions_[id])
2355 return;
2356
2357 WebVector<WebString> ws_file_names(paths.size());
2358 for (size_t i = 0; i < paths.size(); ++i)
[email protected]728c2ee2013-06-25 04:01:072359 ws_file_names[i] = paths[i].AsUTF16Unsafe();
[email protected]600ea402011-04-12 00:01:512360
2361 enumeration_completions_[id]->didChooseFile(ws_file_names);
2362 enumeration_completions_.erase(id);
2363}
2364
[email protected]244ac1892011-12-02 17:04:472365void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size,
2366 const gfx::Size& max_size) {
2367 DCHECK(disable_scrollbars_size_limit_.IsEmpty());
2368 if (!webview())
2369 return;
oshima33ec97cd2015-12-14 19:40:242370
[email protected]97e1bf72013-03-06 14:06:052371 auto_resize_mode_ = true;
oshima33ec97cd2015-12-14 19:40:242372 if (IsUseZoomForDSFEnabled()) {
2373 webview()->enableAutoResizeMode(
2374 gfx::ScaleToCeiledSize(min_size, device_scale_factor_),
2375 gfx::ScaleToCeiledSize(max_size, device_scale_factor_));
2376 } else {
2377 webview()->enableAutoResizeMode(min_size, max_size);
2378 }
[email protected]61e2b3cc2012-03-02 16:13:342379}
2380
2381void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) {
2382 DCHECK(disable_scrollbars_size_limit_.IsEmpty());
2383 if (!webview())
2384 return;
[email protected]97e1bf72013-03-06 14:06:052385 auto_resize_mode_ = false;
[email protected]61e2b3cc2012-03-02 16:13:342386 webview()->disableAutoResizeMode();
2387
[email protected]eac2b362013-05-22 07:01:452388 if (!new_size.IsEmpty()) {
mfomitchev2600fd7c2016-02-17 20:53:392389 ResizeParams resize_params;
jbroman5ff10302016-07-22 03:36:262390 resize_params.screen_info = screen_info_;
mfomitchev2600fd7c2016-02-17 20:53:392391 resize_params.new_size = new_size;
2392 resize_params.physical_backing_size = physical_backing_size_;
2393 resize_params.top_controls_shrink_blink_size =
2394 top_controls_shrink_blink_size_;
2395 resize_params.top_controls_height = top_controls_height_;
2396 resize_params.visible_viewport_size = visible_viewport_size_;
mfomitchev2600fd7c2016-02-17 20:53:392397 resize_params.is_fullscreen_granted = is_fullscreen_granted();
2398 resize_params.display_mode = display_mode_;
2399 resize_params.needs_resize_ack = false;
2400 Resize(resize_params);
[email protected]eac2b362013-05-22 07:01:452401 }
[email protected]244ac1892011-12-02 17:04:472402}
2403
[email protected]2bf834f2011-11-17 20:02:212404void RenderViewImpl::OnEnablePreferredSizeChangedMode() {
[email protected]9fb325e2010-05-06 18:23:242405 if (send_preferred_size_changes_)
2406 return;
[email protected]9fb325e2010-05-06 18:23:242407 send_preferred_size_changes_ = true;
[email protected]770dd8b2010-05-24 18:11:392408
[email protected]d812fd12011-05-27 23:05:072409 // Start off with an initial preferred size notification (in case
2410 // |didUpdateLayout| was already called).
[email protected]169d4282011-11-30 19:33:592411 didUpdateLayout();
[email protected]0666aef2009-05-13 19:48:082412}
2413
[email protected]310ebd6302011-10-10 19:06:282414void RenderViewImpl::OnDisableScrollbarsForSmallWindows(
[email protected]cda45c02010-02-25 19:28:102415 const gfx::Size& disable_scrollbar_size_limit) {
2416 disable_scrollbars_size_limit_ = disable_scrollbar_size_limit;
2417}
2418
[email protected]310ebd6302011-10-10 19:06:282419void RenderViewImpl::OnSetRendererPrefs(
[email protected]e9ff79c2012-10-19 21:31:262420 const RendererPreferences& renderer_prefs) {
[email protected]ebd5ea52014-05-28 14:51:152421 std::string old_accept_languages = renderer_preferences_.accept_languages;
2422
[email protected]80d96fa2009-06-10 22:34:512423 renderer_preferences_ = renderer_prefs;
ananta59b9fe72015-04-07 01:33:262424
[email protected]6e282c92009-07-24 01:19:372425 UpdateFontRenderingFromRendererPrefs();
scottmgb92365e2016-08-30 20:54:402426 UpdateThemePrefs();
ellyjones8ae17692016-08-05 15:19:212427 blink::setCaretBlinkInterval(renderer_prefs.caret_blink_interval);
[email protected]38a85712013-01-02 22:45:022428
[email protected]dcc297772014-04-10 22:20:522429#if defined(USE_DEFAULT_RENDER_THEME)
[email protected]1596efb2013-01-17 22:13:012430 if (renderer_prefs.use_custom_colors) {
esprehn021507d2015-11-13 23:35:012431 blink::setFocusRingColor(renderer_prefs.focus_ring_color);
[email protected]1596efb2013-01-17 22:13:012432
2433 if (webview()) {
[email protected]1596efb2013-01-17 22:13:012434 webview()->setSelectionColors(
2435 renderer_prefs.active_selection_bg_color,
2436 renderer_prefs.active_selection_fg_color,
2437 renderer_prefs.inactive_selection_bg_color,
2438 renderer_prefs.inactive_selection_fg_color);
2439 webview()->themeChanged();
2440 }
[email protected]644d77e2010-01-27 01:03:102441 }
[email protected]c997bc42014-04-11 18:25:582442#endif // defined(USE_DEFAULT_RENDER_THEME)
[email protected]d299d972012-03-23 02:26:552443
[email protected]ebd5ea52014-05-28 14:51:152444 if (webview() &&
2445 old_accept_languages != renderer_preferences_.accept_languages) {
2446 webview()->acceptLanguagesChanged();
2447 }
[email protected]80d96fa2009-06-10 22:34:512448}
2449
[email protected]310ebd6302011-10-10 19:06:282450void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location,
2451 const WebMediaPlayerAction& action) {
[email protected]952cb702009-10-07 05:50:282452 if (webview())
2453 webview()->performMediaPlayerAction(action, location);
[email protected]581b87eb2009-07-23 23:06:562454}
2455
[email protected]fcdc5642014-05-09 14:32:242456void RenderViewImpl::OnOrientationChange() {
japhete20ec7c2015-03-18 19:16:182457 if (webview() && webview()->mainFrame()->isWebLocalFrame())
2458 webview()->mainFrame()->toWebLocalFrame()->sendOrientationChangeEvent();
[email protected]77829642012-05-15 14:47:172459}
2460
[email protected]81375e872012-01-11 21:40:362461void RenderViewImpl::OnPluginActionAt(const gfx::Point& location,
2462 const WebPluginAction& action) {
2463 if (webview())
2464 webview()->performPluginAction(action, location);
2465}
2466
[email protected]310ebd6302011-10-10 19:06:282467void RenderViewImpl::OnClosePage() {
[email protected]77fc9b92011-10-15 16:20:372468 FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage());
initial.commit09911bf2008-07-26 23:55:292469 // TODO(creis): We'd rather use webview()->Close() here, but that currently
2470 // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs
2471 // in the onunload handler from appearing. For now, we're bypassing that and
2472 // calling the FrameLoader's CloseURL method directly. This should be
2473 // revisited to avoid having two ways to close a page. Having a single way
2474 // to close that can run onunload is also useful for fixing
2475 // http://b/issue?id=753080.
[email protected]11fd5db2014-04-02 03:49:462476 webview()->mainFrame()->dispatchUnloadEvent();
initial.commit09911bf2008-07-26 23:55:292477
avia3dca182016-03-19 01:09:522478 Send(new ViewHostMsg_ClosePage_ACK(GetRoutingID()));
initial.commit09911bf2008-07-26 23:55:292479}
2480
naskoc288745f2015-05-01 22:54:212481void RenderViewImpl::OnClose() {
2482 if (closing_)
avia3dca182016-03-19 01:09:522483 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID()));
naskoc288745f2015-05-01 22:54:212484 RenderWidget::OnClose();
2485}
2486
[email protected]310ebd6302011-10-10 19:06:282487void RenderViewImpl::OnMoveOrResizeStarted() {
[email protected]30f75e62009-02-25 22:01:002488 if (webview())
[email protected]a72a1fa2010-05-03 22:18:472489 webview()->hidePopups();
[email protected]30f75e62009-02-25 22:01:002490}
2491
bokanc63441c2016-04-27 15:49:122492void RenderViewImpl::ResizeWebWidget() {
2493 webview()->resizeWithTopControls(GetSizeForWebWidget(),
2494 top_controls_height_,
2495 top_controls_shrink_blink_size_);
2496}
2497
fsamuel664e8b62016-01-20 19:54:012498void RenderViewImpl::OnResize(const ResizeParams& params) {
[email protected]189a8862014-07-18 00:27:532499 TRACE_EVENT0("renderer", "RenderViewImpl::OnResize");
[email protected]cda45c02010-02-25 19:28:102500 if (webview()) {
[email protected]a72a1fa2010-05-03 22:18:472501 webview()->hidePopups();
kenrb5fd60fb82016-06-10 17:27:572502 if (send_preferred_size_changes_ &&
2503 webview()->mainFrame()->isWebLocalFrame()) {
[email protected]7339cd22010-10-27 00:11:202504 webview()->mainFrame()->setCanHaveScrollbars(
[email protected]0fdd5012013-05-29 08:05:562505 ShouldDisplayScrollbars(params.new_size.width(),
2506 params.new_size.height()));
[email protected]cda45c02010-02-25 19:28:102507 }
mikhail.pozdnyakovc0e251b2015-04-15 06:51:122508 if (display_mode_ != params.display_mode) {
2509 display_mode_ = params.display_mode;
2510 webview()->setDisplayMode(display_mode_);
2511 }
[email protected]cda45c02010-02-25 19:28:102512 }
2513
[email protected]cbbdeef2014-05-26 15:57:362514 gfx::Size old_visible_viewport_size = visible_viewport_size_;
2515
bokanc63441c2016-04-27 15:49:122516 top_controls_shrink_blink_size_ = params.top_controls_shrink_blink_size;
2517 top_controls_height_ = params.top_controls_height;
2518
[email protected]0fdd5012013-05-29 08:05:562519 RenderWidget::OnResize(params);
[email protected]cbbdeef2014-05-26 15:57:362520
2521 if (old_visible_viewport_size != visible_viewport_size_)
2522 has_scrolled_focused_editable_node_into_rect_ = false;
[email protected]30f75e62009-02-25 22:01:002523}
[email protected]0aa477bd2009-03-23 22:21:432524
avib9dbd972016-03-08 18:19:322525void RenderViewImpl::RenderWidgetDidFlushPaint() {
[email protected]5b1dec8c2012-02-07 04:35:382526 // If the RenderWidget is closing down then early-exit, otherwise we'll crash.
2527 // See crbug.com/112921.
2528 if (!webview())
2529 return;
2530
[email protected]00c39612010-03-06 02:53:282531 WebFrame* main_frame = webview()->mainFrame();
[email protected]82307f6b2014-08-07 03:30:122532 for (WebFrame* frame = main_frame; frame;
2533 frame = frame->traverseNext(false)) {
pmeenandcc725b2014-10-22 18:04:112534 // TODO(nasko): This is a hack for the case in which the top-level
2535 // frame is being rendered in another process. It will not
2536 // behave correctly for out of process iframes.
2537 if (frame->isWebLocalFrame()) {
[email protected]82307f6b2014-08-07 03:30:122538 main_frame = frame;
pmeenandcc725b2014-10-22 18:04:112539 break;
2540 }
[email protected]82307f6b2014-08-07 03:30:122541 }
[email protected]00c39612010-03-06 02:53:282542
alexmos6806d182015-07-28 00:04:192543 // There's nothing to do if there are no local frames in this RenderView's
2544 // frame tree. This can happen if DidFlushPaint is called after the
2545 // RenderView's local main frame is swapped to a remote frame. See
2546 // http://crbug.com/513552.
2547 if (main_frame->isWebRemoteFrame())
2548 return;
2549
[email protected]00c39612010-03-06 02:53:282550 // If we have a provisional frame we are between the start and commit stages
2551 // of loading and we don't want to save stats.
2552 if (!main_frame->provisionalDataSource()) {
2553 WebDataSource* ds = main_frame->dataSource();
enne95486602015-04-30 23:41:102554 if (!ds)
2555 return;
2556
[email protected]007733c2011-11-17 00:34:072557 DocumentState* document_state = DocumentState::FromDataSource(ds);
[email protected]92d457802013-04-01 19:18:492558
[email protected]05c8e502010-08-15 15:13:522559 // TODO(jar): The following code should all be inside a method, probably in
2560 // NavigatorState.
[email protected]00c39612010-03-06 02:53:282561 Time now = Time::Now();
[email protected]007733c2011-11-17 00:34:072562 if (document_state->first_paint_time().is_null()) {
2563 document_state->set_first_paint_time(now);
[email protected]00c39612010-03-06 02:53:282564 }
[email protected]007733c2011-11-17 00:34:072565 if (document_state->first_paint_after_load_time().is_null() &&
2566 !document_state->finish_load_time().is_null()) {
2567 document_state->set_first_paint_after_load_time(now);
[email protected]00c39612010-03-06 02:53:282568 }
2569 }
2570}
2571
[email protected]ab6c9112014-02-27 00:20:582572void RenderViewImpl::OnClearFocusedElement() {
[email protected]05d478752009-04-08 23:38:162573 if (webview())
[email protected]ab6c9112014-02-27 00:20:582574 webview()->clearFocusedElement();
[email protected]05d478752009-04-08 23:38:162575}
2576
[email protected]61f91832014-05-13 01:24:422577void RenderViewImpl::OnSetBackgroundOpaque(bool opaque) {
lfgcaab5142016-02-26 19:06:522578 if (frame_widget_)
2579 frame_widget_->setIsTransparent(!opaque);
[email protected]ba91a792013-02-06 09:48:282580 if (compositor_)
[email protected]61f91832014-05-13 01:24:422581 compositor_->setHasTransparentBackground(!opaque);
[email protected]699ab0d2009-04-23 23:19:142582}
2583
[email protected]310ebd6302011-10-10 19:06:282584void RenderViewImpl::OnSetActive(bool active) {
[email protected]8c66c5a2009-07-22 17:26:342585 if (webview())
[email protected]b4bb2502009-10-01 22:35:272586 webview()->setIsActive(active);
[email protected]8c66c5a2009-07-22 17:26:342587}
2588
lfg8ff33912016-09-13 20:59:212589blink::WebWidget* RenderViewImpl::GetWebWidget() const {
2590 if (frame_widget_)
2591 return frame_widget_;
2592
2593 return RenderWidget::GetWebWidget();
2594}
2595
dcheng3ce04b62015-10-26 23:30:552596void RenderViewImpl::CloseForFrame() {
2597 DCHECK(frame_widget_);
2598 frame_widget_->close();
2599 frame_widget_ = nullptr;
2600}
2601
[email protected]310ebd6302011-10-10 19:06:282602void RenderViewImpl::Close() {
[email protected]60c42a8c72009-10-09 04:08:592603 // We need to grab a pointer to the doomed WebView before we destroy it.
lfg4fa48da2016-05-09 18:25:132604 WebView* doomed = webview_;
[email protected]60c42a8c72009-10-09 04:08:592605 RenderWidget::Close();
lfg4fa48da2016-05-09 18:25:132606 webview_ = nullptr;
[email protected]625332e02010-12-14 07:48:492607 g_view_map.Get().erase(doomed);
avia3dca182016-03-19 01:09:522608 g_routing_id_view_map.Get().erase(GetRoutingID());
2609 RenderThread::Get()->Send(new ViewHostMsg_Close_ACK(GetRoutingID()));
[email protected]60c42a8c72009-10-09 04:08:592610}
2611
lfg717154072016-06-30 15:04:162612void RenderViewImpl::OnPageWasHidden() {
[email protected]68877c282013-09-20 05:52:422613#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
[email protected]6392d982013-04-16 16:59:222614 RenderThreadImpl::current()->video_capture_impl_manager()->
2615 SuspendDevices(true);
[email protected]e976c3c52014-07-24 17:41:552616 if (speech_recognition_dispatcher_)
2617 speech_recognition_dispatcher_->AbortAllRecognitions();
[email protected]6392d982013-04-16 16:59:222618#endif
[email protected]2d7b82c2012-06-01 05:57:502619
lfg717154072016-06-30 15:04:162620 if (webview()) {
2621 // TODO(lfg): It's not correct to defer the page visibility to the main
2622 // frame. Currently, this is done because the main frame may override the
2623 // visibility of the page when prerendering. In order to fix this,
2624 // prerendering must be made aware of OOPIFs. https://crbug.com/440544
2625 blink::WebPageVisibilityState visibilityState =
2626 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2627 : blink::WebPageVisibilityStateHidden;
2628 webview()->setVisibilityState(visibilityState, false);
2629 }
[email protected]941e4552010-02-01 21:23:432630}
2631
lfg717154072016-06-30 15:04:162632void RenderViewImpl::OnPageWasShown() {
[email protected]6392d982013-04-16 16:59:222633#if defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
2634 RenderThreadImpl::current()->video_capture_impl_manager()->
2635 SuspendDevices(false);
2636#endif
2637
lfg717154072016-06-30 15:04:162638 if (webview()) {
2639 blink::WebPageVisibilityState visibilityState =
2640 GetMainRenderFrame() ? GetMainRenderFrame()->visibilityState()
2641 : blink::WebPageVisibilityStateVisible;
2642 webview()->setVisibilityState(visibilityState, false);
2643 }
[email protected]a6939ca42011-02-18 17:58:072644}
[email protected]1e6e3c992010-02-08 15:52:132645
[email protected]ed7defa2013-03-12 21:29:592646GURL RenderViewImpl::GetURLForGraphicsContext3D() {
2647 DCHECK(webview());
[email protected]82307f6b2014-08-07 03:30:122648 if (webview()->mainFrame()->isWebLocalFrame())
[email protected]ed7defa2013-03-12 21:29:592649 return GURL(webview()->mainFrame()->document().url());
2650 else
2651 return GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D");
[email protected]65225772011-05-12 21:10:242652}
2653
[email protected]310ebd6302011-10-10 19:06:282654void RenderViewImpl::OnSetFocus(bool enable) {
naskoc6edf7e2015-10-16 01:48:452655 // This message must always be received when the main frame is a
2656 // WebLocalFrame.
2657 CHECK(webview()->mainFrame()->isWebLocalFrame());
alexmos3fcd0ca2015-10-23 18:18:332658 SetFocus(enable);
2659}
alexmos7fac9aeb2015-10-16 22:39:492660
alexmos3fcd0ca2015-10-23 18:18:332661void RenderViewImpl::SetFocus(bool enable) {
[email protected]1e6e3c992010-02-08 15:52:132662 RenderWidget::OnSetFocus(enable);
2663
[email protected]321032992012-11-08 01:01:272664 // Notify all BrowserPlugins of the RenderView's focus state.
fsamuel6c1dfeb2014-12-18 19:21:332665 if (BrowserPluginManager::Get())
2666 BrowserPluginManager::Get()->UpdateFocusState();
[email protected]1e6e3c992010-02-08 15:52:132667}
[email protected]941e4552010-02-01 21:23:432668
avi40b5be7a2016-03-03 21:13:442669void RenderViewImpl::RenderWidgetDidSetColorProfile(
[email protected]28ed6b32014-06-08 02:16:272670 const std::vector<char>& profile) {
avi40b5be7a2016-03-03 21:13:442671 if (webview()) {
ccameron7c4df6c22016-08-11 03:03:152672 WebVector<char> colorProfile = profile;
2673 webview()->setDeviceColorProfile(colorProfile);
avi40b5be7a2016-03-03 21:13:442674 }
noeldb4df152014-09-16 17:45:202675}
2676
rouslanf7ebd8832015-01-22 01:54:142677void RenderViewImpl::DidCompletePageScaleAnimation() {
avid7d6b2e2016-03-04 19:41:172678 GetWidget()->FocusChangeComplete();
rouslanf7ebd8832015-01-22 01:54:142679}
2680
oshimad5279032015-12-16 18:22:332681void RenderViewImpl::OnDeviceScaleFactorChanged() {
2682 RenderWidget::OnDeviceScaleFactorChanged();
2683 UpdateWebViewWithDeviceScaleFactor();
2684 if (auto_resize_mode_)
2685 AutoResizeCompositor();
2686}
2687
[email protected]b2e4c70132013-10-03 02:07:512688void RenderViewImpl::SetScreenMetricsEmulationParameters(
dgozman9260b0a12015-03-16 13:45:202689 bool enabled,
2690 const blink::WebDeviceEmulationParams& params) {
[email protected]404630b2014-07-03 19:33:032691 if (webview() && compositor()) {
dgozman9260b0a12015-03-16 13:45:202692 if (enabled)
2693 webview()->enableDeviceEmulation(params);
2694 else
2695 webview()->disableDeviceEmulation();
[email protected]b2e4c70132013-10-03 02:07:512696 }
2697}
2698
[email protected]180ef242013-11-07 06:50:462699blink::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() {
[email protected]64d09222012-05-25 10:10:342700 if (!speech_recognition_dispatcher_)
2701 speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this);
[email protected]64d09222012-05-25 10:10:342702 return speech_recognition_dispatcher_;
2703}
2704
[email protected]310ebd6302011-10-10 19:06:282705void RenderViewImpl::zoomLimitsChanged(double minimum_level,
2706 double maximum_level) {
a.sarkar.arundaadc712015-02-26 05:39:082707 // Round the double to avoid returning incorrect minimum/maximum zoom
2708 // percentages.
2709 int minimum_percent = round(
[email protected]7940b8e2013-07-25 23:08:492710 ZoomLevelToZoomFactor(minimum_level) * 100);
a.sarkar.arundaadc712015-02-26 05:39:082711 int maximum_percent = round(
[email protected]7940b8e2013-07-25 23:08:492712 ZoomLevelToZoomFactor(maximum_level) * 100);
[email protected]b75b8292010-10-01 07:28:252713
avia3dca182016-03-19 01:09:522714 Send(new ViewHostMsg_UpdateZoomLimits(GetRoutingID(), minimum_percent,
fsamuele8326c742016-01-12 00:49:392715 maximum_percent));
[email protected]b75b8292010-10-01 07:28:252716}
2717
[email protected]310ebd6302011-10-10 19:06:282718void RenderViewImpl::zoomLevelChanged() {
[email protected]54b8e182014-05-02 18:08:292719 double zoom_level = webview()->zoomLevel();
[email protected]2b942c332012-04-25 16:26:262720
[email protected]54b8e182014-05-02 18:08:292721 // Do not send empty URLs to the browser when we are just setting the default
2722 // zoom level (from RendererPreferences) before the first navigation.
2723 if (!webview()->mainFrame()->document().url().isEmpty()) {
2724 // Tell the browser which url got zoomed so it can update the menu and the
2725 // saved values if necessary
2726 Send(new ViewHostMsg_DidZoomURL(
avia3dca182016-03-19 01:09:522727 GetRoutingID(), zoom_level,
[email protected]54b8e182014-05-02 18:08:292728 GURL(webview()->mainFrame()->document().url())));
2729 }
[email protected]b75b8292010-10-01 07:28:252730}
2731
ccameronb7c1d6c2015-03-09 17:08:242732void RenderViewImpl::pageScaleFactorChanged() {
2733 if (!webview())
2734 return;
mcnee432e47d2015-11-09 19:37:462735
avia3dca182016-03-19 01:09:522736 Send(new ViewHostMsg_PageScaleFactorChanged(GetRoutingID(),
mcnee432e47d2015-11-09 19:37:462737 webview()->pageScaleFactor()));
ccameronb7c1d6c2015-03-09 17:08:242738}
2739
[email protected]7940b8e2013-07-25 23:08:492740double RenderViewImpl::zoomLevelToZoomFactor(double zoom_level) const {
2741 return ZoomLevelToZoomFactor(zoom_level);
2742}
2743
2744double RenderViewImpl::zoomFactorToZoomLevel(double factor) const {
2745 return ZoomFactorToZoomLevel(factor);
2746}
2747
[email protected]a0629af92012-08-08 00:39:372748void RenderViewImpl::draggableRegionsChanged() {
2749 FOR_EACH_OBSERVER(
2750 RenderViewObserver,
2751 observers_,
2752 DraggableRegionsChanged(webview()->mainFrame()));
2753}
2754
kouhei40f03cb2015-09-24 07:47:012755void RenderViewImpl::pageImportanceSignalsChanged() {
2756 if (!webview() || !main_render_frame_)
2757 return;
2758
vmpstr10e0d5f2016-07-21 23:46:092759 auto* web_signals = webview()->pageImportanceSignals();
kouhei40f03cb2015-09-24 07:47:012760
2761 PageImportanceSignals signals;
2762 signals.had_form_interaction = web_signals->hadFormInteraction();
2763
2764 main_render_frame_->Send(new FrameHostMsg_UpdatePageImportanceSignals(
2765 main_render_frame_->GetRoutingID(), signals));
2766}
2767
dglazkov8d0c21dd2016-08-06 15:56:362768// TODO(dglazkov): Remove this ifdef. The content detection code
2769// should not be platform-specific.
2770// See http://crbug.com/635214 for details.
[email protected]20657a82012-08-21 20:23:032771#if defined(OS_ANDROID)
dglazkov8d0c21dd2016-08-06 15:56:362772WebURL RenderViewImpl::detectContentIntentAt(
[email protected]20657a82012-08-21 20:23:032773 const WebHitTestResult& touch_hit) {
[email protected]20657a82012-08-21 20:23:032774 DCHECK(touch_hit.node().isTextNode());
2775
2776 // Process the position with all the registered content detectors until
2777 // a match is found. Priority is provided by their relative order.
limasdf81d962e2015-11-20 08:39:182778 for (const auto& detector : content_detectors_) {
dglazkov0d073cb2016-08-07 19:46:462779 WebURL intent = detector->FindTappedContent(touch_hit);
2780 if (intent.isValid()) {
2781 return intent;
[email protected]20657a82012-08-21 20:23:032782 }
2783 }
dglazkov8d0c21dd2016-08-06 15:56:362784 return WebURL();
[email protected]20657a82012-08-21 20:23:032785}
2786
mnaganov42d9e372015-11-02 23:27:412787void RenderViewImpl::scheduleContentIntent(const WebURL& intent,
2788 bool is_main_frame) {
[email protected]20657a82012-08-21 20:23:032789 // Introduce a short delay so that the user can notice the content.
fdoray7a8954a42016-06-07 04:28:382790 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
[email protected]20657a82012-08-21 20:23:032791 FROM_HERE,
mnaganov42d9e372015-11-02 23:27:412792 base::Bind(&RenderViewImpl::LaunchAndroidContentIntent, AsWeakPtr(),
2793 intent, expected_content_intent_id_, is_main_frame),
[email protected]20657a82012-08-21 20:23:032794 base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds));
2795}
2796
2797void RenderViewImpl::cancelScheduledContentIntents() {
2798 ++expected_content_intent_id_;
2799}
2800
2801void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent,
mnaganov42d9e372015-11-02 23:27:412802 size_t request_id,
2803 bool is_main_frame) {
[email protected]20657a82012-08-21 20:23:032804 if (request_id != expected_content_intent_id_)
qinmin0d5560df2014-11-12 19:03:392805 return;
[email protected]20657a82012-08-21 20:23:032806
2807 // Remove the content highlighting if any.
jdduke491a3f0c2015-06-15 23:30:262808 ScheduleComposite();
[email protected]20657a82012-08-21 20:23:032809
mnaganov42d9e372015-11-02 23:27:412810 if (!intent.is_empty()) {
avia3dca182016-03-19 01:09:522811 Send(new ViewHostMsg_StartContentIntent(GetRoutingID(), intent,
fsamuele8326c742016-01-12 00:49:392812 is_main_frame));
mnaganov42d9e372015-11-02 23:27:412813 }
[email protected]20657a82012-08-21 20:23:032814}
[email protected]b18583c2012-12-18 06:55:272815
2816bool RenderViewImpl::openDateTimeChooser(
[email protected]180ef242013-11-07 06:50:462817 const blink::WebDateTimeChooserParams& params,
2818 blink::WebDateTimeChooserCompletion* completion) {
[email protected]e8072562013-12-04 06:04:132819 // JavaScript may try to open a date time chooser while one is already open.
2820 if (date_time_picker_client_)
2821 return false;
[email protected]b18583c2012-12-18 06:55:272822 date_time_picker_client_.reset(
2823 new RendererDateTimePicker(this, params, completion));
2824 return date_time_picker_client_->Open();
2825}
2826
[email protected]e8072562013-12-04 06:04:132827void RenderViewImpl::DismissDateTimeDialog() {
2828 DCHECK(date_time_picker_client_);
2829 date_time_picker_client_.reset(NULL);
2830}
[email protected]e8072562013-12-04 06:04:132831
[email protected]6d17f6392012-12-05 05:24:542832#endif // defined(OS_ANDROID)
[email protected]20657a82012-08-21 20:23:032833
[email protected]be1af0662014-07-29 19:55:512834void RenderViewImpl::OnShowContextMenu(
2835 ui::MenuSourceType source_type, const gfx::Point& location) {
fsamuele8326c742016-01-12 00:49:392836 input_handler_->set_context_menu_source_type(source_type);
[email protected]be1af0662014-07-29 19:55:512837 has_host_context_menu_location_ = true;
2838 host_context_menu_location_ = location;
[email protected]47822262013-04-23 17:22:362839 if (webview())
2840 webview()->showContextMenu();
[email protected]be1af0662014-07-29 19:55:512841 has_host_context_menu_location_ = false;
[email protected]47822262013-04-23 17:22:362842}
2843
estade6b9696bd2016-05-04 23:51:362844#if defined(OS_ANDROID)
[email protected]f9526d12012-10-18 01:55:032845bool RenderViewImpl::didTapMultipleTargets(
timav29a8d0f62014-09-25 20:45:532846 const WebSize& inner_viewport_offset,
2847 const WebRect& touch_rect,
[email protected]f9526d12012-10-18 01:55:032848 const WebVector<WebRect>& target_rects) {
[email protected]8d3dfee62013-06-19 05:50:332849 // Never show a disambiguation popup when accessibility is enabled,
2850 // as this interferes with "touch exploration".
[email protected]95640212014-07-26 18:14:302851 AccessibilityMode accessibility_mode =
mostynbc33353232014-09-12 09:38:312852 GetMainRenderFrame()->accessibility_mode();
[email protected]95640212014-07-26 18:14:302853 bool matches_accessibility_mode_complete =
2854 (accessibility_mode & AccessibilityModeComplete) ==
2855 AccessibilityModeComplete;
2856 if (matches_accessibility_mode_complete)
[email protected]8d3dfee62013-06-19 05:50:332857 return false;
2858
timav29a8d0f62014-09-25 20:45:532859 // The touch_rect, target_rects and zoom_rect are in the outer viewport
2860 // reference frame.
[email protected]f9526d12012-10-18 01:55:032861 gfx::Rect zoom_rect;
[email protected]70221f02013-01-31 22:17:072862 float new_total_scale =
2863 DisambiguationPopupHelper::ComputeZoomAreaAndScaleFactor(
timav29a8d0f62014-09-25 20:45:532864 touch_rect, target_rects, GetSize(),
[email protected]70221f02013-01-31 22:17:072865 gfx::Rect(webview()->mainFrame()->visibleContentRect()).size(),
2866 device_scale_factor_ * webview()->pageScaleFactor(), &zoom_rect);
jbauman0ed09182015-01-30 22:33:492867 if (!new_total_scale || zoom_rect.IsEmpty())
[email protected]f9526d12012-10-18 01:55:032868 return false;
2869
[email protected]4ded1dbf2013-08-28 21:11:032870 bool handled = false;
2871 switch (renderer_preferences_.tap_multiple_targets_strategy) {
2872 case TAP_MULTIPLE_TARGETS_STRATEGY_ZOOM:
2873 handled = webview()->zoomToMultipleTargetsRect(zoom_rect);
2874 break;
2875 case TAP_MULTIPLE_TARGETS_STRATEGY_POPUP: {
[email protected]bc2804d2013-08-06 07:45:492876 gfx::Size canvas_size =
danakjddaec912015-09-25 19:38:402877 gfx::ScaleToCeiledSize(zoom_rect.size(), new_total_scale);
[email protected]cb189e062014-04-23 00:57:012878 cc::SharedBitmapManager* manager =
2879 RenderThreadImpl::current()->shared_bitmap_manager();
dchengcedca5612016-04-09 01:40:152880 std::unique_ptr<cc::SharedBitmap> shared_bitmap =
[email protected]cb189e062014-04-23 00:57:012881 manager->AllocateSharedBitmap(canvas_size);
jbauman0ed09182015-01-30 22:33:492882 CHECK(!!shared_bitmap);
[email protected]bc2804d2013-08-06 07:45:492883 {
[email protected]cb189e062014-04-23 00:57:012884 SkBitmap bitmap;
2885 SkImageInfo info = SkImageInfo::MakeN32Premul(canvas_size.width(),
2886 canvas_size.height());
2887 bitmap.installPixels(info, shared_bitmap->pixels(), info.minRowBytes());
2888 SkCanvas canvas(bitmap);
[email protected]f9526d12012-10-18 01:55:032889
[email protected]bc2804d2013-08-06 07:45:492890 // TODO(trchen): Cleanup the device scale factor mess.
2891 // device scale will be applied in WebKit
2892 // --> zoom_rect doesn't include device scale,
2893 // but WebKit will still draw on zoom_rect * device_scale_factor_
[email protected]cb189e062014-04-23 00:57:012894 canvas.scale(new_total_scale / device_scale_factor_,
2895 new_total_scale / device_scale_factor_);
2896 canvas.translate(-zoom_rect.x() * device_scale_factor_,
2897 -zoom_rect.y() * device_scale_factor_);
[email protected]f9526d12012-10-18 01:55:032898
lfg8ff33912016-09-13 20:59:212899 DCHECK(webview_->isAcceleratedCompositingActive());
2900 webview_->paintIgnoringCompositing(&canvas, zoom_rect);
[email protected]bc2804d2013-08-06 07:45:492901 }
2902
timav29a8d0f62014-09-25 20:45:532903 gfx::Rect zoom_rect_in_screen =
2904 zoom_rect - gfx::Vector2d(inner_viewport_offset.width,
2905 inner_viewport_offset.height);
2906
[email protected]bc2804d2013-08-06 07:45:492907 gfx::Rect physical_window_zoom_rect = gfx::ToEnclosingRect(
timav29a8d0f62014-09-25 20:45:532908 ClientRectToPhysicalWindowRect(gfx::RectF(zoom_rect_in_screen)));
2909
fsamuele8326c742016-01-12 00:49:392910 Send(new ViewHostMsg_ShowDisambiguationPopup(
avia3dca182016-03-19 01:09:522911 GetRoutingID(), physical_window_zoom_rect, canvas_size,
fsamuele8326c742016-01-12 00:49:392912 shared_bitmap->id()));
[email protected]cb189e062014-04-23 00:57:012913 cc::SharedBitmapId id = shared_bitmap->id();
2914 disambiguation_bitmaps_[id] = shared_bitmap.release();
[email protected]4ded1dbf2013-08-28 21:11:032915 handled = true;
2916 break;
2917 }
2918 case TAP_MULTIPLE_TARGETS_STRATEGY_NONE:
2919 // No-op.
2920 break;
[email protected]f9526d12012-10-18 01:55:032921 }
[email protected]70221f02013-01-31 22:17:072922
[email protected]4ded1dbf2013-08-28 21:11:032923 return handled;
[email protected]f9526d12012-10-18 01:55:032924}
estade6b9696bd2016-05-04 23:51:362925#endif // defined(OS_ANDROID)
[email protected]f9526d12012-10-18 01:55:032926
[email protected]b283d292013-02-21 08:40:342927unsigned RenderViewImpl::GetLocalSessionHistoryLengthForTesting() const {
2928 return history_list_length_;
2929}
2930
[email protected]cc290f902013-03-04 20:06:022931void RenderViewImpl::SetFocusAndActivateForTesting(bool enable) {
2932 if (enable) {
2933 if (has_focus())
2934 return;
2935 OnSetActive(true);
2936 OnSetFocus(true);
2937 } else {
2938 if (!has_focus())
2939 return;
2940 OnSetFocus(false);
2941 OnSetActive(false);
2942 }
2943}
2944
[email protected]3a1c8a8032013-03-18 22:35:322945void RenderViewImpl::SetDeviceScaleFactorForTesting(float factor) {
fsamuel664e8b62016-01-20 19:54:012946 ResizeParams params;
[email protected]b54fe452013-06-07 14:01:532947 params.screen_info = screen_info_;
ccameron2f451532016-09-07 21:49:272948 params.screen_info.device_scale_factor = factor;
[email protected]b54fe452013-06-07 14:01:532949 params.new_size = size();
bokanf0fd2412014-10-30 15:28:552950 params.visible_viewport_size = visible_viewport_size_;
danakjddaec912015-09-25 19:38:402951 params.physical_backing_size = gfx::ScaleToCeiledSize(size(), factor);
dtrainorcb7779b82014-12-04 01:08:022952 params.top_controls_shrink_blink_size = false;
2953 params.top_controls_height = 0.f;
mikhail.pozdnyakovf2c902a2015-04-14 08:09:122954 params.is_fullscreen_granted = is_fullscreen_granted();
mikhail.pozdnyakovc0e251b2015-04-15 06:51:122955 params.display_mode = display_mode_;
[email protected]b54fe452013-06-07 14:01:532956 OnResize(params);
[email protected]3a1c8a8032013-03-18 22:35:322957}
2958
[email protected]92650162013-10-30 03:31:022959void RenderViewImpl::ForceResizeForTesting(const gfx::Size& new_size) {
bokanc007c3a2015-02-03 07:15:562960 gfx::Rect new_window_rect(rootWindowRect().x,
2961 rootWindowRect().y,
2962 new_size.width(),
2963 new_size.height());
2964 SetWindowRectSynchronously(new_window_rect);
[email protected]92650162013-10-30 03:31:022965}
2966
[email protected]5b45ad42013-10-25 00:42:042967void RenderViewImpl::UseSynchronousResizeModeForTesting(bool enable) {
2968 resizing_mode_selector_->set_is_synchronous_mode(enable);
2969}
2970
[email protected]eac2b362013-05-22 07:01:452971void RenderViewImpl::EnableAutoResizeForTesting(const gfx::Size& min_size,
2972 const gfx::Size& max_size) {
2973 OnEnableAutoResize(min_size, max_size);
2974}
2975
2976void RenderViewImpl::DisableAutoResizeForTesting(const gfx::Size& new_size) {
2977 OnDisableAutoResize(new_size);
2978}
2979
[email protected]cb189e062014-04-23 00:57:012980void RenderViewImpl::OnReleaseDisambiguationPopupBitmap(
2981 const cc::SharedBitmapId& id) {
2982 BitmapMap::iterator it = disambiguation_bitmaps_.find(id);
2983 DCHECK(it != disambiguation_bitmaps_.end());
2984 delete it->second;
2985 disambiguation_bitmaps_.erase(it);
[email protected]f9526d12012-10-18 01:55:032986}
[email protected]e9ff79c2012-10-19 21:31:262987
[email protected]6fceb912013-02-15 06:24:152988void RenderViewImpl::DidCommitCompositorFrame() {
2989 RenderWidget::DidCommitCompositorFrame();
2990 FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidCommitCompositorFrame());
2991}
2992
[email protected]41225fe2013-03-29 05:32:022993void RenderViewImpl::SendUpdateFaviconURL(const std::vector<FaviconURL>& urls) {
2994 if (!urls.empty())
avia3dca182016-03-19 01:09:522995 Send(new ViewHostMsg_UpdateFaviconURL(GetRoutingID(), urls));
[email protected]41225fe2013-03-29 05:32:022996}
2997
2998void RenderViewImpl::DidStopLoadingIcons() {
huangsdde9aceb2015-03-17 21:26:162999 int icon_types = WebIconURL::TypeFavicon | WebIconURL::TypeTouchPrecomposed |
3000 WebIconURL::TypeTouch;
[email protected]41225fe2013-03-29 05:32:023001
nasko2411ba372014-10-13 17:45:413002 // Favicons matter only for the top-level frame. If it is a WebRemoteFrame,
3003 // just return early.
3004 if (webview()->mainFrame()->isWebRemoteFrame())
3005 return;
3006
[email protected]41225fe2013-03-29 05:32:023007 WebVector<WebIconURL> icon_urls =
3008 webview()->mainFrame()->iconURLs(icon_types);
3009
3010 std::vector<FaviconURL> urls;
3011 for (size_t i = 0; i < icon_urls.size(); i++) {
3012 WebURL url = icon_urls[i].iconURL();
[email protected]2bd262b2014-04-16 05:31:233013 std::vector<gfx::Size> sizes;
[email protected]f34ac132014-03-20 23:02:053014 ConvertToFaviconSizes(icon_urls[i].sizes(), &sizes);
[email protected]41225fe2013-03-29 05:32:023015 if (!url.isEmpty())
[email protected]f34ac132014-03-20 23:02:053016 urls.push_back(
3017 FaviconURL(url, ToFaviconType(icon_urls[i].iconType()), sizes));
[email protected]41225fe2013-03-29 05:32:023018 }
3019 SendUpdateFaviconURL(urls);
3020}
3021
oshimad5279032015-12-16 18:22:333022void RenderViewImpl::UpdateWebViewWithDeviceScaleFactor() {
3023 if (!webview())
3024 return;
oshima750cb4342015-10-31 00:59:013025 if (IsUseZoomForDSFEnabled()) {
oshimad5279032015-12-16 18:22:333026 webview()->setZoomFactorForDeviceScaleFactor(device_scale_factor_);
oshima750cb4342015-10-31 00:59:013027 } else {
3028 webview()->setDeviceScaleFactor(device_scale_factor_);
3029 }
oshimad5279032015-12-16 18:22:333030 webview()->settings()->setPreferCompositingToLCDTextEnabled(
3031 PreferCompositingToLCDText(compositor_deps_, device_scale_factor_));
oshima750cb4342015-10-31 00:59:013032}
3033
[email protected]e9ff79c2012-10-19 21:31:263034} // namespace content