[email protected] | b553edd5 | 2012-01-10 12:15:23 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5 | #include "content/renderer/render_view_impl.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 6 | |
| 7 | #include <algorithm> |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 8 | #include <cmath> |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 9 | #include <string> |
| 10 | #include <vector> |
| 11 | |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 12 | #include "base/bind.h" |
| 13 | #include "base/bind_helpers.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 14 | #include "base/command_line.h" |
[email protected] | bb063b7 | 2009-03-27 23:18:50 | [diff] [blame] | 15 | #include "base/compiler_specific.h" |
[email protected] | e7ca289 | 2012-09-01 00:52:15 | [diff] [blame] | 16 | #include "base/debug/trace_event.h" |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 17 | #include "base/json/json_reader.h" |
[email protected] | b1cf337 | 2011-04-20 21:28:10 | [diff] [blame] | 18 | #include "base/json/json_writer.h" |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 19 | #include "base/lazy_instance.h" |
[email protected] | 084c855 | 2012-08-12 22:51:20 | [diff] [blame] | 20 | #include "base/message_loop_proxy.h" |
[email protected] | 835d7c8 | 2010-10-14 04:38:38 | [diff] [blame] | 21 | #include "base/metrics/histogram.h" |
[email protected] | 7bf795d9 | 2010-05-22 00:14:28 | [diff] [blame] | 22 | #include "base/path_service.h" |
[email protected] | 8380c09 | 2009-06-25 17:45:51 | [diff] [blame] | 23 | #include "base/process_util.h" |
[email protected] | 7ddea980 | 2012-02-22 23:08:05 | [diff] [blame] | 24 | #include "base/string_number_conversions.h" |
[email protected] | 0a35efc | 2012-03-13 17:28:13 | [diff] [blame] | 25 | #include "base/string_piece.h" |
[email protected] | 318bf580 | 2011-08-08 17:12:41 | [diff] [blame] | 26 | #include "base/string_split.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 27 | #include "base/string_util.h" |
[email protected] | 5512613 | 2010-08-19 14:53:28 | [diff] [blame] | 28 | #include "base/sys_string_conversions.h" |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 29 | #include "base/time.h" |
[email protected] | be1ce6a7 | 2010-08-03 14:35:22 | [diff] [blame] | 30 | #include "base/utf_string_conversions.h" |
[email protected] | e93e04e | 2011-03-14 00:27:10 | [diff] [blame] | 31 | #include "content/common/appcache/appcache_dispatcher.h" |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 32 | #include "content/common/child_thread.h" |
[email protected] | 127dd58 | 2011-03-16 21:32:10 | [diff] [blame] | 33 | #include "content/common/clipboard_messages.h" |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 34 | #include "content/common/content_constants_internal.h" |
[email protected] | 37666cf | 2011-03-13 21:51:42 | [diff] [blame] | 35 | #include "content/common/database_messages.h" |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 36 | #include "content/common/drag_messages.h" |
[email protected] | 16dd6e2 | 2012-03-01 19:08:20 | [diff] [blame] | 37 | #include "content/common/fileapi/file_system_dispatcher.h" |
| 38 | #include "content/common/fileapi/webfilesystem_callback_dispatcher.h" |
[email protected] | c26ad88 | 2012-02-07 06:41:20 | [diff] [blame] | 39 | #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 40 | #include "content/common/intents_messages.h" |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 41 | #include "content/common/java_bridge_messages.h" |
[email protected] | bac466e | 2012-07-31 02:10:54 | [diff] [blame] | 42 | #include "content/common/old_browser_plugin_messages.h" |
[email protected] | 127dd58 | 2011-03-16 21:32:10 | [diff] [blame] | 43 | #include "content/common/pepper_messages.h" |
[email protected] | cebc3dc | 2011-04-18 17:15:00 | [diff] [blame] | 44 | #include "content/common/pepper_plugin_registry.h" |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 45 | #include "content/common/quota_dispatcher.h" |
[email protected] | 940895b | 2011-08-20 00:50:05 | [diff] [blame] | 46 | #include "content/common/request_extra_data.h" |
[email protected] | 5fa3a06 | 2012-03-21 15:39:34 | [diff] [blame] | 47 | #include "content/common/socket_stream_handle_data.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 48 | #include "content/common/view_messages.h" |
[email protected] | 4e1eb339 | 2012-05-18 00:08:05 | [diff] [blame] | 49 | #include "content/common/webmessageportchannel_impl.h" |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 50 | #include "content/public/common/bindings_policy.h" |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 51 | #include "content/public/common/content_client.h" |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 52 | #include "content/public/common/content_constants.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 53 | #include "content/public/common/content_switches.h" |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 54 | #include "content/public/common/context_menu_params.h" |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 55 | #include "content/public/common/file_chooser_params.h" |
[email protected] | a1d2916 | 2011-10-14 17:14:03 | [diff] [blame] | 56 | #include "content/public/common/url_constants.h" |
[email protected] | d344114c | 2011-10-01 01:24:34 | [diff] [blame] | 57 | #include "content/public/renderer/content_renderer_client.h" |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 58 | #include "content/public/renderer/document_state.h" |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 59 | #include "content/public/renderer/navigation_state.h" |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 60 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 61 | #include "content/public/renderer/render_view_visitor.h" |
[email protected] | e6e5675 | 2012-08-10 00:46:06 | [diff] [blame] | 62 | #include "content/renderer/browser_plugin/browser_plugin.h" |
| 63 | #include "content/renderer/browser_plugin/browser_plugin_manager.h" |
[email protected] | cc510d7e | 2012-08-08 04:40:10 | [diff] [blame] | 64 | #include "content/renderer/browser_plugin/old/old_browser_plugin.h" |
[email protected] | 14cf0f1 | 2012-06-18 17:15:57 | [diff] [blame] | 65 | #include "content/renderer/browser_plugin/old/browser_plugin_channel_manager.h" |
| 66 | #include "content/renderer/browser_plugin/old/browser_plugin_constants.h" |
| 67 | #include "content/renderer/browser_plugin/old/guest_to_embedder_channel.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 68 | #include "content/renderer/device_orientation_dispatcher.h" |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 69 | #include "content/renderer/devtools_agent.h" |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 70 | #include "content/renderer/dom_automation_controller.h" |
[email protected] | 1910fe8 | 2012-05-10 00:04:10 | [diff] [blame] | 71 | #include "content/renderer/dom_storage/webstoragenamespace_impl.h" |
[email protected] | 5572215 | 2011-03-22 01:33:53 | [diff] [blame] | 72 | #include "content/renderer/external_popup_menu.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 73 | #include "content/renderer/geolocation_dispatcher.h" |
[email protected] | 84a83e19 | 2012-03-09 18:43:40 | [diff] [blame] | 74 | #include "content/renderer/gpu/compositor_thread.h" |
[email protected] | 1842fe2 | 2012-08-13 23:24:35 | [diff] [blame] | 75 | #include "content/renderer/gpu/compositor_output_surface.h" |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 76 | #include "content/renderer/idle_user_detector.h" |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 77 | #include "content/renderer/input_tag_speech_dispatcher.h" |
[email protected] | 0716190 | 2011-11-11 09:57:42 | [diff] [blame] | 78 | #include "content/renderer/java/java_bridge_dispatcher.h" |
[email protected] | 921f159 | 2011-03-18 00:41:02 | [diff] [blame] | 79 | #include "content/renderer/load_progress_tracker.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 80 | #include "content/renderer/media/media_stream_dependency_factory.h" |
| 81 | #include "content/renderer/media/media_stream_dispatcher.h" |
[email protected] | ab2c473 | 2011-07-20 19:57:40 | [diff] [blame] | 82 | #include "content/renderer/media/media_stream_impl.h" |
[email protected] | 6048d51 | 2012-01-28 03:14:48 | [diff] [blame] | 83 | #include "content/renderer/media/render_audiosourceprovider.h" |
[email protected] | 090f731 | 2011-08-05 23:26:40 | [diff] [blame] | 84 | #include "content/renderer/media/render_media_log.h" |
[email protected] | 6048d51 | 2012-01-28 03:14:48 | [diff] [blame] | 85 | #include "content/renderer/media/renderer_gpu_video_decoder_factories.h" |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 86 | #include "content/renderer/mhtml_generator.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 87 | #include "content/renderer/notification_provider.h" |
[email protected] | ccc70d8e | 2011-03-16 20:40:37 | [diff] [blame] | 88 | #include "content/renderer/p2p/socket_dispatcher.h" |
[email protected] | 6f51608 | 2011-03-17 19:15:35 | [diff] [blame] | 89 | #include "content/renderer/plugin_channel_host.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 90 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 91 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 8905450 | 2012-06-03 10:29:24 | [diff] [blame] | 92 | #include "content/renderer/render_view_mouse_lock_dispatcher.h" |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 93 | #include "content/renderer/render_widget_fullscreen_pepper.h" |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 94 | #include "content/renderer/renderer_accessibility.h" |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 95 | #include "content/renderer/renderer_accessibility_complete.h" |
| 96 | #include "content/renderer/renderer_accessibility_focus_only.h" |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 97 | #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 98 | #include "content/renderer/renderer_webcolorchooser_impl.h" |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 99 | #include "content/renderer/speech_recognition_dispatcher.h" |
[email protected] | 86a7d3c | 2011-09-12 16:45:32 | [diff] [blame] | 100 | #include "content/renderer/text_input_client_observer.h" |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 101 | #include "content/renderer/v8_value_converter_impl.h" |
[email protected] | 0a35efc | 2012-03-13 17:28:13 | [diff] [blame] | 102 | #include "content/renderer/web_intents_host.h" |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 103 | #include "content/renderer/web_ui_bindings.h" |
[email protected] | 6f51608 | 2011-03-17 19:15:35 | [diff] [blame] | 104 | #include "content/renderer/webplugin_delegate_proxy.h" |
| 105 | #include "content/renderer/websharedworker_proxy.h" |
[email protected] | f8db813 | 2010-12-03 00:27:49 | [diff] [blame] | 106 | #include "media/base/filter_collection.h" |
[email protected] | ee68378a | 2010-08-10 01:05:41 | [diff] [blame] | 107 | #include "media/base/media_switches.h" |
[email protected] | b8032290 | 2012-03-06 01:33:50 | [diff] [blame] | 108 | #include "media/base/message_loop_factory.h" |
[email protected] | 37136d16 | 2012-04-09 23:39:19 | [diff] [blame] | 109 | #include "media/filters/audio_renderer_impl.h" |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 110 | #include "media/filters/gpu_video_decoder.h" |
[email protected] | d1ef81d | 2012-07-24 11:39:36 | [diff] [blame] | 111 | #include "net/base/data_url.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 112 | #include "net/base/escape.h" |
| 113 | #include "net/base/net_errors.h" |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 114 | #include "net/http/http_util.h" |
[email protected] | 1842fe2 | 2012-08-13 23:24:35 | [diff] [blame] | 115 | #include "third_party/WebKit/Source/Platform/chromium/public/WebCompositorOutputSurface.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 116 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 117 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEvent.h" |
| 118 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMMessageEvent.h" |
[email protected] | be2510c0 | 2012-05-28 14:52:14 | [diff] [blame] | 119 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
| 120 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 121 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 122 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 123 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h" |
| 124 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" |
| 125 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" |
| 126 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" |
| 127 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
[email protected] | 4b1146bc | 2012-07-10 18:46:03 | [diff] [blame] | 128 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 129 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 130 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 131 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 132 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" |
[email protected] | 592e20b | 2012-01-20 05:53:44 | [diff] [blame] | 133 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h" |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 134 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.h" |
[email protected] | 69f110d6 | 2011-03-17 19:01:14 | [diff] [blame] | 135 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h" |
[email protected] | 4e1eb339 | 2012-05-18 00:08:05 | [diff] [blame] | 136 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebMessagePortChannel.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 137 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 138 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 139 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 140 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 141 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 142 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
| 143 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 144 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 145 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
| 146 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData.h" |
| 147 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
[email protected] | 20dc3cad | 2011-04-20 17:27:17 | [diff] [blame] | 148 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 149 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 150 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallbacks.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 151 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 152 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 153 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
| 154 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h" |
| 155 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.h" |
| 156 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h" |
[email protected] | 132e281a | 2012-07-31 18:32:44 | [diff] [blame] | 157 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebHTTPBody.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 158 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
[email protected] | 50da23d0 | 2012-04-13 17:47:48 | [diff] [blame] | 159 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnection00Handler.h" |
| 160 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnection00HandlerClient.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 161 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h" |
| 162 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandlerClient.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 163 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
| 164 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 165 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerializedScriptValue.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 166 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
[email protected] | 5fa3a06 | 2012-03-21 15:39:34 | [diff] [blame] | 167 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSocketStreamHandle.h" |
[email protected] | e6e90dc | 2011-12-03 00:01:37 | [diff] [blame] | 168 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 169 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 170 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h" |
| 171 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h" |
| 172 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h" |
| 173 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 174 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | ddb034b | 2012-06-26 20:31:39 | [diff] [blame] | 175 | #include "ui/base/dialogs/selected_file_info.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 176 | #include "ui/gfx/native_widget_types.h" |
| 177 | #include "ui/gfx/point.h" |
| 178 | #include "ui/gfx/rect.h" |
[email protected] | c4a9e93 | 2011-03-05 04:05:55 | [diff] [blame] | 179 | #include "v8/include/v8.h" |
[email protected] | 80f584d9 | 2010-01-21 03:59:04 | [diff] [blame] | 180 | #include "webkit/appcache/web_application_cache_host_impl.h" |
[email protected] | b928936b | 2012-04-13 01:16:16 | [diff] [blame] | 181 | #include "webkit/dom_storage/dom_storage_types.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 182 | #include "webkit/forms/form_data.h" |
| 183 | #include "webkit/forms/form_field.h" |
| 184 | #include "webkit/forms/password_form_dom_manager.h" |
[email protected] | 25e18f8 | 2010-10-27 16:38:43 | [diff] [blame] | 185 | #include "webkit/glue/alt_error_page_resource_fetcher.h" |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 186 | #include "webkit/glue/dom_operations.h" |
[email protected] | 95056b58 | 2010-02-18 01:29:24 | [diff] [blame] | 187 | #include "webkit/glue/glue_serialize.h" |
[email protected] | 3a3b75a | 2012-06-01 08:38:36 | [diff] [blame] | 188 | #include "webkit/glue/web_intent_service_data.h" |
[email protected] | 851334d | 2012-06-15 22:39:31 | [diff] [blame] | 189 | #include "webkit/glue/webdropdata.h" |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 190 | #include "webkit/glue/webkit_constants.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 191 | #include "webkit/glue/webkit_glue.h" |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 192 | #include "webkit/glue/weburlresponse_extradata_impl.h" |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 193 | #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 194 | #include "webkit/media/webmediaplayer_impl.h" |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 195 | #include "webkit/plugins/npapi/plugin_list.h" |
| 196 | #include "webkit/plugins/npapi/webplugin_delegate.h" |
| 197 | #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 198 | #include "webkit/plugins/npapi/webplugin_impl.h" |
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 199 | #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 200 | |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 201 | #if defined(OS_ANDROID) |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 202 | #include "content/common/android/device_info.h" |
| 203 | #include "content/renderer/android/address_detector.h" |
| 204 | #include "content/renderer/android/content_detector.h" |
| 205 | #include "content/renderer/android/email_detector.h" |
| 206 | #include "content/renderer/android/phone_number_detector.h" |
[email protected] | dbd3d21 | 2012-07-13 02:17:22 | [diff] [blame] | 207 | #include "content/renderer/media/stream_texture_factory_impl_android.h" |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 208 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebHitTestResult.h" |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 209 | #include "webkit/media/android/webmediaplayer_android.h" |
[email protected] | 2d7b82c | 2012-06-01 05:57:50 | [diff] [blame] | 210 | #include "webkit/media/android/webmediaplayer_manager_android.h" |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 211 | #elif defined(OS_WIN) |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 212 | // TODO(port): these files are currently Windows only because they concern: |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 213 | // * theming |
[email protected] | f78452f | 2012-05-15 02:07:52 | [diff] [blame] | 214 | #include "ui/base/native_theme/native_theme_win.h" |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 215 | #elif defined(USE_X11) |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 216 | #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme.h" |
[email protected] | f78452f | 2012-05-15 02:07:52 | [diff] [blame] | 217 | #include "ui/base/native_theme/native_theme.h" |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 218 | #elif defined(OS_MACOSX) |
| 219 | #include "skia/ext/skia_utils_mac.h" |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 220 | #endif |
| 221 | |
[email protected] | 9892b47 | 2010-09-16 00:23:42 | [diff] [blame] | 222 | using WebKit::WebAccessibilityNotification; |
[email protected] | cc0445f | 2009-10-13 16:09:08 | [diff] [blame] | 223 | using WebKit::WebAccessibilityObject; |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 224 | using WebKit::WebApplicationCacheHost; |
| 225 | using WebKit::WebApplicationCacheHostClient; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 226 | using WebKit::WebCString; |
[email protected] | 1c83eb4 | 2009-09-11 21:08:41 | [diff] [blame] | 227 | using WebKit::WebColor; |
| 228 | using WebKit::WebColorName; |
[email protected] | 0dea3ea | 2009-03-31 23:30:59 | [diff] [blame] | 229 | using WebKit::WebConsoleMessage; |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 230 | using WebKit::WebContextMenuData; |
[email protected] | b921cfd2 | 2010-02-25 16:57:51 | [diff] [blame] | 231 | using WebKit::WebCookieJar; |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 232 | using WebKit::WebData; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 233 | using WebKit::WebDataSource; |
[email protected] | 5bc8fe9 | 2010-03-11 18:19:00 | [diff] [blame] | 234 | using WebKit::WebDocument; |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 235 | using WebKit::WebDOMEvent; |
| 236 | using WebKit::WebDOMMessageEvent; |
[email protected] | e80c73b | 2009-04-07 23:24:58 | [diff] [blame] | 237 | using WebKit::WebDragData; |
[email protected] | 1d9f413 | 2009-09-08 17:29:25 | [diff] [blame] | 238 | using WebKit::WebDragOperation; |
| 239 | using WebKit::WebDragOperationsMask; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 240 | using WebKit::WebEditingAction; |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 241 | using WebKit::WebElement; |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 242 | using WebKit::WebExternalPopupMenu; |
| 243 | using WebKit::WebExternalPopupMenuClient; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 244 | using WebKit::WebFileChooserCompletion; |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 245 | using WebKit::WebFileSystem; |
| 246 | using WebKit::WebFileSystemCallbacks; |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 247 | using WebKit::WebFindOptions; |
[email protected] | b143821 | 2010-04-03 00:30:59 | [diff] [blame] | 248 | using WebKit::WebFormControlElement; |
[email protected] | 979c28b | 2009-11-07 01:30:48 | [diff] [blame] | 249 | using WebKit::WebFormElement; |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 250 | using WebKit::WebFrame; |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 251 | using WebKit::WebGraphicsContext3D; |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 252 | using WebKit::WebHistoryItem; |
[email protected] | 132e281a | 2012-07-31 18:32:44 | [diff] [blame] | 253 | using WebKit::WebHTTPBody; |
[email protected] | 42054a25 | 2011-05-17 18:02:13 | [diff] [blame] | 254 | using WebKit::WebIconURL; |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 255 | using WebKit::WebImage; |
[email protected] | e6efd02 | 2010-03-31 09:34:50 | [diff] [blame] | 256 | using WebKit::WebInputElement; |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 257 | using WebKit::WebIntentRequest; |
| 258 | using WebKit::WebIntentServiceInfo; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 259 | using WebKit::WebMediaPlayer; |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 260 | using WebKit::WebMediaPlayerAction; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 261 | using WebKit::WebMediaPlayerClient; |
[email protected] | 2b942c33 | 2012-04-25 16:26:26 | [diff] [blame] | 262 | using WebKit::WebMouseEvent; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 263 | using WebKit::WebNavigationPolicy; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 264 | using WebKit::WebNavigationType; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 265 | using WebKit::WebNode; |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 266 | using WebKit::WebPageSerializer; |
| 267 | using WebKit::WebPageSerializerClient; |
[email protected] | 50da23d0 | 2012-04-13 17:47:48 | [diff] [blame] | 268 | using WebKit::WebPeerConnection00Handler; |
| 269 | using WebKit::WebPeerConnection00HandlerClient; |
| 270 | using WebKit::WebPeerConnectionHandler; |
| 271 | using WebKit::WebPeerConnectionHandlerClient; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 272 | using WebKit::WebPlugin; |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 273 | using WebKit::WebPluginAction; |
[email protected] | 00152e9 | 2010-07-19 11:47:40 | [diff] [blame] | 274 | using WebKit::WebPluginContainer; |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 275 | using WebKit::WebPluginDocument; |
[email protected] | aad51d1c | 2010-08-05 08:38:09 | [diff] [blame] | 276 | using WebKit::WebPluginParams; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 277 | using WebKit::WebPoint; |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 278 | using WebKit::WebPopupMenuInfo; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 279 | using WebKit::WebRange; |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 280 | using WebKit::WebRect; |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 281 | using WebKit::WebReferrerPolicy; |
[email protected] | 4f99913 | 2009-03-31 18:08:40 | [diff] [blame] | 282 | using WebKit::WebScriptSource; |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 283 | using WebKit::WebSearchableFormData; |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 284 | using WebKit::WebSecurityOrigin; |
[email protected] | 20dc3cad | 2011-04-20 17:27:17 | [diff] [blame] | 285 | using WebKit::WebSecurityPolicy; |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 286 | using WebKit::WebSerializedScriptValue; |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 287 | using WebKit::WebSettings; |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 288 | using WebKit::WebSharedWorker; |
[email protected] | 8649fb3 | 2009-06-26 17:51:02 | [diff] [blame] | 289 | using WebKit::WebSize; |
[email protected] | 5fa3a06 | 2012-03-21 15:39:34 | [diff] [blame] | 290 | using WebKit::WebSocketStreamHandle; |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 291 | using WebKit::WebStorageNamespace; |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 292 | using WebKit::WebStorageQuotaCallbacks; |
| 293 | using WebKit::WebStorageQuotaError; |
| 294 | using WebKit::WebStorageQuotaType; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 295 | using WebKit::WebString; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 296 | using WebKit::WebTextAffinity; |
[email protected] | de570ef | 2009-07-29 18:27:52 | [diff] [blame] | 297 | using WebKit::WebTextDirection; |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 298 | using WebKit::WebTouchEvent; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 299 | using WebKit::WebURL; |
| 300 | using WebKit::WebURLError; |
| 301 | using WebKit::WebURLRequest; |
| 302 | using WebKit::WebURLResponse; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 303 | using WebKit::WebVector; |
[email protected] | 50ae00ef | 2009-10-19 05:11:03 | [diff] [blame] | 304 | using WebKit::WebView; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 305 | using WebKit::WebWidget; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 306 | using WebKit::WebWindowFeatures; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 307 | using appcache::WebApplicationCacheHostImpl; |
| 308 | using base::Time; |
| 309 | using base::TimeDelta; |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 310 | using content::DocumentState; |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 311 | using content::NavigationState; |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 312 | using content::Referrer; |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 313 | using content::RenderThread; |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 314 | using content::RenderViewObserver; |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 315 | using content::RenderViewVisitor; |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 316 | using content::RendererAccessibilityComplete; |
| 317 | using content::RendererAccessibilityFocusOnly; |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 318 | using content::V8ValueConverter; |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 319 | using webkit::forms::FormField; |
| 320 | using webkit::forms::PasswordForm; |
| 321 | using webkit::forms::PasswordFormDomManager; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 322 | using webkit_glue::AltErrorPageResourceFetcher; |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 323 | using webkit_glue::ResourceFetcher; |
[email protected] | 6717bf27 | 2012-05-11 23:31:25 | [diff] [blame] | 324 | using webkit_glue::WebPreferences; |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 325 | using webkit_glue::WebURLResponseExtraDataImpl; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 326 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 327 | #if defined(OS_ANDROID) |
| 328 | using content::AddressDetector; |
| 329 | using content::ContentDetector; |
| 330 | using content::EmailDetector; |
| 331 | using content::PhoneNumberDetector; |
| 332 | using WebKit::WebContentDetectionResult; |
| 333 | using WebKit::WebHitTestResult; |
| 334 | #endif |
| 335 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 336 | //----------------------------------------------------------------------------- |
| 337 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 338 | typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; |
[email protected] | 6de0fd1d | 2011-11-15 13:31:49 | [diff] [blame] | 339 | static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 340 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 341 | // Time, in seconds, we delay before sending content state changes (such as form |
| 342 | // state and scroll position) to the browser. We delay sending changes to avoid |
| 343 | // spamming the browser. |
| 344 | // To avoid having tab/session restore require sending a message to get the |
| 345 | // current content state during tab closing we use a shorter timeout for the |
| 346 | // foreground renderer. This means there is a small window of time from which |
| 347 | // content state is modified and not sent to session restore, but this is |
| 348 | // better than having to wake up all renderers during shutdown. |
| 349 | static const int kDelaySecondsForContentStateSyncHidden = 5; |
| 350 | static const int kDelaySecondsForContentStateSync = 1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 351 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 352 | static const size_t kExtraCharsBeforeAndAfterSelection = 100; |
| 353 | |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 354 | // The maximum number of popups that can be spawned from one page. |
| 355 | static const int kMaximumNumberOfUnacknowledgedPopups = 25; |
| 356 | |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 357 | static const float kScalingIncrement = 0.1f; |
| 358 | |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 359 | static const float kScalingIncrementForGesture = 0.01f; |
| 360 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 361 | #if defined(OS_ANDROID) |
| 362 | // Delay between tapping in content and launching the associated android intent. |
| 363 | // Used to allow users see what has been recognized as content. |
| 364 | static const size_t kContentIntentDelayMilliseconds = 700; |
| 365 | #endif |
| 366 | |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 367 | static RenderViewImpl* FromRoutingID(int32 routing_id) { |
| 368 | return static_cast<RenderViewImpl*>( |
| 369 | ChildThread::current()->ResolveRoute(routing_id)); |
| 370 | } |
| 371 | |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 372 | static WebKit::WebFrame* FindFrameByID(WebKit::WebFrame* root, int frame_id) { |
| 373 | for (WebFrame* frame = root; frame; frame = frame->traverseNext(false)) { |
| 374 | if (frame->identifier() == frame_id) |
| 375 | return frame; |
| 376 | } |
| 377 | return NULL; |
| 378 | } |
| 379 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 380 | static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 381 | WebVector<WebURL> urls; |
| 382 | ds->redirectChain(urls); |
| 383 | result->reserve(urls.size()); |
| 384 | for (size_t i = 0; i < urls.size(); ++i) |
| 385 | result->push_back(urls[i]); |
| 386 | } |
| 387 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 388 | // If |data_source| is non-null and has a DocumentState associated with it, |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 389 | // the AltErrorPageResourceFetcher is reset. |
| 390 | static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
| 391 | if (data_source) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 392 | DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 393 | if (document_state) |
| 394 | document_state->set_alt_error_page_fetcher(NULL); |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 395 | } |
| 396 | } |
| 397 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 398 | static bool IsReload(const ViewMsg_Navigate_Params& params) { |
| 399 | return |
| 400 | params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
[email protected] | 7c16976c | 2012-08-04 02:38:23 | [diff] [blame] | 401 | params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE || |
| 402 | params.navigation_type == |
| 403 | ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL; |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 404 | } |
| 405 | |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 406 | static WebReferrerPolicy GetReferrerPolicyFromRequest( |
[email protected] | ca66282 | 2012-05-11 17:53:59 | [diff] [blame] | 407 | WebFrame* frame, |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 408 | const WebURLRequest& request) { |
| 409 | return request.extraData() ? |
| 410 | static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : |
[email protected] | ca66282 | 2012-05-11 17:53:59 | [diff] [blame] | 411 | frame->document().referrerPolicy(); |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 412 | } |
| 413 | |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 414 | static WebURLResponseExtraDataImpl* GetExtraDataFromResponse( |
| 415 | const WebURLResponse& response) { |
| 416 | return static_cast<WebURLResponseExtraDataImpl*>( |
| 417 | response.extraData()); |
| 418 | } |
| 419 | |
[email protected] | 2149cc62 | 2012-02-14 01:12:12 | [diff] [blame] | 420 | NOINLINE static void CrashIntentionally() { |
| 421 | // NOTE(shess): Crash directly rather than using NOTREACHED() so |
| 422 | // that the signature is easier to triage in crash reports. |
| 423 | volatile int* zero = NULL; |
| 424 | *zero = 0; |
| 425 | } |
| 426 | |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 427 | static void MaybeHandleDebugURL(const GURL& url) { |
| 428 | if (!url.SchemeIs(chrome::kChromeUIScheme)) |
| 429 | return; |
| 430 | if (url == GURL(chrome::kChromeUICrashURL)) { |
[email protected] | 2149cc62 | 2012-02-14 01:12:12 | [diff] [blame] | 431 | CrashIntentionally(); |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 432 | } else if (url == GURL(chrome::kChromeUIKillURL)) { |
| 433 | base::KillProcess(base::GetCurrentProcessHandle(), 1, false); |
| 434 | } else if (url == GURL(chrome::kChromeUIHangURL)) { |
| 435 | for (;;) { |
| 436 | base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 437 | } |
| 438 | } else if (url == GURL(chrome::kChromeUIShorthangURL)) { |
| 439 | base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
| 440 | } |
| 441 | } |
| 442 | |
[email protected] | fd3238af | 2012-05-22 18:55:30 | [diff] [blame] | 443 | // Returns false unless this is a top-level navigation. |
| 444 | static bool IsTopLevelNavigation(WebFrame* frame) { |
| 445 | return frame->parent() == NULL; |
| 446 | } |
| 447 | |
| 448 | // Returns false unless this is a top-level navigation that crosses origins. |
| 449 | static bool IsNonLocalTopLevelNavigation(const GURL& url, |
| 450 | WebFrame* frame, |
| 451 | WebNavigationType type) { |
| 452 | if (!IsTopLevelNavigation(frame)) |
| 453 | return false; |
| 454 | |
| 455 | // Navigations initiated within Webkit are not sent out to the external host |
| 456 | // in the following cases. |
| 457 | // 1. The url scheme is not http/https |
| 458 | // 2. The origin of the url and the opener is the same in which case the |
| 459 | // opener relationship is maintained. |
| 460 | // 3. Reloads/form submits/back forward navigations |
| 461 | if (!url.SchemeIs(chrome::kHttpScheme) && !url.SchemeIs(chrome::kHttpsScheme)) |
| 462 | return false; |
| 463 | |
| 464 | // Not interested in reloads/form submits/resubmits/back forward navigations. |
| 465 | if (type != WebKit::WebNavigationTypeReload && |
| 466 | type != WebKit::WebNavigationTypeFormSubmitted && |
| 467 | type != WebKit::WebNavigationTypeFormResubmitted && |
| 468 | type != WebKit::WebNavigationTypeBackForward) { |
| 469 | // The opener relationship between the new window and the parent allows the |
| 470 | // new window to script the parent and vice versa. This is not allowed if |
| 471 | // the origins of the two domains are different. This can be treated as a |
| 472 | // top level navigation and routed back to the host. |
| 473 | WebKit::WebFrame* opener = frame->opener(); |
| 474 | if (!opener) { |
| 475 | return true; |
| 476 | } |
| 477 | |
| 478 | if (url.GetOrigin() != GURL(opener->document().url()).GetOrigin()) |
| 479 | return true; |
| 480 | } |
| 481 | return false; |
| 482 | } |
| 483 | |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 484 | // Recursively walks the frame tree and serializes it to JSON as described in |
| 485 | // the comment for ViewMsg_UpdateFrameTree. If |exclude_frame_subtree| is not |
| 486 | // NULL, the subtree for the frame is not included in the serialized form. |
| 487 | // This is used when a frame is going to be removed from the tree. |
| 488 | static void ConstructFrameTree(WebKit::WebFrame* frame, |
| 489 | WebKit::WebFrame* exclude_frame_subtree, |
| 490 | base::DictionaryValue* dict) { |
| 491 | dict->SetString(content::kFrameTreeNodeNameKey, |
| 492 | UTF16ToUTF8(frame->assignedName()).c_str()); |
| 493 | dict->SetInteger(content::kFrameTreeNodeIdKey, frame->identifier()); |
| 494 | |
| 495 | WebFrame* child = frame->firstChild(); |
| 496 | ListValue* children = new ListValue(); |
| 497 | for (; child; child = child->nextSibling()) { |
| 498 | if (child == exclude_frame_subtree) |
| 499 | continue; |
| 500 | |
| 501 | base::DictionaryValue* d = new base::DictionaryValue(); |
| 502 | ConstructFrameTree(child, exclude_frame_subtree, d); |
| 503 | children->Append(d); |
| 504 | } |
| 505 | if (children->GetSize() > 0) |
| 506 | dict->Set(content::kFrameTreeNodeSubtreeKey, children); |
| 507 | } |
| 508 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 509 | /////////////////////////////////////////////////////////////////////////////// |
| 510 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 511 | struct RenderViewImpl::PendingFileChooser { |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 512 | PendingFileChooser(const content::FileChooserParams& p, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 513 | WebFileChooserCompletion* c) |
| 514 | : params(p), |
| 515 | completion(c) { |
| 516 | } |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 517 | content::FileChooserParams params; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 518 | WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
| 519 | }; |
| 520 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 521 | namespace { |
| 522 | |
| 523 | class WebWidgetLockTarget : public MouseLockDispatcher::LockTarget { |
| 524 | public: |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 525 | explicit WebWidgetLockTarget(WebKit::WebWidget* webwidget) |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 526 | : webwidget_(webwidget) {} |
| 527 | |
| 528 | virtual void OnLockMouseACK(bool succeeded) OVERRIDE { |
| 529 | if (succeeded) |
| 530 | webwidget_->didAcquirePointerLock(); |
| 531 | else |
| 532 | webwidget_->didNotAcquirePointerLock(); |
| 533 | } |
| 534 | |
| 535 | virtual void OnMouseLockLost() OVERRIDE { |
| 536 | webwidget_->didLosePointerLock(); |
| 537 | } |
| 538 | |
| 539 | virtual bool HandleMouseLockedInputEvent( |
| 540 | const WebKit::WebMouseEvent &event) OVERRIDE { |
| 541 | // The WebWidget handles mouse lock in WebKit's handleInputEvent(). |
| 542 | return false; |
| 543 | } |
| 544 | |
| 545 | private: |
| 546 | WebKit::WebWidget* webwidget_; |
| 547 | }; |
| 548 | |
[email protected] | 86cd947 | 2012-02-03 19:51:05 | [diff] [blame] | 549 | int64 ExtractPostId(const WebHistoryItem& item) { |
| 550 | if (item.isNull()) |
| 551 | return -1; |
| 552 | |
| 553 | if (item.httpBody().isNull()) |
| 554 | return -1; |
| 555 | |
| 556 | return item.httpBody().identifier(); |
| 557 | } |
| 558 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 559 | } // namespace |
| 560 | |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 561 | RenderViewImpl::RenderViewImpl( |
| 562 | gfx::NativeViewId parent_hwnd, |
| 563 | int32 opener_id, |
| 564 | const content::RendererPreferences& renderer_prefs, |
| 565 | const WebPreferences& webkit_prefs, |
| 566 | SharedRenderViewCounter* counter, |
| 567 | int32 routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 568 | int32 surface_id, |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 569 | int64 session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 570 | const string16& frame_name, |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 571 | bool is_renderer_created, |
| 572 | bool swapped_out, |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 573 | int32 next_page_id, |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 574 | const WebKit::WebScreenInfo& screen_info, |
[email protected] | cb25aa1 | 2012-08-07 19:13:43 | [diff] [blame] | 575 | content::old::GuestToEmbedderChannel* guest_to_embedder_channel, |
[email protected] | 3e3c452 | 2012-04-13 21:16:29 | [diff] [blame] | 576 | AccessibilityMode accessibility_mode) |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 577 | : RenderWidget(WebKit::WebPopupTypeNone, screen_info, swapped_out), |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 578 | webkit_preferences_(webkit_prefs), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 579 | send_content_state_immediately_(false), |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 580 | enabled_bindings_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 581 | send_preferred_size_changes_(false), |
[email protected] | 81a3441 | 2009-01-05 19:17:24 | [diff] [blame] | 582 | is_loading_(false), |
[email protected] | e75cb49e | 2009-01-05 23:13:21 | [diff] [blame] | 583 | navigation_gesture_(NavigationGestureUnknown), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 584 | opened_by_user_gesture_(true), |
| 585 | opener_suppressed_(false), |
[email protected] | 81a3441 | 2009-01-05 19:17:24 | [diff] [blame] | 586 | page_id_(-1), |
| 587 | last_page_id_sent_to_browser_(-1), |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 588 | next_page_id_(next_page_id), |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 589 | history_list_offset_(-1), |
| 590 | history_list_length_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 591 | target_url_status_(TARGET_NONE), |
[email protected] | bbef1d3 | 2011-10-25 14:36:55 | [diff] [blame] | 592 | selection_text_offset_(0), |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 593 | cached_is_main_frame_pinned_to_left_(false), |
| 594 | cached_is_main_frame_pinned_to_right_(false), |
| 595 | cached_has_main_frame_horizontal_scrollbar_(false), |
| 596 | cached_has_main_frame_vertical_scrollbar_(false), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 597 | ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 598 | geolocation_dispatcher_(NULL), |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 599 | input_tag_speech_dispatcher_(NULL), |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 600 | speech_recognition_dispatcher_(NULL), |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 601 | device_orientation_dispatcher_(NULL), |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 602 | media_stream_dispatcher_(NULL), |
[email protected] | 1bc65a4 | 2012-04-23 09:31:25 | [diff] [blame] | 603 | media_stream_impl_(NULL), |
[email protected] | cae8c849 | 2011-03-03 11:12:18 | [diff] [blame] | 604 | p2p_socket_dispatcher_(NULL), |
[email protected] | c5c1d6d | 2011-07-28 18:42:41 | [diff] [blame] | 605 | devtools_agent_(NULL), |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 606 | accessibility_mode_(AccessibilityModeOff), |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 607 | renderer_accessibility_(NULL), |
[email protected] | 7e9c5bb0 | 2012-05-14 13:58:31 | [diff] [blame] | 608 | java_bridge_dispatcher_(NULL), |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 609 | mouse_lock_dispatcher_(NULL), |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 610 | #if defined(OS_ANDROID) |
| 611 | expected_content_intent_id_(0), |
| 612 | #endif |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 613 | session_storage_namespace_id_(session_storage_namespace_id), |
[email protected] | ef5e98e | 2011-12-06 09:49:18 | [diff] [blame] | 614 | handling_select_range_(false), |
| 615 | #if defined(OS_WIN) |
| 616 | focused_plugin_id_(-1), |
| 617 | #endif |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 618 | guest_to_embedder_channel_(guest_to_embedder_channel), |
| 619 | guest_pp_instance_(0), |
| 620 | guest_uninitialized_context_(NULL), |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 621 | updating_frame_tree_(false), |
| 622 | pending_frame_tree_update_(false), |
| 623 | target_process_id_(0), |
| 624 | target_routing_id_(0), |
[email protected] | ef5e98e | 2011-12-06 09:49:18 | [diff] [blame] | 625 | ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
[email protected] | ce2b28e | 2012-08-09 15:53:57 | [diff] [blame] | 626 | set_throttle_input_events(renderer_prefs.throttle_input_events); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 627 | routing_id_ = routing_id; |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 628 | surface_id_ = surface_id; |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 629 | if (opener_id != MSG_ROUTING_NONE && is_renderer_created) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 630 | opener_id_ = opener_id; |
| 631 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 632 | // Ensure we start with a valid next_page_id_ from the browser. |
| 633 | DCHECK_GE(next_page_id_, 0); |
| 634 | |
[email protected] | 21b3a6ae | 2011-11-30 00:45:29 | [diff] [blame] | 635 | #if defined(ENABLE_NOTIFICATIONS) |
| 636 | notification_provider_ = new NotificationProvider(this); |
| 637 | #else |
| 638 | notification_provider_ = NULL; |
| 639 | #endif |
| 640 | |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 641 | webwidget_ = WebView::create(this); |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 642 | webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 643 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 644 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 645 | |
| 646 | #if defined(OS_ANDROID) |
| 647 | scoped_ptr<content::DeviceInfo> device_info(new content::DeviceInfo()); |
| 648 | |
| 649 | const std::string region_code = |
| 650 | command_line.HasSwitch(switches::kNetworkCountryIso) |
| 651 | ? command_line.GetSwitchValueASCII(switches::kNetworkCountryIso) |
| 652 | : device_info->GetNetworkCountryIso(); |
| 653 | content_detectors_.push_back(linked_ptr<ContentDetector>( |
| 654 | new AddressDetector())); |
| 655 | content_detectors_.push_back(linked_ptr<ContentDetector>( |
| 656 | new PhoneNumberDetector(region_code))); |
| 657 | content_detectors_.push_back(linked_ptr<ContentDetector>( |
| 658 | new EmailDetector())); |
| 659 | #endif |
| 660 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 661 | if (counter) { |
| 662 | shared_popup_counter_ = counter; |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 663 | // Only count this if it isn't swapped out upon creation. |
| 664 | if (!swapped_out) |
| 665 | shared_popup_counter_->data++; |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 666 | decrement_shared_popup_at_destruction_ = true; |
| 667 | } else { |
| 668 | shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 669 | decrement_shared_popup_at_destruction_ = false; |
| 670 | } |
| 671 | |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 672 | RenderThread::Get()->AddRoute(routing_id_, this); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 673 | // Take a reference on behalf of the RenderThread. This will be balanced |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 674 | // when we receive ViewMsg_ClosePage. |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 675 | AddRef(); |
| 676 | |
| 677 | // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 678 | // completing initialization. Otherwise, we can finish it now. |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 679 | if (!guest_to_embedder_channel && opener_id_ == MSG_ROUTING_NONE) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 680 | did_show_ = true; |
[email protected] | 2d7c855 | 2011-06-27 19:21:55 | [diff] [blame] | 681 | CompleteInit(parent_hwnd); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 682 | } |
| 683 | |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 684 | g_view_map.Get().insert(std::make_pair(webview(), this)); |
[email protected] | 60051ec | 2012-06-08 22:40:57 | [diff] [blame] | 685 | webview()->setDeviceScaleFactor(device_scale_factor_); |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 686 | webkit_preferences_.Apply(webview()); |
| 687 | webview()->initializeMainFrame(this); |
[email protected] | 2024c92 | 2011-09-02 23:34:35 | [diff] [blame] | 688 | if (!frame_name.empty()) |
| 689 | webview()->mainFrame()->setName(frame_name); |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 690 | webview()->settings()->setMinimumTimerInterval( |
| 691 | is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
| 692 | webkit_glue::kForegroundTabTimerInterval); |
| 693 | |
| 694 | OnSetRendererPrefs(renderer_prefs); |
| 695 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 696 | host_window_ = parent_hwnd; |
| 697 | |
[email protected] | 4fb0f20 | 2012-05-30 22:44:53 | [diff] [blame] | 698 | #if defined(ENABLE_WEBRTC) |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 699 | if (!p2p_socket_dispatcher_) |
| 700 | p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
[email protected] | 735873d | 2012-01-25 23:31:02 | [diff] [blame] | 701 | if (!media_stream_dispatcher_) |
| 702 | media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
[email protected] | 5b87e78 | 2012-02-09 18:19:32 | [diff] [blame] | 703 | #endif |
[email protected] | 735873d | 2012-01-25 23:31:02 | [diff] [blame] | 704 | |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 705 | new MHTMLGenerator(this); |
[email protected] | 86a7d3c | 2011-09-12 16:45:32 | [diff] [blame] | 706 | #if defined(OS_MACOSX) |
| 707 | new TextInputClientObserver(this); |
| 708 | #endif // defined(OS_MACOSX) |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 709 | |
[email protected] | 2d7b82c | 2012-06-01 05:57:50 | [diff] [blame] | 710 | #if defined(OS_ANDROID) |
| 711 | media_player_manager_.reset( |
| 712 | new webkit_media::WebMediaPlayerManagerAndroid()); |
| 713 | #endif |
| 714 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 715 | // The next group of objects all implement RenderViewObserver, so are deleted |
| 716 | // along with the RenderView automatically. |
[email protected] | c5c1d6d | 2011-07-28 18:42:41 | [diff] [blame] | 717 | devtools_agent_ = new DevToolsAgent(this); |
[email protected] | 8905450 | 2012-06-03 10:29:24 | [diff] [blame] | 718 | mouse_lock_dispatcher_ = new RenderViewMouseLockDispatcher(this); |
[email protected] | 0fc7dea7 | 2012-02-09 03:47:40 | [diff] [blame] | 719 | intents_host_ = new WebIntentsHost(this); |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 720 | |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 721 | // Create renderer_accessibility_ if needed. |
| 722 | OnSetAccessibilityMode(accessibility_mode); |
| 723 | |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 724 | new IdleUserDetector(this); |
| 725 | |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 726 | if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 727 | enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; |
| 728 | |
[email protected] | 5b52cd2f71 | 2012-03-28 02:12:48 | [diff] [blame] | 729 | ProcessViewLayoutFlags(command_line); |
[email protected] | 7ddea980 | 2012-02-22 23:08:05 | [diff] [blame] | 730 | |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 731 | content::GetContentClient()->renderer()->RenderViewCreated(this); |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 732 | |
| 733 | // If we have an opener_id but we weren't created by a renderer, then |
| 734 | // it's the browser asking us to set our opener to another RenderView. |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 735 | if (opener_id != MSG_ROUTING_NONE && !is_renderer_created) { |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 736 | RenderViewImpl* opener_view = FromRoutingID(opener_id); |
| 737 | if (opener_view) |
| 738 | webview()->mainFrame()->setOpener(opener_view->webview()->mainFrame()); |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 739 | } |
| 740 | |
| 741 | // If we are initially swapped out, navigate to kSwappedOutURL. |
| 742 | // This ensures we are in a unique origin that others cannot script. |
| 743 | if (is_swapped_out_) |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 744 | NavigateToSwappedOutURL(webview()->mainFrame()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 745 | } |
| 746 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 747 | RenderViewImpl::~RenderViewImpl() { |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 748 | history_page_ids_.clear(); |
| 749 | |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 750 | if (decrement_shared_popup_at_destruction_) |
| 751 | shared_popup_counter_->data--; |
| 752 | |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 753 | // If file chooser is still waiting for answer, dispatch empty answer. |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 754 | while (!file_chooser_completions_.empty()) { |
| 755 | if (file_chooser_completions_.front()->completion) { |
| 756 | file_chooser_completions_.front()->completion->didChooseFile( |
| 757 | WebVector<WebString>()); |
| 758 | } |
| 759 | file_chooser_completions_.pop_front(); |
| 760 | } |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 761 | |
[email protected] | 83dde54 | 2009-09-11 20:59:55 | [diff] [blame] | 762 | #if defined(OS_MACOSX) |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 763 | // Destroy all fake plugin window handles on the browser side. |
| 764 | while (!fake_plugin_window_handles_.empty()) { |
| 765 | // Make sure no NULL plugin window handles were inserted into this list. |
| 766 | DCHECK(*fake_plugin_window_handles_.begin()); |
| 767 | // DestroyFakePluginWindowHandle modifies fake_plugin_window_handles_. |
| 768 | DestroyFakePluginWindowHandle(*fake_plugin_window_handles_.begin()); |
| 769 | } |
[email protected] | 83dde54 | 2009-09-11 20:59:55 | [diff] [blame] | 770 | #endif |
[email protected] | 9832489 | 2009-09-09 21:16:05 | [diff] [blame] | 771 | |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 772 | #ifndef NDEBUG |
| 773 | // Make sure we are no longer referenced by the ViewMap. |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 774 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 775 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 776 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
| 777 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 778 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 779 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 780 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 781 | } |
| 782 | |
| 783 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 784 | RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 785 | ViewMap* views = g_view_map.Pointer(); |
| 786 | ViewMap::iterator it = views->find(webview); |
| 787 | return it == views->end() ? NULL : it->second; |
| 788 | } |
| 789 | |
| 790 | /*static*/ |
| 791 | content::RenderView* |
| 792 | content::RenderView::FromWebView(WebKit::WebView* webview) { |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 793 | return RenderViewImpl::FromWebView(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 794 | } |
| 795 | |
| 796 | /*static*/ |
| 797 | void content::RenderView::ForEach(content::RenderViewVisitor* visitor) { |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 798 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 799 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 800 | if (!visitor->Visit(it->second)) |
| 801 | return; |
| 802 | } |
| 803 | } |
| 804 | |
| 805 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 806 | RenderViewImpl* RenderViewImpl::Create( |
[email protected] | 18bcc3c | 2009-01-27 21:39:15 | [diff] [blame] | 807 | gfx::NativeViewId parent_hwnd, |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 808 | int32 opener_id, |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 809 | const content::RendererPreferences& renderer_prefs, |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 810 | const WebPreferences& webkit_prefs, |
| 811 | SharedRenderViewCounter* counter, |
[email protected] | 4e6419c | 2010-01-15 04:50:34 | [diff] [blame] | 812 | int32 routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 813 | int32 surface_id, |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 814 | int64 session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 815 | const string16& frame_name, |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 816 | bool is_renderer_created, |
| 817 | bool swapped_out, |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 818 | int32 next_page_id, |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 819 | const WebKit::WebScreenInfo& screen_info, |
[email protected] | cb25aa1 | 2012-08-07 19:13:43 | [diff] [blame] | 820 | content::old::GuestToEmbedderChannel* guest_to_embedder_channel, |
[email protected] | 3e3c452 | 2012-04-13 21:16:29 | [diff] [blame] | 821 | AccessibilityMode accessibility_mode) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 822 | DCHECK(routing_id != MSG_ROUTING_NONE); |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 823 | return new RenderViewImpl( |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 824 | parent_hwnd, |
| 825 | opener_id, |
| 826 | renderer_prefs, |
| 827 | webkit_prefs, |
| 828 | counter, |
| 829 | routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 830 | surface_id, |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 831 | session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 832 | frame_name, |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 833 | is_renderer_created, |
| 834 | swapped_out, |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 835 | next_page_id, |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 836 | screen_info, |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 837 | guest_to_embedder_channel, |
[email protected] | 3e3c452 | 2012-04-13 21:16:29 | [diff] [blame] | 838 | accessibility_mode); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 839 | } |
| 840 | |
[email protected] | 50da23d0 | 2012-04-13 17:47:48 | [diff] [blame] | 841 | WebPeerConnection00Handler* RenderViewImpl::CreatePeerConnectionHandlerJsep( |
| 842 | WebPeerConnection00HandlerClient* client) { |
| 843 | EnsureMediaStreamImpl(); |
[email protected] | 1bc65a4 | 2012-04-23 09:31:25 | [diff] [blame] | 844 | if (!media_stream_impl_) |
[email protected] | 50da23d0 | 2012-04-13 17:47:48 | [diff] [blame] | 845 | return NULL; |
| 846 | return media_stream_impl_->CreatePeerConnectionHandlerJsep(client); |
| 847 | } |
| 848 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 849 | void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 850 | observers_.AddObserver(observer); |
| 851 | } |
| 852 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 853 | void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 854 | observer->RenderViewGone(); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 855 | observers_.RemoveObserver(observer); |
| 856 | } |
| 857 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 858 | WebKit::WebView* RenderViewImpl::webview() const { |
[email protected] | 4d51d5bf | 2010-07-26 18:48:26 | [diff] [blame] | 859 | return static_cast<WebKit::WebView*>(webwidget()); |
| 860 | } |
| 861 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 862 | void RenderViewImpl::SetReportLoadProgressEnabled(bool enabled) { |
[email protected] | 1a3c3cb | 2010-12-16 21:03:40 | [diff] [blame] | 863 | if (!enabled) { |
| 864 | load_progress_tracker_.reset(NULL); |
| 865 | return; |
| 866 | } |
| 867 | if (load_progress_tracker_ == NULL) |
| 868 | load_progress_tracker_.reset(new LoadProgressTracker(this)); |
| 869 | } |
| 870 | |
[email protected] | cb25aa1 | 2012-08-07 19:13:43 | [diff] [blame] | 871 | content::old::GuestToEmbedderChannel* |
[email protected] | 7900bfdb | 2012-05-24 19:31:24 | [diff] [blame] | 872 | RenderViewImpl::GetGuestToEmbedderChannel() const { |
| 873 | return guest_to_embedder_channel_; |
| 874 | } |
| 875 | |
| 876 | void RenderViewImpl::SetGuestToEmbedderChannel( |
[email protected] | cb25aa1 | 2012-08-07 19:13:43 | [diff] [blame] | 877 | content::old::GuestToEmbedderChannel* channel) { |
[email protected] | 7900bfdb | 2012-05-24 19:31:24 | [diff] [blame] | 878 | guest_to_embedder_channel_ = channel; |
| 879 | } |
| 880 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 881 | void RenderViewImpl::PluginCrashed(const FilePath& plugin_path) { |
[email protected] | a3a8fb6d | 2009-10-22 20:12:51 | [diff] [blame] | 882 | Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 883 | } |
| 884 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 885 | void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 886 | plugin_delegates_.insert(delegate); |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 887 | // If the renderer is visible, set initial visibility and focus state. |
| 888 | if (!is_hidden()) { |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 889 | #if defined(OS_MACOSX) |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 890 | delegate->SetContainerVisibility(true); |
| 891 | if (webview() && webview()->isActive()) |
| 892 | delegate->SetWindowFocus(true); |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 893 | #endif |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 894 | } |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 895 | // Plugins start assuming the content has focus (so that they work in |
| 896 | // environments where RenderView isn't hosting them), so we always have to |
| 897 | // set the initial state. See webplugin_delegate_impl.h for details. |
| 898 | delegate->SetContentAreaFocus(has_focus()); |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 899 | } |
| 900 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 901 | void RenderViewImpl::UnregisterPluginDelegate( |
| 902 | WebPluginDelegateProxy* delegate) { |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 903 | plugin_delegates_.erase(delegate); |
| 904 | } |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 905 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 906 | bool RenderViewImpl::GetPluginInfo(const GURL& url, |
| 907 | const GURL& page_url, |
| 908 | const std::string& mime_type, |
| 909 | webkit::WebPluginInfo* plugin_info, |
| 910 | std::string* actual_mime_type) { |
[email protected] | 4a7d639 | 2011-09-19 20:55:08 | [diff] [blame] | 911 | bool found = false; |
| 912 | Send(new ViewHostMsg_GetPluginInfo( |
| 913 | routing_id_, url, page_url, mime_type, &found, plugin_info, |
| 914 | actual_mime_type)); |
| 915 | return found; |
| 916 | } |
| 917 | |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 918 | void RenderViewImpl::TransferActiveWheelFlingAnimation( |
| 919 | const WebKit::WebActiveWheelFlingParameters& params) { |
| 920 | if (webview()) |
| 921 | webview()->transferActiveWheelFlingAnimation(params); |
| 922 | } |
| 923 | |
[email protected] | 8fe8f74 | 2012-06-14 00:36:08 | [diff] [blame] | 924 | bool RenderViewImpl::HasIMETextFocus() { |
| 925 | return GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE; |
| 926 | } |
| 927 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 928 | bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 929 | WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
[email protected] | a9f607e | 2009-10-23 19:59:27 | [diff] [blame] | 930 | if (main_frame) |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 931 | content::GetContentClient()->SetActiveURL(main_frame->document().url()); |
[email protected] | f8b6b6f | 2009-03-10 16:48:26 | [diff] [blame] | 932 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 933 | ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| 934 | RenderViewObserver* observer; |
| 935 | while ((observer = it.GetNext()) != NULL) |
| 936 | if (observer->OnMessageReceived(message)) |
| 937 | return true; |
[email protected] | b2abac7 | 2009-02-26 12:39:28 | [diff] [blame] | 938 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 939 | bool handled = true; |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 940 | bool msg_is_ok = true; |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 941 | IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 942 | IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
| 943 | IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
[email protected] | 1dda402 | 2010-01-28 18:24:56 | [diff] [blame] | 944 | IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 945 | IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) |
| 946 | IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) |
| 947 | IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
| 948 | IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 949 | #if defined(OS_MACOSX) |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 950 | IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 951 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 952 | IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) |
[email protected] | 44bf700 | 2011-10-16 02:46:15 | [diff] [blame] | 953 | IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 954 | IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) |
| 955 | IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
| 956 | IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 957 | IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 958 | IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
[email protected] | 4b59ae60 | 2009-06-23 20:58:15 | [diff] [blame] | 959 | IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 960 | IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 961 | IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
[email protected] | 630e26b | 2008-10-14 22:55:17 | [diff] [blame] | 962 | IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
[email protected] | d0b8d09 | 2010-10-25 04:05:17 | [diff] [blame] | 963 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 964 | IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 965 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 966 | OnSetZoomLevelForLoadingURL) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 967 | IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
[email protected] | a697f4c | 2009-09-14 22:30:18 | [diff] [blame] | 968 | IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 969 | OnResetPageEncodingToDefault) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 970 | IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 971 | IPC_MESSAGE_HANDLER(ViewMsg_PostMessageEvent, OnPostMessageEvent) |
[email protected] | 1810e13 | 2009-03-24 23:35:48 | [diff] [blame] | 972 | IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 973 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 974 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 975 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 976 | IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
| 977 | IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) |
| 978 | IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
| 979 | OnDragSourceSystemDragEnded) |
[email protected] | 18cb257 | 2008-08-21 20:34:45 | [diff] [blame] | 980 | IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
[email protected] | d098079 | 2011-02-13 19:41:40 | [diff] [blame] | 981 | IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 982 | IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
[email protected] | 333ec8d0 | 2011-09-16 18:59:19 | [diff] [blame] | 983 | IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, |
| 984 | OnScrollFocusedEditableNodeIntoRect) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 985 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 986 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
| 987 | IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 988 | IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 989 | OnEnumerateDirectoryResponse) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 990 | IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
[email protected] | 9b18a84f | 2010-06-10 15:54:04 | [diff] [blame] | 991 | IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 992 | IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 993 | IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 994 | IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 995 | IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
| 996 | OnDisassociateFromPopupCount) |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 997 | IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 998 | IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode) |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 999 | IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) |
[email protected] | ab32b16c | 2009-10-16 14:57:25 | [diff] [blame] | 1000 | IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 1001 | OnEnablePreferredSizeChangedMode) |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 1002 | IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 1003 | IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 1004 | IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 1005 | OnDisableScrollbarsForSmallWindows) |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 1006 | IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 1007 | IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
[email protected] | 7782964 | 2012-05-15 14:47:17 | [diff] [blame] | 1008 | IPC_MESSAGE_HANDLER(ViewMsg_OrientationChangeEvent, |
| 1009 | OnOrientationChangeEvent) |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 1010 | IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 1011 | IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
[email protected] | 7a17bac0 | 2012-03-07 21:58:12 | [diff] [blame] | 1012 | IPC_MESSAGE_HANDLER(ViewMsg_SetNavigationStartTime, |
| 1013 | OnSetNavigationStartTime) |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 1014 | #if defined(OS_MACOSX) |
| 1015 | IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 1016 | IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 1017 | IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
| 1018 | OnPluginImeCompositionCompleted) |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 1019 | #endif |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 1020 | IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 1021 | OnSetEditCommandsForNextKeyEvent) |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 1022 | IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
| 1023 | OnCustomContextMenuAction) |
[email protected] | 27a9ef3 | 2010-09-10 04:06:24 | [diff] [blame] | 1024 | IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
[email protected] | eb415bf0e | 2011-04-14 02:45:42 | [diff] [blame] | 1025 | IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, |
| 1026 | OnPpapiBrokerChannelCreated) |
[email protected] | d8415ad9 | 2012-08-23 14:40:50 | [diff] [blame] | 1027 | IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerPermissionResult, |
| 1028 | OnPpapiBrokerPermissionResult) |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 1029 | IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
| 1030 | OnGetAllSavableResourceLinksForCurrentPage) |
| 1031 | IPC_MESSAGE_HANDLER( |
| 1032 | ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
| 1033 | OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 1034 | #if defined(OS_MACOSX) |
| 1035 | IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 1036 | #elif defined(OS_ANDROID) |
| 1037 | IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 1038 | #endif |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 1039 | IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
[email protected] | f055793 | 2011-01-25 20:20:51 | [diff] [blame] | 1040 | // TODO(viettrungluu): Move to a separate message filter. |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1041 | #if defined(OS_MACOSX) |
| 1042 | IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 1043 | #endif |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1044 | IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 1045 | OnSetHistoryLengthAndPrune) |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 1046 | IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 1047 | IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 1048 | IPC_MESSAGE_HANDLER(ViewMsg_SetAccessibilityMode, OnSetAccessibilityMode) |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 1049 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateFrameTree, OnUpdatedFrameTree) |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1050 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1051 | // Have the super handle all other messages. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1052 | IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1053 | IPC_END_MESSAGE_MAP() |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 1054 | |
| 1055 | if (!msg_is_ok) { |
| 1056 | // The message had a handler, but its deserialization failed. |
| 1057 | // Kill the renderer to avoid potential spoofing attacks. |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1058 | CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 1059 | } |
| 1060 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 1061 | return handled; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1062 | } |
| 1063 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1064 | void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
[email protected] | 7900bfdb | 2012-05-24 19:31:24 | [diff] [blame] | 1065 | // If we don't have guest-to-embedder channel associated with this RenderView |
| 1066 | // but we need one, grab one now. |
| 1067 | if (!params.embedder_channel_name.empty() && !GetGuestToEmbedderChannel()) { |
[email protected] | cb25aa1 | 2012-08-07 19:13:43 | [diff] [blame] | 1068 | content::old::GuestToEmbedderChannel* embedder_channel = |
[email protected] | 7900bfdb | 2012-05-24 19:31:24 | [diff] [blame] | 1069 | RenderThreadImpl::current()->browser_plugin_channel_manager()-> |
| 1070 | GetChannelByName(params.embedder_channel_name); |
| 1071 | DCHECK(embedder_channel); |
| 1072 | SetGuestToEmbedderChannel(embedder_channel); |
| 1073 | host_window_set_ = false; |
| 1074 | // TODO(fsamuel): This is test code. Need to find a better way to tell |
| 1075 | // a WebView to drop its context. This needs to change in |
| 1076 | // GuestToEmbedderChannel::OnContextLost. |
| 1077 | GetWebView()->loseCompositorContext(1); |
| 1078 | RenderThreadImpl::current()->browser_plugin_channel_manager()-> |
| 1079 | ReportChannelToEmbedder(this, |
| 1080 | embedder_channel->embedder_channel_handle(), |
| 1081 | params.embedder_channel_name, |
| 1082 | params.embedder_container_id); |
| 1083 | } |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 1084 | MaybeHandleDebugURL(params.url); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1085 | if (!webview()) |
| 1086 | return; |
| 1087 | |
[email protected] | 440a0e5 | 2011-09-13 17:38:58 | [diff] [blame] | 1088 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
| 1089 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1090 | bool is_reload = IsReload(params); |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 1091 | |
| 1092 | // If this is a stale back/forward (due to a recent navigation the browser |
| 1093 | // didn't know about), ignore it. |
| 1094 | if (IsBackForwardToStaleEntry(params, is_reload)) |
| 1095 | return; |
| 1096 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 1097 | // Swap this renderer back in if necessary. |
[email protected] | 961541a9 | 2012-06-01 21:15:28 | [diff] [blame] | 1098 | if (is_swapped_out_) { |
| 1099 | // We marked the view as hidden when swapping the view out, so be sure to |
| 1100 | // reset the visibility state before navigating to the new URL. |
| 1101 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 1102 | SetSwappedOut(false); |
[email protected] | 961541a9 | 2012-06-01 21:15:28 | [diff] [blame] | 1103 | } |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 1104 | |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1105 | history_list_offset_ = params.current_history_list_offset; |
| 1106 | history_list_length_ = params.current_history_list_length; |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 1107 | if (history_list_length_ >= 0) |
| 1108 | history_page_ids_.resize(history_list_length_, -1); |
| 1109 | if (params.pending_history_list_offset >= 0 && |
| 1110 | params.pending_history_list_offset < history_list_length_) |
| 1111 | history_page_ids_[params.pending_history_list_offset] = params.page_id; |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1112 | |
[email protected] | 38b59290 | 2011-04-16 02:08:42 | [diff] [blame] | 1113 | content::GetContentClient()->SetActiveURL(params.url); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1114 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1115 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1116 | if (is_reload && main_frame->currentHistoryItem().isNull()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1117 | // We cannot reload if we do not have any history state. This happens, for |
| 1118 | // example, when recovering from a crash. Our workaround here is a bit of |
| 1119 | // a hack since it means that reload after a crashed tab does not cause an |
| 1120 | // end-to-end cache validation. |
| 1121 | is_reload = false; |
| 1122 | } |
| 1123 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1124 | pending_navigation_params_.reset(new ViewMsg_Navigate_Params); |
| 1125 | *pending_navigation_params_.get() = params; |
[email protected] | 48a5c77 | 2011-04-18 23:50:50 | [diff] [blame] | 1126 | |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 1127 | // If we are reloading, then WebKit will use the history state of the current |
| 1128 | // page, so we should just ignore any given history state. Otherwise, if we |
| 1129 | // have history state, then we need to navigate to it, which corresponds to a |
| 1130 | // back/forward navigation event. |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 1131 | if (is_reload) { |
[email protected] | 7c16976c | 2012-08-04 02:38:23 | [diff] [blame] | 1132 | bool reload_original_url = |
| 1133 | (params.navigation_type == |
| 1134 | ViewMsg_Navigate_Type::RELOAD_ORIGINAL_REQUEST_URL); |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 1135 | bool ignore_cache = (params.navigation_type == |
[email protected] | 2c556966 | 2011-03-22 20:45:02 | [diff] [blame] | 1136 | ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
[email protected] | 7c16976c | 2012-08-04 02:38:23 | [diff] [blame] | 1137 | |
| 1138 | if (reload_original_url) |
| 1139 | main_frame->reloadWithOverrideURL(params.url, true); |
| 1140 | else |
| 1141 | main_frame->reload(ignore_cache); |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 1142 | } else if (!params.state.empty()) { |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 1143 | // We must know the page ID of the page we are navigating back to. |
[email protected] | f929f2f2 | 2009-06-12 16:56:58 | [diff] [blame] | 1144 | DCHECK_NE(params.page_id, -1); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1145 | main_frame->loadHistoryItem( |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1146 | webkit_glue::HistoryItemFromString(params.state)); |
[email protected] | d1ef81d | 2012-07-24 11:39:36 | [diff] [blame] | 1147 | } else if (!params.base_url_for_data_url.is_empty()) { |
| 1148 | // A loadData request with a specified base URL. |
| 1149 | std::string mime_type, charset, data; |
| 1150 | if (net::DataURL::Parse(params.url, &mime_type, &charset, &data)) { |
| 1151 | main_frame->loadData( |
| 1152 | WebData(data.c_str(), data.length()), |
| 1153 | WebString::fromUTF8(mime_type), |
| 1154 | WebString::fromUTF8(charset), |
| 1155 | params.base_url_for_data_url, |
| 1156 | params.history_url_for_data_url, |
| 1157 | false); |
| 1158 | } else { |
| 1159 | CHECK(false) << |
| 1160 | "Invalid URL passed: " << params.url.possibly_invalid_spec(); |
| 1161 | } |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 1162 | } else { |
| 1163 | // Navigate to the given URL. |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1164 | WebURLRequest request(params.url); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1165 | |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 1166 | // A session history navigation should have been accompanied by state. |
[email protected] | cbc0cb7 | 2011-12-06 18:58:23 | [diff] [blame] | 1167 | CHECK_EQ(params.page_id, -1); |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 1168 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1169 | if (main_frame->isViewSourceModeEnabled()) |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 1170 | request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 1171 | |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1172 | if (params.referrer.url.is_valid()) { |
| 1173 | WebString referrer = WebSecurityPolicy::generateReferrerHeader( |
| 1174 | params.referrer.policy, |
| 1175 | params.url, |
| 1176 | WebString::fromUTF8(params.referrer.url.spec())); |
| 1177 | if (!referrer.isEmpty()) |
| 1178 | request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1179 | } |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 1180 | |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 1181 | if (!params.extra_headers.empty()) { |
| 1182 | for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
| 1183 | params.extra_headers.end(), "\n"); |
| 1184 | i.GetNext(); ) { |
| 1185 | request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
| 1186 | WebString::fromUTF8(i.values())); |
| 1187 | } |
| 1188 | } |
[email protected] | 132e281a | 2012-07-31 18:32:44 | [diff] [blame] | 1189 | |
| 1190 | if (params.is_post) { |
| 1191 | request.setHTTPMethod(WebString::fromUTF8("POST")); |
| 1192 | |
| 1193 | // Set post data. |
| 1194 | WebHTTPBody http_body; |
| 1195 | http_body.initialize(); |
| 1196 | http_body.appendData(WebData( |
| 1197 | reinterpret_cast<const char*>( |
| 1198 | ¶ms.browser_initiated_post_data.front()), |
| 1199 | params.browser_initiated_post_data.size())); |
| 1200 | request.setHTTPBody(http_body); |
| 1201 | } |
| 1202 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1203 | main_frame->loadRequest(request); |
[email protected] | c058805 | 2008-10-27 23:01:50 | [diff] [blame] | 1204 | } |
| 1205 | |
[email protected] | 77f17a8 | 2009-05-21 04:42:54 | [diff] [blame] | 1206 | // In case LoadRequest failed before DidCreateDataSource was called. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1207 | pending_navigation_params_.reset(); |
[email protected] | e7ca289 | 2012-09-01 00:52:15 | [diff] [blame] | 1208 | |
| 1209 | UNSHIPPED_TRACE_EVENT_INSTANT0("test_tracing", "RenderViewImpl::OnNavigate"); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1210 | } |
| 1211 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1212 | bool RenderViewImpl::IsBackForwardToStaleEntry( |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 1213 | const ViewMsg_Navigate_Params& params, |
| 1214 | bool is_reload) { |
| 1215 | // Make sure this isn't a back/forward to an entry we have already cropped |
| 1216 | // or replaced from our history, before the browser knew about it. If so, |
| 1217 | // a new navigation has committed in the mean time, and we can ignore this. |
| 1218 | bool is_back_forward = !is_reload && !params.state.empty(); |
| 1219 | |
| 1220 | // Note: if the history_list_length_ is 0 for a back/forward, we must be |
| 1221 | // restoring from a previous session. We'll update our state in OnNavigate. |
| 1222 | if (!is_back_forward || history_list_length_ <= 0) |
| 1223 | return false; |
| 1224 | |
| 1225 | DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); |
| 1226 | |
| 1227 | // Check for whether the forward history has been cropped due to a recent |
| 1228 | // navigation the browser didn't know about. |
| 1229 | if (params.pending_history_list_offset >= history_list_length_) |
| 1230 | return true; |
| 1231 | |
| 1232 | // Check for whether this entry has been replaced with a new one. |
| 1233 | int expected_page_id = |
| 1234 | history_page_ids_[params.pending_history_list_offset]; |
[email protected] | 9978b8f0 | 2011-08-13 16:17:44 | [diff] [blame] | 1235 | if (expected_page_id > 0 && params.page_id != expected_page_id) { |
| 1236 | if (params.page_id < expected_page_id) |
| 1237 | return true; |
| 1238 | |
| 1239 | // Otherwise we've removed an earlier entry and should have shifted all |
| 1240 | // entries left. For now, it's ok to lazily update the list. |
| 1241 | // TODO(creis): Notify all live renderers when we remove entries from |
| 1242 | // the front of the list, so that we don't hit this case. |
| 1243 | history_page_ids_[params.pending_history_list_offset] = params.page_id; |
| 1244 | } |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 1245 | |
| 1246 | return false; |
| 1247 | } |
| 1248 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1249 | // Stop loading the current page |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1250 | void RenderViewImpl::OnStop() { |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 1251 | if (webview()) { |
| 1252 | WebFrame* main_frame = webview()->mainFrame(); |
| 1253 | // Stop the alt error page fetcher. If we let it continue it may complete |
| 1254 | // and cause RenderViewHostManager to swap to this RenderView, even though |
| 1255 | // it may no longer be active. |
| 1256 | StopAltErrorPageFetcher(main_frame->provisionalDataSource()); |
| 1257 | StopAltErrorPageFetcher(main_frame->dataSource()); |
| 1258 | main_frame->stopLoading(); |
| 1259 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1260 | } |
| 1261 | |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 1262 | // Reload current focused frame. |
| 1263 | // E.g. called by right-clicking on the frame and picking "reload this frame". |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1264 | void RenderViewImpl::OnReloadFrame() { |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 1265 | if (webview() && webview()->focusedFrame()) { |
| 1266 | // We always obey the cache (ignore_cache=false) here. |
| 1267 | // TODO(evanm): perhaps we could allow shift-clicking the menu item to do |
| 1268 | // a cache-ignoring reload of the frame. |
| 1269 | webview()->focusedFrame()->reload(false); |
| 1270 | } |
[email protected] | 1dda402 | 2010-01-28 18:24:56 | [diff] [blame] | 1271 | } |
| 1272 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1273 | void RenderViewImpl::OnCopyImageAt(int x, int y) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1274 | webview()->copyImageAt(WebPoint(x, y)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1275 | } |
| 1276 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1277 | void RenderViewImpl::OnExecuteEditCommand(const std::string& name, |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 1278 | const std::string& value) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1279 | if (!webview() || !webview()->focusedFrame()) |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 1280 | return; |
| 1281 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1282 | webview()->focusedFrame()->executeCommand( |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1283 | WebString::fromUTF8(name), WebString::fromUTF8(value)); |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 1284 | } |
| 1285 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1286 | void RenderViewImpl::OnUpdateTargetURLAck() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1287 | // Check if there is a targeturl waiting to be sent. |
| 1288 | if (target_url_status_ == TARGET_PENDING) { |
| 1289 | Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, |
| 1290 | pending_target_url_)); |
| 1291 | } |
| 1292 | |
| 1293 | target_url_status_ = TARGET_NONE; |
| 1294 | } |
| 1295 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1296 | void RenderViewImpl::OnUndo() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1297 | if (!webview()) |
| 1298 | return; |
| 1299 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1300 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1301 | } |
| 1302 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1303 | void RenderViewImpl::OnRedo() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1304 | if (!webview()) |
| 1305 | return; |
| 1306 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1307 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1308 | } |
| 1309 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1310 | void RenderViewImpl::OnCut() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1311 | if (!webview()) |
| 1312 | return; |
| 1313 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1314 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1315 | } |
| 1316 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1317 | void RenderViewImpl::OnCopy() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1318 | if (!webview()) |
| 1319 | return; |
| 1320 | |
[email protected] | f6b1856b | 2011-06-29 22:02:53 | [diff] [blame] | 1321 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"), |
| 1322 | context_menu_node_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1323 | } |
| 1324 | |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 1325 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1326 | void RenderViewImpl::OnCopyToFindPboard() { |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1327 | if (!webview()) |
| 1328 | return; |
| 1329 | |
| 1330 | // Since the find pasteboard supports only plain text, this can be simpler |
| 1331 | // than the |OnCopy()| case. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1332 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1333 | if (frame->hasSelection()) { |
| 1334 | string16 selection = frame->selectionAsText(); |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1335 | RenderThread::Get()->Send( |
[email protected] | 7e358974 | 2011-03-10 18:49:17 | [diff] [blame] | 1336 | new ClipboardHostMsg_FindPboardWriteStringAsync(selection)); |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1337 | } |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1338 | } |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 1339 | #endif |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1340 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1341 | void RenderViewImpl::OnPaste() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1342 | if (!webview()) |
| 1343 | return; |
| 1344 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1345 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1346 | } |
| 1347 | |
[email protected] | 44bf700 | 2011-10-16 02:46:15 | [diff] [blame] | 1348 | void RenderViewImpl::OnPasteAndMatchStyle() { |
| 1349 | if (!webview()) |
| 1350 | return; |
| 1351 | |
| 1352 | webview()->focusedFrame()->executeCommand( |
| 1353 | WebString::fromUTF8("PasteAndMatchStyle")); |
| 1354 | } |
| 1355 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1356 | void RenderViewImpl::OnReplace(const string16& text) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1357 | if (!webview()) |
| 1358 | return; |
| 1359 | |
[email protected] | 1ff7a03 | 2010-02-03 02:46:03 | [diff] [blame] | 1360 | WebFrame* frame = webview()->focusedFrame(); |
| 1361 | if (!frame->hasSelection()) |
| 1362 | frame->selectWordAroundCaret(); |
| 1363 | frame->replaceSelection(text); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1364 | } |
| 1365 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1366 | void RenderViewImpl::OnDelete() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1367 | if (!webview()) |
| 1368 | return; |
| 1369 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1370 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1371 | } |
| 1372 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1373 | void RenderViewImpl::OnSelectAll() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1374 | if (!webview()) |
| 1375 | return; |
| 1376 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1377 | webview()->focusedFrame()->executeCommand( |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 1378 | WebString::fromUTF8("SelectAll")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1379 | } |
| 1380 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1381 | void RenderViewImpl::OnSelectRange(const gfx::Point& start, |
| 1382 | const gfx::Point& end) { |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1383 | if (!webview()) |
| 1384 | return; |
| 1385 | |
[email protected] | c95e53ad | 2012-08-13 17:56:16 | [diff] [blame] | 1386 | Send(new ViewHostMsg_SelectRange_ACK(routing_id_)); |
| 1387 | |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1388 | handling_select_range_ = true; |
| 1389 | webview()->focusedFrame()->selectRange(start, end); |
| 1390 | handling_select_range_ = false; |
| 1391 | } |
| 1392 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1393 | void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, |
| 1394 | int32 minimum_page_id) { |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 1395 | DCHECK_GE(history_length, 0); |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1396 | DCHECK(history_list_offset_ == history_list_length_ - 1); |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 1397 | DCHECK_GE(minimum_page_id, -1); |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1398 | |
| 1399 | // Generate the new list. |
| 1400 | std::vector<int32> new_history_page_ids(history_length, -1); |
| 1401 | for (size_t i = 0; i < history_page_ids_.size(); ++i) { |
| 1402 | if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) |
| 1403 | continue; |
| 1404 | new_history_page_ids.push_back(history_page_ids_[i]); |
| 1405 | } |
| 1406 | new_history_page_ids.swap(history_page_ids_); |
| 1407 | |
| 1408 | // Update indexes. |
| 1409 | history_list_length_ = history_page_ids_.size(); |
| 1410 | history_list_offset_ = history_list_length_ - 1; |
| 1411 | } |
| 1412 | |
| 1413 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1414 | void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1415 | if (!webview()) |
| 1416 | return; |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1417 | webview()->setInitialFocus(reverse); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1418 | } |
| 1419 | |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1420 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1421 | void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) { |
[email protected] | 4274b3e | 2011-08-09 19:09:33 | [diff] [blame] | 1422 | if (!webview()) |
| 1423 | return; |
| 1424 | if (in_live_resize) |
| 1425 | webview()->willStartLiveResize(); |
| 1426 | else |
| 1427 | webview()->willEndLiveResize(); |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1428 | } |
| 1429 | #endif |
| 1430 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1431 | void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1432 | const gfx::Rect& rect) { |
[email protected] | 13a1e4c3c | 2011-02-03 21:07:09 | [diff] [blame] | 1433 | WebKit::WebNode node = GetFocusedNode(); |
| 1434 | if (!node.isNull()) { |
| 1435 | if (IsEditableNode(node)) |
[email protected] | 333ec8d0 | 2011-09-16 18:59:19 | [diff] [blame] | 1436 | webview()->scrollFocusedNodeIntoRect(rect); |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 1437 | } |
| 1438 | } |
| 1439 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1440 | /////////////////////////////////////////////////////////////////////////////// |
| 1441 | |
| 1442 | // Tell the embedding application that the URL of the active page has changed |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1443 | void RenderViewImpl::UpdateURL(WebFrame* frame) { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1444 | WebDataSource* ds = frame->dataSource(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1445 | DCHECK(ds); |
| 1446 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1447 | const WebURLRequest& request = ds->request(); |
| 1448 | const WebURLRequest& original_request = ds->originalRequest(); |
| 1449 | const WebURLResponse& response = ds->response(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1450 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1451 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 1452 | NavigationState* navigation_state = document_state->navigation_state(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1453 | |
| 1454 | ViewHostMsg_FrameNavigate_Params params; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1455 | params.http_status_code = response.httpStatusCode(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1456 | params.is_post = false; |
[email protected] | 86cd947 | 2012-02-03 19:51:05 | [diff] [blame] | 1457 | params.post_id = -1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1458 | params.page_id = page_id_; |
[email protected] | dabb0d1 | 2010-10-05 12:50:07 | [diff] [blame] | 1459 | params.frame_id = frame->identifier(); |
[email protected] | 6d81b48 | 2011-02-22 19:47:19 | [diff] [blame] | 1460 | params.socket_address.set_host(response.remoteIPAddress().utf8()); |
| 1461 | params.socket_address.set_port(response.remotePort()); |
[email protected] | b9a7c6d4 | 2011-02-25 02:13:03 | [diff] [blame] | 1462 | params.was_fetched_via_proxy = response.wasFetchedViaProxy(); |
[email protected] | af15bed | 2010-08-25 21:12:09 | [diff] [blame] | 1463 | params.was_within_same_page = navigation_state->was_within_same_page(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1464 | if (!document_state->security_info().empty()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1465 | // SSL state specified in the request takes precedence over the one in the |
| 1466 | // response. |
| 1467 | // So far this is only intended for error pages that are not expected to be |
| 1468 | // over ssl, so we should not get any clash. |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1469 | DCHECK(response.securityInfo().isEmpty()); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1470 | params.security_info = document_state->security_info(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1471 | } else { |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1472 | params.security_info = response.securityInfo(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1473 | } |
| 1474 | |
| 1475 | // Set the URL to be displayed in the browser UI to the user. |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 1476 | params.url = GetLoadingUrl(frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1477 | |
[email protected] | 5f9b871 | 2011-11-23 08:55:57 | [diff] [blame] | 1478 | if (frame->document().baseURL() != params.url) |
| 1479 | params.base_url = frame->document().baseURL(); |
| 1480 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1481 | GetRedirectChain(ds, ¶ms.redirects); |
[email protected] | d94dc1e | 2010-03-04 09:29:24 | [diff] [blame] | 1482 | params.should_update_history = !ds->hasUnreachableURL() && |
[email protected] | b7df1b7 | 2011-02-10 00:08:04 | [diff] [blame] | 1483 | !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1484 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1485 | params.searchable_form_url = document_state->searchable_form_url(); |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 1486 | params.searchable_form_encoding = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1487 | document_state->searchable_form_encoding(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1488 | |
| 1489 | const PasswordForm* password_form_data = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1490 | document_state->password_form_data(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1491 | if (password_form_data) |
| 1492 | params.password_form = *password_form_data; |
| 1493 | |
| 1494 | params.gesture = navigation_gesture_; |
| 1495 | navigation_gesture_ = NavigationGestureUnknown; |
| 1496 | |
[email protected] | 0f38dc455 | 2011-02-25 11:24:00 | [diff] [blame] | 1497 | // Make navigation state a part of the FrameNavigate message so that commited |
| 1498 | // entry had it at all times. |
| 1499 | const WebHistoryItem& item = frame->currentHistoryItem(); |
| 1500 | if (!item.isNull()) { |
| 1501 | params.content_state = webkit_glue::HistoryItemToString(item); |
| 1502 | } else { |
| 1503 | params.content_state = |
| 1504 | webkit_glue::CreateHistoryStateForURL(GURL(request.url())); |
| 1505 | } |
| 1506 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1507 | if (!frame->parent()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1508 | // Top-level navigation. |
| 1509 | |
[email protected] | d00a797 | 2012-08-07 06:09:58 | [diff] [blame] | 1510 | // Reset the zoom limits in case a plugin had changed them previously. This |
| 1511 | // will also call us back which will cause us to send a message to |
| 1512 | // update WebContentsImpl. |
| 1513 | webview()->zoomLimitsChanged( |
| 1514 | WebView::zoomFactorToZoomLevel(content::kMinimumZoomFactor), |
| 1515 | WebView::zoomFactorToZoomLevel(content::kMaximumZoomFactor)); |
| 1516 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1517 | // Set zoom level, but don't do it for full-page plugin since they don't use |
| 1518 | // the same zoom settings. |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1519 | HostZoomLevels::iterator host_zoom = |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 1520 | host_zoom_levels_.find(GURL(request.url())); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1521 | if (webview()->mainFrame()->document().isPluginDocument()) { |
| 1522 | // Reset the zoom levels for plugins. |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1523 | webview()->setZoomLevel(false, 0); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1524 | } else { |
| 1525 | if (host_zoom != host_zoom_levels_.end()) |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1526 | webview()->setZoomLevel(false, host_zoom->second); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1527 | } |
| 1528 | |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1529 | if (host_zoom != host_zoom_levels_.end()) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 1530 | // This zoom level was merely recorded transiently for this load. We can |
| 1531 | // erase it now. If at some point we reload this page, the browser will |
| 1532 | // send us a new, up-to-date zoom level. |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1533 | host_zoom_levels_.erase(host_zoom); |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 1534 | } |
| 1535 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1536 | // Update contents MIME type for main frame. |
[email protected] | 9c5645b | 2009-08-11 03:37:55 | [diff] [blame] | 1537 | params.contents_mime_type = ds->response().mimeType().utf8(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1538 | |
[email protected] | daa8c58e | 2009-06-15 17:21:10 | [diff] [blame] | 1539 | params.transition = navigation_state->transition_type(); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1540 | if (!content::PageTransitionIsMainFrame(params.transition)) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1541 | // If the main frame does a load, it should not be reported as a subframe |
| 1542 | // navigation. This can occur in the following case: |
| 1543 | // 1. You're on a site with frames. |
| 1544 | // 2. You do a subframe navigation. This is stored with transition type |
| 1545 | // MANUAL_SUBFRAME. |
| 1546 | // 3. You navigate to some non-frame site, say, google.com. |
| 1547 | // 4. You navigate back to the page from step 2. Since it was initially |
| 1548 | // MANUAL_SUBFRAME, it will be that same transition type here. |
| 1549 | // We don't want that, because any navigation that changes the toplevel |
| 1550 | // frame should be tracked as a toplevel navigation (this allows us to |
| 1551 | // update the URL bar, etc). |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1552 | params.transition = content::PAGE_TRANSITION_LINK; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1553 | } |
| 1554 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1555 | // If we have a valid consumed client redirect source, |
| 1556 | // the page contained a client redirect (meta refresh, document.loc...), |
| 1557 | // so we set the referrer and transition to match. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1558 | if (completed_client_redirect_src_.url.is_valid()) { |
| 1559 | DCHECK(completed_client_redirect_src_.url == params.redirects[0]); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1560 | params.referrer = completed_client_redirect_src_; |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1561 | params.transition = static_cast<content::PageTransition>( |
| 1562 | params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1563 | } else { |
| 1564 | // Bug 654101: the referrer will be empty on https->http transitions. It |
| 1565 | // would be nice if we could get the real referrer from somewhere. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1566 | params.referrer = Referrer(GURL( |
| 1567 | original_request.httpHeaderField(WebString::fromUTF8("Referer"))), |
[email protected] | ca66282 | 2012-05-11 17:53:59 | [diff] [blame] | 1568 | GetReferrerPolicyFromRequest(frame, original_request)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1569 | } |
| 1570 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1571 | string16 method = request.httpMethod(); |
[email protected] | 86cd947 | 2012-02-03 19:51:05 | [diff] [blame] | 1572 | if (EqualsASCII(method, "POST")) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1573 | params.is_post = true; |
[email protected] | 86cd947 | 2012-02-03 19:51:05 | [diff] [blame] | 1574 | params.post_id = ExtractPostId(item); |
| 1575 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1576 | |
[email protected] | bf70edce | 2012-06-20 22:32:22 | [diff] [blame] | 1577 | // Send the user agent override back. |
| 1578 | params.is_overriding_user_agent = |
| 1579 | document_state->is_overriding_user_agent(); |
| 1580 | |
[email protected] | 7c16976c | 2012-08-04 02:38:23 | [diff] [blame] | 1581 | // Track the URL of the original request. |
| 1582 | params.original_request_url = original_request.url(); |
| 1583 | |
[email protected] | c2a797d | 2009-09-21 16:46:32 | [diff] [blame] | 1584 | // Save some histogram data so we can compute the average memory used per |
| 1585 | // page load of the glyphs. |
| 1586 | UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
| 1587 | webkit_glue::GetGlyphPageCount()); |
| 1588 | |
[email protected] | 15cf526b | 2010-02-12 06:33:49 | [diff] [blame] | 1589 | // This message needs to be sent before any of allowScripts(), |
| 1590 | // allowImages(), allowPlugins() is called for the new page, so that when |
| 1591 | // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
| 1592 | // after the ViewHostMsg_FrameNavigate message. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1593 | Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1594 | } else { |
| 1595 | // Subframe navigation: the type depends on whether this navigation |
| 1596 | // generated a new session history entry. When they do generate a session |
| 1597 | // history entry, it means the user initiated the navigation and we should |
| 1598 | // mark it as such. This test checks if this is the first time UpdateURL |
| 1599 | // has been called since WillNavigateToURL was called to initiate the load. |
| 1600 | if (page_id_ > last_page_id_sent_to_browser_) |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1601 | params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1602 | else |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1603 | params.transition = content::PAGE_TRANSITION_AUTO_SUBFRAME; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1604 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1605 | Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1606 | } |
| 1607 | |
| 1608 | last_page_id_sent_to_browser_ = |
| 1609 | std::max(last_page_id_sent_to_browser_, page_id_); |
| 1610 | |
| 1611 | // If we end up reusing this WebRequest (for example, due to a #ref click), |
[email protected] | daa8c58e | 2009-06-15 17:21:10 | [diff] [blame] | 1612 | // we don't want the transition type to persist. Just clear it. |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1613 | navigation_state->set_transition_type(content::PAGE_TRANSITION_LINK); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1614 | } |
| 1615 | |
| 1616 | // Tell the embedding application that the title of the active page has changed |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1617 | void RenderViewImpl::UpdateTitle(WebFrame* frame, |
| 1618 | const string16& title, |
| 1619 | WebTextDirection title_direction) { |
[email protected] | a49e10b | 2011-08-01 23:57:46 | [diff] [blame] | 1620 | // Ignore all but top level navigations. |
| 1621 | if (frame->parent()) |
| 1622 | return; |
| 1623 | |
| 1624 | string16 shortened_title = title.substr(0, content::kMaxTitleChars); |
| 1625 | Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, |
| 1626 | title_direction)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1627 | } |
| 1628 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1629 | void RenderViewImpl::UpdateEncoding(WebFrame* frame, |
| 1630 | const std::string& encoding_name) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1631 | // Only update main frame's encoding_name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1632 | if (webview()->mainFrame() == frame && |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1633 | last_encoding_name_ != encoding_name) { |
[email protected] | e38f4015 | 2008-09-12 23:08:30 | [diff] [blame] | 1634 | // Save the encoding name for later comparing. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1635 | last_encoding_name_ = encoding_name; |
| 1636 | |
[email protected] | e38f4015 | 2008-09-12 23:08:30 | [diff] [blame] | 1637 | Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1638 | } |
| 1639 | } |
| 1640 | |
[email protected] | e15f68073 | 2010-11-23 22:30:20 | [diff] [blame] | 1641 | // Sends the last committed session history state to the browser so it will be |
| 1642 | // saved before we navigate to a new page. This must be called *before* the |
| 1643 | // page ID has been updated so we know what it was. |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1644 | void RenderViewImpl::UpdateSessionHistory(WebFrame* frame) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1645 | // If we have a valid page ID at this point, then it corresponds to the page |
| 1646 | // we are navigating away from. Otherwise, this is the first navigation, so |
| 1647 | // there is no past session history to record. |
| 1648 | if (page_id_ == -1) |
| 1649 | return; |
| 1650 | |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1651 | const WebHistoryItem& item = |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1652 | webview()->mainFrame()->previousHistoryItem(); |
[email protected] | 6459800a | 2012-03-27 23:57:05 | [diff] [blame] | 1653 | SendUpdateState(item); |
| 1654 | } |
| 1655 | |
| 1656 | void RenderViewImpl::SendUpdateState(const WebHistoryItem& item) { |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1657 | if (item.isNull()) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1658 | return; |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1659 | |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 1660 | // Don't send state updates for content::kSwappedOutURL. |
| 1661 | if (item.urlString() == WebString::fromUTF8(content::kSwappedOutURL)) |
[email protected] | 6459800a | 2012-03-27 23:57:05 | [diff] [blame] | 1662 | return; |
| 1663 | |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1664 | Send(new ViewHostMsg_UpdateState( |
| 1665 | routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1666 | } |
| 1667 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1668 | void RenderViewImpl::OpenURL(WebFrame* frame, |
| 1669 | const GURL& url, |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1670 | const Referrer& referrer, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1671 | WebNavigationPolicy policy) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1672 | Send(new ViewHostMsg_OpenURL( |
[email protected] | ae5184d6 | 2011-10-06 19:25:58 | [diff] [blame] | 1673 | routing_id_, |
| 1674 | url, |
| 1675 | referrer, |
| 1676 | NavigationPolicyToDisposition(policy), |
| 1677 | frame->identifier())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1678 | } |
| 1679 | |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1680 | // WebViewDelegate ------------------------------------------------------------ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1681 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1682 | void RenderViewImpl::LoadNavigationErrorPage( |
| 1683 | WebFrame* frame, |
| 1684 | const WebURLRequest& failed_request, |
| 1685 | const WebURLError& error, |
| 1686 | const std::string& html, |
| 1687 | bool replace) { |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 1688 | std::string alt_html; |
| 1689 | const std::string* error_html; |
| 1690 | |
| 1691 | if (!html.empty()) { |
| 1692 | error_html = &html; |
| 1693 | } else { |
| 1694 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 1695 | failed_request, error, &alt_html, NULL); |
| 1696 | error_html = &alt_html; |
| 1697 | } |
| 1698 | |
| 1699 | frame->loadHTMLString(*error_html, |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 1700 | GURL(content::kUnreachableWebDataURL), |
[email protected] | 21d61e5 | 2011-03-18 19:08:25 | [diff] [blame] | 1701 | error.unreachableURL, |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 1702 | replace); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1703 | } |
| 1704 | |
[email protected] | be2510c0 | 2012-05-28 14:52:14 | [diff] [blame] | 1705 | bool RenderViewImpl::RunJavaScriptMessage(content::JavaScriptMessageType type, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1706 | const string16& message, |
| 1707 | const string16& default_value, |
| 1708 | const GURL& frame_url, |
| 1709 | string16* result) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1710 | bool success = false; |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1711 | string16 result_temp; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1712 | if (!result) |
| 1713 | result = &result_temp; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1714 | |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1715 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( |
| 1716 | routing_id_, message, default_value, frame_url, type, &success, result)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1717 | return success; |
| 1718 | } |
| 1719 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1720 | bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1721 | // Before WebKit asks us to show an alert (etc.), it takes care of doing the |
| 1722 | // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog |
| 1723 | // it is particularly important that we do not call willEnterModalLoop as |
| 1724 | // that would defer resource loads for the dialog itself. |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 1725 | if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 1726 | RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1727 | |
| 1728 | message->EnableMessagePumping(); // Runs a nested message loop. |
| 1729 | return Send(message); |
| 1730 | } |
| 1731 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1732 | // WebKit::WebViewClient ------------------------------------------------------ |
| 1733 | |
[email protected] | 916dfb6 | 2012-03-05 03:39:37 | [diff] [blame] | 1734 | WebView* RenderViewImpl::createView( |
| 1735 | WebFrame* creator, |
| 1736 | const WebURLRequest& request, |
| 1737 | const WebWindowFeatures& features, |
| 1738 | const WebString& frame_name, |
| 1739 | WebNavigationPolicy policy) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1740 | // Check to make sure we aren't overloading on popups. |
| 1741 | if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) |
| 1742 | return NULL; |
| 1743 | |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1744 | ViewHostMsg_CreateWindow_Params params; |
| 1745 | params.opener_id = routing_id_; |
| 1746 | params.user_gesture = creator->isProcessingUserGesture(); |
| 1747 | params.window_container_type = WindowFeaturesToContainerType(features); |
| 1748 | params.session_storage_namespace_id = session_storage_namespace_id_; |
| 1749 | params.frame_name = frame_name; |
[email protected] | 41e6550 | 2011-01-21 09:29:11 | [diff] [blame] | 1750 | params.opener_frame_id = creator->identifier(); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1751 | params.opener_url = creator->document().url(); |
| 1752 | params.opener_security_origin = |
| 1753 | creator->document().securityOrigin().toString().utf8(); |
[email protected] | f92ce2b | 2012-03-06 18:02:59 | [diff] [blame] | 1754 | params.opener_suppressed = creator->willSuppressOpenerInNewFrame(); |
| 1755 | params.disposition = NavigationPolicyToDisposition(policy); |
[email protected] | 41e6550 | 2011-01-21 09:29:11 | [diff] [blame] | 1756 | if (!request.isNull()) |
| 1757 | params.target_url = request.url(); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1758 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1759 | int32 routing_id = MSG_ROUTING_NONE; |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1760 | int32 surface_id = 0; |
[email protected] | 4e6419c | 2010-01-15 04:50:34 | [diff] [blame] | 1761 | int64 cloned_session_storage_namespace_id; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1762 | |
[email protected] | 7c962ee3 | 2012-08-28 21:12:50 | [diff] [blame] | 1763 | creator->consumeUserGesture(); |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1764 | RenderThread::Get()->Send( |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1765 | new ViewHostMsg_CreateWindow(params, |
| 1766 | &routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1767 | &surface_id, |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1768 | &cloned_session_storage_namespace_id)); |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1769 | if (routing_id == MSG_ROUTING_NONE) |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1770 | return NULL; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1771 | |
[email protected] | 8cca3da | 2012-03-20 08:26:34 | [diff] [blame] | 1772 | // TODO(fsamuel): The host renderer needs to be able to control whether |
| 1773 | // the guest renderer is allowed to do this or not. This current |
| 1774 | // behavior is not well defined. |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1775 | RenderViewImpl* view = RenderViewImpl::Create( |
| 1776 | 0, |
| 1777 | routing_id_, |
| 1778 | renderer_preferences_, |
| 1779 | webkit_preferences_, |
| 1780 | shared_popup_counter_, |
| 1781 | routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1782 | surface_id, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1783 | cloned_session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 1784 | frame_name, |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 1785 | true, |
| 1786 | false, |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 1787 | 1, |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 1788 | screen_info_, |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 1789 | guest_to_embedder_channel_, |
[email protected] | 3e3c452 | 2012-04-13 21:16:29 | [diff] [blame] | 1790 | accessibility_mode_); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1791 | view->opened_by_user_gesture_ = params.user_gesture; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1792 | |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 1793 | // Record whether the creator frame is trying to suppress the opener field. |
[email protected] | f92ce2b | 2012-03-06 18:02:59 | [diff] [blame] | 1794 | view->opener_suppressed_ = params.opener_suppressed; |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 1795 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1796 | // Record the security origin of the creator. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1797 | GURL creator_url(creator->document().securityOrigin().toString().utf8()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1798 | if (!creator_url.is_valid() || !creator_url.IsStandard()) |
| 1799 | creator_url = GURL(); |
| 1800 | view->creator_url_ = creator_url; |
| 1801 | |
| 1802 | // Copy over the alternate error page URL so we can have alt error pages in |
| 1803 | // the new render view (we don't need the browser to send the URL back down). |
| 1804 | view->alternate_error_page_url_ = alternate_error_page_url_; |
| 1805 | |
| 1806 | return view->webview(); |
| 1807 | } |
| 1808 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1809 | WebWidget* RenderViewImpl::createPopupMenu(WebKit::WebPopupType popup_type) { |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 1810 | RenderWidget* widget = |
[email protected] | 842f1065 | 2012-06-06 01:54:04 | [diff] [blame] | 1811 | RenderWidget::Create(routing_id_, popup_type, screen_info_); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1812 | return widget->webwidget(); |
| 1813 | } |
| 1814 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1815 | WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 1816 | const WebPopupMenuInfo& popup_menu_info, |
| 1817 | WebExternalPopupMenuClient* popup_menu_client) { |
[email protected] | 8de2f88 | 2012-05-30 00:32:27 | [diff] [blame] | 1818 | // An IPC message is sent to the browser to build and display the actual |
| 1819 | // popup. The user could have time to click a different select by the time |
| 1820 | // the popup is shown. In that case external_popup_menu_ is non NULL. |
| 1821 | // By returning NULL in that case, we instruct WebKit to cancel that new |
| 1822 | // popup. So from the user perspective, only the first one will show, and |
| 1823 | // will have to close the first one before another one can be shown. |
| 1824 | if (external_popup_menu_.get()) |
| 1825 | return NULL; |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 1826 | external_popup_menu_.reset( |
| 1827 | new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); |
| 1828 | return external_popup_menu_.get(); |
| 1829 | } |
| 1830 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1831 | RenderWidgetFullscreenPepper* RenderViewImpl::CreatePepperFullscreenContainer( |
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 1832 | webkit::ppapi::PluginInstance* plugin) { |
[email protected] | d91233b7e | 2011-03-29 20:33:53 | [diff] [blame] | 1833 | GURL active_url; |
[email protected] | d91ddfc | 2011-04-07 18:33:42 | [diff] [blame] | 1834 | if (webview() && webview()->mainFrame()) |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1835 | active_url = GURL(webview()->mainFrame()->document().url()); |
[email protected] | d91233b7e | 2011-03-29 20:33:53 | [diff] [blame] | 1836 | RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( |
[email protected] | bee6eb7 | 2012-07-26 03:47:32 | [diff] [blame] | 1837 | routing_id_, plugin, active_url, screen_info_); |
[email protected] | 79c7bed | 2010-09-14 22:28:39 | [diff] [blame] | 1838 | widget->show(WebKit::WebNavigationPolicyIgnore); |
[email protected] | 92abcb83 | 2011-01-06 20:39:56 | [diff] [blame] | 1839 | return widget; |
[email protected] | 79c7bed | 2010-09-14 22:28:39 | [diff] [blame] | 1840 | } |
| 1841 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1842 | WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace( |
| 1843 | unsigned quota) { |
[email protected] | b928936b | 2012-04-13 01:16:16 | [diff] [blame] | 1844 | CHECK(session_storage_namespace_id_ != |
| 1845 | dom_storage::kInvalidSessionStorageNamespaceId); |
[email protected] | 1910fe8 | 2012-05-10 00:04:10 | [diff] [blame] | 1846 | return new WebStorageNamespaceImpl(session_storage_namespace_id_); |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1847 | } |
| 1848 | |
[email protected] | 1842fe2 | 2012-08-13 23:24:35 | [diff] [blame] | 1849 | WebKit::WebCompositorOutputSurface* RenderViewImpl::createOutputSurface() { |
| 1850 | // TODO(aelias): if force-software-mode is on, create an output surface |
| 1851 | // without a 3D context. |
| 1852 | |
| 1853 | // Explicitly disable antialiasing for the compositor. As of the time of |
| 1854 | // this writing, the only platform that supported antialiasing for the |
| 1855 | // compositor was Mac OS X, because the on-screen OpenGL context creation |
| 1856 | // code paths on Windows and Linux didn't yet have multisampling support. |
| 1857 | // Mac OS X essentially always behaves as though it's rendering offscreen. |
| 1858 | // Multisampling has a heavy cost especially on devices with relatively low |
| 1859 | // fill rate like most notebooks, and the Mac implementation would need to |
| 1860 | // be optimized to resolve directly into the IOSurface shared between the |
| 1861 | // GPU and browser processes. For these reasons and to avoid platform |
| 1862 | // disparities we explicitly disable antialiasing. |
| 1863 | WebKit::WebGraphicsContext3D::Attributes attributes; |
| 1864 | attributes.antialias = false; |
| 1865 | attributes.shareResources = true; |
| 1866 | WebGraphicsContext3D* context = CreateGraphicsContext3D(attributes); |
| 1867 | if (!context) |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 1868 | return NULL; |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 1869 | |
[email protected] | 1842fe2 | 2012-08-13 23:24:35 | [diff] [blame] | 1870 | return new CompositorOutputSurface(routing_id(), context); |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 1871 | } |
| 1872 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1873 | void RenderViewImpl::didAddMessageToConsole( |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1874 | const WebConsoleMessage& message, const WebString& source_name, |
| 1875 | unsigned source_line) { |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1876 | logging::LogSeverity log_severity = logging::LOG_VERBOSE; |
[email protected] | f7eb0a39 | 2011-07-12 10:19:51 | [diff] [blame] | 1877 | switch (message.level) { |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1878 | case WebConsoleMessage::LevelTip: |
| 1879 | log_severity = logging::LOG_VERBOSE; |
| 1880 | break; |
| 1881 | case WebConsoleMessage::LevelLog: |
| 1882 | log_severity = logging::LOG_INFO; |
| 1883 | break; |
| 1884 | case WebConsoleMessage::LevelWarning: |
| 1885 | log_severity = logging::LOG_WARNING; |
| 1886 | break; |
| 1887 | case WebConsoleMessage::LevelError: |
| 1888 | log_severity = logging::LOG_ERROR; |
| 1889 | break; |
| 1890 | default: |
| 1891 | NOTREACHED(); |
| 1892 | } |
| 1893 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1894 | Send(new ViewHostMsg_AddMessageToConsole(routing_id_, |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1895 | static_cast<int32>(log_severity), |
[email protected] | aa21d2a | 2011-08-08 23:56:31 | [diff] [blame] | 1896 | message.text, |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1897 | static_cast<int32>(source_line), |
[email protected] | aa21d2a | 2011-08-08 23:56:31 | [diff] [blame] | 1898 | source_name)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1899 | } |
| 1900 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1901 | void RenderViewImpl::printPage(WebFrame* frame) { |
[email protected] | d91ddfc | 2011-04-07 18:33:42 | [diff] [blame] | 1902 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, PrintPage(frame)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1903 | } |
| 1904 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1905 | WebKit::WebNotificationPresenter* RenderViewImpl::notificationPresenter() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1906 | return notification_provider_; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 1907 | } |
| 1908 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1909 | bool RenderViewImpl::enumerateChosenDirectory( |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1910 | const WebString& path, |
| 1911 | WebFileChooserCompletion* chooser_completion) { |
| 1912 | int id = enumeration_completion_id_++; |
| 1913 | enumeration_completions_[id] = chooser_completion; |
| 1914 | return Send(new ViewHostMsg_EnumerateDirectory( |
| 1915 | routing_id_, |
| 1916 | id, |
| 1917 | webkit_glue::WebStringToFilePath(path))); |
| 1918 | } |
| 1919 | |
[email protected] | 4b1146bc | 2012-07-10 18:46:03 | [diff] [blame] | 1920 | void RenderViewImpl::initializeHelperPluginWebFrame( |
| 1921 | WebKit::WebHelperPlugin* plugin) { |
| 1922 | plugin->initializeFrame(this); |
| 1923 | } |
| 1924 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1925 | void RenderViewImpl::didStartLoading() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1926 | if (is_loading_) { |
[email protected] | 511754da | 2012-01-24 20:48:14 | [diff] [blame] | 1927 | DVLOG(1) << "didStartLoading called while loading"; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1928 | return; |
| 1929 | } |
| 1930 | |
| 1931 | is_loading_ = true; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1932 | |
| 1933 | Send(new ViewHostMsg_DidStartLoading(routing_id_)); |
[email protected] | 93b9d69 | 2011-04-13 00:44:31 | [diff] [blame] | 1934 | |
| 1935 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1936 | } |
| 1937 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1938 | void RenderViewImpl::didStopLoading() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1939 | if (!is_loading_) { |
[email protected] | 511754da | 2012-01-24 20:48:14 | [diff] [blame] | 1940 | DVLOG(1) << "DidStopLoading called while not loading"; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1941 | return; |
| 1942 | } |
| 1943 | |
| 1944 | is_loading_ = false; |
| 1945 | |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 1946 | if (pending_frame_tree_update_) { |
| 1947 | pending_frame_tree_update_ = false; |
| 1948 | SendUpdatedFrameTree(NULL); |
| 1949 | } |
| 1950 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1951 | // NOTE: For now we're doing the safest thing, and sending out notification |
| 1952 | // when done loading. This currently isn't an issue as the favicon is only |
| 1953 | // displayed when done loading. Ideally we would send notification when |
| 1954 | // finished parsing the head, but webkit doesn't support that yet. |
| 1955 | // The feed discovery code would also benefit from access to the head. |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1956 | Send(new ViewHostMsg_DidStopLoading(routing_id_)); |
| 1957 | |
[email protected] | 9010941 | 2010-12-15 17:14:24 | [diff] [blame] | 1958 | if (load_progress_tracker_ != NULL) |
| 1959 | load_progress_tracker_->DidStopLoading(); |
| 1960 | |
[email protected] | 93b9d69 | 2011-04-13 00:44:31 | [diff] [blame] | 1961 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1962 | } |
| 1963 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1964 | void RenderViewImpl::didChangeLoadProgress(WebFrame* frame, |
| 1965 | double load_progress) { |
[email protected] | 9010941 | 2010-12-15 17:14:24 | [diff] [blame] | 1966 | if (load_progress_tracker_ != NULL) |
| 1967 | load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); |
| 1968 | } |
| 1969 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1970 | bool RenderViewImpl::isSmartInsertDeleteEnabled() { |
[email protected] | f55039a | 2010-02-17 14:12:06 | [diff] [blame] | 1971 | #if defined(OS_MACOSX) |
| 1972 | return true; |
| 1973 | #else |
| 1974 | return false; |
| 1975 | #endif |
| 1976 | } |
| 1977 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1978 | bool RenderViewImpl::isSelectTrailingWhitespaceEnabled() { |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1979 | #if defined(OS_WIN) |
| 1980 | return true; |
| 1981 | #else |
| 1982 | return false; |
| 1983 | #endif |
| 1984 | } |
| 1985 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1986 | void RenderViewImpl::didChangeSelection(bool is_empty_selection) { |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1987 | if (!handling_input_event_ && !handling_select_range_) |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1988 | return; |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1989 | handling_select_range_ = false; |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1990 | |
[email protected] | fca5202 | 2012-04-03 17:00:50 | [diff] [blame] | 1991 | if (is_empty_selection) |
| 1992 | selection_text_.clear(); |
| 1993 | |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 1994 | SyncSelectionIfRequired(); |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1995 | } |
| 1996 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1997 | void RenderViewImpl::didExecuteCommand(const WebString& command_name) { |
[email protected] | afe3a167 | 2009-11-17 19:04:12 | [diff] [blame] | 1998 | const std::string& name = UTF16ToUTF8(command_name); |
| 1999 | if (StartsWithASCII(name, "Move", true) || |
| 2000 | StartsWithASCII(name, "Insert", true) || |
| 2001 | StartsWithASCII(name, "Delete", true)) |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 2002 | return; |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 2003 | RenderThreadImpl::current()->RecordUserMetrics(name); |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 2004 | } |
| 2005 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2006 | bool RenderViewImpl::handleCurrentKeyboardEvent() { |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 2007 | if (edit_commands_.empty()) |
| 2008 | return false; |
| 2009 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2010 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 2011 | if (!frame) |
| 2012 | return false; |
| 2013 | |
| 2014 | EditCommands::iterator it = edit_commands_.begin(); |
| 2015 | EditCommands::iterator end = edit_commands_.end(); |
| 2016 | |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 2017 | bool did_execute_command = false; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 2018 | for (; it != end; ++it) { |
[email protected] | e6e1501 | 2009-09-30 14:59:33 | [diff] [blame] | 2019 | // In gtk and cocoa, it's possible to bind multiple edit commands to one |
| 2020 | // key (but it's the exception). Once one edit command is not executed, it |
| 2021 | // seems safest to not execute the rest. |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 2022 | if (!frame->executeCommand(WebString::fromUTF8(it->name), |
| 2023 | WebString::fromUTF8(it->value))) |
| 2024 | break; |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 2025 | did_execute_command = true; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 2026 | } |
| 2027 | |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 2028 | return did_execute_command; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 2029 | } |
| 2030 | |
[email protected] | da854376 | 2012-03-20 08:52:20 | [diff] [blame] | 2031 | WebKit::WebColorChooser* RenderViewImpl::createColorChooser( |
| 2032 | WebKit::WebColorChooserClient* client, |
| 2033 | const WebKit::WebColor& initial_color) { |
| 2034 | RendererWebColorChooserImpl* color_chooser = |
| 2035 | new RendererWebColorChooserImpl(this, client); |
| 2036 | color_chooser->Open(static_cast<SkColor>(initial_color)); |
| 2037 | return color_chooser; |
| 2038 | } |
| 2039 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2040 | bool RenderViewImpl::runFileChooser( |
[email protected] | 01178b5 | 2010-01-15 06:59:35 | [diff] [blame] | 2041 | const WebKit::WebFileChooserParams& params, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 2042 | WebFileChooserCompletion* chooser_completion) { |
[email protected] | 7ef03e0 | 2010-10-23 11:58:35 | [diff] [blame] | 2043 | // Do not open the file dialog in a hidden RenderView. |
| 2044 | if (is_hidden()) |
| 2045 | return false; |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 2046 | content::FileChooserParams ipc_params; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 2047 | if (params.directory) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 2048 | ipc_params.mode = content::FileChooserParams::OpenFolder; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 2049 | else if (params.multiSelect) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 2050 | ipc_params.mode = content::FileChooserParams::OpenMultiple; |
[email protected] | 459fba8 | 2011-10-13 02:48:50 | [diff] [blame] | 2051 | else if (params.saveAs) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 2052 | ipc_params.mode = content::FileChooserParams::Save; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 2053 | else |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 2054 | ipc_params.mode = content::FileChooserParams::Open; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 2055 | ipc_params.title = params.title; |
| 2056 | ipc_params.default_file_name = |
| 2057 | webkit_glue::WebStringToFilePath(params.initialValue); |
[email protected] | f9a4c41a | 2012-05-30 00:05:32 | [diff] [blame] | 2058 | ipc_params.accept_types.reserve(params.acceptTypes.size()); |
| 2059 | for (size_t i = 0; i < params.acceptTypes.size(); ++i) |
| 2060 | ipc_params.accept_types.push_back(params.acceptTypes[i]); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 2061 | |
| 2062 | return ScheduleFileChooser(ipc_params, chooser_completion); |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 2063 | } |
| 2064 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 2065 | void RenderViewImpl::runModalAlertDialog(WebFrame* frame, |
| 2066 | const WebString& message) { |
[email protected] | be2510c0 | 2012-05-28 14:52:14 | [diff] [blame] | 2067 | RunJavaScriptMessage(content::JAVASCRIPT_MESSAGE_TYPE_ALERT, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 2068 | message, |
| 2069 | string16(), |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2070 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2071 | NULL); |
| 2072 | } |
| 2073 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 2074 | bool RenderViewImpl::runModalConfirmDialog(WebFrame* frame, |
| 2075 | const WebString& message) { |
[email protected] | be2510c0 | 2012-05-28 14:52:14 | [diff] [blame] | 2076 | return RunJavaScriptMessage(content::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 2077 | message, |
| 2078 | string16(), |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2079 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2080 | NULL); |
| 2081 | } |
| 2082 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 2083 | bool RenderViewImpl::runModalPromptDialog(WebFrame* frame, |
| 2084 | const WebString& message, |
| 2085 | const WebString& default_value, |
| 2086 | WebString* actual_value) { |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 2087 | string16 result; |
[email protected] | be2510c0 | 2012-05-28 14:52:14 | [diff] [blame] | 2088 | bool ok = RunJavaScriptMessage(content::JAVASCRIPT_MESSAGE_TYPE_PROMPT, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 2089 | message, |
| 2090 | default_value, |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2091 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2092 | &result); |
| 2093 | if (ok) |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 2094 | actual_value->assign(result); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2095 | return ok; |
| 2096 | } |
| 2097 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2098 | bool RenderViewImpl::runModalBeforeUnloadDialog( |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2099 | WebFrame* frame, const WebString& message) { |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 2100 | // If we are swapping out, we have already run the beforeunload handler. |
| 2101 | // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload |
| 2102 | // at all, to avoid running it twice. |
| 2103 | if (is_swapped_out_) |
| 2104 | return true; |
| 2105 | |
[email protected] | 3b3301f6 | 2012-02-29 04:32:32 | [diff] [blame] | 2106 | bool is_reload = false; |
| 2107 | WebDataSource* ds = frame->provisionalDataSource(); |
| 2108 | if (ds) |
| 2109 | is_reload = (ds->navigationType() == WebKit::WebNavigationTypeReload); |
| 2110 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2111 | bool success = false; |
| 2112 | // This is an ignored return value, but is included so we can accept the same |
| 2113 | // response as RunJavaScriptMessage. |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 2114 | string16 ignored_result; |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 2115 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( |
[email protected] | 3b3301f6 | 2012-02-29 04:32:32 | [diff] [blame] | 2116 | routing_id_, frame->document().url(), message, is_reload, |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2117 | &success, &ignored_result)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2118 | return success; |
| 2119 | } |
| 2120 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2121 | void RenderViewImpl::showContextMenu( |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 2122 | WebFrame* frame, const WebContextMenuData& data) { |
[email protected] | 8f635f8 | 2012-06-22 22:02:44 | [diff] [blame] | 2123 | // TODO(fsamuel): In the future, we might want the embedder to be able to |
| 2124 | // decide whether the guest can show a context menu or not. See |
| 2125 | // http://www.crbug.com/134207 |
| 2126 | if (GetGuestToEmbedderChannel()) |
| 2127 | return; |
| 2128 | |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 2129 | content::ContextMenuParams params(data); |
[email protected] | 7fcd9b7 | 2011-07-27 16:52:37 | [diff] [blame] | 2130 | |
| 2131 | // frame is NULL if invoked by BlockedPlugin. |
| 2132 | if (frame) |
| 2133 | params.frame_id = frame->identifier(); |
| 2134 | |
[email protected] | db803aae | 2011-03-05 02:00:42 | [diff] [blame] | 2135 | // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do |
[email protected] | 216932c | 2010-08-26 21:44:27 | [diff] [blame] | 2136 | // it. We replace it with an empty GURL so the appropriate items are disabled |
| 2137 | // in the context menu. |
| 2138 | // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large |
| 2139 | // data encoded images. We should have a way to save them. |
[email protected] | db803aae | 2011-03-05 02:00:42 | [diff] [blame] | 2140 | if (params.src_url.spec().size() > content::kMaxURLChars) |
[email protected] | 216932c | 2010-08-26 21:44:27 | [diff] [blame] | 2141 | params.src_url = GURL(); |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 2142 | context_menu_node_ = data.node; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 2143 | Send(new ViewHostMsg_ContextMenu(routing_id_, params)); |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 2144 | } |
| 2145 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2146 | void RenderViewImpl::setStatusText(const WebString& text) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2147 | } |
| 2148 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2149 | void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 2150 | const GURL& fallback_url) { |
[email protected] | aa6b90b3 | 2010-04-26 15:49:58 | [diff] [blame] | 2151 | GURL latest_url = url.is_empty() ? fallback_url : url; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2152 | if (latest_url == target_url_) |
| 2153 | return; |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 2154 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2155 | // Tell the browser to display a destination link. |
| 2156 | if (target_url_status_ == TARGET_INFLIGHT || |
| 2157 | target_url_status_ == TARGET_PENDING) { |
| 2158 | // If we have a request in-flight, save the URL to be sent when we |
| 2159 | // receive an ACK to the in-flight request. We can happily overwrite |
| 2160 | // any existing pending sends. |
| 2161 | pending_target_url_ = latest_url; |
| 2162 | target_url_status_ = TARGET_PENDING; |
| 2163 | } else { |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 2164 | // URLs larger than |content::kMaxURLChars| cannot be sent through IPC - |
| 2165 | // see |ParamTraits<GURL>|. |
| 2166 | if (latest_url.possibly_invalid_spec().size() > content::kMaxURLChars) |
| 2167 | latest_url = GURL(); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2168 | Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); |
| 2169 | target_url_ = latest_url; |
| 2170 | target_url_status_ = TARGET_INFLIGHT; |
| 2171 | } |
| 2172 | } |
| 2173 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2174 | void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 2175 | int delay; |
| 2176 | if (send_content_state_immediately_) |
| 2177 | delay = 0; |
| 2178 | else if (is_hidden()) |
| 2179 | delay = kDelaySecondsForContentStateSyncHidden; |
| 2180 | else |
| 2181 | delay = kDelaySecondsForContentStateSync; |
| 2182 | |
| 2183 | if (nav_state_sync_timer_.IsRunning()) { |
| 2184 | // The timer is already running. If the delay of the timer maches the amount |
| 2185 | // we want to delay by, then return. Otherwise stop the timer so that it |
| 2186 | // gets started with the right delay. |
| 2187 | if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
| 2188 | return; |
| 2189 | nav_state_sync_timer_.Stop(); |
| 2190 | } |
| 2191 | |
[email protected] | d323a17 | 2011-09-02 18:23:02 | [diff] [blame] | 2192 | nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2193 | &RenderViewImpl::SyncNavigationState); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 2194 | } |
| 2195 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2196 | void RenderViewImpl::setMouseOverURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 2197 | mouse_over_url_ = GURL(url); |
| 2198 | UpdateTargetURL(mouse_over_url_, focus_url_); |
| 2199 | } |
| 2200 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2201 | void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 2202 | focus_url_ = GURL(url); |
| 2203 | UpdateTargetURL(focus_url_, mouse_over_url_); |
| 2204 | } |
| 2205 | |
[email protected] | 0407e42 | 2012-05-18 19:51:25 | [diff] [blame] | 2206 | void RenderViewImpl::startDragging(WebFrame* frame, |
| 2207 | const WebDragData& data, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2208 | WebDragOperationsMask mask, |
| 2209 | const WebImage& image, |
| 2210 | const WebPoint& imageOffset) { |
[email protected] | b67151d | 2012-05-25 23:23:24 | [diff] [blame] | 2211 | WebDropData drop_data(data); |
| 2212 | drop_data.referrer_policy = frame->document().referrerPolicy(); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 2213 | Send(new DragHostMsg_StartDragging(routing_id_, |
[email protected] | b67151d | 2012-05-25 23:23:24 | [diff] [blame] | 2214 | drop_data, |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 2215 | mask, |
[email protected] | 97612707 | 2012-05-10 20:08:11 | [diff] [blame] | 2216 | image.getSkBitmap(), |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 2217 | imageOffset)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2218 | } |
| 2219 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2220 | bool RenderViewImpl::acceptsLoadDrops() { |
[email protected] | 28b92df | 2009-09-25 17:35:45 | [diff] [blame] | 2221 | return renderer_preferences_.can_accept_load_drops; |
| 2222 | } |
| 2223 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2224 | void RenderViewImpl::focusNext() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2225 | Send(new ViewHostMsg_TakeFocus(routing_id_, false)); |
| 2226 | } |
| 2227 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2228 | void RenderViewImpl::focusPrevious() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2229 | Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
| 2230 | } |
| 2231 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2232 | void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 2233 | Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
[email protected] | a4b103b | 2010-10-05 18:46:07 | [diff] [blame] | 2234 | |
[email protected] | 38b59290 | 2011-04-16 02:08:42 | [diff] [blame] | 2235 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
[email protected] | 08e9e13 | 2010-06-01 16:58:49 | [diff] [blame] | 2236 | } |
| 2237 | |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 2238 | void RenderViewImpl::didUpdateLayout() { |
| 2239 | // We don't always want to set up a timer, only if we've been put in that |
| 2240 | // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 2241 | // message. |
| 2242 | if (!send_preferred_size_changes_ || !webview()) |
| 2243 | return; |
| 2244 | |
| 2245 | if (check_preferred_size_timer_.IsRunning()) |
| 2246 | return; |
| 2247 | check_preferred_size_timer_.Start(FROM_HERE, |
| 2248 | TimeDelta::FromMilliseconds(0), this, |
| 2249 | &RenderViewImpl::CheckPreferredSize); |
| 2250 | } |
| 2251 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2252 | void RenderViewImpl::navigateBackForwardSoon(int offset) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2253 | Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); |
| 2254 | } |
| 2255 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2256 | int RenderViewImpl::historyBackListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 2257 | return history_list_offset_ < 0 ? 0 : history_list_offset_; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2258 | } |
| 2259 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2260 | int RenderViewImpl::historyForwardListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 2261 | return history_list_length_ - historyBackListCount() - 1; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2262 | } |
| 2263 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2264 | void RenderViewImpl::postAccessibilityNotification( |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 2265 | const WebAccessibilityObject& obj, |
| 2266 | WebAccessibilityNotification notification) { |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 2267 | if (renderer_accessibility_) { |
| 2268 | renderer_accessibility_->HandleWebAccessibilityNotification( |
| 2269 | obj, notification); |
| 2270 | } |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 2271 | } |
| 2272 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2273 | void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, |
[email protected] | c4e9890 | 2010-06-01 10:20:14 | [diff] [blame] | 2274 | const WebString& value) { |
| 2275 | Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
| 2276 | key.utf8(), |
| 2277 | value.utf8())); |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 2278 | } |
| 2279 | |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 2280 | // WebKit::WebWidgetClient ---------------------------------------------------- |
| 2281 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2282 | void RenderViewImpl::didFocus() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 2283 | // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 2284 | // we won't have to test for user gesture anymore and we can |
| 2285 | // move that code back to render_widget.cc |
| 2286 | if (webview() && webview()->mainFrame() && |
| 2287 | webview()->mainFrame()->isProcessingUserGesture()) { |
| 2288 | Send(new ViewHostMsg_Focus(routing_id_)); |
| 2289 | } |
| 2290 | } |
| 2291 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2292 | void RenderViewImpl::didBlur() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 2293 | // TODO(jcivelli): see TODO above in didFocus(). |
| 2294 | if (webview() && webview()->mainFrame() && |
| 2295 | webview()->mainFrame()->isProcessingUserGesture()) { |
| 2296 | Send(new ViewHostMsg_Blur(routing_id_)); |
| 2297 | } |
| 2298 | } |
| 2299 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2300 | // We are supposed to get a single call to Show for a newly created RenderView |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2301 | // that was created via RenderViewImpl::CreateWebView. So, we wait until this |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2302 | // point to dispatch the ShowView message. |
| 2303 | // |
| 2304 | // This method provides us with the information about how to display the newly |
[email protected] | 5f9de588 | 2011-09-30 23:36:28 | [diff] [blame] | 2305 | // created RenderView (i.e., as a blocked popup or as a new tab). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2306 | // |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2307 | void RenderViewImpl::show(WebNavigationPolicy policy) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2308 | DCHECK(!did_show_) << "received extraneous Show call"; |
| 2309 | DCHECK(opener_id_ != MSG_ROUTING_NONE); |
| 2310 | |
| 2311 | if (did_show_) |
| 2312 | return; |
| 2313 | did_show_ = true; |
| 2314 | |
[email protected] | 6779aa1 | 2011-03-29 17:32:24 | [diff] [blame] | 2315 | if (content::GetContentClient()->renderer()->AllowPopup(creator_url_)) |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 2316 | opened_by_user_gesture_ = true; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 2317 | |
[email protected] | 28295ec | 2009-10-16 05:34:33 | [diff] [blame] | 2318 | // Force new windows to a popup if they were not opened with a user gesture. |
| 2319 | if (!opened_by_user_gesture_) { |
| 2320 | // We exempt background tabs for compat with older versions of Chrome. |
| 2321 | // TODO(darin): This seems bogus. These should have a user gesture, so |
| 2322 | // we probably don't need this check. |
| 2323 | if (policy != WebKit::WebNavigationPolicyNewBackgroundTab) |
| 2324 | policy = WebKit::WebNavigationPolicyNewPopup; |
| 2325 | } |
| 2326 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2327 | // NOTE: initial_pos_ may still have its default values at this point, but |
| 2328 | // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the |
| 2329 | // browser process will impose a default position otherwise. |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 2330 | Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, |
| 2331 | NavigationPolicyToDisposition(policy), initial_pos_, |
[email protected] | 7e7414ae | 2010-01-26 20:19:29 | [diff] [blame] | 2332 | opened_by_user_gesture_)); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 2333 | SetPendingWindowRect(initial_pos_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2334 | } |
| 2335 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2336 | void RenderViewImpl::runModal() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2337 | DCHECK(did_show_) << "should already have shown the view"; |
| 2338 | |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 2339 | // We must keep WebKit's shared timer running in this case in order to allow |
| 2340 | // showModalDialog to function properly. |
| 2341 | // |
| 2342 | // TODO(darin): WebKit should really be smarter about suppressing events and |
| 2343 | // timers so that we do not need to manage the shared timer in such a heavy |
| 2344 | // handed manner. |
| 2345 | // |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 2346 | if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 2347 | RenderThreadImpl::current()->DoNotSuspendWebKitSharedTimer(); |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 2348 | |
[email protected] | 08a1c810 | 2012-05-11 23:14:26 | [diff] [blame] | 2349 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal( |
| 2350 | routing_id_, opener_id_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2351 | } |
| 2352 | |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 2353 | bool RenderViewImpl::enterFullScreen() { |
| 2354 | Send(new ViewHostMsg_ToggleFullscreen(routing_id_, true)); |
| 2355 | return true; |
| 2356 | } |
| 2357 | |
| 2358 | void RenderViewImpl::exitFullScreen() { |
| 2359 | Send(new ViewHostMsg_ToggleFullscreen(routing_id_, false)); |
| 2360 | } |
| 2361 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 2362 | bool RenderViewImpl::requestPointerLock() { |
| 2363 | return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get()); |
| 2364 | } |
| 2365 | |
| 2366 | void RenderViewImpl::requestPointerUnlock() { |
| 2367 | mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2368 | } |
| 2369 | |
| 2370 | bool RenderViewImpl::isPointerLocked() { |
| 2371 | return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2372 | webwidget_mouse_lock_target_.get()); |
| 2373 | } |
| 2374 | |
[email protected] | 7a1ec28a | 2012-03-28 21:10:24 | [diff] [blame] | 2375 | void RenderViewImpl::didActivateCompositor(int input_handler_identifier) { |
| 2376 | CompositorThread* compositor_thread = |
| 2377 | RenderThreadImpl::current()->compositor_thread(); |
| 2378 | if (compositor_thread) |
| 2379 | compositor_thread->AddInputHandler( |
| 2380 | routing_id_, input_handler_identifier, AsWeakPtr()); |
| 2381 | |
| 2382 | RenderWidget::didActivateCompositor(input_handler_identifier); |
| 2383 | } |
| 2384 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2385 | // WebKit::WebFrameClient ----------------------------------------------------- |
| 2386 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2387 | WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, |
| 2388 | const WebPluginParams& params) { |
[email protected] | eaacd1f | 2011-09-23 02:32:55 | [diff] [blame] | 2389 | WebPlugin* plugin = NULL; |
| 2390 | if (content::GetContentClient()->renderer()->OverrideCreatePlugin( |
| 2391 | this, frame, params, &plugin)) { |
| 2392 | return plugin; |
| 2393 | } |
| 2394 | |
[email protected] | e6e5675 | 2012-08-10 00:46:06 | [diff] [blame] | 2395 | // TODO(fsamuel): Remove this once upstreaming of the new browser plugin is |
| 2396 | // complete. |
| 2397 | if (UTF16ToASCII(params.mimeType) == content::kBrowserPluginNewMimeType) { |
| 2398 | return content::BrowserPluginManager::Get()-> |
| 2399 | CreateBrowserPlugin(this, frame, params); |
| 2400 | } |
| 2401 | |
[email protected] | c64e4d5 | 2012-06-20 23:09:06 | [diff] [blame] | 2402 | if (UTF16ToASCII(params.mimeType) == content::kBrowserPluginMimeType) |
[email protected] | cb25aa1 | 2012-08-07 19:13:43 | [diff] [blame] | 2403 | return content::old::BrowserPlugin::Create(this, frame, params); |
[email protected] | b1c4de4c | 2012-06-08 00:04:56 | [diff] [blame] | 2404 | |
[email protected] | a813c8e | 2011-10-08 01:34:11 | [diff] [blame] | 2405 | webkit::WebPluginInfo info; |
| 2406 | std::string mime_type; |
| 2407 | bool found = GetPluginInfo(params.url, frame->top()->document().url(), |
| 2408 | params.mimeType.utf8(), &info, &mime_type); |
| 2409 | if (!found) |
| 2410 | return NULL; |
| 2411 | |
| 2412 | WebPluginParams params_to_use = params; |
| 2413 | params_to_use.mimeType = WebString::fromUTF8(mime_type); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2414 | return CreatePlugin(frame, info, params_to_use); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2415 | } |
| 2416 | |
[email protected] | 6ac77cb | 2012-05-01 14:49:01 | [diff] [blame] | 2417 | WebPlugin* RenderViewImpl::createPluginReplacement( |
| 2418 | WebFrame* frame, |
| 2419 | const WebPluginParams& params) { |
| 2420 | webkit::WebPluginInfo info; |
| 2421 | std::string mime_type; |
| 2422 | GetPluginInfo(params.url, frame->top()->document().url(), |
| 2423 | params.mimeType.utf8(), &info, &mime_type); |
| 2424 | return content::GetContentClient()->renderer()->CreatePluginReplacement( |
| 2425 | this, info.path); |
| 2426 | } |
| 2427 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2428 | WebSharedWorker* RenderViewImpl::createSharedWorker( |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 2429 | WebFrame* frame, const WebURL& url, const WebString& name, |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2430 | unsigned long long document_id) { |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 2431 | |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2432 | int route_id = MSG_ROUTING_NONE; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2433 | bool exists = false; |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2434 | bool url_mismatch = false; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2435 | ViewHostMsg_CreateWorker_Params params; |
| 2436 | params.url = url; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2437 | params.name = name; |
| 2438 | params.document_id = document_id; |
| 2439 | params.render_view_route_id = routing_id_; |
| 2440 | params.route_id = MSG_ROUTING_NONE; |
[email protected] | f9bc9c0 | 2010-05-24 19:19:23 | [diff] [blame] | 2441 | params.script_resource_appcache_id = 0; |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2442 | Send(new ViewHostMsg_LookupSharedWorker( |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2443 | params, &exists, &route_id, &url_mismatch)); |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2444 | if (url_mismatch) { |
| 2445 | return NULL; |
| 2446 | } else { |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 2447 | return new WebSharedWorkerProxy(RenderThreadImpl::current(), |
[email protected] | 0791d3a | 2010-01-28 01:28:49 | [diff] [blame] | 2448 | document_id, |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2449 | exists, |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2450 | route_id, |
| 2451 | routing_id_); |
| 2452 | } |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 2453 | } |
| 2454 | |
[email protected] | 97b150db | 2012-08-16 18:26:02 | [diff] [blame] | 2455 | WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
| 2456 | WebFrame* frame, const WebKit::WebURL& url, WebMediaPlayerClient* client) { |
[email protected] | 16e923d | 2011-04-30 00:41:44 | [diff] [blame] | 2457 | FOR_EACH_OBSERVER( |
| 2458 | RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
[email protected] | 7198402c | 2011-04-11 12:15:17 | [diff] [blame] | 2459 | |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 2460 | #if defined(OS_ANDROID) |
[email protected] | dbd3d21 | 2012-07-13 02:17:22 | [diff] [blame] | 2461 | // TODO(qinmin): upstream the implementation of getting WebGraphicsContext3D |
| 2462 | // and GpuChannelHost here to replace the NULL params. |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 2463 | return new webkit_media::WebMediaPlayerAndroid( |
[email protected] | dbd3d21 | 2012-07-13 02:17:22 | [diff] [blame] | 2464 | frame, client, cookieJar(frame), media_player_manager_.get(), |
| 2465 | new content::StreamTextureFactoryImpl(NULL, NULL, routing_id_)); |
[email protected] | 25fb9b3 | 2012-04-27 03:21:55 | [diff] [blame] | 2466 | #endif |
| 2467 | |
[email protected] | bb6fd40 | 2011-12-09 02:45:44 | [diff] [blame] | 2468 | media::MessageLoopFactory* message_loop_factory = |
[email protected] | b8032290 | 2012-03-06 01:33:50 | [diff] [blame] | 2469 | new media::MessageLoopFactory(); |
[email protected] | bb6fd40 | 2011-12-09 02:45:44 | [diff] [blame] | 2470 | media::FilterCollection* collection = new media::FilterCollection(); |
| 2471 | RenderMediaLog* render_media_log = new RenderMediaLog(); |
[email protected] | 457d834 | 2010-10-23 01:20:37 | [diff] [blame] | 2472 | |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 2473 | RenderAudioSourceProvider* audio_source_provider = NULL; |
| 2474 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2475 | // Add in any custom filter factories first. |
| 2476 | const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 2477 | if (!cmd_line->HasSwitch(switches::kDisableAudio)) { |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 2478 | // audio_source_provider is a "provider" to WebKit, and a sink |
| 2479 | // from the perspective of the audio renderer. |
| 2480 | audio_source_provider = new RenderAudioSourceProvider(); |
| 2481 | |
| 2482 | // Add the chrome specific audio renderer, using audio_source_provider |
| 2483 | // as the sink. |
[email protected] | 37136d16 | 2012-04-09 23:39:19 | [diff] [blame] | 2484 | media::AudioRendererImpl* audio_renderer = |
| 2485 | new media::AudioRendererImpl(audio_source_provider); |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 2486 | collection->AddAudioRenderer(audio_renderer); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2487 | } |
| 2488 | |
[email protected] | 15d206e | 2012-08-17 22:35:13 | [diff] [blame] | 2489 | WebGraphicsContext3DCommandBufferImpl* context3d = NULL; |
| 2490 | if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 2491 | switches::kDisableAcceleratedVideoDecode)) |
| 2492 | context3d = RenderThreadImpl::current()->GetGpuVDAContext3D(); |
[email protected] | 851334d | 2012-06-15 22:39:31 | [diff] [blame] | 2493 | if (context3d) { |
[email protected] | 084c855 | 2012-08-12 22:51:20 | [diff] [blame] | 2494 | scoped_refptr<base::MessageLoopProxy> factories_loop = |
[email protected] | 84a83e19 | 2012-03-09 18:43:40 | [diff] [blame] | 2495 | RenderThreadImpl::current()->compositor_thread() ? |
| 2496 | RenderThreadImpl::current()->compositor_thread()->GetWebThread() |
[email protected] | 084c855 | 2012-08-12 22:51:20 | [diff] [blame] | 2497 | ->message_loop()->message_loop_proxy() : |
| 2498 | base::MessageLoopProxy::current(); |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 2499 | GpuChannelHost* gpu_channel_host = |
| 2500 | RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 2501 | content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
[email protected] | 873da26 | 2012-08-10 22:02:47 | [diff] [blame] | 2502 | collection->GetVideoDecoders()->push_back(new media::GpuVideoDecoder( |
[email protected] | 084c855 | 2012-08-12 22:51:20 | [diff] [blame] | 2503 | base::Bind(&media::MessageLoopFactory::GetMessageLoop, |
| 2504 | base::Unretained(message_loop_factory), |
| 2505 | media::MessageLoopFactory::kVideoDecoder), |
[email protected] | 84a83e19 | 2012-03-09 18:43:40 | [diff] [blame] | 2506 | factories_loop, |
[email protected] | 8d435928 | 2012-01-14 00:53:31 | [diff] [blame] | 2507 | new RendererGpuVideoDecoderFactories( |
[email protected] | 84a83e19 | 2012-03-09 18:43:40 | [diff] [blame] | 2508 | gpu_channel_host, factories_loop, context3d))); |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 2509 | } |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 2510 | |
[email protected] | 5d65fe9 | 2012-06-02 00:48:55 | [diff] [blame] | 2511 | WebMediaPlayer* media_player = |
[email protected] | da952fd | 2012-01-13 03:49:25 | [diff] [blame] | 2512 | content::GetContentClient()->renderer()->OverrideCreateWebMediaPlayer( |
| 2513 | this, frame, client, AsWeakPtr(), collection, audio_source_provider, |
[email protected] | 1113bfdf | 2012-07-16 21:46:10 | [diff] [blame] | 2514 | audio_source_provider, message_loop_factory, media_stream_impl_, |
| 2515 | render_media_log); |
[email protected] | da952fd | 2012-01-13 03:49:25 | [diff] [blame] | 2516 | if (!media_player) { |
[email protected] | cec4eb8 | 2012-01-12 17:51:56 | [diff] [blame] | 2517 | media_player = new webkit_media::WebMediaPlayerImpl( |
[email protected] | da952fd | 2012-01-13 03:49:25 | [diff] [blame] | 2518 | frame, client, AsWeakPtr(), collection, audio_source_provider, |
[email protected] | 1113bfdf | 2012-07-16 21:46:10 | [diff] [blame] | 2519 | audio_source_provider, message_loop_factory, media_stream_impl_, |
| 2520 | render_media_log); |
[email protected] | bb6fd40 | 2011-12-09 02:45:44 | [diff] [blame] | 2521 | } |
[email protected] | cec4eb8 | 2012-01-12 17:51:56 | [diff] [blame] | 2522 | return media_player; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2523 | } |
| 2524 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2525 | WebApplicationCacheHost* RenderViewImpl::createApplicationCacheHost( |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2526 | WebFrame* frame, WebApplicationCacheHostClient* client) { |
[email protected] | cdeeeb2 | 2012-01-11 07:44:23 | [diff] [blame] | 2527 | if (!frame || !frame->view()) |
| 2528 | return NULL; |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2529 | return new RendererWebApplicationCacheHostImpl( |
| 2530 | FromWebView(frame->view()), client, |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 2531 | RenderThreadImpl::current()->appcache_dispatcher()->backend_proxy()); |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2532 | } |
| 2533 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2534 | WebCookieJar* RenderViewImpl::cookieJar(WebFrame* frame) { |
[email protected] | 8ff18107 | 2010-11-29 17:09:38 | [diff] [blame] | 2535 | return &cookie_jar_; |
| 2536 | } |
| 2537 | |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 2538 | void RenderViewImpl::didCreateFrame(WebFrame* parent, WebFrame* child) { |
| 2539 | if (is_loading_) { |
| 2540 | pending_frame_tree_update_ = true; |
| 2541 | return; |
| 2542 | } |
| 2543 | if (!updating_frame_tree_) |
| 2544 | SendUpdatedFrameTree(NULL); |
| 2545 | } |
| 2546 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2547 | void RenderViewImpl::frameDetached(WebFrame* frame) { |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 2548 | if (is_loading_) { |
| 2549 | pending_frame_tree_update_ = true; |
| 2550 | // Make sure observers are notified, even if we return right away. |
| 2551 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameDetached(frame)); |
| 2552 | return; |
| 2553 | } |
| 2554 | if (!updating_frame_tree_) |
| 2555 | SendUpdatedFrameTree(frame); |
| 2556 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 2557 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameDetached(frame)); |
[email protected] | 5041f98 | 2010-08-11 21:40:45 | [diff] [blame] | 2558 | } |
| 2559 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2560 | void RenderViewImpl::willClose(WebFrame* frame) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 2561 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameWillClose(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2562 | } |
| 2563 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2564 | void RenderViewImpl::loadURLExternally( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2565 | WebFrame* frame, const WebURLRequest& request, |
| 2566 | WebNavigationPolicy policy) { |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2567 | loadURLExternally(frame, request, policy, WebString()); |
| 2568 | } |
| 2569 | |
[email protected] | 5e92282f | 2012-08-17 08:11:57 | [diff] [blame] | 2570 | void RenderViewImpl::Repaint(const gfx::Size& size) { |
| 2571 | OnMsgRepaint(size); |
| 2572 | } |
| 2573 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2574 | void RenderViewImpl::loadURLExternally( |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2575 | WebFrame* frame, const WebURLRequest& request, |
| 2576 | WebNavigationPolicy policy, |
| 2577 | const WebString& suggested_name) { |
[email protected] | 5650554 | 2012-05-12 00:25:37 | [diff] [blame] | 2578 | Referrer referrer( |
| 2579 | GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2580 | GetReferrerPolicyFromRequest(frame, request)); |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2581 | if (policy == WebKit::WebNavigationPolicyDownload) { |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2582 | Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, |
| 2583 | suggested_name)); |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2584 | } else { |
[email protected] | 5650554 | 2012-05-12 00:25:37 | [diff] [blame] | 2585 | OpenURL(frame, request.url(), referrer, policy); |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2586 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2587 | } |
| 2588 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2589 | WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2590 | WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
[email protected] | 65b95cd | 2009-10-09 05:10:22 | [diff] [blame] | 2591 | const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
[email protected] | 0639c063a | 2012-03-22 20:55:33 | [diff] [blame] | 2592 | Referrer referrer( |
| 2593 | GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
[email protected] | ca66282 | 2012-05-11 17:53:59 | [diff] [blame] | 2594 | GetReferrerPolicyFromRequest(frame, request)); |
[email protected] | 0639c063a | 2012-03-22 20:55:33 | [diff] [blame] | 2595 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 2596 | if (is_swapped_out_) { |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 2597 | if (request.url() != GURL(content::kSwappedOutURL)) { |
[email protected] | 0639c063a | 2012-03-22 20:55:33 | [diff] [blame] | 2598 | // Targeted links may try to navigate a swapped out frame. Allow the |
| 2599 | // browser process to navigate the tab instead. Note that it is also |
| 2600 | // possible for non-targeted navigations (from this view) to arrive |
| 2601 | // here just after we are swapped out. It's ok to send them to the |
| 2602 | // browser, as long as they're for the top level frame. |
| 2603 | // TODO(creis): Ensure this supports targeted form submissions when |
| 2604 | // fixing http://crbug.com/101395. |
| 2605 | if (frame->parent() == NULL) { |
| 2606 | OpenURL(frame, request.url(), referrer, default_policy); |
| 2607 | return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2608 | } |
| 2609 | |
| 2610 | // We should otherwise ignore in-process iframe navigations, if they |
| 2611 | // arrive just after we are swapped out. |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 2612 | return WebKit::WebNavigationPolicyIgnore; |
[email protected] | 0639c063a | 2012-03-22 20:55:33 | [diff] [blame] | 2613 | } |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 2614 | |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 2615 | // Allow content::kSwappedOutURL to complete. |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 2616 | return default_policy; |
| 2617 | } |
| 2618 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2619 | // Webkit is asking whether to navigate to a new URL. |
| 2620 | // This is fine normally, except if we're showing UI from one security |
| 2621 | // context and they're trying to navigate to a different context. |
| 2622 | const GURL& url = request.url(); |
| 2623 | |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 2624 | // A content initiated navigation may have originated from a link-click, |
| 2625 | // script, drag-n-drop operation, etc. |
| 2626 | bool is_content_initiated = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2627 | DocumentState::FromDataSource(frame->provisionalDataSource())-> |
| 2628 | navigation_state()->is_content_initiated(); |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 2629 | |
[email protected] | a8c269a | 2011-10-25 20:17:22 | [diff] [blame] | 2630 | // Experimental: |
| 2631 | // If --enable-strict-site-isolation is enabled, send all top-level |
| 2632 | // navigations to the browser to let it swap processes when crossing site |
| 2633 | // boundaries. This is currently expected to break some script calls and |
| 2634 | // navigations, such as form submissions. |
| 2635 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | 313b80bd | 2011-11-23 03:49:10 | [diff] [blame] | 2636 | if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && |
| 2637 | !frame->parent() && (is_content_initiated || is_redirect)) { |
| 2638 | WebString origin_str = frame->document().securityOrigin().toString(); |
| 2639 | GURL frame_url(origin_str.utf8().data()); |
| 2640 | // TODO(cevans): revisit whether this origin check is still necessary once |
| 2641 | // crbug.com/101395 is fixed. |
| 2642 | if (frame_url.GetOrigin() != url.GetOrigin()) { |
[email protected] | 313b80bd | 2011-11-23 03:49:10 | [diff] [blame] | 2643 | OpenURL(frame, url, referrer, default_policy); |
| 2644 | return WebKit::WebNavigationPolicyIgnore; |
| 2645 | } |
[email protected] | a8c269a | 2011-10-25 20:17:22 | [diff] [blame] | 2646 | } |
| 2647 | |
[email protected] | fd3238af | 2012-05-22 18:55:30 | [diff] [blame] | 2648 | // If the browser is interested, then give it a chance to look at the request. |
[email protected] | 5f000f27 | 2012-01-19 05:25:08 | [diff] [blame] | 2649 | if (is_content_initiated) { |
[email protected] | fd3238af | 2012-05-22 18:55:30 | [diff] [blame] | 2650 | bool browser_handles_request = |
| 2651 | renderer_preferences_.browser_handles_non_local_top_level_requests && |
[email protected] | 5f000f27 | 2012-01-19 05:25:08 | [diff] [blame] | 2652 | IsNonLocalTopLevelNavigation(url, frame, type); |
[email protected] | fd3238af | 2012-05-22 18:55:30 | [diff] [blame] | 2653 | if (!browser_handles_request) { |
| 2654 | browser_handles_request = |
| 2655 | renderer_preferences_.browser_handles_all_top_level_requests && |
| 2656 | IsTopLevelNavigation(frame); |
| 2657 | } |
| 2658 | |
| 2659 | if (browser_handles_request) { |
[email protected] | 5f000f27 | 2012-01-19 05:25:08 | [diff] [blame] | 2660 | // Reset these counters as the RenderView could be reused for the next |
| 2661 | // navigation. |
| 2662 | page_id_ = -1; |
| 2663 | last_page_id_sent_to_browser_ = -1; |
| 2664 | OpenURL(frame, url, referrer, default_policy); |
| 2665 | return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2666 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2667 | } |
| 2668 | |
[email protected] | dc67e1c3 | 2012-06-08 00:10:40 | [diff] [blame] | 2669 | // Use the frame's original request's URL rather than the document's URL for |
| 2670 | // subsequent checks. For a popup, the document's URL may become the opener |
| 2671 | // window's URL if the opener has called document.write(). |
| 2672 | // See http://crbug.com/93517. |
| 2673 | GURL old_url(frame->dataSource()->request().url()); |
| 2674 | |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2675 | // Detect when we're crossing a permission-based boundary (e.g. into or out of |
[email protected] | c39f9bf | 2011-02-12 00:43:55 | [diff] [blame] | 2676 | // an extension or app origin, leaving a WebUI page, etc). We only care about |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2677 | // top-level navigations (not iframes). But we sometimes navigate to |
| 2678 | // about:blank to clear a tab, and we want to still allow that. |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2679 | // |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2680 | // Note: this is known to break POST submissions when crossing process |
| 2681 | // boundaries until http://crbug.com/101395 is fixed. This is better for |
| 2682 | // security than loading a WebUI, extension or app page in the wrong process. |
| 2683 | // POST requests don't work because this mechanism does not preserve form |
| 2684 | // POST data. We will need to send the request's httpBody data up to the |
| 2685 | // browser process, and issue a special POST navigation in WebKit (via |
[email protected] | 8f4da8c | 2011-02-09 19:49:57 | [diff] [blame] | 2686 | // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl |
| 2687 | // for examples of how to send the httpBody data. |
[email protected] | 2762a1b | 2011-12-09 15:25:22 | [diff] [blame] | 2688 | if (!frame->parent() && is_content_initiated && |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2689 | !url.SchemeIs(chrome::kAboutScheme)) { |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2690 | bool send_referrer = false; |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2691 | |
| 2692 | // All navigations to WebUI URLs or within WebUI-enabled RenderProcesses |
| 2693 | // must be handled by the browser process so that the correct bindings and |
| 2694 | // data sources can be registered. |
| 2695 | // Similarly, navigations to view-source URLs or within ViewSource mode |
| 2696 | // must be handled by the browser process. |
[email protected] | dc67e1c3 | 2012-06-08 00:10:40 | [diff] [blame] | 2697 | // Lastly, access to file:// URLs from non-file:// URL pages must be |
| 2698 | // handled by the browser so that ordinary renderer processes don't get |
| 2699 | // blessed with file permissions. |
| 2700 | int cumulative_bindings = RenderProcess::current()->GetEnabledBindings(); |
| 2701 | bool is_initial_navigation = page_id_ == -1; |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2702 | bool should_fork = |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2703 | content::GetContentClient()->HasWebUIScheme(url) || |
| 2704 | (cumulative_bindings & content::BINDINGS_POLICY_WEB_UI) || |
| 2705 | url.SchemeIs(chrome::kViewSourceScheme) || |
| 2706 | frame->isViewSourceModeEnabled(); |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 2707 | |
[email protected] | dc67e1c3 | 2012-06-08 00:10:40 | [diff] [blame] | 2708 | if (!should_fork && url.SchemeIs(chrome::kFileScheme)) { |
| 2709 | // Fork non-file to file opens. Check the opener URL if this is the |
| 2710 | // initial navigation in a newly opened window. |
| 2711 | GURL source_url(old_url); |
| 2712 | if (is_initial_navigation && source_url.is_empty() && frame->opener()) |
| 2713 | source_url = frame->opener()->top()->document().url(); |
| 2714 | DCHECK(!source_url.is_empty()); |
| 2715 | should_fork = !source_url.SchemeIs(chrome::kFileScheme); |
| 2716 | } |
| 2717 | |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2718 | if (!should_fork) { |
| 2719 | // Give the embedder a chance. |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2720 | // For now, we skip this for POST submissions. This is because |
| 2721 | // http://crbug.com/101395 is more likely to cause compatibility issues |
| 2722 | // with hosted apps and extensions than WebUI pages. We will remove this |
| 2723 | // check when cross-process POST submissions are supported. |
| 2724 | if (request.httpMethod() == "GET") { |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 2725 | should_fork = content::GetContentClient()->renderer()->ShouldFork( |
| 2726 | frame, url, is_initial_navigation, &send_referrer); |
| 2727 | } |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2728 | } |
| 2729 | |
| 2730 | if (should_fork) { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2731 | OpenURL( |
| 2732 | frame, url, send_referrer ? referrer : Referrer(), default_policy); |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 2733 | return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2734 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2735 | } |
| 2736 | |
| 2737 | // Detect when a page is "forking" a new tab that can be safely rendered in |
| 2738 | // its own process. This is done by sites like Gmail that try to open links |
| 2739 | // in new windows without script connections back to the original page. We |
| 2740 | // treat such cases as browser navigations (in which we will create a new |
| 2741 | // renderer for a cross-site navigation), rather than WebKit navigations. |
| 2742 | // |
| 2743 | // We use the following heuristic to decide whether to fork a new page in its |
| 2744 | // own process: |
| 2745 | // The parent page must open a new tab to about:blank, set the new tab's |
| 2746 | // window.opener to null, and then redirect the tab to a cross-site URL using |
| 2747 | // JavaScript. |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 2748 | // |
| 2749 | // TODO(creis): Deprecate this logic once we can rely on rel=noreferrer |
| 2750 | // (see below). |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2751 | bool is_fork = |
| 2752 | // Must start from a tab showing about:blank, which is later redirected. |
[email protected] | a6b960ad97 | 2010-09-01 19:53:58 | [diff] [blame] | 2753 | old_url == GURL(chrome::kAboutBlankURL) && |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2754 | // Must be the first real navigation of the tab. |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2755 | historyBackListCount() < 1 && |
| 2756 | historyForwardListCount() < 1 && |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2757 | // The parent page must have set the child's window.opener to null before |
| 2758 | // redirecting to the desired URL. |
| 2759 | frame->opener() == NULL && |
| 2760 | // Must be a top-level frame. |
| 2761 | frame->parent() == NULL && |
| 2762 | // Must not have issued the request from this page. |
| 2763 | is_content_initiated && |
| 2764 | // Must be targeted at the current tab. |
| 2765 | default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 2766 | // Must be a JavaScript navigation, which appears as "other". |
| 2767 | type == WebKit::WebNavigationTypeOther; |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 2768 | |
[email protected] | f92ce2b | 2012-03-06 18:02:59 | [diff] [blame] | 2769 | if (is_fork) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2770 | // Open the URL via the browser, not via WebKit. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2771 | OpenURL(frame, url, Referrer(), default_policy); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2772 | return WebKit::WebNavigationPolicyIgnore; |
| 2773 | } |
| 2774 | |
| 2775 | return default_policy; |
| 2776 | } |
| 2777 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2778 | bool RenderViewImpl::canHandleRequest( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2779 | WebFrame* frame, const WebURLRequest& request) { |
| 2780 | // We allow WebKit to think that everything can be handled even though |
| 2781 | // browser-side we limit what we load. |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2782 | return true; |
| 2783 | } |
| 2784 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2785 | WebURLError RenderViewImpl::cannotHandleRequestError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2786 | WebFrame* frame, const WebURLRequest& request) { |
| 2787 | NOTREACHED(); // Since we said we can handle all requests. |
| 2788 | return WebURLError(); |
| 2789 | } |
| 2790 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2791 | WebURLError RenderViewImpl::cancelledError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2792 | WebFrame* frame, const WebURLRequest& request) { |
| 2793 | WebURLError error; |
| 2794 | error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2795 | error.reason = net::ERR_ABORTED; |
| 2796 | error.unreachableURL = request.url(); |
| 2797 | return error; |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2798 | } |
| 2799 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2800 | void RenderViewImpl::unableToImplementPolicyWithError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2801 | WebFrame*, const WebURLError&) { |
| 2802 | NOTREACHED(); // Since we said we can handle all requests. |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2803 | } |
| 2804 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2805 | void RenderViewImpl::willSendSubmitEvent(WebKit::WebFrame* frame, |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2806 | const WebKit::WebFormElement& form) { |
| 2807 | // Some login forms have onSubmit handlers that put a hash of the password |
| 2808 | // into a hidden field and then clear the password. (Issue 28910.) |
| 2809 | // This method gets called before any of those handlers run, so save away |
| 2810 | // a copy of the password in case it gets lost. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2811 | DocumentState* document_state = |
| 2812 | DocumentState::FromDataSource(frame->dataSource()); |
| 2813 | document_state->set_password_form_data( |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2814 | PasswordFormDomManager::CreatePasswordForm(form)); |
| 2815 | } |
| 2816 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2817 | void RenderViewImpl::willSubmitForm(WebFrame* frame, |
| 2818 | const WebFormElement& form) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2819 | DocumentState* document_state = |
| 2820 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 2821 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2822 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2823 | if (navigation_state->transition_type() == content::PAGE_TRANSITION_LINK) |
| 2824 | navigation_state->set_transition_type(content::PAGE_TRANSITION_FORM_SUBMIT); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2825 | |
| 2826 | // Save these to be processed when the ensuing navigation is committed. |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 2827 | WebSearchableFormData web_searchable_form_data(form); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2828 | document_state->set_searchable_form_url(web_searchable_form_data.url()); |
| 2829 | document_state->set_searchable_form_encoding( |
[email protected] | b7910b3a | 2010-01-13 18:33:21 | [diff] [blame] | 2830 | web_searchable_form_data.encoding().utf8()); |
[email protected] | a045f4e3 | 2012-08-31 09:36:07 | [diff] [blame] | 2831 | scoped_ptr<PasswordForm> password_form_data = |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2832 | PasswordFormDomManager::CreatePasswordForm(form); |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2833 | |
[email protected] | 098c95cb | 2011-04-28 16:49:01 | [diff] [blame] | 2834 | // In order to save the password that the user actually typed and not one |
| 2835 | // that may have gotten transformed by the site prior to submit, recover it |
| 2836 | // from the form contents already stored by |willSendSubmitEvent| into the |
| 2837 | // dataSource's NavigationState (as opposed to the provisionalDataSource's, |
| 2838 | // which is what we're storing into now.) |
[email protected] | a045f4e3 | 2012-08-31 09:36:07 | [diff] [blame] | 2839 | if (password_form_data.get()) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2840 | DocumentState* old_document_state = |
| 2841 | DocumentState::FromDataSource(frame->dataSource()); |
| 2842 | if (old_document_state) { |
| 2843 | PasswordForm* old_form_data = old_document_state->password_form_data(); |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2844 | if (old_form_data && old_form_data->action == password_form_data->action) |
| 2845 | password_form_data->password_value = old_form_data->password_value; |
| 2846 | } |
| 2847 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2848 | |
[email protected] | a045f4e3 | 2012-08-31 09:36:07 | [diff] [blame] | 2849 | document_state->set_password_form_data(password_form_data.Pass()); |
| 2850 | |
[email protected] | 2a5b173 | 2011-04-01 23:55:55 | [diff] [blame] | 2851 | FOR_EACH_OBSERVER( |
| 2852 | RenderViewObserver, observers_, WillSubmitForm(frame, form)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2853 | } |
| 2854 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2855 | void RenderViewImpl::willPerformClientRedirect( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2856 | WebFrame* frame, const WebURL& from, const WebURL& to, double interval, |
| 2857 | double fire_time) { |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2858 | FOR_EACH_OBSERVER( |
| 2859 | RenderViewObserver, observers_, |
| 2860 | WillPerformClientRedirect(frame, from, to, interval, fire_time)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2861 | } |
| 2862 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2863 | void RenderViewImpl::didCancelClientRedirect(WebFrame* frame) { |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2864 | FOR_EACH_OBSERVER( |
| 2865 | RenderViewObserver, observers_, DidCancelClientRedirect(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2866 | } |
| 2867 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2868 | void RenderViewImpl::didCompleteClientRedirect( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2869 | WebFrame* frame, const WebURL& from) { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2870 | if (!frame->parent()) { |
| 2871 | WebDataSource* ds = frame->provisionalDataSource(); |
| 2872 | // If there's no provisional data source, it's a reference fragment |
| 2873 | // navigation. |
| 2874 | completed_client_redirect_src_ = Referrer( |
[email protected] | ca66282 | 2012-05-11 17:53:59 | [diff] [blame] | 2875 | from, ds ? GetReferrerPolicyFromRequest(frame, ds->request()) : |
[email protected] | f36f409 | 2012-05-09 18:31:04 | [diff] [blame] | 2876 | frame->document().referrerPolicy()); |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2877 | } |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2878 | FOR_EACH_OBSERVER( |
| 2879 | RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2880 | } |
| 2881 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2882 | void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 2883 | bool content_initiated = !pending_navigation_params_.get(); |
| 2884 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2885 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2886 | if (!document_state) { |
| 2887 | document_state = new DocumentState; |
| 2888 | ds->setExtraData(document_state); |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 2889 | if (!content_initiated) |
| 2890 | PopulateDocumentStateFromPending(document_state); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2891 | } |
| 2892 | |
[email protected] | bf70edce | 2012-06-20 22:32:22 | [diff] [blame] | 2893 | // Carry over the user agent override flag, if it exists. |
| 2894 | if (content_initiated && webview() && webview()->mainFrame() && |
| 2895 | webview()->mainFrame()->dataSource()) { |
| 2896 | DocumentState* old_document_state = |
| 2897 | DocumentState::FromDataSource(webview()->mainFrame()->dataSource()); |
| 2898 | if (old_document_state) { |
| 2899 | document_state->set_is_overriding_user_agent( |
| 2900 | old_document_state->is_overriding_user_agent()); |
| 2901 | } |
| 2902 | } |
| 2903 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2904 | // The rest of RenderView assumes that a WebDataSource will always have a |
| 2905 | // non-null NavigationState. |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 2906 | if (content_initiated) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2907 | document_state->set_navigation_state( |
| 2908 | NavigationState::CreateContentInitiated()); |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 2909 | } else { |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 2910 | document_state->set_navigation_state(CreateNavigationStateFromPending()); |
| 2911 | pending_navigation_params_.reset(); |
| 2912 | } |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2913 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2914 | // DocumentState::referred_by_prefetcher_ is true if we are |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2915 | // navigating from a page that used prefetching using a link on that |
| 2916 | // page. We are early enough in the request process here that we |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2917 | // can still see the DocumentState of the previous page and set |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2918 | // this value appropriately. |
| 2919 | // TODO(gavinp): catch the important case of navigation in a new |
| 2920 | // renderer process. |
| 2921 | if (webview()) { |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 2922 | if (WebFrame* old_frame = webview()->mainFrame()) { |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2923 | const WebURLRequest& original_request = ds->originalRequest(); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2924 | const GURL referrer( |
| 2925 | original_request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 2926 | if (!referrer.is_empty() && |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2927 | DocumentState::FromDataSource( |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2928 | old_frame->dataSource())->was_prefetcher()) { |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 2929 | for (; old_frame; old_frame = old_frame->traverseNext(false)) { |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2930 | WebDataSource* old_frame_ds = old_frame->dataSource(); |
| 2931 | if (old_frame_ds && referrer == GURL(old_frame_ds->request().url())) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2932 | document_state->set_was_referred_by_prefetcher(true); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2933 | break; |
| 2934 | } |
| 2935 | } |
| 2936 | } |
| 2937 | } |
| 2938 | } |
| 2939 | |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2940 | if (content_initiated) { |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2941 | const WebURLRequest& request = ds->request(); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2942 | switch (request.cachePolicy()) { |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2943 | case WebURLRequest::UseProtocolCachePolicy: // normal load. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2944 | document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2945 | break; |
| 2946 | case WebURLRequest::ReloadIgnoringCacheData: // reload. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2947 | document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2948 | break; |
| 2949 | case WebURLRequest::ReturnCacheDataElseLoad: // allow stale data. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2950 | document_state->set_load_type( |
| 2951 | DocumentState::LINK_LOAD_CACHE_STALE_OK); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2952 | break; |
| 2953 | case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2954 | document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2955 | break; |
| 2956 | } |
| 2957 | } |
[email protected] | fa7b6b54 | 2009-11-03 05:02:30 | [diff] [blame] | 2958 | |
[email protected] | 946a003 | 2011-03-31 18:42:28 | [diff] [blame] | 2959 | FOR_EACH_OBSERVER( |
| 2960 | RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2961 | } |
| 2962 | |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 2963 | void RenderViewImpl::PopulateDocumentStateFromPending( |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2964 | DocumentState* document_state) { |
| 2965 | const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 2966 | document_state->set_request_time(params.request_time); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2967 | |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 2968 | if (!params.url.SchemeIs(chrome::kJavaScriptScheme) && |
| 2969 | params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { |
| 2970 | // We're doing a load of a page that was restored from the last session. By |
| 2971 | // default this prefers the cache over loading (LOAD_PREFERRING_CACHE) which |
| 2972 | // can result in stale data for pages that are set to expire. We explicitly |
| 2973 | // override that by setting the policy here so that as necessary we load |
| 2974 | // from the network. |
| 2975 | document_state->set_cache_policy_override( |
| 2976 | WebURLRequest::UseProtocolCachePolicy); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2977 | } |
| 2978 | |
| 2979 | if (IsReload(params)) |
| 2980 | document_state->set_load_type(DocumentState::RELOAD); |
| 2981 | else if (!params.state.empty()) |
| 2982 | document_state->set_load_type(DocumentState::HISTORY_LOAD); |
| 2983 | else |
| 2984 | document_state->set_load_type(DocumentState::NORMAL_LOAD); |
[email protected] | ca66282 | 2012-05-11 17:53:59 | [diff] [blame] | 2985 | |
| 2986 | document_state->set_referrer_policy(params.referrer.policy); |
[email protected] | bf70edce | 2012-06-20 22:32:22 | [diff] [blame] | 2987 | document_state->set_is_overriding_user_agent(params.is_overriding_user_agent); |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 2988 | } |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2989 | |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 2990 | NavigationState* RenderViewImpl::CreateNavigationStateFromPending() { |
| 2991 | const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
| 2992 | NavigationState* navigation_state = NULL; |
| 2993 | |
| 2994 | // A navigation resulting from loading a javascript URL should not be treated |
| 2995 | // as a browser initiated event. Instead, we want it to look as if the page |
| 2996 | // initiated any load resulting from JS execution. |
| 2997 | if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { |
| 2998 | navigation_state = NavigationState::CreateBrowserInitiated( |
| 2999 | params.page_id, |
| 3000 | params.pending_history_list_offset, |
| 3001 | params.transition); |
| 3002 | navigation_state->set_transferred_request_child_id( |
| 3003 | params.transferred_request_child_id); |
| 3004 | navigation_state->set_transferred_request_request_id( |
| 3005 | params.transferred_request_request_id); |
[email protected] | 8074478 | 2012-05-04 01:47:00 | [diff] [blame] | 3006 | navigation_state->set_allow_download(params.allow_download); |
[email protected] | 45d83a1 | 2012-04-06 22:57:57 | [diff] [blame] | 3007 | } else { |
| 3008 | navigation_state = NavigationState::CreateContentInitiated(); |
| 3009 | } |
| 3010 | return navigation_state; |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3011 | } |
| 3012 | |
[email protected] | 5b52cd2f71 | 2012-03-28 02:12:48 | [diff] [blame] | 3013 | void RenderViewImpl::ProcessViewLayoutFlags(const CommandLine& command_line) { |
| 3014 | bool enable_viewport = |
[email protected] | 06ea34a | 2012-05-07 18:52:10 | [diff] [blame] | 3015 | command_line.HasSwitch(switches::kEnableViewport); |
[email protected] | 5b52cd2f71 | 2012-03-28 02:12:48 | [diff] [blame] | 3016 | bool enable_fixed_layout = |
| 3017 | command_line.HasSwitch(switches::kEnableFixedLayout); |
[email protected] | 4ef6104a | 2012-06-06 18:15:32 | [diff] [blame] | 3018 | bool enable_pinch = enable_viewport || |
| 3019 | command_line.HasSwitch(switches::kEnablePinch); |
[email protected] | 5b52cd2f71 | 2012-03-28 02:12:48 | [diff] [blame] | 3020 | |
| 3021 | webview()->enableFixedLayoutMode(enable_fixed_layout || enable_viewport); |
| 3022 | webview()->settings()->setFixedElementsLayoutRelativeToFrame(true); |
[email protected] | 4ef6104a | 2012-06-06 18:15:32 | [diff] [blame] | 3023 | if (!enable_pinch && |
[email protected] | 60051ec | 2012-06-08 22:40:57 | [diff] [blame] | 3024 | webview()->isAcceleratedCompositingActive() && |
[email protected] | 4ef6104a | 2012-06-06 18:15:32 | [diff] [blame] | 3025 | webkit_preferences_.apply_default_device_scale_factor_in_compositor && |
[email protected] | 60051ec | 2012-06-08 22:40:57 | [diff] [blame] | 3026 | device_scale_factor_ != 1) { |
[email protected] | 4ef6104a | 2012-06-06 18:15:32 | [diff] [blame] | 3027 | // Page scaling is disabled by default when applying a scale factor in the |
| 3028 | // compositor since they are currently incompatible. |
| 3029 | webview()->setPageScaleFactorLimits(1, 1); |
| 3030 | } |
[email protected] | 5b52cd2f71 | 2012-03-28 02:12:48 | [diff] [blame] | 3031 | |
| 3032 | if (enable_viewport) { |
| 3033 | webview()->settings()->setViewportEnabled(true); |
| 3034 | } else if (enable_fixed_layout) { |
| 3035 | std::string str = |
| 3036 | command_line.GetSwitchValueASCII(switches::kEnableFixedLayout); |
| 3037 | std::vector<std::string> tokens; |
| 3038 | base::SplitString(str, ',', &tokens); |
| 3039 | if (tokens.size() == 2) { |
| 3040 | int width, height; |
| 3041 | if (base::StringToInt(tokens[0], &width) && |
| 3042 | base::StringToInt(tokens[1], &height)) |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 3043 | webview()->setFixedLayoutSize(WebSize(width, height)); |
[email protected] | 5b52cd2f71 | 2012-03-28 02:12:48 | [diff] [blame] | 3044 | } |
| 3045 | } |
| 3046 | } |
| 3047 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3048 | void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3049 | WebDataSource* ds = frame->provisionalDataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3050 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3051 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3052 | // Update the request time if WebKit has better knowledge of it. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3053 | if (document_state->request_time().is_null()) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3054 | double event_time = ds->triggeringEventTime(); |
| 3055 | if (event_time != 0.0) |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3056 | document_state->set_request_time(Time::FromDoubleT(event_time)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3057 | } |
| 3058 | |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 3059 | // Start time is only set after request time. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3060 | document_state->set_start_load_time(Time::Now()); |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 3061 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3062 | bool is_top_most = !frame->parent(); |
| 3063 | if (is_top_most) { |
| 3064 | navigation_gesture_ = frame->isProcessingUserGesture() ? |
[email protected] | cd44809 | 2010-12-06 23:49:13 | [diff] [blame] | 3065 | NavigationGestureUser : NavigationGestureAuto; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3066 | |
| 3067 | // Make sure redirect tracking state is clear for the new load. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 3068 | completed_client_redirect_src_ = Referrer(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3069 | } else if (frame->parent()->isLoading()) { |
| 3070 | // Take note of AUTO_SUBFRAME loads here, so that we can know how to |
[email protected] | 4fb6684 | 2009-12-04 21:41:00 | [diff] [blame] | 3071 | // load an error page. See didFailProvisionalLoad. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3072 | document_state->navigation_state()->set_transition_type( |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 3073 | content::PAGE_TRANSITION_AUTO_SUBFRAME); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3074 | } |
| 3075 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 3076 | FOR_EACH_OBSERVER( |
| 3077 | RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); |
| 3078 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3079 | Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 3080 | routing_id_, frame->identifier(), is_top_most, GetOpenerUrl(), |
[email protected] | eacb080b | 2011-05-22 19:40:26 | [diff] [blame] | 3081 | ds->request().url())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3082 | } |
| 3083 | |
[email protected] | 400992b | 2012-06-14 00:03:54 | [diff] [blame] | 3084 | void RenderViewImpl::didReceiveServerRedirectForProvisionalLoad( |
| 3085 | WebFrame* frame) { |
| 3086 | if (frame->parent()) |
| 3087 | return; |
| 3088 | // Received a redirect on the main frame. |
| 3089 | WebDataSource* data_source = frame->provisionalDataSource(); |
| 3090 | if (!data_source) { |
| 3091 | // Should only be invoked when we have a data source. |
| 3092 | NOTREACHED(); |
| 3093 | return; |
| 3094 | } |
| 3095 | std::vector<GURL> redirects; |
| 3096 | GetRedirectChain(data_source, &redirects); |
| 3097 | if (redirects.size() >= 2) { |
| 3098 | Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_, |
| 3099 | GetOpenerUrl(), redirects[redirects.size() - 2], redirects.back())); |
| 3100 | } |
| 3101 | } |
| 3102 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3103 | void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, |
| 3104 | const WebURLError& error) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3105 | // Notify the browser that we failed a provisional load with an error. |
| 3106 | // |
| 3107 | // Note: It is important this notification occur before DidStopLoading so the |
| 3108 | // SSL manager can react to the provisional load failure before being |
| 3109 | // notified the load stopped. |
| 3110 | // |
| 3111 | WebDataSource* ds = frame->provisionalDataSource(); |
| 3112 | DCHECK(ds); |
| 3113 | |
| 3114 | const WebURLRequest& failed_request = ds->request(); |
| 3115 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 3116 | FOR_EACH_OBSERVER( |
| 3117 | RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); |
| 3118 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3119 | bool show_repost_interstitial = |
| 3120 | (error.reason == net::ERR_CACHE_MISS && |
| 3121 | EqualsASCII(failed_request.httpMethod(), "POST")); |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 3122 | |
| 3123 | ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 3124 | params.frame_id = frame->identifier(); |
| 3125 | params.is_main_frame = !frame->parent(); |
| 3126 | params.error_code = error.reason; |
| 3127 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 3128 | failed_request, |
| 3129 | error, |
| 3130 | NULL, |
| 3131 | ¶ms.error_description); |
| 3132 | params.url = error.unreachableURL; |
| 3133 | params.showing_repost_interstitial = show_repost_interstitial; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3134 | Send(new ViewHostMsg_DidFailProvisionalLoadWithError( |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 3135 | routing_id_, params)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3136 | |
| 3137 | // Don't display an error page if this is simply a cancelled load. Aside |
| 3138 | // from being dumb, WebCore doesn't expect it and it will cause a crash. |
| 3139 | if (error.reason == net::ERR_ABORTED) |
| 3140 | return; |
[email protected] | b553edd5 | 2012-01-10 12:15:23 | [diff] [blame] | 3141 | // Don't display an error message if the request was handled by an |
| 3142 | // external protocol handler. |
| 3143 | if (error.reason == net::ERR_UNKNOWN_URL_SCHEME) |
| 3144 | return; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3145 | |
| 3146 | // Make sure we never show errors in view source mode. |
| 3147 | frame->enableViewSourceMode(false); |
| 3148 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3149 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3150 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3151 | |
| 3152 | // If this is a failed back/forward/reload navigation, then we need to do a |
| 3153 | // 'replace' load. This is necessary to avoid messing up session history. |
| 3154 | // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| 3155 | // as session history is concerned. |
| 3156 | // |
| 3157 | // AUTO_SUBFRAME loads should always be treated as loads that do not advance |
| 3158 | // the page id. |
| 3159 | // |
| 3160 | bool replace = |
| 3161 | navigation_state->pending_page_id() != -1 || |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 3162 | navigation_state->transition_type() == |
| 3163 | content::PAGE_TRANSITION_AUTO_SUBFRAME; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3164 | |
| 3165 | // If we failed on a browser initiated request, then make sure that our error |
| 3166 | // page load is regarded as the same browser initiated request. |
| 3167 | if (!navigation_state->is_content_initiated()) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3168 | pending_navigation_params_.reset(new ViewMsg_Navigate_Params); |
| 3169 | pending_navigation_params_->page_id = |
| 3170 | navigation_state->pending_page_id(); |
| 3171 | pending_navigation_params_->pending_history_list_offset = |
| 3172 | navigation_state->pending_history_list_offset(); |
| 3173 | pending_navigation_params_->transition = |
| 3174 | navigation_state->transition_type(); |
| 3175 | pending_navigation_params_->request_time = |
| 3176 | document_state->request_time(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3177 | } |
| 3178 | |
| 3179 | // Provide the user with a more helpful error page? |
| 3180 | if (MaybeLoadAlternateErrorPage(frame, error, replace)) |
| 3181 | return; |
| 3182 | |
| 3183 | // Fallback to a local error page. |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 3184 | LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3185 | } |
| 3186 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3187 | void RenderViewImpl::didReceiveDocumentData( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3188 | WebFrame* frame, const char* data, size_t data_len, |
| 3189 | bool& prevent_default) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3190 | DocumentState* document_state = |
| 3191 | DocumentState::FromDataSource(frame->dataSource()); |
| 3192 | document_state->set_use_error_page(false); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3193 | } |
| 3194 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3195 | void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, |
| 3196 | bool is_new_navigation) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3197 | DocumentState* document_state = |
| 3198 | DocumentState::FromDataSource(frame->dataSource()); |
| 3199 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3200 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3201 | if (document_state->commit_load_time().is_null()) |
| 3202 | document_state->set_commit_load_time(Time::Now()); |
| 3203 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3204 | if (is_new_navigation) { |
[email protected] | e15f68073 | 2010-11-23 22:30:20 | [diff] [blame] | 3205 | // When we perform a new navigation, we need to update the last committed |
| 3206 | // session history entry with state for the page we are leaving. |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3207 | UpdateSessionHistory(frame); |
| 3208 | |
| 3209 | // We bump our Page ID to correspond with the new session history entry. |
| 3210 | page_id_ = next_page_id_++; |
| 3211 | |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 3212 | // Don't update history_page_ids_ (etc) for content::kSwappedOutURL, since |
[email protected] | 58436a1 | 2012-03-21 17:10:26 | [diff] [blame] | 3213 | // we don't want to forget the entry that was there, and since we will |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 3214 | // never come back to content::kSwappedOutURL. Note that we have to call |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 3215 | // UpdateSessionHistory and update page_id_ even in this case, so that |
| 3216 | // the current entry gets a state update and so that we don't send a |
| 3217 | // state update to the wrong entry when we swap back in. |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 3218 | if (GetLoadingUrl(frame) != GURL(content::kSwappedOutURL)) { |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 3219 | // Advance our offset in session history, applying the length limit. |
| 3220 | // There is now no forward history. |
| 3221 | history_list_offset_++; |
| 3222 | if (history_list_offset_ >= content::kMaxSessionHistoryEntries) |
| 3223 | history_list_offset_ = content::kMaxSessionHistoryEntries - 1; |
| 3224 | history_list_length_ = history_list_offset_ + 1; |
| 3225 | history_page_ids_.resize(history_list_length_, -1); |
| 3226 | history_page_ids_[history_list_offset_] = page_id_; |
| 3227 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3228 | } else { |
| 3229 | // Inspect the navigation_state on this frame to see if the navigation |
| 3230 | // corresponds to a session history navigation... Note: |frame| may or |
| 3231 | // may not be the toplevel frame, but for the case of capturing session |
| 3232 | // history, the first committed frame suffices. We keep track of whether |
| 3233 | // we've seen this commit before so that only capture session history once |
| 3234 | // per navigation. |
| 3235 | // |
| 3236 | // Note that we need to check if the page ID changed. In the case of a |
| 3237 | // reload, the page ID doesn't change, and UpdateSessionHistory gets the |
| 3238 | // previous URL and the current page ID, which would be wrong. |
| 3239 | if (navigation_state->pending_page_id() != -1 && |
| 3240 | navigation_state->pending_page_id() != page_id_ && |
| 3241 | !navigation_state->request_committed()) { |
| 3242 | // This is a successful session history navigation! |
| 3243 | UpdateSessionHistory(frame); |
| 3244 | page_id_ = navigation_state->pending_page_id(); |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 3245 | |
| 3246 | history_list_offset_ = navigation_state->pending_history_list_offset(); |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 3247 | |
| 3248 | // If the history list is valid, our list of page IDs should be correct. |
| 3249 | DCHECK(history_list_length_ <= 0 || |
| 3250 | history_list_offset_ < 0 || |
| 3251 | history_list_offset_ >= history_list_length_ || |
| 3252 | history_page_ids_[history_list_offset_] == page_id_); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3253 | } |
| 3254 | } |
| 3255 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 3256 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3257 | DidCommitProvisionalLoad(frame, is_new_navigation)); |
| 3258 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3259 | // Remember that we've already processed this request, so we don't update |
| 3260 | // the session history again. We do this regardless of whether this is |
| 3261 | // a session history navigation, because if we attempted a session history |
| 3262 | // navigation without valid HistoryItem state, WebCore will think it is a |
| 3263 | // new navigation. |
| 3264 | navigation_state->set_request_committed(true); |
| 3265 | |
| 3266 | UpdateURL(frame); |
| 3267 | |
| 3268 | // If this committed load was initiated by a client redirect, we're |
| 3269 | // at the last stop now, so clear it. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 3270 | completed_client_redirect_src_ = Referrer(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3271 | |
| 3272 | // Check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3273 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3274 | } |
| 3275 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3276 | void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
[email protected] | 9966325b | 2011-04-18 05:00:10 | [diff] [blame] | 3277 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3278 | DidClearWindowObject(frame)); |
| 3279 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3280 | GURL frame_url = frame->document().url(); |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 3281 | if ((enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) && |
[email protected] | bfa83eb8 | 2010-10-06 08:41:25 | [diff] [blame] | 3282 | (frame_url.SchemeIs(chrome::kChromeUIScheme) || |
| 3283 | frame_url.SchemeIs(chrome::kDataScheme))) { |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 3284 | GetWebUIBindings()->BindToJavascript(frame, "chrome"); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3285 | } |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 3286 | |
| 3287 | if (enabled_bindings_ & content::BINDINGS_POLICY_DOM_AUTOMATION) { |
| 3288 | if (!dom_automation_controller_.get()) |
| 3289 | dom_automation_controller_.reset(new DomAutomationController()); |
| 3290 | dom_automation_controller_->set_message_sender( |
| 3291 | static_cast<content::RenderView*>(this)); |
| 3292 | dom_automation_controller_->set_routing_id(routing_id()); |
| 3293 | dom_automation_controller_->BindToJavascript(frame, |
| 3294 | "domAutomationController"); |
| 3295 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3296 | } |
| 3297 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3298 | void RenderViewImpl::didCreateDocumentElement(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3299 | // Notify the browser about non-blank documents loading in the top frame. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3300 | GURL url = frame->document().url(); |
[email protected] | e0d48158 | 2009-09-15 21:06:25 | [diff] [blame] | 3301 | if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { |
[email protected] | 87717d0e | 2012-04-26 02:58:43 | [diff] [blame] | 3302 | if (frame == webview()->mainFrame()) |
| 3303 | Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3304 | } |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 3305 | |
| 3306 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3307 | DidCreateDocumentElement(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3308 | } |
| 3309 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3310 | void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title, |
| 3311 | WebTextDirection direction) { |
[email protected] | a49e10b | 2011-08-01 23:57:46 | [diff] [blame] | 3312 | UpdateTitle(frame, title, direction); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3313 | |
| 3314 | // Also check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3315 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3316 | } |
| 3317 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3318 | void RenderViewImpl::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { |
[email protected] | 42054a25 | 2011-05-17 18:02:13 | [diff] [blame] | 3319 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3320 | DidChangeIcon(frame, type)); |
[email protected] | 5019ef1 | 2010-04-27 17:26:58 | [diff] [blame] | 3321 | } |
| 3322 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3323 | void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3324 | WebDataSource* ds = frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3325 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3326 | document_state->set_finish_document_load_time(Time::Now()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3327 | |
[email protected] | 622474d | 2010-11-04 09:21:08 | [diff] [blame] | 3328 | Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3329 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 3330 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3331 | DidFinishDocumentLoad(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3332 | |
| 3333 | // Check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3334 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3335 | } |
| 3336 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3337 | void RenderViewImpl::didHandleOnloadEvents(WebFrame* frame) { |
[email protected] | 2549749 | 2010-09-11 15:15:08 | [diff] [blame] | 3338 | if (webview()->mainFrame() == frame) { |
| 3339 | Send(new ViewHostMsg_DocumentOnLoadCompletedInMainFrame(routing_id_, |
| 3340 | page_id_)); |
| 3341 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3342 | } |
| 3343 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3344 | void RenderViewImpl::didFailLoad(WebFrame* frame, const WebURLError& error) { |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 3345 | WebDataSource* ds = frame->dataSource(); |
| 3346 | DCHECK(ds); |
| 3347 | |
| 3348 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 3349 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 3350 | |
| 3351 | const WebURLRequest& failed_request = ds->request(); |
| 3352 | string16 error_description; |
| 3353 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 3354 | failed_request, |
| 3355 | error, |
| 3356 | NULL, |
| 3357 | &error_description); |
| 3358 | Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, |
| 3359 | frame->identifier(), |
| 3360 | failed_request.url(), |
| 3361 | !frame->parent(), |
| 3362 | error.reason, |
| 3363 | error_description)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3364 | } |
| 3365 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3366 | void RenderViewImpl::didFinishLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3367 | WebDataSource* ds = frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3368 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 3369 | if (document_state->finish_load_time().is_null()) |
| 3370 | document_state->set_finish_load_time(Time::Now()); |
[email protected] | 4d44a1c | 2010-04-28 19:20:41 | [diff] [blame] | 3371 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 3372 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); |
[email protected] | fdd94a0 | 2010-11-05 08:07:17 | [diff] [blame] | 3373 | |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 3374 | Send(new ViewHostMsg_DidFinishLoad(routing_id_, |
| 3375 | frame->identifier(), |
| 3376 | ds->request().url(), |
| 3377 | !frame->parent())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3378 | } |
| 3379 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3380 | void RenderViewImpl::didNavigateWithinPage( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3381 | WebFrame* frame, bool is_new_navigation) { |
| 3382 | // If this was a reference fragment navigation that we initiated, then we |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3383 | // could end up having a non-null pending navigation params. We just need to |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3384 | // update the ExtraData on the datasource so that others who read the |
| 3385 | // ExtraData will get the new NavigationState. Similarly, if we did not |
| 3386 | // initiate this navigation, then we need to take care to reset any pre- |
| 3387 | // existing navigation state to a content-initiated navigation state. |
| 3388 | // DidCreateDataSource conveniently takes care of this for us. |
| 3389 | didCreateDataSource(frame, frame->dataSource()); |
| 3390 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3391 | DocumentState* document_state = |
| 3392 | DocumentState::FromDataSource(frame->dataSource()); |
| 3393 | NavigationState* new_state = document_state->navigation_state(); |
[email protected] | af15bed | 2010-08-25 21:12:09 | [diff] [blame] | 3394 | new_state->set_was_within_same_page(true); |
| 3395 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3396 | didCommitProvisionalLoad(frame, is_new_navigation); |
| 3397 | |
[email protected] | 750fcf87 | 2011-08-03 23:10:47 | [diff] [blame] | 3398 | WebDataSource* datasource = frame->view()->mainFrame()->dataSource(); |
| 3399 | UpdateTitle(frame, datasource->pageTitle(), datasource->pageTitleDirection()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3400 | } |
| 3401 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3402 | void RenderViewImpl::didUpdateCurrentHistoryItem(WebFrame* frame) { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 3403 | StartNavStateSyncTimerIfNecessary(); |
[email protected] | 476b6f8 | 2009-09-10 21:00:59 | [diff] [blame] | 3404 | } |
| 3405 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3406 | void RenderViewImpl::assignIdentifierToRequest( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3407 | WebFrame* frame, unsigned identifier, const WebURLRequest& request) { |
| 3408 | // Ignore |
| 3409 | } |
| 3410 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3411 | void RenderViewImpl::willSendRequest(WebFrame* frame, |
| 3412 | unsigned identifier, |
| 3413 | WebURLRequest& request, |
| 3414 | const WebURLResponse& redirect_response) { |
[email protected] | 5e36967 | 2009-11-03 23:48:30 | [diff] [blame] | 3415 | WebFrame* top_frame = frame->top(); |
| 3416 | if (!top_frame) |
| 3417 | top_frame = frame; |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 3418 | WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
| 3419 | WebDataSource* top_data_source = top_frame->dataSource(); |
| 3420 | WebDataSource* data_source = |
| 3421 | provisional_data_source ? provisional_data_source : top_data_source; |
[email protected] | 78d5cfe | 2011-02-04 08:43:22 | [diff] [blame] | 3422 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 3423 | content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3424 | DocumentState* document_state = DocumentState::FromDataSource(data_source); |
[email protected] | def55e02 | 2012-07-26 01:15:29 | [diff] [blame] | 3425 | DCHECK(document_state); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3426 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | e1ed5a1 | 2012-08-08 19:57:44 | [diff] [blame] | 3427 | transition_type = navigation_state->transition_type(); |
| 3428 | |
| 3429 | GURL request_url(request.url()); |
| 3430 | GURL new_url; |
| 3431 | if (content::GetContentClient()->renderer()->WillSendRequest( |
| 3432 | frame, transition_type, request_url, &new_url)) { |
| 3433 | request.setURL(WebURL(new_url)); |
| 3434 | } |
| 3435 | |
[email protected] | def55e02 | 2012-07-26 01:15:29 | [diff] [blame] | 3436 | if (document_state->is_cache_policy_override_set()) |
| 3437 | request.setCachePolicy(document_state->cache_policy_override()); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 3438 | |
[email protected] | ca66282 | 2012-05-11 17:53:59 | [diff] [blame] | 3439 | WebKit::WebReferrerPolicy referrer_policy; |
| 3440 | if (document_state && document_state->is_referrer_policy_set()) { |
| 3441 | referrer_policy = document_state->referrer_policy(); |
| 3442 | document_state->clear_referrer_policy(); |
| 3443 | } else { |
| 3444 | referrer_policy = frame->document().referrerPolicy(); |
| 3445 | } |
| 3446 | |
[email protected] | e372f3d | 2012-07-17 19:16:44 | [diff] [blame] | 3447 | // The request's extra data may indicate that we should set a custom user |
| 3448 | // agent. This needs to be done here, after WebKit is through with setting the |
| 3449 | // user agent on its own. |
| 3450 | WebString custom_user_agent; |
| 3451 | if (request.extraData()) { |
| 3452 | webkit_glue::WebURLRequestExtraDataImpl* old_extra_data = |
| 3453 | static_cast<webkit_glue::WebURLRequestExtraDataImpl*>( |
| 3454 | request.extraData()); |
| 3455 | custom_user_agent = old_extra_data->custom_user_agent(); |
| 3456 | |
| 3457 | if (!custom_user_agent.isNull()) { |
| 3458 | if (custom_user_agent.isEmpty()) |
| 3459 | request.clearHTTPHeaderField("User-Agent"); |
| 3460 | else |
| 3461 | request.setHTTPHeaderField("User-Agent", custom_user_agent); |
| 3462 | } |
| 3463 | } |
| 3464 | |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 3465 | request.setExtraData( |
[email protected] | ca66282 | 2012-05-11 17:53:59 | [diff] [blame] | 3466 | new RequestExtraData(referrer_policy, |
[email protected] | e372f3d | 2012-07-17 19:16:44 | [diff] [blame] | 3467 | custom_user_agent, |
[email protected] | 537fbe0 | 2011-11-24 00:58:06 | [diff] [blame] | 3468 | (frame == top_frame), |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 3469 | frame->identifier(), |
| 3470 | frame->parent() == top_frame, |
| 3471 | frame->parent() ? frame->parent()->identifier() : -1, |
[email protected] | 8074478 | 2012-05-04 01:47:00 | [diff] [blame] | 3472 | navigation_state->allow_download(), |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 3473 | transition_type, |
| 3474 | navigation_state->transferred_request_child_id(), |
| 3475 | navigation_state->transferred_request_request_id())); |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 3476 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3477 | DocumentState* top_document_state = |
| 3478 | DocumentState::FromDataSource(top_data_source); |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 3479 | // TODO(gavinp): separate out prefetching and prerender field trials |
| 3480 | // if the rel=prerender rel type is sticking around. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3481 | if (top_document_state && |
[email protected] | 925dec1c | 2012-05-18 05:09:00 | [diff] [blame] | 3482 | request.targetType() == WebURLRequest::TargetIsPrefetch) |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3483 | top_document_state->set_was_prefetcher(true); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 3484 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3485 | request.setRequestorID(routing_id_); |
[email protected] | cd44809 | 2010-12-06 23:49:13 | [diff] [blame] | 3486 | request.setHasUserGesture(frame->isProcessingUserGesture()); |
| 3487 | |
[email protected] | 0a8db0d | 2011-04-13 15:15:40 | [diff] [blame] | 3488 | if (!renderer_preferences_.enable_referrers) |
[email protected] | 7deade4 | 2010-03-05 09:33:13 | [diff] [blame] | 3489 | request.clearHTTPHeaderField("Referer"); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3490 | } |
| 3491 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3492 | void RenderViewImpl::didReceiveResponse( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3493 | WebFrame* frame, unsigned identifier, const WebURLResponse& response) { |
[email protected] | fa0a343 | 2010-03-30 16:53:49 | [diff] [blame] | 3494 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3495 | // Only do this for responses that correspond to a provisional data source |
| 3496 | // of the top-most frame. If we have a provisional data source, then we |
| 3497 | // can't have any sub-resources yet, so we know that this response must |
| 3498 | // correspond to a frame load. |
| 3499 | if (!frame->provisionalDataSource() || frame->parent()) |
| 3500 | return; |
| 3501 | |
| 3502 | // If we are in view source mode, then just let the user see the source of |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 3503 | // the server's error page. |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3504 | if (frame->isViewSourceModeEnabled()) |
| 3505 | return; |
| 3506 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3507 | DocumentState* document_state = |
| 3508 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 3509 | int http_status_code = response.httpStatusCode(); |
[email protected] | 65041fa | 2010-05-21 06:56:53 | [diff] [blame] | 3510 | |
[email protected] | 972ebdff | 2010-06-10 22:59:07 | [diff] [blame] | 3511 | // Record page load flags. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3512 | document_state->set_was_fetched_via_spdy(response.wasFetchedViaSPDY()); |
| 3513 | document_state->set_was_npn_negotiated(response.wasNpnNegotiated()); |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 3514 | WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); |
| 3515 | if (extra_data) { |
| 3516 | document_state->set_npn_negotiated_protocol( |
| 3517 | extra_data->npn_negotiated_protocol()); |
| 3518 | } |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3519 | document_state->set_was_alternate_protocol_available( |
[email protected] | 193b0b89 | 2010-06-26 03:57:57 | [diff] [blame] | 3520 | response.wasAlternateProtocolAvailable()); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3521 | document_state->set_was_fetched_via_proxy(response.wasFetchedViaProxy()); |
| 3522 | document_state->set_http_status_code(http_status_code); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3523 | // Whether or not the http status code actually corresponds to an error is |
| 3524 | // only checked when the page is done loading, if |use_error_page| is |
| 3525 | // still true. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3526 | document_state->set_use_error_page(true); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3527 | } |
| 3528 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3529 | void RenderViewImpl::didFinishResourceLoad( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3530 | WebFrame* frame, unsigned identifier) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3531 | DocumentState* document_state = |
| 3532 | DocumentState::FromDataSource(frame->dataSource()); |
| 3533 | if (!document_state->use_error_page()) |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3534 | return; |
| 3535 | |
[email protected] | 7bfc153f | 2011-09-23 22:00:20 | [diff] [blame] | 3536 | // Do not show error page when DevTools is attached. |
| 3537 | if (devtools_agent_->IsAttached()) |
| 3538 | return; |
| 3539 | |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3540 | // Display error page, if appropriate. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3541 | int http_status_code = document_state->http_status_code(); |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 3542 | if (http_status_code == 404) { |
| 3543 | // On 404s, try a remote search page as a fallback. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3544 | const GURL& document_url = frame->document().url(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3545 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3546 | const GURL& error_page_url = |
| 3547 | GetAlternateErrorPageURL(document_url, HTTP_404); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3548 | if (error_page_url.is_valid()) { |
| 3549 | WebURLError original_error; |
[email protected] | 2e9706c | 2011-06-09 16:49:47 | [diff] [blame] | 3550 | original_error.domain = "http"; |
| 3551 | original_error.reason = 404; |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3552 | original_error.unreachableURL = document_url; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3553 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3554 | document_state->set_alt_error_page_fetcher( |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3555 | new AltErrorPageResourceFetcher( |
| 3556 | error_page_url, frame, original_error, |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 3557 | base::Bind(&RenderViewImpl::AltErrorPageFinished, |
| 3558 | base::Unretained(this)))); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3559 | return; |
| 3560 | } |
| 3561 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3562 | |
[email protected] | e6a2ce5 | 2011-10-08 01:40:13 | [diff] [blame] | 3563 | std::string error_domain; |
| 3564 | if (content::GetContentClient()->renderer()->HasErrorPage( |
| 3565 | http_status_code, &error_domain)) { |
| 3566 | WebURLError error; |
| 3567 | error.unreachableURL = frame->document().url(); |
| 3568 | error.domain = WebString::fromUTF8(error_domain); |
| 3569 | error.reason = http_status_code; |
| 3570 | |
| 3571 | LoadNavigationErrorPage( |
| 3572 | frame, frame->dataSource()->request(), error, std::string(), true); |
| 3573 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3574 | } |
| 3575 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3576 | void RenderViewImpl::didFailResourceLoad( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3577 | WebFrame* frame, unsigned identifier, const WebURLError& error) { |
| 3578 | // Ignore |
| 3579 | } |
| 3580 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3581 | void RenderViewImpl::didLoadResourceFromMemoryCache( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3582 | WebFrame* frame, const WebURLRequest& request, |
| 3583 | const WebURLResponse& response) { |
[email protected] | 8470329 | 2011-10-28 20:44:00 | [diff] [blame] | 3584 | // The recipients of this message have no use for data: URLs: they don't |
| 3585 | // affect the page's insecure content list and are not in the disk cache. To |
| 3586 | // prevent large (1M+) data: URLs from crashing in the IPC system, we simply |
| 3587 | // filter them out here. |
| 3588 | GURL url(request.url()); |
| 3589 | if (url.SchemeIs("data")) |
| 3590 | return; |
| 3591 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3592 | // Let the browser know we loaded a resource from the memory cache. This |
| 3593 | // message is needed to display the correct SSL indicators. |
| 3594 | Send(new ViewHostMsg_DidLoadResourceFromMemoryCache( |
| 3595 | routing_id_, |
[email protected] | 8470329 | 2011-10-28 20:44:00 | [diff] [blame] | 3596 | url, |
[email protected] | 7043596 | 2011-08-02 20:13:28 | [diff] [blame] | 3597 | response.securityInfo(), |
| 3598 | request.httpMethod().utf8(), |
[email protected] | 6d6cfb3a | 2012-05-23 22:53:18 | [diff] [blame] | 3599 | response.mimeType().utf8(), |
[email protected] | 7043596 | 2011-08-02 20:13:28 | [diff] [blame] | 3600 | ResourceType::FromTargetType(request.targetType()))); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3601 | } |
| 3602 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3603 | void RenderViewImpl::didDisplayInsecureContent(WebFrame* frame) { |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 3604 | Send(new ViewHostMsg_DidDisplayInsecureContent(routing_id_)); |
| 3605 | } |
| 3606 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3607 | void RenderViewImpl::didRunInsecureContent( |
[email protected] | 9277111 | 2011-01-20 00:13:02 | [diff] [blame] | 3608 | WebFrame* frame, const WebSecurityOrigin& origin, const WebURL& target) { |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 3609 | Send(new ViewHostMsg_DidRunInsecureContent( |
| 3610 | routing_id_, |
[email protected] | 9277111 | 2011-01-20 00:13:02 | [diff] [blame] | 3611 | origin.toString().utf8(), |
| 3612 | target)); |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 3613 | } |
| 3614 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3615 | void RenderViewImpl::didExhaustMemoryAvailableForScript(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3616 | Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); |
| 3617 | } |
| 3618 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3619 | void RenderViewImpl::didCreateScriptContext(WebFrame* frame, |
| 3620 | v8::Handle<v8::Context> context, |
[email protected] | a00fe69 | 2012-02-27 05:52:58 | [diff] [blame] | 3621 | int extension_group, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3622 | int world_id) { |
[email protected] | 5bc1093 | 2011-09-21 21:03:30 | [diff] [blame] | 3623 | content::GetContentClient()->renderer()->DidCreateScriptContext( |
[email protected] | a00fe69 | 2012-02-27 05:52:58 | [diff] [blame] | 3624 | frame, context, extension_group, world_id); |
| 3625 | } |
| 3626 | |
| 3627 | void RenderViewImpl::didCreateScriptContext(WebFrame* frame, |
| 3628 | v8::Handle<v8::Context> context, |
| 3629 | int world_id) { |
| 3630 | content::GetContentClient()->renderer()->DidCreateScriptContext( |
| 3631 | frame, context, -1, world_id); |
[email protected] | 0c882b28 | 2009-10-07 17:01:28 | [diff] [blame] | 3632 | } |
| 3633 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3634 | void RenderViewImpl::willReleaseScriptContext(WebFrame* frame, |
| 3635 | v8::Handle<v8::Context> context, |
| 3636 | int world_id) { |
[email protected] | 5bc1093 | 2011-09-21 21:03:30 | [diff] [blame] | 3637 | content::GetContentClient()->renderer()->WillReleaseScriptContext( |
| 3638 | frame, context, world_id); |
[email protected] | 0c882b28 | 2009-10-07 17:01:28 | [diff] [blame] | 3639 | } |
| 3640 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3641 | void RenderViewImpl::CheckPreferredSize() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 3642 | // We don't always want to send the change messages over IPC, only if we've |
| 3643 | // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 3644 | // message. |
| 3645 | if (!send_preferred_size_changes_ || !webview()) |
| 3646 | return; |
| 3647 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 3648 | gfx::Size size(webview()->mainFrame()->contentsPreferredWidth(), |
| 3649 | webview()->mainFrame()->documentElementScrollHeight()); |
[email protected] | 8205d74 | 2010-10-22 23:51:53 | [diff] [blame] | 3650 | |
| 3651 | // In the presence of zoom, these sizes are still reported as if unzoomed, |
| 3652 | // so we need to adjust. |
| 3653 | double zoom_factor = WebView::zoomLevelToZoomFactor(webview()->zoomLevel()); |
| 3654 | size.set_width(static_cast<int>(size.width() * zoom_factor)); |
| 3655 | size.set_height(static_cast<int>(size.height() * zoom_factor)); |
| 3656 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 3657 | if (size == preferred_size_) |
| 3658 | return; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 3659 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 3660 | preferred_size_ = size; |
| 3661 | Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
| 3662 | preferred_size_)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3663 | } |
| 3664 | |
[email protected] | 1842fe2 | 2012-08-13 23:24:35 | [diff] [blame] | 3665 | WebGraphicsContext3D* RenderViewImpl::CreateGraphicsContext3D( |
| 3666 | const WebGraphicsContext3D::Attributes& attributes) { |
| 3667 | if (!webview()) |
| 3668 | return NULL; |
| 3669 | |
| 3670 | if (GetGuestToEmbedderChannel()) { |
| 3671 | WebGraphicsContext3DCommandBufferImpl* context = |
| 3672 | GetGuestToEmbedderChannel()->CreateWebGraphicsContext3D( |
| 3673 | this, attributes, false); |
| 3674 | if (!guest_pp_instance()) { |
| 3675 | guest_uninitialized_context_ = context; |
| 3676 | guest_attributes_ = attributes; |
| 3677 | } |
| 3678 | return context; |
| 3679 | } |
| 3680 | |
| 3681 | // The WebGraphicsContext3DInProcessImpl code path is used for |
| 3682 | // layout tests (though not through this code) as well as for |
| 3683 | // debugging and bringing up new ports. |
| 3684 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { |
| 3685 | return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( |
| 3686 | attributes, true); |
| 3687 | } else { |
| 3688 | GURL url; |
| 3689 | if (webview()->mainFrame()) |
| 3690 | url = GURL(webview()->mainFrame()->document().url()); |
| 3691 | else |
[email protected] | f89e173a | 2012-08-24 01:12:26 | [diff] [blame] | 3692 | url = GURL("chrome://gpu/RenderViewImpl::CreateGraphicsContext3D"); |
[email protected] | 1842fe2 | 2012-08-13 23:24:35 | [diff] [blame] | 3693 | |
| 3694 | scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| 3695 | new WebGraphicsContext3DCommandBufferImpl( |
| 3696 | surface_id(), |
| 3697 | url, |
| 3698 | RenderThreadImpl::current(), |
| 3699 | AsWeakPtr())); |
| 3700 | |
| 3701 | if (!context->Initialize( |
| 3702 | attributes, |
| 3703 | false /* bind generates resources */, |
| 3704 | content::CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)) |
| 3705 | return NULL; |
| 3706 | return context.release(); |
| 3707 | } |
| 3708 | } |
| 3709 | |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 3710 | // The browser process needs to know the shape of the tree, as well as the names |
| 3711 | // and ids of all frames. This allows it to properly route JavaScript messages |
| 3712 | // across processes and frames. The serialization format is described in the |
| 3713 | // comments of the ViewMsg_FrameTreeUpdated message. |
| 3714 | // This function sends those updates to the browser and updates the RVH |
| 3715 | // corresponding to this object. It must be called on any events that modify |
| 3716 | // the tree structure or the names of any frames. |
| 3717 | void RenderViewImpl::SendUpdatedFrameTree( |
| 3718 | WebKit::WebFrame* exclude_frame_subtree) { |
| 3719 | std::string json; |
| 3720 | base::DictionaryValue tree; |
| 3721 | |
| 3722 | ConstructFrameTree(webview()->mainFrame(), exclude_frame_subtree, &tree); |
| 3723 | base::JSONWriter::Write(&tree, &json); |
| 3724 | |
| 3725 | Send(new ViewHostMsg_FrameTreeUpdated(routing_id_, json)); |
| 3726 | } |
| 3727 | |
| 3728 | void RenderViewImpl::CreateFrameTree(WebKit::WebFrame* frame, |
| 3729 | DictionaryValue* frame_tree) { |
| 3730 | NavigateToSwappedOutURL(frame); |
| 3731 | |
| 3732 | string16 name; |
| 3733 | if (frame_tree->GetString(content::kFrameTreeNodeNameKey, &name) && |
| 3734 | name != string16()) { |
| 3735 | frame->setName(name); |
| 3736 | } |
| 3737 | |
| 3738 | int remote_id; |
| 3739 | if (frame_tree->GetInteger(content::kFrameTreeNodeIdKey, &remote_id)) |
| 3740 | active_frame_id_map_.insert(std::pair<int, int>(frame->identifier(), |
| 3741 | remote_id)); |
| 3742 | |
| 3743 | ListValue* children; |
| 3744 | if (!frame_tree->GetList(content::kFrameTreeNodeSubtreeKey, &children)) |
| 3745 | return; |
| 3746 | |
| 3747 | base::DictionaryValue* child; |
| 3748 | for (size_t i = 0; i < children->GetSize(); ++i) { |
| 3749 | if (!children->GetDictionary(i, &child)) |
| 3750 | continue; |
| 3751 | WebElement element = frame->document().createElement("iframe"); |
| 3752 | if (frame->document().body().appendChild(element)) { |
| 3753 | WebFrame* subframe = WebFrame::fromFrameOwnerElement(element); |
| 3754 | if (subframe) |
| 3755 | CreateFrameTree(subframe, child); |
| 3756 | } else { |
| 3757 | LOG(ERROR) << "Failed to append created iframe element."; |
| 3758 | } |
| 3759 | } |
| 3760 | } |
| 3761 | |
| 3762 | WebKit::WebFrame* RenderViewImpl::GetFrameByMappedID(int frame_id) { |
| 3763 | std::map<int, int>::iterator it = active_frame_id_map_.find(frame_id); |
| 3764 | if (it == active_frame_id_map_.end()) |
| 3765 | return NULL; |
| 3766 | |
| 3767 | return FindFrameByID(webview()->mainFrame(), it->second); |
| 3768 | } |
| 3769 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3770 | void RenderViewImpl::EnsureMediaStreamImpl() { |
[email protected] | 7082fb94 | 2012-05-16 23:44:59 | [diff] [blame] | 3771 | if (!RenderThreadImpl::current()) // Will be NULL during unit tests. |
[email protected] | 0838156 | 2012-05-15 20:55:40 | [diff] [blame] | 3772 | return; |
| 3773 | |
[email protected] | 4fb0f20 | 2012-05-30 22:44:53 | [diff] [blame] | 3774 | #if defined(ENABLE_WEBRTC) |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3775 | if (!p2p_socket_dispatcher_) |
| 3776 | p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3777 | |
| 3778 | if (!media_stream_dispatcher_) |
| 3779 | media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
| 3780 | |
[email protected] | 1bc65a4 | 2012-04-23 09:31:25 | [diff] [blame] | 3781 | if (!media_stream_impl_) { |
[email protected] | f3625c0b | 2012-05-03 09:18:28 | [diff] [blame] | 3782 | MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory( |
| 3783 | RenderThreadImpl::current()->video_capture_impl_manager()); |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3784 | media_stream_impl_ = new MediaStreamImpl( |
[email protected] | 1bc65a4 | 2012-04-23 09:31:25 | [diff] [blame] | 3785 | this, |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3786 | media_stream_dispatcher_, |
| 3787 | p2p_socket_dispatcher_, |
| 3788 | RenderThreadImpl::current()->video_capture_impl_manager(), |
| 3789 | factory); |
| 3790 | } |
[email protected] | 5b87e78 | 2012-02-09 18:19:32 | [diff] [blame] | 3791 | #endif |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3792 | } |
| 3793 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3794 | void RenderViewImpl::didChangeContentsSize(WebFrame* frame, |
| 3795 | const WebSize& size) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3796 | if (webview()->mainFrame() != frame) |
| 3797 | return; |
| 3798 | WebView* frameView = frame->view(); |
| 3799 | if (!frameView) |
| 3800 | return; |
| 3801 | |
| 3802 | bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); |
| 3803 | bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); |
| 3804 | |
| 3805 | if (has_horizontal_scrollbar != cached_has_main_frame_horizontal_scrollbar_ || |
| 3806 | has_vertical_scrollbar != cached_has_main_frame_vertical_scrollbar_) { |
| 3807 | Send(new ViewHostMsg_DidChangeScrollbarsForMainFrame( |
| 3808 | routing_id_, has_horizontal_scrollbar, has_vertical_scrollbar)); |
| 3809 | |
| 3810 | cached_has_main_frame_horizontal_scrollbar_ = has_horizontal_scrollbar; |
| 3811 | cached_has_main_frame_vertical_scrollbar_ = has_vertical_scrollbar; |
| 3812 | } |
| 3813 | } |
| 3814 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3815 | void RenderViewImpl::UpdateScrollState(WebFrame* frame) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3816 | WebSize offset = frame->scrollOffset(); |
| 3817 | WebSize minimum_offset = frame->minimumScrollOffset(); |
| 3818 | WebSize maximum_offset = frame->maximumScrollOffset(); |
| 3819 | |
| 3820 | bool is_pinned_to_left = offset.width <= minimum_offset.width; |
| 3821 | bool is_pinned_to_right = offset.width >= maximum_offset.width; |
| 3822 | |
| 3823 | if (is_pinned_to_left != cached_is_main_frame_pinned_to_left_ || |
| 3824 | is_pinned_to_right != cached_is_main_frame_pinned_to_right_) { |
| 3825 | Send(new ViewHostMsg_DidChangeScrollOffsetPinningForMainFrame( |
| 3826 | routing_id_, is_pinned_to_left, is_pinned_to_right)); |
| 3827 | |
| 3828 | cached_is_main_frame_pinned_to_left_ = is_pinned_to_left; |
| 3829 | cached_is_main_frame_pinned_to_right_ = is_pinned_to_right; |
| 3830 | } |
| 3831 | } |
| 3832 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3833 | void RenderViewImpl::didChangeScrollOffset(WebFrame* frame) { |
[email protected] | 143dcd59 | 2009-11-06 21:33:49 | [diff] [blame] | 3834 | StartNavStateSyncTimerIfNecessary(); |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3835 | |
| 3836 | if (webview()->mainFrame() == frame) |
| 3837 | UpdateScrollState(frame); |
[email protected] | 2b942c33 | 2012-04-25 16:26:26 | [diff] [blame] | 3838 | |
| 3839 | FOR_EACH_OBSERVER( |
| 3840 | RenderViewObserver, observers_, DidChangeScrollOffset(frame)); |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3841 | } |
| 3842 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3843 | void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3844 | Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); |
[email protected] | 143dcd59 | 2009-11-06 21:33:49 | [diff] [blame] | 3845 | } |
| 3846 | |
[email protected] | c8ac905 | 2012-07-20 21:43:40 | [diff] [blame] | 3847 | void RenderViewImpl::hasTouchEventHandlers(bool has_handlers) { |
| 3848 | Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); |
| 3849 | } |
| 3850 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3851 | void RenderViewImpl::reportFindInPageMatchCount(int request_id, int count, |
| 3852 | bool final_update) { |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 3853 | int active_match_ordinal = -1; // -1 = don't update active match ordinal |
| 3854 | if (!count) |
| 3855 | active_match_ordinal = 0; |
| 3856 | |
[email protected] | 733a58f | 2012-08-11 03:49:01 | [diff] [blame] | 3857 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 3858 | request_id, |
| 3859 | count, |
| 3860 | gfx::Rect(), |
| 3861 | active_match_ordinal, |
| 3862 | final_update)); |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3863 | } |
| 3864 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3865 | void RenderViewImpl::reportFindInPageSelection(int request_id, |
| 3866 | int active_match_ordinal, |
| 3867 | const WebRect& selection_rect) { |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3868 | // Send the search result over to the browser process. |
| 3869 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 3870 | request_id, |
| 3871 | -1, |
| 3872 | selection_rect, |
| 3873 | active_match_ordinal, |
| 3874 | false)); |
| 3875 | } |
| 3876 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3877 | void RenderViewImpl::openFileSystem( |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3878 | WebFrame* frame, |
| 3879 | WebFileSystem::Type type, |
| 3880 | long long size, |
[email protected] | d275d7a | 2010-11-03 01:34:49 | [diff] [blame] | 3881 | bool create, |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3882 | WebFileSystemCallbacks* callbacks) { |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3883 | DCHECK(callbacks); |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3884 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3885 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3886 | if (origin.isUnique()) { |
| 3887 | // Unique origins cannot store persistent state. |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3888 | callbacks->didFail(WebKit::WebFileErrorAbort); |
| 3889 | return; |
| 3890 | } |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3891 | |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3892 | ChildThread::current()->file_system_dispatcher()->OpenFileSystem( |
| 3893 | GURL(origin.toString()), static_cast<fileapi::FileSystemType>(type), |
[email protected] | d275d7a | 2010-11-03 01:34:49 | [diff] [blame] | 3894 | size, create, new WebFileSystemCallbackDispatcher(callbacks)); |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3895 | } |
| 3896 | |
[email protected] | d5e0855 | 2012-08-02 21:43:40 | [diff] [blame] | 3897 | void RenderViewImpl::deleteFileSystem( |
| 3898 | WebFrame* frame, |
| 3899 | WebFileSystem::Type type , |
| 3900 | WebFileSystemCallbacks* callbacks) { |
| 3901 | DCHECK(callbacks); |
| 3902 | |
| 3903 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
| 3904 | if (origin.isUnique()) { |
| 3905 | // Unique origins cannot store persistent state. |
| 3906 | callbacks->didSucceed(); |
| 3907 | return; |
| 3908 | } |
| 3909 | |
| 3910 | ChildThread::current()->file_system_dispatcher()->DeleteFileSystem( |
| 3911 | GURL(origin.toString()), |
| 3912 | static_cast<fileapi::FileSystemType>(type), |
| 3913 | new WebFileSystemCallbackDispatcher(callbacks)); |
| 3914 | } |
| 3915 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3916 | void RenderViewImpl::queryStorageUsageAndQuota( |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3917 | WebFrame* frame, |
| 3918 | WebStorageQuotaType type, |
| 3919 | WebStorageQuotaCallbacks* callbacks) { |
| 3920 | DCHECK(frame); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3921 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3922 | if (origin.isUnique()) { |
| 3923 | // Unique origins cannot store persistent state. |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3924 | callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); |
| 3925 | return; |
| 3926 | } |
| 3927 | ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota( |
[email protected] | 666bcc5c | 2011-07-29 06:25:53 | [diff] [blame] | 3928 | GURL(origin.toString()), |
| 3929 | static_cast<quota::StorageType>(type), |
| 3930 | QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3931 | } |
| 3932 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3933 | void RenderViewImpl::requestStorageQuota( |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3934 | WebFrame* frame, |
| 3935 | WebStorageQuotaType type, |
| 3936 | unsigned long long requested_size, |
| 3937 | WebStorageQuotaCallbacks* callbacks) { |
| 3938 | DCHECK(frame); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3939 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3940 | if (origin.isUnique()) { |
| 3941 | // Unique origins cannot store persistent state. |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3942 | callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); |
| 3943 | return; |
| 3944 | } |
| 3945 | ChildThread::current()->quota_dispatcher()->RequestStorageQuota( |
[email protected] | 666bcc5c | 2011-07-29 06:25:53 | [diff] [blame] | 3946 | routing_id(), GURL(origin.toString()), |
| 3947 | static_cast<quota::StorageType>(type), requested_size, |
| 3948 | QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3949 | } |
| 3950 | |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3951 | void RenderViewImpl::registerIntentService( |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 3952 | WebFrame* frame, const WebIntentServiceInfo& service) { |
[email protected] | 3a3b75a | 2012-06-01 08:38:36 | [diff] [blame] | 3953 | webkit_glue::WebIntentServiceData data(service); |
| 3954 | if (data.title.empty()) |
| 3955 | data.title = webview()->mainFrame()->document().title(); |
| 3956 | bool user_gesture = frame->isProcessingUserGesture(); |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3957 | Send(new IntentsHostMsg_RegisterIntentService(routing_id_, |
[email protected] | 3a3b75a | 2012-06-01 08:38:36 | [diff] [blame] | 3958 | data, |
| 3959 | user_gesture)); |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3960 | } |
| 3961 | |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 3962 | void RenderViewImpl::dispatchIntent( |
| 3963 | WebFrame* frame, const WebIntentRequest& intentRequest) { |
| 3964 | webkit_glue::WebIntentData intent_data(intentRequest.intent()); |
[email protected] | 4e1eb339 | 2012-05-18 00:08:05 | [diff] [blame] | 3965 | |
| 3966 | // See WebMessagePortChannelImpl::postMessage() and ::OnMessagedQueued() |
| 3967 | WebKit::WebMessagePortChannelArray* channels = |
| 3968 | intentRequest.intent().messagePortChannelsRelease(); |
| 3969 | if (channels) { |
| 3970 | for (size_t i = 0; i < channels->size(); ++i) { |
| 3971 | WebMessagePortChannelImpl* webchannel = |
| 3972 | static_cast<WebMessagePortChannelImpl*>((*channels)[i]); |
| 3973 | intent_data.message_port_ids.push_back(webchannel->message_port_id()); |
| 3974 | DCHECK(intent_data.message_port_ids[i] != MSG_ROUTING_NONE); |
| 3975 | } |
| 3976 | delete channels; |
| 3977 | } |
| 3978 | |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 3979 | int id = intents_host_->RegisterWebIntent(intentRequest); |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3980 | Send(new IntentsHostMsg_WebIntentDispatch( |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 3981 | routing_id_, intent_data, id)); |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3982 | } |
| 3983 | |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 3984 | bool RenderViewImpl::willCheckAndDispatchMessageEvent( |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 3985 | WebKit::WebFrame* sourceFrame, |
| 3986 | WebKit::WebFrame* targetFrame, |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 3987 | WebKit::WebSecurityOrigin target_origin, |
| 3988 | WebKit::WebDOMMessageEvent event) { |
| 3989 | if (!is_swapped_out_) |
| 3990 | return false; |
| 3991 | |
| 3992 | ViewMsg_PostMessage_Params params; |
| 3993 | params.data = event.data().toString(); |
| 3994 | params.source_origin = event.origin(); |
| 3995 | if (!target_origin.isNull()) |
| 3996 | params.target_origin = target_origin.toString(); |
| 3997 | |
| 3998 | // Include the routing ID for the source frame, which the browser process |
| 3999 | // will translate into the routing ID for the equivalent frame in the target |
| 4000 | // process. |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 4001 | params.source_routing_id = MSG_ROUTING_NONE; |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 4002 | RenderViewImpl* source_view = FromWebView(sourceFrame->view()); |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 4003 | if (source_view) |
| 4004 | params.source_routing_id = source_view->routing_id(); |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 4005 | params.source_frame_id = sourceFrame->identifier(); |
| 4006 | |
| 4007 | // Include the process, route, and frame IDs of the target frame. This allows |
| 4008 | // the browser to detect races between this message being sent and the target |
| 4009 | // frame no longer being valid. |
| 4010 | params.target_process_id = target_process_id_; |
| 4011 | params.target_routing_id = target_routing_id_; |
| 4012 | |
| 4013 | std::map<int,int>::iterator it = active_frame_id_map_.find( |
| 4014 | targetFrame->identifier()); |
| 4015 | if (it != active_frame_id_map_.end()) { |
| 4016 | params.target_frame_id = it->second; |
| 4017 | } else { |
| 4018 | params.target_frame_id = 0; |
| 4019 | } |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 4020 | |
| 4021 | Send(new ViewHostMsg_RouteMessageEvent(routing_id_, params)); |
| 4022 | return true; |
| 4023 | } |
| 4024 | |
[email protected] | 5fa3a06 | 2012-03-21 15:39:34 | [diff] [blame] | 4025 | void RenderViewImpl::willOpenSocketStream( |
| 4026 | WebSocketStreamHandle* handle) { |
| 4027 | SocketStreamHandleData::AddToHandle(handle, routing_id_); |
| 4028 | } |
| 4029 | |
[email protected] | bf70edce | 2012-06-20 22:32:22 | [diff] [blame] | 4030 | WebKit::WebString RenderViewImpl::userAgentOverride( |
| 4031 | WebKit::WebFrame* frame, |
| 4032 | const WebKit::WebURL& url) { |
| 4033 | if (!webview() || !webview()->mainFrame() || |
| 4034 | renderer_preferences_.user_agent_override.empty()) { |
| 4035 | return WebKit::WebString(); |
| 4036 | } |
| 4037 | |
| 4038 | // If we're in the middle of committing a load, the data source we need |
| 4039 | // will still be provisional. |
| 4040 | WebFrame* main_frame = webview()->mainFrame(); |
| 4041 | WebDataSource* data_source = NULL; |
| 4042 | if (main_frame->provisionalDataSource()) |
| 4043 | data_source = main_frame->provisionalDataSource(); |
| 4044 | else |
| 4045 | data_source = main_frame->dataSource(); |
| 4046 | |
| 4047 | DocumentState* document_state = |
| 4048 | data_source ? DocumentState::FromDataSource(data_source) : NULL; |
| 4049 | if (document_state && document_state->is_overriding_user_agent()) |
| 4050 | return WebString::fromUTF8(renderer_preferences_.user_agent_override); |
| 4051 | else |
| 4052 | return WebKit::WebString(); |
| 4053 | } |
| 4054 | |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4055 | // WebKit::WebPageSerializerClient implementation ------------------------------ |
| 4056 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4057 | void RenderViewImpl::didSerializeDataForFrame( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4058 | const WebURL& frame_url, |
| 4059 | const WebCString& data, |
| 4060 | WebPageSerializerClient::PageSerializationStatus status) { |
| 4061 | Send(new ViewHostMsg_SendSerializedHtmlData( |
| 4062 | routing_id(), |
| 4063 | frame_url, |
| 4064 | data.data(), |
| 4065 | static_cast<int32>(status))); |
| 4066 | } |
| 4067 | |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4068 | // content::RenderView implementation ------------------------------------------ |
| 4069 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4070 | bool RenderViewImpl::Send(IPC::Message* message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4071 | return RenderWidget::Send(message); |
| 4072 | } |
| 4073 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4074 | int RenderViewImpl::GetRoutingID() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4075 | return routing_id_; |
| 4076 | } |
| 4077 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4078 | int RenderViewImpl::GetPageId() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4079 | return page_id_; |
| 4080 | } |
| 4081 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4082 | gfx::Size RenderViewImpl::GetSize() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4083 | return size(); |
| 4084 | } |
| 4085 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4086 | WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4087 | return webkit_preferences_; |
| 4088 | } |
| 4089 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4090 | WebKit::WebView* RenderViewImpl::GetWebView() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4091 | return webview(); |
| 4092 | } |
| 4093 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4094 | WebKit::WebNode RenderViewImpl::GetFocusedNode() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4095 | if (!webview()) |
| 4096 | return WebNode(); |
| 4097 | WebFrame* focused_frame = webview()->focusedFrame(); |
| 4098 | if (focused_frame) { |
| 4099 | WebDocument doc = focused_frame->document(); |
| 4100 | if (!doc.isNull()) |
| 4101 | return doc.focusedNode(); |
| 4102 | } |
| 4103 | |
| 4104 | return WebNode(); |
| 4105 | } |
| 4106 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4107 | WebKit::WebNode RenderViewImpl::GetContextMenuNode() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4108 | return context_menu_node_; |
| 4109 | } |
| 4110 | |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 4111 | bool RenderViewImpl::IsEditableNode(const WebNode& node) const { |
| 4112 | if (node.isNull()) |
| 4113 | return false; |
| 4114 | |
| 4115 | if (node.isContentEditable()) |
| 4116 | return true; |
| 4117 | |
| 4118 | if (node.isElementNode()) { |
| 4119 | const WebElement& element = node.toConst<WebElement>(); |
| 4120 | if (element.isTextFormControlElement()) |
| 4121 | return true; |
| 4122 | |
| 4123 | // Also return true if it has an ARIA role of 'textbox'. |
| 4124 | for (unsigned i = 0; i < element.attributeCount(); ++i) { |
| 4125 | if (LowerCaseEqualsASCII(element.attributeLocalName(i), "role")) { |
| 4126 | if (LowerCaseEqualsASCII(element.attributeValue(i), "textbox")) |
| 4127 | return true; |
| 4128 | break; |
| 4129 | } |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4130 | } |
| 4131 | } |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 4132 | |
| 4133 | return false; |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4134 | } |
| 4135 | |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 4136 | void RenderViewImpl::GuestReady(PP_Instance instance) { |
| 4137 | guest_pp_instance_ = instance; |
| 4138 | if (guest_uninitialized_context_) { |
[email protected] | 7900bfdb | 2012-05-24 19:31:24 | [diff] [blame] | 4139 | bool success = GetGuestToEmbedderChannel()->CreateGraphicsContext( |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 4140 | guest_uninitialized_context_, |
| 4141 | guest_attributes_, |
| 4142 | false, |
| 4143 | this); |
| 4144 | DCHECK(success); |
[email protected] | 7900bfdb | 2012-05-24 19:31:24 | [diff] [blame] | 4145 | CompleteInit(host_window_); |
| 4146 | guest_uninitialized_context_ = NULL; |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 4147 | } |
[email protected] | 468e490 | 2012-05-23 01:49:31 | [diff] [blame] | 4148 | } |
| 4149 | |
| 4150 | webkit::ppapi::WebPluginImpl* RenderViewImpl::CreateBrowserPlugin( |
| 4151 | const IPC::ChannelHandle& channel_handle, |
| 4152 | int guest_process_id, |
| 4153 | const WebKit::WebPluginParams& params) { |
| 4154 | scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
| 4155 | pepper_delegate_.CreateBrowserPluginModule(channel_handle, |
| 4156 | guest_process_id)); |
| 4157 | return new webkit::ppapi::WebPluginImpl( |
| 4158 | pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); |
| 4159 | } |
| 4160 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4161 | WebKit::WebPlugin* RenderViewImpl::CreatePlugin( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4162 | WebKit::WebFrame* frame, |
| 4163 | const webkit::WebPluginInfo& info, |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4164 | const WebKit::WebPluginParams& params) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4165 | bool pepper_plugin_was_registered = false; |
| 4166 | scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
| 4167 | pepper_delegate_.CreatePepperPluginModule(info, |
| 4168 | &pepper_plugin_was_registered)); |
| 4169 | if (pepper_plugin_was_registered) { |
| 4170 | if (!pepper_module) |
| 4171 | return NULL; |
| 4172 | return new webkit::ppapi::WebPluginImpl( |
| 4173 | pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); |
| 4174 | } |
| 4175 | |
[email protected] | 34b27e44 | 2012-01-20 20:07:41 | [diff] [blame] | 4176 | #if defined(USE_AURA) |
| 4177 | return NULL; |
| 4178 | #else |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4179 | return new webkit::npapi::WebPluginImpl( |
| 4180 | frame, params, info.path, AsWeakPtr()); |
[email protected] | 34b27e44 | 2012-01-20 20:07:41 | [diff] [blame] | 4181 | #endif |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4182 | } |
| 4183 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4184 | void RenderViewImpl::EvaluateScript(const string16& frame_xpath, |
| 4185 | const string16& jscript, |
| 4186 | int id, |
| 4187 | bool notify_result) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4188 | v8::Handle<v8::Value> result; |
| 4189 | WebFrame* web_frame = GetChildFrame(frame_xpath); |
| 4190 | if (web_frame) |
| 4191 | result = web_frame->executeScriptAndReturnValue(WebScriptSource(jscript)); |
| 4192 | if (notify_result) { |
| 4193 | ListValue list; |
| 4194 | if (!result.IsEmpty() && web_frame) { |
| 4195 | v8::HandleScope handle_scope; |
| 4196 | v8::Local<v8::Context> context = web_frame->mainWorldScriptContext(); |
| 4197 | v8::Context::Scope context_scope(context); |
| 4198 | V8ValueConverterImpl converter; |
[email protected] | 3de391e8 | 2012-05-16 17:50:51 | [diff] [blame] | 4199 | converter.SetDateAllowed(true); |
| 4200 | converter.SetRegexpAllowed(true); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4201 | list.Set(0, converter.FromV8Value(result, context)); |
| 4202 | } else { |
| 4203 | list.Set(0, Value::CreateNullValue()); |
| 4204 | } |
| 4205 | Send(new ViewHostMsg_ScriptEvalResponse(routing_id_, id, list)); |
| 4206 | } |
| 4207 | } |
| 4208 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4209 | bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4210 | return (!send_preferred_size_changes_ || |
| 4211 | (disable_scrollbars_size_limit_.width() <= width || |
| 4212 | disable_scrollbars_size_limit_.height() <= height)); |
| 4213 | } |
| 4214 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4215 | int RenderViewImpl::GetEnabledBindings() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4216 | return enabled_bindings_; |
| 4217 | } |
| 4218 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4219 | bool RenderViewImpl::GetContentStateImmediately() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4220 | return send_content_state_immediately_; |
| 4221 | } |
| 4222 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4223 | float RenderViewImpl::GetFilteredTimePerFrame() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4224 | return filtered_time_per_frame(); |
| 4225 | } |
| 4226 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4227 | void RenderViewImpl::ShowContextMenu(WebKit::WebFrame* frame, |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4228 | const WebKit::WebContextMenuData& data) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4229 | showContextMenu(frame, data); |
| 4230 | } |
| 4231 | |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4232 | WebKit::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4233 | return visibilityState(); |
| 4234 | } |
| 4235 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4236 | void RenderViewImpl::RunModalAlertDialog(WebKit::WebFrame* frame, |
| 4237 | const WebKit::WebString& message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4238 | return runModalAlertDialog(frame, message); |
| 4239 | } |
| 4240 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4241 | void RenderViewImpl::LoadURLExternally( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4242 | WebKit::WebFrame* frame, |
| 4243 | const WebKit::WebURLRequest& request, |
| 4244 | WebKit::WebNavigationPolicy policy) { |
| 4245 | loadURLExternally(frame, request, policy); |
| 4246 | } |
| 4247 | |
| 4248 | // webkit_glue::WebPluginPageDelegate ------------------------------------------ |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 4249 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4250 | webkit::npapi::WebPluginDelegate* RenderViewImpl::CreatePluginDelegate( |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 4251 | const FilePath& file_path, |
| 4252 | const std::string& mime_type) { |
[email protected] | 94752ee | 2012-02-10 10:38:20 | [diff] [blame] | 4253 | if (!PluginChannelHost::IsListening()) { |
| 4254 | LOG(ERROR) << "PluginChannelHost isn't listening"; |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4255 | return NULL; |
[email protected] | 94752ee | 2012-02-10 10:38:20 | [diff] [blame] | 4256 | } |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4257 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4258 | bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); |
[email protected] | d032f49 | 2009-09-29 00:33:46 | [diff] [blame] | 4259 | if (in_process_plugin) { |
[email protected] | 7398dcc | 2011-09-06 21:40:32 | [diff] [blame] | 4260 | #if defined(OS_WIN) && !defined(USE_AURA) |
[email protected] | e8f7a18 | 2011-03-10 00:50:22 | [diff] [blame] | 4261 | return webkit::npapi::WebPluginDelegateImpl::Create( |
| 4262 | file_path, mime_type, gfx::NativeViewFromId(host_window_)); |
[email protected] | 6876dff | 2010-01-15 19:38:09 | [diff] [blame] | 4263 | #else |
[email protected] | 7398dcc | 2011-09-06 21:40:32 | [diff] [blame] | 4264 | // In-proc plugins aren't supported on non-Windows. |
[email protected] | e8f7a18 | 2011-03-10 00:50:22 | [diff] [blame] | 4265 | NOTIMPLEMENTED(); |
| 4266 | return NULL; |
[email protected] | 7b6616f | 2010-01-14 18:07:55 | [diff] [blame] | 4267 | #endif |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4268 | } |
| 4269 | |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 4270 | return new WebPluginDelegateProxy(mime_type, AsWeakPtr()); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4271 | } |
| 4272 | |
[email protected] | 6ac77cb | 2012-05-01 14:49:01 | [diff] [blame] | 4273 | WebKit::WebPlugin* RenderViewImpl::CreatePluginReplacement( |
| 4274 | const FilePath& file_path) { |
| 4275 | return content::GetContentClient()->renderer()->CreatePluginReplacement( |
| 4276 | this, file_path); |
| 4277 | } |
| 4278 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4279 | void RenderViewImpl::CreatedPluginWindow(gfx::PluginWindowHandle window) { |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 4280 | #if defined(USE_X11) |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 4281 | Send(new ViewHostMsg_CreatePluginContainer(routing_id(), window)); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4282 | #endif |
| 4283 | } |
| 4284 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4285 | void RenderViewImpl::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 4286 | #if defined(USE_X11) |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 4287 | Send(new ViewHostMsg_DestroyPluginContainer(routing_id(), window)); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4288 | #endif |
| 4289 | CleanupWindowInPluginMoves(window); |
| 4290 | } |
| 4291 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4292 | void RenderViewImpl::DidMovePlugin( |
| 4293 | const webkit::npapi::WebPluginGeometry& move) { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4294 | SchedulePluginMove(move); |
| 4295 | } |
| 4296 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4297 | void RenderViewImpl::DidStartLoadingForPlugin() { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4298 | // TODO(darin): Make is_loading_ be a counter! |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 4299 | didStartLoading(); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4300 | } |
| 4301 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4302 | void RenderViewImpl::DidStopLoadingForPlugin() { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4303 | // TODO(darin): Make is_loading_ be a counter! |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 4304 | didStopLoading(); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 4305 | } |
| 4306 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4307 | WebCookieJar* RenderViewImpl::GetCookieJar() { |
[email protected] | b921cfd2 | 2010-02-25 16:57:51 | [diff] [blame] | 4308 | return &cookie_jar_; |
| 4309 | } |
| 4310 | |
[email protected] | 5d65fe9 | 2012-06-02 00:48:55 | [diff] [blame] | 4311 | void RenderViewImpl::DidPlay(WebKit::WebMediaPlayer* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 4312 | Send(new ViewHostMsg_MediaNotification(routing_id_, |
| 4313 | reinterpret_cast<int64>(player), |
| 4314 | player->hasVideo(), |
| 4315 | player->hasAudio(), |
| 4316 | true)); |
| 4317 | } |
| 4318 | |
[email protected] | 5d65fe9 | 2012-06-02 00:48:55 | [diff] [blame] | 4319 | void RenderViewImpl::DidPause(WebKit::WebMediaPlayer* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 4320 | Send(new ViewHostMsg_MediaNotification(routing_id_, |
| 4321 | reinterpret_cast<int64>(player), |
| 4322 | player->hasVideo(), |
| 4323 | player->hasAudio(), |
| 4324 | false)); |
| 4325 | } |
| 4326 | |
[email protected] | 5d65fe9 | 2012-06-02 00:48:55 | [diff] [blame] | 4327 | void RenderViewImpl::PlayerGone(WebKit::WebMediaPlayer* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 4328 | DidPause(player); |
| 4329 | } |
| 4330 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4331 | void RenderViewImpl::SyncNavigationState() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4332 | if (!webview()) |
| 4333 | return; |
| 4334 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4335 | const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem(); |
[email protected] | 6459800a | 2012-03-27 23:57:05 | [diff] [blame] | 4336 | SendUpdateState(item); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4337 | } |
| 4338 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4339 | void RenderViewImpl::SyncSelectionIfRequired() { |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 4340 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4341 | if (!frame) |
| 4342 | return; |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 4343 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4344 | string16 text; |
| 4345 | size_t offset; |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame] | 4346 | ui::Range range; |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4347 | |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame] | 4348 | if (pepper_delegate_.IsPluginFocused()) { |
| 4349 | pepper_delegate_.GetSurroundingText(&text, &range); |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4350 | offset = 0; // Pepper API does not support offset reporting. |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame] | 4351 | // TODO(kinaba): cut as needed. |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4352 | } else { |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame] | 4353 | size_t location, length; |
| 4354 | if (!webview()->caretOrSelectionRange(&location, &length)) |
| 4355 | return; |
| 4356 | |
| 4357 | range = ui::Range(location, location + length); |
| 4358 | |
| 4359 | if (webview()->textInputType() != WebKit::WebTextInputTypeNone) { |
| 4360 | // If current focused element is editable, we will send 100 more chars |
| 4361 | // before and after selection. It is for input method surrounding text |
| 4362 | // feature. |
| 4363 | if (location > kExtraCharsBeforeAndAfterSelection) |
| 4364 | offset = location - kExtraCharsBeforeAndAfterSelection; |
| 4365 | else |
| 4366 | offset = 0; |
| 4367 | length = location + length - offset + kExtraCharsBeforeAndAfterSelection; |
| 4368 | WebRange webrange = WebRange::fromDocumentRange(frame, offset, length); |
| 4369 | if (!webrange.isNull()) |
| 4370 | text = WebRange::fromDocumentRange(frame, offset, length).toPlainText(); |
| 4371 | } else { |
| 4372 | offset = location; |
| 4373 | text = frame->selectionAsText(); |
| 4374 | // http://crbug.com/101435 |
| 4375 | // In some case, frame->selectionAsText() returned text's length is not |
| 4376 | // equal to the length returned from webview()->caretOrSelectionRange(). |
| 4377 | // So we have to set the range according to text.length(). |
| 4378 | range.set_end(range.start() + text.length()); |
| 4379 | } |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 4380 | } |
| 4381 | |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 4382 | // Sometimes we get repeated didChangeSelection calls from webkit when |
| 4383 | // the selection hasn't actually changed. We don't want to report these |
| 4384 | // because it will cause us to continually claim the X clipboard. |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4385 | if (selection_text_offset_ != offset || |
| 4386 | selection_range_ != range || |
| 4387 | selection_text_ != text) { |
| 4388 | selection_text_ = text; |
| 4389 | selection_text_offset_ = offset; |
| 4390 | selection_range_ = range; |
| 4391 | Send(new ViewHostMsg_SelectionChanged(routing_id_, text, offset, range)); |
| 4392 | } |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 4393 | } |
| 4394 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4395 | GURL RenderViewImpl::GetAlternateErrorPageURL(const GURL& failed_url, |
| 4396 | ErrorPageType error_type) { |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 4397 | if (failed_url.SchemeIsSecure()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4398 | // If the URL that failed was secure, then the embedding web page was not |
| 4399 | // expecting a network attacker to be able to manipulate its contents. As |
| 4400 | // we fetch alternate error pages over HTTP, we would be allowing a network |
| 4401 | // attacker to manipulate the contents of the response if we tried to use |
| 4402 | // the link doctor here. |
[email protected] | 810a52ef | 2010-01-08 01:22:15 | [diff] [blame] | 4403 | return GURL(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4404 | } |
| 4405 | |
| 4406 | // Grab the base URL from the browser process. |
| 4407 | if (!alternate_error_page_url_.is_valid()) |
[email protected] | 810a52ef | 2010-01-08 01:22:15 | [diff] [blame] | 4408 | return GURL(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4409 | |
| 4410 | // Strip query params from the failed URL. |
| 4411 | GURL::Replacements remove_params; |
| 4412 | remove_params.ClearUsername(); |
| 4413 | remove_params.ClearPassword(); |
| 4414 | remove_params.ClearQuery(); |
| 4415 | remove_params.ClearRef(); |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 4416 | const GURL url_to_send = failed_url.ReplaceComponents(remove_params); |
[email protected] | 6fd28f64 | 2010-03-15 17:15:50 | [diff] [blame] | 4417 | std::string spec_to_send = url_to_send.spec(); |
| 4418 | // Notify link doctor of the url truncation by sending of "?" at the end. |
| 4419 | if (failed_url.has_query()) |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 4420 | spec_to_send.append("?"); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4421 | |
| 4422 | // Construct the query params to send to link doctor. |
| 4423 | std::string params(alternate_error_page_url_.query()); |
| 4424 | params.append("&url="); |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 4425 | params.append(net::EscapeQueryParamValue(spec_to_send, true)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4426 | params.append("&sourceid=chrome"); |
| 4427 | params.append("&error="); |
| 4428 | switch (error_type) { |
| 4429 | case DNS_ERROR: |
| 4430 | params.append("dnserror"); |
| 4431 | break; |
| 4432 | |
| 4433 | case HTTP_404: |
| 4434 | params.append("http404"); |
| 4435 | break; |
| 4436 | |
[email protected] | 5df266ac | 2008-10-15 19:50:13 | [diff] [blame] | 4437 | case CONNECTION_ERROR: |
[email protected] | e1f934b | 2009-01-26 20:41:33 | [diff] [blame] | 4438 | params.append("connectionfailure"); |
[email protected] | 5df266ac | 2008-10-15 19:50:13 | [diff] [blame] | 4439 | break; |
| 4440 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4441 | default: |
| 4442 | NOTREACHED() << "unknown ErrorPageType"; |
| 4443 | } |
| 4444 | |
| 4445 | // OK, build the final url to return. |
| 4446 | GURL::Replacements link_doctor_params; |
| 4447 | link_doctor_params.SetQueryStr(params); |
| 4448 | GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params); |
| 4449 | return url; |
| 4450 | } |
| 4451 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4452 | GURL RenderViewImpl::GetOpenerUrl() const { |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 4453 | if (opener_id_ == MSG_ROUTING_NONE || opener_suppressed_) |
| 4454 | return GURL(); |
| 4455 | else |
| 4456 | return creator_url_; |
| 4457 | } |
| 4458 | |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 4459 | GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { |
| 4460 | WebDataSource* ds = frame->dataSource(); |
| 4461 | if (ds->hasUnreachableURL()) |
| 4462 | return ds->unreachableURL(); |
| 4463 | |
| 4464 | const WebURLRequest& request = ds->request(); |
| 4465 | return request.url(); |
| 4466 | } |
| 4467 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4468 | WebUIBindings* RenderViewImpl::GetWebUIBindings() { |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 4469 | if (!web_ui_bindings_.get()) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4470 | web_ui_bindings_.reset(new WebUIBindings( |
| 4471 | static_cast<content::RenderView*>(this), routing_id_)); |
[email protected] | c091c2c | 2010-09-17 19:05:46 | [diff] [blame] | 4472 | } |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 4473 | return web_ui_bindings_.get(); |
[email protected] | c091c2c | 2010-09-17 19:05:46 | [diff] [blame] | 4474 | } |
| 4475 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4476 | WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 4477 | return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4478 | } |
| 4479 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4480 | void RenderViewImpl::OnFind(int request_id, const string16& search_text, |
| 4481 | const WebFindOptions& options) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4482 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4483 | |
[email protected] | 87254253 | 2011-06-23 00:43:16 | [diff] [blame] | 4484 | // Check if the plugin still exists in the document. |
| 4485 | if (main_frame->document().isPluginDocument() && |
| 4486 | GetWebPluginFromPluginDocument()) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4487 | if (options.findNext) { |
| 4488 | // Just navigate back/forward. |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 4489 | GetWebPluginFromPluginDocument()->selectFindResult(options.forward); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4490 | } else { |
[email protected] | afdbd14 | 2010-07-10 08:01:23 | [diff] [blame] | 4491 | if (GetWebPluginFromPluginDocument()->startFind( |
| 4492 | search_text, options.matchCase, request_id)) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4493 | } else { |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 4494 | // Send "no results". |
| 4495 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 4496 | request_id, |
| 4497 | 0, |
| 4498 | gfx::Rect(), |
| 4499 | 0, |
| 4500 | true)); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4501 | } |
| 4502 | } |
| 4503 | return; |
| 4504 | } |
| 4505 | |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 4506 | WebFrame* frame_after_main = main_frame->traverseNext(true); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4507 | WebFrame* focused_frame = webview()->focusedFrame(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4508 | WebFrame* search_frame = focused_frame; // start searching focused frame. |
| 4509 | |
| 4510 | bool multi_frame = (frame_after_main != main_frame); |
| 4511 | |
| 4512 | // If we have multiple frames, we don't want to wrap the search within the |
| 4513 | // frame, so we check here if we only have main_frame in the chain. |
| 4514 | bool wrap_within_frame = !multi_frame; |
| 4515 | |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 4516 | WebRect selection_rect; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4517 | bool result = false; |
| 4518 | |
[email protected] | 7830da3e | 2009-11-06 16:27:26 | [diff] [blame] | 4519 | // If something is selected when we start searching it means we cannot just |
| 4520 | // increment the current match ordinal; we need to re-generate it. |
| 4521 | WebRange current_selection = focused_frame->selectionRange(); |
| 4522 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4523 | do { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4524 | result = search_frame->find( |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 4525 | request_id, search_text, options, wrap_within_frame, &selection_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4526 | |
| 4527 | if (!result) { |
| 4528 | // don't leave text selected as you move to the next frame. |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 4529 | search_frame->executeCommand(WebString::fromUTF8("Unselect")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4530 | |
| 4531 | // Find the next frame, but skip the invisible ones. |
| 4532 | do { |
| 4533 | // What is the next frame to search? (we might be going backwards). Note |
| 4534 | // that we specify wrap=true so that search_frame never becomes NULL. |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 4535 | search_frame = options.forward ? |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 4536 | search_frame->traverseNext(true) : |
| 4537 | search_frame->traversePrevious(true); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4538 | } while (!search_frame->hasVisibleContent() && |
| 4539 | search_frame != focused_frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4540 | |
[email protected] | 884db41 | 2008-11-24 23:46:50 | [diff] [blame] | 4541 | // Make sure selection doesn't affect the search operation in new frame. |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 4542 | search_frame->executeCommand(WebString::fromUTF8("Unselect")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4543 | |
| 4544 | // If we have multiple frames and we have wrapped back around to the |
| 4545 | // focused frame, we need to search it once more allowing wrap within |
| 4546 | // the frame, otherwise it will report 'no match' if the focused frame has |
| 4547 | // reported matches, but no frames after the focused_frame contain a |
| 4548 | // match for the search word(s). |
| 4549 | if (multi_frame && search_frame == focused_frame) { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4550 | result = search_frame->find( |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 4551 | request_id, search_text, options, true, // Force wrapping. |
| 4552 | &selection_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4553 | } |
| 4554 | } |
| 4555 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4556 | webview()->setFocusedFrame(search_frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4557 | } while (!result && search_frame != focused_frame); |
| 4558 | |
[email protected] | 7830da3e | 2009-11-06 16:27:26 | [diff] [blame] | 4559 | if (options.findNext && current_selection.isNull()) { |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 4560 | // Force the main_frame to report the actual count. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4561 | main_frame->increaseMatchCount(0, request_id); |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 4562 | } else { |
| 4563 | // If nothing is found, set result to "0 of 0", otherwise, set it to |
| 4564 | // "-1 of 1" to indicate that we found at least one item, but we don't know |
| 4565 | // yet what is active. |
| 4566 | int ordinal = result ? -1 : 0; // -1 here means, we might know more later. |
| 4567 | int match_count = result ? 1 : 0; // 1 here means possibly more coming. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4568 | |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 4569 | // If we find no matches then this will be our last status update. |
| 4570 | // Otherwise the scoping effort will send more results. |
| 4571 | bool final_status_update = !result; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4572 | |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 4573 | // Send the search result over to the browser process. |
[email protected] | 4f99913 | 2009-03-31 18:08:40 | [diff] [blame] | 4574 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 4575 | request_id, |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 4576 | match_count, |
| 4577 | selection_rect, |
| 4578 | ordinal, |
| 4579 | final_status_update)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4580 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4581 | // Scoping effort begins, starting with the mainframe. |
| 4582 | search_frame = main_frame; |
| 4583 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4584 | main_frame->resetMatchCount(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4585 | |
| 4586 | do { |
| 4587 | // Cancel all old scoping requests before starting a new one. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4588 | search_frame->cancelPendingScopingEffort(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4589 | |
| 4590 | // We don't start another scoping effort unless at least one match has |
| 4591 | // been found. |
| 4592 | if (result) { |
| 4593 | // Start new scoping request. If the scoping function determines that it |
| 4594 | // needs to scope, it will defer until later. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4595 | search_frame->scopeStringMatches(request_id, |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 4596 | search_text, |
| 4597 | options, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4598 | true); // reset the tickmarks |
| 4599 | } |
| 4600 | |
| 4601 | // Iterate to the next frame. The frame will not necessarily scope, for |
| 4602 | // example if it is not visible. |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 4603 | search_frame = search_frame->traverseNext(true); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4604 | } while (search_frame != main_frame); |
| 4605 | } |
| 4606 | } |
| 4607 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 4608 | void RenderViewImpl::OnStopFinding(content::StopFindAction action) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4609 | WebView* view = webview(); |
| 4610 | if (!view) |
| 4611 | return; |
| 4612 | |
| 4613 | WebDocument doc = view->mainFrame()->document(); |
[email protected] | 87254253 | 2011-06-23 00:43:16 | [diff] [blame] | 4614 | if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 4615 | GetWebPluginFromPluginDocument()->stopFind(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4616 | return; |
| 4617 | } |
| 4618 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 4619 | bool clear_selection = action == content::STOP_FIND_ACTION_CLEAR_SELECTION; |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4620 | if (clear_selection) |
| 4621 | view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); |
| 4622 | |
| 4623 | WebFrame* frame = view->mainFrame(); |
| 4624 | while (frame) { |
| 4625 | frame->stopFinding(clear_selection); |
| 4626 | frame = frame->traverseNext(false); |
| 4627 | } |
| 4628 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 4629 | if (action == content::STOP_FIND_ACTION_ACTIVATE_SELECTION) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 4630 | WebFrame* focused_frame = view->focusedFrame(); |
| 4631 | if (focused_frame) { |
| 4632 | WebDocument doc = focused_frame->document(); |
| 4633 | if (!doc.isNull()) { |
| 4634 | WebNode node = doc.focusedNode(); |
| 4635 | if (!node.isNull()) |
| 4636 | node.simulateClick(); |
| 4637 | } |
| 4638 | } |
| 4639 | } |
| 4640 | } |
| 4641 | |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 4642 | void RenderViewImpl::OnZoom(content::PageZoom zoom) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 4643 | if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 4644 | return; |
| 4645 | |
[email protected] | 258d3112 | 2010-05-09 10:59:41 | [diff] [blame] | 4646 | webview()->hidePopups(); |
[email protected] | 854ab546 | 2011-11-22 20:48:10 | [diff] [blame] | 4647 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4648 | double old_zoom_level = webview()->zoomLevel(); |
| 4649 | double zoom_level; |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 4650 | if (zoom == content::PAGE_ZOOM_RESET) { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4651 | zoom_level = 0; |
| 4652 | } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
| 4653 | // Previous zoom level is a whole number, so just increment/decrement. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 4654 | zoom_level = old_zoom_level + zoom; |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4655 | } else { |
| 4656 | // Either the user hit the zoom factor limit and thus the zoom level is now |
| 4657 | // not a whole number, or a plugin changed it to a custom value. We want |
| 4658 | // to go to the next whole number so that the user can always get back to |
| 4659 | // 100% with the keyboard/menu. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 4660 | if ((old_zoom_level > 1 && zoom > 0) || |
| 4661 | (old_zoom_level < 1 && zoom < 0)) { |
| 4662 | zoom_level = static_cast<int>(old_zoom_level + zoom); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4663 | } else { |
| 4664 | // We're going towards 100%, so first go to the next whole number. |
| 4665 | zoom_level = static_cast<int>(old_zoom_level); |
| 4666 | } |
| 4667 | } |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4668 | webview()->setZoomLevel(false, zoom_level); |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 4669 | zoomLevelChanged(); |
| 4670 | } |
| 4671 | |
| 4672 | void RenderViewImpl::OnZoomFactor(content::PageZoom zoom, |
| 4673 | int zoom_center_x, int zoom_center_y) { |
| 4674 | ZoomFactorHelper(zoom, zoom_center_x, zoom_center_y, |
| 4675 | kScalingIncrementForGesture); |
| 4676 | } |
| 4677 | |
| 4678 | void RenderViewImpl::ZoomFactorHelper(content::PageZoom zoom, |
| 4679 | int zoom_center_x, |
| 4680 | int zoom_center_y, |
| 4681 | float scaling_increment) { |
| 4682 | if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 4683 | return; |
| 4684 | |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 4685 | double old_page_scale_factor = webview()->pageScaleFactor(); |
| 4686 | double page_scale_factor; |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 4687 | if (zoom == content::PAGE_ZOOM_RESET) { |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 4688 | page_scale_factor = 1.0; |
| 4689 | } else { |
| 4690 | page_scale_factor = old_page_scale_factor + |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 4691 | (zoom > 0 ? scaling_increment : -scaling_increment); |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 4692 | } |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 4693 | if (page_scale_factor > 0) { |
[email protected] | 8519136 | 2011-11-08 18:53:09 | [diff] [blame] | 4694 | webview()->setPageScaleFactor(page_scale_factor, |
| 4695 | WebPoint(zoom_center_x, zoom_center_y)); |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 4696 | } |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 4697 | } |
| 4698 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4699 | void RenderViewImpl::OnSetZoomLevel(double zoom_level) { |
[email protected] | d0b8d09 | 2010-10-25 04:05:17 | [diff] [blame] | 4700 | webview()->hidePopups(); |
| 4701 | webview()->setZoomLevel(false, zoom_level); |
| 4702 | zoomLevelChanged(); |
| 4703 | } |
| 4704 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4705 | void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
| 4706 | double zoom_level) { |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 4707 | host_zoom_levels_[url] = zoom_level; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4708 | } |
| 4709 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4710 | void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4711 | webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4712 | } |
| 4713 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4714 | void RenderViewImpl::OnResetPageEncodingToDefault() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4715 | WebString no_encoding; |
| 4716 | webview()->setPageEncoding(no_encoding); |
[email protected] | a697f4c | 2009-09-14 22:30:18 | [diff] [blame] | 4717 | } |
| 4718 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4719 | WebFrame* RenderViewImpl::GetChildFrame(const string16& xpath) const { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4720 | if (xpath.empty()) |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4721 | return webview()->mainFrame(); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4722 | |
| 4723 | // xpath string can represent a frame deep down the tree (across multiple |
| 4724 | // frame DOMs). |
| 4725 | // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] |
| 4726 | // should break into 2 xpaths |
| 4727 | // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] |
[email protected] | 318bf580 | 2011-08-08 17:12:41 | [diff] [blame] | 4728 | std::vector<string16> xpaths; |
| 4729 | base::SplitString(xpath, '\n', &xpaths); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4730 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4731 | WebFrame* frame = webview()->mainFrame(); |
[email protected] | 318bf580 | 2011-08-08 17:12:41 | [diff] [blame] | 4732 | for (std::vector<string16>::const_iterator i = xpaths.begin(); |
| 4733 | frame && i != xpaths.end(); ++i) { |
| 4734 | frame = frame->findChildByExpression(*i); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4735 | } |
| 4736 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4737 | return frame; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4738 | } |
| 4739 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4740 | void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, |
| 4741 | const string16& jscript, |
| 4742 | int id, |
| 4743 | bool notify_result) { |
[email protected] | 882b7b2 | 2010-10-05 03:34:53 | [diff] [blame] | 4744 | EvaluateScript(frame_xpath, jscript, id, notify_result); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4745 | } |
| 4746 | |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 4747 | void RenderViewImpl::OnPostMessageEvent( |
| 4748 | const ViewMsg_PostMessage_Params& params) { |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 4749 | // Find the target frame of this message. The source tags the message with |
| 4750 | // |target_frame_id|, so use it to locate the frame. |
| 4751 | WebFrame* frame = FindFrameByID(webview()->mainFrame(), |
| 4752 | params.target_frame_id); |
| 4753 | if (!frame) |
| 4754 | return; |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 4755 | |
| 4756 | // Find the source frame if it exists. |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 4757 | WebFrame* source_frame = NULL; |
| 4758 | if (params.source_routing_id != MSG_ROUTING_NONE) { |
| 4759 | RenderViewImpl* source_view = FromRoutingID(params.source_routing_id); |
| 4760 | if (source_view) |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 4761 | source_frame = source_view->GetFrameByMappedID(params.source_frame_id); |
[email protected] | f546640b | 2012-05-15 00:03:49 | [diff] [blame] | 4762 | } |
| 4763 | |
| 4764 | // Create an event with the message. The final parameter to initMessageEvent |
| 4765 | // is the last event ID, which is not used with postMessage. |
| 4766 | WebDOMEvent event = frame->document().createEvent("MessageEvent"); |
| 4767 | WebDOMMessageEvent msg_event = event.to<WebDOMMessageEvent>(); |
| 4768 | msg_event.initMessageEvent("message", |
| 4769 | // |canBubble| and |cancellable| are always false |
| 4770 | false, false, |
| 4771 | WebSerializedScriptValue::fromString(params.data), |
| 4772 | params.source_origin, source_frame, ""); |
| 4773 | |
| 4774 | // We must pass in the target_origin to do the security check on this side, |
| 4775 | // since it may have changed since the original postMessage call was made. |
| 4776 | WebSecurityOrigin target_origin; |
| 4777 | if (!params.target_origin.empty()) { |
| 4778 | target_origin = |
| 4779 | WebSecurityOrigin::createFromString(WebString(params.target_origin)); |
| 4780 | } |
| 4781 | frame->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
| 4782 | } |
| 4783 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4784 | void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, |
| 4785 | const std::string& css) { |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 4786 | WebFrame* frame = GetChildFrame(frame_xpath); |
| 4787 | if (!frame) |
[email protected] | 21681395 | 2011-05-19 22:21:26 | [diff] [blame] | 4788 | return; |
[email protected] | ae46154 | 2009-06-19 19:03:41 | [diff] [blame] | 4789 | |
[email protected] | 01cf589c | 2011-07-28 18:04:03 | [diff] [blame] | 4790 | frame->document().insertUserStyleSheet( |
| 4791 | WebString::fromUTF8(css), |
| 4792 | WebDocument::UserStyleAuthorLevel); |
[email protected] | 1810e13 | 2009-03-24 23:35:48 | [diff] [blame] | 4793 | } |
| 4794 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4795 | void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 4796 | enabled_bindings_ |= enabled_bindings_flags; |
[email protected] | 744c2a2 | 2012-03-15 18:42:04 | [diff] [blame] | 4797 | |
| 4798 | // Keep track of the total bindings accumulated in this process. |
| 4799 | RenderProcess::current()->AddBindings(enabled_bindings_flags); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4800 | } |
| 4801 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4802 | void RenderViewImpl::OnSetWebUIProperty(const std::string& name, |
| 4803 | const std::string& value) { |
[email protected] | 808bda5 | 2012-03-09 22:43:32 | [diff] [blame] | 4804 | if (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) |
| 4805 | GetWebUIBindings()->SetProperty(name, value); |
| 4806 | else |
| 4807 | NOTREACHED() << "WebUI bindings not enabled."; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4808 | } |
| 4809 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4810 | void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
| 4811 | const gfx::Point& client_point, |
| 4812 | const gfx::Point& screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 4813 | WebDragOperationsMask ops, |
| 4814 | int key_modifiers) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4815 | WebDragOperation operation = webview()->dragTargetDragEnter( |
| 4816 | drop_data.ToDragData(), |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4817 | client_point, |
| 4818 | screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 4819 | ops, |
| 4820 | key_modifiers); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4821 | |
| 4822 | Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); |
| 4823 | } |
| 4824 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4825 | void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
| 4826 | const gfx::Point& screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 4827 | WebDragOperationsMask ops, |
| 4828 | int key_modifiers) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4829 | WebDragOperation operation = webview()->dragTargetDragOver( |
| 4830 | client_point, |
| 4831 | screen_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 4832 | ops, |
| 4833 | key_modifiers); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4834 | |
| 4835 | Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); |
| 4836 | } |
| 4837 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4838 | void RenderViewImpl::OnDragTargetDragLeave() { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4839 | webview()->dragTargetDragLeave(); |
| 4840 | } |
| 4841 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4842 | void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, |
[email protected] | 1f2230b | 2012-05-17 23:43:42 | [diff] [blame] | 4843 | const gfx::Point& screen_point, |
| 4844 | int key_modifiers) { |
| 4845 | webview()->dragTargetDrop(client_point, screen_point, key_modifiers); |
[email protected] | fcad4945 | 2011-06-28 17:11:57 | [diff] [blame] | 4846 | |
| 4847 | Send(new DragHostMsg_TargetDrop_ACK(routing_id_)); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4848 | } |
| 4849 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4850 | void RenderViewImpl::OnDragSourceEndedOrMoved(const gfx::Point& client_point, |
| 4851 | const gfx::Point& screen_point, |
| 4852 | bool ended, |
| 4853 | WebDragOperation op) { |
[email protected] | 5f9ae6c | 2009-07-08 02:38:03 | [diff] [blame] | 4854 | if (ended) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4855 | webview()->dragSourceEndedAt(client_point, screen_point, op); |
[email protected] | daec5d6 | 2010-06-04 09:14:20 | [diff] [blame] | 4856 | } else { |
| 4857 | webview()->dragSourceMovedTo(client_point, screen_point, op); |
[email protected] | 5f9ae6c | 2009-07-08 02:38:03 | [diff] [blame] | 4858 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4859 | } |
| 4860 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4861 | void RenderViewImpl::OnDragSourceSystemDragEnded() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4862 | webview()->dragSourceSystemDragEnded(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4863 | } |
| 4864 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4865 | void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 4866 | webkit_preferences_ = prefs; |
| 4867 | webkit_preferences_.Apply(webview()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4868 | } |
| 4869 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4870 | void RenderViewImpl::OnSetAltErrorPageURL(const GURL& url) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4871 | alternate_error_page_url_ = url; |
| 4872 | } |
| 4873 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4874 | void RenderViewImpl::OnCustomContextMenuAction( |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 4875 | const content::CustomContextMenuContext& custom_context, |
[email protected] | b29aa74b | 2011-01-31 21:41:08 | [diff] [blame] | 4876 | unsigned action) { |
| 4877 | if (custom_context.is_pepper_menu) |
| 4878 | pepper_delegate_.OnCustomContextMenuAction(custom_context, action); |
| 4879 | else |
| 4880 | webview()->performCustomContextMenuAction(action); |
[email protected] | 440a0e5 | 2011-09-13 17:38:58 | [diff] [blame] | 4881 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 4882 | ContextMenuAction(action)); |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 4883 | } |
| 4884 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4885 | void RenderViewImpl::OnEnumerateDirectoryResponse( |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 4886 | int id, |
| 4887 | const std::vector<FilePath>& paths) { |
| 4888 | if (!enumeration_completions_[id]) |
| 4889 | return; |
| 4890 | |
| 4891 | WebVector<WebString> ws_file_names(paths.size()); |
| 4892 | for (size_t i = 0; i < paths.size(); ++i) |
| 4893 | ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
| 4894 | |
| 4895 | enumeration_completions_[id]->didChooseFile(ws_file_names); |
| 4896 | enumeration_completions_.erase(id); |
| 4897 | } |
| 4898 | |
[email protected] | fb11b6a4 | 2012-03-14 07:25:12 | [diff] [blame] | 4899 | void RenderViewImpl::OnFileChooserResponse( |
[email protected] | ddb034b | 2012-06-26 20:31:39 | [diff] [blame] | 4900 | const std::vector<ui::SelectedFileInfo>& files) { |
[email protected] | 8029f567 | 2009-03-20 22:33:36 | [diff] [blame] | 4901 | // This could happen if we navigated to a different page before the user |
| 4902 | // closed the chooser. |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 4903 | if (file_chooser_completions_.empty()) |
[email protected] | 8029f567 | 2009-03-20 22:33:36 | [diff] [blame] | 4904 | return; |
| 4905 | |
[email protected] | b518852 | 2012-03-15 00:18:04 | [diff] [blame] | 4906 | // Convert Chrome's SelectedFileInfo list to WebKit's. |
| 4907 | WebVector<WebFileChooserCompletion::SelectedFileInfo> selected_files( |
| 4908 | files.size()); |
| 4909 | for (size_t i = 0; i < files.size(); ++i) { |
| 4910 | WebFileChooserCompletion::SelectedFileInfo selected_file; |
[email protected] | 53f04c8 | 2012-07-26 02:31:09 | [diff] [blame] | 4911 | selected_file.path = webkit_glue::FilePathToWebString(files[i].local_path); |
[email protected] | b518852 | 2012-03-15 00:18:04 | [diff] [blame] | 4912 | selected_file.displayName = webkit_glue::FilePathStringToWebString( |
| 4913 | files[i].display_name); |
| 4914 | selected_files[i] = selected_file; |
| 4915 | } |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 4916 | |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 4917 | if (file_chooser_completions_.front()->completion) |
[email protected] | b518852 | 2012-03-15 00:18:04 | [diff] [blame] | 4918 | file_chooser_completions_.front()->completion->didChooseFile( |
| 4919 | selected_files); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 4920 | file_chooser_completions_.pop_front(); |
| 4921 | |
| 4922 | // If there are more pending file chooser requests, schedule one now. |
| 4923 | if (!file_chooser_completions_.empty()) { |
| 4924 | Send(new ViewHostMsg_RunFileChooser(routing_id_, |
| 4925 | file_chooser_completions_.front()->params)); |
| 4926 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4927 | } |
| 4928 | |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 4929 | void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, |
| 4930 | const gfx::Size& max_size) { |
| 4931 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 4932 | if (!webview()) |
| 4933 | return; |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 4934 | webview()->enableAutoResizeMode(min_size, max_size); |
| 4935 | } |
| 4936 | |
| 4937 | void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) { |
| 4938 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 4939 | if (!webview()) |
| 4940 | return; |
| 4941 | webview()->disableAutoResizeMode(); |
| 4942 | |
| 4943 | Resize(new_size, resizer_rect_, is_fullscreen_, NO_RESIZE_ACK); |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 4944 | } |
| 4945 | |
[email protected] | 2bf834f | 2011-11-17 20:02:21 | [diff] [blame] | 4946 | void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 4947 | if (send_preferred_size_changes_) |
| 4948 | return; |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 4949 | send_preferred_size_changes_ = true; |
[email protected] | 770dd8b | 2010-05-24 18:11:39 | [diff] [blame] | 4950 | |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 4951 | // Start off with an initial preferred size notification (in case |
| 4952 | // |didUpdateLayout| was already called). |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 4953 | didUpdateLayout(); |
[email protected] | 0666aef | 2009-05-13 19:48:08 | [diff] [blame] | 4954 | } |
| 4955 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4956 | void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4957 | const gfx::Size& disable_scrollbar_size_limit) { |
| 4958 | disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
| 4959 | } |
| 4960 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4961 | void RenderViewImpl::OnSetRendererPrefs( |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 4962 | const content::RendererPreferences& renderer_prefs) { |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 4963 | double old_zoom_level = renderer_preferences_.default_zoom_level; |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 4964 | renderer_preferences_ = renderer_prefs; |
[email protected] | 6e282c9 | 2009-07-24 01:19:37 | [diff] [blame] | 4965 | UpdateFontRenderingFromRendererPrefs(); |
[email protected] | a13283cc | 2012-04-05 00:21:22 | [diff] [blame] | 4966 | #if defined(TOOLKIT_GTK) |
[email protected] | 1c83eb4 | 2009-09-11 21:08:41 | [diff] [blame] | 4967 | WebColorName name = WebKit::WebColorWebkitFocusRingColor; |
| 4968 | WebKit::setNamedColors(&name, &renderer_prefs.focus_ring_color, 1); |
[email protected] | 39cd64ed | 2010-02-05 02:18:46 | [diff] [blame] | 4969 | WebKit::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
[email protected] | f78452f | 2012-05-15 02:07:52 | [diff] [blame] | 4970 | ui::NativeTheme::instance()->SetScrollbarColors( |
[email protected] | 8d1b864d1 | 2010-10-10 00:04:34 | [diff] [blame] | 4971 | renderer_prefs.thumb_inactive_color, |
| 4972 | renderer_prefs.thumb_active_color, |
| 4973 | renderer_prefs.track_color); |
[email protected] | d299d97 | 2012-03-23 02:26:55 | [diff] [blame] | 4974 | #endif |
[email protected] | 93623c5d | 2009-12-10 21:40:32 | [diff] [blame] | 4975 | |
[email protected] | a13283cc | 2012-04-05 00:21:22 | [diff] [blame] | 4976 | #if defined(USE_ASH) || defined(TOOLKIT_GTK) |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 4977 | if (webview()) { |
[email protected] | a13283cc | 2012-04-05 00:21:22 | [diff] [blame] | 4978 | #if defined(TOOLKIT_GTK) |
[email protected] | 93623c5d | 2009-12-10 21:40:32 | [diff] [blame] | 4979 | webview()->setScrollbarColors( |
| 4980 | renderer_prefs.thumb_inactive_color, |
| 4981 | renderer_prefs.thumb_active_color, |
| 4982 | renderer_prefs.track_color); |
[email protected] | d299d97 | 2012-03-23 02:26:55 | [diff] [blame] | 4983 | #endif |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 4984 | webview()->setSelectionColors( |
| 4985 | renderer_prefs.active_selection_bg_color, |
| 4986 | renderer_prefs.active_selection_fg_color, |
| 4987 | renderer_prefs.inactive_selection_bg_color, |
| 4988 | renderer_prefs.inactive_selection_fg_color); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 4989 | webview()->themeChanged(); |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 4990 | } |
[email protected] | 7a74e10 | 2009-09-03 00:16:56 | [diff] [blame] | 4991 | #endif |
[email protected] | d299d97 | 2012-03-23 02:26:55 | [diff] [blame] | 4992 | |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 4993 | // If the zoom level for this page matches the old zoom default, and this |
| 4994 | // is not a plugin, update the zoom level to match the new default. |
| 4995 | if (webview() && !webview()->mainFrame()->document().isPluginDocument() && |
| 4996 | content::ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { |
| 4997 | webview()->setZoomLevel(false, renderer_preferences_.default_zoom_level); |
| 4998 | zoomLevelChanged(); |
| 4999 | } |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 5000 | } |
| 5001 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5002 | void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
| 5003 | const WebMediaPlayerAction& action) { |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 5004 | if (webview()) |
| 5005 | webview()->performMediaPlayerAction(action, location); |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 5006 | } |
| 5007 | |
[email protected] | 7782964 | 2012-05-15 14:47:17 | [diff] [blame] | 5008 | void RenderViewImpl::OnOrientationChangeEvent(int orientation) { |
| 5009 | webview()->mainFrame()->sendOrientationChangeEvent(orientation); |
| 5010 | } |
| 5011 | |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 5012 | void RenderViewImpl::OnPluginActionAt(const gfx::Point& location, |
| 5013 | const WebPluginAction& action) { |
| 5014 | if (webview()) |
| 5015 | webview()->performPluginAction(action, location); |
| 5016 | } |
| 5017 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5018 | void RenderViewImpl::OnGetAllSavableResourceLinksForCurrentPage( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 5019 | const GURL& page_url) { |
| 5020 | // Prepare list to storage all savable resource links. |
| 5021 | std::vector<GURL> resources_list; |
[email protected] | c2d98651 | 2012-05-12 00:22:46 | [diff] [blame] | 5022 | std::vector<GURL> referrer_urls_list; |
| 5023 | std::vector<WebKit::WebReferrerPolicy> referrer_policies_list; |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 5024 | std::vector<GURL> frames_list; |
| 5025 | webkit_glue::SavableResourcesResult result(&resources_list, |
[email protected] | c2d98651 | 2012-05-12 00:22:46 | [diff] [blame] | 5026 | &referrer_urls_list, |
| 5027 | &referrer_policies_list, |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 5028 | &frames_list); |
| 5029 | |
[email protected] | c2d98651 | 2012-05-12 00:22:46 | [diff] [blame] | 5030 | // webkit/ doesn't know about content::Referrer. |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 5031 | if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( |
| 5032 | webview(), |
| 5033 | page_url, |
| 5034 | &result, |
[email protected] | 1de7a17 | 2012-05-28 18:36:43 | [diff] [blame] | 5035 | const_cast<const char**>(content::GetSavableSchemes()))) { |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 5036 | // If something is wrong when collecting all savable resource links, |
| 5037 | // send empty list to embedder(browser) to tell it failed. |
[email protected] | c2d98651 | 2012-05-12 00:22:46 | [diff] [blame] | 5038 | referrer_urls_list.clear(); |
| 5039 | referrer_policies_list.clear(); |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 5040 | resources_list.clear(); |
| 5041 | frames_list.clear(); |
| 5042 | } |
| 5043 | |
[email protected] | c2d98651 | 2012-05-12 00:22:46 | [diff] [blame] | 5044 | std::vector<content::Referrer> referrers_list; |
| 5045 | CHECK_EQ(referrer_urls_list.size(), referrer_policies_list.size()); |
| 5046 | for (unsigned i = 0; i < referrer_urls_list.size(); ++i) { |
| 5047 | referrers_list.push_back( |
| 5048 | content::Referrer(referrer_urls_list[i], referrer_policies_list[i])); |
| 5049 | } |
| 5050 | |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 5051 | // Send result of all savable resource links to embedder. |
| 5052 | Send(new ViewHostMsg_SendCurrentPageAllSavableResourceLinks(routing_id(), |
| 5053 | resources_list, |
| 5054 | referrers_list, |
| 5055 | frames_list)); |
| 5056 | } |
| 5057 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5058 | void RenderViewImpl::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 5059 | const std::vector<GURL>& links, |
| 5060 | const std::vector<FilePath>& local_paths, |
| 5061 | const FilePath& local_directory_name) { |
| 5062 | |
| 5063 | // Convert std::vector of GURLs to WebVector<WebURL> |
| 5064 | WebVector<WebURL> weburl_links(links); |
| 5065 | |
| 5066 | // Convert std::vector of std::strings to WebVector<WebString> |
| 5067 | WebVector<WebString> webstring_paths(local_paths.size()); |
| 5068 | for (size_t i = 0; i < local_paths.size(); i++) |
| 5069 | webstring_paths[i] = webkit_glue::FilePathToWebString(local_paths[i]); |
| 5070 | |
| 5071 | WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links, |
| 5072 | webstring_paths, |
| 5073 | webkit_glue::FilePathToWebString( |
| 5074 | local_directory_name)); |
| 5075 | } |
| 5076 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5077 | void RenderViewImpl::OnShouldClose() { |
[email protected] | 7a17bac0 | 2012-03-07 21:58:12 | [diff] [blame] | 5078 | base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 5079 | bool should_close = webview()->dispatchBeforeUnloadEvent(); |
[email protected] | 7a17bac0 | 2012-03-07 21:58:12 | [diff] [blame] | 5080 | base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
| 5081 | Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close, |
| 5082 | before_unload_start_time, |
| 5083 | before_unload_end_time)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 5084 | } |
| 5085 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5086 | void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 5087 | // Ensure that no other in-progress navigation continues. |
| 5088 | OnStop(); |
| 5089 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 5090 | // Only run unload if we're not swapped out yet, but send the ack either way. |
| 5091 | if (!is_swapped_out_) { |
| 5092 | // Swap this RenderView out so the tab can navigate to a page rendered by a |
| 5093 | // different process. This involves running the unload handler and clearing |
| 5094 | // the page. Once WasSwappedOut is called, we also allow this process to |
| 5095 | // exit if there are no other active RenderViews in it. |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 5096 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 5097 | // Send an UpdateState message before we get swapped out. |
| 5098 | SyncNavigationState(); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 5099 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 5100 | // Synchronously run the unload handler before sending the ACK. |
| 5101 | webview()->dispatchUnloadEvent(); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 5102 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 5103 | // Swap out and stop sending any IPC messages that are not ACKs. |
| 5104 | SetSwappedOut(true); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 5105 | |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 5106 | // Replace the page with a blank dummy URL. The unload handler will not be |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 5107 | // run a second time, thanks to a check in FrameLoader::stopLoading. |
| 5108 | // TODO(creis): Need to add a better way to do this that avoids running the |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 5109 | // beforeunload handler. For now, we just run it a second time silently. |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 5110 | NavigateToSwappedOutURL(webview()->mainFrame()); |
[email protected] | 961541a9 | 2012-06-01 21:15:28 | [diff] [blame] | 5111 | |
| 5112 | // Let WebKit know that this view is hidden so it can drop resources and |
| 5113 | // stop compositing. |
| 5114 | webview()->setVisibilityState(WebKit::WebPageVisibilityStateHidden, false); |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 5115 | } |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 5116 | |
| 5117 | // Just echo back the params in the ACK. |
| 5118 | Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); |
| 5119 | } |
| 5120 | |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 5121 | void RenderViewImpl::NavigateToSwappedOutURL(WebKit::WebFrame* frame) { |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 5122 | // We use loadRequest instead of loadHTMLString because the former commits |
| 5123 | // synchronously. Otherwise a new navigation can interrupt the navigation |
| 5124 | // to content::kSwappedOutURL. If that happens to be to the page we had been |
| 5125 | // showing, then WebKit will never send a commit and we'll be left spinning. |
| 5126 | GURL swappedOutURL(content::kSwappedOutURL); |
| 5127 | WebURLRequest request(swappedOutURL); |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 5128 | frame->loadRequest(request); |
[email protected] | 14392a5 | 2012-05-02 20:28:44 | [diff] [blame] | 5129 | } |
| 5130 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5131 | void RenderViewImpl::OnClosePage() { |
[email protected] | 77fc9b9 | 2011-10-15 16:20:37 | [diff] [blame] | 5132 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 5133 | // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 5134 | // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 5135 | // in the onunload handler from appearing. For now, we're bypassing that and |
| 5136 | // calling the FrameLoader's CloseURL method directly. This should be |
| 5137 | // revisited to avoid having two ways to close a page. Having a single way |
| 5138 | // to close that can run onunload is also useful for fixing |
| 5139 | // http://b/issue?id=753080. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 5140 | webview()->dispatchUnloadEvent(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 5141 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 5142 | Send(new ViewHostMsg_ClosePage_ACK(routing_id_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 5143 | } |
| 5144 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5145 | void RenderViewImpl::OnThemeChanged() { |
[email protected] | e8d6b9f | 2011-10-10 22:21:02 | [diff] [blame] | 5146 | #if defined(USE_AURA) |
| 5147 | // Aura doesn't care if we switch themes. |
| 5148 | #elif defined(OS_WIN) |
[email protected] | f78452f | 2012-05-15 02:07:52 | [diff] [blame] | 5149 | ui::NativeThemeWin::instance()->CloseHandles(); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 5150 | if (webview()) |
| 5151 | webview()->themeChanged(); |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 5152 | #else // defined(OS_WIN) |
| 5153 | // TODO(port): we don't support theming on non-Windows platforms yet |
| 5154 | NOTIMPLEMENTED(); |
| 5155 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 5156 | } |
| 5157 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5158 | void RenderViewImpl::OnDisassociateFromPopupCount() { |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 5159 | if (decrement_shared_popup_at_destruction_) |
| 5160 | shared_popup_counter_->data--; |
| 5161 | shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 5162 | decrement_shared_popup_at_destruction_ = false; |
| 5163 | } |
| 5164 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5165 | bool RenderViewImpl::MaybeLoadAlternateErrorPage(WebFrame* frame, |
| 5166 | const WebURLError& error, |
| 5167 | bool replace) { |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5168 | // We only show alternate error pages in the main frame. They are |
| 5169 | // intended to assist the user when navigating, so there is not much |
| 5170 | // value in showing them for failed subframes. Ideally, we would be |
| 5171 | // able to use the TYPED transition type for this, but that flag is |
| 5172 | // not preserved across page reloads. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 5173 | if (frame->parent()) |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5174 | return false; |
| 5175 | |
| 5176 | // Use the alternate error page service if this is a DNS failure or |
[email protected] | c53976d5 | 2009-08-07 18:58:37 | [diff] [blame] | 5177 | // connection failure. |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5178 | int ec = error.reason; |
| 5179 | if (ec != net::ERR_NAME_NOT_RESOLVED && |
| 5180 | ec != net::ERR_CONNECTION_FAILED && |
| 5181 | ec != net::ERR_CONNECTION_REFUSED && |
| 5182 | ec != net::ERR_ADDRESS_UNREACHABLE && |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 5183 | ec != net::ERR_CONNECTION_TIMED_OUT) { |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5184 | return false; |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 5185 | } |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5186 | |
| 5187 | const GURL& error_page_url = GetAlternateErrorPageURL(error.unreachableURL, |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 5188 | ec == net::ERR_NAME_NOT_RESOLVED ? DNS_ERROR : CONNECTION_ERROR); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5189 | if (!error_page_url.is_valid()) |
| 5190 | return false; |
| 5191 | |
| 5192 | // Load an empty page first so there is an immediate response to the error, |
| 5193 | // and then kick off a request for the alternate error page. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 5194 | frame->loadHTMLString(std::string(), |
[email protected] | 285f4bb8 | 2012-04-17 15:57:28 | [diff] [blame] | 5195 | GURL(content::kUnreachableWebDataURL), |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5196 | error.unreachableURL, |
| 5197 | replace); |
| 5198 | |
| 5199 | // Now, create a fetcher for the error page and associate it with the data |
| 5200 | // source we just created via the LoadHTMLString call. That way if another |
| 5201 | // navigation occurs, the fetcher will get destroyed. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 5202 | DocumentState* document_state = |
| 5203 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 5204 | document_state->set_alt_error_page_fetcher( |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5205 | new AltErrorPageResourceFetcher( |
| 5206 | error_page_url, frame, error, |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 5207 | base::Bind(&RenderViewImpl::AltErrorPageFinished, |
| 5208 | base::Unretained(this)))); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5209 | return true; |
| 5210 | } |
| 5211 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5212 | void RenderViewImpl::AltErrorPageFinished(WebFrame* frame, |
| 5213 | const WebURLError& original_error, |
| 5214 | const std::string& html) { |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5215 | // Here, we replace the blank page we loaded previously. |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 5216 | // If we failed to download the alternate error page, LoadNavigationErrorPage |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 5217 | // will simply display a default error page. |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 5218 | LoadNavigationErrorPage(frame, WebURLRequest(), original_error, html, true); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 5219 | } |
| 5220 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5221 | void RenderViewImpl::OnMoveOrResizeStarted() { |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 5222 | if (webview()) |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 5223 | webview()->hidePopups(); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 5224 | } |
| 5225 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5226 | void RenderViewImpl::OnResize(const gfx::Size& new_size, |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 5227 | const gfx::Rect& resizer_rect, |
| 5228 | bool is_fullscreen) { |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 5229 | if (webview()) { |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 5230 | webview()->hidePopups(); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 5231 | if (send_preferred_size_changes_) { |
[email protected] | 7339cd2 | 2010-10-27 00:11:20 | [diff] [blame] | 5232 | webview()->mainFrame()->setCanHaveScrollbars( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 5233 | ShouldDisplayScrollbars(new_size.width(), new_size.height())); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 5234 | } |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 5235 | UpdateScrollState(webview()->mainFrame()); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 5236 | } |
| 5237 | |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 5238 | RenderWidget::OnResize(new_size, resizer_rect, is_fullscreen); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 5239 | } |
[email protected] | 0aa477bd | 2009-03-23 22:21:43 | [diff] [blame] | 5240 | |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 5241 | void RenderViewImpl::WillInitiatePaint() { |
| 5242 | // Notify the pepper plugins that we're about to paint. |
| 5243 | pepper_delegate_.ViewWillInitiatePaint(); |
| 5244 | } |
| 5245 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5246 | void RenderViewImpl::DidInitiatePaint() { |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 5247 | // Notify the pepper plugins that we've painted, and are waiting to flush. |
[email protected] | 53900d5 | 2010-06-16 04:25:01 | [diff] [blame] | 5248 | pepper_delegate_.ViewInitiatedPaint(); |
[email protected] | 7900bfdb | 2012-05-24 19:31:24 | [diff] [blame] | 5249 | if (GetGuestToEmbedderChannel()) |
| 5250 | GetGuestToEmbedderChannel()->IssueSwapBuffers(guest_graphics_resource()); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 5251 | } |
| 5252 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5253 | void RenderViewImpl::DidFlushPaint() { |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 5254 | // Notify any pepper plugins that we painted. This will call into the plugin, |
| 5255 | // and we it may ask to close itself as a result. This will, in turn, modify |
| 5256 | // our set, possibly invalidating the iterator. So we iterate on a copy that |
| 5257 | // won't change out from under us. |
[email protected] | 53900d5 | 2010-06-16 04:25:01 | [diff] [blame] | 5258 | pepper_delegate_.ViewFlushedPaint(); |
| 5259 | |
[email protected] | 5b1dec8c | 2012-02-07 04:35:38 | [diff] [blame] | 5260 | // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
| 5261 | // See crbug.com/112921. |
| 5262 | if (!webview()) |
| 5263 | return; |
| 5264 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 5265 | WebFrame* main_frame = webview()->mainFrame(); |
| 5266 | |
| 5267 | // If we have a provisional frame we are between the start and commit stages |
| 5268 | // of loading and we don't want to save stats. |
| 5269 | if (!main_frame->provisionalDataSource()) { |
| 5270 | WebDataSource* ds = main_frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 5271 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 5272 | |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 5273 | // TODO(jar): The following code should all be inside a method, probably in |
| 5274 | // NavigatorState. |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 5275 | Time now = Time::Now(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 5276 | if (document_state->first_paint_time().is_null()) { |
| 5277 | document_state->set_first_paint_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 5278 | } |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 5279 | if (document_state->first_paint_after_load_time().is_null() && |
| 5280 | !document_state->finish_load_time().is_null()) { |
| 5281 | document_state->set_first_paint_after_load_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 5282 | } |
| 5283 | } |
| 5284 | } |
| 5285 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5286 | void RenderViewImpl::OnViewContextSwapBuffersPosted() { |
[email protected] | 37a6f30 | 2011-07-11 23:43:08 | [diff] [blame] | 5287 | RenderWidget::OnSwapBuffersPosted(); |
| 5288 | } |
| 5289 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5290 | void RenderViewImpl::OnViewContextSwapBuffersComplete() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 5291 | RenderWidget::OnSwapBuffersComplete(); |
| 5292 | } |
| 5293 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5294 | void RenderViewImpl::OnViewContextSwapBuffersAborted() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 5295 | RenderWidget::OnSwapBuffersAborted(); |
| 5296 | } |
| 5297 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5298 | webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint( |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 5299 | const gfx::Rect& paint_bounds, |
| 5300 | TransportDIB** dib, |
| 5301 | gfx::Rect* location, |
[email protected] | 0f3a2d1 | 2012-09-01 03:37:20 | [diff] [blame^] | 5302 | gfx::Rect* clip, |
| 5303 | float* scale_factor) { |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 5304 | return pepper_delegate_.GetBitmapForOptimizedPluginPaint( |
[email protected] | 0f3a2d1 | 2012-09-01 03:37:20 | [diff] [blame^] | 5305 | paint_bounds, dib, location, clip, scale_factor); |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 5306 | } |
| 5307 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5308 | gfx::Point RenderViewImpl::GetScrollOffset() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 5309 | WebSize scroll_offset = webview()->mainFrame()->scrollOffset(); |
[email protected] | bcaf227 | 2011-02-15 15:29:43 | [diff] [blame] | 5310 | return gfx::Point(scroll_offset.width, scroll_offset.height); |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 5311 | } |
| 5312 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5313 | void RenderViewImpl::OnClearFocusedNode() { |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 5314 | if (webview()) |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 5315 | webview()->clearFocusedNode(); |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 5316 | } |
| 5317 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5318 | void RenderViewImpl::OnSetBackground(const SkBitmap& background) { |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 5319 | if (webview()) |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 5320 | webview()->setIsTransparent(!background.empty()); |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 5321 | |
| 5322 | SetBackground(background); |
| 5323 | } |
| 5324 | |
[email protected] | 2a84f9d | 2012-06-05 21:50:43 | [diff] [blame] | 5325 | void RenderViewImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { |
| 5326 | if (accessibility_mode_ == new_mode) |
| 5327 | return; |
| 5328 | accessibility_mode_ = new_mode; |
| 5329 | if (renderer_accessibility_) { |
| 5330 | delete renderer_accessibility_; |
| 5331 | renderer_accessibility_ = NULL; |
| 5332 | } |
| 5333 | if (accessibility_mode_ == AccessibilityModeComplete) |
| 5334 | renderer_accessibility_ = new RendererAccessibilityComplete(this); |
| 5335 | else if (accessibility_mode_ == AccessibilityModeEditableTextOnly) |
| 5336 | renderer_accessibility_ = new RendererAccessibilityFocusOnly(this); |
| 5337 | } |
| 5338 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5339 | void RenderViewImpl::OnSetActive(bool active) { |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 5340 | if (webview()) |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 5341 | webview()->setIsActive(active); |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 5342 | |
| 5343 | #if defined(OS_MACOSX) |
| 5344 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 5345 | for (plugin_it = plugin_delegates_.begin(); |
| 5346 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 5347 | (*plugin_it)->SetWindowFocus(active); |
| 5348 | } |
| 5349 | #endif |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 5350 | } |
| 5351 | |
[email protected] | 7a17bac0 | 2012-03-07 21:58:12 | [diff] [blame] | 5352 | void RenderViewImpl::OnSetNavigationStartTime( |
| 5353 | const base::TimeTicks& browser_navigation_start) { |
| 5354 | if (!webview()) |
| 5355 | return; |
| 5356 | |
| 5357 | // Only the initial navigation can be a cross-renderer navigation. If we've |
| 5358 | // already navigated away from that page, we can ignore this message. |
| 5359 | if (page_id_ != -1) |
| 5360 | return; |
| 5361 | |
| 5362 | // browser_navigation_start is likely before this process existed, so we can't |
| 5363 | // use InterProcessTimeTicksConverter. Instead, the best we can do is just |
| 5364 | // ensure we don't report a bogus value in the future. |
| 5365 | base::TimeTicks navigation_start = std::min(base::TimeTicks::Now(), |
| 5366 | browser_navigation_start); |
| 5367 | webview()->mainFrame()->provisionalDataSource()->setNavigationStartTime( |
| 5368 | (navigation_start - base::TimeTicks()).InSecondsF()); |
| 5369 | } |
| 5370 | |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 5371 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5372 | void RenderViewImpl::OnSetWindowVisibility(bool visible) { |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 5373 | // Inform plugins that their container has changed visibility. |
| 5374 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 5375 | for (plugin_it = plugin_delegates_.begin(); |
| 5376 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 5377 | (*plugin_it)->SetContainerVisibility(visible); |
| 5378 | } |
| 5379 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 5380 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5381 | void RenderViewImpl::OnWindowFrameChanged(const gfx::Rect& window_frame, |
| 5382 | const gfx::Rect& view_frame) { |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 5383 | // Inform plugins that their window's frame has changed. |
| 5384 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 5385 | for (plugin_it = plugin_delegates_.begin(); |
| 5386 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 5387 | (*plugin_it)->WindowFrameChanged(window_frame, view_frame); |
| 5388 | } |
| 5389 | } |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 5390 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5391 | void RenderViewImpl::OnPluginImeCompositionCompleted(const string16& text, |
| 5392 | int plugin_id) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 5393 | // WebPluginDelegateProxy is responsible for figuring out if this event |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 5394 | // applies to it or not, so inform all the delegates. |
| 5395 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 5396 | for (plugin_it = plugin_delegates_.begin(); |
| 5397 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 5398 | (*plugin_it)->ImeCompositionCompleted(text, plugin_id); |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 5399 | } |
| 5400 | } |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 5401 | #endif // OS_MACOSX |
| 5402 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5403 | void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 5404 | const EditCommands& edit_commands) { |
| 5405 | edit_commands_ = edit_commands; |
| 5406 | } |
| 5407 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5408 | void RenderViewImpl::Close() { |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 5409 | // We need to grab a pointer to the doomed WebView before we destroy it. |
| 5410 | WebView* doomed = webview(); |
| 5411 | RenderWidget::Close(); |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 5412 | g_view_map.Get().erase(doomed); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 5413 | } |
| 5414 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5415 | void RenderViewImpl::DidHandleKeyEvent() { |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 5416 | edit_commands_.clear(); |
| 5417 | } |
| 5418 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5419 | bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 5420 | pepper_delegate_.WillHandleMouseEvent(); |
| 5421 | |
| 5422 | // If the mouse is locked, only the current owner of the mouse lock can |
| 5423 | // process mouse events. |
| 5424 | return mouse_lock_dispatcher_->WillHandleMouseEvent(event); |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 5425 | } |
| 5426 | |
[email protected] | 2b942c33 | 2012-04-25 16:26:26 | [diff] [blame] | 5427 | void RenderViewImpl::DidHandleMouseEvent(const WebMouseEvent& event) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 5428 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 5429 | } |
| 5430 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5431 | void RenderViewImpl::DidHandleTouchEvent(const WebTouchEvent& event) { |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 5432 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleTouchEvent(event)); |
| 5433 | } |
| 5434 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5435 | void RenderViewImpl::OnWasHidden() { |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 5436 | RenderWidget::OnWasHidden(); |
| 5437 | |
[email protected] | 2d7b82c | 2012-06-01 05:57:50 | [diff] [blame] | 5438 | #if defined(OS_ANDROID) |
| 5439 | // Inform WebMediaPlayerManagerAndroid to release all media player resources. |
| 5440 | media_player_manager_->ReleaseMediaResources(); |
| 5441 | #endif |
| 5442 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 5443 | if (webview()) { |
| 5444 | webview()->settings()->setMinimumTimerInterval( |
| 5445 | webkit_glue::kBackgroundTabTimerInterval); |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 5446 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 5447 | } |
| 5448 | |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 5449 | // Inform PPAPI plugins that their page is no longer visible. |
| 5450 | pepper_delegate_.PageVisibilityChanged(false); |
| 5451 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 5452 | #if defined(OS_MACOSX) |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 5453 | // Inform NPAPI plugins that their container is no longer visible. |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 5454 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 5455 | for (plugin_it = plugin_delegates_.begin(); |
| 5456 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 5457 | (*plugin_it)->SetContainerVisibility(false); |
| 5458 | } |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 5459 | #endif // OS_MACOSX |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 5460 | } |
| 5461 | |
[email protected] | 9e2e463 | 2012-07-27 16:38:41 | [diff] [blame] | 5462 | void RenderViewImpl::OnWasShown(bool needs_repainting) { |
| 5463 | RenderWidget::OnWasShown(needs_repainting); |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 5464 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 5465 | if (webview()) { |
| 5466 | webview()->settings()->setMinimumTimerInterval( |
| 5467 | webkit_glue::kForegroundTabTimerInterval); |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 5468 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 5469 | } |
| 5470 | |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 5471 | // Inform PPAPI plugins that their page is visible. |
| 5472 | pepper_delegate_.PageVisibilityChanged(true); |
| 5473 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 5474 | #if defined(OS_MACOSX) |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 5475 | // Inform NPAPI plugins that their container is now visible. |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 5476 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 5477 | for (plugin_it = plugin_delegates_.begin(); |
| 5478 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 5479 | (*plugin_it)->SetContainerVisibility(true); |
| 5480 | } |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 5481 | #endif // OS_MACOSX |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 5482 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 5483 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5484 | bool RenderViewImpl::SupportsAsynchronousSwapBuffers() { |
[email protected] | 9caf09bc | 2012-06-25 21:46:28 | [diff] [blame] | 5485 | // Contexts using the command buffer support asynchronous swapbuffers. |
[email protected] | f89e173a | 2012-08-24 01:12:26 | [diff] [blame] | 5486 | // See RenderViewImpl::createOutputSurface(). |
[email protected] | 9caf09bc | 2012-06-25 21:46:28 | [diff] [blame] | 5487 | if (WebWidgetHandlesCompositorScheduling() || |
| 5488 | CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) |
[email protected] | 555e75d | 2011-10-08 01:23:38 | [diff] [blame] | 5489 | return false; |
| 5490 | |
[email protected] | 9caf09bc | 2012-06-25 21:46:28 | [diff] [blame] | 5491 | return true; |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 5492 | } |
| 5493 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5494 | void RenderViewImpl::OnSetFocus(bool enable) { |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 5495 | RenderWidget::OnSetFocus(enable); |
| 5496 | |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 5497 | if (webview() && webview()->isActive()) { |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 5498 | // Notify all NPAPI plugins. |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 5499 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 5500 | for (plugin_it = plugin_delegates_.begin(); |
| 5501 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 5502 | #if defined(OS_MACOSX) |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 5503 | // RenderWidget's call to setFocus can cause the underlying webview's |
| 5504 | // activation state to change just like a call to setIsActive. |
| 5505 | if (enable) |
| 5506 | (*plugin_it)->SetWindowFocus(true); |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 5507 | #endif |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 5508 | (*plugin_it)->SetContentAreaFocus(enable); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 5509 | } |
| 5510 | } |
[email protected] | a01da568 | 2012-06-30 00:37:31 | [diff] [blame] | 5511 | // Notify all Pepper plugins. |
| 5512 | pepper_delegate_.OnSetFocus(enable); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 5513 | } |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 5514 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5515 | void RenderViewImpl::PpapiPluginFocusChanged() { |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 5516 | UpdateTextInputState(); |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 5517 | UpdateSelectionBounds(); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 5518 | } |
| 5519 | |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 5520 | void RenderViewImpl::PpapiPluginTextInputTypeChanged() { |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 5521 | UpdateTextInputState(); |
[email protected] | 8fe8f74 | 2012-06-14 00:36:08 | [diff] [blame] | 5522 | if (renderer_accessibility_) |
| 5523 | renderer_accessibility_->FocusedNodeChanged(WebNode()); |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 5524 | } |
| 5525 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 5526 | void RenderViewImpl::PpapiPluginCaretPositionChanged() { |
| 5527 | UpdateSelectionBounds(); |
| 5528 | } |
| 5529 | |
[email protected] | b25b3ee | 2012-01-13 05:19:54 | [diff] [blame] | 5530 | bool RenderViewImpl::GetPpapiPluginCaretBounds(gfx::Rect* rect) { |
| 5531 | if (!pepper_delegate_.IsPluginFocused()) |
| 5532 | return false; |
| 5533 | *rect = pepper_delegate_.GetCaretBounds(); |
| 5534 | return true; |
| 5535 | } |
| 5536 | |
[email protected] | 397c2396 | 2012-05-21 07:09:32 | [diff] [blame] | 5537 | void RenderViewImpl::SimulateImeSetComposition( |
| 5538 | const string16& text, |
| 5539 | const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 5540 | int selection_start, |
| 5541 | int selection_end) { |
| 5542 | OnImeSetComposition(text, underlines, selection_start, selection_end); |
| 5543 | } |
| 5544 | |
| 5545 | void RenderViewImpl::SimulateImeConfirmComposition( |
| 5546 | const string16& text, |
| 5547 | const ui::Range& replacement_range) { |
| 5548 | OnImeConfirmComposition(text, replacement_range); |
| 5549 | } |
| 5550 | |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 5551 | void RenderViewImpl::PpapiPluginCancelComposition() { |
| 5552 | Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 5553 | const ui::Range range(ui::Range::InvalidRange()); |
| 5554 | const std::vector<gfx::Rect> empty_bounds; |
| 5555 | UpdateCompositionInfo(range, empty_bounds); |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 5556 | } |
| 5557 | |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame] | 5558 | void RenderViewImpl::PpapiPluginSelectionChanged() { |
| 5559 | SyncSelectionIfRequired(); |
| 5560 | } |
| 5561 | |
[email protected] | 93df81e | 2012-08-10 22:22:46 | [diff] [blame] | 5562 | void RenderViewImpl::PpapiPluginCreated(content::RendererPpapiHost* host) { |
[email protected] | 236bf85 | 2012-07-27 22:49:36 | [diff] [blame] | 5563 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 5564 | DidCreatePepperPlugin(host)); |
| 5565 | } |
| 5566 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5567 | void RenderViewImpl::OnImeSetComposition( |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 5568 | const string16& text, |
| 5569 | const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 5570 | int selection_start, |
| 5571 | int selection_end) { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 5572 | if (pepper_delegate_.IsPluginFocused()) { |
| 5573 | // When a PPAPI plugin has focus, we bypass WebKit. |
| 5574 | pepper_delegate_.OnImeSetComposition(text, |
| 5575 | underlines, |
| 5576 | selection_start, |
| 5577 | selection_end); |
| 5578 | } else { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 5579 | #if defined(OS_WIN) |
| 5580 | // When a plug-in has focus, we create platform-specific IME data used by |
| 5581 | // our IME emulator and send it directly to the focused plug-in, i.e. we |
| 5582 | // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its |
| 5583 | // instance ID is the same one as the specified ID.) |
| 5584 | if (focused_plugin_id_ >= 0) { |
| 5585 | std::vector<int> clauses; |
| 5586 | std::vector<int> target; |
| 5587 | for (size_t i = 0; i < underlines.size(); ++i) { |
| 5588 | clauses.push_back(underlines[i].startOffset); |
| 5589 | clauses.push_back(underlines[i].endOffset); |
| 5590 | if (underlines[i].thick) { |
| 5591 | target.clear(); |
| 5592 | target.push_back(underlines[i].startOffset); |
| 5593 | target.push_back(underlines[i].endOffset); |
| 5594 | } |
| 5595 | } |
| 5596 | std::set<WebPluginDelegateProxy*>::iterator it; |
| 5597 | for (it = plugin_delegates_.begin(); |
| 5598 | it != plugin_delegates_.end(); ++it) { |
| 5599 | (*it)->ImeCompositionUpdated(text, clauses, target, selection_end, |
| 5600 | focused_plugin_id_); |
| 5601 | } |
| 5602 | return; |
| 5603 | } |
| 5604 | #endif |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 5605 | RenderWidget::OnImeSetComposition(text, |
| 5606 | underlines, |
| 5607 | selection_start, |
| 5608 | selection_end); |
| 5609 | } |
| 5610 | } |
| 5611 | |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 5612 | void RenderViewImpl::OnImeConfirmComposition( |
| 5613 | const string16& text, const ui::Range& replacement_range) { |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 5614 | if (pepper_delegate_.IsPluginFocused()) { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 5615 | // When a PPAPI plugin has focus, we bypass WebKit. |
| 5616 | pepper_delegate_.OnImeConfirmComposition(text); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 5617 | } else { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 5618 | #if defined(OS_WIN) |
| 5619 | // Same as OnImeSetComposition(), we send the text from IMEs directly to |
| 5620 | // plug-ins. When we send IME text directly to plug-ins, we should not send |
| 5621 | // it to WebKit to prevent WebKit from controlling IMEs. |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 5622 | // TODO(thakis): Honor |replacement_range| for plugins? |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 5623 | if (focused_plugin_id_ >= 0) { |
| 5624 | std::set<WebPluginDelegateProxy*>::iterator it; |
| 5625 | for (it = plugin_delegates_.begin(); |
| 5626 | it != plugin_delegates_.end(); ++it) { |
| 5627 | (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
| 5628 | } |
| 5629 | return; |
| 5630 | } |
| 5631 | #endif |
[email protected] | ebd28ac | 2011-10-13 18:49:05 | [diff] [blame] | 5632 | if (replacement_range.IsValid() && webview()) { |
| 5633 | // Select the text in |replacement_range|, it will then be replaced by |
| 5634 | // text added by the call to RenderWidget::OnImeConfirmComposition(). |
| 5635 | if (WebFrame* frame = webview()->focusedFrame()) { |
[email protected] | 4bacb82 | 2011-11-02 15:10:16 | [diff] [blame] | 5636 | WebRange webrange = WebRange::fromDocumentRange( |
| 5637 | frame, replacement_range.start(), replacement_range.length()); |
| 5638 | if (!webrange.isNull()) |
[email protected] | 884f900 | 2012-08-21 19:33:58 | [diff] [blame] | 5639 | frame->selectRange(webrange); |
[email protected] | ebd28ac | 2011-10-13 18:49:05 | [diff] [blame] | 5640 | } |
| 5641 | } |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 5642 | RenderWidget::OnImeConfirmComposition(text, replacement_range); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 5643 | } |
| 5644 | } |
| 5645 | |
[email protected] | dea5e768 | 2012-06-14 05:21:24 | [diff] [blame] | 5646 | void RenderViewImpl::OnSetDeviceScaleFactor(float device_scale_factor) { |
| 5647 | RenderWidget::OnSetDeviceScaleFactor(device_scale_factor); |
| 5648 | if (webview()) |
| 5649 | webview()->setDeviceScaleFactor(device_scale_factor); |
| 5650 | } |
| 5651 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5652 | ui::TextInputType RenderViewImpl::GetTextInputType() { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 5653 | return pepper_delegate_.IsPluginFocused() ? |
| 5654 | pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); |
| 5655 | } |
| 5656 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 5657 | void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { |
| 5658 | if (pepper_delegate_.IsPluginFocused()) { |
| 5659 | // TODO(kinaba) http://crbug.com/101101 |
| 5660 | // Current Pepper IME API does not handle selection bounds. So we simply |
| 5661 | // use the caret position as an empty range for now. It will be updated |
| 5662 | // after Pepper API equips features related to surrounding text retrieval. |
| 5663 | gfx::Rect caret = pepper_delegate_.GetCaretBounds(); |
| 5664 | *start = caret; |
| 5665 | *end = caret; |
| 5666 | return; |
| 5667 | } |
| 5668 | RenderWidget::GetSelectionBounds(start, end); |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 5669 | } |
| 5670 | |
[email protected] | 58b48a0d | 2012-06-13 07:01:35 | [diff] [blame] | 5671 | void RenderViewImpl::GetCompositionCharacterBounds( |
| 5672 | std::vector<gfx::Rect>* bounds) { |
| 5673 | DCHECK(bounds); |
| 5674 | bounds->clear(); |
| 5675 | |
| 5676 | if (!webview()) |
| 5677 | return; |
| 5678 | size_t start_offset = 0; |
| 5679 | size_t character_count = 0; |
| 5680 | if (!webview()->compositionRange(&start_offset, &character_count)) |
| 5681 | return; |
| 5682 | if (character_count == 0) |
| 5683 | return; |
| 5684 | |
| 5685 | WebKit::WebFrame* frame = webview()->focusedFrame(); |
| 5686 | if (!frame) |
| 5687 | return; |
| 5688 | |
| 5689 | bounds->reserve(character_count); |
| 5690 | WebKit::WebRect webrect; |
| 5691 | for (size_t i = 0; i < character_count; ++i) { |
| 5692 | if (!frame->firstRectForCharacterRange(start_offset + i, 1, webrect)) { |
| 5693 | DLOG(ERROR) << "Could not retrieve character rectangle at " << i; |
| 5694 | bounds->clear(); |
| 5695 | return; |
| 5696 | } |
| 5697 | bounds->push_back(webrect); |
| 5698 | } |
| 5699 | } |
| 5700 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5701 | bool RenderViewImpl::CanComposeInline() { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 5702 | return pepper_delegate_.IsPluginFocused() ? |
| 5703 | pepper_delegate_.CanComposeInline() : true; |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 5704 | } |
| 5705 | |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 5706 | #if defined(OS_WIN) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5707 | void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 5708 | if (focused) |
| 5709 | focused_plugin_id_ = plugin_id; |
| 5710 | else |
| 5711 | focused_plugin_id_ = -1; |
| 5712 | } |
| 5713 | #endif |
| 5714 | |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 5715 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5716 | void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 5717 | Send(new ViewHostMsg_PluginFocusChanged(routing_id(), focused, plugin_id)); |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 5718 | } |
| 5719 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5720 | void RenderViewImpl::StartPluginIme() { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 5721 | IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 5722 | // This message can be sent during event-handling, and needs to be delivered |
| 5723 | // within that context. |
| 5724 | msg->set_unblock(true); |
| 5725 | Send(msg); |
| 5726 | } |
| 5727 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5728 | gfx::PluginWindowHandle RenderViewImpl::AllocateFakePluginWindowHandle( |
[email protected] | 77e74db | 2010-08-04 17:46:23 | [diff] [blame] | 5729 | bool opaque, bool root) { |
[email protected] | b296829 | 2012-03-28 01:35:51 | [diff] [blame] | 5730 | gfx::PluginWindowHandle window = gfx::kNullPluginWindow; |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 5731 | Send(new ViewHostMsg_AllocateFakePluginWindowHandle( |
[email protected] | 77e74db | 2010-08-04 17:46:23 | [diff] [blame] | 5732 | routing_id(), opaque, root, &window)); |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 5733 | if (window) { |
| 5734 | fake_plugin_window_handles_.insert(window); |
| 5735 | } |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 5736 | return window; |
| 5737 | } |
| 5738 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5739 | void RenderViewImpl::DestroyFakePluginWindowHandle( |
| 5740 | gfx::PluginWindowHandle window) { |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 5741 | if (window && fake_plugin_window_handles_.find(window) != |
| 5742 | fake_plugin_window_handles_.end()) { |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 5743 | Send(new ViewHostMsg_DestroyFakePluginWindowHandle(routing_id(), window)); |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 5744 | fake_plugin_window_handles_.erase(window); |
| 5745 | } |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 5746 | } |
| 5747 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5748 | void RenderViewImpl::AcceleratedSurfaceSetIOSurface( |
| 5749 | gfx::PluginWindowHandle window, |
| 5750 | int32 width, |
| 5751 | int32 height, |
| 5752 | uint64 io_surface_identifier) { |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 5753 | Send(new ViewHostMsg_AcceleratedSurfaceSetIOSurface( |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 5754 | routing_id(), window, width, height, io_surface_identifier)); |
| 5755 | } |
| 5756 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5757 | void RenderViewImpl::AcceleratedSurfaceSetTransportDIB( |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 5758 | gfx::PluginWindowHandle window, |
| 5759 | int32 width, |
| 5760 | int32 height, |
| 5761 | TransportDIB::Handle transport_dib) { |
| 5762 | Send(new ViewHostMsg_AcceleratedSurfaceSetTransportDIB( |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 5763 | routing_id(), window, width, height, transport_dib)); |
| 5764 | } |
| 5765 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5766 | TransportDIB::Handle RenderViewImpl::AcceleratedSurfaceAllocTransportDIB( |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 5767 | size_t size) { |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 5768 | TransportDIB::Handle dib_handle; |
| 5769 | // Assume this is a synchronous RPC. |
[email protected] | ada848b1 | 2010-04-08 22:35:38 | [diff] [blame] | 5770 | if (Send(new ViewHostMsg_AllocTransportDIB(size, true, &dib_handle))) |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 5771 | return dib_handle; |
| 5772 | // Return an invalid handle if Send() fails. |
| 5773 | return TransportDIB::DefaultHandleValue(); |
| 5774 | } |
| 5775 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5776 | void RenderViewImpl::AcceleratedSurfaceFreeTransportDIB( |
| 5777 | TransportDIB::Id dib_id) { |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 5778 | Send(new ViewHostMsg_FreeTransportDIB(dib_id)); |
| 5779 | } |
| 5780 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5781 | void RenderViewImpl::AcceleratedSurfaceBuffersSwapped( |
[email protected] | 7de8fb7 | 2012-03-14 04:24:32 | [diff] [blame] | 5782 | gfx::PluginWindowHandle window, uint64 surface_handle) { |
[email protected] | f35d667 | 2010-10-28 21:39:14 | [diff] [blame] | 5783 | Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( |
[email protected] | 7de8fb7 | 2012-03-14 04:24:32 | [diff] [blame] | 5784 | routing_id(), window, surface_handle)); |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 5785 | } |
[email protected] | 82114f5 | 2012-03-20 22:53:41 | [diff] [blame] | 5786 | #endif // defined(OS_MACOSX) |
[email protected] | 58c321d | 2010-02-19 12:11:28 | [diff] [blame] | 5787 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5788 | bool RenderViewImpl::ScheduleFileChooser( |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 5789 | const content::FileChooserParams& params, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 5790 | WebFileChooserCompletion* completion) { |
| 5791 | static const size_t kMaximumPendingFileChooseRequests = 4; |
| 5792 | if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { |
| 5793 | // This sanity check prevents too many file choose requests from getting |
| 5794 | // queued which could DoS the user. Getting these is most likely a |
| 5795 | // programming error (there are many ways to DoS the user so it's not |
| 5796 | // considered a "real" security check), either in JS requesting many file |
| 5797 | // choosers to pop up, or in a plugin. |
| 5798 | // |
| 5799 | // TODO(brettw) we might possibly want to require a user gesture to open |
| 5800 | // a file picker, which will address this issue in a better way. |
| 5801 | return false; |
| 5802 | } |
| 5803 | |
| 5804 | file_chooser_completions_.push_back(linked_ptr<PendingFileChooser>( |
| 5805 | new PendingFileChooser(params, completion))); |
| 5806 | if (file_chooser_completions_.size() == 1) { |
| 5807 | // Actually show the browse dialog when this is the first request. |
| 5808 | Send(new ViewHostMsg_RunFileChooser(routing_id_, params)); |
| 5809 | } |
| 5810 | return true; |
| 5811 | } |
| 5812 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5813 | WebKit::WebGeolocationClient* RenderViewImpl::geolocationClient() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 5814 | if (!geolocation_dispatcher_) |
| 5815 | geolocation_dispatcher_ = new GeolocationDispatcher(this); |
| 5816 | return geolocation_dispatcher_; |
[email protected] | 7e0c470 | 2010-12-31 14:06:25 | [diff] [blame] | 5817 | } |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 5818 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5819 | WebKit::WebSpeechInputController* RenderViewImpl::speechInputController( |
[email protected] | 638694c | 2010-08-04 22:24:11 | [diff] [blame] | 5820 | WebKit::WebSpeechInputListener* listener) { |
[email protected] | 9eb100e | 2011-10-14 05:08:22 | [diff] [blame] | 5821 | #if defined(ENABLE_INPUT_SPEECH) |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 5822 | if (!input_tag_speech_dispatcher_) |
| 5823 | input_tag_speech_dispatcher_ = |
| 5824 | new InputTagSpeechDispatcher(this, listener); |
[email protected] | 9eb100e | 2011-10-14 05:08:22 | [diff] [blame] | 5825 | #endif |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 5826 | return input_tag_speech_dispatcher_; |
[email protected] | 638694c | 2010-08-04 22:24:11 | [diff] [blame] | 5827 | } |
| 5828 | |
[email protected] | 64d0922 | 2012-05-25 10:10:34 | [diff] [blame] | 5829 | WebKit::WebSpeechRecognizer* RenderViewImpl::speechRecognizer() { |
| 5830 | #if defined(ENABLE_INPUT_SPEECH) |
| 5831 | if (!speech_recognition_dispatcher_) |
| 5832 | speech_recognition_dispatcher_ = new SpeechRecognitionDispatcher(this); |
| 5833 | #endif |
| 5834 | return speech_recognition_dispatcher_; |
| 5835 | } |
| 5836 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5837 | WebKit::WebDeviceOrientationClient* RenderViewImpl::deviceOrientationClient() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 5838 | if (!device_orientation_dispatcher_) |
| 5839 | device_orientation_dispatcher_ = new DeviceOrientationDispatcher(this); |
| 5840 | return device_orientation_dispatcher_; |
[email protected] | 57ead35 | 2010-08-11 14:42:53 | [diff] [blame] | 5841 | } |
| 5842 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5843 | void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
| 5844 | double maximum_level) { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5845 | // For now, don't remember plugin zoom values. We don't want to mix them with |
| 5846 | // normal web content (i.e. a fixed layout plugin would usually want them |
| 5847 | // different). |
| 5848 | bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
| 5849 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5850 | int minimum_percent = static_cast<int>( |
| 5851 | WebView::zoomLevelToZoomFactor(minimum_level) * 100); |
| 5852 | int maximum_percent = static_cast<int>( |
| 5853 | WebView::zoomLevelToZoomFactor(maximum_level) * 100); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5854 | |
| 5855 | Send(new ViewHostMsg_UpdateZoomLimits( |
| 5856 | routing_id_, minimum_percent, maximum_percent, remember)); |
| 5857 | } |
| 5858 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5859 | void RenderViewImpl::zoomLevelChanged() { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5860 | bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
[email protected] | ba51d3b | 2011-08-24 19:53:08 | [diff] [blame] | 5861 | float zoom_level = webview()->zoomLevel(); |
[email protected] | 2b942c33 | 2012-04-25 16:26:26 | [diff] [blame] | 5862 | |
| 5863 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, ZoomLevelChanged()); |
| 5864 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5865 | // Tell the browser which url got zoomed so it can update the menu and the |
| 5866 | // saved values if necessary |
| 5867 | Send(new ViewHostMsg_DidZoomURL( |
[email protected] | ba51d3b | 2011-08-24 19:53:08 | [diff] [blame] | 5868 | routing_id_, zoom_level, remember, |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 5869 | GURL(webview()->mainFrame()->document().url()))); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5870 | } |
| 5871 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5872 | void RenderViewImpl::registerProtocolHandler(const WebString& scheme, |
| 5873 | const WebString& base_url, |
| 5874 | const WebString& url, |
| 5875 | const WebString& title) { |
[email protected] | 3a3b75a | 2012-06-01 08:38:36 | [diff] [blame] | 5876 | bool user_gesture = (webview()->focusedFrame() && |
| 5877 | webview()->focusedFrame()->isProcessingUserGesture()); |
[email protected] | a6d36cc | 2011-02-23 00:39:48 | [diff] [blame] | 5878 | GURL base(base_url); |
| 5879 | GURL absolute_url = base.Resolve(UTF16ToUTF8(url)); |
| 5880 | if (base.GetOrigin() != absolute_url.GetOrigin()) { |
| 5881 | return; |
| 5882 | } |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 5883 | Send(new ViewHostMsg_RegisterProtocolHandler(routing_id_, |
| 5884 | UTF16ToUTF8(scheme), |
| 5885 | absolute_url, |
[email protected] | 3a3b75a | 2012-06-01 08:38:36 | [diff] [blame] | 5886 | title, |
| 5887 | user_gesture)); |
[email protected] | a6d36cc | 2011-02-23 00:39:48 | [diff] [blame] | 5888 | } |
| 5889 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5890 | WebKit::WebPageVisibilityState RenderViewImpl::visibilityState() const { |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 5891 | WebKit::WebPageVisibilityState current_state = is_hidden() ? |
| 5892 | WebKit::WebPageVisibilityStateHidden : |
| 5893 | WebKit::WebPageVisibilityStateVisible; |
| 5894 | WebKit::WebPageVisibilityState override_state = current_state; |
| 5895 | if (content::GetContentClient()->renderer()-> |
| 5896 | ShouldOverridePageVisibilityState(this, |
| 5897 | &override_state)) |
| 5898 | return override_state; |
| 5899 | return current_state; |
[email protected] | 94dec93 | 2011-05-26 20:04:21 | [diff] [blame] | 5900 | } |
| 5901 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 5902 | WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 5903 | EnsureMediaStreamImpl(); |
| 5904 | return media_stream_impl_; |
| 5905 | } |
| 5906 | |
[email protected] | a0629af9 | 2012-08-08 00:39:37 | [diff] [blame] | 5907 | void RenderViewImpl::draggableRegionsChanged() { |
| 5908 | FOR_EACH_OBSERVER( |
| 5909 | RenderViewObserver, |
| 5910 | observers_, |
| 5911 | DraggableRegionsChanged(webview()->mainFrame())); |
| 5912 | } |
| 5913 | |
[email protected] | 20657a8 | 2012-08-21 20:23:03 | [diff] [blame] | 5914 | #if defined(OS_ANDROID) |
| 5915 | WebContentDetectionResult RenderViewImpl::detectContentAround( |
| 5916 | const WebHitTestResult& touch_hit) { |
| 5917 | DCHECK(!touch_hit.isNull()); |
| 5918 | DCHECK(!touch_hit.node().isNull()); |
| 5919 | DCHECK(touch_hit.node().isTextNode()); |
| 5920 | |
| 5921 | // Process the position with all the registered content detectors until |
| 5922 | // a match is found. Priority is provided by their relative order. |
| 5923 | for (ContentDetectorList::const_iterator it = content_detectors_.begin(); |
| 5924 | it != content_detectors_.end(); ++it) { |
| 5925 | ContentDetector::Result content = (*it)->FindTappedContent(touch_hit); |
| 5926 | if (content.valid) { |
| 5927 | return WebContentDetectionResult(content.content_boundaries, |
| 5928 | UTF8ToUTF16(content.text), content.intent_url); |
| 5929 | } |
| 5930 | } |
| 5931 | return WebContentDetectionResult(); |
| 5932 | } |
| 5933 | |
| 5934 | void RenderViewImpl::scheduleContentIntent(const WebURL& intent) { |
| 5935 | // Introduce a short delay so that the user can notice the content. |
| 5936 | MessageLoop::current()->PostDelayedTask( |
| 5937 | FROM_HERE, |
| 5938 | base::Bind(&RenderViewImpl::LaunchAndroidContentIntent, AsWeakPtr(), |
| 5939 | intent, expected_content_intent_id_), |
| 5940 | base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds)); |
| 5941 | } |
| 5942 | |
| 5943 | void RenderViewImpl::cancelScheduledContentIntents() { |
| 5944 | ++expected_content_intent_id_; |
| 5945 | } |
| 5946 | |
| 5947 | void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, |
| 5948 | size_t request_id) { |
| 5949 | if (request_id != expected_content_intent_id_) |
| 5950 | return; |
| 5951 | |
| 5952 | // Remove the content highlighting if any. |
| 5953 | scheduleComposite(); |
| 5954 | |
| 5955 | if (!intent.is_empty()) |
| 5956 | Send(new ViewHostMsg_StartContentIntent(routing_id_, intent)); |
| 5957 | } |
| 5958 | #endif |
| 5959 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5960 | void RenderViewImpl::OnAsyncFileOpened( |
| 5961 | base::PlatformFileError error_code, |
| 5962 | IPC::PlatformFileForTransit file_for_transit, |
| 5963 | int message_id) { |
[email protected] | 27a9ef3 | 2010-09-10 04:06:24 | [diff] [blame] | 5964 | pepper_delegate_.OnAsyncFileOpened( |
| 5965 | error_code, |
| 5966 | IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
| 5967 | message_id); |
| 5968 | } |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 5969 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5970 | void RenderViewImpl::OnPpapiBrokerChannelCreated( |
[email protected] | 2b657fd | 2011-04-18 16:00:47 | [diff] [blame] | 5971 | int request_id, |
[email protected] | d5430507 | 2011-06-22 20:58:43 | [diff] [blame] | 5972 | const IPC::ChannelHandle& handle) { |
[email protected] | 2b657fd | 2011-04-18 16:00:47 | [diff] [blame] | 5973 | pepper_delegate_.OnPpapiBrokerChannelCreated(request_id, |
[email protected] | 2b657fd | 2011-04-18 16:00:47 | [diff] [blame] | 5974 | handle); |
[email protected] | eb415bf0e | 2011-04-14 02:45:42 | [diff] [blame] | 5975 | } |
| 5976 | |
[email protected] | d8415ad9 | 2012-08-23 14:40:50 | [diff] [blame] | 5977 | void RenderViewImpl::OnPpapiBrokerPermissionResult( |
| 5978 | int request_id, |
| 5979 | bool result) { |
| 5980 | pepper_delegate_.OnPpapiBrokerPermissionResult(request_id, result); |
| 5981 | } |
| 5982 | |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 5983 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5984 | void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { |
[email protected] | 68dc3ba | 2010-12-06 21:43:15 | [diff] [blame] | 5985 | if (external_popup_menu_ == NULL) { |
| 5986 | // Crash reports from the field indicate that we can be notified with a |
| 5987 | // NULL external popup menu (we probably get notified twice). |
| 5988 | // If you hit this please file a bug against jcivelli and include the page |
| 5989 | // and steps to repro. |
| 5990 | NOTREACHED(); |
| 5991 | return; |
| 5992 | } |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 5993 | external_popup_menu_->DidSelectItem(selected_index); |
| 5994 | external_popup_menu_.reset(); |
| 5995 | } |
| 5996 | #endif |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 5997 | |
[email protected] | 24d2b17 | 2012-05-26 00:54:12 | [diff] [blame] | 5998 | #if defined(OS_ANDROID) |
| 5999 | void RenderViewImpl::OnSelectPopupMenuItems( |
| 6000 | bool canceled, |
| 6001 | const std::vector<int>& selected_indices) { |
| 6002 | // It is possible to receive more than one of these calls if the user presses |
| 6003 | // a select faster than it takes for the show-select-popup IPC message to make |
| 6004 | // it to the browser UI thread. Ignore the extra-messages. |
| 6005 | // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. |
| 6006 | if (!external_popup_menu_.get()) |
| 6007 | return; |
| 6008 | |
| 6009 | external_popup_menu_->DidSelectItems(canceled, selected_indices); |
| 6010 | external_popup_menu_.reset(); |
| 6011 | } |
| 6012 | #endif |
| 6013 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 6014 | void RenderViewImpl::OnContextMenuClosed( |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 6015 | const content::CustomContextMenuContext& custom_context) { |
[email protected] | b29aa74b | 2011-01-31 21:41:08 | [diff] [blame] | 6016 | if (custom_context.is_pepper_menu) |
| 6017 | pepper_delegate_.OnContextMenuClosed(custom_context); |
| 6018 | else |
| 6019 | context_menu_node_.reset(); |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 6020 | } |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 6021 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 6022 | void RenderViewImpl::OnEnableViewSourceMode() { |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 6023 | if (!webview()) |
| 6024 | return; |
| 6025 | WebFrame* main_frame = webview()->mainFrame(); |
| 6026 | if (!main_frame) |
| 6027 | return; |
| 6028 | main_frame->enableViewSourceMode(true); |
| 6029 | } |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 6030 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 6031 | bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
[email protected] | ab21f2c | 2011-11-19 00:50:08 | [diff] [blame] | 6032 | return !!RenderThreadImpl::current()->compositor_thread(); |
[email protected] | c3d4553 | 2011-10-07 19:20:40 | [diff] [blame] | 6033 | } |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 6034 | |
[email protected] | 64d0e19 | 2011-12-09 14:44:20 | [diff] [blame] | 6035 | void RenderViewImpl::OnJavaBridgeInit() { |
[email protected] | 7e9c5bb0 | 2012-05-14 13:58:31 | [diff] [blame] | 6036 | DCHECK(!java_bridge_dispatcher_); |
[email protected] | 464750f | 2011-10-24 23:16:18 | [diff] [blame] | 6037 | #if defined(ENABLE_JAVA_BRIDGE) |
[email protected] | 7e9c5bb0 | 2012-05-14 13:58:31 | [diff] [blame] | 6038 | java_bridge_dispatcher_ = new JavaBridgeDispatcher(this); |
[email protected] | 464750f | 2011-10-24 23:16:18 | [diff] [blame] | 6039 | #endif |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 6040 | } |
[email protected] | 0720b53 | 2012-08-28 19:23:37 | [diff] [blame] | 6041 | |
| 6042 | void RenderViewImpl::OnUpdatedFrameTree( |
| 6043 | int process_id, |
| 6044 | int route_id, |
| 6045 | const std::string& frame_tree) { |
| 6046 | base::DictionaryValue* frames = NULL; |
| 6047 | scoped_ptr<base::Value> tree(base::JSONReader::Read(frame_tree)); |
| 6048 | if (tree.get() && tree->IsType(base::Value::TYPE_DICTIONARY)) |
| 6049 | tree->GetAsDictionary(&frames); |
| 6050 | |
| 6051 | updating_frame_tree_ = true; |
| 6052 | active_frame_id_map_.clear(); |
| 6053 | |
| 6054 | target_process_id_ = process_id; |
| 6055 | target_routing_id_ = route_id; |
| 6056 | CreateFrameTree(webview()->mainFrame(), frames); |
| 6057 | |
| 6058 | updating_frame_tree_ = false; |
| 6059 | } |