[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] | 005bab0 | 2011-10-07 18:36:00 | [diff] [blame] | 16 | #include "base/json/json_value_serializer.h" |
[email protected] | b1cf337 | 2011-04-20 21:28:10 | [diff] [blame] | 17 | #include "base/json/json_writer.h" |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 18 | #include "base/lazy_instance.h" |
[email protected] | 835d7c8 | 2010-10-14 04:38:38 | [diff] [blame] | 19 | #include "base/metrics/histogram.h" |
[email protected] | 7bf795d9 | 2010-05-22 00:14:28 | [diff] [blame] | 20 | #include "base/path_service.h" |
[email protected] | 8380c09 | 2009-06-25 17:45:51 | [diff] [blame] | 21 | #include "base/process_util.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 22 | #include "base/string_piece.h" |
[email protected] | 318bf580 | 2011-08-08 17:12:41 | [diff] [blame] | 23 | #include "base/string_split.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 24 | #include "base/string_util.h" |
[email protected] | 5512613 | 2010-08-19 14:53:28 | [diff] [blame] | 25 | #include "base/sys_string_conversions.h" |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 26 | #include "base/time.h" |
[email protected] | be1ce6a7 | 2010-08-03 14:35:22 | [diff] [blame] | 27 | #include "base/utf_string_conversions.h" |
[email protected] | e93e04e | 2011-03-14 00:27:10 | [diff] [blame] | 28 | #include "content/common/appcache/appcache_dispatcher.h" |
[email protected] | 127dd58 | 2011-03-16 21:32:10 | [diff] [blame] | 29 | #include "content/common/clipboard_messages.h" |
[email protected] | 37666cf | 2011-03-13 21:51:42 | [diff] [blame] | 30 | #include "content/common/database_messages.h" |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 31 | #include "content/common/drag_messages.h" |
[email protected] | 7ef40ffe1 | 2011-03-08 05:05:28 | [diff] [blame] | 32 | #include "content/common/file_system/file_system_dispatcher.h" |
| 33 | #include "content/common/file_system/webfilesystem_callback_dispatcher.h" |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 34 | #include "content/common/intents_messages.h" |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 35 | #include "content/common/java_bridge_messages.h" |
[email protected] | 127dd58 | 2011-03-16 21:32:10 | [diff] [blame] | 36 | #include "content/common/pepper_messages.h" |
[email protected] | cebc3dc | 2011-04-18 17:15:00 | [diff] [blame] | 37 | #include "content/common/pepper_plugin_registry.h" |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 38 | #include "content/common/quota_dispatcher.h" |
[email protected] | 940895b | 2011-08-20 00:50:05 | [diff] [blame] | 39 | #include "content/common/request_extra_data.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 40 | #include "content/common/view_messages.h" |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 41 | #include "content/public/common/bindings_policy.h" |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 42 | #include "content/public/common/content_constants.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 43 | #include "content/public/common/content_switches.h" |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 44 | #include "content/public/common/file_chooser_params.h" |
[email protected] | a1d2916 | 2011-10-14 17:14:03 | [diff] [blame] | 45 | #include "content/public/common/url_constants.h" |
[email protected] | d344114c | 2011-10-01 01:24:34 | [diff] [blame] | 46 | #include "content/public/renderer/content_renderer_client.h" |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 47 | #include "content/public/renderer/document_state.h" |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 48 | #include "content/public/renderer/navigation_state.h" |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 49 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 50 | #include "content/public/renderer/render_view_visitor.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 51 | #include "content/renderer/device_orientation_dispatcher.h" |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 52 | #include "content/renderer/devtools_agent.h" |
[email protected] | 5572215 | 2011-03-22 01:33:53 | [diff] [blame] | 53 | #include "content/renderer/external_popup_menu.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 54 | #include "content/renderer/geolocation_dispatcher.h" |
[email protected] | a03a222 | 2011-05-25 21:26:40 | [diff] [blame] | 55 | #include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h" |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 56 | #include "content/renderer/idle_user_detector.h" |
[email protected] | 0d9989d | 2011-12-21 20:26:00 | [diff] [blame] | 57 | #include "content/renderer/web_intents_host.h" |
[email protected] | 0716190 | 2011-11-11 09:57:42 | [diff] [blame] | 58 | #include "content/renderer/java/java_bridge_dispatcher.h" |
[email protected] | 921f159 | 2011-03-18 00:41:02 | [diff] [blame] | 59 | #include "content/renderer/load_progress_tracker.h" |
[email protected] | 25803d15 | 2011-06-14 01:18:08 | [diff] [blame] | 60 | #include "content/renderer/media/audio_message_filter.h" |
[email protected] | ccc70d8e | 2011-03-16 20:40:37 | [diff] [blame] | 61 | #include "content/renderer/media/audio_renderer_impl.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 62 | #include "content/renderer/media/media_stream_dependency_factory.h" |
| 63 | #include "content/renderer/media/media_stream_dispatcher.h" |
[email protected] | ab2c473 | 2011-07-20 19:57:40 | [diff] [blame] | 64 | #include "content/renderer/media/media_stream_impl.h" |
[email protected] | 090f731 | 2011-08-05 23:26:40 | [diff] [blame] | 65 | #include "content/renderer/media/render_media_log.h" |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 66 | #include "content/renderer/mhtml_generator.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 67 | #include "content/renderer/notification_provider.h" |
[email protected] | ccc70d8e | 2011-03-16 20:40:37 | [diff] [blame] | 68 | #include "content/renderer/p2p/socket_dispatcher.h" |
[email protected] | 6f51608 | 2011-03-17 19:15:35 | [diff] [blame] | 69 | #include "content/renderer/plugin_channel_host.h" |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 70 | #include "content/renderer/render_audiosourceprovider.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 71 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 72 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 73 | #include "content/renderer/render_widget_fullscreen_pepper.h" |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 74 | #include "content/renderer/renderer_accessibility.h" |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 75 | #include "content/renderer/renderer_gpu_video_decoder_factories.h" |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 76 | #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
| 77 | #include "content/renderer/renderer_webstoragenamespace_impl.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 78 | #include "content/renderer/speech_input_dispatcher.h" |
[email protected] | 86a7d3c | 2011-09-12 16:45:32 | [diff] [blame] | 79 | #include "content/renderer/text_input_client_observer.h" |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 80 | #include "content/renderer/v8_value_converter_impl.h" |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 81 | #include "content/renderer/web_ui_bindings.h" |
[email protected] | 6f51608 | 2011-03-17 19:15:35 | [diff] [blame] | 82 | #include "content/renderer/webplugin_delegate_proxy.h" |
| 83 | #include "content/renderer/websharedworker_proxy.h" |
[email protected] | f8db813 | 2010-12-03 00:27:49 | [diff] [blame] | 84 | #include "media/base/filter_collection.h" |
[email protected] | ee68378a | 2010-08-10 01:05:41 | [diff] [blame] | 85 | #include "media/base/media_switches.h" |
[email protected] | f78d1dfc | 2011-01-15 07:09:27 | [diff] [blame] | 86 | #include "media/base/message_loop_factory_impl.h" |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 87 | #include "media/filters/gpu_video_decoder.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 88 | #include "net/base/escape.h" |
| 89 | #include "net/base/net_errors.h" |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 90 | #include "net/http/http_util.h" |
[email protected] | 9d9f1bb | 2011-02-23 22:10:57 | [diff] [blame] | 91 | #include "ppapi/c/private/ppb_flash_net_connector.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 92 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 93 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 94 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 95 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 96 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 97 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h" |
| 98 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" |
| 99 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" |
| 100 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" |
| 101 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 102 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 103 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 104 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 105 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" |
[email protected] | 592e20b | 2012-01-20 05:53:44 | [diff] [blame^] | 106 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h" |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 107 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.h" |
[email protected] | 69f110d6 | 2011-03-17 19:01:14 | [diff] [blame] | 108 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 109 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 110 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 111 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 112 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 113 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 114 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
| 115 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 116 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 117 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
| 118 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData.h" |
| 119 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
[email protected] | 20dc3cad | 2011-04-20 17:27:17 | [diff] [blame] | 120 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 121 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 122 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h" |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 123 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallbacks.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 124 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 125 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 126 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
| 127 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h" |
| 128 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.h" |
| 129 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h" |
| 130 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 131 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h" |
| 132 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandlerClient.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 133 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
| 134 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| 135 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
[email protected] | e6e90dc | 2011-12-03 00:01:37 | [diff] [blame] | 136 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 137 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 138 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h" |
| 139 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h" |
| 140 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h" |
| 141 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 142 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 143 | #include "ui/base/javascript_message_type.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 144 | #include "ui/gfx/native_widget_types.h" |
| 145 | #include "ui/gfx/point.h" |
| 146 | #include "ui/gfx/rect.h" |
[email protected] | c4a9e93 | 2011-03-05 04:05:55 | [diff] [blame] | 147 | #include "v8/include/v8.h" |
[email protected] | 80f584d9 | 2010-01-21 03:59:04 | [diff] [blame] | 148 | #include "webkit/appcache/web_application_cache_host_impl.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 149 | #include "webkit/forms/form_data.h" |
| 150 | #include "webkit/forms/form_field.h" |
| 151 | #include "webkit/forms/password_form_dom_manager.h" |
[email protected] | 25e18f8 | 2010-10-27 16:38:43 | [diff] [blame] | 152 | #include "webkit/glue/alt_error_page_resource_fetcher.h" |
[email protected] | 7a4de7a6 | 2010-08-17 18:38:24 | [diff] [blame] | 153 | #include "webkit/glue/context_menu.h" |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 154 | #include "webkit/glue/dom_operations.h" |
[email protected] | 95056b58 | 2010-02-18 01:29:24 | [diff] [blame] | 155 | #include "webkit/glue/glue_serialize.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 156 | #include "webkit/glue/webdropdata.h" |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 157 | #include "webkit/glue/webkit_constants.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 158 | #include "webkit/glue/webkit_glue.h" |
[email protected] | b00ba70 | 2011-08-17 01:41:03 | [diff] [blame] | 159 | #include "webkit/glue/weburlloader_impl.h" |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 160 | #include "webkit/media/webmediaplayer_impl.h" |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 161 | #include "webkit/plugins/npapi/plugin_list.h" |
| 162 | #include "webkit/plugins/npapi/webplugin_delegate.h" |
| 163 | #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 164 | #include "webkit/plugins/npapi/webplugin_impl.h" |
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 165 | #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 166 | |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 167 | #if defined(OS_WIN) |
| 168 | // TODO(port): these files are currently Windows only because they concern: |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 169 | // * theming |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 170 | #include "ui/gfx/native_theme_win.h" |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 171 | #elif defined(USE_X11) |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 172 | #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme.h" |
[email protected] | 42e5c86 | 2011-04-07 22:13:51 | [diff] [blame] | 173 | #include "ui/gfx/native_theme.h" |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 174 | #elif defined(OS_MACOSX) |
| 175 | #include "skia/ext/skia_utils_mac.h" |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 176 | #endif |
| 177 | |
[email protected] | 9892b47 | 2010-09-16 00:23:42 | [diff] [blame] | 178 | using WebKit::WebAccessibilityNotification; |
[email protected] | cc0445f | 2009-10-13 16:09:08 | [diff] [blame] | 179 | using WebKit::WebAccessibilityObject; |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 180 | using WebKit::WebApplicationCacheHost; |
| 181 | using WebKit::WebApplicationCacheHostClient; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 182 | using WebKit::WebCString; |
[email protected] | 1c83eb4 | 2009-09-11 21:08:41 | [diff] [blame] | 183 | using WebKit::WebColor; |
| 184 | using WebKit::WebColorName; |
[email protected] | 0dea3ea | 2009-03-31 23:30:59 | [diff] [blame] | 185 | using WebKit::WebConsoleMessage; |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 186 | using WebKit::WebContextMenuData; |
[email protected] | b921cfd2 | 2010-02-25 16:57:51 | [diff] [blame] | 187 | using WebKit::WebCookieJar; |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 188 | using WebKit::WebData; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 189 | using WebKit::WebDataSource; |
[email protected] | 5bc8fe9 | 2010-03-11 18:19:00 | [diff] [blame] | 190 | using WebKit::WebDocument; |
[email protected] | e80c73b | 2009-04-07 23:24:58 | [diff] [blame] | 191 | using WebKit::WebDragData; |
[email protected] | 1d9f413 | 2009-09-08 17:29:25 | [diff] [blame] | 192 | using WebKit::WebDragOperation; |
| 193 | using WebKit::WebDragOperationsMask; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 194 | using WebKit::WebEditingAction; |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 195 | using WebKit::WebElement; |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 196 | using WebKit::WebExternalPopupMenu; |
| 197 | using WebKit::WebExternalPopupMenuClient; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 198 | using WebKit::WebFileChooserCompletion; |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 199 | using WebKit::WebFileSystem; |
| 200 | using WebKit::WebFileSystemCallbacks; |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 201 | using WebKit::WebFindOptions; |
[email protected] | b143821 | 2010-04-03 00:30:59 | [diff] [blame] | 202 | using WebKit::WebFormControlElement; |
[email protected] | 979c28b | 2009-11-07 01:30:48 | [diff] [blame] | 203 | using WebKit::WebFormElement; |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 204 | using WebKit::WebFrame; |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 205 | using WebKit::WebHistoryItem; |
[email protected] | 42054a25 | 2011-05-17 18:02:13 | [diff] [blame] | 206 | using WebKit::WebIconURL; |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 207 | using WebKit::WebImage; |
[email protected] | e6efd02 | 2010-03-31 09:34:50 | [diff] [blame] | 208 | using WebKit::WebInputElement; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 209 | using WebKit::WebMediaPlayer; |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 210 | using WebKit::WebMediaPlayerAction; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 211 | using WebKit::WebMediaPlayerClient; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 212 | using WebKit::WebNavigationPolicy; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 213 | using WebKit::WebNavigationType; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 214 | using WebKit::WebNode; |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 215 | using WebKit::WebPageSerializer; |
| 216 | using WebKit::WebPageSerializerClient; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 217 | using WebKit::WebPlugin; |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 218 | using WebKit::WebPluginAction; |
[email protected] | 00152e9 | 2010-07-19 11:47:40 | [diff] [blame] | 219 | using WebKit::WebPluginContainer; |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 220 | using WebKit::WebPluginDocument; |
[email protected] | aad51d1c | 2010-08-05 08:38:09 | [diff] [blame] | 221 | using WebKit::WebPluginParams; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 222 | using WebKit::WebPoint; |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 223 | using WebKit::WebPopupMenuInfo; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 224 | using WebKit::WebRange; |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 225 | using WebKit::WebRect; |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 226 | using WebKit::WebReferrerPolicy; |
[email protected] | 4f99913 | 2009-03-31 18:08:40 | [diff] [blame] | 227 | using WebKit::WebScriptSource; |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 228 | using WebKit::WebSearchableFormData; |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 229 | using WebKit::WebSecurityOrigin; |
[email protected] | 20dc3cad | 2011-04-20 17:27:17 | [diff] [blame] | 230 | using WebKit::WebSecurityPolicy; |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 231 | using WebKit::WebSettings; |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 232 | using WebKit::WebSharedWorker; |
[email protected] | 8649fb3 | 2009-06-26 17:51:02 | [diff] [blame] | 233 | using WebKit::WebSize; |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 234 | using WebKit::WebStorageNamespace; |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 235 | using WebKit::WebStorageQuotaCallbacks; |
| 236 | using WebKit::WebStorageQuotaError; |
| 237 | using WebKit::WebStorageQuotaType; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 238 | using WebKit::WebString; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 239 | using WebKit::WebTextAffinity; |
[email protected] | de570ef | 2009-07-29 18:27:52 | [diff] [blame] | 240 | using WebKit::WebTextDirection; |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 241 | using WebKit::WebTouchEvent; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 242 | using WebKit::WebURL; |
| 243 | using WebKit::WebURLError; |
| 244 | using WebKit::WebURLRequest; |
| 245 | using WebKit::WebURLResponse; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 246 | using WebKit::WebVector; |
[email protected] | 50ae00ef | 2009-10-19 05:11:03 | [diff] [blame] | 247 | using WebKit::WebView; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 248 | using WebKit::WebWidget; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 249 | using WebKit::WebWindowFeatures; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 250 | using appcache::WebApplicationCacheHostImpl; |
| 251 | using base::Time; |
| 252 | using base::TimeDelta; |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 253 | using content::DocumentState; |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 254 | using content::NavigationState; |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 255 | using content::RenderThread; |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 256 | using content::RenderViewObserver; |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 257 | using content::RenderViewVisitor; |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 258 | using content::Referrer; |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 259 | using content::V8ValueConverter; |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 260 | using webkit::forms::FormField; |
| 261 | using webkit::forms::PasswordForm; |
| 262 | using webkit::forms::PasswordFormDomManager; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 263 | using webkit_glue::AltErrorPageResourceFetcher; |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 264 | using webkit_glue::ResourceFetcher; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 265 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 266 | //----------------------------------------------------------------------------- |
| 267 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 268 | typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; |
[email protected] | 6de0fd1d | 2011-11-15 13:31:49 | [diff] [blame] | 269 | static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 270 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 271 | // Time, in seconds, we delay before sending content state changes (such as form |
| 272 | // state and scroll position) to the browser. We delay sending changes to avoid |
| 273 | // spamming the browser. |
| 274 | // To avoid having tab/session restore require sending a message to get the |
| 275 | // current content state during tab closing we use a shorter timeout for the |
| 276 | // foreground renderer. This means there is a small window of time from which |
| 277 | // content state is modified and not sent to session restore, but this is |
| 278 | // better than having to wake up all renderers during shutdown. |
| 279 | static const int kDelaySecondsForContentStateSyncHidden = 5; |
| 280 | static const int kDelaySecondsForContentStateSync = 1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 281 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 282 | static const size_t kExtraCharsBeforeAndAfterSelection = 100; |
| 283 | |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 284 | // The maximum number of popups that can be spawned from one page. |
| 285 | static const int kMaximumNumberOfUnacknowledgedPopups = 25; |
| 286 | |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 287 | static const float kScalingIncrement = 0.1f; |
| 288 | |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 289 | static const float kScalingIncrementForGesture = 0.01f; |
| 290 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 291 | static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 292 | WebVector<WebURL> urls; |
| 293 | ds->redirectChain(urls); |
| 294 | result->reserve(urls.size()); |
| 295 | for (size_t i = 0; i < urls.size(); ++i) |
| 296 | result->push_back(urls[i]); |
| 297 | } |
| 298 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 299 | // If |data_source| is non-null and has a DocumentState associated with it, |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 300 | // the AltErrorPageResourceFetcher is reset. |
| 301 | static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
| 302 | if (data_source) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 303 | DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 304 | if (document_state) |
| 305 | document_state->set_alt_error_page_fetcher(NULL); |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 306 | } |
| 307 | } |
| 308 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 309 | static bool IsReload(const ViewMsg_Navigate_Params& params) { |
| 310 | return |
| 311 | params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
| 312 | params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
| 313 | } |
| 314 | |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 315 | static WebReferrerPolicy getReferrerPolicyFromRequest( |
| 316 | const WebURLRequest& request) { |
| 317 | return request.extraData() ? |
| 318 | static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : |
| 319 | WebKit::WebReferrerPolicyDefault; |
| 320 | } |
| 321 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 322 | /////////////////////////////////////////////////////////////////////////////// |
| 323 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 324 | struct RenderViewImpl::PendingFileChooser { |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 325 | PendingFileChooser(const content::FileChooserParams& p, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 326 | WebFileChooserCompletion* c) |
| 327 | : params(p), |
| 328 | completion(c) { |
| 329 | } |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 330 | content::FileChooserParams params; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 331 | WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
| 332 | }; |
| 333 | |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 334 | RenderViewImpl::RenderViewImpl( |
| 335 | gfx::NativeViewId parent_hwnd, |
| 336 | int32 opener_id, |
| 337 | const content::RendererPreferences& renderer_prefs, |
| 338 | const WebPreferences& webkit_prefs, |
| 339 | SharedRenderViewCounter* counter, |
| 340 | int32 routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 341 | int32 surface_id, |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 342 | int64 session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 343 | const string16& frame_name, |
| 344 | int32 next_page_id) |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 345 | : RenderWidget(WebKit::WebPopupTypeNone), |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 346 | webkit_preferences_(webkit_prefs), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 347 | send_content_state_immediately_(false), |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 348 | enabled_bindings_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 349 | send_preferred_size_changes_(false), |
[email protected] | 81a3441 | 2009-01-05 19:17:24 | [diff] [blame] | 350 | is_loading_(false), |
[email protected] | e75cb49e | 2009-01-05 23:13:21 | [diff] [blame] | 351 | navigation_gesture_(NavigationGestureUnknown), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 352 | opened_by_user_gesture_(true), |
| 353 | opener_suppressed_(false), |
[email protected] | 81a3441 | 2009-01-05 19:17:24 | [diff] [blame] | 354 | page_id_(-1), |
| 355 | last_page_id_sent_to_browser_(-1), |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 356 | next_page_id_(next_page_id), |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 357 | history_list_offset_(-1), |
| 358 | history_list_length_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 359 | target_url_status_(TARGET_NONE), |
[email protected] | bbef1d3 | 2011-10-25 14:36:55 | [diff] [blame] | 360 | selection_text_offset_(0), |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 361 | cached_is_main_frame_pinned_to_left_(false), |
| 362 | cached_is_main_frame_pinned_to_right_(false), |
| 363 | cached_has_main_frame_horizontal_scrollbar_(false), |
| 364 | cached_has_main_frame_vertical_scrollbar_(false), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 365 | ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 366 | geolocation_dispatcher_(NULL), |
| 367 | speech_input_dispatcher_(NULL), |
| 368 | device_orientation_dispatcher_(NULL), |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 369 | media_stream_dispatcher_(NULL), |
[email protected] | cae8c849 | 2011-03-03 11:12:18 | [diff] [blame] | 370 | p2p_socket_dispatcher_(NULL), |
[email protected] | c5c1d6d | 2011-07-28 18:42:41 | [diff] [blame] | 371 | devtools_agent_(NULL), |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 372 | renderer_accessibility_(NULL), |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 373 | session_storage_namespace_id_(session_storage_namespace_id), |
[email protected] | ef5e98e | 2011-12-06 09:49:18 | [diff] [blame] | 374 | handling_select_range_(false), |
| 375 | #if defined(OS_WIN) |
| 376 | focused_plugin_id_(-1), |
| 377 | #endif |
| 378 | ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 379 | routing_id_ = routing_id; |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 380 | surface_id_ = surface_id; |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 381 | if (opener_id != MSG_ROUTING_NONE) |
| 382 | opener_id_ = opener_id; |
| 383 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 384 | // Ensure we start with a valid next_page_id_ from the browser. |
| 385 | DCHECK_GE(next_page_id_, 0); |
| 386 | |
[email protected] | 21b3a6ae | 2011-11-30 00:45:29 | [diff] [blame] | 387 | #if defined(ENABLE_NOTIFICATIONS) |
| 388 | notification_provider_ = new NotificationProvider(this); |
| 389 | #else |
| 390 | notification_provider_ = NULL; |
| 391 | #endif |
| 392 | |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 393 | webwidget_ = WebView::create(this); |
| 394 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 395 | if (counter) { |
| 396 | shared_popup_counter_ = counter; |
| 397 | shared_popup_counter_->data++; |
| 398 | decrement_shared_popup_at_destruction_ = true; |
| 399 | } else { |
| 400 | shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 401 | decrement_shared_popup_at_destruction_ = false; |
| 402 | } |
| 403 | |
[email protected] | 0d9989d | 2011-12-21 20:26:00 | [diff] [blame] | 404 | intents_host_ = new WebIntentsHost(this); |
[email protected] | 7cce323 | 2011-10-28 10:41:57 | [diff] [blame] | 405 | |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 406 | RenderThread::Get()->AddRoute(routing_id_, this); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 407 | // Take a reference on behalf of the RenderThread. This will be balanced |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 408 | // when we receive ViewMsg_ClosePage. |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 409 | AddRef(); |
| 410 | |
| 411 | // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 412 | // completing initialization. Otherwise, we can finish it now. |
| 413 | if (opener_id == MSG_ROUTING_NONE) { |
| 414 | did_show_ = true; |
[email protected] | 2d7c855 | 2011-06-27 19:21:55 | [diff] [blame] | 415 | CompleteInit(parent_hwnd); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 416 | } |
| 417 | |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 418 | g_view_map.Get().insert(std::make_pair(webview(), this)); |
| 419 | webkit_preferences_.Apply(webview()); |
| 420 | webview()->initializeMainFrame(this); |
[email protected] | 2024c92 | 2011-09-02 23:34:35 | [diff] [blame] | 421 | if (!frame_name.empty()) |
| 422 | webview()->mainFrame()->setName(frame_name); |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 423 | webview()->settings()->setMinimumTimerInterval( |
| 424 | is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
| 425 | webkit_glue::kForegroundTabTimerInterval); |
| 426 | |
| 427 | OnSetRendererPrefs(renderer_prefs); |
| 428 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 429 | host_window_ = parent_hwnd; |
| 430 | |
[email protected] | a026daa | 2011-04-20 15:49:51 | [diff] [blame] | 431 | #if defined(ENABLE_P2P_APIS) |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 432 | if (!p2p_socket_dispatcher_) |
| 433 | p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
[email protected] | a026daa | 2011-04-20 15:49:51 | [diff] [blame] | 434 | #endif |
[email protected] | cae8c849 | 2011-03-03 11:12:18 | [diff] [blame] | 435 | |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 436 | new MHTMLGenerator(this); |
[email protected] | 86a7d3c | 2011-09-12 16:45:32 | [diff] [blame] | 437 | #if defined(OS_MACOSX) |
| 438 | new TextInputClientObserver(this); |
| 439 | #endif // defined(OS_MACOSX) |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 440 | |
[email protected] | c5c1d6d | 2011-07-28 18:42:41 | [diff] [blame] | 441 | devtools_agent_ = new DevToolsAgent(this); |
[email protected] | 8262245 | 2011-07-22 09:57:20 | [diff] [blame] | 442 | |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 443 | renderer_accessibility_ = new RendererAccessibility(this); |
| 444 | |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 445 | new IdleUserDetector(this); |
| 446 | |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 447 | content::GetContentClient()->renderer()->RenderViewCreated(this); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 448 | } |
| 449 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 450 | RenderViewImpl::~RenderViewImpl() { |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 451 | history_page_ids_.clear(); |
| 452 | |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 453 | if (decrement_shared_popup_at_destruction_) |
| 454 | shared_popup_counter_->data--; |
| 455 | |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 456 | // If file chooser is still waiting for answer, dispatch empty answer. |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 457 | while (!file_chooser_completions_.empty()) { |
| 458 | if (file_chooser_completions_.front()->completion) { |
| 459 | file_chooser_completions_.front()->completion->didChooseFile( |
| 460 | WebVector<WebString>()); |
| 461 | } |
| 462 | file_chooser_completions_.pop_front(); |
| 463 | } |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 464 | |
[email protected] | 83dde54 | 2009-09-11 20:59:55 | [diff] [blame] | 465 | #if defined(OS_MACOSX) |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 466 | // Destroy all fake plugin window handles on the browser side. |
| 467 | while (!fake_plugin_window_handles_.empty()) { |
| 468 | // Make sure no NULL plugin window handles were inserted into this list. |
| 469 | DCHECK(*fake_plugin_window_handles_.begin()); |
| 470 | // DestroyFakePluginWindowHandle modifies fake_plugin_window_handles_. |
| 471 | DestroyFakePluginWindowHandle(*fake_plugin_window_handles_.begin()); |
| 472 | } |
[email protected] | 83dde54 | 2009-09-11 20:59:55 | [diff] [blame] | 473 | #endif |
[email protected] | 9832489 | 2009-09-09 21:16:05 | [diff] [blame] | 474 | |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 475 | #ifndef NDEBUG |
| 476 | // Make sure we are no longer referenced by the ViewMap. |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 477 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 478 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 479 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
| 480 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 481 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 482 | // MediaStreamImpl holds weak references to RenderViewObserver objects, |
| 483 | // ensure it's deleted before the observers. |
| 484 | media_stream_impl_ = NULL; |
| 485 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 486 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 487 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 491 | RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 492 | ViewMap* views = g_view_map.Pointer(); |
| 493 | ViewMap::iterator it = views->find(webview); |
| 494 | return it == views->end() ? NULL : it->second; |
| 495 | } |
| 496 | |
| 497 | /*static*/ |
| 498 | content::RenderView* |
| 499 | content::RenderView::FromWebView(WebKit::WebView* webview) { |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 500 | return RenderViewImpl::FromWebView(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 501 | } |
| 502 | |
| 503 | /*static*/ |
| 504 | void content::RenderView::ForEach(content::RenderViewVisitor* visitor) { |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 505 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 506 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 507 | if (!visitor->Visit(it->second)) |
| 508 | return; |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 513 | RenderViewImpl* RenderViewImpl::Create( |
[email protected] | 18bcc3c | 2009-01-27 21:39:15 | [diff] [blame] | 514 | gfx::NativeViewId parent_hwnd, |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 515 | int32 opener_id, |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 516 | const content::RendererPreferences& renderer_prefs, |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 517 | const WebPreferences& webkit_prefs, |
| 518 | SharedRenderViewCounter* counter, |
[email protected] | 4e6419c | 2010-01-15 04:50:34 | [diff] [blame] | 519 | int32 routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 520 | int32 surface_id, |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 521 | int64 session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 522 | const string16& frame_name, |
| 523 | int32 next_page_id) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 524 | DCHECK(routing_id != MSG_ROUTING_NONE); |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 525 | return new RenderViewImpl( |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 526 | parent_hwnd, |
| 527 | opener_id, |
| 528 | renderer_prefs, |
| 529 | webkit_prefs, |
| 530 | counter, |
| 531 | routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 532 | surface_id, |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 533 | session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 534 | frame_name, |
| 535 | next_page_id); // adds reference |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 536 | } |
| 537 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 538 | WebKit::WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler( |
| 539 | WebKit::WebPeerConnectionHandlerClient* client) { |
| 540 | const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 541 | if (!cmd_line->HasSwitch(switches::kEnableMediaStream)) |
| 542 | return NULL; |
| 543 | EnsureMediaStreamImpl(); |
| 544 | return media_stream_impl_->CreatePeerConnectionHandler(client); |
| 545 | } |
| 546 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 547 | void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 548 | observers_.AddObserver(observer); |
| 549 | } |
| 550 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 551 | void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 552 | observer->RenderViewGone(); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 553 | observers_.RemoveObserver(observer); |
| 554 | } |
| 555 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 556 | WebKit::WebView* RenderViewImpl::webview() const { |
[email protected] | 4d51d5bf | 2010-07-26 18:48:26 | [diff] [blame] | 557 | return static_cast<WebKit::WebView*>(webwidget()); |
| 558 | } |
| 559 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 560 | void RenderViewImpl::SetReportLoadProgressEnabled(bool enabled) { |
[email protected] | 1a3c3cb | 2010-12-16 21:03:40 | [diff] [blame] | 561 | if (!enabled) { |
| 562 | load_progress_tracker_.reset(NULL); |
| 563 | return; |
| 564 | } |
| 565 | if (load_progress_tracker_ == NULL) |
| 566 | load_progress_tracker_.reset(new LoadProgressTracker(this)); |
| 567 | } |
| 568 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 569 | void RenderViewImpl::PluginCrashed(const FilePath& plugin_path) { |
[email protected] | a3a8fb6d | 2009-10-22 20:12:51 | [diff] [blame] | 570 | Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 571 | } |
| 572 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 573 | void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 574 | plugin_delegates_.insert(delegate); |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 575 | // If the renderer is visible, set initial visibility and focus state. |
| 576 | if (!is_hidden()) { |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 577 | #if defined(OS_MACOSX) |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 578 | delegate->SetContainerVisibility(true); |
| 579 | if (webview() && webview()->isActive()) |
| 580 | delegate->SetWindowFocus(true); |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 581 | #endif |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 582 | } |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 583 | // Plugins start assuming the content has focus (so that they work in |
| 584 | // environments where RenderView isn't hosting them), so we always have to |
| 585 | // set the initial state. See webplugin_delegate_impl.h for details. |
| 586 | delegate->SetContentAreaFocus(has_focus()); |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 587 | } |
| 588 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 589 | void RenderViewImpl::UnregisterPluginDelegate( |
| 590 | WebPluginDelegateProxy* delegate) { |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 591 | plugin_delegates_.erase(delegate); |
| 592 | } |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 593 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 594 | bool RenderViewImpl::GetPluginInfo(const GURL& url, |
| 595 | const GURL& page_url, |
| 596 | const std::string& mime_type, |
| 597 | webkit::WebPluginInfo* plugin_info, |
| 598 | std::string* actual_mime_type) { |
[email protected] | 4a7d639 | 2011-09-19 20:55:08 | [diff] [blame] | 599 | bool found = false; |
| 600 | Send(new ViewHostMsg_GetPluginInfo( |
| 601 | routing_id_, url, page_url, mime_type, &found, plugin_info, |
| 602 | actual_mime_type)); |
| 603 | return found; |
| 604 | } |
| 605 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 606 | bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 607 | WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
[email protected] | a9f607e | 2009-10-23 19:59:27 | [diff] [blame] | 608 | if (main_frame) |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 609 | content::GetContentClient()->SetActiveURL(main_frame->document().url()); |
[email protected] | f8b6b6f | 2009-03-10 16:48:26 | [diff] [blame] | 610 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 611 | ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| 612 | RenderViewObserver* observer; |
| 613 | while ((observer = it.GetNext()) != NULL) |
| 614 | if (observer->OnMessageReceived(message)) |
| 615 | return true; |
[email protected] | b2abac7 | 2009-02-26 12:39:28 | [diff] [blame] | 616 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 617 | bool handled = true; |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 618 | bool msg_is_ok = true; |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 619 | IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 620 | IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
| 621 | IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
[email protected] | 1dda402 | 2010-01-28 18:24:56 | [diff] [blame] | 622 | IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 623 | IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) |
| 624 | IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) |
| 625 | IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
| 626 | IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 627 | #if defined(OS_MACOSX) |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 628 | IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 629 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 630 | IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) |
[email protected] | 44bf700 | 2011-10-16 02:46:15 | [diff] [blame] | 631 | IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 632 | IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) |
| 633 | IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
| 634 | IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 635 | IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 636 | IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
[email protected] | 4b59ae60 | 2009-06-23 20:58:15 | [diff] [blame] | 637 | IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 638 | IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 639 | IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| 640 | IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) |
[email protected] | 630e26b | 2008-10-14 22:55:17 | [diff] [blame] | 641 | IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
[email protected] | d0b8d09 | 2010-10-25 04:05:17 | [diff] [blame] | 642 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 643 | IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 644 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 645 | OnSetZoomLevelForLoadingURL) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 646 | IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
[email protected] | a697f4c | 2009-09-14 22:30:18 | [diff] [blame] | 647 | IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 648 | OnResetPageEncodingToDefault) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 649 | IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) |
[email protected] | 1810e13 | 2009-03-24 23:35:48 | [diff] [blame] | 650 | IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 651 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 652 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 653 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 654 | IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
| 655 | IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) |
| 656 | IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
| 657 | OnDragSourceSystemDragEnded) |
[email protected] | 18cb257 | 2008-08-21 20:34:45 | [diff] [blame] | 658 | IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
[email protected] | d098079 | 2011-02-13 19:41:40 | [diff] [blame] | 659 | IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 660 | IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
[email protected] | 333ec8d0 | 2011-09-16 18:59:19 | [diff] [blame] | 661 | IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, |
| 662 | OnScrollFocusedEditableNodeIntoRect) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 663 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 664 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
| 665 | IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 666 | IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 667 | OnEnumerateDirectoryResponse) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 668 | IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
[email protected] | 9b18a84f | 2010-06-10 15:54:04 | [diff] [blame] | 669 | IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 670 | IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 671 | IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 672 | IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 673 | IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
| 674 | OnDisassociateFromPopupCount) |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 675 | IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 676 | IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode) |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 677 | IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) |
[email protected] | ab32b16c | 2009-10-16 14:57:25 | [diff] [blame] | 678 | IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 679 | OnEnablePreferredSizeChangedMode) |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 680 | IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 681 | IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 682 | OnDisableScrollbarsForSmallWindows) |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 683 | IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 684 | IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 685 | IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 686 | IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 687 | #if defined(OS_MACOSX) |
| 688 | IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 689 | IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 690 | IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
| 691 | OnPluginImeCompositionCompleted) |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 692 | #endif |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 693 | IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 694 | OnSetEditCommandsForNextKeyEvent) |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 695 | IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
| 696 | OnCustomContextMenuAction) |
[email protected] | 27a9ef3 | 2010-09-10 04:06:24 | [diff] [blame] | 697 | IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
[email protected] | eb415bf0e | 2011-04-14 02:45:42 | [diff] [blame] | 698 | IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, |
| 699 | OnPpapiBrokerChannelCreated) |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 700 | IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
| 701 | OnGetAllSavableResourceLinksForCurrentPage) |
| 702 | IPC_MESSAGE_HANDLER( |
| 703 | ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
| 704 | OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 705 | #if defined(OS_MACOSX) |
| 706 | IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
| 707 | #endif |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 708 | IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
[email protected] | f055793 | 2011-01-25 20:20:51 | [diff] [blame] | 709 | // TODO(viettrungluu): Move to a separate message filter. |
| 710 | #if defined(ENABLE_FLAPPER_HACKS) |
| 711 | IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
| 712 | #endif |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 713 | #if defined(OS_MACOSX) |
| 714 | IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 715 | #endif |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 716 | IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 717 | OnSetHistoryLengthAndPrune) |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 718 | IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 719 | IPC_MESSAGE_HANDLER(ViewMsg_LockMouse_ACK, OnLockMouseACK) |
| 720 | IPC_MESSAGE_HANDLER(ViewMsg_MouseLockLost, OnMouseLockLost) |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 721 | IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 722 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 723 | // Have the super handle all other messages. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 724 | IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 725 | IPC_END_MESSAGE_MAP() |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 726 | |
| 727 | if (!msg_is_ok) { |
| 728 | // The message had a handler, but its deserialization failed. |
| 729 | // Kill the renderer to avoid potential spoofing attacks. |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 730 | CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 731 | } |
| 732 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 733 | return handled; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 734 | } |
| 735 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 736 | void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 737 | if (!webview()) |
| 738 | return; |
| 739 | |
[email protected] | 440a0e5 | 2011-09-13 17:38:58 | [diff] [blame] | 740 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
| 741 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 742 | bool is_reload = IsReload(params); |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 743 | |
| 744 | // If this is a stale back/forward (due to a recent navigation the browser |
| 745 | // didn't know about), ignore it. |
| 746 | if (IsBackForwardToStaleEntry(params, is_reload)) |
| 747 | return; |
| 748 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 749 | // Swap this renderer back in if necessary. |
| 750 | if (is_swapped_out_) |
| 751 | SetSwappedOut(false); |
| 752 | |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 753 | history_list_offset_ = params.current_history_list_offset; |
| 754 | history_list_length_ = params.current_history_list_length; |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 755 | if (history_list_length_ >= 0) |
| 756 | history_page_ids_.resize(history_list_length_, -1); |
| 757 | if (params.pending_history_list_offset >= 0 && |
| 758 | params.pending_history_list_offset < history_list_length_) |
| 759 | history_page_ids_[params.pending_history_list_offset] = params.page_id; |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 760 | |
[email protected] | 38b59290 | 2011-04-16 02:08:42 | [diff] [blame] | 761 | content::GetContentClient()->SetActiveURL(params.url); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 762 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 763 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 764 | if (is_reload && main_frame->currentHistoryItem().isNull()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 765 | // We cannot reload if we do not have any history state. This happens, for |
| 766 | // example, when recovering from a crash. Our workaround here is a bit of |
| 767 | // a hack since it means that reload after a crashed tab does not cause an |
| 768 | // end-to-end cache validation. |
| 769 | is_reload = false; |
| 770 | } |
| 771 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 772 | pending_navigation_params_.reset(new ViewMsg_Navigate_Params); |
| 773 | *pending_navigation_params_.get() = params; |
[email protected] | 48a5c77 | 2011-04-18 23:50:50 | [diff] [blame] | 774 | |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 775 | // If we are reloading, then WebKit will use the history state of the current |
| 776 | // page, so we should just ignore any given history state. Otherwise, if we |
| 777 | // have history state, then we need to navigate to it, which corresponds to a |
| 778 | // back/forward navigation event. |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 779 | if (is_reload) { |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 780 | bool ignore_cache = (params.navigation_type == |
[email protected] | 2c556966 | 2011-03-22 20:45:02 | [diff] [blame] | 781 | ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 782 | main_frame->reload(ignore_cache); |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 783 | } else if (!params.state.empty()) { |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 784 | // 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] | 785 | DCHECK_NE(params.page_id, -1); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 786 | main_frame->loadHistoryItem( |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 787 | webkit_glue::HistoryItemFromString(params.state)); |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 788 | } else { |
| 789 | // Navigate to the given URL. |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 790 | WebURLRequest request(params.url); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 791 | |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 792 | // A session history navigation should have been accompanied by state. |
[email protected] | cbc0cb7 | 2011-12-06 18:58:23 | [diff] [blame] | 793 | CHECK_EQ(params.page_id, -1); |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 794 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 795 | if (main_frame->isViewSourceModeEnabled()) |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 796 | request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 797 | |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 798 | if (params.referrer.url.is_valid()) { |
| 799 | WebString referrer = WebSecurityPolicy::generateReferrerHeader( |
| 800 | params.referrer.policy, |
| 801 | params.url, |
| 802 | WebString::fromUTF8(params.referrer.url.spec())); |
| 803 | if (!referrer.isEmpty()) |
| 804 | request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 805 | } |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 806 | |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 807 | if (!params.extra_headers.empty()) { |
| 808 | for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
| 809 | params.extra_headers.end(), "\n"); |
| 810 | i.GetNext(); ) { |
| 811 | request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
| 812 | WebString::fromUTF8(i.values())); |
| 813 | } |
| 814 | } |
| 815 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 816 | main_frame->loadRequest(request); |
[email protected] | c058805 | 2008-10-27 23:01:50 | [diff] [blame] | 817 | } |
| 818 | |
[email protected] | 77f17a8 | 2009-05-21 04:42:54 | [diff] [blame] | 819 | // In case LoadRequest failed before DidCreateDataSource was called. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 820 | pending_navigation_params_.reset(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 821 | } |
| 822 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 823 | bool RenderViewImpl::IsBackForwardToStaleEntry( |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 824 | const ViewMsg_Navigate_Params& params, |
| 825 | bool is_reload) { |
| 826 | // Make sure this isn't a back/forward to an entry we have already cropped |
| 827 | // or replaced from our history, before the browser knew about it. If so, |
| 828 | // a new navigation has committed in the mean time, and we can ignore this. |
| 829 | bool is_back_forward = !is_reload && !params.state.empty(); |
| 830 | |
| 831 | // Note: if the history_list_length_ is 0 for a back/forward, we must be |
| 832 | // restoring from a previous session. We'll update our state in OnNavigate. |
| 833 | if (!is_back_forward || history_list_length_ <= 0) |
| 834 | return false; |
| 835 | |
| 836 | DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); |
| 837 | |
| 838 | // Check for whether the forward history has been cropped due to a recent |
| 839 | // navigation the browser didn't know about. |
| 840 | if (params.pending_history_list_offset >= history_list_length_) |
| 841 | return true; |
| 842 | |
| 843 | // Check for whether this entry has been replaced with a new one. |
| 844 | int expected_page_id = |
| 845 | history_page_ids_[params.pending_history_list_offset]; |
[email protected] | 9978b8f0 | 2011-08-13 16:17:44 | [diff] [blame] | 846 | if (expected_page_id > 0 && params.page_id != expected_page_id) { |
| 847 | if (params.page_id < expected_page_id) |
| 848 | return true; |
| 849 | |
| 850 | // Otherwise we've removed an earlier entry and should have shifted all |
| 851 | // entries left. For now, it's ok to lazily update the list. |
| 852 | // TODO(creis): Notify all live renderers when we remove entries from |
| 853 | // the front of the list, so that we don't hit this case. |
| 854 | history_page_ids_[params.pending_history_list_offset] = params.page_id; |
| 855 | } |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 856 | |
| 857 | return false; |
| 858 | } |
| 859 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 860 | // Stop loading the current page |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 861 | void RenderViewImpl::OnStop() { |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 862 | if (webview()) { |
| 863 | WebFrame* main_frame = webview()->mainFrame(); |
| 864 | // Stop the alt error page fetcher. If we let it continue it may complete |
| 865 | // and cause RenderViewHostManager to swap to this RenderView, even though |
| 866 | // it may no longer be active. |
| 867 | StopAltErrorPageFetcher(main_frame->provisionalDataSource()); |
| 868 | StopAltErrorPageFetcher(main_frame->dataSource()); |
| 869 | main_frame->stopLoading(); |
| 870 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 871 | } |
| 872 | |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 873 | // Reload current focused frame. |
| 874 | // 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] | 875 | void RenderViewImpl::OnReloadFrame() { |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 876 | if (webview() && webview()->focusedFrame()) { |
| 877 | // We always obey the cache (ignore_cache=false) here. |
| 878 | // TODO(evanm): perhaps we could allow shift-clicking the menu item to do |
| 879 | // a cache-ignoring reload of the frame. |
| 880 | webview()->focusedFrame()->reload(false); |
| 881 | } |
[email protected] | 1dda402 | 2010-01-28 18:24:56 | [diff] [blame] | 882 | } |
| 883 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 884 | void RenderViewImpl::OnCopyImageAt(int x, int y) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 885 | webview()->copyImageAt(WebPoint(x, y)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 886 | } |
| 887 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 888 | void RenderViewImpl::OnExecuteEditCommand(const std::string& name, |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 889 | const std::string& value) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 890 | if (!webview() || !webview()->focusedFrame()) |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 891 | return; |
| 892 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 893 | webview()->focusedFrame()->executeCommand( |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 894 | WebString::fromUTF8(name), WebString::fromUTF8(value)); |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 895 | } |
| 896 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 897 | void RenderViewImpl::OnUpdateTargetURLAck() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 898 | // Check if there is a targeturl waiting to be sent. |
| 899 | if (target_url_status_ == TARGET_PENDING) { |
| 900 | Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, |
| 901 | pending_target_url_)); |
| 902 | } |
| 903 | |
| 904 | target_url_status_ = TARGET_NONE; |
| 905 | } |
| 906 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 907 | void RenderViewImpl::OnUndo() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 908 | if (!webview()) |
| 909 | return; |
| 910 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 911 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 912 | } |
| 913 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 914 | void RenderViewImpl::OnRedo() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 915 | if (!webview()) |
| 916 | return; |
| 917 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 918 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 919 | } |
| 920 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 921 | void RenderViewImpl::OnCut() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 922 | if (!webview()) |
| 923 | return; |
| 924 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 925 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 926 | } |
| 927 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 928 | void RenderViewImpl::OnCopy() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 929 | if (!webview()) |
| 930 | return; |
| 931 | |
[email protected] | f6b1856b | 2011-06-29 22:02:53 | [diff] [blame] | 932 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"), |
| 933 | context_menu_node_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 934 | } |
| 935 | |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 936 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 937 | void RenderViewImpl::OnCopyToFindPboard() { |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 938 | if (!webview()) |
| 939 | return; |
| 940 | |
| 941 | // Since the find pasteboard supports only plain text, this can be simpler |
| 942 | // than the |OnCopy()| case. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 943 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 944 | if (frame->hasSelection()) { |
| 945 | string16 selection = frame->selectionAsText(); |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 946 | RenderThread::Get()->Send( |
[email protected] | 7e358974 | 2011-03-10 18:49:17 | [diff] [blame] | 947 | new ClipboardHostMsg_FindPboardWriteStringAsync(selection)); |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 948 | } |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 949 | } |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 950 | #endif |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 951 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 952 | void RenderViewImpl::OnPaste() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 953 | if (!webview()) |
| 954 | return; |
| 955 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 956 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 957 | } |
| 958 | |
[email protected] | 44bf700 | 2011-10-16 02:46:15 | [diff] [blame] | 959 | void RenderViewImpl::OnPasteAndMatchStyle() { |
| 960 | if (!webview()) |
| 961 | return; |
| 962 | |
| 963 | webview()->focusedFrame()->executeCommand( |
| 964 | WebString::fromUTF8("PasteAndMatchStyle")); |
| 965 | } |
| 966 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 967 | void RenderViewImpl::OnReplace(const string16& text) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 968 | if (!webview()) |
| 969 | return; |
| 970 | |
[email protected] | 1ff7a03 | 2010-02-03 02:46:03 | [diff] [blame] | 971 | WebFrame* frame = webview()->focusedFrame(); |
| 972 | if (!frame->hasSelection()) |
| 973 | frame->selectWordAroundCaret(); |
| 974 | frame->replaceSelection(text); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 975 | } |
| 976 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 977 | void RenderViewImpl::OnDelete() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 978 | if (!webview()) |
| 979 | return; |
| 980 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 981 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 982 | } |
| 983 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 984 | void RenderViewImpl::OnSelectAll() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 985 | if (!webview()) |
| 986 | return; |
| 987 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 988 | webview()->focusedFrame()->executeCommand( |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 989 | WebString::fromUTF8("SelectAll")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 990 | } |
| 991 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 992 | void RenderViewImpl::OnSelectRange(const gfx::Point& start, |
| 993 | const gfx::Point& end) { |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 994 | if (!webview()) |
| 995 | return; |
| 996 | |
| 997 | handling_select_range_ = true; |
| 998 | webview()->focusedFrame()->selectRange(start, end); |
| 999 | handling_select_range_ = false; |
| 1000 | } |
| 1001 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1002 | void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, |
| 1003 | int32 minimum_page_id) { |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1004 | DCHECK(history_length >= 0); |
| 1005 | DCHECK(history_list_offset_ == history_list_length_ - 1); |
| 1006 | DCHECK(minimum_page_id >= -1); |
| 1007 | |
| 1008 | // Generate the new list. |
| 1009 | std::vector<int32> new_history_page_ids(history_length, -1); |
| 1010 | for (size_t i = 0; i < history_page_ids_.size(); ++i) { |
| 1011 | if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) |
| 1012 | continue; |
| 1013 | new_history_page_ids.push_back(history_page_ids_[i]); |
| 1014 | } |
| 1015 | new_history_page_ids.swap(history_page_ids_); |
| 1016 | |
| 1017 | // Update indexes. |
| 1018 | history_list_length_ = history_page_ids_.size(); |
| 1019 | history_list_offset_ = history_list_length_ - 1; |
| 1020 | } |
| 1021 | |
| 1022 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1023 | void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1024 | if (!webview()) |
| 1025 | return; |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1026 | webview()->setInitialFocus(reverse); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1027 | } |
| 1028 | |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1029 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1030 | void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) { |
[email protected] | 4274b3e | 2011-08-09 19:09:33 | [diff] [blame] | 1031 | if (!webview()) |
| 1032 | return; |
| 1033 | if (in_live_resize) |
| 1034 | webview()->willStartLiveResize(); |
| 1035 | else |
| 1036 | webview()->willEndLiveResize(); |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1037 | } |
| 1038 | #endif |
| 1039 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1040 | void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1041 | const gfx::Rect& rect) { |
[email protected] | 13a1e4c3c | 2011-02-03 21:07:09 | [diff] [blame] | 1042 | WebKit::WebNode node = GetFocusedNode(); |
| 1043 | if (!node.isNull()) { |
| 1044 | if (IsEditableNode(node)) |
[email protected] | 333ec8d0 | 2011-09-16 18:59:19 | [diff] [blame] | 1045 | webview()->scrollFocusedNodeIntoRect(rect); |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 1046 | } |
| 1047 | } |
| 1048 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1049 | /////////////////////////////////////////////////////////////////////////////// |
| 1050 | |
| 1051 | // Tell the embedding application that the URL of the active page has changed |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1052 | void RenderViewImpl::UpdateURL(WebFrame* frame) { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1053 | WebDataSource* ds = frame->dataSource(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1054 | DCHECK(ds); |
| 1055 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1056 | const WebURLRequest& request = ds->request(); |
| 1057 | const WebURLRequest& original_request = ds->originalRequest(); |
| 1058 | const WebURLResponse& response = ds->response(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1059 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1060 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 1061 | NavigationState* navigation_state = document_state->navigation_state(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1062 | |
| 1063 | ViewHostMsg_FrameNavigate_Params params; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1064 | params.http_status_code = response.httpStatusCode(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1065 | params.is_post = false; |
| 1066 | params.page_id = page_id_; |
[email protected] | dabb0d1 | 2010-10-05 12:50:07 | [diff] [blame] | 1067 | params.frame_id = frame->identifier(); |
[email protected] | 6d81b48 | 2011-02-22 19:47:19 | [diff] [blame] | 1068 | params.socket_address.set_host(response.remoteIPAddress().utf8()); |
| 1069 | params.socket_address.set_port(response.remotePort()); |
[email protected] | b9a7c6d4 | 2011-02-25 02:13:03 | [diff] [blame] | 1070 | params.was_fetched_via_proxy = response.wasFetchedViaProxy(); |
[email protected] | af15bed | 2010-08-25 21:12:09 | [diff] [blame] | 1071 | params.was_within_same_page = navigation_state->was_within_same_page(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1072 | if (!document_state->security_info().empty()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1073 | // SSL state specified in the request takes precedence over the one in the |
| 1074 | // response. |
| 1075 | // So far this is only intended for error pages that are not expected to be |
| 1076 | // over ssl, so we should not get any clash. |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1077 | DCHECK(response.securityInfo().isEmpty()); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1078 | params.security_info = document_state->security_info(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1079 | } else { |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1080 | params.security_info = response.securityInfo(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1081 | } |
| 1082 | |
| 1083 | // Set the URL to be displayed in the browser UI to the user. |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1084 | if (ds->hasUnreachableURL()) { |
| 1085 | params.url = ds->unreachableURL(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1086 | } else { |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1087 | params.url = request.url(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1088 | } |
| 1089 | |
[email protected] | 5f9b871 | 2011-11-23 08:55:57 | [diff] [blame] | 1090 | if (frame->document().baseURL() != params.url) |
| 1091 | params.base_url = frame->document().baseURL(); |
| 1092 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1093 | GetRedirectChain(ds, ¶ms.redirects); |
[email protected] | d94dc1e | 2010-03-04 09:29:24 | [diff] [blame] | 1094 | params.should_update_history = !ds->hasUnreachableURL() && |
[email protected] | b7df1b7 | 2011-02-10 00:08:04 | [diff] [blame] | 1095 | !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1096 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1097 | params.searchable_form_url = document_state->searchable_form_url(); |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 1098 | params.searchable_form_encoding = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1099 | document_state->searchable_form_encoding(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1100 | |
| 1101 | const PasswordForm* password_form_data = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1102 | document_state->password_form_data(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1103 | if (password_form_data) |
| 1104 | params.password_form = *password_form_data; |
| 1105 | |
| 1106 | params.gesture = navigation_gesture_; |
| 1107 | navigation_gesture_ = NavigationGestureUnknown; |
| 1108 | |
[email protected] | 0f38dc455 | 2011-02-25 11:24:00 | [diff] [blame] | 1109 | // Make navigation state a part of the FrameNavigate message so that commited |
| 1110 | // entry had it at all times. |
| 1111 | const WebHistoryItem& item = frame->currentHistoryItem(); |
| 1112 | if (!item.isNull()) { |
| 1113 | params.content_state = webkit_glue::HistoryItemToString(item); |
| 1114 | } else { |
| 1115 | params.content_state = |
| 1116 | webkit_glue::CreateHistoryStateForURL(GURL(request.url())); |
| 1117 | } |
| 1118 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1119 | if (!frame->parent()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1120 | // Top-level navigation. |
| 1121 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1122 | // Set zoom level, but don't do it for full-page plugin since they don't use |
| 1123 | // the same zoom settings. |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1124 | HostZoomLevels::iterator host_zoom = |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 1125 | host_zoom_levels_.find(GURL(request.url())); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1126 | if (webview()->mainFrame()->document().isPluginDocument()) { |
| 1127 | // Reset the zoom levels for plugins. |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1128 | webview()->setZoomLevel(false, 0); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1129 | } else { |
| 1130 | if (host_zoom != host_zoom_levels_.end()) |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1131 | webview()->setZoomLevel(false, host_zoom->second); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1132 | } |
| 1133 | |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1134 | if (host_zoom != host_zoom_levels_.end()) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 1135 | // This zoom level was merely recorded transiently for this load. We can |
| 1136 | // erase it now. If at some point we reload this page, the browser will |
| 1137 | // send us a new, up-to-date zoom level. |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1138 | host_zoom_levels_.erase(host_zoom); |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 1139 | } |
| 1140 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1141 | // Reset the zoom limits in case a plugin had changed them previously. This |
| 1142 | // will also call us back which will cause us to send a message to |
| 1143 | // update TabContents. |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1144 | webview()->zoomLimitsChanged( |
[email protected] | 0f08340 | 2011-11-22 02:59:01 | [diff] [blame] | 1145 | WebView::zoomFactorToZoomLevel(content::kMinimumZoomFactor), |
| 1146 | WebView::zoomFactorToZoomLevel(content::kMaximumZoomFactor)); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1147 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1148 | // Update contents MIME type for main frame. |
[email protected] | 9c5645b | 2009-08-11 03:37:55 | [diff] [blame] | 1149 | params.contents_mime_type = ds->response().mimeType().utf8(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1150 | |
[email protected] | daa8c58e | 2009-06-15 17:21:10 | [diff] [blame] | 1151 | params.transition = navigation_state->transition_type(); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1152 | if (!content::PageTransitionIsMainFrame(params.transition)) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1153 | // If the main frame does a load, it should not be reported as a subframe |
| 1154 | // navigation. This can occur in the following case: |
| 1155 | // 1. You're on a site with frames. |
| 1156 | // 2. You do a subframe navigation. This is stored with transition type |
| 1157 | // MANUAL_SUBFRAME. |
| 1158 | // 3. You navigate to some non-frame site, say, google.com. |
| 1159 | // 4. You navigate back to the page from step 2. Since it was initially |
| 1160 | // MANUAL_SUBFRAME, it will be that same transition type here. |
| 1161 | // We don't want that, because any navigation that changes the toplevel |
| 1162 | // frame should be tracked as a toplevel navigation (this allows us to |
| 1163 | // update the URL bar, etc). |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1164 | params.transition = content::PAGE_TRANSITION_LINK; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1165 | } |
| 1166 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1167 | // If we have a valid consumed client redirect source, |
| 1168 | // the page contained a client redirect (meta refresh, document.loc...), |
| 1169 | // so we set the referrer and transition to match. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1170 | if (completed_client_redirect_src_.url.is_valid()) { |
| 1171 | DCHECK(completed_client_redirect_src_.url == params.redirects[0]); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1172 | params.referrer = completed_client_redirect_src_; |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1173 | params.transition = static_cast<content::PageTransition>( |
| 1174 | params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1175 | } else { |
| 1176 | // Bug 654101: the referrer will be empty on https->http transitions. It |
| 1177 | // would be nice if we could get the real referrer from somewhere. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1178 | params.referrer = Referrer(GURL( |
| 1179 | original_request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 1180 | getReferrerPolicyFromRequest(original_request)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1181 | } |
| 1182 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1183 | string16 method = request.httpMethod(); |
| 1184 | if (EqualsASCII(method, "POST")) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1185 | params.is_post = true; |
| 1186 | |
[email protected] | c2a797d | 2009-09-21 16:46:32 | [diff] [blame] | 1187 | // Save some histogram data so we can compute the average memory used per |
| 1188 | // page load of the glyphs. |
| 1189 | UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
| 1190 | webkit_glue::GetGlyphPageCount()); |
| 1191 | |
[email protected] | 15cf526b | 2010-02-12 06:33:49 | [diff] [blame] | 1192 | // This message needs to be sent before any of allowScripts(), |
| 1193 | // allowImages(), allowPlugins() is called for the new page, so that when |
| 1194 | // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
| 1195 | // after the ViewHostMsg_FrameNavigate message. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1196 | Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1197 | } else { |
| 1198 | // Subframe navigation: the type depends on whether this navigation |
| 1199 | // generated a new session history entry. When they do generate a session |
| 1200 | // history entry, it means the user initiated the navigation and we should |
| 1201 | // mark it as such. This test checks if this is the first time UpdateURL |
| 1202 | // has been called since WillNavigateToURL was called to initiate the load. |
| 1203 | if (page_id_ > last_page_id_sent_to_browser_) |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1204 | params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1205 | else |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1206 | params.transition = content::PAGE_TRANSITION_AUTO_SUBFRAME; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1207 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1208 | Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1209 | } |
| 1210 | |
| 1211 | last_page_id_sent_to_browser_ = |
| 1212 | std::max(last_page_id_sent_to_browser_, page_id_); |
| 1213 | |
| 1214 | // 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] | 1215 | // we don't want the transition type to persist. Just clear it. |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1216 | navigation_state->set_transition_type(content::PAGE_TRANSITION_LINK); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1217 | } |
| 1218 | |
| 1219 | // Tell the embedding application that the title of the active page has changed |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1220 | void RenderViewImpl::UpdateTitle(WebFrame* frame, |
| 1221 | const string16& title, |
| 1222 | WebTextDirection title_direction) { |
[email protected] | a49e10b | 2011-08-01 23:57:46 | [diff] [blame] | 1223 | // Ignore all but top level navigations. |
| 1224 | if (frame->parent()) |
| 1225 | return; |
| 1226 | |
| 1227 | string16 shortened_title = title.substr(0, content::kMaxTitleChars); |
| 1228 | Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, |
| 1229 | title_direction)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1230 | } |
| 1231 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1232 | void RenderViewImpl::UpdateEncoding(WebFrame* frame, |
| 1233 | const std::string& encoding_name) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1234 | // Only update main frame's encoding_name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1235 | if (webview()->mainFrame() == frame && |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1236 | last_encoding_name_ != encoding_name) { |
[email protected] | e38f4015 | 2008-09-12 23:08:30 | [diff] [blame] | 1237 | // Save the encoding name for later comparing. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1238 | last_encoding_name_ = encoding_name; |
| 1239 | |
[email protected] | e38f4015 | 2008-09-12 23:08:30 | [diff] [blame] | 1240 | Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1241 | } |
| 1242 | } |
| 1243 | |
[email protected] | e15f68073 | 2010-11-23 22:30:20 | [diff] [blame] | 1244 | // Sends the last committed session history state to the browser so it will be |
| 1245 | // saved before we navigate to a new page. This must be called *before* the |
| 1246 | // page ID has been updated so we know what it was. |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1247 | void RenderViewImpl::UpdateSessionHistory(WebFrame* frame) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1248 | // If we have a valid page ID at this point, then it corresponds to the page |
| 1249 | // we are navigating away from. Otherwise, this is the first navigation, so |
| 1250 | // there is no past session history to record. |
| 1251 | if (page_id_ == -1) |
| 1252 | return; |
| 1253 | |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1254 | const WebHistoryItem& item = |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1255 | webview()->mainFrame()->previousHistoryItem(); |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1256 | if (item.isNull()) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1257 | return; |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1258 | |
| 1259 | Send(new ViewHostMsg_UpdateState( |
| 1260 | routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1261 | } |
| 1262 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1263 | void RenderViewImpl::OpenURL(WebFrame* frame, |
| 1264 | const GURL& url, |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1265 | const Referrer& referrer, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1266 | WebNavigationPolicy policy) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1267 | Send(new ViewHostMsg_OpenURL( |
[email protected] | ae5184d6 | 2011-10-06 19:25:58 | [diff] [blame] | 1268 | routing_id_, |
| 1269 | url, |
| 1270 | referrer, |
| 1271 | NavigationPolicyToDisposition(policy), |
| 1272 | frame->identifier())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1273 | } |
| 1274 | |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1275 | // WebViewDelegate ------------------------------------------------------------ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1276 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1277 | void RenderViewImpl::LoadNavigationErrorPage( |
| 1278 | WebFrame* frame, |
| 1279 | const WebURLRequest& failed_request, |
| 1280 | const WebURLError& error, |
| 1281 | const std::string& html, |
| 1282 | bool replace) { |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 1283 | std::string alt_html; |
| 1284 | const std::string* error_html; |
| 1285 | |
| 1286 | if (!html.empty()) { |
| 1287 | error_html = &html; |
| 1288 | } else { |
| 1289 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 1290 | failed_request, error, &alt_html, NULL); |
| 1291 | error_html = &alt_html; |
| 1292 | } |
| 1293 | |
| 1294 | frame->loadHTMLString(*error_html, |
[email protected] | 144143c | 2010-10-28 08:17:36 | [diff] [blame] | 1295 | GURL(chrome::kUnreachableWebDataURL), |
[email protected] | 21d61e5 | 2011-03-18 19:08:25 | [diff] [blame] | 1296 | error.unreachableURL, |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 1297 | replace); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1298 | } |
| 1299 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1300 | bool RenderViewImpl::RunJavaScriptMessage(ui::JavascriptMessageType type, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1301 | const string16& message, |
| 1302 | const string16& default_value, |
| 1303 | const GURL& frame_url, |
| 1304 | string16* result) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1305 | bool success = false; |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1306 | string16 result_temp; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1307 | if (!result) |
| 1308 | result = &result_temp; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1309 | |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1310 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( |
| 1311 | routing_id_, message, default_value, frame_url, type, &success, result)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1312 | return success; |
| 1313 | } |
| 1314 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1315 | bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1316 | // Before WebKit asks us to show an alert (etc.), it takes care of doing the |
| 1317 | // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog |
| 1318 | // it is particularly important that we do not call willEnterModalLoop as |
| 1319 | // that would defer resource loads for the dialog itself. |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 1320 | if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 1321 | RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1322 | |
| 1323 | message->EnableMessagePumping(); // Runs a nested message loop. |
| 1324 | return Send(message); |
| 1325 | } |
| 1326 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1327 | // WebKit::WebViewClient ------------------------------------------------------ |
| 1328 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1329 | WebView* RenderViewImpl::createView( |
[email protected] | 844acf37 | 2011-01-14 10:49:27 | [diff] [blame] | 1330 | WebFrame* creator, |
| 1331 | const WebURLRequest& request, |
| 1332 | const WebWindowFeatures& features, |
| 1333 | const WebString& frame_name) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1334 | // Check to make sure we aren't overloading on popups. |
| 1335 | if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) |
| 1336 | return NULL; |
| 1337 | |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1338 | ViewHostMsg_CreateWindow_Params params; |
| 1339 | params.opener_id = routing_id_; |
| 1340 | params.user_gesture = creator->isProcessingUserGesture(); |
| 1341 | params.window_container_type = WindowFeaturesToContainerType(features); |
| 1342 | params.session_storage_namespace_id = session_storage_namespace_id_; |
| 1343 | params.frame_name = frame_name; |
[email protected] | 41e6550 | 2011-01-21 09:29:11 | [diff] [blame] | 1344 | params.opener_frame_id = creator->identifier(); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1345 | params.opener_url = creator->document().url(); |
| 1346 | params.opener_security_origin = |
| 1347 | creator->document().securityOrigin().toString().utf8(); |
[email protected] | 41e6550 | 2011-01-21 09:29:11 | [diff] [blame] | 1348 | if (!request.isNull()) |
| 1349 | params.target_url = request.url(); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1350 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1351 | int32 routing_id = MSG_ROUTING_NONE; |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1352 | int32 surface_id = 0; |
[email protected] | 4e6419c | 2010-01-15 04:50:34 | [diff] [blame] | 1353 | int64 cloned_session_storage_namespace_id; |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1354 | bool opener_suppressed = creator->willSuppressOpenerInNewFrame(); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1355 | |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1356 | RenderThread::Get()->Send( |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1357 | new ViewHostMsg_CreateWindow(params, |
| 1358 | &routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1359 | &surface_id, |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1360 | &cloned_session_storage_namespace_id)); |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1361 | if (routing_id == MSG_ROUTING_NONE) |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1362 | return NULL; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1363 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1364 | RenderViewImpl* view = RenderViewImpl::Create( |
| 1365 | 0, |
| 1366 | routing_id_, |
| 1367 | renderer_preferences_, |
| 1368 | webkit_preferences_, |
| 1369 | shared_popup_counter_, |
| 1370 | routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1371 | surface_id, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1372 | cloned_session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 1373 | frame_name, |
| 1374 | 1); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1375 | view->opened_by_user_gesture_ = params.user_gesture; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1376 | |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 1377 | // Record whether the creator frame is trying to suppress the opener field. |
| 1378 | view->opener_suppressed_ = opener_suppressed; |
| 1379 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1380 | // Record the security origin of the creator. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1381 | GURL creator_url(creator->document().securityOrigin().toString().utf8()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1382 | if (!creator_url.is_valid() || !creator_url.IsStandard()) |
| 1383 | creator_url = GURL(); |
| 1384 | view->creator_url_ = creator_url; |
| 1385 | |
| 1386 | // Copy over the alternate error page URL so we can have alt error pages in |
| 1387 | // the new render view (we don't need the browser to send the URL back down). |
| 1388 | view->alternate_error_page_url_ = alternate_error_page_url_; |
| 1389 | |
| 1390 | return view->webview(); |
| 1391 | } |
| 1392 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1393 | WebWidget* RenderViewImpl::createPopupMenu(WebKit::WebPopupType popup_type) { |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1394 | RenderWidget* widget = RenderWidget::Create(routing_id_, popup_type); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1395 | return widget->webwidget(); |
| 1396 | } |
| 1397 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1398 | WebWidget* RenderViewImpl::createPopupMenu(const WebPopupMenuInfo& info) { |
[email protected] | 8de12d94 | 2010-11-17 20:42:44 | [diff] [blame] | 1399 | // TODO(jcivelli): Remove this deprecated method when its been removed from |
| 1400 | // the WebViewClient interface. It's been replaced by |
| 1401 | // createExternalPopupMenu. |
| 1402 | NOTREACHED(); |
| 1403 | return NULL; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1404 | } |
| 1405 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1406 | WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 1407 | const WebPopupMenuInfo& popup_menu_info, |
| 1408 | WebExternalPopupMenuClient* popup_menu_client) { |
| 1409 | DCHECK(!external_popup_menu_.get()); |
| 1410 | external_popup_menu_.reset( |
| 1411 | new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); |
| 1412 | return external_popup_menu_.get(); |
| 1413 | } |
| 1414 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1415 | RenderWidgetFullscreenPepper* RenderViewImpl::CreatePepperFullscreenContainer( |
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 1416 | webkit::ppapi::PluginInstance* plugin) { |
[email protected] | d91233b7e | 2011-03-29 20:33:53 | [diff] [blame] | 1417 | GURL active_url; |
[email protected] | d91ddfc | 2011-04-07 18:33:42 | [diff] [blame] | 1418 | if (webview() && webview()->mainFrame()) |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1419 | active_url = GURL(webview()->mainFrame()->document().url()); |
[email protected] | d91233b7e | 2011-03-29 20:33:53 | [diff] [blame] | 1420 | RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1421 | routing_id_, plugin, active_url); |
[email protected] | 79c7bed | 2010-09-14 22:28:39 | [diff] [blame] | 1422 | widget->show(WebKit::WebNavigationPolicyIgnore); |
[email protected] | 92abcb83 | 2011-01-06 20:39:56 | [diff] [blame] | 1423 | return widget; |
[email protected] | 79c7bed | 2010-09-14 22:28:39 | [diff] [blame] | 1424 | } |
| 1425 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1426 | WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace( |
| 1427 | unsigned quota) { |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1428 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
[email protected] | 68c50e5 | 2010-05-12 11:14:39 | [diff] [blame] | 1429 | return WebStorageNamespace::createSessionStorageNamespace(quota); |
[email protected] | 59afea1 | 2010-01-20 04:48:29 | [diff] [blame] | 1430 | CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
| 1431 | return new RendererWebStorageNamespaceImpl(DOM_STORAGE_SESSION, |
| 1432 | session_storage_namespace_id_); |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1433 | } |
| 1434 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1435 | void RenderViewImpl::didAddMessageToConsole( |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1436 | const WebConsoleMessage& message, const WebString& source_name, |
| 1437 | unsigned source_line) { |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1438 | logging::LogSeverity log_severity = logging::LOG_VERBOSE; |
[email protected] | f7eb0a39 | 2011-07-12 10:19:51 | [diff] [blame] | 1439 | switch (message.level) { |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1440 | case WebConsoleMessage::LevelTip: |
| 1441 | log_severity = logging::LOG_VERBOSE; |
| 1442 | break; |
| 1443 | case WebConsoleMessage::LevelLog: |
| 1444 | log_severity = logging::LOG_INFO; |
| 1445 | break; |
| 1446 | case WebConsoleMessage::LevelWarning: |
| 1447 | log_severity = logging::LOG_WARNING; |
| 1448 | break; |
| 1449 | case WebConsoleMessage::LevelError: |
| 1450 | log_severity = logging::LOG_ERROR; |
| 1451 | break; |
| 1452 | default: |
| 1453 | NOTREACHED(); |
| 1454 | } |
| 1455 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1456 | Send(new ViewHostMsg_AddMessageToConsole(routing_id_, |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1457 | static_cast<int32>(log_severity), |
[email protected] | aa21d2a | 2011-08-08 23:56:31 | [diff] [blame] | 1458 | message.text, |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1459 | static_cast<int32>(source_line), |
[email protected] | aa21d2a | 2011-08-08 23:56:31 | [diff] [blame] | 1460 | source_name)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1461 | } |
| 1462 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1463 | void RenderViewImpl::printPage(WebFrame* frame) { |
[email protected] | d91ddfc | 2011-04-07 18:33:42 | [diff] [blame] | 1464 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, PrintPage(frame)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1465 | } |
| 1466 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1467 | WebKit::WebNotificationPresenter* RenderViewImpl::notificationPresenter() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1468 | return notification_provider_; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 1469 | } |
| 1470 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1471 | bool RenderViewImpl::enumerateChosenDirectory( |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1472 | const WebString& path, |
| 1473 | WebFileChooserCompletion* chooser_completion) { |
| 1474 | int id = enumeration_completion_id_++; |
| 1475 | enumeration_completions_[id] = chooser_completion; |
| 1476 | return Send(new ViewHostMsg_EnumerateDirectory( |
| 1477 | routing_id_, |
| 1478 | id, |
| 1479 | webkit_glue::WebStringToFilePath(path))); |
| 1480 | } |
| 1481 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1482 | void RenderViewImpl::didStartLoading() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1483 | if (is_loading_) { |
| 1484 | DLOG(WARNING) << "didStartLoading called while loading"; |
| 1485 | return; |
| 1486 | } |
| 1487 | |
| 1488 | is_loading_ = true; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1489 | |
| 1490 | Send(new ViewHostMsg_DidStartLoading(routing_id_)); |
[email protected] | 93b9d69 | 2011-04-13 00:44:31 | [diff] [blame] | 1491 | |
| 1492 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1493 | } |
| 1494 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1495 | void RenderViewImpl::didStopLoading() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1496 | if (!is_loading_) { |
| 1497 | DLOG(WARNING) << "DidStopLoading called while not loading"; |
| 1498 | return; |
| 1499 | } |
| 1500 | |
| 1501 | is_loading_ = false; |
| 1502 | |
| 1503 | // NOTE: For now we're doing the safest thing, and sending out notification |
| 1504 | // when done loading. This currently isn't an issue as the favicon is only |
| 1505 | // displayed when done loading. Ideally we would send notification when |
| 1506 | // finished parsing the head, but webkit doesn't support that yet. |
| 1507 | // The feed discovery code would also benefit from access to the head. |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1508 | Send(new ViewHostMsg_DidStopLoading(routing_id_)); |
| 1509 | |
[email protected] | 9010941 | 2010-12-15 17:14:24 | [diff] [blame] | 1510 | if (load_progress_tracker_ != NULL) |
| 1511 | load_progress_tracker_->DidStopLoading(); |
| 1512 | |
[email protected] | 93b9d69 | 2011-04-13 00:44:31 | [diff] [blame] | 1513 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1514 | } |
| 1515 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1516 | void RenderViewImpl::didChangeLoadProgress(WebFrame* frame, |
| 1517 | double load_progress) { |
[email protected] | 9010941 | 2010-12-15 17:14:24 | [diff] [blame] | 1518 | if (load_progress_tracker_ != NULL) |
| 1519 | load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); |
| 1520 | } |
| 1521 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1522 | bool RenderViewImpl::isSmartInsertDeleteEnabled() { |
[email protected] | f55039a | 2010-02-17 14:12:06 | [diff] [blame] | 1523 | #if defined(OS_MACOSX) |
| 1524 | return true; |
| 1525 | #else |
| 1526 | return false; |
| 1527 | #endif |
| 1528 | } |
| 1529 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1530 | bool RenderViewImpl::isSelectTrailingWhitespaceEnabled() { |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1531 | #if defined(OS_WIN) |
| 1532 | return true; |
| 1533 | #else |
| 1534 | return false; |
| 1535 | #endif |
| 1536 | } |
| 1537 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1538 | void RenderViewImpl::didChangeSelection(bool is_empty_selection) { |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1539 | if (!handling_input_event_ && !handling_select_range_) |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1540 | return; |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1541 | handling_select_range_ = false; |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1542 | |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 1543 | SyncSelectionIfRequired(); |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1544 | } |
| 1545 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1546 | void RenderViewImpl::didExecuteCommand(const WebString& command_name) { |
[email protected] | afe3a167 | 2009-11-17 19:04:12 | [diff] [blame] | 1547 | const std::string& name = UTF16ToUTF8(command_name); |
| 1548 | if (StartsWithASCII(name, "Move", true) || |
| 1549 | StartsWithASCII(name, "Insert", true) || |
| 1550 | StartsWithASCII(name, "Delete", true)) |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1551 | return; |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 1552 | RenderThreadImpl::current()->RecordUserMetrics(name); |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1553 | } |
| 1554 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1555 | bool RenderViewImpl::handleCurrentKeyboardEvent() { |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1556 | if (edit_commands_.empty()) |
| 1557 | return false; |
| 1558 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1559 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1560 | if (!frame) |
| 1561 | return false; |
| 1562 | |
| 1563 | EditCommands::iterator it = edit_commands_.begin(); |
| 1564 | EditCommands::iterator end = edit_commands_.end(); |
| 1565 | |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1566 | bool did_execute_command = false; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1567 | for (; it != end; ++it) { |
[email protected] | e6e1501 | 2009-09-30 14:59:33 | [diff] [blame] | 1568 | // In gtk and cocoa, it's possible to bind multiple edit commands to one |
| 1569 | // key (but it's the exception). Once one edit command is not executed, it |
| 1570 | // seems safest to not execute the rest. |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1571 | if (!frame->executeCommand(WebString::fromUTF8(it->name), |
| 1572 | WebString::fromUTF8(it->value))) |
| 1573 | break; |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1574 | did_execute_command = true; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1575 | } |
| 1576 | |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1577 | return did_execute_command; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1578 | } |
| 1579 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1580 | bool RenderViewImpl::runFileChooser( |
[email protected] | 01178b5 | 2010-01-15 06:59:35 | [diff] [blame] | 1581 | const WebKit::WebFileChooserParams& params, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1582 | WebFileChooserCompletion* chooser_completion) { |
[email protected] | 7ef03e0 | 2010-10-23 11:58:35 | [diff] [blame] | 1583 | // Do not open the file dialog in a hidden RenderView. |
| 1584 | if (is_hidden()) |
| 1585 | return false; |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1586 | content::FileChooserParams ipc_params; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1587 | if (params.directory) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1588 | ipc_params.mode = content::FileChooserParams::OpenFolder; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1589 | else if (params.multiSelect) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1590 | ipc_params.mode = content::FileChooserParams::OpenMultiple; |
[email protected] | 459fba8 | 2011-10-13 02:48:50 | [diff] [blame] | 1591 | else if (params.saveAs) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1592 | ipc_params.mode = content::FileChooserParams::Save; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1593 | else |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1594 | ipc_params.mode = content::FileChooserParams::Open; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1595 | ipc_params.title = params.title; |
| 1596 | ipc_params.default_file_name = |
| 1597 | webkit_glue::WebStringToFilePath(params.initialValue); |
[email protected] | 3314c2b1 | 2011-11-02 08:05:46 | [diff] [blame] | 1598 | ipc_params.accept_types.reserve(params.acceptMIMETypes.size()); |
| 1599 | for (size_t i = 0; i < params.acceptMIMETypes.size(); ++i) |
| 1600 | ipc_params.accept_types.push_back(params.acceptMIMETypes[i]); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1601 | |
| 1602 | return ScheduleFileChooser(ipc_params, chooser_completion); |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 1603 | } |
| 1604 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1605 | void RenderViewImpl::runModalAlertDialog(WebFrame* frame, |
| 1606 | const WebString& message) { |
| 1607 | RunJavaScriptMessage(ui::JAVASCRIPT_MESSAGE_TYPE_ALERT, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1608 | message, |
| 1609 | string16(), |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1610 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1611 | NULL); |
| 1612 | } |
| 1613 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1614 | bool RenderViewImpl::runModalConfirmDialog(WebFrame* frame, |
| 1615 | const WebString& message) { |
| 1616 | return RunJavaScriptMessage(ui::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1617 | message, |
| 1618 | string16(), |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1619 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1620 | NULL); |
| 1621 | } |
| 1622 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1623 | bool RenderViewImpl::runModalPromptDialog(WebFrame* frame, |
| 1624 | const WebString& message, |
| 1625 | const WebString& default_value, |
| 1626 | WebString* actual_value) { |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1627 | string16 result; |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1628 | bool ok = RunJavaScriptMessage(ui::JAVASCRIPT_MESSAGE_TYPE_PROMPT, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1629 | message, |
| 1630 | default_value, |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1631 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1632 | &result); |
| 1633 | if (ok) |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1634 | actual_value->assign(result); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1635 | return ok; |
| 1636 | } |
| 1637 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1638 | bool RenderViewImpl::runModalBeforeUnloadDialog( |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1639 | WebFrame* frame, const WebString& message) { |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 1640 | // If we are swapping out, we have already run the beforeunload handler. |
| 1641 | // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload |
| 1642 | // at all, to avoid running it twice. |
| 1643 | if (is_swapped_out_) |
| 1644 | return true; |
| 1645 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1646 | bool success = false; |
| 1647 | // This is an ignored return value, but is included so we can accept the same |
| 1648 | // response as RunJavaScriptMessage. |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1649 | string16 ignored_result; |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1650 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1651 | routing_id_, frame->document().url(), message, |
| 1652 | &success, &ignored_result)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1653 | return success; |
| 1654 | } |
| 1655 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1656 | void RenderViewImpl::showContextMenu( |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 1657 | WebFrame* frame, const WebContextMenuData& data) { |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 1658 | ContextMenuParams params = ContextMenuParams(data); |
[email protected] | 7fcd9b7 | 2011-07-27 16:52:37 | [diff] [blame] | 1659 | |
| 1660 | // frame is NULL if invoked by BlockedPlugin. |
| 1661 | if (frame) |
| 1662 | params.frame_id = frame->identifier(); |
| 1663 | |
[email protected] | db803aae | 2011-03-05 02:00:42 | [diff] [blame] | 1664 | // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do |
[email protected] | 216932c | 2010-08-26 21:44:27 | [diff] [blame] | 1665 | // it. We replace it with an empty GURL so the appropriate items are disabled |
| 1666 | // in the context menu. |
| 1667 | // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large |
| 1668 | // data encoded images. We should have a way to save them. |
[email protected] | db803aae | 2011-03-05 02:00:42 | [diff] [blame] | 1669 | if (params.src_url.spec().size() > content::kMaxURLChars) |
[email protected] | 216932c | 2010-08-26 21:44:27 | [diff] [blame] | 1670 | params.src_url = GURL(); |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 1671 | context_menu_node_ = data.node; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 1672 | Send(new ViewHostMsg_ContextMenu(routing_id_, params)); |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 1673 | } |
| 1674 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1675 | void RenderViewImpl::enterFullscreen() { |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1676 | // TODO(darin): Remove once WebKit roll is complete. |
| 1677 | enterFullScreen(); |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 1678 | } |
| 1679 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1680 | void RenderViewImpl::exitFullscreen() { |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1681 | // TODO(darin): Remove once WebKit roll is complete. |
| 1682 | exitFullScreen(); |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 1683 | } |
| 1684 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1685 | void RenderViewImpl::setStatusText(const WebString& text) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1686 | } |
| 1687 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1688 | void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 1689 | const GURL& fallback_url) { |
[email protected] | aa6b90b3 | 2010-04-26 15:49:58 | [diff] [blame] | 1690 | GURL latest_url = url.is_empty() ? fallback_url : url; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1691 | if (latest_url == target_url_) |
| 1692 | return; |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1693 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1694 | // Tell the browser to display a destination link. |
| 1695 | if (target_url_status_ == TARGET_INFLIGHT || |
| 1696 | target_url_status_ == TARGET_PENDING) { |
| 1697 | // If we have a request in-flight, save the URL to be sent when we |
| 1698 | // receive an ACK to the in-flight request. We can happily overwrite |
| 1699 | // any existing pending sends. |
| 1700 | pending_target_url_ = latest_url; |
| 1701 | target_url_status_ = TARGET_PENDING; |
| 1702 | } else { |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1703 | // URLs larger than |content::kMaxURLChars| cannot be sent through IPC - |
| 1704 | // see |ParamTraits<GURL>|. |
| 1705 | if (latest_url.possibly_invalid_spec().size() > content::kMaxURLChars) |
| 1706 | latest_url = GURL(); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1707 | Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); |
| 1708 | target_url_ = latest_url; |
| 1709 | target_url_status_ = TARGET_INFLIGHT; |
| 1710 | } |
| 1711 | } |
| 1712 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1713 | void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1714 | int delay; |
| 1715 | if (send_content_state_immediately_) |
| 1716 | delay = 0; |
| 1717 | else if (is_hidden()) |
| 1718 | delay = kDelaySecondsForContentStateSyncHidden; |
| 1719 | else |
| 1720 | delay = kDelaySecondsForContentStateSync; |
| 1721 | |
| 1722 | if (nav_state_sync_timer_.IsRunning()) { |
| 1723 | // The timer is already running. If the delay of the timer maches the amount |
| 1724 | // we want to delay by, then return. Otherwise stop the timer so that it |
| 1725 | // gets started with the right delay. |
| 1726 | if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
| 1727 | return; |
| 1728 | nav_state_sync_timer_.Stop(); |
| 1729 | } |
| 1730 | |
[email protected] | d323a17 | 2011-09-02 18:23:02 | [diff] [blame] | 1731 | nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1732 | &RenderViewImpl::SyncNavigationState); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1733 | } |
| 1734 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1735 | void RenderViewImpl::setMouseOverURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1736 | mouse_over_url_ = GURL(url); |
| 1737 | UpdateTargetURL(mouse_over_url_, focus_url_); |
| 1738 | } |
| 1739 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1740 | void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1741 | focus_url_ = GURL(url); |
| 1742 | UpdateTargetURL(focus_url_, mouse_over_url_); |
| 1743 | } |
| 1744 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1745 | void RenderViewImpl::startDragging(const WebDragData& data, |
| 1746 | WebDragOperationsMask mask, |
| 1747 | const WebImage& image, |
| 1748 | const WebPoint& imageOffset) { |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 1749 | #if WEBKIT_USING_SKIA |
| 1750 | SkBitmap bitmap(image.getSkBitmap()); |
| 1751 | #elif WEBKIT_USING_CG |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 1752 | SkBitmap bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef()); |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 1753 | #endif |
| 1754 | |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 1755 | Send(new DragHostMsg_StartDragging(routing_id_, |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1756 | WebDropData(data), |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 1757 | mask, |
| 1758 | bitmap, |
| 1759 | imageOffset)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1760 | } |
| 1761 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1762 | bool RenderViewImpl::acceptsLoadDrops() { |
[email protected] | 28b92df | 2009-09-25 17:35:45 | [diff] [blame] | 1763 | return renderer_preferences_.can_accept_load_drops; |
| 1764 | } |
| 1765 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1766 | void RenderViewImpl::focusNext() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1767 | Send(new ViewHostMsg_TakeFocus(routing_id_, false)); |
| 1768 | } |
| 1769 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1770 | void RenderViewImpl::focusPrevious() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1771 | Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
| 1772 | } |
| 1773 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1774 | void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 1775 | Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
[email protected] | a4b103b | 2010-10-05 18:46:07 | [diff] [blame] | 1776 | |
[email protected] | 38b59290 | 2011-04-16 02:08:42 | [diff] [blame] | 1777 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
[email protected] | 08e9e13 | 2010-06-01 16:58:49 | [diff] [blame] | 1778 | } |
| 1779 | |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 1780 | void RenderViewImpl::didUpdateLayout() { |
| 1781 | // We don't always want to set up a timer, only if we've been put in that |
| 1782 | // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 1783 | // message. |
| 1784 | if (!send_preferred_size_changes_ || !webview()) |
| 1785 | return; |
| 1786 | |
| 1787 | if (check_preferred_size_timer_.IsRunning()) |
| 1788 | return; |
| 1789 | check_preferred_size_timer_.Start(FROM_HERE, |
| 1790 | TimeDelta::FromMilliseconds(0), this, |
| 1791 | &RenderViewImpl::CheckPreferredSize); |
| 1792 | } |
| 1793 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1794 | void RenderViewImpl::navigateBackForwardSoon(int offset) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1795 | Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); |
| 1796 | } |
| 1797 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1798 | int RenderViewImpl::historyBackListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1799 | return history_list_offset_ < 0 ? 0 : history_list_offset_; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1800 | } |
| 1801 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1802 | int RenderViewImpl::historyForwardListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1803 | return history_list_length_ - historyBackListCount() - 1; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1804 | } |
| 1805 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1806 | void RenderViewImpl::postAccessibilityNotification( |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 1807 | const WebAccessibilityObject& obj, |
| 1808 | WebAccessibilityNotification notification) { |
| 1809 | renderer_accessibility_->PostAccessibilityNotification(obj, notification); |
| 1810 | } |
| 1811 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1812 | void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, |
[email protected] | c4e9890 | 2010-06-01 10:20:14 | [diff] [blame] | 1813 | const WebString& value) { |
| 1814 | Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
| 1815 | key.utf8(), |
| 1816 | value.utf8())); |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 1817 | } |
| 1818 | |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1819 | // WebKit::WebWidgetClient ---------------------------------------------------- |
| 1820 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1821 | void RenderViewImpl::didFocus() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 1822 | // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 1823 | // we won't have to test for user gesture anymore and we can |
| 1824 | // move that code back to render_widget.cc |
| 1825 | if (webview() && webview()->mainFrame() && |
| 1826 | webview()->mainFrame()->isProcessingUserGesture()) { |
| 1827 | Send(new ViewHostMsg_Focus(routing_id_)); |
| 1828 | } |
| 1829 | } |
| 1830 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1831 | void RenderViewImpl::didBlur() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 1832 | // TODO(jcivelli): see TODO above in didFocus(). |
| 1833 | if (webview() && webview()->mainFrame() && |
| 1834 | webview()->mainFrame()->isProcessingUserGesture()) { |
| 1835 | Send(new ViewHostMsg_Blur(routing_id_)); |
| 1836 | } |
| 1837 | } |
| 1838 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1839 | // 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] | 1840 | // that was created via RenderViewImpl::CreateWebView. So, we wait until this |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1841 | // point to dispatch the ShowView message. |
| 1842 | // |
| 1843 | // This method provides us with the information about how to display the newly |
[email protected] | 5f9de588 | 2011-09-30 23:36:28 | [diff] [blame] | 1844 | // created RenderView (i.e., as a blocked popup or as a new tab). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1845 | // |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1846 | void RenderViewImpl::show(WebNavigationPolicy policy) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1847 | DCHECK(!did_show_) << "received extraneous Show call"; |
| 1848 | DCHECK(opener_id_ != MSG_ROUTING_NONE); |
| 1849 | |
| 1850 | if (did_show_) |
| 1851 | return; |
| 1852 | did_show_ = true; |
| 1853 | |
[email protected] | 6779aa1 | 2011-03-29 17:32:24 | [diff] [blame] | 1854 | if (content::GetContentClient()->renderer()->AllowPopup(creator_url_)) |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 1855 | opened_by_user_gesture_ = true; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 1856 | |
[email protected] | 28295ec | 2009-10-16 05:34:33 | [diff] [blame] | 1857 | // Force new windows to a popup if they were not opened with a user gesture. |
| 1858 | if (!opened_by_user_gesture_) { |
| 1859 | // We exempt background tabs for compat with older versions of Chrome. |
| 1860 | // TODO(darin): This seems bogus. These should have a user gesture, so |
| 1861 | // we probably don't need this check. |
| 1862 | if (policy != WebKit::WebNavigationPolicyNewBackgroundTab) |
| 1863 | policy = WebKit::WebNavigationPolicyNewPopup; |
| 1864 | } |
| 1865 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1866 | // NOTE: initial_pos_ may still have its default values at this point, but |
| 1867 | // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the |
| 1868 | // browser process will impose a default position otherwise. |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 1869 | Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, |
| 1870 | NavigationPolicyToDisposition(policy), initial_pos_, |
[email protected] | 7e7414ae | 2010-01-26 20:19:29 | [diff] [blame] | 1871 | opened_by_user_gesture_)); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 1872 | SetPendingWindowRect(initial_pos_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1873 | } |
| 1874 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1875 | void RenderViewImpl::runModal() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1876 | DCHECK(did_show_) << "should already have shown the view"; |
| 1877 | |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1878 | // We must keep WebKit's shared timer running in this case in order to allow |
| 1879 | // showModalDialog to function properly. |
| 1880 | // |
| 1881 | // TODO(darin): WebKit should really be smarter about suppressing events and |
| 1882 | // timers so that we do not need to manage the shared timer in such a heavy |
| 1883 | // handed manner. |
| 1884 | // |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 1885 | if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 1886 | RenderThreadImpl::current()->DoNotSuspendWebKitSharedTimer(); |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1887 | |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1888 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1889 | } |
| 1890 | |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1891 | bool RenderViewImpl::enterFullScreen() { |
| 1892 | Send(new ViewHostMsg_ToggleFullscreen(routing_id_, true)); |
| 1893 | return true; |
| 1894 | } |
| 1895 | |
| 1896 | void RenderViewImpl::exitFullScreen() { |
| 1897 | Send(new ViewHostMsg_ToggleFullscreen(routing_id_, false)); |
| 1898 | } |
| 1899 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1900 | // WebKit::WebFrameClient ----------------------------------------------------- |
| 1901 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1902 | WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, |
| 1903 | const WebPluginParams& params) { |
[email protected] | eaacd1f | 2011-09-23 02:32:55 | [diff] [blame] | 1904 | WebPlugin* plugin = NULL; |
| 1905 | if (content::GetContentClient()->renderer()->OverrideCreatePlugin( |
| 1906 | this, frame, params, &plugin)) { |
| 1907 | return plugin; |
| 1908 | } |
| 1909 | |
[email protected] | a813c8e | 2011-10-08 01:34:11 | [diff] [blame] | 1910 | webkit::WebPluginInfo info; |
| 1911 | std::string mime_type; |
| 1912 | bool found = GetPluginInfo(params.url, frame->top()->document().url(), |
| 1913 | params.mimeType.utf8(), &info, &mime_type); |
| 1914 | if (!found) |
| 1915 | return NULL; |
| 1916 | |
| 1917 | WebPluginParams params_to_use = params; |
| 1918 | params_to_use.mimeType = WebString::fromUTF8(mime_type); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 1919 | return CreatePlugin(frame, info, params_to_use); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1920 | } |
| 1921 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1922 | WebSharedWorker* RenderViewImpl::createSharedWorker( |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 1923 | WebFrame* frame, const WebURL& url, const WebString& name, |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 1924 | unsigned long long document_id) { |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 1925 | |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 1926 | int route_id = MSG_ROUTING_NONE; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 1927 | bool exists = false; |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 1928 | bool url_mismatch = false; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 1929 | ViewHostMsg_CreateWorker_Params params; |
| 1930 | params.url = url; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 1931 | params.name = name; |
| 1932 | params.document_id = document_id; |
| 1933 | params.render_view_route_id = routing_id_; |
| 1934 | params.route_id = MSG_ROUTING_NONE; |
[email protected] | f9bc9c0 | 2010-05-24 19:19:23 | [diff] [blame] | 1935 | params.script_resource_appcache_id = 0; |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 1936 | Send(new ViewHostMsg_LookupSharedWorker( |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 1937 | params, &exists, &route_id, &url_mismatch)); |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 1938 | if (url_mismatch) { |
| 1939 | return NULL; |
| 1940 | } else { |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 1941 | return new WebSharedWorkerProxy(RenderThreadImpl::current(), |
[email protected] | 0791d3a | 2010-01-28 01:28:49 | [diff] [blame] | 1942 | document_id, |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 1943 | exists, |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 1944 | route_id, |
| 1945 | routing_id_); |
| 1946 | } |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 1947 | } |
| 1948 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1949 | WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1950 | WebFrame* frame, WebMediaPlayerClient* client) { |
[email protected] | 16e923d | 2011-04-30 00:41:44 | [diff] [blame] | 1951 | FOR_EACH_OBSERVER( |
| 1952 | RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
[email protected] | 7198402c | 2011-04-11 12:15:17 | [diff] [blame] | 1953 | |
[email protected] | bb6fd40 | 2011-12-09 02:45:44 | [diff] [blame] | 1954 | media::MessageLoopFactory* message_loop_factory = |
| 1955 | new media::MessageLoopFactoryImpl(); |
| 1956 | media::FilterCollection* collection = new media::FilterCollection(); |
| 1957 | RenderMediaLog* render_media_log = new RenderMediaLog(); |
[email protected] | 457d834 | 2010-10-23 01:20:37 | [diff] [blame] | 1958 | |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 1959 | RenderAudioSourceProvider* audio_source_provider = NULL; |
| 1960 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1961 | // Add in any custom filter factories first. |
| 1962 | const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 1963 | if (!cmd_line->HasSwitch(switches::kDisableAudio)) { |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 1964 | // audio_source_provider is a "provider" to WebKit, and a sink |
| 1965 | // from the perspective of the audio renderer. |
| 1966 | audio_source_provider = new RenderAudioSourceProvider(); |
| 1967 | |
| 1968 | // Add the chrome specific audio renderer, using audio_source_provider |
| 1969 | // as the sink. |
| 1970 | AudioRendererImpl* audio_renderer = |
| 1971 | new AudioRendererImpl(audio_source_provider); |
| 1972 | collection->AddAudioRenderer(audio_renderer); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1973 | } |
| 1974 | |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 1975 | #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 1976 | // Currently only cros/arm has any HW video decode support in |
| 1977 | // GpuVideoDecodeAccelerator so we don't even try to use it on other |
| 1978 | // platforms. This is a startup-time optimization. When new VDA |
| 1979 | // implementations are added, relax the #if above. |
| 1980 | WebKit::WebGraphicsContext3D* wk_context3d = webview()->graphicsContext3D(); |
| 1981 | if (wk_context3d) { |
| 1982 | WebGraphicsContext3DCommandBufferImpl* context3d = |
| 1983 | static_cast<WebGraphicsContext3DCommandBufferImpl*>(wk_context3d); |
| 1984 | GpuChannelHost* gpu_channel_host = |
| 1985 | RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 1986 | content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| 1987 | collection->AddVideoDecoder(new media::GpuVideoDecoder( |
[email protected] | 8d435928 | 2012-01-14 00:53:31 | [diff] [blame] | 1988 | message_loop_factory->GetMessageLoop("GpuVideoDecoder"), |
| 1989 | new RendererGpuVideoDecoderFactories( |
| 1990 | gpu_channel_host, context3d->context()->AsWeakPtr()))); |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 1991 | } |
| 1992 | #endif |
| 1993 | |
[email protected] | da952fd | 2012-01-13 03:49:25 | [diff] [blame] | 1994 | webkit_media::WebMediaPlayerImpl* media_player = |
| 1995 | content::GetContentClient()->renderer()->OverrideCreateWebMediaPlayer( |
| 1996 | this, frame, client, AsWeakPtr(), collection, audio_source_provider, |
| 1997 | message_loop_factory, media_stream_impl_.get(), render_media_log); |
| 1998 | if (!media_player) { |
[email protected] | cec4eb8 | 2012-01-12 17:51:56 | [diff] [blame] | 1999 | media_player = new webkit_media::WebMediaPlayerImpl( |
[email protected] | da952fd | 2012-01-13 03:49:25 | [diff] [blame] | 2000 | frame, client, AsWeakPtr(), collection, audio_source_provider, |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 2001 | message_loop_factory, media_stream_impl_.get(), render_media_log); |
[email protected] | bb6fd40 | 2011-12-09 02:45:44 | [diff] [blame] | 2002 | } |
[email protected] | cec4eb8 | 2012-01-12 17:51:56 | [diff] [blame] | 2003 | return media_player; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2004 | } |
| 2005 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2006 | WebApplicationCacheHost* RenderViewImpl::createApplicationCacheHost( |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2007 | WebFrame* frame, WebApplicationCacheHostClient* client) { |
[email protected] | cdeeeb2 | 2012-01-11 07:44:23 | [diff] [blame] | 2008 | if (!frame || !frame->view()) |
| 2009 | return NULL; |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2010 | return new RendererWebApplicationCacheHostImpl( |
| 2011 | FromWebView(frame->view()), client, |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 2012 | RenderThreadImpl::current()->appcache_dispatcher()->backend_proxy()); |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2013 | } |
| 2014 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2015 | WebCookieJar* RenderViewImpl::cookieJar(WebFrame* frame) { |
[email protected] | 8ff18107 | 2010-11-29 17:09:38 | [diff] [blame] | 2016 | return &cookie_jar_; |
| 2017 | } |
| 2018 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2019 | void RenderViewImpl::frameDetached(WebFrame* frame) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 2020 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameDetached(frame)); |
[email protected] | 5041f98 | 2010-08-11 21:40:45 | [diff] [blame] | 2021 | } |
| 2022 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2023 | void RenderViewImpl::willClose(WebFrame* frame) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 2024 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameWillClose(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2025 | } |
| 2026 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2027 | void RenderViewImpl::loadURLExternally( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2028 | WebFrame* frame, const WebURLRequest& request, |
| 2029 | WebNavigationPolicy policy) { |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2030 | loadURLExternally(frame, request, policy, WebString()); |
| 2031 | } |
| 2032 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2033 | void RenderViewImpl::loadURLExternally( |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2034 | WebFrame* frame, const WebURLRequest& request, |
| 2035 | WebNavigationPolicy policy, |
| 2036 | const WebString& suggested_name) { |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2037 | GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 2038 | if (policy == WebKit::WebNavigationPolicyDownload) { |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2039 | Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, |
| 2040 | suggested_name)); |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2041 | } else { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2042 | OpenURL(frame, request.url(), |
| 2043 | Referrer(referrer, getReferrerPolicyFromRequest(request)), policy); |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2044 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2045 | } |
| 2046 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2047 | WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2048 | WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
[email protected] | 65b95cd | 2009-10-09 05:10:22 | [diff] [blame] | 2049 | const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 2050 | // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. |
| 2051 | if (is_swapped_out_) { |
| 2052 | DCHECK(request.url() == GURL("about:swappedout")); |
| 2053 | return default_policy; |
| 2054 | } |
| 2055 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2056 | // Webkit is asking whether to navigate to a new URL. |
| 2057 | // This is fine normally, except if we're showing UI from one security |
| 2058 | // context and they're trying to navigate to a different context. |
| 2059 | const GURL& url = request.url(); |
| 2060 | |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 2061 | // A content initiated navigation may have originated from a link-click, |
| 2062 | // script, drag-n-drop operation, etc. |
| 2063 | bool is_content_initiated = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2064 | DocumentState::FromDataSource(frame->provisionalDataSource())-> |
| 2065 | navigation_state()->is_content_initiated(); |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 2066 | |
[email protected] | a8c269a | 2011-10-25 20:17:22 | [diff] [blame] | 2067 | // Experimental: |
| 2068 | // If --enable-strict-site-isolation is enabled, send all top-level |
| 2069 | // navigations to the browser to let it swap processes when crossing site |
| 2070 | // boundaries. This is currently expected to break some script calls and |
| 2071 | // navigations, such as form submissions. |
| 2072 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | 313b80bd | 2011-11-23 03:49:10 | [diff] [blame] | 2073 | if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && |
| 2074 | !frame->parent() && (is_content_initiated || is_redirect)) { |
| 2075 | WebString origin_str = frame->document().securityOrigin().toString(); |
| 2076 | GURL frame_url(origin_str.utf8().data()); |
| 2077 | // TODO(cevans): revisit whether this origin check is still necessary once |
| 2078 | // crbug.com/101395 is fixed. |
| 2079 | if (frame_url.GetOrigin() != url.GetOrigin()) { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2080 | Referrer referrer( |
| 2081 | GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2082 | getReferrerPolicyFromRequest(request)); |
[email protected] | 313b80bd | 2011-11-23 03:49:10 | [diff] [blame] | 2083 | OpenURL(frame, url, referrer, default_policy); |
| 2084 | return WebKit::WebNavigationPolicyIgnore; |
| 2085 | } |
[email protected] | a8c269a | 2011-10-25 20:17:22 | [diff] [blame] | 2086 | } |
| 2087 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2088 | // If the browser is interested, then give it a chance to look at top level |
[email protected] | 3a8eecb | 2010-04-22 23:56:30 | [diff] [blame] | 2089 | // navigations. |
[email protected] | 5f000f27 | 2012-01-19 05:25:08 | [diff] [blame] | 2090 | if (is_content_initiated) { |
| 2091 | bool browser_handles_top_level_requests = |
| 2092 | renderer_preferences_.browser_handles_top_level_requests && |
| 2093 | IsNonLocalTopLevelNavigation(url, frame, type); |
| 2094 | if (browser_handles_top_level_requests || |
| 2095 | renderer_preferences_.browser_handles_all_requests) { |
| 2096 | Referrer referrer( |
| 2097 | GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2098 | getReferrerPolicyFromRequest(request)); |
| 2099 | // Reset these counters as the RenderView could be reused for the next |
| 2100 | // navigation. |
| 2101 | page_id_ = -1; |
| 2102 | last_page_id_sent_to_browser_ = -1; |
| 2103 | OpenURL(frame, url, referrer, default_policy); |
| 2104 | return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2105 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2106 | } |
| 2107 | |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2108 | // 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] | 2109 | // an extension or app origin, leaving a WebUI page, etc). We only care about |
[email protected] | 8f4da8c | 2011-02-09 19:49:57 | [diff] [blame] | 2110 | // top-level navigations within the current tab (as opposed to, for example, |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2111 | // opening a new window). But we sometimes navigate to about:blank to clear a |
| 2112 | // tab, and we want to still allow that. |
| 2113 | // |
[email protected] | 8f4da8c | 2011-02-09 19:49:57 | [diff] [blame] | 2114 | // Note: we do this only for GET requests because our mechanism for switching |
| 2115 | // processes only issues GET requests. In particular, POST requests don't |
| 2116 | // work, because this mechanism does not preserve form POST data. If it |
| 2117 | // becomes necessary to support process switching for POST requests, we will |
| 2118 | // need to send the request's httpBody data up to the browser process, and |
| 2119 | // issue a special POST navigation in WebKit (via |
| 2120 | // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl |
| 2121 | // for examples of how to send the httpBody data. |
[email protected] | 2762a1b | 2011-12-09 15:25:22 | [diff] [blame] | 2122 | if (!frame->parent() && is_content_initiated && |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2123 | default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 2124 | request.httpMethod() == "GET" && !url.SchemeIs(chrome::kAboutScheme)) { |
| 2125 | bool send_referrer = false; |
| 2126 | bool should_fork = |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 2127 | (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) || |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2128 | frame->isViewSourceModeEnabled() || |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2129 | url.SchemeIs(chrome::kViewSourceScheme); |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 2130 | |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2131 | if (!should_fork) { |
| 2132 | // Give the embedder a chance. |
[email protected] | d55c238 | 2011-08-18 23:10:36 | [diff] [blame] | 2133 | bool is_initial_navigation = page_id_ == -1; |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2134 | should_fork = content::GetContentClient()->renderer()->ShouldFork( |
[email protected] | d55c238 | 2011-08-18 23:10:36 | [diff] [blame] | 2135 | frame, url, is_content_initiated, is_initial_navigation, |
| 2136 | &send_referrer); |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2137 | } |
| 2138 | |
| 2139 | if (should_fork) { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2140 | Referrer referrer( |
| 2141 | GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
| 2142 | getReferrerPolicyFromRequest(request)); |
| 2143 | OpenURL( |
| 2144 | frame, url, send_referrer ? referrer : Referrer(), default_policy); |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 2145 | return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2146 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2147 | } |
| 2148 | |
[email protected] | 43763f98 | 2011-08-26 18:33:40 | [diff] [blame] | 2149 | // Use the frame's original request's URL rather than the document's URL for |
| 2150 | // this check. For a popup, the document's URL may become the opener window's |
| 2151 | // URL if the opener has called document.write. See http://crbug.com/93517. |
| 2152 | GURL old_url(frame->dataSource()->request().url()); |
| 2153 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2154 | // Detect when a page is "forking" a new tab that can be safely rendered in |
| 2155 | // its own process. This is done by sites like Gmail that try to open links |
| 2156 | // in new windows without script connections back to the original page. We |
| 2157 | // treat such cases as browser navigations (in which we will create a new |
| 2158 | // renderer for a cross-site navigation), rather than WebKit navigations. |
| 2159 | // |
| 2160 | // We use the following heuristic to decide whether to fork a new page in its |
| 2161 | // own process: |
| 2162 | // The parent page must open a new tab to about:blank, set the new tab's |
| 2163 | // window.opener to null, and then redirect the tab to a cross-site URL using |
| 2164 | // JavaScript. |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 2165 | // |
| 2166 | // TODO(creis): Deprecate this logic once we can rely on rel=noreferrer |
| 2167 | // (see below). |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2168 | bool is_fork = |
| 2169 | // Must start from a tab showing about:blank, which is later redirected. |
[email protected] | a6b960ad97 | 2010-09-01 19:53:58 | [diff] [blame] | 2170 | old_url == GURL(chrome::kAboutBlankURL) && |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2171 | // Must be the first real navigation of the tab. |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2172 | historyBackListCount() < 1 && |
| 2173 | historyForwardListCount() < 1 && |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2174 | // The parent page must have set the child's window.opener to null before |
| 2175 | // redirecting to the desired URL. |
| 2176 | frame->opener() == NULL && |
| 2177 | // Must be a top-level frame. |
| 2178 | frame->parent() == NULL && |
| 2179 | // Must not have issued the request from this page. |
| 2180 | is_content_initiated && |
| 2181 | // Must be targeted at the current tab. |
| 2182 | default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 2183 | // Must be a JavaScript navigation, which appears as "other". |
| 2184 | type == WebKit::WebNavigationTypeOther; |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 2185 | |
| 2186 | // Recognize if this navigation is from a link with rel=noreferrer and |
| 2187 | // target=_blank attributes, in which case the opener will be suppressed. If |
| 2188 | // so, it is safe to load cross-site pages in a separate process, so we |
| 2189 | // should let the browser handle it. |
| 2190 | bool is_noreferrer_and_blank_target = |
| 2191 | // Frame should be top level and not yet navigated. |
| 2192 | frame->parent() == NULL && |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2193 | frame->document().url().isEmpty() && |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 2194 | historyBackListCount() < 1 && |
| 2195 | historyForwardListCount() < 1 && |
| 2196 | // Links with rel=noreferrer will have no Referer field, and their |
| 2197 | // resulting frame will have its window.opener suppressed. |
| 2198 | // TODO(creis): should add a request.httpReferrer() method to help avoid |
| 2199 | // typos on the unusual spelling of Referer. |
| 2200 | request.httpHeaderField(WebString::fromUTF8("Referer")).isNull() && |
| 2201 | opener_suppressed_ && |
| 2202 | frame->opener() == NULL && |
| 2203 | // Links with target=_blank will have no name. |
| 2204 | frame->name().isNull() && |
| 2205 | // Another frame (with a non-empty creator) should have initiated the |
| 2206 | // request, targeted at this frame. |
| 2207 | !creator_url_.is_empty() && |
| 2208 | is_content_initiated && |
| 2209 | default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 2210 | type == WebKit::WebNavigationTypeOther; |
| 2211 | |
| 2212 | if (is_fork || is_noreferrer_and_blank_target) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2213 | // Open the URL via the browser, not via WebKit. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2214 | OpenURL(frame, url, Referrer(), default_policy); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2215 | return WebKit::WebNavigationPolicyIgnore; |
| 2216 | } |
| 2217 | |
| 2218 | return default_policy; |
| 2219 | } |
| 2220 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2221 | bool RenderViewImpl::canHandleRequest( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2222 | WebFrame* frame, const WebURLRequest& request) { |
| 2223 | // We allow WebKit to think that everything can be handled even though |
| 2224 | // browser-side we limit what we load. |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2225 | return true; |
| 2226 | } |
| 2227 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2228 | WebURLError RenderViewImpl::cannotHandleRequestError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2229 | WebFrame* frame, const WebURLRequest& request) { |
| 2230 | NOTREACHED(); // Since we said we can handle all requests. |
| 2231 | return WebURLError(); |
| 2232 | } |
| 2233 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2234 | WebURLError RenderViewImpl::cancelledError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2235 | WebFrame* frame, const WebURLRequest& request) { |
| 2236 | WebURLError error; |
| 2237 | error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2238 | error.reason = net::ERR_ABORTED; |
| 2239 | error.unreachableURL = request.url(); |
| 2240 | return error; |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2241 | } |
| 2242 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2243 | void RenderViewImpl::unableToImplementPolicyWithError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2244 | WebFrame*, const WebURLError&) { |
| 2245 | NOTREACHED(); // Since we said we can handle all requests. |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2246 | } |
| 2247 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2248 | void RenderViewImpl::willSendSubmitEvent(WebKit::WebFrame* frame, |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2249 | const WebKit::WebFormElement& form) { |
| 2250 | // Some login forms have onSubmit handlers that put a hash of the password |
| 2251 | // into a hidden field and then clear the password. (Issue 28910.) |
| 2252 | // This method gets called before any of those handlers run, so save away |
| 2253 | // a copy of the password in case it gets lost. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2254 | DocumentState* document_state = |
| 2255 | DocumentState::FromDataSource(frame->dataSource()); |
| 2256 | document_state->set_password_form_data( |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2257 | PasswordFormDomManager::CreatePasswordForm(form)); |
| 2258 | } |
| 2259 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2260 | void RenderViewImpl::willSubmitForm(WebFrame* frame, |
| 2261 | const WebFormElement& form) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2262 | DocumentState* document_state = |
| 2263 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 2264 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2265 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2266 | if (navigation_state->transition_type() == content::PAGE_TRANSITION_LINK) |
| 2267 | navigation_state->set_transition_type(content::PAGE_TRANSITION_FORM_SUBMIT); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2268 | |
| 2269 | // Save these to be processed when the ensuing navigation is committed. |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 2270 | WebSearchableFormData web_searchable_form_data(form); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2271 | document_state->set_searchable_form_url(web_searchable_form_data.url()); |
| 2272 | document_state->set_searchable_form_encoding( |
[email protected] | b7910b3a | 2010-01-13 18:33:21 | [diff] [blame] | 2273 | web_searchable_form_data.encoding().utf8()); |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2274 | PasswordForm* password_form_data = |
| 2275 | PasswordFormDomManager::CreatePasswordForm(form); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2276 | document_state->set_password_form_data(password_form_data); |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2277 | |
[email protected] | 098c95cb | 2011-04-28 16:49:01 | [diff] [blame] | 2278 | // In order to save the password that the user actually typed and not one |
| 2279 | // that may have gotten transformed by the site prior to submit, recover it |
| 2280 | // from the form contents already stored by |willSendSubmitEvent| into the |
| 2281 | // dataSource's NavigationState (as opposed to the provisionalDataSource's, |
| 2282 | // which is what we're storing into now.) |
| 2283 | if (password_form_data) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2284 | DocumentState* old_document_state = |
| 2285 | DocumentState::FromDataSource(frame->dataSource()); |
| 2286 | if (old_document_state) { |
| 2287 | PasswordForm* old_form_data = old_document_state->password_form_data(); |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2288 | if (old_form_data && old_form_data->action == password_form_data->action) |
| 2289 | password_form_data->password_value = old_form_data->password_value; |
| 2290 | } |
| 2291 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2292 | |
[email protected] | 2a5b173 | 2011-04-01 23:55:55 | [diff] [blame] | 2293 | FOR_EACH_OBSERVER( |
| 2294 | RenderViewObserver, observers_, WillSubmitForm(frame, form)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2295 | } |
| 2296 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2297 | void RenderViewImpl::willPerformClientRedirect( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2298 | WebFrame* frame, const WebURL& from, const WebURL& to, double interval, |
| 2299 | double fire_time) { |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2300 | FOR_EACH_OBSERVER( |
| 2301 | RenderViewObserver, observers_, |
| 2302 | WillPerformClientRedirect(frame, from, to, interval, fire_time)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2303 | } |
| 2304 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2305 | void RenderViewImpl::didCancelClientRedirect(WebFrame* frame) { |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2306 | FOR_EACH_OBSERVER( |
| 2307 | RenderViewObserver, observers_, DidCancelClientRedirect(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2308 | } |
| 2309 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2310 | void RenderViewImpl::didCompleteClientRedirect( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2311 | WebFrame* frame, const WebURL& from) { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2312 | if (!frame->parent()) { |
| 2313 | WebDataSource* ds = frame->provisionalDataSource(); |
| 2314 | // If there's no provisional data source, it's a reference fragment |
| 2315 | // navigation. |
| 2316 | completed_client_redirect_src_ = Referrer( |
| 2317 | from, ds ? getReferrerPolicyFromRequest(ds->request()) : |
| 2318 | frame->referrerPolicy()); |
| 2319 | } |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2320 | FOR_EACH_OBSERVER( |
| 2321 | RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2322 | } |
| 2323 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2324 | void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2325 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2326 | if (!document_state) { |
| 2327 | document_state = new DocumentState; |
| 2328 | ds->setExtraData(document_state); |
| 2329 | } |
| 2330 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2331 | // The rest of RenderView assumes that a WebDataSource will always have a |
| 2332 | // non-null NavigationState. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2333 | bool content_initiated = !pending_navigation_params_.get(); |
| 2334 | if (content_initiated) |
| 2335 | document_state->set_navigation_state( |
| 2336 | NavigationState::CreateContentInitiated()); |
| 2337 | else |
| 2338 | PopulateStateFromPendingNavigationParams(document_state); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2339 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2340 | // DocumentState::referred_by_prefetcher_ is true if we are |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2341 | // navigating from a page that used prefetching using a link on that |
| 2342 | // page. We are early enough in the request process here that we |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2343 | // can still see the DocumentState of the previous page and set |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2344 | // this value appropriately. |
| 2345 | // TODO(gavinp): catch the important case of navigation in a new |
| 2346 | // renderer process. |
| 2347 | if (webview()) { |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 2348 | if (WebFrame* old_frame = webview()->mainFrame()) { |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2349 | const WebURLRequest& original_request = ds->originalRequest(); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2350 | const GURL referrer( |
| 2351 | original_request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 2352 | if (!referrer.is_empty() && |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2353 | DocumentState::FromDataSource( |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2354 | old_frame->dataSource())->was_prefetcher()) { |
| 2355 | for (;old_frame;old_frame = old_frame->traverseNext(false)) { |
| 2356 | WebDataSource* old_frame_ds = old_frame->dataSource(); |
| 2357 | if (old_frame_ds && referrer == GURL(old_frame_ds->request().url())) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2358 | document_state->set_was_referred_by_prefetcher(true); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2359 | break; |
| 2360 | } |
| 2361 | } |
| 2362 | } |
| 2363 | } |
| 2364 | } |
| 2365 | |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2366 | if (content_initiated) { |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2367 | const WebURLRequest& request = ds->request(); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2368 | switch (request.cachePolicy()) { |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2369 | case WebURLRequest::UseProtocolCachePolicy: // normal load. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2370 | document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2371 | break; |
| 2372 | case WebURLRequest::ReloadIgnoringCacheData: // reload. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2373 | document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2374 | break; |
| 2375 | case WebURLRequest::ReturnCacheDataElseLoad: // allow stale data. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2376 | document_state->set_load_type( |
| 2377 | DocumentState::LINK_LOAD_CACHE_STALE_OK); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2378 | break; |
| 2379 | case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2380 | document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2381 | break; |
| 2382 | } |
| 2383 | } |
[email protected] | fa7b6b54 | 2009-11-03 05:02:30 | [diff] [blame] | 2384 | |
[email protected] | 946a003 | 2011-03-31 18:42:28 | [diff] [blame] | 2385 | FOR_EACH_OBSERVER( |
| 2386 | RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2387 | } |
| 2388 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2389 | void RenderViewImpl::PopulateStateFromPendingNavigationParams( |
| 2390 | DocumentState* document_state) { |
| 2391 | const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
| 2392 | |
| 2393 | if (document_state->request_time().is_null()) |
| 2394 | document_state->set_request_time(params.request_time); |
| 2395 | |
| 2396 | // A navigation resulting from loading a javascript URL should not be treated |
| 2397 | // as a browser initiated event. Instead, we want it to look as if the page |
| 2398 | // initiated any load resulting from JS execution. |
| 2399 | if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { |
| 2400 | NavigationState* navigation_state = NavigationState::CreateBrowserInitiated( |
| 2401 | params.page_id, |
| 2402 | params.pending_history_list_offset, |
| 2403 | params.transition); |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 2404 | navigation_state->set_transferred_request_child_id( |
| 2405 | params.transferred_request_child_id); |
| 2406 | navigation_state->set_transferred_request_request_id( |
| 2407 | params.transferred_request_request_id); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2408 | if (params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { |
| 2409 | // We're doing a load of a page that was restored from the last session. |
| 2410 | // By default this prefers the cache over loading (LOAD_PREFERRING_CACHE) |
| 2411 | // which can result in stale data for pages that are set to expire. We |
| 2412 | // explicitly override that by setting the policy here so that as |
| 2413 | // necessary we load from the network. |
| 2414 | document_state->set_cache_policy_override( |
| 2415 | WebURLRequest::UseProtocolCachePolicy); |
| 2416 | } |
| 2417 | document_state->set_navigation_state(navigation_state); |
| 2418 | } else { |
| 2419 | document_state->set_navigation_state( |
| 2420 | NavigationState::CreateContentInitiated()); |
| 2421 | } |
| 2422 | |
| 2423 | if (IsReload(params)) |
| 2424 | document_state->set_load_type(DocumentState::RELOAD); |
| 2425 | else if (!params.state.empty()) |
| 2426 | document_state->set_load_type(DocumentState::HISTORY_LOAD); |
| 2427 | else |
| 2428 | document_state->set_load_type(DocumentState::NORMAL_LOAD); |
| 2429 | |
| 2430 | pending_navigation_params_.reset(); |
| 2431 | } |
| 2432 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2433 | void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2434 | WebDataSource* ds = frame->provisionalDataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2435 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2436 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2437 | // Update the request time if WebKit has better knowledge of it. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2438 | if (document_state->request_time().is_null()) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2439 | double event_time = ds->triggeringEventTime(); |
| 2440 | if (event_time != 0.0) |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2441 | document_state->set_request_time(Time::FromDoubleT(event_time)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2442 | } |
| 2443 | |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2444 | // Start time is only set after request time. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2445 | document_state->set_start_load_time(Time::Now()); |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2446 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2447 | bool is_top_most = !frame->parent(); |
| 2448 | if (is_top_most) { |
| 2449 | navigation_gesture_ = frame->isProcessingUserGesture() ? |
[email protected] | cd44809 | 2010-12-06 23:49:13 | [diff] [blame] | 2450 | NavigationGestureUser : NavigationGestureAuto; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2451 | |
| 2452 | // Make sure redirect tracking state is clear for the new load. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2453 | completed_client_redirect_src_ = Referrer(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2454 | } else if (frame->parent()->isLoading()) { |
| 2455 | // 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] | 2456 | // load an error page. See didFailProvisionalLoad. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2457 | document_state->navigation_state()->set_transition_type( |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2458 | content::PAGE_TRANSITION_AUTO_SUBFRAME); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2459 | } |
| 2460 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2461 | FOR_EACH_OBSERVER( |
| 2462 | RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); |
| 2463 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2464 | Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 2465 | routing_id_, frame->identifier(), is_top_most, GetOpenerUrl(), |
[email protected] | eacb080b | 2011-05-22 19:40:26 | [diff] [blame] | 2466 | ds->request().url())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2467 | } |
| 2468 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2469 | void RenderViewImpl::didReceiveServerRedirectForProvisionalLoad( |
| 2470 | WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2471 | if (frame->parent()) |
| 2472 | return; |
| 2473 | // Received a redirect on the main frame. |
| 2474 | WebDataSource* data_source = frame->provisionalDataSource(); |
| 2475 | if (!data_source) { |
| 2476 | // Should only be invoked when we have a data source. |
| 2477 | NOTREACHED(); |
| 2478 | return; |
| 2479 | } |
| 2480 | std::vector<GURL> redirects; |
| 2481 | GetRedirectChain(data_source, &redirects); |
| 2482 | if (redirects.size() >= 2) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 2483 | Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_, |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 2484 | GetOpenerUrl(), redirects[redirects.size() - 2], redirects.back())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2485 | } |
| 2486 | } |
| 2487 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2488 | void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, |
| 2489 | const WebURLError& error) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2490 | // Notify the browser that we failed a provisional load with an error. |
| 2491 | // |
| 2492 | // Note: It is important this notification occur before DidStopLoading so the |
| 2493 | // SSL manager can react to the provisional load failure before being |
| 2494 | // notified the load stopped. |
| 2495 | // |
| 2496 | WebDataSource* ds = frame->provisionalDataSource(); |
| 2497 | DCHECK(ds); |
| 2498 | |
| 2499 | const WebURLRequest& failed_request = ds->request(); |
| 2500 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2501 | FOR_EACH_OBSERVER( |
| 2502 | RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); |
| 2503 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2504 | bool show_repost_interstitial = |
| 2505 | (error.reason == net::ERR_CACHE_MISS && |
| 2506 | EqualsASCII(failed_request.httpMethod(), "POST")); |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 2507 | |
| 2508 | ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 2509 | params.frame_id = frame->identifier(); |
| 2510 | params.is_main_frame = !frame->parent(); |
| 2511 | params.error_code = error.reason; |
| 2512 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 2513 | failed_request, |
| 2514 | error, |
| 2515 | NULL, |
| 2516 | ¶ms.error_description); |
| 2517 | params.url = error.unreachableURL; |
| 2518 | params.showing_repost_interstitial = show_repost_interstitial; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2519 | Send(new ViewHostMsg_DidFailProvisionalLoadWithError( |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 2520 | routing_id_, params)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2521 | |
| 2522 | // Don't display an error page if this is simply a cancelled load. Aside |
| 2523 | // from being dumb, WebCore doesn't expect it and it will cause a crash. |
| 2524 | if (error.reason == net::ERR_ABORTED) |
| 2525 | return; |
[email protected] | b553edd5 | 2012-01-10 12:15:23 | [diff] [blame] | 2526 | // Don't display an error message if the request was handled by an |
| 2527 | // external protocol handler. |
| 2528 | if (error.reason == net::ERR_UNKNOWN_URL_SCHEME) |
| 2529 | return; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2530 | |
| 2531 | // Make sure we never show errors in view source mode. |
| 2532 | frame->enableViewSourceMode(false); |
| 2533 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2534 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2535 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2536 | |
| 2537 | // If this is a failed back/forward/reload navigation, then we need to do a |
| 2538 | // 'replace' load. This is necessary to avoid messing up session history. |
| 2539 | // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| 2540 | // as session history is concerned. |
| 2541 | // |
| 2542 | // AUTO_SUBFRAME loads should always be treated as loads that do not advance |
| 2543 | // the page id. |
| 2544 | // |
| 2545 | bool replace = |
| 2546 | navigation_state->pending_page_id() != -1 || |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2547 | navigation_state->transition_type() == |
| 2548 | content::PAGE_TRANSITION_AUTO_SUBFRAME; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2549 | |
| 2550 | // If we failed on a browser initiated request, then make sure that our error |
| 2551 | // page load is regarded as the same browser initiated request. |
| 2552 | if (!navigation_state->is_content_initiated()) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2553 | pending_navigation_params_.reset(new ViewMsg_Navigate_Params); |
| 2554 | pending_navigation_params_->page_id = |
| 2555 | navigation_state->pending_page_id(); |
| 2556 | pending_navigation_params_->pending_history_list_offset = |
| 2557 | navigation_state->pending_history_list_offset(); |
| 2558 | pending_navigation_params_->transition = |
| 2559 | navigation_state->transition_type(); |
| 2560 | pending_navigation_params_->request_time = |
| 2561 | document_state->request_time(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2562 | } |
| 2563 | |
| 2564 | // Provide the user with a more helpful error page? |
| 2565 | if (MaybeLoadAlternateErrorPage(frame, error, replace)) |
| 2566 | return; |
| 2567 | |
| 2568 | // Fallback to a local error page. |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 2569 | LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2570 | } |
| 2571 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2572 | void RenderViewImpl::didReceiveDocumentData( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2573 | WebFrame* frame, const char* data, size_t data_len, |
| 2574 | bool& prevent_default) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2575 | DocumentState* document_state = |
| 2576 | DocumentState::FromDataSource(frame->dataSource()); |
| 2577 | document_state->set_use_error_page(false); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2578 | } |
| 2579 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2580 | void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, |
| 2581 | bool is_new_navigation) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2582 | DocumentState* document_state = |
| 2583 | DocumentState::FromDataSource(frame->dataSource()); |
| 2584 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2585 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2586 | if (document_state->commit_load_time().is_null()) |
| 2587 | document_state->set_commit_load_time(Time::Now()); |
| 2588 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2589 | if (is_new_navigation) { |
[email protected] | e15f68073 | 2010-11-23 22:30:20 | [diff] [blame] | 2590 | // When we perform a new navigation, we need to update the last committed |
| 2591 | // session history entry with state for the page we are leaving. |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2592 | UpdateSessionHistory(frame); |
| 2593 | |
| 2594 | // We bump our Page ID to correspond with the new session history entry. |
| 2595 | page_id_ = next_page_id_++; |
| 2596 | |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 2597 | // Advance our offset in session history, applying the length limit. There |
| 2598 | // is now no forward history. |
| 2599 | history_list_offset_++; |
[email protected] | 9966325b | 2011-04-18 05:00:10 | [diff] [blame] | 2600 | if (history_list_offset_ >= content::kMaxSessionHistoryEntries) |
| 2601 | history_list_offset_ = content::kMaxSessionHistoryEntries - 1; |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 2602 | history_list_length_ = history_list_offset_ + 1; |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 2603 | history_page_ids_.resize(history_list_length_, -1); |
| 2604 | history_page_ids_[history_list_offset_] = page_id_; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2605 | } else { |
| 2606 | // Inspect the navigation_state on this frame to see if the navigation |
| 2607 | // corresponds to a session history navigation... Note: |frame| may or |
| 2608 | // may not be the toplevel frame, but for the case of capturing session |
| 2609 | // history, the first committed frame suffices. We keep track of whether |
| 2610 | // we've seen this commit before so that only capture session history once |
| 2611 | // per navigation. |
| 2612 | // |
| 2613 | // Note that we need to check if the page ID changed. In the case of a |
| 2614 | // reload, the page ID doesn't change, and UpdateSessionHistory gets the |
| 2615 | // previous URL and the current page ID, which would be wrong. |
| 2616 | if (navigation_state->pending_page_id() != -1 && |
| 2617 | navigation_state->pending_page_id() != page_id_ && |
| 2618 | !navigation_state->request_committed()) { |
| 2619 | // This is a successful session history navigation! |
| 2620 | UpdateSessionHistory(frame); |
| 2621 | page_id_ = navigation_state->pending_page_id(); |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 2622 | |
| 2623 | history_list_offset_ = navigation_state->pending_history_list_offset(); |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 2624 | |
| 2625 | // If the history list is valid, our list of page IDs should be correct. |
| 2626 | DCHECK(history_list_length_ <= 0 || |
| 2627 | history_list_offset_ < 0 || |
| 2628 | history_list_offset_ >= history_list_length_ || |
| 2629 | history_page_ids_[history_list_offset_] == page_id_); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2630 | } |
| 2631 | } |
| 2632 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2633 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2634 | DidCommitProvisionalLoad(frame, is_new_navigation)); |
| 2635 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2636 | // Remember that we've already processed this request, so we don't update |
| 2637 | // the session history again. We do this regardless of whether this is |
| 2638 | // a session history navigation, because if we attempted a session history |
| 2639 | // navigation without valid HistoryItem state, WebCore will think it is a |
| 2640 | // new navigation. |
| 2641 | navigation_state->set_request_committed(true); |
| 2642 | |
| 2643 | UpdateURL(frame); |
| 2644 | |
| 2645 | // If this committed load was initiated by a client redirect, we're |
| 2646 | // at the last stop now, so clear it. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2647 | completed_client_redirect_src_ = Referrer(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2648 | |
| 2649 | // Check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2650 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2651 | } |
| 2652 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2653 | void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
[email protected] | 9966325b | 2011-04-18 05:00:10 | [diff] [blame] | 2654 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2655 | DidClearWindowObject(frame)); |
| 2656 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2657 | GURL frame_url = frame->document().url(); |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 2658 | if ((enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) && |
[email protected] | bfa83eb8 | 2010-10-06 08:41:25 | [diff] [blame] | 2659 | (frame_url.SchemeIs(chrome::kChromeUIScheme) || |
| 2660 | frame_url.SchemeIs(chrome::kDataScheme))) { |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 2661 | GetWebUIBindings()->BindToJavascript(frame, "chrome"); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2662 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2663 | } |
| 2664 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2665 | void RenderViewImpl::didCreateDocumentElement(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2666 | // Notify the browser about non-blank documents loading in the top frame. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2667 | GURL url = frame->document().url(); |
[email protected] | e0d48158 | 2009-09-15 21:06:25 | [diff] [blame] | 2668 | if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2669 | if (frame == webview()->mainFrame()) |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2670 | Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
| 2671 | } |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2672 | |
| 2673 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2674 | DidCreateDocumentElement(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2675 | } |
| 2676 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2677 | void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title, |
| 2678 | WebTextDirection direction) { |
[email protected] | a49e10b | 2011-08-01 23:57:46 | [diff] [blame] | 2679 | UpdateTitle(frame, title, direction); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2680 | |
| 2681 | // Also check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2682 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2683 | } |
| 2684 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2685 | void RenderViewImpl::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { |
[email protected] | 42054a25 | 2011-05-17 18:02:13 | [diff] [blame] | 2686 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2687 | DidChangeIcon(frame, type)); |
[email protected] | 5019ef1 | 2010-04-27 17:26:58 | [diff] [blame] | 2688 | } |
| 2689 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2690 | void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2691 | WebDataSource* ds = frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2692 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2693 | document_state->set_finish_document_load_time(Time::Now()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2694 | |
[email protected] | 622474d | 2010-11-04 09:21:08 | [diff] [blame] | 2695 | Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2696 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2697 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2698 | DidFinishDocumentLoad(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2699 | |
| 2700 | // Check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2701 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2702 | } |
| 2703 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2704 | void RenderViewImpl::didHandleOnloadEvents(WebFrame* frame) { |
[email protected] | 2549749 | 2010-09-11 15:15:08 | [diff] [blame] | 2705 | if (webview()->mainFrame() == frame) { |
| 2706 | Send(new ViewHostMsg_DocumentOnLoadCompletedInMainFrame(routing_id_, |
| 2707 | page_id_)); |
| 2708 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2709 | } |
| 2710 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2711 | void RenderViewImpl::didFailLoad(WebFrame* frame, const WebURLError& error) { |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 2712 | WebDataSource* ds = frame->dataSource(); |
| 2713 | DCHECK(ds); |
| 2714 | |
| 2715 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2716 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 2717 | |
| 2718 | const WebURLRequest& failed_request = ds->request(); |
| 2719 | string16 error_description; |
| 2720 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 2721 | failed_request, |
| 2722 | error, |
| 2723 | NULL, |
| 2724 | &error_description); |
| 2725 | Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, |
| 2726 | frame->identifier(), |
| 2727 | failed_request.url(), |
| 2728 | !frame->parent(), |
| 2729 | error.reason, |
| 2730 | error_description)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2731 | } |
| 2732 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2733 | void RenderViewImpl::didFinishLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2734 | WebDataSource* ds = frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2735 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2736 | if (document_state->finish_load_time().is_null()) |
| 2737 | document_state->set_finish_load_time(Time::Now()); |
[email protected] | 4d44a1c | 2010-04-28 19:20:41 | [diff] [blame] | 2738 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 2739 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); |
[email protected] | fdd94a0 | 2010-11-05 08:07:17 | [diff] [blame] | 2740 | |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 2741 | Send(new ViewHostMsg_DidFinishLoad(routing_id_, |
| 2742 | frame->identifier(), |
| 2743 | ds->request().url(), |
| 2744 | !frame->parent())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2745 | } |
| 2746 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2747 | void RenderViewImpl::didNavigateWithinPage( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2748 | WebFrame* frame, bool is_new_navigation) { |
| 2749 | // If this was a reference fragment navigation that we initiated, then we |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2750 | // 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] | 2751 | // update the ExtraData on the datasource so that others who read the |
| 2752 | // ExtraData will get the new NavigationState. Similarly, if we did not |
| 2753 | // initiate this navigation, then we need to take care to reset any pre- |
| 2754 | // existing navigation state to a content-initiated navigation state. |
| 2755 | // DidCreateDataSource conveniently takes care of this for us. |
| 2756 | didCreateDataSource(frame, frame->dataSource()); |
| 2757 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2758 | DocumentState* document_state = |
| 2759 | DocumentState::FromDataSource(frame->dataSource()); |
| 2760 | NavigationState* new_state = document_state->navigation_state(); |
[email protected] | af15bed | 2010-08-25 21:12:09 | [diff] [blame] | 2761 | new_state->set_was_within_same_page(true); |
| 2762 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2763 | didCommitProvisionalLoad(frame, is_new_navigation); |
| 2764 | |
[email protected] | 750fcf87 | 2011-08-03 23:10:47 | [diff] [blame] | 2765 | WebDataSource* datasource = frame->view()->mainFrame()->dataSource(); |
| 2766 | UpdateTitle(frame, datasource->pageTitle(), datasource->pageTitleDirection()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2767 | } |
| 2768 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2769 | void RenderViewImpl::didUpdateCurrentHistoryItem(WebFrame* frame) { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 2770 | StartNavStateSyncTimerIfNecessary(); |
[email protected] | 476b6f8 | 2009-09-10 21:00:59 | [diff] [blame] | 2771 | } |
| 2772 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2773 | void RenderViewImpl::assignIdentifierToRequest( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2774 | WebFrame* frame, unsigned identifier, const WebURLRequest& request) { |
| 2775 | // Ignore |
| 2776 | } |
| 2777 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2778 | void RenderViewImpl::willSendRequest(WebFrame* frame, |
| 2779 | unsigned identifier, |
| 2780 | WebURLRequest& request, |
| 2781 | const WebURLResponse& redirect_response) { |
[email protected] | 5e36967 | 2009-11-03 23:48:30 | [diff] [blame] | 2782 | WebFrame* top_frame = frame->top(); |
| 2783 | if (!top_frame) |
| 2784 | top_frame = frame; |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2785 | WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
| 2786 | WebDataSource* top_data_source = top_frame->dataSource(); |
| 2787 | WebDataSource* data_source = |
| 2788 | provisional_data_source ? provisional_data_source : top_data_source; |
[email protected] | 78d5cfe | 2011-02-04 08:43:22 | [diff] [blame] | 2789 | |
[email protected] | 78d5cfe | 2011-02-04 08:43:22 | [diff] [blame] | 2790 | GURL request_url(request.url()); |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2791 | GURL new_url; |
| 2792 | if (content::GetContentClient()->renderer()->WillSendRequest( |
| 2793 | frame, request_url, &new_url)) { |
| 2794 | request.setURL(WebURL(new_url)); |
[email protected] | 78d5cfe | 2011-02-04 08:43:22 | [diff] [blame] | 2795 | } |
| 2796 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2797 | content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2798 | DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 2799 | NavigationState* navigation_state = document_state->navigation_state(); |
| 2800 | if (document_state) { |
| 2801 | if (document_state->is_cache_policy_override_set()) |
| 2802 | request.setCachePolicy(document_state->cache_policy_override()); |
| 2803 | transition_type = navigation_state->transition_type(); |
[email protected] | 5e36967 | 2009-11-03 23:48:30 | [diff] [blame] | 2804 | } |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2805 | |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 2806 | request.setExtraData( |
[email protected] | 537fbe0 | 2011-11-24 00:58:06 | [diff] [blame] | 2807 | new RequestExtraData(frame->referrerPolicy(), |
| 2808 | (frame == top_frame), |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 2809 | frame->identifier(), |
| 2810 | frame->parent() == top_frame, |
| 2811 | frame->parent() ? frame->parent()->identifier() : -1, |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 2812 | transition_type, |
| 2813 | navigation_state->transferred_request_child_id(), |
| 2814 | navigation_state->transferred_request_request_id())); |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 2815 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2816 | DocumentState* top_document_state = |
| 2817 | DocumentState::FromDataSource(top_data_source); |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 2818 | // TODO(gavinp): separate out prefetching and prerender field trials |
| 2819 | // if the rel=prerender rel type is sticking around. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2820 | if (top_document_state && |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 2821 | (request.targetType() == WebURLRequest::TargetIsPrefetch || |
| 2822 | request.targetType() == WebURLRequest::TargetIsPrerender)) |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2823 | top_document_state->set_was_prefetcher(true); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2824 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2825 | request.setRequestorID(routing_id_); |
[email protected] | cd44809 | 2010-12-06 23:49:13 | [diff] [blame] | 2826 | request.setHasUserGesture(frame->isProcessingUserGesture()); |
| 2827 | |
[email protected] | 0a8db0d | 2011-04-13 15:15:40 | [diff] [blame] | 2828 | if (!renderer_preferences_.enable_referrers) |
[email protected] | 7deade4 | 2010-03-05 09:33:13 | [diff] [blame] | 2829 | request.clearHTTPHeaderField("Referer"); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2830 | } |
| 2831 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2832 | void RenderViewImpl::didReceiveResponse( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2833 | WebFrame* frame, unsigned identifier, const WebURLResponse& response) { |
[email protected] | fa0a343 | 2010-03-30 16:53:49 | [diff] [blame] | 2834 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2835 | // Only do this for responses that correspond to a provisional data source |
| 2836 | // of the top-most frame. If we have a provisional data source, then we |
| 2837 | // can't have any sub-resources yet, so we know that this response must |
| 2838 | // correspond to a frame load. |
| 2839 | if (!frame->provisionalDataSource() || frame->parent()) |
| 2840 | return; |
| 2841 | |
| 2842 | // 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] | 2843 | // the server's error page. |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2844 | if (frame->isViewSourceModeEnabled()) |
| 2845 | return; |
| 2846 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2847 | DocumentState* document_state = |
| 2848 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 2849 | int http_status_code = response.httpStatusCode(); |
[email protected] | 65041fa | 2010-05-21 06:56:53 | [diff] [blame] | 2850 | |
[email protected] | 972ebdff | 2010-06-10 22:59:07 | [diff] [blame] | 2851 | // Record page load flags. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2852 | document_state->set_was_fetched_via_spdy(response.wasFetchedViaSPDY()); |
| 2853 | document_state->set_was_npn_negotiated(response.wasNpnNegotiated()); |
| 2854 | document_state->set_was_alternate_protocol_available( |
[email protected] | 193b0b89 | 2010-06-26 03:57:57 | [diff] [blame] | 2855 | response.wasAlternateProtocolAvailable()); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2856 | document_state->set_was_fetched_via_proxy(response.wasFetchedViaProxy()); |
| 2857 | document_state->set_http_status_code(http_status_code); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 2858 | // Whether or not the http status code actually corresponds to an error is |
| 2859 | // only checked when the page is done loading, if |use_error_page| is |
| 2860 | // still true. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2861 | document_state->set_use_error_page(true); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2862 | } |
| 2863 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2864 | void RenderViewImpl::didFinishResourceLoad( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2865 | WebFrame* frame, unsigned identifier) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2866 | DocumentState* document_state = |
| 2867 | DocumentState::FromDataSource(frame->dataSource()); |
| 2868 | if (!document_state->use_error_page()) |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2869 | return; |
| 2870 | |
[email protected] | 7bfc153f | 2011-09-23 22:00:20 | [diff] [blame] | 2871 | // Do not show error page when DevTools is attached. |
| 2872 | if (devtools_agent_->IsAttached()) |
| 2873 | return; |
| 2874 | |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 2875 | // Display error page, if appropriate. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2876 | int http_status_code = document_state->http_status_code(); |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 2877 | if (http_status_code == 404) { |
| 2878 | // On 404s, try a remote search page as a fallback. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2879 | const GURL& document_url = frame->document().url(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2880 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2881 | const GURL& error_page_url = |
| 2882 | GetAlternateErrorPageURL(document_url, HTTP_404); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 2883 | if (error_page_url.is_valid()) { |
| 2884 | WebURLError original_error; |
[email protected] | 2e9706c | 2011-06-09 16:49:47 | [diff] [blame] | 2885 | original_error.domain = "http"; |
| 2886 | original_error.reason = 404; |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2887 | original_error.unreachableURL = document_url; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2888 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2889 | document_state->set_alt_error_page_fetcher( |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 2890 | new AltErrorPageResourceFetcher( |
| 2891 | error_page_url, frame, original_error, |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 2892 | base::Bind(&RenderViewImpl::AltErrorPageFinished, |
| 2893 | base::Unretained(this)))); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 2894 | return; |
| 2895 | } |
| 2896 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2897 | |
[email protected] | e6a2ce5 | 2011-10-08 01:40:13 | [diff] [blame] | 2898 | std::string error_domain; |
| 2899 | if (content::GetContentClient()->renderer()->HasErrorPage( |
| 2900 | http_status_code, &error_domain)) { |
| 2901 | WebURLError error; |
| 2902 | error.unreachableURL = frame->document().url(); |
| 2903 | error.domain = WebString::fromUTF8(error_domain); |
| 2904 | error.reason = http_status_code; |
| 2905 | |
| 2906 | LoadNavigationErrorPage( |
| 2907 | frame, frame->dataSource()->request(), error, std::string(), true); |
| 2908 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2909 | } |
| 2910 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2911 | void RenderViewImpl::didFailResourceLoad( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2912 | WebFrame* frame, unsigned identifier, const WebURLError& error) { |
| 2913 | // Ignore |
| 2914 | } |
| 2915 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2916 | void RenderViewImpl::didLoadResourceFromMemoryCache( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2917 | WebFrame* frame, const WebURLRequest& request, |
| 2918 | const WebURLResponse& response) { |
[email protected] | 8470329 | 2011-10-28 20:44:00 | [diff] [blame] | 2919 | // The recipients of this message have no use for data: URLs: they don't |
| 2920 | // affect the page's insecure content list and are not in the disk cache. To |
| 2921 | // prevent large (1M+) data: URLs from crashing in the IPC system, we simply |
| 2922 | // filter them out here. |
| 2923 | GURL url(request.url()); |
| 2924 | if (url.SchemeIs("data")) |
| 2925 | return; |
| 2926 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2927 | // Let the browser know we loaded a resource from the memory cache. This |
| 2928 | // message is needed to display the correct SSL indicators. |
| 2929 | Send(new ViewHostMsg_DidLoadResourceFromMemoryCache( |
| 2930 | routing_id_, |
[email protected] | 8470329 | 2011-10-28 20:44:00 | [diff] [blame] | 2931 | url, |
[email protected] | 7043596 | 2011-08-02 20:13:28 | [diff] [blame] | 2932 | response.securityInfo(), |
| 2933 | request.httpMethod().utf8(), |
| 2934 | ResourceType::FromTargetType(request.targetType()))); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2935 | } |
| 2936 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2937 | void RenderViewImpl::didDisplayInsecureContent(WebFrame* frame) { |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 2938 | Send(new ViewHostMsg_DidDisplayInsecureContent(routing_id_)); |
| 2939 | } |
| 2940 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2941 | void RenderViewImpl::didRunInsecureContent( |
[email protected] | 9277111 | 2011-01-20 00:13:02 | [diff] [blame] | 2942 | WebFrame* frame, const WebSecurityOrigin& origin, const WebURL& target) { |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 2943 | Send(new ViewHostMsg_DidRunInsecureContent( |
| 2944 | routing_id_, |
[email protected] | 9277111 | 2011-01-20 00:13:02 | [diff] [blame] | 2945 | origin.toString().utf8(), |
| 2946 | target)); |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 2947 | } |
| 2948 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2949 | void RenderViewImpl::didAdoptURLLoader(WebKit::WebURLLoader* loader) { |
[email protected] | b00ba70 | 2011-08-17 01:41:03 | [diff] [blame] | 2950 | webkit_glue::WebURLLoaderImpl* loader_impl = |
| 2951 | static_cast<webkit_glue::WebURLLoaderImpl*>(loader); |
| 2952 | loader_impl->UpdateRoutingId(routing_id_); |
| 2953 | } |
| 2954 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2955 | void RenderViewImpl::didExhaustMemoryAvailableForScript(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2956 | Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); |
| 2957 | } |
| 2958 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2959 | void RenderViewImpl::didCreateScriptContext(WebFrame* frame, |
| 2960 | v8::Handle<v8::Context> context, |
| 2961 | int world_id) { |
[email protected] | 5bc1093 | 2011-09-21 21:03:30 | [diff] [blame] | 2962 | content::GetContentClient()->renderer()->DidCreateScriptContext( |
| 2963 | frame, context, world_id); |
[email protected] | 0c882b28 | 2009-10-07 17:01:28 | [diff] [blame] | 2964 | } |
| 2965 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2966 | void RenderViewImpl::willReleaseScriptContext(WebFrame* frame, |
| 2967 | v8::Handle<v8::Context> context, |
| 2968 | int world_id) { |
[email protected] | 5bc1093 | 2011-09-21 21:03:30 | [diff] [blame] | 2969 | content::GetContentClient()->renderer()->WillReleaseScriptContext( |
| 2970 | frame, context, world_id); |
[email protected] | 0c882b28 | 2009-10-07 17:01:28 | [diff] [blame] | 2971 | } |
| 2972 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2973 | void RenderViewImpl::CheckPreferredSize() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 2974 | // We don't always want to send the change messages over IPC, only if we've |
| 2975 | // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 2976 | // message. |
| 2977 | if (!send_preferred_size_changes_ || !webview()) |
| 2978 | return; |
| 2979 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2980 | gfx::Size size(webview()->mainFrame()->contentsPreferredWidth(), |
| 2981 | webview()->mainFrame()->documentElementScrollHeight()); |
[email protected] | 8205d74 | 2010-10-22 23:51:53 | [diff] [blame] | 2982 | |
| 2983 | // In the presence of zoom, these sizes are still reported as if unzoomed, |
| 2984 | // so we need to adjust. |
| 2985 | double zoom_factor = WebView::zoomLevelToZoomFactor(webview()->zoomLevel()); |
| 2986 | size.set_width(static_cast<int>(size.width() * zoom_factor)); |
| 2987 | size.set_height(static_cast<int>(size.height() * zoom_factor)); |
| 2988 | |
[email protected] | 6b5576cb | 2011-12-05 08:23:00 | [diff] [blame] | 2989 | if (!size.height()) |
| 2990 | size.set_height(preferred_size_.height()); |
| 2991 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2992 | if (size == preferred_size_) |
| 2993 | return; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 2994 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 2995 | preferred_size_ = size; |
| 2996 | Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
| 2997 | preferred_size_)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2998 | } |
| 2999 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3000 | void RenderViewImpl::EnsureMediaStreamImpl() { |
| 3001 | #if defined(ENABLE_P2P_APIS) |
| 3002 | if (!p2p_socket_dispatcher_) |
| 3003 | p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
| 3004 | #endif |
| 3005 | |
| 3006 | if (!media_stream_dispatcher_) |
| 3007 | media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
| 3008 | |
| 3009 | if (!media_stream_impl_.get()) { |
| 3010 | MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory(); |
| 3011 | media_stream_impl_ = new MediaStreamImpl( |
| 3012 | media_stream_dispatcher_, |
| 3013 | p2p_socket_dispatcher_, |
| 3014 | RenderThreadImpl::current()->video_capture_impl_manager(), |
| 3015 | factory); |
| 3016 | } |
| 3017 | } |
| 3018 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3019 | void RenderViewImpl::didChangeContentsSize(WebFrame* frame, |
| 3020 | const WebSize& size) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3021 | if (webview()->mainFrame() != frame) |
| 3022 | return; |
| 3023 | WebView* frameView = frame->view(); |
| 3024 | if (!frameView) |
| 3025 | return; |
| 3026 | |
| 3027 | bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); |
| 3028 | bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); |
| 3029 | |
| 3030 | if (has_horizontal_scrollbar != cached_has_main_frame_horizontal_scrollbar_ || |
| 3031 | has_vertical_scrollbar != cached_has_main_frame_vertical_scrollbar_) { |
| 3032 | Send(new ViewHostMsg_DidChangeScrollbarsForMainFrame( |
| 3033 | routing_id_, has_horizontal_scrollbar, has_vertical_scrollbar)); |
| 3034 | |
| 3035 | cached_has_main_frame_horizontal_scrollbar_ = has_horizontal_scrollbar; |
| 3036 | cached_has_main_frame_vertical_scrollbar_ = has_vertical_scrollbar; |
| 3037 | } |
| 3038 | } |
| 3039 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3040 | void RenderViewImpl::UpdateScrollState(WebFrame* frame) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3041 | WebSize offset = frame->scrollOffset(); |
| 3042 | WebSize minimum_offset = frame->minimumScrollOffset(); |
| 3043 | WebSize maximum_offset = frame->maximumScrollOffset(); |
| 3044 | |
| 3045 | bool is_pinned_to_left = offset.width <= minimum_offset.width; |
| 3046 | bool is_pinned_to_right = offset.width >= maximum_offset.width; |
| 3047 | |
| 3048 | if (is_pinned_to_left != cached_is_main_frame_pinned_to_left_ || |
| 3049 | is_pinned_to_right != cached_is_main_frame_pinned_to_right_) { |
| 3050 | Send(new ViewHostMsg_DidChangeScrollOffsetPinningForMainFrame( |
| 3051 | routing_id_, is_pinned_to_left, is_pinned_to_right)); |
| 3052 | |
| 3053 | cached_is_main_frame_pinned_to_left_ = is_pinned_to_left; |
| 3054 | cached_is_main_frame_pinned_to_right_ = is_pinned_to_right; |
| 3055 | } |
| 3056 | } |
| 3057 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3058 | void RenderViewImpl::didChangeScrollOffset(WebFrame* frame) { |
[email protected] | 143dcd59 | 2009-11-06 21:33:49 | [diff] [blame] | 3059 | StartNavStateSyncTimerIfNecessary(); |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3060 | |
| 3061 | if (webview()->mainFrame() == frame) |
| 3062 | UpdateScrollState(frame); |
| 3063 | } |
| 3064 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3065 | void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3066 | Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); |
[email protected] | 143dcd59 | 2009-11-06 21:33:49 | [diff] [blame] | 3067 | } |
| 3068 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3069 | void RenderViewImpl::reportFindInPageMatchCount(int request_id, int count, |
| 3070 | bool final_update) { |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 3071 | int active_match_ordinal = -1; // -1 = don't update active match ordinal |
| 3072 | if (!count) |
| 3073 | active_match_ordinal = 0; |
| 3074 | |
| 3075 | IPC::Message* msg = new ViewHostMsg_Find_Reply( |
| 3076 | routing_id_, |
| 3077 | request_id, |
| 3078 | count, |
| 3079 | gfx::Rect(), |
| 3080 | active_match_ordinal, |
| 3081 | final_update); |
| 3082 | |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3083 | // If we have a message that has been queued up, then we should just replace |
| 3084 | // it. The ACK from the browser will make sure it gets sent when the browser |
| 3085 | // wants it. |
| 3086 | if (queued_find_reply_message_.get()) { |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3087 | queued_find_reply_message_.reset(msg); |
| 3088 | } else { |
| 3089 | // Send the search result over to the browser process. |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 3090 | Send(msg); |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3091 | } |
| 3092 | } |
| 3093 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3094 | void RenderViewImpl::reportFindInPageSelection(int request_id, |
| 3095 | int active_match_ordinal, |
| 3096 | const WebRect& selection_rect) { |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3097 | // Send the search result over to the browser process. |
| 3098 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 3099 | request_id, |
| 3100 | -1, |
| 3101 | selection_rect, |
| 3102 | active_match_ordinal, |
| 3103 | false)); |
| 3104 | } |
| 3105 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3106 | void RenderViewImpl::openFileSystem( |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3107 | WebFrame* frame, |
| 3108 | WebFileSystem::Type type, |
| 3109 | long long size, |
[email protected] | d275d7a | 2010-11-03 01:34:49 | [diff] [blame] | 3110 | bool create, |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3111 | WebFileSystemCallbacks* callbacks) { |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3112 | DCHECK(callbacks); |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3113 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3114 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3115 | if (origin.isUnique()) { |
| 3116 | // Unique origins cannot store persistent state. |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3117 | callbacks->didFail(WebKit::WebFileErrorAbort); |
| 3118 | return; |
| 3119 | } |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3120 | |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3121 | ChildThread::current()->file_system_dispatcher()->OpenFileSystem( |
| 3122 | GURL(origin.toString()), static_cast<fileapi::FileSystemType>(type), |
[email protected] | d275d7a | 2010-11-03 01:34:49 | [diff] [blame] | 3123 | size, create, new WebFileSystemCallbackDispatcher(callbacks)); |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3124 | } |
| 3125 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3126 | void RenderViewImpl::queryStorageUsageAndQuota( |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3127 | WebFrame* frame, |
| 3128 | WebStorageQuotaType type, |
| 3129 | WebStorageQuotaCallbacks* callbacks) { |
| 3130 | DCHECK(frame); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3131 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3132 | if (origin.isUnique()) { |
| 3133 | // Unique origins cannot store persistent state. |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3134 | callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); |
| 3135 | return; |
| 3136 | } |
| 3137 | ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota( |
[email protected] | 666bcc5c | 2011-07-29 06:25:53 | [diff] [blame] | 3138 | GURL(origin.toString()), |
| 3139 | static_cast<quota::StorageType>(type), |
| 3140 | QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3141 | } |
| 3142 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3143 | void RenderViewImpl::requestStorageQuota( |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3144 | WebFrame* frame, |
| 3145 | WebStorageQuotaType type, |
| 3146 | unsigned long long requested_size, |
| 3147 | WebStorageQuotaCallbacks* callbacks) { |
| 3148 | DCHECK(frame); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3149 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3150 | if (origin.isUnique()) { |
| 3151 | // Unique origins cannot store persistent state. |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3152 | callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); |
| 3153 | return; |
| 3154 | } |
| 3155 | ChildThread::current()->quota_dispatcher()->RequestStorageQuota( |
[email protected] | 666bcc5c | 2011-07-29 06:25:53 | [diff] [blame] | 3156 | routing_id(), GURL(origin.toString()), |
| 3157 | static_cast<quota::StorageType>(type), requested_size, |
| 3158 | QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3159 | } |
| 3160 | |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3161 | void RenderViewImpl::registerIntentService( |
| 3162 | WebKit::WebFrame* frame, const WebKit::WebIntentServiceInfo& service) { |
[email protected] | e6e35cd | 2011-12-22 19:37:06 | [diff] [blame] | 3163 | string16 title = service.title(); |
| 3164 | if (title.empty()) |
| 3165 | title = webview()->mainFrame()->document().title(); |
| 3166 | |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3167 | Send(new IntentsHostMsg_RegisterIntentService(routing_id_, |
| 3168 | service.action(), |
| 3169 | service.type(), |
| 3170 | service.url().spec().utf16(), |
[email protected] | e6e35cd | 2011-12-22 19:37:06 | [diff] [blame] | 3171 | title, |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3172 | service.disposition())); |
| 3173 | } |
| 3174 | |
| 3175 | void RenderViewImpl::dispatchIntent(WebKit::WebFrame* frame, |
[email protected] | 592e20b | 2012-01-20 05:53:44 | [diff] [blame^] | 3176 | const WebKit::WebIntentRequest& request) { |
| 3177 | WebKit::WebIntent intent(request.intent()); |
[email protected] | 67810501 | 2011-12-09 04:01:21 | [diff] [blame] | 3178 | webkit_glue::WebIntentData intent_data(intent); |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3179 | Send(new IntentsHostMsg_WebIntentDispatch( |
| 3180 | routing_id_, intent_data, intent.identifier())); |
| 3181 | } |
| 3182 | |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 3183 | // WebKit::WebPageSerializerClient implementation ------------------------------ |
| 3184 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3185 | void RenderViewImpl::didSerializeDataForFrame( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 3186 | const WebURL& frame_url, |
| 3187 | const WebCString& data, |
| 3188 | WebPageSerializerClient::PageSerializationStatus status) { |
| 3189 | Send(new ViewHostMsg_SendSerializedHtmlData( |
| 3190 | routing_id(), |
| 3191 | frame_url, |
| 3192 | data.data(), |
| 3193 | static_cast<int32>(status))); |
| 3194 | } |
| 3195 | |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3196 | // content::RenderView implementation ------------------------------------------ |
| 3197 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3198 | bool RenderViewImpl::Send(IPC::Message* message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3199 | return RenderWidget::Send(message); |
| 3200 | } |
| 3201 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3202 | int RenderViewImpl::GetRoutingId() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3203 | return routing_id_; |
| 3204 | } |
| 3205 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3206 | int RenderViewImpl::GetPageId() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3207 | return page_id_; |
| 3208 | } |
| 3209 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3210 | gfx::Size RenderViewImpl::GetSize() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3211 | return size(); |
| 3212 | } |
| 3213 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3214 | gfx::NativeViewId RenderViewImpl::GetHostWindow() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3215 | return host_window(); |
| 3216 | } |
| 3217 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3218 | WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3219 | return webkit_preferences_; |
| 3220 | } |
| 3221 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3222 | WebKit::WebView* RenderViewImpl::GetWebView() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3223 | return webview(); |
| 3224 | } |
| 3225 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3226 | WebKit::WebNode RenderViewImpl::GetFocusedNode() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3227 | if (!webview()) |
| 3228 | return WebNode(); |
| 3229 | WebFrame* focused_frame = webview()->focusedFrame(); |
| 3230 | if (focused_frame) { |
| 3231 | WebDocument doc = focused_frame->document(); |
| 3232 | if (!doc.isNull()) |
| 3233 | return doc.focusedNode(); |
| 3234 | } |
| 3235 | |
| 3236 | return WebNode(); |
| 3237 | } |
| 3238 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3239 | WebKit::WebNode RenderViewImpl::GetContextMenuNode() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3240 | return context_menu_node_; |
| 3241 | } |
| 3242 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3243 | bool RenderViewImpl::IsEditableNode(const WebKit::WebNode& node) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3244 | bool is_editable_node = false; |
| 3245 | if (!node.isNull()) { |
| 3246 | if (node.isContentEditable()) { |
| 3247 | is_editable_node = true; |
| 3248 | } else if (node.isElementNode()) { |
| 3249 | is_editable_node = |
| 3250 | node.toConst<WebElement>().isTextFormControlElement(); |
| 3251 | } |
| 3252 | } |
| 3253 | return is_editable_node; |
| 3254 | } |
| 3255 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3256 | WebKit::WebPlugin* RenderViewImpl::CreatePlugin( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3257 | WebKit::WebFrame* frame, |
| 3258 | const webkit::WebPluginInfo& info, |
| 3259 | const WebKit::WebPluginParams& params) { |
| 3260 | bool pepper_plugin_was_registered = false; |
| 3261 | scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
| 3262 | pepper_delegate_.CreatePepperPluginModule(info, |
| 3263 | &pepper_plugin_was_registered)); |
| 3264 | if (pepper_plugin_was_registered) { |
| 3265 | if (!pepper_module) |
| 3266 | return NULL; |
| 3267 | return new webkit::ppapi::WebPluginImpl( |
| 3268 | pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); |
| 3269 | } |
| 3270 | |
| 3271 | return new webkit::npapi::WebPluginImpl( |
| 3272 | frame, params, info.path, AsWeakPtr()); |
| 3273 | } |
| 3274 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3275 | void RenderViewImpl::EvaluateScript(const string16& frame_xpath, |
| 3276 | const string16& jscript, |
| 3277 | int id, |
| 3278 | bool notify_result) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3279 | v8::Handle<v8::Value> result; |
| 3280 | WebFrame* web_frame = GetChildFrame(frame_xpath); |
| 3281 | if (web_frame) |
| 3282 | result = web_frame->executeScriptAndReturnValue(WebScriptSource(jscript)); |
| 3283 | if (notify_result) { |
| 3284 | ListValue list; |
| 3285 | if (!result.IsEmpty() && web_frame) { |
| 3286 | v8::HandleScope handle_scope; |
| 3287 | v8::Local<v8::Context> context = web_frame->mainWorldScriptContext(); |
| 3288 | v8::Context::Scope context_scope(context); |
| 3289 | V8ValueConverterImpl converter; |
| 3290 | converter.set_allow_date(true); |
| 3291 | converter.set_allow_regexp(true); |
| 3292 | list.Set(0, converter.FromV8Value(result, context)); |
| 3293 | } else { |
| 3294 | list.Set(0, Value::CreateNullValue()); |
| 3295 | } |
| 3296 | Send(new ViewHostMsg_ScriptEvalResponse(routing_id_, id, list)); |
| 3297 | } |
| 3298 | } |
| 3299 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3300 | bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3301 | return (!send_preferred_size_changes_ || |
| 3302 | (disable_scrollbars_size_limit_.width() <= width || |
| 3303 | disable_scrollbars_size_limit_.height() <= height)); |
| 3304 | } |
| 3305 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3306 | int RenderViewImpl::GetEnabledBindings() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3307 | return enabled_bindings_; |
| 3308 | } |
| 3309 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3310 | void RenderViewImpl::SetEnabledBindings(int enabled_bindings) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3311 | enabled_bindings_ = enabled_bindings; |
| 3312 | } |
| 3313 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3314 | bool RenderViewImpl::GetContentStateImmediately() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3315 | return send_content_state_immediately_; |
| 3316 | } |
| 3317 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3318 | float RenderViewImpl::GetFilteredTimePerFrame() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3319 | return filtered_time_per_frame(); |
| 3320 | } |
| 3321 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3322 | void RenderViewImpl::ShowContextMenu(WebKit::WebFrame* frame, |
| 3323 | const WebKit::WebContextMenuData& data) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3324 | showContextMenu(frame, data); |
| 3325 | } |
| 3326 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3327 | WebKit::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3328 | return visibilityState(); |
| 3329 | } |
| 3330 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3331 | void RenderViewImpl::RunModalAlertDialog(WebKit::WebFrame* frame, |
| 3332 | const WebKit::WebString& message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3333 | return runModalAlertDialog(frame, message); |
| 3334 | } |
| 3335 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3336 | void RenderViewImpl::LoadURLExternally( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3337 | WebKit::WebFrame* frame, |
| 3338 | const WebKit::WebURLRequest& request, |
| 3339 | WebKit::WebNavigationPolicy policy) { |
| 3340 | loadURLExternally(frame, request, policy); |
| 3341 | } |
| 3342 | |
| 3343 | // webkit_glue::WebPluginPageDelegate ------------------------------------------ |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 3344 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3345 | webkit::npapi::WebPluginDelegate* RenderViewImpl::CreatePluginDelegate( |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 3346 | const FilePath& file_path, |
| 3347 | const std::string& mime_type) { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3348 | if (!PluginChannelHost::IsListening()) |
| 3349 | return NULL; |
| 3350 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 3351 | bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); |
[email protected] | d032f49 | 2009-09-29 00:33:46 | [diff] [blame] | 3352 | if (in_process_plugin) { |
[email protected] | 7398dcc | 2011-09-06 21:40:32 | [diff] [blame] | 3353 | #if defined(OS_WIN) && !defined(USE_AURA) |
[email protected] | e8f7a18 | 2011-03-10 00:50:22 | [diff] [blame] | 3354 | return webkit::npapi::WebPluginDelegateImpl::Create( |
| 3355 | file_path, mime_type, gfx::NativeViewFromId(host_window_)); |
[email protected] | 6876dff | 2010-01-15 19:38:09 | [diff] [blame] | 3356 | #else |
[email protected] | 7398dcc | 2011-09-06 21:40:32 | [diff] [blame] | 3357 | // In-proc plugins aren't supported on non-Windows. |
[email protected] | e8f7a18 | 2011-03-10 00:50:22 | [diff] [blame] | 3358 | NOTIMPLEMENTED(); |
| 3359 | return NULL; |
[email protected] | 7b6616f | 2010-01-14 18:07:55 | [diff] [blame] | 3360 | #endif |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3361 | } |
| 3362 | |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 3363 | return new WebPluginDelegateProxy(mime_type, AsWeakPtr()); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3364 | } |
| 3365 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3366 | void RenderViewImpl::CreatedPluginWindow(gfx::PluginWindowHandle window) { |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 3367 | #if defined(USE_X11) |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 3368 | Send(new ViewHostMsg_CreatePluginContainer(routing_id(), window)); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3369 | #endif |
| 3370 | } |
| 3371 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3372 | void RenderViewImpl::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 3373 | #if defined(USE_X11) |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 3374 | Send(new ViewHostMsg_DestroyPluginContainer(routing_id(), window)); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3375 | #endif |
| 3376 | CleanupWindowInPluginMoves(window); |
| 3377 | } |
| 3378 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3379 | void RenderViewImpl::DidMovePlugin( |
| 3380 | const webkit::npapi::WebPluginGeometry& move) { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3381 | SchedulePluginMove(move); |
| 3382 | } |
| 3383 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3384 | void RenderViewImpl::DidStartLoadingForPlugin() { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3385 | // TODO(darin): Make is_loading_ be a counter! |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 3386 | didStartLoading(); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3387 | } |
| 3388 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3389 | void RenderViewImpl::DidStopLoadingForPlugin() { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3390 | // TODO(darin): Make is_loading_ be a counter! |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 3391 | didStopLoading(); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3392 | } |
| 3393 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3394 | WebCookieJar* RenderViewImpl::GetCookieJar() { |
[email protected] | b921cfd2 | 2010-02-25 16:57:51 | [diff] [blame] | 3395 | return &cookie_jar_; |
| 3396 | } |
| 3397 | |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 3398 | void RenderViewImpl::DidPlay(webkit_media::WebMediaPlayerImpl* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 3399 | Send(new ViewHostMsg_MediaNotification(routing_id_, |
| 3400 | reinterpret_cast<int64>(player), |
| 3401 | player->hasVideo(), |
| 3402 | player->hasAudio(), |
| 3403 | true)); |
| 3404 | } |
| 3405 | |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 3406 | void RenderViewImpl::DidPause(webkit_media::WebMediaPlayerImpl* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 3407 | Send(new ViewHostMsg_MediaNotification(routing_id_, |
| 3408 | reinterpret_cast<int64>(player), |
| 3409 | player->hasVideo(), |
| 3410 | player->hasAudio(), |
| 3411 | false)); |
| 3412 | } |
| 3413 | |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 3414 | void RenderViewImpl::PlayerGone(webkit_media::WebMediaPlayerImpl* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 3415 | DidPause(player); |
| 3416 | } |
| 3417 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3418 | void RenderViewImpl::SyncNavigationState() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3419 | if (!webview()) |
| 3420 | return; |
| 3421 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3422 | const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem(); |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 3423 | if (item.isNull()) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3424 | return; |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 3425 | |
| 3426 | Send(new ViewHostMsg_UpdateState( |
| 3427 | routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3428 | } |
| 3429 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3430 | void RenderViewImpl::SyncSelectionIfRequired() { |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3431 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 3432 | if (!frame) |
| 3433 | return; |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3434 | |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3435 | size_t location, length; |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 3436 | if (!webview()->caretOrSelectionRange(&location, &length)) |
| 3437 | return; |
| 3438 | |
| 3439 | string16 text; |
| 3440 | size_t offset; |
| 3441 | ui::Range range(location, location + length); |
| 3442 | |
| 3443 | if (webview()->textInputType() != WebKit::WebTextInputTypeNone) { |
| 3444 | // If current focused element is editable, we will send 100 more chars |
| 3445 | // before and after selection. It is for input method surrounding text |
| 3446 | // feature. |
| 3447 | if (location > kExtraCharsBeforeAndAfterSelection) |
| 3448 | offset = location - kExtraCharsBeforeAndAfterSelection; |
| 3449 | else |
| 3450 | offset = 0; |
| 3451 | length = location + length - offset + kExtraCharsBeforeAndAfterSelection; |
| 3452 | WebRange webrange = WebRange::fromDocumentRange(frame, offset, length); |
| 3453 | if (!webrange.isNull()) |
| 3454 | text = WebRange::fromDocumentRange(frame, offset, length).toPlainText(); |
| 3455 | } else { |
| 3456 | offset = location; |
| 3457 | text = frame->selectionAsText(); |
[email protected] | e8cdf353 | 2011-10-29 00:50:52 | [diff] [blame] | 3458 | // http://crbug.com/101435 |
| 3459 | // In some case, frame->selectionAsText() returned text's length is not |
| 3460 | // equal to the length returned from webview()->caretOrSelectionRange(). |
| 3461 | // So we have to set the range according to text.length(). |
| 3462 | range.set_end(range.start() + text.length()); |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3463 | } |
| 3464 | |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3465 | // Sometimes we get repeated didChangeSelection calls from webkit when |
| 3466 | // the selection hasn't actually changed. We don't want to report these |
| 3467 | // because it will cause us to continually claim the X clipboard. |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 3468 | if (selection_text_offset_ != offset || |
| 3469 | selection_range_ != range || |
| 3470 | selection_text_ != text) { |
| 3471 | selection_text_ = text; |
| 3472 | selection_text_offset_ = offset; |
| 3473 | selection_range_ = range; |
| 3474 | Send(new ViewHostMsg_SelectionChanged(routing_id_, text, offset, range)); |
| 3475 | } |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3476 | } |
| 3477 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3478 | GURL RenderViewImpl::GetAlternateErrorPageURL(const GURL& failed_url, |
| 3479 | ErrorPageType error_type) { |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 3480 | if (failed_url.SchemeIsSecure()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3481 | // If the URL that failed was secure, then the embedding web page was not |
| 3482 | // expecting a network attacker to be able to manipulate its contents. As |
| 3483 | // we fetch alternate error pages over HTTP, we would be allowing a network |
| 3484 | // attacker to manipulate the contents of the response if we tried to use |
| 3485 | // the link doctor here. |
[email protected] | 810a52ef | 2010-01-08 01:22:15 | [diff] [blame] | 3486 | return GURL(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3487 | } |
| 3488 | |
| 3489 | // Grab the base URL from the browser process. |
| 3490 | if (!alternate_error_page_url_.is_valid()) |
[email protected] | 810a52ef | 2010-01-08 01:22:15 | [diff] [blame] | 3491 | return GURL(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3492 | |
| 3493 | // Strip query params from the failed URL. |
| 3494 | GURL::Replacements remove_params; |
| 3495 | remove_params.ClearUsername(); |
| 3496 | remove_params.ClearPassword(); |
| 3497 | remove_params.ClearQuery(); |
| 3498 | remove_params.ClearRef(); |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 3499 | const GURL url_to_send = failed_url.ReplaceComponents(remove_params); |
[email protected] | 6fd28f64 | 2010-03-15 17:15:50 | [diff] [blame] | 3500 | std::string spec_to_send = url_to_send.spec(); |
| 3501 | // Notify link doctor of the url truncation by sending of "?" at the end. |
| 3502 | if (failed_url.has_query()) |
| 3503 | spec_to_send.append("?"); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3504 | |
| 3505 | // Construct the query params to send to link doctor. |
| 3506 | std::string params(alternate_error_page_url_.query()); |
| 3507 | params.append("&url="); |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 3508 | params.append(net::EscapeQueryParamValue(spec_to_send, true)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3509 | params.append("&sourceid=chrome"); |
| 3510 | params.append("&error="); |
| 3511 | switch (error_type) { |
| 3512 | case DNS_ERROR: |
| 3513 | params.append("dnserror"); |
| 3514 | break; |
| 3515 | |
| 3516 | case HTTP_404: |
| 3517 | params.append("http404"); |
| 3518 | break; |
| 3519 | |
[email protected] | 5df266ac | 2008-10-15 19:50:13 | [diff] [blame] | 3520 | case CONNECTION_ERROR: |
[email protected] | e1f934b | 2009-01-26 20:41:33 | [diff] [blame] | 3521 | params.append("connectionfailure"); |
[email protected] | 5df266ac | 2008-10-15 19:50:13 | [diff] [blame] | 3522 | break; |
| 3523 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3524 | default: |
| 3525 | NOTREACHED() << "unknown ErrorPageType"; |
| 3526 | } |
| 3527 | |
| 3528 | // OK, build the final url to return. |
| 3529 | GURL::Replacements link_doctor_params; |
| 3530 | link_doctor_params.SetQueryStr(params); |
| 3531 | GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params); |
| 3532 | return url; |
| 3533 | } |
| 3534 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3535 | GURL RenderViewImpl::GetOpenerUrl() const { |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 3536 | if (opener_id_ == MSG_ROUTING_NONE || opener_suppressed_) |
| 3537 | return GURL(); |
| 3538 | else |
| 3539 | return creator_url_; |
| 3540 | } |
| 3541 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3542 | WebUIBindings* RenderViewImpl::GetWebUIBindings() { |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 3543 | if (!web_ui_bindings_.get()) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3544 | web_ui_bindings_.reset(new WebUIBindings( |
| 3545 | static_cast<content::RenderView*>(this), routing_id_)); |
[email protected] | c091c2c | 2010-09-17 19:05:46 | [diff] [blame] | 3546 | } |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 3547 | return web_ui_bindings_.get(); |
[email protected] | c091c2c | 2010-09-17 19:05:46 | [diff] [blame] | 3548 | } |
| 3549 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3550 | WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 3551 | return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3552 | } |
| 3553 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3554 | void RenderViewImpl::OnFind(int request_id, const string16& search_text, |
| 3555 | const WebFindOptions& options) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3556 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3557 | |
[email protected] | 87254253 | 2011-06-23 00:43:16 | [diff] [blame] | 3558 | // Check if the plugin still exists in the document. |
| 3559 | if (main_frame->document().isPluginDocument() && |
| 3560 | GetWebPluginFromPluginDocument()) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3561 | if (options.findNext) { |
| 3562 | // Just navigate back/forward. |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 3563 | GetWebPluginFromPluginDocument()->selectFindResult(options.forward); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3564 | } else { |
[email protected] | afdbd14 | 2010-07-10 08:01:23 | [diff] [blame] | 3565 | if (GetWebPluginFromPluginDocument()->startFind( |
| 3566 | search_text, options.matchCase, request_id)) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3567 | } else { |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 3568 | // Send "no results". |
| 3569 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 3570 | request_id, |
| 3571 | 0, |
| 3572 | gfx::Rect(), |
| 3573 | 0, |
| 3574 | true)); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3575 | } |
| 3576 | } |
| 3577 | return; |
| 3578 | } |
| 3579 | |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 3580 | WebFrame* frame_after_main = main_frame->traverseNext(true); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3581 | WebFrame* focused_frame = webview()->focusedFrame(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3582 | WebFrame* search_frame = focused_frame; // start searching focused frame. |
| 3583 | |
| 3584 | bool multi_frame = (frame_after_main != main_frame); |
| 3585 | |
| 3586 | // If we have multiple frames, we don't want to wrap the search within the |
| 3587 | // frame, so we check here if we only have main_frame in the chain. |
| 3588 | bool wrap_within_frame = !multi_frame; |
| 3589 | |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 3590 | WebRect selection_rect; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3591 | bool result = false; |
| 3592 | |
[email protected] | 7830da3e | 2009-11-06 16:27:26 | [diff] [blame] | 3593 | // If something is selected when we start searching it means we cannot just |
| 3594 | // increment the current match ordinal; we need to re-generate it. |
| 3595 | WebRange current_selection = focused_frame->selectionRange(); |
| 3596 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3597 | do { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3598 | result = search_frame->find( |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3599 | request_id, search_text, options, wrap_within_frame, &selection_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3600 | |
| 3601 | if (!result) { |
| 3602 | // don't leave text selected as you move to the next frame. |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 3603 | search_frame->executeCommand(WebString::fromUTF8("Unselect")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3604 | |
| 3605 | // Find the next frame, but skip the invisible ones. |
| 3606 | do { |
| 3607 | // What is the next frame to search? (we might be going backwards). Note |
| 3608 | // that we specify wrap=true so that search_frame never becomes NULL. |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3609 | search_frame = options.forward ? |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 3610 | search_frame->traverseNext(true) : |
| 3611 | search_frame->traversePrevious(true); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3612 | } while (!search_frame->hasVisibleContent() && |
| 3613 | search_frame != focused_frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3614 | |
[email protected] | 884db41 | 2008-11-24 23:46:50 | [diff] [blame] | 3615 | // Make sure selection doesn't affect the search operation in new frame. |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 3616 | search_frame->executeCommand(WebString::fromUTF8("Unselect")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3617 | |
| 3618 | // If we have multiple frames and we have wrapped back around to the |
| 3619 | // focused frame, we need to search it once more allowing wrap within |
| 3620 | // the frame, otherwise it will report 'no match' if the focused frame has |
| 3621 | // reported matches, but no frames after the focused_frame contain a |
| 3622 | // match for the search word(s). |
| 3623 | if (multi_frame && search_frame == focused_frame) { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3624 | result = search_frame->find( |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3625 | request_id, search_text, options, true, // Force wrapping. |
| 3626 | &selection_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3627 | } |
| 3628 | } |
| 3629 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3630 | webview()->setFocusedFrame(search_frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3631 | } while (!result && search_frame != focused_frame); |
| 3632 | |
[email protected] | 7830da3e | 2009-11-06 16:27:26 | [diff] [blame] | 3633 | if (options.findNext && current_selection.isNull()) { |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3634 | // Force the main_frame to report the actual count. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3635 | main_frame->increaseMatchCount(0, request_id); |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3636 | } else { |
| 3637 | // If nothing is found, set result to "0 of 0", otherwise, set it to |
| 3638 | // "-1 of 1" to indicate that we found at least one item, but we don't know |
| 3639 | // yet what is active. |
| 3640 | int ordinal = result ? -1 : 0; // -1 here means, we might know more later. |
| 3641 | int match_count = result ? 1 : 0; // 1 here means possibly more coming. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3642 | |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3643 | // If we find no matches then this will be our last status update. |
| 3644 | // Otherwise the scoping effort will send more results. |
| 3645 | bool final_status_update = !result; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3646 | |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3647 | // Send the search result over to the browser process. |
[email protected] | 4f99913 | 2009-03-31 18:08:40 | [diff] [blame] | 3648 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3649 | request_id, |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3650 | match_count, |
| 3651 | selection_rect, |
| 3652 | ordinal, |
| 3653 | final_status_update)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3654 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3655 | // Scoping effort begins, starting with the mainframe. |
| 3656 | search_frame = main_frame; |
| 3657 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3658 | main_frame->resetMatchCount(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3659 | |
| 3660 | do { |
| 3661 | // Cancel all old scoping requests before starting a new one. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3662 | search_frame->cancelPendingScopingEffort(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3663 | |
| 3664 | // We don't start another scoping effort unless at least one match has |
| 3665 | // been found. |
| 3666 | if (result) { |
| 3667 | // Start new scoping request. If the scoping function determines that it |
| 3668 | // needs to scope, it will defer until later. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3669 | search_frame->scopeStringMatches(request_id, |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3670 | search_text, |
| 3671 | options, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3672 | true); // reset the tickmarks |
| 3673 | } |
| 3674 | |
| 3675 | // Iterate to the next frame. The frame will not necessarily scope, for |
| 3676 | // example if it is not visible. |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 3677 | search_frame = search_frame->traverseNext(true); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3678 | } while (search_frame != main_frame); |
| 3679 | } |
| 3680 | } |
| 3681 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 3682 | void RenderViewImpl::OnStopFinding(content::StopFindAction action) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3683 | WebView* view = webview(); |
| 3684 | if (!view) |
| 3685 | return; |
| 3686 | |
| 3687 | WebDocument doc = view->mainFrame()->document(); |
[email protected] | 87254253 | 2011-06-23 00:43:16 | [diff] [blame] | 3688 | if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 3689 | GetWebPluginFromPluginDocument()->stopFind(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3690 | return; |
| 3691 | } |
| 3692 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 3693 | bool clear_selection = action == content::STOP_FIND_ACTION_CLEAR_SELECTION; |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3694 | if (clear_selection) |
| 3695 | view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); |
| 3696 | |
| 3697 | WebFrame* frame = view->mainFrame(); |
| 3698 | while (frame) { |
| 3699 | frame->stopFinding(clear_selection); |
| 3700 | frame = frame->traverseNext(false); |
| 3701 | } |
| 3702 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 3703 | if (action == content::STOP_FIND_ACTION_ACTIVATE_SELECTION) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3704 | WebFrame* focused_frame = view->focusedFrame(); |
| 3705 | if (focused_frame) { |
| 3706 | WebDocument doc = focused_frame->document(); |
| 3707 | if (!doc.isNull()) { |
| 3708 | WebNode node = doc.focusedNode(); |
| 3709 | if (!node.isNull()) |
| 3710 | node.simulateClick(); |
| 3711 | } |
| 3712 | } |
| 3713 | } |
| 3714 | } |
| 3715 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3716 | void RenderViewImpl::OnFindReplyAck() { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3717 | // Check if there is any queued up request waiting to be sent. |
| 3718 | if (queued_find_reply_message_.get()) { |
| 3719 | // Send the search result over to the browser process. |
[email protected] | d22d873 | 2010-05-04 19:24:42 | [diff] [blame] | 3720 | Send(queued_find_reply_message_.release()); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3721 | } |
| 3722 | } |
| 3723 | |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3724 | void RenderViewImpl::OnZoom(content::PageZoom zoom) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 3725 | if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 3726 | return; |
| 3727 | |
[email protected] | 258d3112 | 2010-05-09 10:59:41 | [diff] [blame] | 3728 | webview()->hidePopups(); |
[email protected] | 854ab546 | 2011-11-22 20:48:10 | [diff] [blame] | 3729 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3730 | double old_zoom_level = webview()->zoomLevel(); |
| 3731 | double zoom_level; |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3732 | if (zoom == content::PAGE_ZOOM_RESET) { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3733 | zoom_level = 0; |
| 3734 | } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
| 3735 | // Previous zoom level is a whole number, so just increment/decrement. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3736 | zoom_level = old_zoom_level + zoom; |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3737 | } else { |
| 3738 | // Either the user hit the zoom factor limit and thus the zoom level is now |
| 3739 | // not a whole number, or a plugin changed it to a custom value. We want |
| 3740 | // to go to the next whole number so that the user can always get back to |
| 3741 | // 100% with the keyboard/menu. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3742 | if ((old_zoom_level > 1 && zoom > 0) || |
| 3743 | (old_zoom_level < 1 && zoom < 0)) { |
| 3744 | zoom_level = static_cast<int>(old_zoom_level + zoom); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3745 | } else { |
| 3746 | // We're going towards 100%, so first go to the next whole number. |
| 3747 | zoom_level = static_cast<int>(old_zoom_level); |
| 3748 | } |
| 3749 | } |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3750 | webview()->setZoomLevel(false, zoom_level); |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 3751 | zoomLevelChanged(); |
| 3752 | } |
| 3753 | |
| 3754 | void RenderViewImpl::OnZoomFactor(content::PageZoom zoom, |
| 3755 | int zoom_center_x, int zoom_center_y) { |
| 3756 | ZoomFactorHelper(zoom, zoom_center_x, zoom_center_y, |
| 3757 | kScalingIncrementForGesture); |
| 3758 | } |
| 3759 | |
| 3760 | void RenderViewImpl::ZoomFactorHelper(content::PageZoom zoom, |
| 3761 | int zoom_center_x, |
| 3762 | int zoom_center_y, |
| 3763 | float scaling_increment) { |
| 3764 | if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 3765 | return; |
| 3766 | |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 3767 | double old_page_scale_factor = webview()->pageScaleFactor(); |
| 3768 | double page_scale_factor; |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3769 | if (zoom == content::PAGE_ZOOM_RESET) { |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 3770 | page_scale_factor = 1.0; |
| 3771 | } else { |
| 3772 | page_scale_factor = old_page_scale_factor + |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 3773 | (zoom > 0 ? scaling_increment : -scaling_increment); |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 3774 | } |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 3775 | if (page_scale_factor > 0) { |
[email protected] | 8519136 | 2011-11-08 18:53:09 | [diff] [blame] | 3776 | webview()->setPageScaleFactor(page_scale_factor, |
| 3777 | WebPoint(zoom_center_x, zoom_center_y)); |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 3778 | } |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 3779 | } |
| 3780 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3781 | void RenderViewImpl::OnSetZoomLevel(double zoom_level) { |
[email protected] | d0b8d09 | 2010-10-25 04:05:17 | [diff] [blame] | 3782 | webview()->hidePopups(); |
| 3783 | webview()->setZoomLevel(false, zoom_level); |
| 3784 | zoomLevelChanged(); |
| 3785 | } |
| 3786 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3787 | void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
| 3788 | double zoom_level) { |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 3789 | host_zoom_levels_[url] = zoom_level; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3790 | } |
| 3791 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3792 | void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3793 | webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3794 | } |
| 3795 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3796 | void RenderViewImpl::OnResetPageEncodingToDefault() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3797 | WebString no_encoding; |
| 3798 | webview()->setPageEncoding(no_encoding); |
[email protected] | a697f4c | 2009-09-14 22:30:18 | [diff] [blame] | 3799 | } |
| 3800 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3801 | WebFrame* RenderViewImpl::GetChildFrame(const string16& xpath) const { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3802 | if (xpath.empty()) |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3803 | return webview()->mainFrame(); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3804 | |
| 3805 | // xpath string can represent a frame deep down the tree (across multiple |
| 3806 | // frame DOMs). |
| 3807 | // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] |
| 3808 | // should break into 2 xpaths |
| 3809 | // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] |
[email protected] | 318bf580 | 2011-08-08 17:12:41 | [diff] [blame] | 3810 | std::vector<string16> xpaths; |
| 3811 | base::SplitString(xpath, '\n', &xpaths); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3812 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3813 | WebFrame* frame = webview()->mainFrame(); |
[email protected] | 318bf580 | 2011-08-08 17:12:41 | [diff] [blame] | 3814 | for (std::vector<string16>::const_iterator i = xpaths.begin(); |
| 3815 | frame && i != xpaths.end(); ++i) { |
| 3816 | frame = frame->findChildByExpression(*i); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3817 | } |
| 3818 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3819 | return frame; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3820 | } |
| 3821 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3822 | void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, |
| 3823 | const string16& jscript, |
| 3824 | int id, |
| 3825 | bool notify_result) { |
[email protected] | 882b7b2 | 2010-10-05 03:34:53 | [diff] [blame] | 3826 | EvaluateScript(frame_xpath, jscript, id, notify_result); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3827 | } |
| 3828 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3829 | void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, |
| 3830 | const std::string& css) { |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3831 | WebFrame* frame = GetChildFrame(frame_xpath); |
| 3832 | if (!frame) |
[email protected] | 21681395 | 2011-05-19 22:21:26 | [diff] [blame] | 3833 | return; |
[email protected] | ae46154 | 2009-06-19 19:03:41 | [diff] [blame] | 3834 | |
[email protected] | 01cf589c | 2011-07-28 18:04:03 | [diff] [blame] | 3835 | frame->document().insertUserStyleSheet( |
| 3836 | WebString::fromUTF8(css), |
| 3837 | WebDocument::UserStyleAuthorLevel); |
[email protected] | 1810e13 | 2009-03-24 23:35:48 | [diff] [blame] | 3838 | } |
| 3839 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3840 | void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 3841 | enabled_bindings_ |= enabled_bindings_flags; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3842 | } |
| 3843 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3844 | void RenderViewImpl::OnSetWebUIProperty(const std::string& name, |
| 3845 | const std::string& value) { |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 3846 | DCHECK(enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI); |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 3847 | GetWebUIBindings()->SetProperty(name, value); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3848 | } |
| 3849 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3850 | void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
| 3851 | const gfx::Point& client_point, |
| 3852 | const gfx::Point& screen_point, |
| 3853 | WebDragOperationsMask ops) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 3854 | WebDragOperation operation = webview()->dragTargetDragEnter( |
| 3855 | drop_data.ToDragData(), |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 3856 | client_point, |
| 3857 | screen_point, |
| 3858 | ops); |
| 3859 | |
| 3860 | Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); |
| 3861 | } |
| 3862 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3863 | void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
| 3864 | const gfx::Point& screen_point, |
| 3865 | WebDragOperationsMask ops) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 3866 | WebDragOperation operation = webview()->dragTargetDragOver( |
| 3867 | client_point, |
| 3868 | screen_point, |
| 3869 | ops); |
| 3870 | |
| 3871 | Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); |
| 3872 | } |
| 3873 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3874 | void RenderViewImpl::OnDragTargetDragLeave() { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 3875 | webview()->dragTargetDragLeave(); |
| 3876 | } |
| 3877 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3878 | void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, |
| 3879 | const gfx::Point& screen_point) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 3880 | webview()->dragTargetDrop(client_point, screen_point); |
[email protected] | fcad4945 | 2011-06-28 17:11:57 | [diff] [blame] | 3881 | |
| 3882 | Send(new DragHostMsg_TargetDrop_ACK(routing_id_)); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 3883 | } |
| 3884 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3885 | void RenderViewImpl::OnDragSourceEndedOrMoved(const gfx::Point& client_point, |
| 3886 | const gfx::Point& screen_point, |
| 3887 | bool ended, |
| 3888 | WebDragOperation op) { |
[email protected] | 5f9ae6c | 2009-07-08 02:38:03 | [diff] [blame] | 3889 | if (ended) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3890 | webview()->dragSourceEndedAt(client_point, screen_point, op); |
[email protected] | daec5d6 | 2010-06-04 09:14:20 | [diff] [blame] | 3891 | } else { |
| 3892 | webview()->dragSourceMovedTo(client_point, screen_point, op); |
[email protected] | 5f9ae6c | 2009-07-08 02:38:03 | [diff] [blame] | 3893 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3894 | } |
| 3895 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3896 | void RenderViewImpl::OnDragSourceSystemDragEnded() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3897 | webview()->dragSourceSystemDragEnded(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3898 | } |
| 3899 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3900 | void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 3901 | webkit_preferences_ = prefs; |
| 3902 | webkit_preferences_.Apply(webview()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3903 | } |
| 3904 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3905 | void RenderViewImpl::OnSetAltErrorPageURL(const GURL& url) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3906 | alternate_error_page_url_ = url; |
| 3907 | } |
| 3908 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3909 | void RenderViewImpl::OnCustomContextMenuAction( |
[email protected] | b29aa74b | 2011-01-31 21:41:08 | [diff] [blame] | 3910 | const webkit_glue::CustomContextMenuContext& custom_context, |
| 3911 | unsigned action) { |
| 3912 | if (custom_context.is_pepper_menu) |
| 3913 | pepper_delegate_.OnCustomContextMenuAction(custom_context, action); |
| 3914 | else |
| 3915 | webview()->performCustomContextMenuAction(action); |
[email protected] | 440a0e5 | 2011-09-13 17:38:58 | [diff] [blame] | 3916 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 3917 | ContextMenuAction(action)); |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 3918 | } |
| 3919 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3920 | void RenderViewImpl::OnEnumerateDirectoryResponse( |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 3921 | int id, |
| 3922 | const std::vector<FilePath>& paths) { |
| 3923 | if (!enumeration_completions_[id]) |
| 3924 | return; |
| 3925 | |
| 3926 | WebVector<WebString> ws_file_names(paths.size()); |
| 3927 | for (size_t i = 0; i < paths.size(); ++i) |
| 3928 | ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
| 3929 | |
| 3930 | enumeration_completions_[id]->didChooseFile(ws_file_names); |
| 3931 | enumeration_completions_.erase(id); |
| 3932 | } |
| 3933 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3934 | void RenderViewImpl::OnFileChooserResponse(const std::vector<FilePath>& paths) { |
[email protected] | 8029f567 | 2009-03-20 22:33:36 | [diff] [blame] | 3935 | // This could happen if we navigated to a different page before the user |
| 3936 | // closed the chooser. |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 3937 | if (file_chooser_completions_.empty()) |
[email protected] | 8029f567 | 2009-03-20 22:33:36 | [diff] [blame] | 3938 | return; |
| 3939 | |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 3940 | WebVector<WebString> ws_file_names(paths.size()); |
| 3941 | for (size_t i = 0; i < paths.size(); ++i) |
| 3942 | ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 3943 | |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 3944 | if (file_chooser_completions_.front()->completion) |
| 3945 | file_chooser_completions_.front()->completion->didChooseFile(ws_file_names); |
| 3946 | file_chooser_completions_.pop_front(); |
| 3947 | |
| 3948 | // If there are more pending file chooser requests, schedule one now. |
| 3949 | if (!file_chooser_completions_.empty()) { |
| 3950 | Send(new ViewHostMsg_RunFileChooser(routing_id_, |
| 3951 | file_chooser_completions_.front()->params)); |
| 3952 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3953 | } |
| 3954 | |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 3955 | void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, |
| 3956 | const gfx::Size& max_size) { |
| 3957 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 3958 | if (!webview()) |
| 3959 | return; |
| 3960 | webview()->enableAutoResizeMode(true, min_size, max_size); |
| 3961 | } |
| 3962 | |
[email protected] | 2bf834f | 2011-11-17 20:02:21 | [diff] [blame] | 3963 | void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 3964 | if (send_preferred_size_changes_) |
| 3965 | return; |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 3966 | send_preferred_size_changes_ = true; |
[email protected] | 770dd8b | 2010-05-24 18:11:39 | [diff] [blame] | 3967 | |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 3968 | // Start off with an initial preferred size notification (in case |
| 3969 | // |didUpdateLayout| was already called). |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 3970 | didUpdateLayout(); |
[email protected] | 0666aef | 2009-05-13 19:48:08 | [diff] [blame] | 3971 | } |
| 3972 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3973 | void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 3974 | const gfx::Size& disable_scrollbar_size_limit) { |
| 3975 | disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
| 3976 | } |
| 3977 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3978 | void RenderViewImpl::OnSetRendererPrefs( |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 3979 | const content::RendererPreferences& renderer_prefs) { |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 3980 | double old_zoom_level = renderer_preferences_.default_zoom_level; |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 3981 | renderer_preferences_ = renderer_prefs; |
[email protected] | 6e282c9 | 2009-07-24 01:19:37 | [diff] [blame] | 3982 | UpdateFontRenderingFromRendererPrefs(); |
[email protected] | 0dd6f9b5 | 2010-10-14 16:39:13 | [diff] [blame] | 3983 | #if defined(TOOLKIT_USES_GTK) |
[email protected] | 1c83eb4 | 2009-09-11 21:08:41 | [diff] [blame] | 3984 | WebColorName name = WebKit::WebColorWebkitFocusRingColor; |
| 3985 | WebKit::setNamedColors(&name, &renderer_prefs.focus_ring_color, 1); |
[email protected] | 39cd64ed | 2010-02-05 02:18:46 | [diff] [blame] | 3986 | WebKit::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
[email protected] | 42e5c86 | 2011-04-07 22:13:51 | [diff] [blame] | 3987 | gfx::NativeTheme::instance()->SetScrollbarColors( |
[email protected] | 8d1b864d1 | 2010-10-10 00:04:34 | [diff] [blame] | 3988 | renderer_prefs.thumb_inactive_color, |
| 3989 | renderer_prefs.thumb_active_color, |
| 3990 | renderer_prefs.track_color); |
[email protected] | 93623c5d | 2009-12-10 21:40:32 | [diff] [blame] | 3991 | |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 3992 | if (webview()) { |
[email protected] | 93623c5d | 2009-12-10 21:40:32 | [diff] [blame] | 3993 | webview()->setScrollbarColors( |
| 3994 | renderer_prefs.thumb_inactive_color, |
| 3995 | renderer_prefs.thumb_active_color, |
| 3996 | renderer_prefs.track_color); |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 3997 | webview()->setSelectionColors( |
| 3998 | renderer_prefs.active_selection_bg_color, |
| 3999 | renderer_prefs.active_selection_fg_color, |
| 4000 | renderer_prefs.inactive_selection_bg_color, |
| 4001 | renderer_prefs.inactive_selection_fg_color); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 4002 | webview()->themeChanged(); |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 4003 | } |
[email protected] | 7a74e10 | 2009-09-03 00:16:56 | [diff] [blame] | 4004 | #endif |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 4005 | // If the zoom level for this page matches the old zoom default, and this |
| 4006 | // is not a plugin, update the zoom level to match the new default. |
| 4007 | if (webview() && !webview()->mainFrame()->document().isPluginDocument() && |
| 4008 | content::ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { |
| 4009 | webview()->setZoomLevel(false, renderer_preferences_.default_zoom_level); |
| 4010 | zoomLevelChanged(); |
| 4011 | } |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 4012 | } |
| 4013 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4014 | void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
| 4015 | const WebMediaPlayerAction& action) { |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 4016 | if (webview()) |
| 4017 | webview()->performMediaPlayerAction(action, location); |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 4018 | } |
| 4019 | |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 4020 | void RenderViewImpl::OnPluginActionAt(const gfx::Point& location, |
| 4021 | const WebPluginAction& action) { |
| 4022 | if (webview()) |
| 4023 | webview()->performPluginAction(action, location); |
| 4024 | } |
| 4025 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4026 | void RenderViewImpl::OnGetAllSavableResourceLinksForCurrentPage( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4027 | const GURL& page_url) { |
| 4028 | // Prepare list to storage all savable resource links. |
| 4029 | std::vector<GURL> resources_list; |
| 4030 | std::vector<GURL> referrers_list; |
| 4031 | std::vector<GURL> frames_list; |
| 4032 | webkit_glue::SavableResourcesResult result(&resources_list, |
| 4033 | &referrers_list, |
| 4034 | &frames_list); |
| 4035 | |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 4036 | // FIXME(rdsmith): When GetAllSavableResourceLinksForCurrentPage starts to |
| 4037 | // return referrers, it should also return the referrer policies. |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4038 | if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( |
| 4039 | webview(), |
| 4040 | page_url, |
| 4041 | &result, |
[email protected] | 2a80aee | 2011-10-07 16:06:03 | [diff] [blame] | 4042 | chrome::GetSavableSchemes())) { |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4043 | // If something is wrong when collecting all savable resource links, |
| 4044 | // send empty list to embedder(browser) to tell it failed. |
| 4045 | referrers_list.clear(); |
| 4046 | resources_list.clear(); |
| 4047 | frames_list.clear(); |
| 4048 | } |
| 4049 | |
| 4050 | // Send result of all savable resource links to embedder. |
| 4051 | Send(new ViewHostMsg_SendCurrentPageAllSavableResourceLinks(routing_id(), |
| 4052 | resources_list, |
| 4053 | referrers_list, |
| 4054 | frames_list)); |
| 4055 | } |
| 4056 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4057 | void RenderViewImpl::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4058 | const std::vector<GURL>& links, |
| 4059 | const std::vector<FilePath>& local_paths, |
| 4060 | const FilePath& local_directory_name) { |
| 4061 | |
| 4062 | // Convert std::vector of GURLs to WebVector<WebURL> |
| 4063 | WebVector<WebURL> weburl_links(links); |
| 4064 | |
| 4065 | // Convert std::vector of std::strings to WebVector<WebString> |
| 4066 | WebVector<WebString> webstring_paths(local_paths.size()); |
| 4067 | for (size_t i = 0; i < local_paths.size(); i++) |
| 4068 | webstring_paths[i] = webkit_glue::FilePathToWebString(local_paths[i]); |
| 4069 | |
| 4070 | WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links, |
| 4071 | webstring_paths, |
| 4072 | webkit_glue::FilePathToWebString( |
| 4073 | local_directory_name)); |
| 4074 | } |
| 4075 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4076 | void RenderViewImpl::OnShouldClose() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4077 | bool should_close = webview()->dispatchBeforeUnloadEvent(); |
[email protected] | 04b4a6c | 2008-08-02 00:44:47 | [diff] [blame] | 4078 | Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4079 | } |
| 4080 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4081 | void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 4082 | if (is_swapped_out_) |
| 4083 | return; |
| 4084 | |
| 4085 | // Swap this RenderView out so the tab can navigate to a page rendered by a |
| 4086 | // different process. This involves running the unload handler and clearing |
| 4087 | // the page. Once WasSwappedOut is called, we also allow this process to exit |
| 4088 | // if there are no other active RenderViews in it. |
| 4089 | |
| 4090 | // Send an UpdateState message before we get swapped out. |
| 4091 | SyncNavigationState(); |
| 4092 | |
| 4093 | // Synchronously run the unload handler before sending the ACK. |
| 4094 | webview()->dispatchUnloadEvent(); |
| 4095 | |
| 4096 | // Swap out and stop sending any IPC messages that are not ACKs. |
| 4097 | SetSwappedOut(true); |
| 4098 | |
| 4099 | // Replace the page with a blank dummy URL. The unload handler will not be |
| 4100 | // run a second time, thanks to a check in FrameLoader::stopLoading. |
| 4101 | // TODO(creis): Need to add a better way to do this that avoids running the |
| 4102 | // beforeunload handler. For now, we just run it a second time silently. |
| 4103 | webview()->mainFrame()->loadHTMLString(std::string(), |
| 4104 | GURL("about:swappedout"), |
| 4105 | GURL("about:swappedout"), |
| 4106 | false); |
| 4107 | |
| 4108 | // Just echo back the params in the ACK. |
| 4109 | Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); |
| 4110 | } |
| 4111 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4112 | void RenderViewImpl::OnClosePage() { |
[email protected] | 77fc9b9 | 2011-10-15 16:20:37 | [diff] [blame] | 4113 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4114 | // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 4115 | // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 4116 | // in the onunload handler from appearing. For now, we're bypassing that and |
| 4117 | // calling the FrameLoader's CloseURL method directly. This should be |
| 4118 | // revisited to avoid having two ways to close a page. Having a single way |
| 4119 | // to close that can run onunload is also useful for fixing |
| 4120 | // http://b/issue?id=753080. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4121 | webview()->dispatchUnloadEvent(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4122 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 4123 | Send(new ViewHostMsg_ClosePage_ACK(routing_id_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4124 | } |
| 4125 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4126 | void RenderViewImpl::OnThemeChanged() { |
[email protected] | e8d6b9f | 2011-10-10 22:21:02 | [diff] [blame] | 4127 | #if defined(USE_AURA) |
| 4128 | // Aura doesn't care if we switch themes. |
| 4129 | #elif defined(OS_WIN) |
[email protected] | c6d94221 | 2011-03-30 19:02:16 | [diff] [blame] | 4130 | gfx::NativeThemeWin::instance()->CloseHandles(); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 4131 | if (webview()) |
| 4132 | webview()->themeChanged(); |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 4133 | #else // defined(OS_WIN) |
| 4134 | // TODO(port): we don't support theming on non-Windows platforms yet |
| 4135 | NOTIMPLEMENTED(); |
| 4136 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4137 | } |
| 4138 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4139 | void RenderViewImpl::OnDisassociateFromPopupCount() { |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 4140 | if (decrement_shared_popup_at_destruction_) |
| 4141 | shared_popup_counter_->data--; |
| 4142 | shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 4143 | decrement_shared_popup_at_destruction_ = false; |
| 4144 | } |
| 4145 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4146 | bool RenderViewImpl::MaybeLoadAlternateErrorPage(WebFrame* frame, |
| 4147 | const WebURLError& error, |
| 4148 | bool replace) { |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4149 | // We only show alternate error pages in the main frame. They are |
| 4150 | // intended to assist the user when navigating, so there is not much |
| 4151 | // value in showing them for failed subframes. Ideally, we would be |
| 4152 | // able to use the TYPED transition type for this, but that flag is |
| 4153 | // not preserved across page reloads. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4154 | if (frame->parent()) |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4155 | return false; |
| 4156 | |
| 4157 | // Use the alternate error page service if this is a DNS failure or |
[email protected] | c53976d5 | 2009-08-07 18:58:37 | [diff] [blame] | 4158 | // connection failure. |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4159 | int ec = error.reason; |
| 4160 | if (ec != net::ERR_NAME_NOT_RESOLVED && |
| 4161 | ec != net::ERR_CONNECTION_FAILED && |
| 4162 | ec != net::ERR_CONNECTION_REFUSED && |
| 4163 | ec != net::ERR_ADDRESS_UNREACHABLE && |
[email protected] | c53976d5 | 2009-08-07 18:58:37 | [diff] [blame] | 4164 | ec != net::ERR_CONNECTION_TIMED_OUT) |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4165 | return false; |
| 4166 | |
| 4167 | const GURL& error_page_url = GetAlternateErrorPageURL(error.unreachableURL, |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 4168 | ec == net::ERR_NAME_NOT_RESOLVED ? DNS_ERROR : CONNECTION_ERROR); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4169 | if (!error_page_url.is_valid()) |
| 4170 | return false; |
| 4171 | |
| 4172 | // Load an empty page first so there is an immediate response to the error, |
| 4173 | // and then kick off a request for the alternate error page. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4174 | frame->loadHTMLString(std::string(), |
[email protected] | 144143c | 2010-10-28 08:17:36 | [diff] [blame] | 4175 | GURL(chrome::kUnreachableWebDataURL), |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4176 | error.unreachableURL, |
| 4177 | replace); |
| 4178 | |
| 4179 | // Now, create a fetcher for the error page and associate it with the data |
| 4180 | // source we just created via the LoadHTMLString call. That way if another |
| 4181 | // navigation occurs, the fetcher will get destroyed. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 4182 | DocumentState* document_state = |
| 4183 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 4184 | document_state->set_alt_error_page_fetcher( |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4185 | new AltErrorPageResourceFetcher( |
| 4186 | error_page_url, frame, error, |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 4187 | base::Bind(&RenderViewImpl::AltErrorPageFinished, |
| 4188 | base::Unretained(this)))); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4189 | return true; |
| 4190 | } |
| 4191 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4192 | void RenderViewImpl::AltErrorPageFinished(WebFrame* frame, |
| 4193 | const WebURLError& original_error, |
| 4194 | const std::string& html) { |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4195 | // Here, we replace the blank page we loaded previously. |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 4196 | // If we failed to download the alternate error page, LoadNavigationErrorPage |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 4197 | // will simply display a default error page. |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 4198 | LoadNavigationErrorPage(frame, WebURLRequest(), original_error, html, true); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4199 | } |
| 4200 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4201 | void RenderViewImpl::OnMoveOrResizeStarted() { |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 4202 | if (webview()) |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 4203 | webview()->hidePopups(); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 4204 | } |
| 4205 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4206 | void RenderViewImpl::OnResize(const gfx::Size& new_size, |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 4207 | const gfx::Rect& resizer_rect, |
| 4208 | bool is_fullscreen) { |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4209 | if (webview()) { |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 4210 | webview()->hidePopups(); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4211 | if (send_preferred_size_changes_) { |
[email protected] | 7339cd2 | 2010-10-27 00:11:20 | [diff] [blame] | 4212 | webview()->mainFrame()->setCanHaveScrollbars( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4213 | ShouldDisplayScrollbars(new_size.width(), new_size.height())); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4214 | } |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 4215 | UpdateScrollState(webview()->mainFrame()); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4216 | } |
| 4217 | |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 4218 | RenderWidget::OnResize(new_size, resizer_rect, is_fullscreen); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 4219 | } |
[email protected] | 0aa477bd | 2009-03-23 22:21:43 | [diff] [blame] | 4220 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4221 | void RenderViewImpl::DidInitiatePaint() { |
[email protected] | 53900d5 | 2010-06-16 04:25:01 | [diff] [blame] | 4222 | // Notify the pepper plugins that we started painting. |
| 4223 | pepper_delegate_.ViewInitiatedPaint(); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4224 | } |
| 4225 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4226 | void RenderViewImpl::DidFlushPaint() { |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4227 | // Notify any pepper plugins that we painted. This will call into the plugin, |
| 4228 | // and we it may ask to close itself as a result. This will, in turn, modify |
| 4229 | // our set, possibly invalidating the iterator. So we iterate on a copy that |
| 4230 | // won't change out from under us. |
[email protected] | 53900d5 | 2010-06-16 04:25:01 | [diff] [blame] | 4231 | pepper_delegate_.ViewFlushedPaint(); |
| 4232 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4233 | WebFrame* main_frame = webview()->mainFrame(); |
| 4234 | |
| 4235 | // If we have a provisional frame we are between the start and commit stages |
| 4236 | // of loading and we don't want to save stats. |
| 4237 | if (!main_frame->provisionalDataSource()) { |
| 4238 | WebDataSource* ds = main_frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 4239 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4240 | |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 4241 | // TODO(jar): The following code should all be inside a method, probably in |
| 4242 | // NavigatorState. |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4243 | Time now = Time::Now(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 4244 | if (document_state->first_paint_time().is_null()) { |
| 4245 | document_state->set_first_paint_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4246 | } |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 4247 | if (document_state->first_paint_after_load_time().is_null() && |
| 4248 | !document_state->finish_load_time().is_null()) { |
| 4249 | document_state->set_first_paint_after_load_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4250 | } |
| 4251 | } |
| 4252 | } |
| 4253 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4254 | void RenderViewImpl::OnViewContextSwapBuffersPosted() { |
[email protected] | 37a6f30 | 2011-07-11 23:43:08 | [diff] [blame] | 4255 | RenderWidget::OnSwapBuffersPosted(); |
| 4256 | } |
| 4257 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4258 | void RenderViewImpl::OnViewContextSwapBuffersComplete() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 4259 | RenderWidget::OnSwapBuffersComplete(); |
| 4260 | } |
| 4261 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4262 | void RenderViewImpl::OnViewContextSwapBuffersAborted() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 4263 | RenderWidget::OnSwapBuffersAborted(); |
| 4264 | } |
| 4265 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4266 | webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint( |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 4267 | const gfx::Rect& paint_bounds, |
| 4268 | TransportDIB** dib, |
| 4269 | gfx::Rect* location, |
| 4270 | gfx::Rect* clip) { |
| 4271 | return pepper_delegate_.GetBitmapForOptimizedPluginPaint( |
| 4272 | paint_bounds, dib, location, clip); |
| 4273 | } |
| 4274 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4275 | gfx::Point RenderViewImpl::GetScrollOffset() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 4276 | WebSize scroll_offset = webview()->mainFrame()->scrollOffset(); |
[email protected] | bcaf227 | 2011-02-15 15:29:43 | [diff] [blame] | 4277 | return gfx::Point(scroll_offset.width, scroll_offset.height); |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 4278 | } |
| 4279 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4280 | void RenderViewImpl::OnClearFocusedNode() { |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 4281 | if (webview()) |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4282 | webview()->clearFocusedNode(); |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 4283 | } |
| 4284 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4285 | void RenderViewImpl::OnSetBackground(const SkBitmap& background) { |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 4286 | if (webview()) |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 4287 | webview()->setIsTransparent(!background.empty()); |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 4288 | |
| 4289 | SetBackground(background); |
| 4290 | } |
| 4291 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4292 | void RenderViewImpl::OnSetActive(bool active) { |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 4293 | if (webview()) |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 4294 | webview()->setIsActive(active); |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 4295 | |
| 4296 | #if defined(OS_MACOSX) |
| 4297 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4298 | for (plugin_it = plugin_delegates_.begin(); |
| 4299 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4300 | (*plugin_it)->SetWindowFocus(active); |
| 4301 | } |
| 4302 | #endif |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 4303 | } |
| 4304 | |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 4305 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4306 | void RenderViewImpl::OnSetWindowVisibility(bool visible) { |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 4307 | // Inform plugins that their container has changed visibility. |
| 4308 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4309 | for (plugin_it = plugin_delegates_.begin(); |
| 4310 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4311 | (*plugin_it)->SetContainerVisibility(visible); |
| 4312 | } |
| 4313 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4314 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4315 | void RenderViewImpl::OnWindowFrameChanged(const gfx::Rect& window_frame, |
| 4316 | const gfx::Rect& view_frame) { |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4317 | // Inform plugins that their window's frame has changed. |
| 4318 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4319 | for (plugin_it = plugin_delegates_.begin(); |
| 4320 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4321 | (*plugin_it)->WindowFrameChanged(window_frame, view_frame); |
| 4322 | } |
| 4323 | } |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 4324 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4325 | void RenderViewImpl::OnPluginImeCompositionCompleted(const string16& text, |
| 4326 | int plugin_id) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 4327 | // WebPluginDelegateProxy is responsible for figuring out if this event |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 4328 | // applies to it or not, so inform all the delegates. |
| 4329 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4330 | for (plugin_it = plugin_delegates_.begin(); |
| 4331 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 4332 | (*plugin_it)->ImeCompositionCompleted(text, plugin_id); |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 4333 | } |
| 4334 | } |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 4335 | #endif // OS_MACOSX |
| 4336 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4337 | void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 4338 | const EditCommands& edit_commands) { |
| 4339 | edit_commands_ = edit_commands; |
| 4340 | } |
| 4341 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4342 | void RenderViewImpl::Close() { |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 4343 | // We need to grab a pointer to the doomed WebView before we destroy it. |
| 4344 | WebView* doomed = webview(); |
| 4345 | RenderWidget::Close(); |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 4346 | g_view_map.Get().erase(doomed); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 4347 | } |
| 4348 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4349 | void RenderViewImpl::DidHandleKeyEvent() { |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 4350 | edit_commands_.clear(); |
| 4351 | } |
| 4352 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4353 | bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
[email protected] | b993705a | 2011-10-09 23:00:24 | [diff] [blame] | 4354 | return pepper_delegate_.HandleMouseEvent(event); |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 4355 | } |
| 4356 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4357 | void RenderViewImpl::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 4358 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 4359 | } |
| 4360 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4361 | void RenderViewImpl::DidHandleTouchEvent(const WebTouchEvent& event) { |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 4362 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleTouchEvent(event)); |
| 4363 | } |
| 4364 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4365 | void RenderViewImpl::OnWasHidden() { |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4366 | RenderWidget::OnWasHidden(); |
| 4367 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4368 | if (webview()) { |
| 4369 | webview()->settings()->setMinimumTimerInterval( |
| 4370 | webkit_glue::kBackgroundTabTimerInterval); |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 4371 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4372 | } |
| 4373 | |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 4374 | // Inform PPAPI plugins that their page is no longer visible. |
| 4375 | pepper_delegate_.PageVisibilityChanged(false); |
| 4376 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4377 | #if defined(OS_MACOSX) |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 4378 | // Inform NPAPI plugins that their container is no longer visible. |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4379 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4380 | for (plugin_it = plugin_delegates_.begin(); |
| 4381 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4382 | (*plugin_it)->SetContainerVisibility(false); |
| 4383 | } |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4384 | #endif // OS_MACOSX |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4385 | } |
| 4386 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4387 | void RenderViewImpl::OnWasRestored(bool needs_repainting) { |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4388 | RenderWidget::OnWasRestored(needs_repainting); |
| 4389 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4390 | if (webview()) { |
| 4391 | webview()->settings()->setMinimumTimerInterval( |
| 4392 | webkit_glue::kForegroundTabTimerInterval); |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 4393 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4394 | } |
| 4395 | |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 4396 | // Inform PPAPI plugins that their page is visible. |
| 4397 | pepper_delegate_.PageVisibilityChanged(true); |
| 4398 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4399 | #if defined(OS_MACOSX) |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 4400 | // Inform NPAPI plugins that their container is now visible. |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4401 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4402 | for (plugin_it = plugin_delegates_.begin(); |
| 4403 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4404 | (*plugin_it)->SetContainerVisibility(true); |
| 4405 | } |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 4406 | #endif // OS_MACOSX |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4407 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4408 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4409 | bool RenderViewImpl::SupportsAsynchronousSwapBuffers() { |
[email protected] | 555e75d | 2011-10-08 01:23:38 | [diff] [blame] | 4410 | if (WebWidgetHandlesCompositorScheduling()) |
| 4411 | return false; |
| 4412 | |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 4413 | WebKit::WebGraphicsContext3D* context = webview()->graphicsContext3D(); |
| 4414 | if (!context) |
| 4415 | return false; |
| 4416 | std::string extensions(context->getRequestableExtensionsCHROMIUM().utf8()); |
| 4417 | return extensions.find("GL_CHROMIUM_swapbuffers_complete_callback") != |
| 4418 | std::string::npos; |
| 4419 | } |
| 4420 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4421 | void RenderViewImpl::OnSetFocus(bool enable) { |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4422 | RenderWidget::OnSetFocus(enable); |
| 4423 | |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 4424 | if (webview() && webview()->isActive()) { |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 4425 | // Notify all NPAPI plugins. |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4426 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4427 | for (plugin_it = plugin_delegates_.begin(); |
| 4428 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 4429 | #if defined(OS_MACOSX) |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 4430 | // RenderWidget's call to setFocus can cause the underlying webview's |
| 4431 | // activation state to change just like a call to setIsActive. |
| 4432 | if (enable) |
| 4433 | (*plugin_it)->SetWindowFocus(true); |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 4434 | #endif |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 4435 | (*plugin_it)->SetContentAreaFocus(enable); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4436 | } |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 4437 | |
| 4438 | // Notify all Pepper plugins. |
| 4439 | pepper_delegate_.OnSetFocus(enable); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4440 | } |
| 4441 | } |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4442 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4443 | void RenderViewImpl::PpapiPluginFocusChanged() { |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4444 | UpdateTextInputState(); |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 4445 | UpdateSelectionBounds(); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4446 | } |
| 4447 | |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4448 | void RenderViewImpl::PpapiPluginTextInputTypeChanged() { |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4449 | UpdateTextInputState(); |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4450 | } |
| 4451 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 4452 | void RenderViewImpl::PpapiPluginCaretPositionChanged() { |
| 4453 | UpdateSelectionBounds(); |
| 4454 | } |
| 4455 | |
[email protected] | b25b3ee | 2012-01-13 05:19:54 | [diff] [blame] | 4456 | bool RenderViewImpl::GetPpapiPluginCaretBounds(gfx::Rect* rect) { |
| 4457 | if (!pepper_delegate_.IsPluginFocused()) |
| 4458 | return false; |
| 4459 | *rect = pepper_delegate_.GetCaretBounds(); |
| 4460 | return true; |
| 4461 | } |
| 4462 | |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4463 | void RenderViewImpl::PpapiPluginCancelComposition() { |
| 4464 | Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 4465 | ui::Range range(ui::Range::InvalidRange()); |
| 4466 | Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range)); |
| 4467 | } |
| 4468 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4469 | void RenderViewImpl::OnImeSetComposition( |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4470 | const string16& text, |
| 4471 | const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 4472 | int selection_start, |
| 4473 | int selection_end) { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4474 | if (pepper_delegate_.IsPluginFocused()) { |
| 4475 | // When a PPAPI plugin has focus, we bypass WebKit. |
| 4476 | pepper_delegate_.OnImeSetComposition(text, |
| 4477 | underlines, |
| 4478 | selection_start, |
| 4479 | selection_end); |
| 4480 | } else { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4481 | #if defined(OS_WIN) |
| 4482 | // When a plug-in has focus, we create platform-specific IME data used by |
| 4483 | // our IME emulator and send it directly to the focused plug-in, i.e. we |
| 4484 | // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its |
| 4485 | // instance ID is the same one as the specified ID.) |
| 4486 | if (focused_plugin_id_ >= 0) { |
| 4487 | std::vector<int> clauses; |
| 4488 | std::vector<int> target; |
| 4489 | for (size_t i = 0; i < underlines.size(); ++i) { |
| 4490 | clauses.push_back(underlines[i].startOffset); |
| 4491 | clauses.push_back(underlines[i].endOffset); |
| 4492 | if (underlines[i].thick) { |
| 4493 | target.clear(); |
| 4494 | target.push_back(underlines[i].startOffset); |
| 4495 | target.push_back(underlines[i].endOffset); |
| 4496 | } |
| 4497 | } |
| 4498 | std::set<WebPluginDelegateProxy*>::iterator it; |
| 4499 | for (it = plugin_delegates_.begin(); |
| 4500 | it != plugin_delegates_.end(); ++it) { |
| 4501 | (*it)->ImeCompositionUpdated(text, clauses, target, selection_end, |
| 4502 | focused_plugin_id_); |
| 4503 | } |
| 4504 | return; |
| 4505 | } |
| 4506 | #endif |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4507 | RenderWidget::OnImeSetComposition(text, |
| 4508 | underlines, |
| 4509 | selection_start, |
| 4510 | selection_end); |
| 4511 | } |
| 4512 | } |
| 4513 | |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 4514 | void RenderViewImpl::OnImeConfirmComposition( |
| 4515 | const string16& text, const ui::Range& replacement_range) { |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4516 | if (pepper_delegate_.IsPluginFocused()) { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4517 | // When a PPAPI plugin has focus, we bypass WebKit. |
| 4518 | pepper_delegate_.OnImeConfirmComposition(text); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4519 | } else { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4520 | #if defined(OS_WIN) |
| 4521 | // Same as OnImeSetComposition(), we send the text from IMEs directly to |
| 4522 | // plug-ins. When we send IME text directly to plug-ins, we should not send |
| 4523 | // it to WebKit to prevent WebKit from controlling IMEs. |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 4524 | // TODO(thakis): Honor |replacement_range| for plugins? |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4525 | if (focused_plugin_id_ >= 0) { |
| 4526 | std::set<WebPluginDelegateProxy*>::iterator it; |
| 4527 | for (it = plugin_delegates_.begin(); |
| 4528 | it != plugin_delegates_.end(); ++it) { |
| 4529 | (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
| 4530 | } |
| 4531 | return; |
| 4532 | } |
| 4533 | #endif |
[email protected] | ebd28ac | 2011-10-13 18:49:05 | [diff] [blame] | 4534 | if (replacement_range.IsValid() && webview()) { |
| 4535 | // Select the text in |replacement_range|, it will then be replaced by |
| 4536 | // text added by the call to RenderWidget::OnImeConfirmComposition(). |
| 4537 | if (WebFrame* frame = webview()->focusedFrame()) { |
[email protected] | 4bacb82 | 2011-11-02 15:10:16 | [diff] [blame] | 4538 | WebRange webrange = WebRange::fromDocumentRange( |
| 4539 | frame, replacement_range.start(), replacement_range.length()); |
| 4540 | if (!webrange.isNull()) |
| 4541 | frame->setSelectionToRange(webrange); |
[email protected] | ebd28ac | 2011-10-13 18:49:05 | [diff] [blame] | 4542 | } |
| 4543 | } |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 4544 | RenderWidget::OnImeConfirmComposition(text, replacement_range); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4545 | } |
| 4546 | } |
| 4547 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4548 | ui::TextInputType RenderViewImpl::GetTextInputType() { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4549 | return pepper_delegate_.IsPluginFocused() ? |
| 4550 | pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); |
| 4551 | } |
| 4552 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 4553 | void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { |
| 4554 | if (pepper_delegate_.IsPluginFocused()) { |
| 4555 | // TODO(kinaba) http://crbug.com/101101 |
| 4556 | // Current Pepper IME API does not handle selection bounds. So we simply |
| 4557 | // use the caret position as an empty range for now. It will be updated |
| 4558 | // after Pepper API equips features related to surrounding text retrieval. |
| 4559 | gfx::Rect caret = pepper_delegate_.GetCaretBounds(); |
| 4560 | *start = caret; |
| 4561 | *end = caret; |
| 4562 | return; |
| 4563 | } |
| 4564 | RenderWidget::GetSelectionBounds(start, end); |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 4565 | } |
| 4566 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4567 | bool RenderViewImpl::CanComposeInline() { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4568 | return pepper_delegate_.IsPluginFocused() ? |
| 4569 | pepper_delegate_.CanComposeInline() : true; |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4570 | } |
| 4571 | |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4572 | #if defined(OS_WIN) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4573 | void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4574 | if (focused) |
| 4575 | focused_plugin_id_ = plugin_id; |
| 4576 | else |
| 4577 | focused_plugin_id_ = -1; |
| 4578 | } |
| 4579 | #endif |
| 4580 | |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4581 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4582 | void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 4583 | IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), |
| 4584 | focused, plugin_id); |
| 4585 | Send(msg); |
| 4586 | } |
| 4587 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4588 | void RenderViewImpl::StartPluginIme() { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 4589 | IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 4590 | // This message can be sent during event-handling, and needs to be delivered |
| 4591 | // within that context. |
| 4592 | msg->set_unblock(true); |
| 4593 | Send(msg); |
| 4594 | } |
| 4595 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4596 | gfx::PluginWindowHandle RenderViewImpl::AllocateFakePluginWindowHandle( |
[email protected] | 77e74db | 2010-08-04 17:46:23 | [diff] [blame] | 4597 | bool opaque, bool root) { |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4598 | gfx::PluginWindowHandle window = NULL; |
| 4599 | Send(new ViewHostMsg_AllocateFakePluginWindowHandle( |
[email protected] | 77e74db | 2010-08-04 17:46:23 | [diff] [blame] | 4600 | routing_id(), opaque, root, &window)); |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 4601 | if (window) { |
| 4602 | fake_plugin_window_handles_.insert(window); |
| 4603 | } |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4604 | return window; |
| 4605 | } |
| 4606 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4607 | void RenderViewImpl::DestroyFakePluginWindowHandle( |
| 4608 | gfx::PluginWindowHandle window) { |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 4609 | if (window && fake_plugin_window_handles_.find(window) != |
| 4610 | fake_plugin_window_handles_.end()) { |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4611 | Send(new ViewHostMsg_DestroyFakePluginWindowHandle(routing_id(), window)); |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 4612 | fake_plugin_window_handles_.erase(window); |
| 4613 | } |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4614 | } |
| 4615 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4616 | void RenderViewImpl::AcceleratedSurfaceSetIOSurface( |
| 4617 | gfx::PluginWindowHandle window, |
| 4618 | int32 width, |
| 4619 | int32 height, |
| 4620 | uint64 io_surface_identifier) { |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 4621 | Send(new ViewHostMsg_AcceleratedSurfaceSetIOSurface( |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4622 | routing_id(), window, width, height, io_surface_identifier)); |
| 4623 | } |
| 4624 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4625 | void RenderViewImpl::AcceleratedSurfaceSetTransportDIB( |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 4626 | gfx::PluginWindowHandle window, |
| 4627 | int32 width, |
| 4628 | int32 height, |
| 4629 | TransportDIB::Handle transport_dib) { |
| 4630 | Send(new ViewHostMsg_AcceleratedSurfaceSetTransportDIB( |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 4631 | routing_id(), window, width, height, transport_dib)); |
| 4632 | } |
| 4633 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4634 | TransportDIB::Handle RenderViewImpl::AcceleratedSurfaceAllocTransportDIB( |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 4635 | size_t size) { |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 4636 | TransportDIB::Handle dib_handle; |
| 4637 | // Assume this is a synchronous RPC. |
[email protected] | ada848b1 | 2010-04-08 22:35:38 | [diff] [blame] | 4638 | if (Send(new ViewHostMsg_AllocTransportDIB(size, true, &dib_handle))) |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 4639 | return dib_handle; |
| 4640 | // Return an invalid handle if Send() fails. |
| 4641 | return TransportDIB::DefaultHandleValue(); |
| 4642 | } |
| 4643 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4644 | void RenderViewImpl::AcceleratedSurfaceFreeTransportDIB( |
| 4645 | TransportDIB::Id dib_id) { |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 4646 | Send(new ViewHostMsg_FreeTransportDIB(dib_id)); |
| 4647 | } |
| 4648 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4649 | void RenderViewImpl::AcceleratedSurfaceBuffersSwapped( |
[email protected] | f35d667 | 2010-10-28 21:39:14 | [diff] [blame] | 4650 | gfx::PluginWindowHandle window, uint64 surface_id) { |
| 4651 | Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( |
| 4652 | routing_id(), window, surface_id)); |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4653 | } |
| 4654 | #endif |
[email protected] | 58c321d | 2010-02-19 12:11:28 | [diff] [blame] | 4655 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4656 | bool RenderViewImpl::ScheduleFileChooser( |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 4657 | const content::FileChooserParams& params, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 4658 | WebFileChooserCompletion* completion) { |
| 4659 | static const size_t kMaximumPendingFileChooseRequests = 4; |
| 4660 | if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { |
| 4661 | // This sanity check prevents too many file choose requests from getting |
| 4662 | // queued which could DoS the user. Getting these is most likely a |
| 4663 | // programming error (there are many ways to DoS the user so it's not |
| 4664 | // considered a "real" security check), either in JS requesting many file |
| 4665 | // choosers to pop up, or in a plugin. |
| 4666 | // |
| 4667 | // TODO(brettw) we might possibly want to require a user gesture to open |
| 4668 | // a file picker, which will address this issue in a better way. |
| 4669 | return false; |
| 4670 | } |
| 4671 | |
| 4672 | file_chooser_completions_.push_back(linked_ptr<PendingFileChooser>( |
| 4673 | new PendingFileChooser(params, completion))); |
| 4674 | if (file_chooser_completions_.size() == 1) { |
| 4675 | // Actually show the browse dialog when this is the first request. |
| 4676 | Send(new ViewHostMsg_RunFileChooser(routing_id_, params)); |
| 4677 | } |
| 4678 | return true; |
| 4679 | } |
| 4680 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4681 | WebKit::WebGeolocationClient* RenderViewImpl::geolocationClient() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 4682 | if (!geolocation_dispatcher_) |
| 4683 | geolocation_dispatcher_ = new GeolocationDispatcher(this); |
| 4684 | return geolocation_dispatcher_; |
[email protected] | 7e0c470 | 2010-12-31 14:06:25 | [diff] [blame] | 4685 | } |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 4686 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4687 | WebKit::WebSpeechInputController* RenderViewImpl::speechInputController( |
[email protected] | 638694c | 2010-08-04 22:24:11 | [diff] [blame] | 4688 | WebKit::WebSpeechInputListener* listener) { |
[email protected] | 9eb100e | 2011-10-14 05:08:22 | [diff] [blame] | 4689 | #if defined(ENABLE_INPUT_SPEECH) |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 4690 | if (!speech_input_dispatcher_) |
| 4691 | speech_input_dispatcher_ = new SpeechInputDispatcher(this, listener); |
[email protected] | 9eb100e | 2011-10-14 05:08:22 | [diff] [blame] | 4692 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 4693 | return speech_input_dispatcher_; |
[email protected] | 638694c | 2010-08-04 22:24:11 | [diff] [blame] | 4694 | } |
| 4695 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4696 | WebKit::WebDeviceOrientationClient* RenderViewImpl::deviceOrientationClient() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 4697 | if (!device_orientation_dispatcher_) |
| 4698 | device_orientation_dispatcher_ = new DeviceOrientationDispatcher(this); |
| 4699 | return device_orientation_dispatcher_; |
[email protected] | 57ead35 | 2010-08-11 14:42:53 | [diff] [blame] | 4700 | } |
| 4701 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4702 | void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
| 4703 | double maximum_level) { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4704 | // For now, don't remember plugin zoom values. We don't want to mix them with |
| 4705 | // normal web content (i.e. a fixed layout plugin would usually want them |
| 4706 | // different). |
| 4707 | bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
| 4708 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4709 | int minimum_percent = static_cast<int>( |
| 4710 | WebView::zoomLevelToZoomFactor(minimum_level) * 100); |
| 4711 | int maximum_percent = static_cast<int>( |
| 4712 | WebView::zoomLevelToZoomFactor(maximum_level) * 100); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4713 | |
| 4714 | Send(new ViewHostMsg_UpdateZoomLimits( |
| 4715 | routing_id_, minimum_percent, maximum_percent, remember)); |
| 4716 | } |
| 4717 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4718 | void RenderViewImpl::zoomLevelChanged() { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4719 | bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
[email protected] | ba51d3b | 2011-08-24 19:53:08 | [diff] [blame] | 4720 | float zoom_level = webview()->zoomLevel(); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4721 | // Tell the browser which url got zoomed so it can update the menu and the |
| 4722 | // saved values if necessary |
| 4723 | Send(new ViewHostMsg_DidZoomURL( |
[email protected] | ba51d3b | 2011-08-24 19:53:08 | [diff] [blame] | 4724 | routing_id_, zoom_level, remember, |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 4725 | GURL(webview()->mainFrame()->document().url()))); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 4726 | } |
| 4727 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4728 | void RenderViewImpl::registerProtocolHandler(const WebString& scheme, |
| 4729 | const WebString& base_url, |
| 4730 | const WebString& url, |
| 4731 | const WebString& title) { |
[email protected] | a6d36cc | 2011-02-23 00:39:48 | [diff] [blame] | 4732 | GURL base(base_url); |
| 4733 | GURL absolute_url = base.Resolve(UTF16ToUTF8(url)); |
| 4734 | if (base.GetOrigin() != absolute_url.GetOrigin()) { |
| 4735 | return; |
| 4736 | } |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 4737 | Send(new ViewHostMsg_RegisterProtocolHandler(routing_id_, |
| 4738 | UTF16ToUTF8(scheme), |
| 4739 | absolute_url, |
| 4740 | title)); |
[email protected] | a6d36cc | 2011-02-23 00:39:48 | [diff] [blame] | 4741 | } |
| 4742 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4743 | WebKit::WebPageVisibilityState RenderViewImpl::visibilityState() const { |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 4744 | WebKit::WebPageVisibilityState current_state = is_hidden() ? |
| 4745 | WebKit::WebPageVisibilityStateHidden : |
| 4746 | WebKit::WebPageVisibilityStateVisible; |
| 4747 | WebKit::WebPageVisibilityState override_state = current_state; |
| 4748 | if (content::GetContentClient()->renderer()-> |
| 4749 | ShouldOverridePageVisibilityState(this, |
| 4750 | &override_state)) |
| 4751 | return override_state; |
| 4752 | return current_state; |
[email protected] | 94dec93 | 2011-05-26 20:04:21 | [diff] [blame] | 4753 | } |
| 4754 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 4755 | WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { |
| 4756 | const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 4757 | if (!cmd_line->HasSwitch(switches::kEnableMediaStream)) |
| 4758 | return NULL; |
| 4759 | EnsureMediaStreamImpl(); |
| 4760 | return media_stream_impl_; |
| 4761 | } |
| 4762 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4763 | bool RenderViewImpl::IsNonLocalTopLevelNavigation( |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 4764 | const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { |
[email protected] | 8079b36 | 2010-05-07 18:37:45 | [diff] [blame] | 4765 | // Must be a top level frame. |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 4766 | if (frame->parent() != NULL) |
| 4767 | return false; |
| 4768 | |
[email protected] | f0a3d0b | 2010-08-06 22:51:53 | [diff] [blame] | 4769 | // Navigations initiated within Webkit are not sent out to the external host |
| 4770 | // in the following cases. |
[email protected] | 900eb2f1 | 2010-08-23 22:36:27 | [diff] [blame] | 4771 | // 1. The url scheme is not http/https |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 4772 | // 2. The origin of the url and the opener is the same in which case the |
[email protected] | f0a3d0b | 2010-08-06 22:51:53 | [diff] [blame] | 4773 | // opener relationship is maintained. |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 4774 | // 3. Reloads/form submits/back forward navigations |
[email protected] | abbfaec | 2011-05-23 23:57:33 | [diff] [blame] | 4775 | if (!url.SchemeIs(chrome::kHttpScheme) && !url.SchemeIs(chrome::kHttpsScheme)) |
[email protected] | f0a3d0b | 2010-08-06 22:51:53 | [diff] [blame] | 4776 | return false; |
| 4777 | |
[email protected] | 2fc22d1 | 2010-12-02 23:08:16 | [diff] [blame] | 4778 | // Not interested in reloads/form submits/resubmits/back forward navigations. |
[email protected] | d0ed50d | 2010-06-22 01:01:32 | [diff] [blame] | 4779 | if (type != WebKit::WebNavigationTypeReload && |
[email protected] | 070c49c | 2010-07-13 22:22:01 | [diff] [blame] | 4780 | type != WebKit::WebNavigationTypeFormSubmitted && |
[email protected] | 2fc22d1 | 2010-12-02 23:08:16 | [diff] [blame] | 4781 | type != WebKit::WebNavigationTypeFormResubmitted && |
[email protected] | 070c49c | 2010-07-13 22:22:01 | [diff] [blame] | 4782 | type != WebKit::WebNavigationTypeBackForward) { |
[email protected] | d0ed50d | 2010-06-22 01:01:32 | [diff] [blame] | 4783 | // The opener relationship between the new window and the parent allows the |
| 4784 | // new window to script the parent and vice versa. This is not allowed if |
| 4785 | // the origins of the two domains are different. This can be treated as a |
| 4786 | // top level navigation and routed back to the host. |
| 4787 | WebKit::WebFrame* opener = frame->opener(); |
[email protected] | 900eb2f1 | 2010-08-23 22:36:27 | [diff] [blame] | 4788 | if (!opener) { |
[email protected] | 8696536 | 2011-04-21 18:42:51 | [diff] [blame] | 4789 | return true; |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 4790 | } else { |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 4791 | if (url.GetOrigin() != GURL(opener->document().url()).GetOrigin()) |
[email protected] | d0ed50d | 2010-06-22 01:01:32 | [diff] [blame] | 4792 | return true; |
| 4793 | } |
| 4794 | } |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 4795 | return false; |
| 4796 | } |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 4797 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4798 | void RenderViewImpl::OnAsyncFileOpened( |
| 4799 | base::PlatformFileError error_code, |
| 4800 | IPC::PlatformFileForTransit file_for_transit, |
| 4801 | int message_id) { |
[email protected] | 27a9ef3 | 2010-09-10 04:06:24 | [diff] [blame] | 4802 | pepper_delegate_.OnAsyncFileOpened( |
| 4803 | error_code, |
| 4804 | IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
| 4805 | message_id); |
| 4806 | } |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 4807 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4808 | void RenderViewImpl::OnPpapiBrokerChannelCreated( |
[email protected] | 2b657fd | 2011-04-18 16:00:47 | [diff] [blame] | 4809 | int request_id, |
| 4810 | base::ProcessHandle broker_process_handle, |
[email protected] | d5430507 | 2011-06-22 20:58:43 | [diff] [blame] | 4811 | const IPC::ChannelHandle& handle) { |
[email protected] | 2b657fd | 2011-04-18 16:00:47 | [diff] [blame] | 4812 | pepper_delegate_.OnPpapiBrokerChannelCreated(request_id, |
| 4813 | broker_process_handle, |
| 4814 | handle); |
[email protected] | eb415bf0e | 2011-04-14 02:45:42 | [diff] [blame] | 4815 | } |
| 4816 | |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 4817 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4818 | void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { |
[email protected] | 68dc3ba | 2010-12-06 21:43:15 | [diff] [blame] | 4819 | if (external_popup_menu_ == NULL) { |
| 4820 | // Crash reports from the field indicate that we can be notified with a |
| 4821 | // NULL external popup menu (we probably get notified twice). |
| 4822 | // If you hit this please file a bug against jcivelli and include the page |
| 4823 | // and steps to repro. |
| 4824 | NOTREACHED(); |
| 4825 | return; |
| 4826 | } |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 4827 | external_popup_menu_->DidSelectItem(selected_index); |
| 4828 | external_popup_menu_.reset(); |
| 4829 | } |
| 4830 | #endif |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 4831 | |
[email protected] | 1b4209f | 2011-01-07 00:25:40 | [diff] [blame] | 4832 | #if defined(ENABLE_FLAPPER_HACKS) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4833 | void RenderViewImpl::OnConnectTcpACK( |
[email protected] | 1b4209f | 2011-01-07 00:25:40 | [diff] [blame] | 4834 | int request_id, |
| 4835 | IPC::PlatformFileForTransit socket_for_transit, |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 4836 | const PP_NetAddress_Private& local_addr, |
| 4837 | const PP_NetAddress_Private& remote_addr) { |
[email protected] | 1b4209f | 2011-01-07 00:25:40 | [diff] [blame] | 4838 | pepper_delegate_.OnConnectTcpACK( |
| 4839 | request_id, |
| 4840 | IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), |
| 4841 | local_addr, |
| 4842 | remote_addr); |
| 4843 | } |
| 4844 | #endif |
[email protected] | a6097f4 | 2011-01-10 08:50:51 | [diff] [blame] | 4845 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4846 | void RenderViewImpl::OnContextMenuClosed( |
[email protected] | b29aa74b | 2011-01-31 21:41:08 | [diff] [blame] | 4847 | const webkit_glue::CustomContextMenuContext& custom_context) { |
| 4848 | if (custom_context.is_pepper_menu) |
| 4849 | pepper_delegate_.OnContextMenuClosed(custom_context); |
| 4850 | else |
| 4851 | context_menu_node_.reset(); |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 4852 | } |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 4853 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4854 | void RenderViewImpl::OnEnableViewSourceMode() { |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 4855 | if (!webview()) |
| 4856 | return; |
| 4857 | WebFrame* main_frame = webview()->mainFrame(); |
| 4858 | if (!main_frame) |
| 4859 | return; |
| 4860 | main_frame->enableViewSourceMode(true); |
| 4861 | } |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 4862 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4863 | void RenderViewImpl::OnLockMouseACK(bool succeeded) { |
[email protected] | 57e02be | 2011-10-11 19:00:53 | [diff] [blame] | 4864 | // Mouse Lock removes the system cursor and provides all mouse motion as |
| 4865 | // .movementX/Y values on events all sent to a fixed target. This requires |
| 4866 | // content to specifically request the mode to be entered. |
| 4867 | // Mouse Capture is implicitly given for the duration of a drag event, and |
| 4868 | // sends all mouse events to the initial target of the drag. |
| 4869 | // If Lock is entered it supercedes any in progress Capture. |
| 4870 | if (succeeded) |
| 4871 | OnMouseCaptureLost(); |
| 4872 | |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 4873 | pepper_delegate_.OnLockMouseACK(succeeded); |
| 4874 | } |
| 4875 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4876 | void RenderViewImpl::OnMouseLockLost() { |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 4877 | pepper_delegate_.OnMouseLockLost(); |
| 4878 | } |
[email protected] | c3d4553 | 2011-10-07 19:20:40 | [diff] [blame] | 4879 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4880 | bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
[email protected] | ab21f2c | 2011-11-19 00:50:08 | [diff] [blame] | 4881 | return !!RenderThreadImpl::current()->compositor_thread(); |
[email protected] | c3d4553 | 2011-10-07 19:20:40 | [diff] [blame] | 4882 | } |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 4883 | |
[email protected] | 64d0e19 | 2011-12-09 14:44:20 | [diff] [blame] | 4884 | void RenderViewImpl::OnJavaBridgeInit() { |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 4885 | DCHECK(!java_bridge_dispatcher_.get()); |
[email protected] | 464750f | 2011-10-24 23:16:18 | [diff] [blame] | 4886 | #if defined(ENABLE_JAVA_BRIDGE) |
[email protected] | 64d0e19 | 2011-12-09 14:44:20 | [diff] [blame] | 4887 | java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
[email protected] | 464750f | 2011-10-24 23:16:18 | [diff] [blame] | 4888 | #endif |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 4889 | } |