[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] | b1cf337 | 2011-04-20 21:28:10 | [diff] [blame] | 16 | #include "base/json/json_writer.h" |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 17 | #include "base/lazy_instance.h" |
[email protected] | 835d7c8 | 2010-10-14 04:38:38 | [diff] [blame] | 18 | #include "base/metrics/histogram.h" |
[email protected] | 7bf795d9 | 2010-05-22 00:14:28 | [diff] [blame] | 19 | #include "base/path_service.h" |
[email protected] | 8380c09 | 2009-06-25 17:45:51 | [diff] [blame] | 20 | #include "base/process_util.h" |
[email protected] | 7ddea980 | 2012-02-22 23:08:05 | [diff] [blame] | 21 | #include "base/string_number_conversions.h" |
[email protected] | 0a35efc | 2012-03-13 17:28:13 | [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] | 16dd6e2 | 2012-03-01 19:08:20 | [diff] [blame] | 32 | #include "content/common/fileapi/file_system_dispatcher.h" |
| 33 | #include "content/common/fileapi/webfilesystem_callback_dispatcher.h" |
[email protected] | c26ad88 | 2012-02-07 06:41:20 | [diff] [blame] | 34 | #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 35 | #include "content/common/intents_messages.h" |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 36 | #include "content/common/java_bridge_messages.h" |
[email protected] | 127dd58 | 2011-03-16 21:32:10 | [diff] [blame] | 37 | #include "content/common/pepper_messages.h" |
[email protected] | cebc3dc | 2011-04-18 17:15:00 | [diff] [blame] | 38 | #include "content/common/pepper_plugin_registry.h" |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 39 | #include "content/common/quota_dispatcher.h" |
[email protected] | 940895b | 2011-08-20 00:50:05 | [diff] [blame] | 40 | #include "content/common/request_extra_data.h" |
[email protected] | 778574e | 2011-03-21 22:03:50 | [diff] [blame] | 41 | #include "content/common/view_messages.h" |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 42 | #include "content/public/common/bindings_policy.h" |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 43 | #include "content/public/common/content_constants.h" |
[email protected] | c08950d2 | 2011-10-13 22:20:29 | [diff] [blame] | 44 | #include "content/public/common/content_switches.h" |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 45 | #include "content/public/common/context_menu_params.h" |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 46 | #include "content/public/common/file_chooser_params.h" |
[email protected] | fb11b6a4 | 2012-03-14 07:25:12 | [diff] [blame] | 47 | #include "content/public/common/selected_file_info.h" |
[email protected] | a1d2916 | 2011-10-14 17:14:03 | [diff] [blame] | 48 | #include "content/public/common/url_constants.h" |
[email protected] | d344114c | 2011-10-01 01:24:34 | [diff] [blame] | 49 | #include "content/public/renderer/content_renderer_client.h" |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 50 | #include "content/public/renderer/document_state.h" |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 51 | #include "content/public/renderer/navigation_state.h" |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 52 | #include "content/public/renderer/render_view_observer.h" |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 53 | #include "content/public/renderer/render_view_visitor.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 54 | #include "content/renderer/device_orientation_dispatcher.h" |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 55 | #include "content/renderer/devtools_agent.h" |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 56 | #include "content/renderer/dom_automation_controller.h" |
[email protected] | 5572215 | 2011-03-22 01:33:53 | [diff] [blame] | 57 | #include "content/renderer/external_popup_menu.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 58 | #include "content/renderer/geolocation_dispatcher.h" |
[email protected] | 84a83e19 | 2012-03-09 18:43:40 | [diff] [blame] | 59 | #include "content/renderer/gpu/compositor_thread.h" |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 60 | #include "content/renderer/idle_user_detector.h" |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 61 | #include "content/renderer/input_tag_speech_dispatcher.h" |
[email protected] | 0716190 | 2011-11-11 09:57:42 | [diff] [blame] | 62 | #include "content/renderer/java/java_bridge_dispatcher.h" |
[email protected] | 921f159 | 2011-03-18 00:41:02 | [diff] [blame] | 63 | #include "content/renderer/load_progress_tracker.h" |
[email protected] | 25803d15 | 2011-06-14 01:18:08 | [diff] [blame] | 64 | #include "content/renderer/media/audio_message_filter.h" |
[email protected] | ccc70d8e | 2011-03-16 20:40:37 | [diff] [blame] | 65 | #include "content/renderer/media/audio_renderer_impl.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 66 | #include "content/renderer/media/media_stream_dependency_factory.h" |
| 67 | #include "content/renderer/media/media_stream_dispatcher.h" |
[email protected] | ab2c473 | 2011-07-20 19:57:40 | [diff] [blame] | 68 | #include "content/renderer/media/media_stream_impl.h" |
[email protected] | 6048d51 | 2012-01-28 03:14:48 | [diff] [blame] | 69 | #include "content/renderer/media/render_audiosourceprovider.h" |
[email protected] | 090f731 | 2011-08-05 23:26:40 | [diff] [blame] | 70 | #include "content/renderer/media/render_media_log.h" |
[email protected] | 6048d51 | 2012-01-28 03:14:48 | [diff] [blame] | 71 | #include "content/renderer/media/renderer_gpu_video_decoder_factories.h" |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 72 | #include "content/renderer/mhtml_generator.h" |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 73 | #include "content/renderer/mouse_lock_dispatcher.h" |
[email protected] | 230b7ef | 2011-03-16 22:30:19 | [diff] [blame] | 74 | #include "content/renderer/notification_provider.h" |
[email protected] | ccc70d8e | 2011-03-16 20:40:37 | [diff] [blame] | 75 | #include "content/renderer/p2p/socket_dispatcher.h" |
[email protected] | 6f51608 | 2011-03-17 19:15:35 | [diff] [blame] | 76 | #include "content/renderer/plugin_channel_host.h" |
[email protected] | 0361b94 | 2012-03-14 06:42:53 | [diff] [blame] | 77 | #include "content/renderer/browser_plugin/browser_plugin_constants.h" |
| 78 | #include "content/renderer/browser_plugin/browser_plugin_placeholder.h" |
[email protected] | 8704f89b | 2011-04-15 00:30:05 | [diff] [blame] | 79 | #include "content/renderer/render_process.h" |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 80 | #include "content/renderer/render_thread_impl.h" |
[email protected] | 2cff005 | 2011-03-18 16:51:44 | [diff] [blame] | 81 | #include "content/renderer/render_widget_fullscreen_pepper.h" |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 82 | #include "content/renderer/renderer_accessibility.h" |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 83 | #include "content/renderer/renderer_webapplicationcachehost_impl.h" |
| 84 | #include "content/renderer/renderer_webstoragenamespace_impl.h" |
[email protected] | 86a7d3c | 2011-09-12 16:45:32 | [diff] [blame] | 85 | #include "content/renderer/text_input_client_observer.h" |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 86 | #include "content/renderer/v8_value_converter_impl.h" |
[email protected] | 0a35efc | 2012-03-13 17:28:13 | [diff] [blame] | 87 | #include "content/renderer/web_intents_host.h" |
[email protected] | 663bd9e | 2011-03-21 01:07:01 | [diff] [blame] | 88 | #include "content/renderer/web_ui_bindings.h" |
[email protected] | 6f51608 | 2011-03-17 19:15:35 | [diff] [blame] | 89 | #include "content/renderer/webplugin_delegate_proxy.h" |
| 90 | #include "content/renderer/websharedworker_proxy.h" |
[email protected] | f8db813 | 2010-12-03 00:27:49 | [diff] [blame] | 91 | #include "media/base/filter_collection.h" |
[email protected] | ee68378a | 2010-08-10 01:05:41 | [diff] [blame] | 92 | #include "media/base/media_switches.h" |
[email protected] | b8032290 | 2012-03-06 01:33:50 | [diff] [blame] | 93 | #include "media/base/message_loop_factory.h" |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 94 | #include "media/filters/gpu_video_decoder.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 95 | #include "net/base/escape.h" |
| 96 | #include "net/base/net_errors.h" |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 97 | #include "net/http/http_util.h" |
[email protected] | 9d9f1bb | 2011-02-23 22:10:57 | [diff] [blame] | 98 | #include "ppapi/c/private/ppb_flash_net_connector.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 99 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebAccessibilityObject.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 100 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 101 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 102 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 103 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileChooserParams.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 104 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFileSystemCallbacks.h" |
| 105 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFindOptions.h" |
| 106 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" |
| 107 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFormElement.h" |
| 108 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 109 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebHistoryItem.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 110 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 111 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 112 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" |
[email protected] | 592e20b | 2012-01-20 05:53:44 | [diff] [blame] | 113 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentRequest.h" |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 114 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntentServiceInfo.h" |
[email protected] | 69f110d6 | 2011-03-17 19:01:14 | [diff] [blame] | 115 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebMediaPlayerAction.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 116 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeList.h" |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 117 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPageSerializer.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 118 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 119 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginAction.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 120 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
| 121 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginDocument.h" |
| 122 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginParams.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 123 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebRange.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 124 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" |
| 125 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSearchableFormData.h" |
| 126 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityOrigin.h" |
[email protected] | 20dc3cad | 2011-04-20 17:27:17 | [diff] [blame] | 127 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSecurityPolicy.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 128 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebSettings.h" |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 129 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageNamespace.h" |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 130 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageQuotaCallbacks.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 131 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebUserMediaClient.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 132 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
| 133 | #include "third_party/WebKit/Source/WebKit/chromium/public/WebWindowFeatures.h" |
| 134 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCString.h" |
| 135 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebDragData.h" |
| 136 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h" |
| 137 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebImage.h" |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 138 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h" |
| 139 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPeerConnectionHandlerClient.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 140 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h" |
| 141 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebRect.h" |
| 142 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSize.h" |
[email protected] | e6e90dc | 2011-12-03 00:01:37 | [diff] [blame] | 143 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 144 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" |
| 145 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLError.h" |
| 146 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLRequest.h" |
| 147 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURLResponse.h" |
| 148 | #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 149 | #include "third_party/skia/include/core/SkBitmap.h" |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 150 | #include "ui/base/javascript_message_type.h" |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 151 | #include "ui/gfx/native_widget_types.h" |
| 152 | #include "ui/gfx/point.h" |
| 153 | #include "ui/gfx/rect.h" |
[email protected] | c4a9e93 | 2011-03-05 04:05:55 | [diff] [blame] | 154 | #include "v8/include/v8.h" |
[email protected] | 80f584d9 | 2010-01-21 03:59:04 | [diff] [blame] | 155 | #include "webkit/appcache/web_application_cache_host_impl.h" |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 156 | #include "webkit/forms/form_data.h" |
| 157 | #include "webkit/forms/form_field.h" |
| 158 | #include "webkit/forms/password_form_dom_manager.h" |
[email protected] | 25e18f8 | 2010-10-27 16:38:43 | [diff] [blame] | 159 | #include "webkit/glue/alt_error_page_resource_fetcher.h" |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 160 | #include "webkit/glue/dom_operations.h" |
[email protected] | 95056b58 | 2010-02-18 01:29:24 | [diff] [blame] | 161 | #include "webkit/glue/glue_serialize.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 162 | #include "webkit/glue/webdropdata.h" |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 163 | #include "webkit/glue/webkit_constants.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 164 | #include "webkit/glue/webkit_glue.h" |
[email protected] | b00ba70 | 2011-08-17 01:41:03 | [diff] [blame] | 165 | #include "webkit/glue/weburlloader_impl.h" |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 166 | #include "webkit/glue/weburlresponse_extradata_impl.h" |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 167 | #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h" |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 168 | #include "webkit/media/webmediaplayer_impl.h" |
[email protected] | 191eb3f7 | 2010-12-21 06:27:50 | [diff] [blame] | 169 | #include "webkit/plugins/npapi/plugin_list.h" |
| 170 | #include "webkit/plugins/npapi/webplugin_delegate.h" |
| 171 | #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
| 172 | #include "webkit/plugins/npapi/webplugin_impl.h" |
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 173 | #include "webkit/plugins/ppapi/ppapi_webplugin_impl.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 174 | |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 175 | #if defined(OS_WIN) |
| 176 | // TODO(port): these files are currently Windows only because they concern: |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 177 | // * theming |
[email protected] | 08397d5 | 2011-02-05 01:53:38 | [diff] [blame] | 178 | #include "ui/gfx/native_theme_win.h" |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 179 | #elif defined(USE_X11) |
[email protected] | 8bd0fe6 | 2011-01-17 06:44:37 | [diff] [blame] | 180 | #include "third_party/WebKit/Source/WebKit/chromium/public/linux/WebRenderTheme.h" |
[email protected] | 42e5c86 | 2011-04-07 22:13:51 | [diff] [blame] | 181 | #include "ui/gfx/native_theme.h" |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 182 | #elif defined(OS_MACOSX) |
| 183 | #include "skia/ext/skia_utils_mac.h" |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 184 | #endif |
| 185 | |
[email protected] | 9892b47 | 2010-09-16 00:23:42 | [diff] [blame] | 186 | using WebKit::WebAccessibilityNotification; |
[email protected] | cc0445f | 2009-10-13 16:09:08 | [diff] [blame] | 187 | using WebKit::WebAccessibilityObject; |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 188 | using WebKit::WebApplicationCacheHost; |
| 189 | using WebKit::WebApplicationCacheHostClient; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 190 | using WebKit::WebCString; |
[email protected] | 1c83eb4 | 2009-09-11 21:08:41 | [diff] [blame] | 191 | using WebKit::WebColor; |
| 192 | using WebKit::WebColorName; |
[email protected] | 0dea3ea | 2009-03-31 23:30:59 | [diff] [blame] | 193 | using WebKit::WebConsoleMessage; |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 194 | using WebKit::WebContextMenuData; |
[email protected] | b921cfd2 | 2010-02-25 16:57:51 | [diff] [blame] | 195 | using WebKit::WebCookieJar; |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 196 | using WebKit::WebData; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 197 | using WebKit::WebDataSource; |
[email protected] | 5bc8fe9 | 2010-03-11 18:19:00 | [diff] [blame] | 198 | using WebKit::WebDocument; |
[email protected] | e80c73b | 2009-04-07 23:24:58 | [diff] [blame] | 199 | using WebKit::WebDragData; |
[email protected] | 1d9f413 | 2009-09-08 17:29:25 | [diff] [blame] | 200 | using WebKit::WebDragOperation; |
| 201 | using WebKit::WebDragOperationsMask; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 202 | using WebKit::WebEditingAction; |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 203 | using WebKit::WebElement; |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 204 | using WebKit::WebExternalPopupMenu; |
| 205 | using WebKit::WebExternalPopupMenuClient; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 206 | using WebKit::WebFileChooserCompletion; |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 207 | using WebKit::WebFileSystem; |
| 208 | using WebKit::WebFileSystemCallbacks; |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 209 | using WebKit::WebFindOptions; |
[email protected] | b143821 | 2010-04-03 00:30:59 | [diff] [blame] | 210 | using WebKit::WebFormControlElement; |
[email protected] | 979c28b | 2009-11-07 01:30:48 | [diff] [blame] | 211 | using WebKit::WebFormElement; |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 212 | using WebKit::WebFrame; |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 213 | using WebKit::WebGraphicsContext3D; |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 214 | using WebKit::WebHistoryItem; |
[email protected] | 42054a25 | 2011-05-17 18:02:13 | [diff] [blame] | 215 | using WebKit::WebIconURL; |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 216 | using WebKit::WebImage; |
[email protected] | e6efd02 | 2010-03-31 09:34:50 | [diff] [blame] | 217 | using WebKit::WebInputElement; |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 218 | using WebKit::WebIntentRequest; |
| 219 | using WebKit::WebIntentServiceInfo; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 220 | using WebKit::WebMediaPlayer; |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 221 | using WebKit::WebMediaPlayerAction; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 222 | using WebKit::WebMediaPlayerClient; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 223 | using WebKit::WebNavigationPolicy; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 224 | using WebKit::WebNavigationType; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 225 | using WebKit::WebNode; |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 226 | using WebKit::WebPageSerializer; |
| 227 | using WebKit::WebPageSerializerClient; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 228 | using WebKit::WebPlugin; |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 229 | using WebKit::WebPluginAction; |
[email protected] | 00152e9 | 2010-07-19 11:47:40 | [diff] [blame] | 230 | using WebKit::WebPluginContainer; |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 231 | using WebKit::WebPluginDocument; |
[email protected] | aad51d1c | 2010-08-05 08:38:09 | [diff] [blame] | 232 | using WebKit::WebPluginParams; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 233 | using WebKit::WebPoint; |
[email protected] | 88efb7ec | 2009-07-14 16:32:59 | [diff] [blame] | 234 | using WebKit::WebPopupMenuInfo; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 235 | using WebKit::WebRange; |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 236 | using WebKit::WebRect; |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 237 | using WebKit::WebReferrerPolicy; |
[email protected] | 4f99913 | 2009-03-31 18:08:40 | [diff] [blame] | 238 | using WebKit::WebScriptSource; |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 239 | using WebKit::WebSearchableFormData; |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 240 | using WebKit::WebSecurityOrigin; |
[email protected] | 20dc3cad | 2011-04-20 17:27:17 | [diff] [blame] | 241 | using WebKit::WebSecurityPolicy; |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 242 | using WebKit::WebSettings; |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 243 | using WebKit::WebSharedWorker; |
[email protected] | 8649fb3 | 2009-06-26 17:51:02 | [diff] [blame] | 244 | using WebKit::WebSize; |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 245 | using WebKit::WebStorageNamespace; |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 246 | using WebKit::WebStorageQuotaCallbacks; |
| 247 | using WebKit::WebStorageQuotaError; |
| 248 | using WebKit::WebStorageQuotaType; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 249 | using WebKit::WebString; |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 250 | using WebKit::WebTextAffinity; |
[email protected] | de570ef | 2009-07-29 18:27:52 | [diff] [blame] | 251 | using WebKit::WebTextDirection; |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 252 | using WebKit::WebTouchEvent; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 253 | using WebKit::WebURL; |
| 254 | using WebKit::WebURLError; |
| 255 | using WebKit::WebURLRequest; |
| 256 | using WebKit::WebURLResponse; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 257 | using WebKit::WebVector; |
[email protected] | 50ae00ef | 2009-10-19 05:11:03 | [diff] [blame] | 258 | using WebKit::WebView; |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 259 | using WebKit::WebWidget; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 260 | using WebKit::WebWindowFeatures; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 261 | using appcache::WebApplicationCacheHostImpl; |
| 262 | using base::Time; |
| 263 | using base::TimeDelta; |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 264 | using content::DocumentState; |
[email protected] | 82ddba1c | 2011-10-04 00:15:32 | [diff] [blame] | 265 | using content::NavigationState; |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 266 | using content::RenderThread; |
[email protected] | 3a034ebb | 2011-10-03 19:19:44 | [diff] [blame] | 267 | using content::RenderViewObserver; |
[email protected] | 64ffa044 | 2011-10-03 22:08:36 | [diff] [blame] | 268 | using content::RenderViewVisitor; |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 269 | using content::Referrer; |
[email protected] | 8d86f13d | 2011-10-04 17:01:19 | [diff] [blame] | 270 | using content::V8ValueConverter; |
[email protected] | 9c4bf23 | 2011-12-15 02:25:08 | [diff] [blame] | 271 | using webkit::forms::FormField; |
| 272 | using webkit::forms::PasswordForm; |
| 273 | using webkit::forms::PasswordFormDomManager; |
[email protected] | 6fdd418 | 2010-10-14 23:59:26 | [diff] [blame] | 274 | using webkit_glue::AltErrorPageResourceFetcher; |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 275 | using webkit_glue::ResourceFetcher; |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 276 | using webkit_glue::WebURLResponseExtraDataImpl; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 277 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 278 | //----------------------------------------------------------------------------- |
| 279 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 280 | typedef std::map<WebKit::WebView*, RenderViewImpl*> ViewMap; |
[email protected] | 6de0fd1d | 2011-11-15 13:31:49 | [diff] [blame] | 281 | static base::LazyInstance<ViewMap> g_view_map = LAZY_INSTANCE_INITIALIZER; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 282 | |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 283 | // Time, in seconds, we delay before sending content state changes (such as form |
| 284 | // state and scroll position) to the browser. We delay sending changes to avoid |
| 285 | // spamming the browser. |
| 286 | // To avoid having tab/session restore require sending a message to get the |
| 287 | // current content state during tab closing we use a shorter timeout for the |
| 288 | // foreground renderer. This means there is a small window of time from which |
| 289 | // content state is modified and not sent to session restore, but this is |
| 290 | // better than having to wake up all renderers during shutdown. |
| 291 | static const int kDelaySecondsForContentStateSyncHidden = 5; |
| 292 | static const int kDelaySecondsForContentStateSync = 1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 293 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 294 | static const size_t kExtraCharsBeforeAndAfterSelection = 100; |
| 295 | |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 296 | // The maximum number of popups that can be spawned from one page. |
| 297 | static const int kMaximumNumberOfUnacknowledgedPopups = 25; |
| 298 | |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 299 | static const float kScalingIncrement = 0.1f; |
| 300 | |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 301 | static const float kScalingIncrementForGesture = 0.01f; |
| 302 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 303 | static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) { |
| 304 | WebVector<WebURL> urls; |
| 305 | ds->redirectChain(urls); |
| 306 | result->reserve(urls.size()); |
| 307 | for (size_t i = 0; i < urls.size(); ++i) |
| 308 | result->push_back(urls[i]); |
| 309 | } |
| 310 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 311 | // If |data_source| is non-null and has a DocumentState associated with it, |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 312 | // the AltErrorPageResourceFetcher is reset. |
| 313 | static void StopAltErrorPageFetcher(WebDataSource* data_source) { |
| 314 | if (data_source) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 315 | DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 316 | if (document_state) |
| 317 | document_state->set_alt_error_page_fetcher(NULL); |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 318 | } |
| 319 | } |
| 320 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 321 | static bool IsReload(const ViewMsg_Navigate_Params& params) { |
| 322 | return |
| 323 | params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
| 324 | params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
| 325 | } |
| 326 | |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 327 | static WebReferrerPolicy GetReferrerPolicyFromRequest( |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 328 | const WebURLRequest& request) { |
| 329 | return request.extraData() ? |
| 330 | static_cast<RequestExtraData*>(request.extraData())->referrer_policy() : |
| 331 | WebKit::WebReferrerPolicyDefault; |
| 332 | } |
| 333 | |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 334 | static WebURLResponseExtraDataImpl* GetExtraDataFromResponse( |
| 335 | const WebURLResponse& response) { |
| 336 | return static_cast<WebURLResponseExtraDataImpl*>( |
| 337 | response.extraData()); |
| 338 | } |
| 339 | |
[email protected] | 2149cc62 | 2012-02-14 01:12:12 | [diff] [blame] | 340 | NOINLINE static void CrashIntentionally() { |
| 341 | // NOTE(shess): Crash directly rather than using NOTREACHED() so |
| 342 | // that the signature is easier to triage in crash reports. |
| 343 | volatile int* zero = NULL; |
| 344 | *zero = 0; |
| 345 | } |
| 346 | |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 347 | static void MaybeHandleDebugURL(const GURL& url) { |
| 348 | if (!url.SchemeIs(chrome::kChromeUIScheme)) |
| 349 | return; |
| 350 | if (url == GURL(chrome::kChromeUICrashURL)) { |
[email protected] | 2149cc62 | 2012-02-14 01:12:12 | [diff] [blame] | 351 | CrashIntentionally(); |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 352 | } else if (url == GURL(chrome::kChromeUIKillURL)) { |
| 353 | base::KillProcess(base::GetCurrentProcessHandle(), 1, false); |
| 354 | } else if (url == GURL(chrome::kChromeUIHangURL)) { |
| 355 | for (;;) { |
| 356 | base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(1)); |
| 357 | } |
| 358 | } else if (url == GURL(chrome::kChromeUIShorthangURL)) { |
| 359 | base::PlatformThread::Sleep(base::TimeDelta::FromSeconds(20)); |
| 360 | } |
| 361 | } |
| 362 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 363 | /////////////////////////////////////////////////////////////////////////////// |
| 364 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 365 | struct RenderViewImpl::PendingFileChooser { |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 366 | PendingFileChooser(const content::FileChooserParams& p, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 367 | WebFileChooserCompletion* c) |
| 368 | : params(p), |
| 369 | completion(c) { |
| 370 | } |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 371 | content::FileChooserParams params; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 372 | WebFileChooserCompletion* completion; // MAY BE NULL to skip callback. |
| 373 | }; |
| 374 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 375 | namespace { |
| 376 | |
| 377 | class WebWidgetLockTarget : public MouseLockDispatcher::LockTarget { |
| 378 | public: |
| 379 | WebWidgetLockTarget (WebKit::WebWidget* webwidget) |
| 380 | : webwidget_(webwidget) {} |
| 381 | |
| 382 | virtual void OnLockMouseACK(bool succeeded) OVERRIDE { |
| 383 | if (succeeded) |
| 384 | webwidget_->didAcquirePointerLock(); |
| 385 | else |
| 386 | webwidget_->didNotAcquirePointerLock(); |
| 387 | } |
| 388 | |
| 389 | virtual void OnMouseLockLost() OVERRIDE { |
| 390 | webwidget_->didLosePointerLock(); |
| 391 | } |
| 392 | |
| 393 | virtual bool HandleMouseLockedInputEvent( |
| 394 | const WebKit::WebMouseEvent &event) OVERRIDE { |
| 395 | // The WebWidget handles mouse lock in WebKit's handleInputEvent(). |
| 396 | return false; |
| 397 | } |
| 398 | |
| 399 | private: |
| 400 | WebKit::WebWidget* webwidget_; |
| 401 | }; |
| 402 | |
[email protected] | 86cd947 | 2012-02-03 19:51:05 | [diff] [blame] | 403 | int64 ExtractPostId(const WebHistoryItem& item) { |
| 404 | if (item.isNull()) |
| 405 | return -1; |
| 406 | |
| 407 | if (item.httpBody().isNull()) |
| 408 | return -1; |
| 409 | |
| 410 | return item.httpBody().identifier(); |
| 411 | } |
| 412 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 413 | } // namespace |
| 414 | |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 415 | RenderViewImpl::RenderViewImpl( |
| 416 | gfx::NativeViewId parent_hwnd, |
| 417 | int32 opener_id, |
| 418 | const content::RendererPreferences& renderer_prefs, |
| 419 | const WebPreferences& webkit_prefs, |
| 420 | SharedRenderViewCounter* counter, |
| 421 | int32 routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 422 | int32 surface_id, |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 423 | int64 session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 424 | const string16& frame_name, |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 425 | int32 next_page_id, |
| 426 | const WebKit::WebScreenInfo& screen_info) |
| 427 | : RenderWidget(WebKit::WebPopupTypeNone, screen_info), |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 428 | webkit_preferences_(webkit_prefs), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 429 | send_content_state_immediately_(false), |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 430 | enabled_bindings_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 431 | send_preferred_size_changes_(false), |
[email protected] | 81a3441 | 2009-01-05 19:17:24 | [diff] [blame] | 432 | is_loading_(false), |
[email protected] | e75cb49e | 2009-01-05 23:13:21 | [diff] [blame] | 433 | navigation_gesture_(NavigationGestureUnknown), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 434 | opened_by_user_gesture_(true), |
| 435 | opener_suppressed_(false), |
[email protected] | 81a3441 | 2009-01-05 19:17:24 | [diff] [blame] | 436 | page_id_(-1), |
| 437 | last_page_id_sent_to_browser_(-1), |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 438 | next_page_id_(next_page_id), |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 439 | history_list_offset_(-1), |
| 440 | history_list_length_(0), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 441 | target_url_status_(TARGET_NONE), |
[email protected] | bbef1d3 | 2011-10-25 14:36:55 | [diff] [blame] | 442 | selection_text_offset_(0), |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 443 | cached_is_main_frame_pinned_to_left_(false), |
| 444 | cached_is_main_frame_pinned_to_right_(false), |
| 445 | cached_has_main_frame_horizontal_scrollbar_(false), |
| 446 | cached_has_main_frame_vertical_scrollbar_(false), |
[email protected] | 05a980d7a | 2012-02-07 22:16:42 | [diff] [blame] | 447 | context_has_swapbuffers_complete_callback_(false), |
| 448 | queried_for_swapbuffers_complete_callback_(false), |
[email protected] | d0fb8a7 | 2012-03-10 18:54:52 | [diff] [blame] | 449 | context_is_web_graphics_context_3d_command_buffer_impl_(false), |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 450 | ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 451 | geolocation_dispatcher_(NULL), |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 452 | input_tag_speech_dispatcher_(NULL), |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 453 | device_orientation_dispatcher_(NULL), |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 454 | media_stream_dispatcher_(NULL), |
[email protected] | cae8c849 | 2011-03-03 11:12:18 | [diff] [blame] | 455 | p2p_socket_dispatcher_(NULL), |
[email protected] | c5c1d6d | 2011-07-28 18:42:41 | [diff] [blame] | 456 | devtools_agent_(NULL), |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 457 | renderer_accessibility_(NULL), |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 458 | mouse_lock_dispatcher_(NULL), |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 459 | session_storage_namespace_id_(session_storage_namespace_id), |
[email protected] | ef5e98e | 2011-12-06 09:49:18 | [diff] [blame] | 460 | handling_select_range_(false), |
| 461 | #if defined(OS_WIN) |
| 462 | focused_plugin_id_(-1), |
| 463 | #endif |
| 464 | ALLOW_THIS_IN_INITIALIZER_LIST(pepper_delegate_(this)) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 465 | routing_id_ = routing_id; |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 466 | surface_id_ = surface_id; |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 467 | if (opener_id != MSG_ROUTING_NONE) |
| 468 | opener_id_ = opener_id; |
| 469 | |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 470 | // Ensure we start with a valid next_page_id_ from the browser. |
| 471 | DCHECK_GE(next_page_id_, 0); |
| 472 | |
[email protected] | 21b3a6ae | 2011-11-30 00:45:29 | [diff] [blame] | 473 | #if defined(ENABLE_NOTIFICATIONS) |
| 474 | notification_provider_ = new NotificationProvider(this); |
| 475 | #else |
| 476 | notification_provider_ = NULL; |
| 477 | #endif |
| 478 | |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 479 | webwidget_ = WebView::create(this); |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 480 | webwidget_mouse_lock_target_.reset(new WebWidgetLockTarget(webwidget_)); |
[email protected] | 11fee233 | 2011-03-29 20:36:35 | [diff] [blame] | 481 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 482 | if (counter) { |
| 483 | shared_popup_counter_ = counter; |
| 484 | shared_popup_counter_->data++; |
| 485 | decrement_shared_popup_at_destruction_ = true; |
| 486 | } else { |
| 487 | shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 488 | decrement_shared_popup_at_destruction_ = false; |
| 489 | } |
| 490 | |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 491 | RenderThread::Get()->AddRoute(routing_id_, this); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 492 | // Take a reference on behalf of the RenderThread. This will be balanced |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 493 | // when we receive ViewMsg_ClosePage. |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 494 | AddRef(); |
| 495 | |
| 496 | // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 497 | // completing initialization. Otherwise, we can finish it now. |
| 498 | if (opener_id == MSG_ROUTING_NONE) { |
| 499 | did_show_ = true; |
[email protected] | 2d7c855 | 2011-06-27 19:21:55 | [diff] [blame] | 500 | CompleteInit(parent_hwnd); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 501 | } |
| 502 | |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 503 | g_view_map.Get().insert(std::make_pair(webview(), this)); |
| 504 | webkit_preferences_.Apply(webview()); |
| 505 | webview()->initializeMainFrame(this); |
[email protected] | 2024c92 | 2011-09-02 23:34:35 | [diff] [blame] | 506 | if (!frame_name.empty()) |
| 507 | webview()->mainFrame()->setName(frame_name); |
[email protected] | 34c61bd5 | 2011-05-02 19:38:33 | [diff] [blame] | 508 | webview()->settings()->setMinimumTimerInterval( |
| 509 | is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
| 510 | webkit_glue::kForegroundTabTimerInterval); |
| 511 | |
| 512 | OnSetRendererPrefs(renderer_prefs); |
| 513 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 514 | host_window_ = parent_hwnd; |
| 515 | |
[email protected] | a026daa | 2011-04-20 15:49:51 | [diff] [blame] | 516 | #if defined(ENABLE_P2P_APIS) |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 517 | if (!p2p_socket_dispatcher_) |
| 518 | p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
[email protected] | a026daa | 2011-04-20 15:49:51 | [diff] [blame] | 519 | #endif |
[email protected] | cae8c849 | 2011-03-03 11:12:18 | [diff] [blame] | 520 | |
[email protected] | 5b87e78 | 2012-02-09 18:19:32 | [diff] [blame] | 521 | #if defined(ENABLE_WEBRTC) |
[email protected] | 735873d | 2012-01-25 23:31:02 | [diff] [blame] | 522 | if (!media_stream_dispatcher_) |
| 523 | media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
[email protected] | 5b87e78 | 2012-02-09 18:19:32 | [diff] [blame] | 524 | #endif |
[email protected] | 735873d | 2012-01-25 23:31:02 | [diff] [blame] | 525 | |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 526 | new MHTMLGenerator(this); |
[email protected] | 86a7d3c | 2011-09-12 16:45:32 | [diff] [blame] | 527 | #if defined(OS_MACOSX) |
| 528 | new TextInputClientObserver(this); |
| 529 | #endif // defined(OS_MACOSX) |
[email protected] | 8f6a3b85 | 2011-07-19 16:48:56 | [diff] [blame] | 530 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 531 | // The next group of objects all implement RenderViewObserver, so are deleted |
| 532 | // along with the RenderView automatically. |
[email protected] | c5c1d6d | 2011-07-28 18:42:41 | [diff] [blame] | 533 | devtools_agent_ = new DevToolsAgent(this); |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 534 | renderer_accessibility_ = new RendererAccessibility(this); |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 535 | mouse_lock_dispatcher_ = new MouseLockDispatcher(this); |
[email protected] | 0fc7dea7 | 2012-02-09 03:47:40 | [diff] [blame] | 536 | intents_host_ = new WebIntentsHost(this); |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 537 | |
[email protected] | 1784b2f | 2011-11-24 10:53:48 | [diff] [blame] | 538 | new IdleUserDetector(this); |
| 539 | |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 540 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 541 | if (command_line.HasSwitch(switches::kDomAutomationController)) |
| 542 | enabled_bindings_ |= content::BINDINGS_POLICY_DOM_AUTOMATION; |
| 543 | |
[email protected] | 7ddea980 | 2012-02-22 23:08:05 | [diff] [blame] | 544 | bool enable_fixed_layout = |
| 545 | command_line.HasSwitch(switches::kEnableFixedLayout); |
| 546 | webview()->enableFixedLayoutMode(enable_fixed_layout); |
| 547 | if (enable_fixed_layout) |
| 548 | webview()->settings()->setFixedElementsLayoutRelativeToFrame(true); |
[email protected] | 7ddea980 | 2012-02-22 23:08:05 | [diff] [blame] | 549 | |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 550 | content::GetContentClient()->renderer()->RenderViewCreated(this); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 551 | } |
| 552 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 553 | RenderViewImpl::~RenderViewImpl() { |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 554 | history_page_ids_.clear(); |
| 555 | |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 556 | if (decrement_shared_popup_at_destruction_) |
| 557 | shared_popup_counter_->data--; |
| 558 | |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 559 | // If file chooser is still waiting for answer, dispatch empty answer. |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 560 | while (!file_chooser_completions_.empty()) { |
| 561 | if (file_chooser_completions_.front()->completion) { |
| 562 | file_chooser_completions_.front()->completion->didChooseFile( |
| 563 | WebVector<WebString>()); |
| 564 | } |
| 565 | file_chooser_completions_.pop_front(); |
| 566 | } |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 567 | |
[email protected] | 83dde54 | 2009-09-11 20:59:55 | [diff] [blame] | 568 | #if defined(OS_MACOSX) |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 569 | // Destroy all fake plugin window handles on the browser side. |
| 570 | while (!fake_plugin_window_handles_.empty()) { |
| 571 | // Make sure no NULL plugin window handles were inserted into this list. |
| 572 | DCHECK(*fake_plugin_window_handles_.begin()); |
| 573 | // DestroyFakePluginWindowHandle modifies fake_plugin_window_handles_. |
| 574 | DestroyFakePluginWindowHandle(*fake_plugin_window_handles_.begin()); |
| 575 | } |
[email protected] | 83dde54 | 2009-09-11 20:59:55 | [diff] [blame] | 576 | #endif |
[email protected] | 9832489 | 2009-09-09 21:16:05 | [diff] [blame] | 577 | |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 578 | #ifndef NDEBUG |
| 579 | // Make sure we are no longer referenced by the ViewMap. |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 580 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 581 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) |
| 582 | DCHECK_NE(this, it->second) << "Failed to call Close?"; |
| 583 | #endif |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 584 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 585 | // MediaStreamImpl holds weak references to RenderViewObserver objects, |
| 586 | // ensure it's deleted before the observers. |
| 587 | media_stream_impl_ = NULL; |
| 588 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 589 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, RenderViewGone()); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 590 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, OnDestruct()); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 591 | } |
| 592 | |
| 593 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 594 | RenderViewImpl* RenderViewImpl::FromWebView(WebView* webview) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 595 | ViewMap* views = g_view_map.Pointer(); |
| 596 | ViewMap::iterator it = views->find(webview); |
| 597 | return it == views->end() ? NULL : it->second; |
| 598 | } |
| 599 | |
| 600 | /*static*/ |
| 601 | content::RenderView* |
| 602 | content::RenderView::FromWebView(WebKit::WebView* webview) { |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 603 | return RenderViewImpl::FromWebView(webview); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | /*static*/ |
| 607 | void content::RenderView::ForEach(content::RenderViewVisitor* visitor) { |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 608 | ViewMap* views = g_view_map.Pointer(); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 609 | for (ViewMap::iterator it = views->begin(); it != views->end(); ++it) { |
| 610 | if (!visitor->Visit(it->second)) |
| 611 | return; |
| 612 | } |
| 613 | } |
| 614 | |
| 615 | /*static*/ |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 616 | RenderViewImpl* RenderViewImpl::Create( |
[email protected] | 18bcc3c | 2009-01-27 21:39:15 | [diff] [blame] | 617 | gfx::NativeViewId parent_hwnd, |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 618 | int32 opener_id, |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 619 | const content::RendererPreferences& renderer_prefs, |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 620 | const WebPreferences& webkit_prefs, |
| 621 | SharedRenderViewCounter* counter, |
[email protected] | 4e6419c | 2010-01-15 04:50:34 | [diff] [blame] | 622 | int32 routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 623 | int32 surface_id, |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 624 | int64 session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 625 | const string16& frame_name, |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 626 | int32 next_page_id, |
| 627 | const WebKit::WebScreenInfo& screen_info) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 628 | DCHECK(routing_id != MSG_ROUTING_NONE); |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 629 | return new RenderViewImpl( |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 630 | parent_hwnd, |
| 631 | opener_id, |
| 632 | renderer_prefs, |
| 633 | webkit_prefs, |
| 634 | counter, |
| 635 | routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 636 | surface_id, |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 637 | session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 638 | frame_name, |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 639 | next_page_id, |
| 640 | screen_info); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 641 | } |
| 642 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 643 | WebKit::WebPeerConnectionHandler* RenderViewImpl::CreatePeerConnectionHandler( |
| 644 | WebKit::WebPeerConnectionHandlerClient* client) { |
| 645 | const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 646 | if (!cmd_line->HasSwitch(switches::kEnableMediaStream)) |
| 647 | return NULL; |
| 648 | EnsureMediaStreamImpl(); |
[email protected] | 5b87e78 | 2012-02-09 18:19:32 | [diff] [blame] | 649 | if (!media_stream_impl_.get()) |
| 650 | return NULL; |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 651 | return media_stream_impl_->CreatePeerConnectionHandler(client); |
| 652 | } |
| 653 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 654 | void RenderViewImpl::AddObserver(RenderViewObserver* observer) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 655 | observers_.AddObserver(observer); |
| 656 | } |
| 657 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 658 | void RenderViewImpl::RemoveObserver(RenderViewObserver* observer) { |
| 659 | observer->RenderViewGone(); |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 660 | observers_.RemoveObserver(observer); |
| 661 | } |
| 662 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 663 | WebKit::WebView* RenderViewImpl::webview() const { |
[email protected] | 4d51d5bf | 2010-07-26 18:48:26 | [diff] [blame] | 664 | return static_cast<WebKit::WebView*>(webwidget()); |
| 665 | } |
| 666 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 667 | void RenderViewImpl::SetReportLoadProgressEnabled(bool enabled) { |
[email protected] | 1a3c3cb | 2010-12-16 21:03:40 | [diff] [blame] | 668 | if (!enabled) { |
| 669 | load_progress_tracker_.reset(NULL); |
| 670 | return; |
| 671 | } |
| 672 | if (load_progress_tracker_ == NULL) |
| 673 | load_progress_tracker_.reset(new LoadProgressTracker(this)); |
| 674 | } |
| 675 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 676 | void RenderViewImpl::PluginCrashed(const FilePath& plugin_path) { |
[email protected] | a3a8fb6d | 2009-10-22 20:12:51 | [diff] [blame] | 677 | Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 678 | } |
| 679 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 680 | void RenderViewImpl::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 681 | plugin_delegates_.insert(delegate); |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 682 | // If the renderer is visible, set initial visibility and focus state. |
| 683 | if (!is_hidden()) { |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 684 | #if defined(OS_MACOSX) |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 685 | delegate->SetContainerVisibility(true); |
| 686 | if (webview() && webview()->isActive()) |
| 687 | delegate->SetWindowFocus(true); |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 688 | #endif |
[email protected] | 4923229 | 2010-09-03 19:07:30 | [diff] [blame] | 689 | } |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 690 | // Plugins start assuming the content has focus (so that they work in |
| 691 | // environments where RenderView isn't hosting them), so we always have to |
| 692 | // set the initial state. See webplugin_delegate_impl.h for details. |
| 693 | delegate->SetContentAreaFocus(has_focus()); |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 694 | } |
| 695 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 696 | void RenderViewImpl::UnregisterPluginDelegate( |
| 697 | WebPluginDelegateProxy* delegate) { |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 698 | plugin_delegates_.erase(delegate); |
| 699 | } |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 700 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 701 | bool RenderViewImpl::GetPluginInfo(const GURL& url, |
| 702 | const GURL& page_url, |
| 703 | const std::string& mime_type, |
| 704 | webkit::WebPluginInfo* plugin_info, |
| 705 | std::string* actual_mime_type) { |
[email protected] | 4a7d639 | 2011-09-19 20:55:08 | [diff] [blame] | 706 | bool found = false; |
| 707 | Send(new ViewHostMsg_GetPluginInfo( |
| 708 | routing_id_, url, page_url, mime_type, &found, plugin_info, |
| 709 | actual_mime_type)); |
| 710 | return found; |
| 711 | } |
| 712 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 713 | bool RenderViewImpl::OnMessageReceived(const IPC::Message& message) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 714 | WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
[email protected] | a9f607e | 2009-10-23 19:59:27 | [diff] [blame] | 715 | if (main_frame) |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 716 | content::GetContentClient()->SetActiveURL(main_frame->document().url()); |
[email protected] | f8b6b6f | 2009-03-10 16:48:26 | [diff] [blame] | 717 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 718 | ObserverListBase<RenderViewObserver>::Iterator it(observers_); |
| 719 | RenderViewObserver* observer; |
| 720 | while ((observer = it.GetNext()) != NULL) |
| 721 | if (observer->OnMessageReceived(message)) |
| 722 | return true; |
[email protected] | b2abac7 | 2009-02-26 12:39:28 | [diff] [blame] | 723 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 724 | bool handled = true; |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 725 | bool msg_is_ok = true; |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 726 | IPC_BEGIN_MESSAGE_MAP_EX(RenderViewImpl, message, msg_is_ok) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 727 | IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
| 728 | IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
[email protected] | 1dda402 | 2010-01-28 18:24:56 | [diff] [blame] | 729 | IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 730 | IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) |
| 731 | IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) |
| 732 | IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
| 733 | IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 734 | #if defined(OS_MACOSX) |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 735 | IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 736 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 737 | IPC_MESSAGE_HANDLER(ViewMsg_Paste, OnPaste) |
[email protected] | 44bf700 | 2011-10-16 02:46:15 | [diff] [blame] | 738 | IPC_MESSAGE_HANDLER(ViewMsg_PasteAndMatchStyle, OnPasteAndMatchStyle) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 739 | IPC_MESSAGE_HANDLER(ViewMsg_Replace, OnReplace) |
| 740 | IPC_MESSAGE_HANDLER(ViewMsg_Delete, OnDelete) |
| 741 | IPC_MESSAGE_HANDLER(ViewMsg_SelectAll, OnSelectAll) |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 742 | IPC_MESSAGE_HANDLER(ViewMsg_SelectRange, OnSelectRange) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 743 | IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) |
[email protected] | 4b59ae60 | 2009-06-23 20:58:15 | [diff] [blame] | 744 | IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 745 | IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 746 | IPC_MESSAGE_HANDLER(ViewMsg_StopFinding, OnStopFinding) |
| 747 | IPC_MESSAGE_HANDLER(ViewMsg_FindReplyACK, OnFindReplyAck) |
[email protected] | 630e26b | 2008-10-14 22:55:17 | [diff] [blame] | 748 | IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) |
[email protected] | d0b8d09 | 2010-10-25 04:05:17 | [diff] [blame] | 749 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevel, OnSetZoomLevel) |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 750 | IPC_MESSAGE_HANDLER(ViewMsg_ZoomFactor, OnZoomFactor) |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 751 | IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingURL, |
| 752 | OnSetZoomLevelForLoadingURL) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 753 | IPC_MESSAGE_HANDLER(ViewMsg_SetPageEncoding, OnSetPageEncoding) |
[email protected] | a697f4c | 2009-09-14 22:30:18 | [diff] [blame] | 754 | IPC_MESSAGE_HANDLER(ViewMsg_ResetPageEncodingToDefault, |
| 755 | OnResetPageEncodingToDefault) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 756 | IPC_MESSAGE_HANDLER(ViewMsg_ScriptEvalRequest, OnScriptEvalRequest) |
[email protected] | 1810e13 | 2009-03-24 23:35:48 | [diff] [blame] | 757 | IPC_MESSAGE_HANDLER(ViewMsg_CSSInsertRequest, OnCSSInsertRequest) |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 758 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragEnter, OnDragTargetDragEnter) |
| 759 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragOver, OnDragTargetDragOver) |
| 760 | IPC_MESSAGE_HANDLER(DragMsg_TargetDragLeave, OnDragTargetDragLeave) |
| 761 | IPC_MESSAGE_HANDLER(DragMsg_TargetDrop, OnDragTargetDrop) |
| 762 | IPC_MESSAGE_HANDLER(DragMsg_SourceEndedOrMoved, OnDragSourceEndedOrMoved) |
| 763 | IPC_MESSAGE_HANDLER(DragMsg_SourceSystemDragEnded, |
| 764 | OnDragSourceSystemDragEnded) |
[email protected] | 18cb257 | 2008-08-21 20:34:45 | [diff] [blame] | 765 | IPC_MESSAGE_HANDLER(ViewMsg_AllowBindings, OnAllowBindings) |
[email protected] | d098079 | 2011-02-13 19:41:40 | [diff] [blame] | 766 | IPC_MESSAGE_HANDLER(ViewMsg_SetWebUIProperty, OnSetWebUIProperty) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 767 | IPC_MESSAGE_HANDLER(ViewMsg_SetInitialFocus, OnSetInitialFocus) |
[email protected] | 333ec8d0 | 2011-09-16 18:59:19 | [diff] [blame] | 768 | IPC_MESSAGE_HANDLER(ViewMsg_ScrollFocusedEditableNodeIntoRect, |
| 769 | OnScrollFocusedEditableNodeIntoRect) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 770 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateTargetURL_ACK, OnUpdateTargetURLAck) |
| 771 | IPC_MESSAGE_HANDLER(ViewMsg_UpdateWebPreferences, OnUpdateWebPreferences) |
| 772 | IPC_MESSAGE_HANDLER(ViewMsg_SetAltErrorPageURL, OnSetAltErrorPageURL) |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 773 | IPC_MESSAGE_HANDLER(ViewMsg_EnumerateDirectoryResponse, |
| 774 | OnEnumerateDirectoryResponse) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 775 | IPC_MESSAGE_HANDLER(ViewMsg_RunFileChooserResponse, OnFileChooserResponse) |
[email protected] | 9b18a84f | 2010-06-10 15:54:04 | [diff] [blame] | 776 | IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnShouldClose) |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 777 | IPC_MESSAGE_HANDLER(ViewMsg_SwapOut, OnSwapOut) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 778 | IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 779 | IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 780 | IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
| 781 | OnDisassociateFromPopupCount) |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 782 | IPC_MESSAGE_HANDLER(ViewMsg_MoveOrResizeStarted, OnMoveOrResizeStarted) |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 783 | IPC_MESSAGE_HANDLER(ViewMsg_ClearFocusedNode, OnClearFocusedNode) |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 784 | IPC_MESSAGE_HANDLER(ViewMsg_SetBackground, OnSetBackground) |
[email protected] | ab32b16c | 2009-10-16 14:57:25 | [diff] [blame] | 785 | IPC_MESSAGE_HANDLER(ViewMsg_EnablePreferredSizeChangedMode, |
| 786 | OnEnablePreferredSizeChangedMode) |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 787 | IPC_MESSAGE_HANDLER(ViewMsg_EnableAutoResize, OnEnableAutoResize) |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 788 | IPC_MESSAGE_HANDLER(ViewMsg_DisableAutoResize, OnDisableAutoResize) |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 789 | IPC_MESSAGE_HANDLER(ViewMsg_DisableScrollbarsForSmallWindows, |
| 790 | OnDisableScrollbarsForSmallWindows) |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 791 | IPC_MESSAGE_HANDLER(ViewMsg_SetRendererPrefs, OnSetRendererPrefs) |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 792 | IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 793 | IPC_MESSAGE_HANDLER(ViewMsg_PluginActionAt, OnPluginActionAt) |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 794 | IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
[email protected] | 7a17bac0 | 2012-03-07 21:58:12 | [diff] [blame] | 795 | IPC_MESSAGE_HANDLER(ViewMsg_SetNavigationStartTime, |
| 796 | OnSetNavigationStartTime) |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 797 | #if defined(OS_MACOSX) |
| 798 | IPC_MESSAGE_HANDLER(ViewMsg_SetWindowVisibility, OnSetWindowVisibility) |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 799 | IPC_MESSAGE_HANDLER(ViewMsg_WindowFrameChanged, OnWindowFrameChanged) |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 800 | IPC_MESSAGE_HANDLER(ViewMsg_PluginImeCompositionCompleted, |
| 801 | OnPluginImeCompositionCompleted) |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 802 | #endif |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 803 | IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 804 | OnSetEditCommandsForNextKeyEvent) |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 805 | IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
| 806 | OnCustomContextMenuAction) |
[email protected] | 27a9ef3 | 2010-09-10 04:06:24 | [diff] [blame] | 807 | IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
[email protected] | eb415bf0e | 2011-04-14 02:45:42 | [diff] [blame] | 808 | IPC_MESSAGE_HANDLER(ViewMsg_PpapiBrokerChannelCreated, |
| 809 | OnPpapiBrokerChannelCreated) |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 810 | IPC_MESSAGE_HANDLER(ViewMsg_GetAllSavableResourceLinksForCurrentPage, |
| 811 | OnGetAllSavableResourceLinksForCurrentPage) |
| 812 | IPC_MESSAGE_HANDLER( |
| 813 | ViewMsg_GetSerializedHtmlDataForCurrentPageWithLocalLinks, |
| 814 | OnGetSerializedHtmlDataForCurrentPageWithLocalLinks) |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 815 | #if defined(OS_MACOSX) |
| 816 | IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
| 817 | #endif |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 818 | IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
[email protected] | f055793 | 2011-01-25 20:20:51 | [diff] [blame] | 819 | // TODO(viettrungluu): Move to a separate message filter. |
| 820 | #if defined(ENABLE_FLAPPER_HACKS) |
| 821 | IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
| 822 | #endif |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 823 | #if defined(OS_MACOSX) |
| 824 | IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 825 | #endif |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 826 | IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 827 | OnSetHistoryLengthAndPrune) |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 828 | IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 829 | IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 830 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 831 | // Have the super handle all other messages. |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 832 | IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 833 | IPC_END_MESSAGE_MAP() |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 834 | |
| 835 | if (!msg_is_ok) { |
| 836 | // The message had a handler, but its deserialization failed. |
| 837 | // Kill the renderer to avoid potential spoofing attacks. |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 838 | CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
[email protected] | ffc906f | 2011-10-04 22:55:40 | [diff] [blame] | 839 | } |
| 840 | |
[email protected] | a95986a8 | 2010-12-24 06:19:28 | [diff] [blame] | 841 | return handled; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 842 | } |
| 843 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 844 | void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
[email protected] | 6dc7ff6 | 2012-03-15 06:16:13 | [diff] [blame] | 845 | #if defined(OS_CHROMEOS) |
| 846 | // crosbug.com/26646. |
| 847 | LOG(ERROR) << "OnNavigate: url=" << params.url |
| 848 | << ", webview=" << webview() |
| 849 | << ", reload=" << IsReload(params) |
| 850 | << ", paerams.state.empty=" << params.state.empty(); |
| 851 | #endif |
[email protected] | 8bf104801 | 2012-02-08 01:22:18 | [diff] [blame] | 852 | MaybeHandleDebugURL(params.url); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 853 | if (!webview()) |
| 854 | return; |
| 855 | |
[email protected] | 440a0e5 | 2011-09-13 17:38:58 | [diff] [blame] | 856 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
| 857 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 858 | bool is_reload = IsReload(params); |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 859 | |
| 860 | // If this is a stale back/forward (due to a recent navigation the browser |
| 861 | // didn't know about), ignore it. |
| 862 | if (IsBackForwardToStaleEntry(params, is_reload)) |
| 863 | return; |
| 864 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 865 | // Swap this renderer back in if necessary. |
| 866 | if (is_swapped_out_) |
| 867 | SetSwappedOut(false); |
| 868 | |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 869 | history_list_offset_ = params.current_history_list_offset; |
| 870 | history_list_length_ = params.current_history_list_length; |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 871 | if (history_list_length_ >= 0) |
| 872 | history_page_ids_.resize(history_list_length_, -1); |
| 873 | if (params.pending_history_list_offset >= 0 && |
| 874 | params.pending_history_list_offset < history_list_length_) |
| 875 | history_page_ids_[params.pending_history_list_offset] = params.page_id; |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 876 | |
[email protected] | 38b59290 | 2011-04-16 02:08:42 | [diff] [blame] | 877 | content::GetContentClient()->SetActiveURL(params.url); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 878 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 879 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 880 | if (is_reload && main_frame->currentHistoryItem().isNull()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 881 | // We cannot reload if we do not have any history state. This happens, for |
| 882 | // example, when recovering from a crash. Our workaround here is a bit of |
| 883 | // a hack since it means that reload after a crashed tab does not cause an |
| 884 | // end-to-end cache validation. |
| 885 | is_reload = false; |
| 886 | } |
| 887 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 888 | pending_navigation_params_.reset(new ViewMsg_Navigate_Params); |
| 889 | *pending_navigation_params_.get() = params; |
[email protected] | 48a5c77 | 2011-04-18 23:50:50 | [diff] [blame] | 890 | |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 891 | // If we are reloading, then WebKit will use the history state of the current |
| 892 | // page, so we should just ignore any given history state. Otherwise, if we |
| 893 | // have history state, then we need to navigate to it, which corresponds to a |
| 894 | // back/forward navigation event. |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 895 | if (is_reload) { |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 896 | bool ignore_cache = (params.navigation_type == |
[email protected] | 2c556966 | 2011-03-22 20:45:02 | [diff] [blame] | 897 | ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE); |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 898 | main_frame->reload(ignore_cache); |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 899 | } else if (!params.state.empty()) { |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 900 | // 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] | 901 | DCHECK_NE(params.page_id, -1); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 902 | main_frame->loadHistoryItem( |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 903 | webkit_glue::HistoryItemFromString(params.state)); |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 904 | } else { |
| 905 | // Navigate to the given URL. |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 906 | WebURLRequest request(params.url); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 907 | |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 908 | // A session history navigation should have been accompanied by state. |
[email protected] | cbc0cb7 | 2011-12-06 18:58:23 | [diff] [blame] | 909 | CHECK_EQ(params.page_id, -1); |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 910 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 911 | if (main_frame->isViewSourceModeEnabled()) |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 912 | request.setCachePolicy(WebURLRequest::ReturnCacheDataElseLoad); |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 913 | |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 914 | if (params.referrer.url.is_valid()) { |
| 915 | WebString referrer = WebSecurityPolicy::generateReferrerHeader( |
| 916 | params.referrer.policy, |
| 917 | params.url, |
| 918 | WebString::fromUTF8(params.referrer.url.spec())); |
| 919 | if (!referrer.isEmpty()) |
| 920 | request.setHTTPHeaderField(WebString::fromUTF8("Referer"), referrer); |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 921 | } |
[email protected] | 04d3c6e | 2009-05-22 17:00:13 | [diff] [blame] | 922 | |
[email protected] | 52c6865 | 2010-12-07 17:47:04 | [diff] [blame] | 923 | if (!params.extra_headers.empty()) { |
| 924 | for (net::HttpUtil::HeadersIterator i(params.extra_headers.begin(), |
| 925 | params.extra_headers.end(), "\n"); |
| 926 | i.GetNext(); ) { |
| 927 | request.addHTTPHeaderField(WebString::fromUTF8(i.name()), |
| 928 | WebString::fromUTF8(i.values())); |
| 929 | } |
| 930 | } |
[email protected] | 6dc7ff6 | 2012-03-15 06:16:13 | [diff] [blame] | 931 | #if defined(OS_CHROMEOS) |
| 932 | // crosbug.com/26646. |
| 933 | LOG(ERROR) << " FrameLoader::loadRequest()"; |
| 934 | #endif |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 935 | main_frame->loadRequest(request); |
[email protected] | c058805 | 2008-10-27 23:01:50 | [diff] [blame] | 936 | } |
| 937 | |
[email protected] | 77f17a8 | 2009-05-21 04:42:54 | [diff] [blame] | 938 | // In case LoadRequest failed before DidCreateDataSource was called. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 939 | pending_navigation_params_.reset(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 940 | } |
| 941 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 942 | bool RenderViewImpl::IsBackForwardToStaleEntry( |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 943 | const ViewMsg_Navigate_Params& params, |
| 944 | bool is_reload) { |
| 945 | // Make sure this isn't a back/forward to an entry we have already cropped |
| 946 | // or replaced from our history, before the browser knew about it. If so, |
| 947 | // a new navigation has committed in the mean time, and we can ignore this. |
| 948 | bool is_back_forward = !is_reload && !params.state.empty(); |
| 949 | |
| 950 | // Note: if the history_list_length_ is 0 for a back/forward, we must be |
| 951 | // restoring from a previous session. We'll update our state in OnNavigate. |
| 952 | if (!is_back_forward || history_list_length_ <= 0) |
| 953 | return false; |
| 954 | |
| 955 | DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); |
| 956 | |
| 957 | // Check for whether the forward history has been cropped due to a recent |
| 958 | // navigation the browser didn't know about. |
| 959 | if (params.pending_history_list_offset >= history_list_length_) |
| 960 | return true; |
| 961 | |
| 962 | // Check for whether this entry has been replaced with a new one. |
| 963 | int expected_page_id = |
| 964 | history_page_ids_[params.pending_history_list_offset]; |
[email protected] | 9978b8f0 | 2011-08-13 16:17:44 | [diff] [blame] | 965 | if (expected_page_id > 0 && params.page_id != expected_page_id) { |
| 966 | if (params.page_id < expected_page_id) |
| 967 | return true; |
| 968 | |
| 969 | // Otherwise we've removed an earlier entry and should have shifted all |
| 970 | // entries left. For now, it's ok to lazily update the list. |
| 971 | // TODO(creis): Notify all live renderers when we remove entries from |
| 972 | // the front of the list, so that we don't hit this case. |
| 973 | history_page_ids_[params.pending_history_list_offset] = params.page_id; |
| 974 | } |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 975 | |
| 976 | return false; |
| 977 | } |
| 978 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 979 | // Stop loading the current page |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 980 | void RenderViewImpl::OnStop() { |
[email protected] | 6a8f511 | 2011-05-13 16:38:44 | [diff] [blame] | 981 | if (webview()) { |
| 982 | WebFrame* main_frame = webview()->mainFrame(); |
| 983 | // Stop the alt error page fetcher. If we let it continue it may complete |
| 984 | // and cause RenderViewHostManager to swap to this RenderView, even though |
| 985 | // it may no longer be active. |
| 986 | StopAltErrorPageFetcher(main_frame->provisionalDataSource()); |
| 987 | StopAltErrorPageFetcher(main_frame->dataSource()); |
| 988 | main_frame->stopLoading(); |
| 989 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 990 | } |
| 991 | |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 992 | // Reload current focused frame. |
| 993 | // 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] | 994 | void RenderViewImpl::OnReloadFrame() { |
[email protected] | ecbf10d | 2010-02-18 13:03:29 | [diff] [blame] | 995 | if (webview() && webview()->focusedFrame()) { |
| 996 | // We always obey the cache (ignore_cache=false) here. |
| 997 | // TODO(evanm): perhaps we could allow shift-clicking the menu item to do |
| 998 | // a cache-ignoring reload of the frame. |
| 999 | webview()->focusedFrame()->reload(false); |
| 1000 | } |
[email protected] | 1dda402 | 2010-01-28 18:24:56 | [diff] [blame] | 1001 | } |
| 1002 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1003 | void RenderViewImpl::OnCopyImageAt(int x, int y) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1004 | webview()->copyImageAt(WebPoint(x, y)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1005 | } |
| 1006 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1007 | void RenderViewImpl::OnExecuteEditCommand(const std::string& name, |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 1008 | const std::string& value) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1009 | if (!webview() || !webview()->focusedFrame()) |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 1010 | return; |
| 1011 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1012 | webview()->focusedFrame()->executeCommand( |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1013 | WebString::fromUTF8(name), WebString::fromUTF8(value)); |
[email protected] | 68b1e92 | 2009-06-23 16:00:25 | [diff] [blame] | 1014 | } |
| 1015 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1016 | void RenderViewImpl::OnUpdateTargetURLAck() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1017 | // Check if there is a targeturl waiting to be sent. |
| 1018 | if (target_url_status_ == TARGET_PENDING) { |
| 1019 | Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, |
| 1020 | pending_target_url_)); |
| 1021 | } |
| 1022 | |
| 1023 | target_url_status_ = TARGET_NONE; |
| 1024 | } |
| 1025 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1026 | void RenderViewImpl::OnUndo() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1027 | if (!webview()) |
| 1028 | return; |
| 1029 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1030 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Undo")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1031 | } |
| 1032 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1033 | void RenderViewImpl::OnRedo() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1034 | if (!webview()) |
| 1035 | return; |
| 1036 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1037 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Redo")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1038 | } |
| 1039 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1040 | void RenderViewImpl::OnCut() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1041 | if (!webview()) |
| 1042 | return; |
| 1043 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1044 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Cut")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1045 | } |
| 1046 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1047 | void RenderViewImpl::OnCopy() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1048 | if (!webview()) |
| 1049 | return; |
| 1050 | |
[email protected] | f6b1856b | 2011-06-29 22:02:53 | [diff] [blame] | 1051 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Copy"), |
| 1052 | context_menu_node_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1053 | } |
| 1054 | |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 1055 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1056 | void RenderViewImpl::OnCopyToFindPboard() { |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1057 | if (!webview()) |
| 1058 | return; |
| 1059 | |
| 1060 | // Since the find pasteboard supports only plain text, this can be simpler |
| 1061 | // than the |OnCopy()| case. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1062 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1063 | if (frame->hasSelection()) { |
| 1064 | string16 selection = frame->selectionAsText(); |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1065 | RenderThread::Get()->Send( |
[email protected] | 7e358974 | 2011-03-10 18:49:17 | [diff] [blame] | 1066 | new ClipboardHostMsg_FindPboardWriteStringAsync(selection)); |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1067 | } |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1068 | } |
[email protected] | c0cc309 | 2009-09-12 08:27:27 | [diff] [blame] | 1069 | #endif |
[email protected] | a954bf7 | 2009-09-12 07:30:35 | [diff] [blame] | 1070 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1071 | void RenderViewImpl::OnPaste() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1072 | if (!webview()) |
| 1073 | return; |
| 1074 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1075 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Paste")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1076 | } |
| 1077 | |
[email protected] | 44bf700 | 2011-10-16 02:46:15 | [diff] [blame] | 1078 | void RenderViewImpl::OnPasteAndMatchStyle() { |
| 1079 | if (!webview()) |
| 1080 | return; |
| 1081 | |
| 1082 | webview()->focusedFrame()->executeCommand( |
| 1083 | WebString::fromUTF8("PasteAndMatchStyle")); |
| 1084 | } |
| 1085 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1086 | void RenderViewImpl::OnReplace(const string16& text) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1087 | if (!webview()) |
| 1088 | return; |
| 1089 | |
[email protected] | 1ff7a03 | 2010-02-03 02:46:03 | [diff] [blame] | 1090 | WebFrame* frame = webview()->focusedFrame(); |
| 1091 | if (!frame->hasSelection()) |
| 1092 | frame->selectWordAroundCaret(); |
| 1093 | frame->replaceSelection(text); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1094 | } |
| 1095 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1096 | void RenderViewImpl::OnDelete() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1097 | if (!webview()) |
| 1098 | return; |
| 1099 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1100 | webview()->focusedFrame()->executeCommand(WebString::fromUTF8("Delete")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1101 | } |
| 1102 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1103 | void RenderViewImpl::OnSelectAll() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1104 | if (!webview()) |
| 1105 | return; |
| 1106 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1107 | webview()->focusedFrame()->executeCommand( |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 1108 | WebString::fromUTF8("SelectAll")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1109 | } |
| 1110 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1111 | void RenderViewImpl::OnSelectRange(const gfx::Point& start, |
| 1112 | const gfx::Point& end) { |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1113 | if (!webview()) |
| 1114 | return; |
| 1115 | |
| 1116 | handling_select_range_ = true; |
| 1117 | webview()->focusedFrame()->selectRange(start, end); |
| 1118 | handling_select_range_ = false; |
| 1119 | } |
| 1120 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1121 | void RenderViewImpl::OnSetHistoryLengthAndPrune(int history_length, |
| 1122 | int32 minimum_page_id) { |
[email protected] | 9e1ad4b | 2011-08-14 16:49:19 | [diff] [blame] | 1123 | DCHECK(history_length >= 0); |
| 1124 | DCHECK(history_list_offset_ == history_list_length_ - 1); |
| 1125 | DCHECK(minimum_page_id >= -1); |
| 1126 | |
| 1127 | // Generate the new list. |
| 1128 | std::vector<int32> new_history_page_ids(history_length, -1); |
| 1129 | for (size_t i = 0; i < history_page_ids_.size(); ++i) { |
| 1130 | if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) |
| 1131 | continue; |
| 1132 | new_history_page_ids.push_back(history_page_ids_[i]); |
| 1133 | } |
| 1134 | new_history_page_ids.swap(history_page_ids_); |
| 1135 | |
| 1136 | // Update indexes. |
| 1137 | history_list_length_ = history_page_ids_.size(); |
| 1138 | history_list_offset_ = history_list_length_ - 1; |
| 1139 | } |
| 1140 | |
| 1141 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1142 | void RenderViewImpl::OnSetInitialFocus(bool reverse) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1143 | if (!webview()) |
| 1144 | return; |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1145 | webview()->setInitialFocus(reverse); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1146 | } |
| 1147 | |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1148 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1149 | void RenderViewImpl::OnSetInLiveResize(bool in_live_resize) { |
[email protected] | 4274b3e | 2011-08-09 19:09:33 | [diff] [blame] | 1150 | if (!webview()) |
| 1151 | return; |
| 1152 | if (in_live_resize) |
| 1153 | webview()->willStartLiveResize(); |
| 1154 | else |
| 1155 | webview()->willEndLiveResize(); |
[email protected] | 54ca3ca89 | 2011-06-07 21:14:54 | [diff] [blame] | 1156 | } |
| 1157 | #endif |
| 1158 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1159 | void RenderViewImpl::OnScrollFocusedEditableNodeIntoRect( |
| 1160 | const gfx::Rect& rect) { |
[email protected] | 13a1e4c3c | 2011-02-03 21:07:09 | [diff] [blame] | 1161 | WebKit::WebNode node = GetFocusedNode(); |
| 1162 | if (!node.isNull()) { |
| 1163 | if (IsEditableNode(node)) |
[email protected] | 333ec8d0 | 2011-09-16 18:59:19 | [diff] [blame] | 1164 | webview()->scrollFocusedNodeIntoRect(rect); |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 1165 | } |
| 1166 | } |
| 1167 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1168 | /////////////////////////////////////////////////////////////////////////////// |
| 1169 | |
| 1170 | // Tell the embedding application that the URL of the active page has changed |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1171 | void RenderViewImpl::UpdateURL(WebFrame* frame) { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1172 | WebDataSource* ds = frame->dataSource(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1173 | DCHECK(ds); |
| 1174 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1175 | const WebURLRequest& request = ds->request(); |
| 1176 | const WebURLRequest& original_request = ds->originalRequest(); |
| 1177 | const WebURLResponse& response = ds->response(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1178 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1179 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 1180 | NavigationState* navigation_state = document_state->navigation_state(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1181 | |
| 1182 | ViewHostMsg_FrameNavigate_Params params; |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1183 | params.http_status_code = response.httpStatusCode(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1184 | params.is_post = false; |
[email protected] | 86cd947 | 2012-02-03 19:51:05 | [diff] [blame] | 1185 | params.post_id = -1; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1186 | params.page_id = page_id_; |
[email protected] | dabb0d1 | 2010-10-05 12:50:07 | [diff] [blame] | 1187 | params.frame_id = frame->identifier(); |
[email protected] | 6d81b48 | 2011-02-22 19:47:19 | [diff] [blame] | 1188 | params.socket_address.set_host(response.remoteIPAddress().utf8()); |
| 1189 | params.socket_address.set_port(response.remotePort()); |
[email protected] | b9a7c6d4 | 2011-02-25 02:13:03 | [diff] [blame] | 1190 | params.was_fetched_via_proxy = response.wasFetchedViaProxy(); |
[email protected] | af15bed | 2010-08-25 21:12:09 | [diff] [blame] | 1191 | params.was_within_same_page = navigation_state->was_within_same_page(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1192 | if (!document_state->security_info().empty()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1193 | // SSL state specified in the request takes precedence over the one in the |
| 1194 | // response. |
| 1195 | // So far this is only intended for error pages that are not expected to be |
| 1196 | // over ssl, so we should not get any clash. |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1197 | DCHECK(response.securityInfo().isEmpty()); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1198 | params.security_info = document_state->security_info(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1199 | } else { |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1200 | params.security_info = response.securityInfo(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1201 | } |
| 1202 | |
| 1203 | // Set the URL to be displayed in the browser UI to the user. |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 1204 | params.url = GetLoadingUrl(frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1205 | |
[email protected] | 5f9b871 | 2011-11-23 08:55:57 | [diff] [blame] | 1206 | if (frame->document().baseURL() != params.url) |
| 1207 | params.base_url = frame->document().baseURL(); |
| 1208 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1209 | GetRedirectChain(ds, ¶ms.redirects); |
[email protected] | d94dc1e | 2010-03-04 09:29:24 | [diff] [blame] | 1210 | params.should_update_history = !ds->hasUnreachableURL() && |
[email protected] | b7df1b7 | 2011-02-10 00:08:04 | [diff] [blame] | 1211 | !response.isMultipartPayload() && (response.httpStatusCode() != 404); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1212 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1213 | params.searchable_form_url = document_state->searchable_form_url(); |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 1214 | params.searchable_form_encoding = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1215 | document_state->searchable_form_encoding(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1216 | |
| 1217 | const PasswordForm* password_form_data = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 1218 | document_state->password_form_data(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1219 | if (password_form_data) |
| 1220 | params.password_form = *password_form_data; |
| 1221 | |
| 1222 | params.gesture = navigation_gesture_; |
| 1223 | navigation_gesture_ = NavigationGestureUnknown; |
| 1224 | |
[email protected] | 0f38dc455 | 2011-02-25 11:24:00 | [diff] [blame] | 1225 | // Make navigation state a part of the FrameNavigate message so that commited |
| 1226 | // entry had it at all times. |
| 1227 | const WebHistoryItem& item = frame->currentHistoryItem(); |
| 1228 | if (!item.isNull()) { |
| 1229 | params.content_state = webkit_glue::HistoryItemToString(item); |
| 1230 | } else { |
| 1231 | params.content_state = |
| 1232 | webkit_glue::CreateHistoryStateForURL(GURL(request.url())); |
| 1233 | } |
| 1234 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 1235 | if (!frame->parent()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1236 | // Top-level navigation. |
| 1237 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1238 | // Set zoom level, but don't do it for full-page plugin since they don't use |
| 1239 | // the same zoom settings. |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1240 | HostZoomLevels::iterator host_zoom = |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 1241 | host_zoom_levels_.find(GURL(request.url())); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1242 | if (webview()->mainFrame()->document().isPluginDocument()) { |
| 1243 | // Reset the zoom levels for plugins. |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1244 | webview()->setZoomLevel(false, 0); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1245 | } else { |
| 1246 | if (host_zoom != host_zoom_levels_.end()) |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1247 | webview()->setZoomLevel(false, host_zoom->second); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1248 | } |
| 1249 | |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1250 | if (host_zoom != host_zoom_levels_.end()) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 1251 | // This zoom level was merely recorded transiently for this load. We can |
| 1252 | // erase it now. If at some point we reload this page, the browser will |
| 1253 | // send us a new, up-to-date zoom level. |
[email protected] | f85f070 | 2010-01-30 09:31:01 | [diff] [blame] | 1254 | host_zoom_levels_.erase(host_zoom); |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 1255 | } |
| 1256 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1257 | // Reset the zoom limits in case a plugin had changed them previously. This |
| 1258 | // will also call us back which will cause us to send a message to |
| 1259 | // update TabContents. |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1260 | webview()->zoomLimitsChanged( |
[email protected] | 0f08340 | 2011-11-22 02:59:01 | [diff] [blame] | 1261 | WebView::zoomFactorToZoomLevel(content::kMinimumZoomFactor), |
| 1262 | WebView::zoomFactorToZoomLevel(content::kMaximumZoomFactor)); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 1263 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1264 | // Update contents MIME type for main frame. |
[email protected] | 9c5645b | 2009-08-11 03:37:55 | [diff] [blame] | 1265 | params.contents_mime_type = ds->response().mimeType().utf8(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1266 | |
[email protected] | daa8c58e | 2009-06-15 17:21:10 | [diff] [blame] | 1267 | params.transition = navigation_state->transition_type(); |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1268 | if (!content::PageTransitionIsMainFrame(params.transition)) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1269 | // If the main frame does a load, it should not be reported as a subframe |
| 1270 | // navigation. This can occur in the following case: |
| 1271 | // 1. You're on a site with frames. |
| 1272 | // 2. You do a subframe navigation. This is stored with transition type |
| 1273 | // MANUAL_SUBFRAME. |
| 1274 | // 3. You navigate to some non-frame site, say, google.com. |
| 1275 | // 4. You navigate back to the page from step 2. Since it was initially |
| 1276 | // MANUAL_SUBFRAME, it will be that same transition type here. |
| 1277 | // We don't want that, because any navigation that changes the toplevel |
| 1278 | // frame should be tracked as a toplevel navigation (this allows us to |
| 1279 | // update the URL bar, etc). |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1280 | params.transition = content::PAGE_TRANSITION_LINK; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1281 | } |
| 1282 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1283 | // If we have a valid consumed client redirect source, |
| 1284 | // the page contained a client redirect (meta refresh, document.loc...), |
| 1285 | // so we set the referrer and transition to match. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1286 | if (completed_client_redirect_src_.url.is_valid()) { |
| 1287 | DCHECK(completed_client_redirect_src_.url == params.redirects[0]); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1288 | params.referrer = completed_client_redirect_src_; |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1289 | params.transition = static_cast<content::PageTransition>( |
| 1290 | params.transition | content::PAGE_TRANSITION_CLIENT_REDIRECT); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1291 | } else { |
| 1292 | // Bug 654101: the referrer will be empty on https->http transitions. It |
| 1293 | // would be nice if we could get the real referrer from somewhere. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1294 | params.referrer = Referrer(GURL( |
| 1295 | original_request.httpHeaderField(WebString::fromUTF8("Referer"))), |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 1296 | GetReferrerPolicyFromRequest(original_request)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1297 | } |
| 1298 | |
[email protected] | 726985e2 | 2009-06-18 21:09:28 | [diff] [blame] | 1299 | string16 method = request.httpMethod(); |
[email protected] | 86cd947 | 2012-02-03 19:51:05 | [diff] [blame] | 1300 | if (EqualsASCII(method, "POST")) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1301 | params.is_post = true; |
[email protected] | 86cd947 | 2012-02-03 19:51:05 | [diff] [blame] | 1302 | params.post_id = ExtractPostId(item); |
| 1303 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1304 | |
[email protected] | c2a797d | 2009-09-21 16:46:32 | [diff] [blame] | 1305 | // Save some histogram data so we can compute the average memory used per |
| 1306 | // page load of the glyphs. |
| 1307 | UMA_HISTOGRAM_COUNTS_10000("Memory.GlyphPagesPerLoad", |
| 1308 | webkit_glue::GetGlyphPageCount()); |
| 1309 | |
[email protected] | 15cf526b | 2010-02-12 06:33:49 | [diff] [blame] | 1310 | // This message needs to be sent before any of allowScripts(), |
| 1311 | // allowImages(), allowPlugins() is called for the new page, so that when |
| 1312 | // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
| 1313 | // after the ViewHostMsg_FrameNavigate message. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1314 | Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1315 | } else { |
| 1316 | // Subframe navigation: the type depends on whether this navigation |
| 1317 | // generated a new session history entry. When they do generate a session |
| 1318 | // history entry, it means the user initiated the navigation and we should |
| 1319 | // mark it as such. This test checks if this is the first time UpdateURL |
| 1320 | // has been called since WillNavigateToURL was called to initiate the load. |
| 1321 | if (page_id_ > last_page_id_sent_to_browser_) |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1322 | params.transition = content::PAGE_TRANSITION_MANUAL_SUBFRAME; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1323 | else |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1324 | params.transition = content::PAGE_TRANSITION_AUTO_SUBFRAME; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1325 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1326 | Send(new ViewHostMsg_FrameNavigate(routing_id_, params)); |
| 1327 | } |
| 1328 | |
| 1329 | last_page_id_sent_to_browser_ = |
| 1330 | std::max(last_page_id_sent_to_browser_, page_id_); |
| 1331 | |
| 1332 | // 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] | 1333 | // we don't want the transition type to persist. Just clear it. |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 1334 | navigation_state->set_transition_type(content::PAGE_TRANSITION_LINK); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | // Tell the embedding application that the title of the active page has changed |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1338 | void RenderViewImpl::UpdateTitle(WebFrame* frame, |
| 1339 | const string16& title, |
| 1340 | WebTextDirection title_direction) { |
[email protected] | a49e10b | 2011-08-01 23:57:46 | [diff] [blame] | 1341 | // Ignore all but top level navigations. |
| 1342 | if (frame->parent()) |
| 1343 | return; |
| 1344 | |
| 1345 | string16 shortened_title = title.substr(0, content::kMaxTitleChars); |
| 1346 | Send(new ViewHostMsg_UpdateTitle(routing_id_, page_id_, shortened_title, |
| 1347 | title_direction)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1348 | } |
| 1349 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1350 | void RenderViewImpl::UpdateEncoding(WebFrame* frame, |
| 1351 | const std::string& encoding_name) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1352 | // Only update main frame's encoding_name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1353 | if (webview()->mainFrame() == frame && |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1354 | last_encoding_name_ != encoding_name) { |
[email protected] | e38f4015 | 2008-09-12 23:08:30 | [diff] [blame] | 1355 | // Save the encoding name for later comparing. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1356 | last_encoding_name_ = encoding_name; |
| 1357 | |
[email protected] | e38f4015 | 2008-09-12 23:08:30 | [diff] [blame] | 1358 | Send(new ViewHostMsg_UpdateEncoding(routing_id_, last_encoding_name_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1359 | } |
| 1360 | } |
| 1361 | |
[email protected] | e15f68073 | 2010-11-23 22:30:20 | [diff] [blame] | 1362 | // Sends the last committed session history state to the browser so it will be |
| 1363 | // saved before we navigate to a new page. This must be called *before* the |
| 1364 | // page ID has been updated so we know what it was. |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1365 | void RenderViewImpl::UpdateSessionHistory(WebFrame* frame) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1366 | // If we have a valid page ID at this point, then it corresponds to the page |
| 1367 | // we are navigating away from. Otherwise, this is the first navigation, so |
| 1368 | // there is no past session history to record. |
| 1369 | if (page_id_ == -1) |
| 1370 | return; |
| 1371 | |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1372 | const WebHistoryItem& item = |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1373 | webview()->mainFrame()->previousHistoryItem(); |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1374 | if (item.isNull()) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1375 | return; |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 1376 | |
| 1377 | Send(new ViewHostMsg_UpdateState( |
| 1378 | routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1379 | } |
| 1380 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1381 | void RenderViewImpl::OpenURL(WebFrame* frame, |
| 1382 | const GURL& url, |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 1383 | const Referrer& referrer, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1384 | WebNavigationPolicy policy) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1385 | Send(new ViewHostMsg_OpenURL( |
[email protected] | ae5184d6 | 2011-10-06 19:25:58 | [diff] [blame] | 1386 | routing_id_, |
| 1387 | url, |
| 1388 | referrer, |
| 1389 | NavigationPolicyToDisposition(policy), |
| 1390 | frame->identifier())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 1391 | } |
| 1392 | |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1393 | // WebViewDelegate ------------------------------------------------------------ |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1394 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1395 | void RenderViewImpl::LoadNavigationErrorPage( |
| 1396 | WebFrame* frame, |
| 1397 | const WebURLRequest& failed_request, |
| 1398 | const WebURLError& error, |
| 1399 | const std::string& html, |
| 1400 | bool replace) { |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 1401 | std::string alt_html; |
| 1402 | const std::string* error_html; |
| 1403 | |
| 1404 | if (!html.empty()) { |
| 1405 | error_html = &html; |
| 1406 | } else { |
| 1407 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 1408 | failed_request, error, &alt_html, NULL); |
| 1409 | error_html = &alt_html; |
| 1410 | } |
| 1411 | |
| 1412 | frame->loadHTMLString(*error_html, |
[email protected] | 144143c | 2010-10-28 08:17:36 | [diff] [blame] | 1413 | GURL(chrome::kUnreachableWebDataURL), |
[email protected] | 21d61e5 | 2011-03-18 19:08:25 | [diff] [blame] | 1414 | error.unreachableURL, |
[email protected] | e6f546c3 | 2009-07-01 17:12:55 | [diff] [blame] | 1415 | replace); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1416 | } |
| 1417 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1418 | bool RenderViewImpl::RunJavaScriptMessage(ui::JavascriptMessageType type, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1419 | const string16& message, |
| 1420 | const string16& default_value, |
| 1421 | const GURL& frame_url, |
| 1422 | string16* result) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1423 | bool success = false; |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1424 | string16 result_temp; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1425 | if (!result) |
| 1426 | result = &result_temp; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1427 | |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1428 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunJavaScriptMessage( |
| 1429 | routing_id_, message, default_value, frame_url, type, &success, result)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1430 | return success; |
| 1431 | } |
| 1432 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1433 | bool RenderViewImpl::SendAndRunNestedMessageLoop(IPC::SyncMessage* message) { |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1434 | // Before WebKit asks us to show an alert (etc.), it takes care of doing the |
| 1435 | // equivalent of WebView::willEnterModalLoop. In the case of showModalDialog |
| 1436 | // it is particularly important that we do not call willEnterModalLoop as |
| 1437 | // that would defer resource loads for the dialog itself. |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 1438 | if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 1439 | RenderThreadImpl::current()->DoNotNotifyWebKitOfModalLoop(); |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 1440 | |
| 1441 | message->EnableMessagePumping(); // Runs a nested message loop. |
| 1442 | return Send(message); |
| 1443 | } |
| 1444 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1445 | // WebKit::WebViewClient ------------------------------------------------------ |
| 1446 | |
[email protected] | 916dfb6 | 2012-03-05 03:39:37 | [diff] [blame] | 1447 | WebView* RenderViewImpl::createView( |
| 1448 | WebFrame* creator, |
| 1449 | const WebURLRequest& request, |
| 1450 | const WebWindowFeatures& features, |
| 1451 | const WebString& frame_name, |
| 1452 | WebNavigationPolicy policy) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1453 | // Check to make sure we aren't overloading on popups. |
| 1454 | if (shared_popup_counter_->data > kMaximumNumberOfUnacknowledgedPopups) |
| 1455 | return NULL; |
| 1456 | |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1457 | ViewHostMsg_CreateWindow_Params params; |
| 1458 | params.opener_id = routing_id_; |
| 1459 | params.user_gesture = creator->isProcessingUserGesture(); |
| 1460 | params.window_container_type = WindowFeaturesToContainerType(features); |
| 1461 | params.session_storage_namespace_id = session_storage_namespace_id_; |
| 1462 | params.frame_name = frame_name; |
[email protected] | 41e6550 | 2011-01-21 09:29:11 | [diff] [blame] | 1463 | params.opener_frame_id = creator->identifier(); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1464 | params.opener_url = creator->document().url(); |
| 1465 | params.opener_security_origin = |
| 1466 | creator->document().securityOrigin().toString().utf8(); |
[email protected] | f92ce2b | 2012-03-06 18:02:59 | [diff] [blame] | 1467 | params.opener_suppressed = creator->willSuppressOpenerInNewFrame(); |
| 1468 | params.disposition = NavigationPolicyToDisposition(policy); |
[email protected] | 41e6550 | 2011-01-21 09:29:11 | [diff] [blame] | 1469 | if (!request.isNull()) |
| 1470 | params.target_url = request.url(); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1471 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1472 | int32 routing_id = MSG_ROUTING_NONE; |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1473 | int32 surface_id = 0; |
[email protected] | 4e6419c | 2010-01-15 04:50:34 | [diff] [blame] | 1474 | int64 cloned_session_storage_namespace_id; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1475 | |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1476 | RenderThread::Get()->Send( |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1477 | new ViewHostMsg_CreateWindow(params, |
| 1478 | &routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1479 | &surface_id, |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1480 | &cloned_session_storage_namespace_id)); |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1481 | if (routing_id == MSG_ROUTING_NONE) |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1482 | return NULL; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1483 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1484 | RenderViewImpl* view = RenderViewImpl::Create( |
| 1485 | 0, |
| 1486 | routing_id_, |
| 1487 | renderer_preferences_, |
| 1488 | webkit_preferences_, |
| 1489 | shared_popup_counter_, |
| 1490 | routing_id, |
[email protected] | 9f4f332 | 2012-01-18 22:29:56 | [diff] [blame] | 1491 | surface_id, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1492 | cloned_session_storage_namespace_id, |
[email protected] | 74ce1ad | 2011-12-16 21:51:46 | [diff] [blame] | 1493 | frame_name, |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 1494 | 1, |
| 1495 | screen_info_); |
[email protected] | 8ab0465 | 2010-06-12 02:47:26 | [diff] [blame] | 1496 | view->opened_by_user_gesture_ = params.user_gesture; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1497 | |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 1498 | // Record whether the creator frame is trying to suppress the opener field. |
[email protected] | f92ce2b | 2012-03-06 18:02:59 | [diff] [blame] | 1499 | view->opener_suppressed_ = params.opener_suppressed; |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 1500 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1501 | // Record the security origin of the creator. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1502 | GURL creator_url(creator->document().securityOrigin().toString().utf8()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1503 | if (!creator_url.is_valid() || !creator_url.IsStandard()) |
| 1504 | creator_url = GURL(); |
| 1505 | view->creator_url_ = creator_url; |
| 1506 | |
| 1507 | // Copy over the alternate error page URL so we can have alt error pages in |
| 1508 | // the new render view (we don't need the browser to send the URL back down). |
| 1509 | view->alternate_error_page_url_ = alternate_error_page_url_; |
| 1510 | |
| 1511 | return view->webview(); |
| 1512 | } |
| 1513 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1514 | WebWidget* RenderViewImpl::createPopupMenu(WebKit::WebPopupType popup_type) { |
[email protected] | 6fd35b7 | 2012-03-01 19:46:41 | [diff] [blame] | 1515 | RenderWidget* widget = |
| 1516 | RenderWidget::Create(routing_id_, popup_type, screen_info_); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1517 | return widget->webwidget(); |
| 1518 | } |
| 1519 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1520 | WebWidget* RenderViewImpl::createPopupMenu(const WebPopupMenuInfo& info) { |
[email protected] | 8de12d94 | 2010-11-17 20:42:44 | [diff] [blame] | 1521 | // TODO(jcivelli): Remove this deprecated method when its been removed from |
| 1522 | // the WebViewClient interface. It's been replaced by |
| 1523 | // createExternalPopupMenu. |
| 1524 | NOTREACHED(); |
| 1525 | return NULL; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1526 | } |
| 1527 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1528 | WebExternalPopupMenu* RenderViewImpl::createExternalPopupMenu( |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 1529 | const WebPopupMenuInfo& popup_menu_info, |
| 1530 | WebExternalPopupMenuClient* popup_menu_client) { |
| 1531 | DCHECK(!external_popup_menu_.get()); |
| 1532 | external_popup_menu_.reset( |
| 1533 | new ExternalPopupMenu(this, popup_menu_info, popup_menu_client)); |
| 1534 | return external_popup_menu_.get(); |
| 1535 | } |
| 1536 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1537 | RenderWidgetFullscreenPepper* RenderViewImpl::CreatePepperFullscreenContainer( |
[email protected] | 0bd75368 | 2010-12-16 18:15:52 | [diff] [blame] | 1538 | webkit::ppapi::PluginInstance* plugin) { |
[email protected] | d91233b7e | 2011-03-29 20:33:53 | [diff] [blame] | 1539 | GURL active_url; |
[email protected] | d91ddfc | 2011-04-07 18:33:42 | [diff] [blame] | 1540 | if (webview() && webview()->mainFrame()) |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1541 | active_url = GURL(webview()->mainFrame()->document().url()); |
[email protected] | d91233b7e | 2011-03-29 20:33:53 | [diff] [blame] | 1542 | RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 1543 | routing_id_, plugin, active_url); |
[email protected] | 79c7bed | 2010-09-14 22:28:39 | [diff] [blame] | 1544 | widget->show(WebKit::WebNavigationPolicyIgnore); |
[email protected] | 92abcb83 | 2011-01-06 20:39:56 | [diff] [blame] | 1545 | return widget; |
[email protected] | 79c7bed | 2010-09-14 22:28:39 | [diff] [blame] | 1546 | } |
| 1547 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1548 | WebStorageNamespace* RenderViewImpl::createSessionStorageNamespace( |
| 1549 | unsigned quota) { |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1550 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess)) |
[email protected] | 68c50e5 | 2010-05-12 11:14:39 | [diff] [blame] | 1551 | return WebStorageNamespace::createSessionStorageNamespace(quota); |
[email protected] | 59afea1 | 2010-01-20 04:48:29 | [diff] [blame] | 1552 | CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
| 1553 | return new RendererWebStorageNamespaceImpl(DOM_STORAGE_SESSION, |
| 1554 | session_storage_namespace_id_); |
[email protected] | bd92c3a | 2010-01-13 05:02:34 | [diff] [blame] | 1555 | } |
| 1556 | |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 1557 | WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( |
[email protected] | 40ec0c1 | 2012-03-08 12:34:40 | [diff] [blame] | 1558 | const WebGraphicsContext3D::Attributes& attributes) { |
| 1559 | return createGraphicsContext3D(attributes, true); |
| 1560 | } |
| 1561 | |
| 1562 | WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( |
[email protected] | 01e6903 | 2012-01-31 05:39:06 | [diff] [blame] | 1563 | const WebGraphicsContext3D::Attributes& attributes, |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 1564 | bool direct) { |
| 1565 | if (!webview()) |
| 1566 | return NULL; |
| 1567 | // The WebGraphicsContext3DInProcessImpl code path is used for |
| 1568 | // layout tests (though not through this code) as well as for |
| 1569 | // debugging and bringing up new ports. |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 1570 | if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { |
[email protected] | 56200f01 | 2012-02-03 23:13:57 | [diff] [blame] | 1571 | return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( |
[email protected] | 33a9c76 | 2012-02-23 22:37:24 | [diff] [blame] | 1572 | attributes, direct); |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 1573 | } else { |
[email protected] | b3e83de | 2012-02-07 03:33:28 | [diff] [blame] | 1574 | int surface = direct ? surface_id() : 0; |
| 1575 | |
| 1576 | GURL url; |
| 1577 | if (webview()->mainFrame()) |
| 1578 | url = GURL(webview()->mainFrame()->document().url()); |
| 1579 | |
| 1580 | base::WeakPtr<WebGraphicsContext3DSwapBuffersClient> swap_client; |
| 1581 | if (direct) |
| 1582 | swap_client = AsWeakPtr(); |
| 1583 | |
| 1584 | scoped_ptr<WebGraphicsContext3DCommandBufferImpl> context( |
| 1585 | new WebGraphicsContext3DCommandBufferImpl( |
[email protected] | 9193034b | 2012-03-12 19:51:22 | [diff] [blame] | 1586 | surface, url, RenderThreadImpl::current(), swap_client)); |
[email protected] | b3e83de | 2012-02-07 03:33:28 | [diff] [blame] | 1587 | |
| 1588 | if (!context->Initialize(attributes)) |
[email protected] | 56200f01 | 2012-02-03 23:13:57 | [diff] [blame] | 1589 | return NULL; |
[email protected] | d0fb8a7 | 2012-03-10 18:54:52 | [diff] [blame] | 1590 | context_is_web_graphics_context_3d_command_buffer_impl_ = true; |
[email protected] | 56200f01 | 2012-02-03 23:13:57 | [diff] [blame] | 1591 | return context.release(); |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 1592 | } |
[email protected] | 7e8b4d1 | 2012-01-20 23:39:51 | [diff] [blame] | 1593 | } |
| 1594 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1595 | void RenderViewImpl::didAddMessageToConsole( |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1596 | const WebConsoleMessage& message, const WebString& source_name, |
| 1597 | unsigned source_line) { |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1598 | logging::LogSeverity log_severity = logging::LOG_VERBOSE; |
[email protected] | f7eb0a39 | 2011-07-12 10:19:51 | [diff] [blame] | 1599 | switch (message.level) { |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1600 | case WebConsoleMessage::LevelTip: |
| 1601 | log_severity = logging::LOG_VERBOSE; |
| 1602 | break; |
| 1603 | case WebConsoleMessage::LevelLog: |
| 1604 | log_severity = logging::LOG_INFO; |
| 1605 | break; |
| 1606 | case WebConsoleMessage::LevelWarning: |
| 1607 | log_severity = logging::LOG_WARNING; |
| 1608 | break; |
| 1609 | case WebConsoleMessage::LevelError: |
| 1610 | log_severity = logging::LOG_ERROR; |
| 1611 | break; |
| 1612 | default: |
| 1613 | NOTREACHED(); |
| 1614 | } |
| 1615 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1616 | Send(new ViewHostMsg_AddMessageToConsole(routing_id_, |
[email protected] | d09df4b | 2011-04-11 19:01:08 | [diff] [blame] | 1617 | static_cast<int32>(log_severity), |
[email protected] | aa21d2a | 2011-08-08 23:56:31 | [diff] [blame] | 1618 | message.text, |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1619 | static_cast<int32>(source_line), |
[email protected] | aa21d2a | 2011-08-08 23:56:31 | [diff] [blame] | 1620 | source_name)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1621 | } |
| 1622 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1623 | void RenderViewImpl::printPage(WebFrame* frame) { |
[email protected] | d91ddfc | 2011-04-07 18:33:42 | [diff] [blame] | 1624 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, PrintPage(frame)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1625 | } |
| 1626 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1627 | WebKit::WebNotificationPresenter* RenderViewImpl::notificationPresenter() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 1628 | return notification_provider_; |
[email protected] | 3354d3e | 2010-06-10 19:53:02 | [diff] [blame] | 1629 | } |
| 1630 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1631 | bool RenderViewImpl::enumerateChosenDirectory( |
[email protected] | 8a58c1c | 2011-04-19 18:40:12 | [diff] [blame] | 1632 | const WebString& path, |
| 1633 | WebFileChooserCompletion* chooser_completion) { |
| 1634 | int id = enumeration_completion_id_++; |
| 1635 | enumeration_completions_[id] = chooser_completion; |
| 1636 | return Send(new ViewHostMsg_EnumerateDirectory( |
| 1637 | routing_id_, |
| 1638 | id, |
| 1639 | webkit_glue::WebStringToFilePath(path))); |
| 1640 | } |
| 1641 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1642 | void RenderViewImpl::didStartLoading() { |
[email protected] | 6dc7ff6 | 2012-03-15 06:16:13 | [diff] [blame] | 1643 | #if defined(OS_CHROMEOS) |
| 1644 | // crosbug.com/26646. |
| 1645 | LOG(ERROR) << "didStartLoading is_loading=" << is_loading_; |
| 1646 | #endif |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1647 | if (is_loading_) { |
[email protected] | 511754da | 2012-01-24 20:48:14 | [diff] [blame] | 1648 | DVLOG(1) << "didStartLoading called while loading"; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1649 | return; |
| 1650 | } |
| 1651 | |
| 1652 | is_loading_ = true; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1653 | |
| 1654 | Send(new ViewHostMsg_DidStartLoading(routing_id_)); |
[email protected] | 93b9d69 | 2011-04-13 00:44:31 | [diff] [blame] | 1655 | |
| 1656 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStartLoading()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1657 | } |
| 1658 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1659 | void RenderViewImpl::didStopLoading() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1660 | if (!is_loading_) { |
[email protected] | 511754da | 2012-01-24 20:48:14 | [diff] [blame] | 1661 | DVLOG(1) << "DidStopLoading called while not loading"; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1662 | return; |
| 1663 | } |
| 1664 | |
| 1665 | is_loading_ = false; |
| 1666 | |
| 1667 | // NOTE: For now we're doing the safest thing, and sending out notification |
| 1668 | // when done loading. This currently isn't an issue as the favicon is only |
| 1669 | // displayed when done loading. Ideally we would send notification when |
| 1670 | // finished parsing the head, but webkit doesn't support that yet. |
| 1671 | // The feed discovery code would also benefit from access to the head. |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1672 | Send(new ViewHostMsg_DidStopLoading(routing_id_)); |
| 1673 | |
[email protected] | 9010941 | 2010-12-15 17:14:24 | [diff] [blame] | 1674 | if (load_progress_tracker_ != NULL) |
| 1675 | load_progress_tracker_->DidStopLoading(); |
| 1676 | |
[email protected] | 93b9d69 | 2011-04-13 00:44:31 | [diff] [blame] | 1677 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidStopLoading()); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1678 | } |
| 1679 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1680 | void RenderViewImpl::didChangeLoadProgress(WebFrame* frame, |
| 1681 | double load_progress) { |
[email protected] | 9010941 | 2010-12-15 17:14:24 | [diff] [blame] | 1682 | if (load_progress_tracker_ != NULL) |
| 1683 | load_progress_tracker_->DidChangeLoadProgress(frame, load_progress); |
| 1684 | } |
| 1685 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1686 | bool RenderViewImpl::isSmartInsertDeleteEnabled() { |
[email protected] | f55039a | 2010-02-17 14:12:06 | [diff] [blame] | 1687 | #if defined(OS_MACOSX) |
| 1688 | return true; |
| 1689 | #else |
| 1690 | return false; |
| 1691 | #endif |
| 1692 | } |
| 1693 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1694 | bool RenderViewImpl::isSelectTrailingWhitespaceEnabled() { |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1695 | #if defined(OS_WIN) |
| 1696 | return true; |
| 1697 | #else |
| 1698 | return false; |
| 1699 | #endif |
| 1700 | } |
| 1701 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1702 | void RenderViewImpl::didChangeSelection(bool is_empty_selection) { |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1703 | if (!handling_input_event_ && !handling_select_range_) |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1704 | return; |
[email protected] | 4fb6014 | 2011-08-09 02:22:08 | [diff] [blame] | 1705 | handling_select_range_ = false; |
[email protected] | d4cff27 | 2011-05-02 15:46:01 | [diff] [blame] | 1706 | |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 1707 | SyncSelectionIfRequired(); |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1708 | } |
| 1709 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1710 | void RenderViewImpl::didExecuteCommand(const WebString& command_name) { |
[email protected] | afe3a167 | 2009-11-17 19:04:12 | [diff] [blame] | 1711 | const std::string& name = UTF16ToUTF8(command_name); |
| 1712 | if (StartsWithASCII(name, "Move", true) || |
| 1713 | StartsWithASCII(name, "Insert", true) || |
| 1714 | StartsWithASCII(name, "Delete", true)) |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1715 | return; |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 1716 | RenderThreadImpl::current()->RecordUserMetrics(name); |
[email protected] | 04fc948 | 2009-09-18 22:13:03 | [diff] [blame] | 1717 | } |
| 1718 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1719 | bool RenderViewImpl::handleCurrentKeyboardEvent() { |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1720 | if (edit_commands_.empty()) |
| 1721 | return false; |
| 1722 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 1723 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1724 | if (!frame) |
| 1725 | return false; |
| 1726 | |
| 1727 | EditCommands::iterator it = edit_commands_.begin(); |
| 1728 | EditCommands::iterator end = edit_commands_.end(); |
| 1729 | |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1730 | bool did_execute_command = false; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1731 | for (; it != end; ++it) { |
[email protected] | e6e1501 | 2009-09-30 14:59:33 | [diff] [blame] | 1732 | // In gtk and cocoa, it's possible to bind multiple edit commands to one |
| 1733 | // key (but it's the exception). Once one edit command is not executed, it |
| 1734 | // seems safest to not execute the rest. |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1735 | if (!frame->executeCommand(WebString::fromUTF8(it->name), |
| 1736 | WebString::fromUTF8(it->value))) |
| 1737 | break; |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1738 | did_execute_command = true; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1739 | } |
| 1740 | |
[email protected] | 507b33ea | 2009-09-29 03:56:51 | [diff] [blame] | 1741 | return did_execute_command; |
[email protected] | b2528b7 | 2009-09-24 06:57:10 | [diff] [blame] | 1742 | } |
| 1743 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1744 | bool RenderViewImpl::runFileChooser( |
[email protected] | 01178b5 | 2010-01-15 06:59:35 | [diff] [blame] | 1745 | const WebKit::WebFileChooserParams& params, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1746 | WebFileChooserCompletion* chooser_completion) { |
[email protected] | 7ef03e0 | 2010-10-23 11:58:35 | [diff] [blame] | 1747 | // Do not open the file dialog in a hidden RenderView. |
| 1748 | if (is_hidden()) |
| 1749 | return false; |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1750 | content::FileChooserParams ipc_params; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1751 | if (params.directory) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1752 | ipc_params.mode = content::FileChooserParams::OpenFolder; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1753 | else if (params.multiSelect) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1754 | ipc_params.mode = content::FileChooserParams::OpenMultiple; |
[email protected] | 459fba8 | 2011-10-13 02:48:50 | [diff] [blame] | 1755 | else if (params.saveAs) |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1756 | ipc_params.mode = content::FileChooserParams::Save; |
[email protected] | b5977a0c | 2010-08-24 19:46:26 | [diff] [blame] | 1757 | else |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 1758 | ipc_params.mode = content::FileChooserParams::Open; |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1759 | ipc_params.title = params.title; |
| 1760 | ipc_params.default_file_name = |
| 1761 | webkit_glue::WebStringToFilePath(params.initialValue); |
[email protected] | 3314c2b1 | 2011-11-02 08:05:46 | [diff] [blame] | 1762 | ipc_params.accept_types.reserve(params.acceptMIMETypes.size()); |
| 1763 | for (size_t i = 0; i < params.acceptMIMETypes.size(); ++i) |
| 1764 | ipc_params.accept_types.push_back(params.acceptMIMETypes[i]); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 1765 | |
| 1766 | return ScheduleFileChooser(ipc_params, chooser_completion); |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 1767 | } |
| 1768 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1769 | void RenderViewImpl::runModalAlertDialog(WebFrame* frame, |
| 1770 | const WebString& message) { |
| 1771 | RunJavaScriptMessage(ui::JAVASCRIPT_MESSAGE_TYPE_ALERT, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1772 | message, |
| 1773 | string16(), |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1774 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1775 | NULL); |
| 1776 | } |
| 1777 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1778 | bool RenderViewImpl::runModalConfirmDialog(WebFrame* frame, |
| 1779 | const WebString& message) { |
| 1780 | return RunJavaScriptMessage(ui::JAVASCRIPT_MESSAGE_TYPE_CONFIRM, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1781 | message, |
| 1782 | string16(), |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1783 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1784 | NULL); |
| 1785 | } |
| 1786 | |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1787 | bool RenderViewImpl::runModalPromptDialog(WebFrame* frame, |
| 1788 | const WebString& message, |
| 1789 | const WebString& default_value, |
| 1790 | WebString* actual_value) { |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1791 | string16 result; |
[email protected] | 269f86d | 2011-12-07 02:43:47 | [diff] [blame] | 1792 | bool ok = RunJavaScriptMessage(ui::JAVASCRIPT_MESSAGE_TYPE_PROMPT, |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1793 | message, |
| 1794 | default_value, |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1795 | frame->document().url(), |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1796 | &result); |
| 1797 | if (ok) |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1798 | actual_value->assign(result); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1799 | return ok; |
| 1800 | } |
| 1801 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1802 | bool RenderViewImpl::runModalBeforeUnloadDialog( |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1803 | WebFrame* frame, const WebString& message) { |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 1804 | // If we are swapping out, we have already run the beforeunload handler. |
| 1805 | // TODO(creis): Fix OnSwapOut to clear the frame without running beforeunload |
| 1806 | // at all, to avoid running it twice. |
| 1807 | if (is_swapped_out_) |
| 1808 | return true; |
| 1809 | |
[email protected] | 3b3301f6 | 2012-02-29 04:32:32 | [diff] [blame] | 1810 | bool is_reload = false; |
| 1811 | WebDataSource* ds = frame->provisionalDataSource(); |
| 1812 | if (ds) |
| 1813 | is_reload = (ds->navigationType() == WebKit::WebNavigationTypeReload); |
| 1814 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1815 | bool success = false; |
| 1816 | // This is an ignored return value, but is included so we can accept the same |
| 1817 | // response as RunJavaScriptMessage. |
[email protected] | 4f5ce84 | 2011-05-27 19:34:41 | [diff] [blame] | 1818 | string16 ignored_result; |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 1819 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunBeforeUnloadConfirm( |
[email protected] | 3b3301f6 | 2012-02-29 04:32:32 | [diff] [blame] | 1820 | routing_id_, frame->document().url(), message, is_reload, |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 1821 | &success, &ignored_result)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1822 | return success; |
| 1823 | } |
| 1824 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1825 | void RenderViewImpl::showContextMenu( |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 1826 | WebFrame* frame, const WebContextMenuData& data) { |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 1827 | content::ContextMenuParams params(data); |
[email protected] | 7fcd9b7 | 2011-07-27 16:52:37 | [diff] [blame] | 1828 | |
| 1829 | // frame is NULL if invoked by BlockedPlugin. |
| 1830 | if (frame) |
| 1831 | params.frame_id = frame->identifier(); |
| 1832 | |
[email protected] | db803aae | 2011-03-05 02:00:42 | [diff] [blame] | 1833 | // Serializing a GURL longer than content::kMaxURLChars will fail, so don't do |
[email protected] | 216932c | 2010-08-26 21:44:27 | [diff] [blame] | 1834 | // it. We replace it with an empty GURL so the appropriate items are disabled |
| 1835 | // in the context menu. |
| 1836 | // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large |
| 1837 | // data encoded images. We should have a way to save them. |
[email protected] | db803aae | 2011-03-05 02:00:42 | [diff] [blame] | 1838 | if (params.src_url.spec().size() > content::kMaxURLChars) |
[email protected] | 216932c | 2010-08-26 21:44:27 | [diff] [blame] | 1839 | params.src_url = GURL(); |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 1840 | context_menu_node_ = data.node; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 1841 | Send(new ViewHostMsg_ContextMenu(routing_id_, params)); |
[email protected] | 79e3744 | 2009-10-09 18:17:44 | [diff] [blame] | 1842 | } |
| 1843 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1844 | void RenderViewImpl::enterFullscreen() { |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1845 | // TODO(darin): Remove once WebKit roll is complete. |
| 1846 | enterFullScreen(); |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 1847 | } |
| 1848 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1849 | void RenderViewImpl::exitFullscreen() { |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 1850 | // TODO(darin): Remove once WebKit roll is complete. |
| 1851 | exitFullScreen(); |
[email protected] | 8a5e0ca | 2011-08-25 06:30:47 | [diff] [blame] | 1852 | } |
| 1853 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1854 | void RenderViewImpl::setStatusText(const WebString& text) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1855 | } |
| 1856 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1857 | void RenderViewImpl::UpdateTargetURL(const GURL& url, |
| 1858 | const GURL& fallback_url) { |
[email protected] | aa6b90b3 | 2010-04-26 15:49:58 | [diff] [blame] | 1859 | GURL latest_url = url.is_empty() ? fallback_url : url; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1860 | if (latest_url == target_url_) |
| 1861 | return; |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1862 | |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1863 | // Tell the browser to display a destination link. |
| 1864 | if (target_url_status_ == TARGET_INFLIGHT || |
| 1865 | target_url_status_ == TARGET_PENDING) { |
| 1866 | // If we have a request in-flight, save the URL to be sent when we |
| 1867 | // receive an ACK to the in-flight request. We can happily overwrite |
| 1868 | // any existing pending sends. |
| 1869 | pending_target_url_ = latest_url; |
| 1870 | target_url_status_ = TARGET_PENDING; |
| 1871 | } else { |
[email protected] | c85f021 | 2011-11-04 16:54:41 | [diff] [blame] | 1872 | // URLs larger than |content::kMaxURLChars| cannot be sent through IPC - |
| 1873 | // see |ParamTraits<GURL>|. |
| 1874 | if (latest_url.possibly_invalid_spec().size() > content::kMaxURLChars) |
| 1875 | latest_url = GURL(); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1876 | Send(new ViewHostMsg_UpdateTargetURL(routing_id_, page_id_, latest_url)); |
| 1877 | target_url_ = latest_url; |
| 1878 | target_url_status_ = TARGET_INFLIGHT; |
| 1879 | } |
| 1880 | } |
| 1881 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1882 | void RenderViewImpl::StartNavStateSyncTimerIfNecessary() { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1883 | int delay; |
| 1884 | if (send_content_state_immediately_) |
| 1885 | delay = 0; |
| 1886 | else if (is_hidden()) |
| 1887 | delay = kDelaySecondsForContentStateSyncHidden; |
| 1888 | else |
| 1889 | delay = kDelaySecondsForContentStateSync; |
| 1890 | |
| 1891 | if (nav_state_sync_timer_.IsRunning()) { |
| 1892 | // The timer is already running. If the delay of the timer maches the amount |
| 1893 | // we want to delay by, then return. Otherwise stop the timer so that it |
| 1894 | // gets started with the right delay. |
| 1895 | if (nav_state_sync_timer_.GetCurrentDelay().InSeconds() == delay) |
| 1896 | return; |
| 1897 | nav_state_sync_timer_.Stop(); |
| 1898 | } |
| 1899 | |
[email protected] | d323a17 | 2011-09-02 18:23:02 | [diff] [blame] | 1900 | nav_state_sync_timer_.Start(FROM_HERE, TimeDelta::FromSeconds(delay), this, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1901 | &RenderViewImpl::SyncNavigationState); |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 1902 | } |
| 1903 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1904 | void RenderViewImpl::setMouseOverURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1905 | mouse_over_url_ = GURL(url); |
| 1906 | UpdateTargetURL(mouse_over_url_, focus_url_); |
| 1907 | } |
| 1908 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1909 | void RenderViewImpl::setKeyboardFocusURL(const WebURL& url) { |
[email protected] | 163f824 | 2009-10-30 20:19:55 | [diff] [blame] | 1910 | focus_url_ = GURL(url); |
| 1911 | UpdateTargetURL(focus_url_, mouse_over_url_); |
| 1912 | } |
| 1913 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1914 | void RenderViewImpl::startDragging(const WebDragData& data, |
| 1915 | WebDragOperationsMask mask, |
| 1916 | const WebImage& image, |
| 1917 | const WebPoint& imageOffset) { |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 1918 | #if WEBKIT_USING_SKIA |
| 1919 | SkBitmap bitmap(image.getSkBitmap()); |
| 1920 | #elif WEBKIT_USING_CG |
[email protected] | 78043bdd | 2010-04-05 18:45:33 | [diff] [blame] | 1921 | SkBitmap bitmap = gfx::CGImageToSkBitmap(image.getCGImageRef()); |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 1922 | #endif |
| 1923 | |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 1924 | Send(new DragHostMsg_StartDragging(routing_id_, |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1925 | WebDropData(data), |
[email protected] | c27ae59 | 2010-03-18 15:24:41 | [diff] [blame] | 1926 | mask, |
| 1927 | bitmap, |
| 1928 | imageOffset)); |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1929 | } |
| 1930 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1931 | bool RenderViewImpl::acceptsLoadDrops() { |
[email protected] | 28b92df | 2009-09-25 17:35:45 | [diff] [blame] | 1932 | return renderer_preferences_.can_accept_load_drops; |
| 1933 | } |
| 1934 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1935 | void RenderViewImpl::focusNext() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1936 | Send(new ViewHostMsg_TakeFocus(routing_id_, false)); |
| 1937 | } |
| 1938 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1939 | void RenderViewImpl::focusPrevious() { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1940 | Send(new ViewHostMsg_TakeFocus(routing_id_, true)); |
| 1941 | } |
| 1942 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1943 | void RenderViewImpl::focusedNodeChanged(const WebNode& node) { |
[email protected] | 9b66f34bf | 2010-10-27 20:45:51 | [diff] [blame] | 1944 | Send(new ViewHostMsg_FocusedNodeChanged(routing_id_, IsEditableNode(node))); |
[email protected] | a4b103b | 2010-10-05 18:46:07 | [diff] [blame] | 1945 | |
[email protected] | 38b59290 | 2011-04-16 02:08:42 | [diff] [blame] | 1946 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FocusedNodeChanged(node)); |
[email protected] | 08e9e13 | 2010-06-01 16:58:49 | [diff] [blame] | 1947 | } |
| 1948 | |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 1949 | void RenderViewImpl::didUpdateLayout() { |
| 1950 | // We don't always want to set up a timer, only if we've been put in that |
| 1951 | // mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 1952 | // message. |
| 1953 | if (!send_preferred_size_changes_ || !webview()) |
| 1954 | return; |
| 1955 | |
| 1956 | if (check_preferred_size_timer_.IsRunning()) |
| 1957 | return; |
| 1958 | check_preferred_size_timer_.Start(FROM_HERE, |
| 1959 | TimeDelta::FromMilliseconds(0), this, |
| 1960 | &RenderViewImpl::CheckPreferredSize); |
| 1961 | } |
| 1962 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1963 | void RenderViewImpl::navigateBackForwardSoon(int offset) { |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1964 | Send(new ViewHostMsg_GoToEntryAtOffset(routing_id_, offset)); |
| 1965 | } |
| 1966 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1967 | int RenderViewImpl::historyBackListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1968 | return history_list_offset_ < 0 ? 0 : history_list_offset_; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1969 | } |
| 1970 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1971 | int RenderViewImpl::historyForwardListCount() { |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 1972 | return history_list_length_ - historyBackListCount() - 1; |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 1973 | } |
| 1974 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1975 | void RenderViewImpl::postAccessibilityNotification( |
[email protected] | 063afcb | 2011-09-29 07:54:32 | [diff] [blame] | 1976 | const WebAccessibilityObject& obj, |
| 1977 | WebAccessibilityNotification notification) { |
| 1978 | renderer_accessibility_->PostAccessibilityNotification(obj, notification); |
| 1979 | } |
| 1980 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1981 | void RenderViewImpl::didUpdateInspectorSetting(const WebString& key, |
[email protected] | c4e9890 | 2010-06-01 10:20:14 | [diff] [blame] | 1982 | const WebString& value) { |
| 1983 | Send(new ViewHostMsg_UpdateInspectorSetting(routing_id_, |
| 1984 | key.utf8(), |
| 1985 | value.utf8())); |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 1986 | } |
| 1987 | |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 1988 | // WebKit::WebWidgetClient ---------------------------------------------------- |
| 1989 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 1990 | void RenderViewImpl::didFocus() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 1991 | // TODO(jcivelli): when https://bugs.webkit.org/show_bug.cgi?id=33389 is fixed |
| 1992 | // we won't have to test for user gesture anymore and we can |
| 1993 | // move that code back to render_widget.cc |
| 1994 | if (webview() && webview()->mainFrame() && |
| 1995 | webview()->mainFrame()->isProcessingUserGesture()) { |
| 1996 | Send(new ViewHostMsg_Focus(routing_id_)); |
| 1997 | } |
| 1998 | } |
| 1999 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2000 | void RenderViewImpl::didBlur() { |
[email protected] | ea42e778 | 2010-08-23 23:58:12 | [diff] [blame] | 2001 | // TODO(jcivelli): see TODO above in didFocus(). |
| 2002 | if (webview() && webview()->mainFrame() && |
| 2003 | webview()->mainFrame()->isProcessingUserGesture()) { |
| 2004 | Send(new ViewHostMsg_Blur(routing_id_)); |
| 2005 | } |
| 2006 | } |
| 2007 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2008 | // 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] | 2009 | // that was created via RenderViewImpl::CreateWebView. So, we wait until this |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2010 | // point to dispatch the ShowView message. |
| 2011 | // |
| 2012 | // This method provides us with the information about how to display the newly |
[email protected] | 5f9de588 | 2011-09-30 23:36:28 | [diff] [blame] | 2013 | // created RenderView (i.e., as a blocked popup or as a new tab). |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2014 | // |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2015 | void RenderViewImpl::show(WebNavigationPolicy policy) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2016 | DCHECK(!did_show_) << "received extraneous Show call"; |
| 2017 | DCHECK(opener_id_ != MSG_ROUTING_NONE); |
| 2018 | |
| 2019 | if (did_show_) |
| 2020 | return; |
| 2021 | did_show_ = true; |
| 2022 | |
[email protected] | 6779aa1 | 2011-03-29 17:32:24 | [diff] [blame] | 2023 | if (content::GetContentClient()->renderer()->AllowPopup(creator_url_)) |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 2024 | opened_by_user_gesture_ = true; |
[email protected] | 4026ce1e | 2010-09-14 19:35:04 | [diff] [blame] | 2025 | |
[email protected] | 28295ec | 2009-10-16 05:34:33 | [diff] [blame] | 2026 | // Force new windows to a popup if they were not opened with a user gesture. |
| 2027 | if (!opened_by_user_gesture_) { |
| 2028 | // We exempt background tabs for compat with older versions of Chrome. |
| 2029 | // TODO(darin): This seems bogus. These should have a user gesture, so |
| 2030 | // we probably don't need this check. |
| 2031 | if (policy != WebKit::WebNavigationPolicyNewBackgroundTab) |
| 2032 | policy = WebKit::WebNavigationPolicyNewPopup; |
| 2033 | } |
| 2034 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2035 | // NOTE: initial_pos_ may still have its default values at this point, but |
| 2036 | // that's okay. It'll be ignored if disposition is not NEW_POPUP, or the |
| 2037 | // browser process will impose a default position otherwise. |
[email protected] | 4873c7d | 2009-07-16 06:36:28 | [diff] [blame] | 2038 | Send(new ViewHostMsg_ShowView(opener_id_, routing_id_, |
| 2039 | NavigationPolicyToDisposition(policy), initial_pos_, |
[email protected] | 7e7414ae | 2010-01-26 20:19:29 | [diff] [blame] | 2040 | opened_by_user_gesture_)); |
[email protected] | 2533ce1 | 2009-05-09 00:02:24 | [diff] [blame] | 2041 | SetPendingWindowRect(initial_pos_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2042 | } |
| 2043 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2044 | void RenderViewImpl::runModal() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2045 | DCHECK(did_show_) << "should already have shown the view"; |
| 2046 | |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 2047 | // We must keep WebKit's shared timer running in this case in order to allow |
| 2048 | // showModalDialog to function properly. |
| 2049 | // |
| 2050 | // TODO(darin): WebKit should really be smarter about suppressing events and |
| 2051 | // timers so that we do not need to manage the shared timer in such a heavy |
| 2052 | // handed manner. |
| 2053 | // |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 2054 | if (RenderThreadImpl::current()) // Will be NULL during unit tests. |
| 2055 | RenderThreadImpl::current()->DoNotSuspendWebKitSharedTimer(); |
[email protected] | c1f50aa | 2010-02-18 03:46:57 | [diff] [blame] | 2056 | |
[email protected] | 12636df | 2009-09-28 22:32:21 | [diff] [blame] | 2057 | SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 2058 | } |
| 2059 | |
[email protected] | 2b624c56 | 2011-10-27 22:58:26 | [diff] [blame] | 2060 | bool RenderViewImpl::enterFullScreen() { |
| 2061 | Send(new ViewHostMsg_ToggleFullscreen(routing_id_, true)); |
| 2062 | return true; |
| 2063 | } |
| 2064 | |
| 2065 | void RenderViewImpl::exitFullScreen() { |
| 2066 | Send(new ViewHostMsg_ToggleFullscreen(routing_id_, false)); |
| 2067 | } |
| 2068 | |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 2069 | bool RenderViewImpl::requestPointerLock() { |
| 2070 | return mouse_lock_dispatcher_->LockMouse(webwidget_mouse_lock_target_.get()); |
| 2071 | } |
| 2072 | |
| 2073 | void RenderViewImpl::requestPointerUnlock() { |
| 2074 | mouse_lock_dispatcher_->UnlockMouse(webwidget_mouse_lock_target_.get()); |
| 2075 | } |
| 2076 | |
| 2077 | bool RenderViewImpl::isPointerLocked() { |
| 2078 | return mouse_lock_dispatcher_->IsMouseLockedTo( |
| 2079 | webwidget_mouse_lock_target_.get()); |
| 2080 | } |
| 2081 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2082 | // WebKit::WebFrameClient ----------------------------------------------------- |
| 2083 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2084 | WebPlugin* RenderViewImpl::createPlugin(WebFrame* frame, |
| 2085 | const WebPluginParams& params) { |
[email protected] | 0361b94 | 2012-03-14 06:42:53 | [diff] [blame] | 2086 | // The browser plugin is a special kind of pepper plugin |
| 2087 | // that loads asynchronously. We first create a placeholder here. |
| 2088 | // When a guest is ready to be displayed, we swap out the placeholder |
| 2089 | // with the guest. |
| 2090 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 2091 | if (command_line.HasSwitch(switches::kEnableBrowserPlugin) && |
| 2092 | UTF16ToASCII(params.mimeType) == kBrowserPluginMimeType) |
| 2093 | return BrowserPluginPlaceholder::Create(this, frame, params); |
| 2094 | |
[email protected] | eaacd1f | 2011-09-23 02:32:55 | [diff] [blame] | 2095 | WebPlugin* plugin = NULL; |
| 2096 | if (content::GetContentClient()->renderer()->OverrideCreatePlugin( |
| 2097 | this, frame, params, &plugin)) { |
| 2098 | return plugin; |
| 2099 | } |
| 2100 | |
[email protected] | a813c8e | 2011-10-08 01:34:11 | [diff] [blame] | 2101 | webkit::WebPluginInfo info; |
| 2102 | std::string mime_type; |
| 2103 | bool found = GetPluginInfo(params.url, frame->top()->document().url(), |
| 2104 | params.mimeType.utf8(), &info, &mime_type); |
| 2105 | if (!found) |
| 2106 | return NULL; |
| 2107 | |
| 2108 | WebPluginParams params_to_use = params; |
| 2109 | params_to_use.mimeType = WebString::fromUTF8(mime_type); |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 2110 | return CreatePlugin(frame, info, params_to_use); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2111 | } |
| 2112 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2113 | WebSharedWorker* RenderViewImpl::createSharedWorker( |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 2114 | WebFrame* frame, const WebURL& url, const WebString& name, |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2115 | unsigned long long document_id) { |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 2116 | |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2117 | int route_id = MSG_ROUTING_NONE; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2118 | bool exists = false; |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2119 | bool url_mismatch = false; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2120 | ViewHostMsg_CreateWorker_Params params; |
| 2121 | params.url = url; |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2122 | params.name = name; |
| 2123 | params.document_id = document_id; |
| 2124 | params.render_view_route_id = routing_id_; |
| 2125 | params.route_id = MSG_ROUTING_NONE; |
[email protected] | f9bc9c0 | 2010-05-24 19:19:23 | [diff] [blame] | 2126 | params.script_resource_appcache_id = 0; |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2127 | Send(new ViewHostMsg_LookupSharedWorker( |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2128 | params, &exists, &route_id, &url_mismatch)); |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2129 | if (url_mismatch) { |
| 2130 | return NULL; |
| 2131 | } else { |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 2132 | return new WebSharedWorkerProxy(RenderThreadImpl::current(), |
[email protected] | 0791d3a | 2010-01-28 01:28:49 | [diff] [blame] | 2133 | document_id, |
[email protected] | 6de0bcf | 2010-02-17 22:00:51 | [diff] [blame] | 2134 | exists, |
[email protected] | 30447b6 | 2009-11-13 01:13:37 | [diff] [blame] | 2135 | route_id, |
| 2136 | routing_id_); |
| 2137 | } |
[email protected] | 9c00f00 | 2009-11-05 22:37:42 | [diff] [blame] | 2138 | } |
| 2139 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2140 | WebMediaPlayer* RenderViewImpl::createMediaPlayer( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2141 | WebFrame* frame, WebMediaPlayerClient* client) { |
[email protected] | 16e923d | 2011-04-30 00:41:44 | [diff] [blame] | 2142 | FOR_EACH_OBSERVER( |
| 2143 | RenderViewObserver, observers_, WillCreateMediaPlayer(frame, client)); |
[email protected] | 7198402c | 2011-04-11 12:15:17 | [diff] [blame] | 2144 | |
[email protected] | bb6fd40 | 2011-12-09 02:45:44 | [diff] [blame] | 2145 | media::MessageLoopFactory* message_loop_factory = |
[email protected] | b8032290 | 2012-03-06 01:33:50 | [diff] [blame] | 2146 | new media::MessageLoopFactory(); |
[email protected] | bb6fd40 | 2011-12-09 02:45:44 | [diff] [blame] | 2147 | media::FilterCollection* collection = new media::FilterCollection(); |
| 2148 | RenderMediaLog* render_media_log = new RenderMediaLog(); |
[email protected] | 457d834 | 2010-10-23 01:20:37 | [diff] [blame] | 2149 | |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 2150 | RenderAudioSourceProvider* audio_source_provider = NULL; |
| 2151 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2152 | // Add in any custom filter factories first. |
| 2153 | const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 2154 | if (!cmd_line->HasSwitch(switches::kDisableAudio)) { |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 2155 | // audio_source_provider is a "provider" to WebKit, and a sink |
| 2156 | // from the perspective of the audio renderer. |
| 2157 | audio_source_provider = new RenderAudioSourceProvider(); |
| 2158 | |
| 2159 | // Add the chrome specific audio renderer, using audio_source_provider |
| 2160 | // as the sink. |
| 2161 | AudioRendererImpl* audio_renderer = |
| 2162 | new AudioRendererImpl(audio_source_provider); |
| 2163 | collection->AddAudioRenderer(audio_renderer); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2164 | } |
| 2165 | |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 2166 | // Currently only cros/arm has any HW video decode support in |
| 2167 | // GpuVideoDecodeAccelerator so we don't even try to use it on other |
| 2168 | // platforms. This is a startup-time optimization. When new VDA |
| 2169 | // implementations are added, relax the #if above. |
[email protected] | d0fb8a7 | 2012-03-10 18:54:52 | [diff] [blame] | 2170 | #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 2171 | // Note we don't actually use the result of this blind down-cast unless it's |
| 2172 | // valid (not NULL and of the right type). |
[email protected] | 4356730 | 2012-02-16 23:21:39 | [diff] [blame] | 2173 | WebGraphicsContext3DCommandBufferImpl* context3d = |
| 2174 | static_cast<WebGraphicsContext3DCommandBufferImpl*>( |
| 2175 | webview()->graphicsContext3D()); |
[email protected] | d0fb8a7 | 2012-03-10 18:54:52 | [diff] [blame] | 2176 | if (context_is_web_graphics_context_3d_command_buffer_impl_ && context3d) { |
[email protected] | 84a83e19 | 2012-03-09 18:43:40 | [diff] [blame] | 2177 | MessageLoop* factories_loop = |
| 2178 | RenderThreadImpl::current()->compositor_thread() ? |
| 2179 | RenderThreadImpl::current()->compositor_thread()->GetWebThread() |
| 2180 | ->message_loop() : |
| 2181 | MessageLoop::current(); |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 2182 | GpuChannelHost* gpu_channel_host = |
| 2183 | RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 2184 | content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| 2185 | collection->AddVideoDecoder(new media::GpuVideoDecoder( |
[email protected] | 8d435928 | 2012-01-14 00:53:31 | [diff] [blame] | 2186 | message_loop_factory->GetMessageLoop("GpuVideoDecoder"), |
[email protected] | 84a83e19 | 2012-03-09 18:43:40 | [diff] [blame] | 2187 | factories_loop, |
[email protected] | 8d435928 | 2012-01-14 00:53:31 | [diff] [blame] | 2188 | new RendererGpuVideoDecoderFactories( |
[email protected] | 84a83e19 | 2012-03-09 18:43:40 | [diff] [blame] | 2189 | gpu_channel_host, factories_loop, context3d))); |
[email protected] | e1d69d76 | 2011-12-13 05:12:18 | [diff] [blame] | 2190 | } |
| 2191 | #endif |
| 2192 | |
[email protected] | da952fd | 2012-01-13 03:49:25 | [diff] [blame] | 2193 | webkit_media::WebMediaPlayerImpl* media_player = |
| 2194 | content::GetContentClient()->renderer()->OverrideCreateWebMediaPlayer( |
| 2195 | this, frame, client, AsWeakPtr(), collection, audio_source_provider, |
| 2196 | message_loop_factory, media_stream_impl_.get(), render_media_log); |
[email protected] | c4dabe45 | 2012-02-08 23:58:12 | [diff] [blame] | 2197 | #if defined(OS_ANDROID) |
| 2198 | // TODO(qinmin): Implement for android. |
| 2199 | // http://crbug.com/113218 |
| 2200 | #else |
[email protected] | da952fd | 2012-01-13 03:49:25 | [diff] [blame] | 2201 | if (!media_player) { |
[email protected] | cec4eb8 | 2012-01-12 17:51:56 | [diff] [blame] | 2202 | media_player = new webkit_media::WebMediaPlayerImpl( |
[email protected] | da952fd | 2012-01-13 03:49:25 | [diff] [blame] | 2203 | frame, client, AsWeakPtr(), collection, audio_source_provider, |
[email protected] | 9e2269d | 2012-01-07 00:06:21 | [diff] [blame] | 2204 | message_loop_factory, media_stream_impl_.get(), render_media_log); |
[email protected] | bb6fd40 | 2011-12-09 02:45:44 | [diff] [blame] | 2205 | } |
[email protected] | c4dabe45 | 2012-02-08 23:58:12 | [diff] [blame] | 2206 | #endif |
[email protected] | cec4eb8 | 2012-01-12 17:51:56 | [diff] [blame] | 2207 | return media_player; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2208 | } |
| 2209 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2210 | WebApplicationCacheHost* RenderViewImpl::createApplicationCacheHost( |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2211 | WebFrame* frame, WebApplicationCacheHostClient* client) { |
[email protected] | cdeeeb2 | 2012-01-11 07:44:23 | [diff] [blame] | 2212 | if (!frame || !frame->view()) |
| 2213 | return NULL; |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2214 | return new RendererWebApplicationCacheHostImpl( |
| 2215 | FromWebView(frame->view()), client, |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 2216 | RenderThreadImpl::current()->appcache_dispatcher()->backend_proxy()); |
[email protected] | 035545f | 2010-04-09 13:10:21 | [diff] [blame] | 2217 | } |
| 2218 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2219 | WebCookieJar* RenderViewImpl::cookieJar(WebFrame* frame) { |
[email protected] | 8ff18107 | 2010-11-29 17:09:38 | [diff] [blame] | 2220 | return &cookie_jar_; |
| 2221 | } |
| 2222 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2223 | void RenderViewImpl::frameDetached(WebFrame* frame) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 2224 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameDetached(frame)); |
[email protected] | 5041f98 | 2010-08-11 21:40:45 | [diff] [blame] | 2225 | } |
| 2226 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2227 | void RenderViewImpl::willClose(WebFrame* frame) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 2228 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, FrameWillClose(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2229 | } |
| 2230 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2231 | void RenderViewImpl::loadURLExternally( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2232 | WebFrame* frame, const WebURLRequest& request, |
| 2233 | WebNavigationPolicy policy) { |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2234 | loadURLExternally(frame, request, policy, WebString()); |
| 2235 | } |
| 2236 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2237 | void RenderViewImpl::loadURLExternally( |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2238 | WebFrame* frame, const WebURLRequest& request, |
| 2239 | WebNavigationPolicy policy, |
| 2240 | const WebString& suggested_name) { |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2241 | GURL referrer(request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 2242 | if (policy == WebKit::WebNavigationPolicyDownload) { |
[email protected] | 0622875ab | 2011-07-27 12:10:34 | [diff] [blame] | 2243 | Send(new ViewHostMsg_DownloadUrl(routing_id_, request.url(), referrer, |
| 2244 | suggested_name)); |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2245 | } else { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2246 | OpenURL(frame, request.url(), |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 2247 | Referrer(referrer, GetReferrerPolicyFromRequest(request)), policy); |
[email protected] | efce17b | 2009-09-11 18:04:59 | [diff] [blame] | 2248 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2249 | } |
| 2250 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2251 | WebNavigationPolicy RenderViewImpl::decidePolicyForNavigation( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2252 | WebFrame* frame, const WebURLRequest& request, WebNavigationType type, |
[email protected] | 65b95cd | 2009-10-09 05:10:22 | [diff] [blame] | 2253 | const WebNode&, WebNavigationPolicy default_policy, bool is_redirect) { |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 2254 | // TODO(creis): Remove this when we fix OnSwapOut to not need a navigation. |
| 2255 | if (is_swapped_out_) { |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 2256 | // It is possible for in-progress navigations to arrive here just after we |
| 2257 | // are swapped out, including iframes. We should cancel them. |
| 2258 | if (request.url() != GURL("about:swappedout")) |
| 2259 | return WebKit::WebNavigationPolicyIgnore; |
| 2260 | |
| 2261 | // Allow about:swappedout to complete. |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 2262 | return default_policy; |
| 2263 | } |
| 2264 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2265 | // Webkit is asking whether to navigate to a new URL. |
| 2266 | // This is fine normally, except if we're showing UI from one security |
| 2267 | // context and they're trying to navigate to a different context. |
| 2268 | const GURL& url = request.url(); |
| 2269 | |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 2270 | // A content initiated navigation may have originated from a link-click, |
| 2271 | // script, drag-n-drop operation, etc. |
| 2272 | bool is_content_initiated = |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2273 | DocumentState::FromDataSource(frame->provisionalDataSource())-> |
| 2274 | navigation_state()->is_content_initiated(); |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 2275 | |
[email protected] | a8c269a | 2011-10-25 20:17:22 | [diff] [blame] | 2276 | // Experimental: |
| 2277 | // If --enable-strict-site-isolation is enabled, send all top-level |
| 2278 | // navigations to the browser to let it swap processes when crossing site |
| 2279 | // boundaries. This is currently expected to break some script calls and |
| 2280 | // navigations, such as form submissions. |
| 2281 | const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
[email protected] | 313b80bd | 2011-11-23 03:49:10 | [diff] [blame] | 2282 | if (command_line.HasSwitch(switches::kEnableStrictSiteIsolation) && |
| 2283 | !frame->parent() && (is_content_initiated || is_redirect)) { |
| 2284 | WebString origin_str = frame->document().securityOrigin().toString(); |
| 2285 | GURL frame_url(origin_str.utf8().data()); |
| 2286 | // TODO(cevans): revisit whether this origin check is still necessary once |
| 2287 | // crbug.com/101395 is fixed. |
| 2288 | if (frame_url.GetOrigin() != url.GetOrigin()) { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2289 | Referrer referrer( |
| 2290 | GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 2291 | GetReferrerPolicyFromRequest(request)); |
[email protected] | 313b80bd | 2011-11-23 03:49:10 | [diff] [blame] | 2292 | OpenURL(frame, url, referrer, default_policy); |
| 2293 | return WebKit::WebNavigationPolicyIgnore; |
| 2294 | } |
[email protected] | a8c269a | 2011-10-25 20:17:22 | [diff] [blame] | 2295 | } |
| 2296 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2297 | // 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] | 2298 | // navigations. |
[email protected] | 5f000f27 | 2012-01-19 05:25:08 | [diff] [blame] | 2299 | if (is_content_initiated) { |
| 2300 | bool browser_handles_top_level_requests = |
| 2301 | renderer_preferences_.browser_handles_top_level_requests && |
| 2302 | IsNonLocalTopLevelNavigation(url, frame, type); |
| 2303 | if (browser_handles_top_level_requests || |
| 2304 | renderer_preferences_.browser_handles_all_requests) { |
| 2305 | Referrer referrer( |
| 2306 | GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 2307 | GetReferrerPolicyFromRequest(request)); |
[email protected] | 5f000f27 | 2012-01-19 05:25:08 | [diff] [blame] | 2308 | // Reset these counters as the RenderView could be reused for the next |
| 2309 | // navigation. |
| 2310 | page_id_ = -1; |
| 2311 | last_page_id_sent_to_browser_ = -1; |
| 2312 | OpenURL(frame, url, referrer, default_policy); |
| 2313 | return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2314 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2315 | } |
| 2316 | |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2317 | // 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] | 2318 | // 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] | 2319 | // top-level navigations within the current tab (as opposed to, for example, |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2320 | // opening a new window). But we sometimes navigate to about:blank to clear a |
| 2321 | // tab, and we want to still allow that. |
| 2322 | // |
[email protected] | 8f4da8c | 2011-02-09 19:49:57 | [diff] [blame] | 2323 | // Note: we do this only for GET requests because our mechanism for switching |
| 2324 | // processes only issues GET requests. In particular, POST requests don't |
| 2325 | // work, because this mechanism does not preserve form POST data. If it |
| 2326 | // becomes necessary to support process switching for POST requests, we will |
| 2327 | // need to send the request's httpBody data up to the browser process, and |
| 2328 | // issue a special POST navigation in WebKit (via |
| 2329 | // FrameLoader::loadFrameRequest). See ResourceDispatcher and WebURLLoaderImpl |
| 2330 | // for examples of how to send the httpBody data. |
[email protected] | 2762a1b | 2011-12-09 15:25:22 | [diff] [blame] | 2331 | if (!frame->parent() && is_content_initiated && |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2332 | default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 2333 | request.httpMethod() == "GET" && !url.SchemeIs(chrome::kAboutScheme)) { |
| 2334 | bool send_referrer = false; |
| 2335 | bool should_fork = |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 2336 | (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) || |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2337 | frame->isViewSourceModeEnabled() || |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2338 | url.SchemeIs(chrome::kViewSourceScheme); |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 2339 | |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2340 | if (!should_fork) { |
| 2341 | // Give the embedder a chance. |
[email protected] | d55c238 | 2011-08-18 23:10:36 | [diff] [blame] | 2342 | bool is_initial_navigation = page_id_ == -1; |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2343 | should_fork = content::GetContentClient()->renderer()->ShouldFork( |
[email protected] | 3f105a2f | 2012-02-25 18:27:36 | [diff] [blame] | 2344 | frame, url, is_initial_navigation, &send_referrer); |
[email protected] | 6101c34 | 2010-12-16 22:44:37 | [diff] [blame] | 2345 | } |
| 2346 | |
| 2347 | if (should_fork) { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2348 | Referrer referrer( |
| 2349 | GURL(request.httpHeaderField(WebString::fromUTF8("Referer"))), |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 2350 | GetReferrerPolicyFromRequest(request)); |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2351 | OpenURL( |
| 2352 | frame, url, send_referrer ? referrer : Referrer(), default_policy); |
[email protected] | 5351dbc | 2010-08-27 15:22:11 | [diff] [blame] | 2353 | return WebKit::WebNavigationPolicyIgnore; // Suppress the load here. |
| 2354 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2355 | } |
| 2356 | |
[email protected] | 43763f98 | 2011-08-26 18:33:40 | [diff] [blame] | 2357 | // Use the frame's original request's URL rather than the document's URL for |
| 2358 | // this check. For a popup, the document's URL may become the opener window's |
| 2359 | // URL if the opener has called document.write. See http://crbug.com/93517. |
| 2360 | GURL old_url(frame->dataSource()->request().url()); |
| 2361 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2362 | // Detect when a page is "forking" a new tab that can be safely rendered in |
| 2363 | // its own process. This is done by sites like Gmail that try to open links |
| 2364 | // in new windows without script connections back to the original page. We |
| 2365 | // treat such cases as browser navigations (in which we will create a new |
| 2366 | // renderer for a cross-site navigation), rather than WebKit navigations. |
| 2367 | // |
| 2368 | // We use the following heuristic to decide whether to fork a new page in its |
| 2369 | // own process: |
| 2370 | // The parent page must open a new tab to about:blank, set the new tab's |
| 2371 | // window.opener to null, and then redirect the tab to a cross-site URL using |
| 2372 | // JavaScript. |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 2373 | // |
| 2374 | // TODO(creis): Deprecate this logic once we can rely on rel=noreferrer |
| 2375 | // (see below). |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2376 | bool is_fork = |
| 2377 | // Must start from a tab showing about:blank, which is later redirected. |
[email protected] | a6b960ad97 | 2010-09-01 19:53:58 | [diff] [blame] | 2378 | old_url == GURL(chrome::kAboutBlankURL) && |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2379 | // Must be the first real navigation of the tab. |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 2380 | historyBackListCount() < 1 && |
| 2381 | historyForwardListCount() < 1 && |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2382 | // The parent page must have set the child's window.opener to null before |
| 2383 | // redirecting to the desired URL. |
| 2384 | frame->opener() == NULL && |
| 2385 | // Must be a top-level frame. |
| 2386 | frame->parent() == NULL && |
| 2387 | // Must not have issued the request from this page. |
| 2388 | is_content_initiated && |
| 2389 | // Must be targeted at the current tab. |
| 2390 | default_policy == WebKit::WebNavigationPolicyCurrentTab && |
| 2391 | // Must be a JavaScript navigation, which appears as "other". |
| 2392 | type == WebKit::WebNavigationTypeOther; |
[email protected] | 007a848b | 2009-10-26 15:55:46 | [diff] [blame] | 2393 | |
[email protected] | f92ce2b | 2012-03-06 18:02:59 | [diff] [blame] | 2394 | if (is_fork) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2395 | // Open the URL via the browser, not via WebKit. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2396 | OpenURL(frame, url, Referrer(), default_policy); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2397 | return WebKit::WebNavigationPolicyIgnore; |
| 2398 | } |
| 2399 | |
| 2400 | return default_policy; |
| 2401 | } |
| 2402 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2403 | bool RenderViewImpl::canHandleRequest( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2404 | WebFrame* frame, const WebURLRequest& request) { |
| 2405 | // We allow WebKit to think that everything can be handled even though |
| 2406 | // browser-side we limit what we load. |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2407 | return true; |
| 2408 | } |
| 2409 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2410 | WebURLError RenderViewImpl::cannotHandleRequestError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2411 | WebFrame* frame, const WebURLRequest& request) { |
| 2412 | NOTREACHED(); // Since we said we can handle all requests. |
| 2413 | return WebURLError(); |
| 2414 | } |
| 2415 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2416 | WebURLError RenderViewImpl::cancelledError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2417 | WebFrame* frame, const WebURLRequest& request) { |
| 2418 | WebURLError error; |
| 2419 | error.domain = WebString::fromUTF8(net::kErrorDomain); |
| 2420 | error.reason = net::ERR_ABORTED; |
| 2421 | error.unreachableURL = request.url(); |
| 2422 | return error; |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2423 | } |
| 2424 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2425 | void RenderViewImpl::unableToImplementPolicyWithError( |
[email protected] | 6069da8c | 2009-10-20 20:33:49 | [diff] [blame] | 2426 | WebFrame*, const WebURLError&) { |
| 2427 | NOTREACHED(); // Since we said we can handle all requests. |
[email protected] | 7b7a7dc | 2009-10-19 02:23:34 | [diff] [blame] | 2428 | } |
| 2429 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2430 | void RenderViewImpl::willSendSubmitEvent(WebKit::WebFrame* frame, |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2431 | const WebKit::WebFormElement& form) { |
| 2432 | // Some login forms have onSubmit handlers that put a hash of the password |
| 2433 | // into a hidden field and then clear the password. (Issue 28910.) |
| 2434 | // This method gets called before any of those handlers run, so save away |
| 2435 | // a copy of the password in case it gets lost. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2436 | DocumentState* document_state = |
| 2437 | DocumentState::FromDataSource(frame->dataSource()); |
| 2438 | document_state->set_password_form_data( |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2439 | PasswordFormDomManager::CreatePasswordForm(form)); |
| 2440 | } |
| 2441 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2442 | void RenderViewImpl::willSubmitForm(WebFrame* frame, |
| 2443 | const WebFormElement& form) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2444 | DocumentState* document_state = |
| 2445 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 2446 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2447 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2448 | if (navigation_state->transition_type() == content::PAGE_TRANSITION_LINK) |
| 2449 | navigation_state->set_transition_type(content::PAGE_TRANSITION_FORM_SUBMIT); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2450 | |
| 2451 | // Save these to be processed when the ensuing navigation is committed. |
[email protected] | ce0e250d | 2009-10-23 21:00:35 | [diff] [blame] | 2452 | WebSearchableFormData web_searchable_form_data(form); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2453 | document_state->set_searchable_form_url(web_searchable_form_data.url()); |
| 2454 | document_state->set_searchable_form_encoding( |
[email protected] | b7910b3a | 2010-01-13 18:33:21 | [diff] [blame] | 2455 | web_searchable_form_data.encoding().utf8()); |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2456 | PasswordForm* password_form_data = |
| 2457 | PasswordFormDomManager::CreatePasswordForm(form); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2458 | document_state->set_password_form_data(password_form_data); |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2459 | |
[email protected] | 098c95cb | 2011-04-28 16:49:01 | [diff] [blame] | 2460 | // In order to save the password that the user actually typed and not one |
| 2461 | // that may have gotten transformed by the site prior to submit, recover it |
| 2462 | // from the form contents already stored by |willSendSubmitEvent| into the |
| 2463 | // dataSource's NavigationState (as opposed to the provisionalDataSource's, |
| 2464 | // which is what we're storing into now.) |
| 2465 | if (password_form_data) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2466 | DocumentState* old_document_state = |
| 2467 | DocumentState::FromDataSource(frame->dataSource()); |
| 2468 | if (old_document_state) { |
| 2469 | PasswordForm* old_form_data = old_document_state->password_form_data(); |
[email protected] | 90eeddb | 2010-05-06 21:06:43 | [diff] [blame] | 2470 | if (old_form_data && old_form_data->action == password_form_data->action) |
| 2471 | password_form_data->password_value = old_form_data->password_value; |
| 2472 | } |
| 2473 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2474 | |
[email protected] | 2a5b173 | 2011-04-01 23:55:55 | [diff] [blame] | 2475 | FOR_EACH_OBSERVER( |
| 2476 | RenderViewObserver, observers_, WillSubmitForm(frame, form)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2477 | } |
| 2478 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2479 | void RenderViewImpl::willPerformClientRedirect( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2480 | WebFrame* frame, const WebURL& from, const WebURL& to, double interval, |
| 2481 | double fire_time) { |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2482 | FOR_EACH_OBSERVER( |
| 2483 | RenderViewObserver, observers_, |
| 2484 | WillPerformClientRedirect(frame, from, to, interval, fire_time)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2485 | } |
| 2486 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2487 | void RenderViewImpl::didCancelClientRedirect(WebFrame* frame) { |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2488 | FOR_EACH_OBSERVER( |
| 2489 | RenderViewObserver, observers_, DidCancelClientRedirect(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2490 | } |
| 2491 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2492 | void RenderViewImpl::didCompleteClientRedirect( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2493 | WebFrame* frame, const WebURL& from) { |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2494 | if (!frame->parent()) { |
| 2495 | WebDataSource* ds = frame->provisionalDataSource(); |
| 2496 | // If there's no provisional data source, it's a reference fragment |
| 2497 | // navigation. |
| 2498 | completed_client_redirect_src_ = Referrer( |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 2499 | from, ds ? GetReferrerPolicyFromRequest(ds->request()) : |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2500 | frame->referrerPolicy()); |
| 2501 | } |
[email protected] | eb0bff94 | 2011-04-07 22:08:38 | [diff] [blame] | 2502 | FOR_EACH_OBSERVER( |
| 2503 | RenderViewObserver, observers_, DidCompleteClientRedirect(frame, from)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2504 | } |
| 2505 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2506 | void RenderViewImpl::didCreateDataSource(WebFrame* frame, WebDataSource* ds) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2507 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2508 | if (!document_state) { |
| 2509 | document_state = new DocumentState; |
| 2510 | ds->setExtraData(document_state); |
| 2511 | } |
| 2512 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2513 | // The rest of RenderView assumes that a WebDataSource will always have a |
| 2514 | // non-null NavigationState. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2515 | bool content_initiated = !pending_navigation_params_.get(); |
| 2516 | if (content_initiated) |
| 2517 | document_state->set_navigation_state( |
| 2518 | NavigationState::CreateContentInitiated()); |
| 2519 | else |
| 2520 | PopulateStateFromPendingNavigationParams(document_state); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2521 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2522 | // DocumentState::referred_by_prefetcher_ is true if we are |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2523 | // navigating from a page that used prefetching using a link on that |
| 2524 | // page. We are early enough in the request process here that we |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2525 | // can still see the DocumentState of the previous page and set |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2526 | // this value appropriately. |
| 2527 | // TODO(gavinp): catch the important case of navigation in a new |
| 2528 | // renderer process. |
| 2529 | if (webview()) { |
[email protected] | e47aec5 | 2010-08-12 00:50:30 | [diff] [blame] | 2530 | if (WebFrame* old_frame = webview()->mainFrame()) { |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2531 | const WebURLRequest& original_request = ds->originalRequest(); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2532 | const GURL referrer( |
| 2533 | original_request.httpHeaderField(WebString::fromUTF8("Referer"))); |
| 2534 | if (!referrer.is_empty() && |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2535 | DocumentState::FromDataSource( |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2536 | old_frame->dataSource())->was_prefetcher()) { |
| 2537 | for (;old_frame;old_frame = old_frame->traverseNext(false)) { |
| 2538 | WebDataSource* old_frame_ds = old_frame->dataSource(); |
| 2539 | if (old_frame_ds && referrer == GURL(old_frame_ds->request().url())) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2540 | document_state->set_was_referred_by_prefetcher(true); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2541 | break; |
| 2542 | } |
| 2543 | } |
| 2544 | } |
| 2545 | } |
| 2546 | } |
| 2547 | |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2548 | if (content_initiated) { |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2549 | const WebURLRequest& request = ds->request(); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2550 | switch (request.cachePolicy()) { |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2551 | case WebURLRequest::UseProtocolCachePolicy: // normal load. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2552 | document_state->set_load_type(DocumentState::LINK_LOAD_NORMAL); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2553 | break; |
| 2554 | case WebURLRequest::ReloadIgnoringCacheData: // reload. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2555 | document_state->set_load_type(DocumentState::LINK_LOAD_RELOAD); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2556 | break; |
| 2557 | case WebURLRequest::ReturnCacheDataElseLoad: // allow stale data. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2558 | document_state->set_load_type( |
| 2559 | DocumentState::LINK_LOAD_CACHE_STALE_OK); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2560 | break; |
| 2561 | case WebURLRequest::ReturnCacheDataDontLoad: // Don't re-post. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2562 | document_state->set_load_type(DocumentState::LINK_LOAD_CACHE_ONLY); |
[email protected] | 4c1b6f0b | 2010-02-07 16:38:18 | [diff] [blame] | 2563 | break; |
| 2564 | } |
| 2565 | } |
[email protected] | fa7b6b54 | 2009-11-03 05:02:30 | [diff] [blame] | 2566 | |
[email protected] | 946a003 | 2011-03-31 18:42:28 | [diff] [blame] | 2567 | FOR_EACH_OBSERVER( |
| 2568 | RenderViewObserver, observers_, DidCreateDataSource(frame, ds)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2569 | } |
| 2570 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2571 | void RenderViewImpl::PopulateStateFromPendingNavigationParams( |
| 2572 | DocumentState* document_state) { |
| 2573 | const ViewMsg_Navigate_Params& params = *pending_navigation_params_.get(); |
| 2574 | |
| 2575 | if (document_state->request_time().is_null()) |
| 2576 | document_state->set_request_time(params.request_time); |
| 2577 | |
| 2578 | // A navigation resulting from loading a javascript URL should not be treated |
| 2579 | // as a browser initiated event. Instead, we want it to look as if the page |
| 2580 | // initiated any load resulting from JS execution. |
| 2581 | if (!params.url.SchemeIs(chrome::kJavaScriptScheme)) { |
| 2582 | NavigationState* navigation_state = NavigationState::CreateBrowserInitiated( |
| 2583 | params.page_id, |
| 2584 | params.pending_history_list_offset, |
| 2585 | params.transition); |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 2586 | navigation_state->set_transferred_request_child_id( |
| 2587 | params.transferred_request_child_id); |
| 2588 | navigation_state->set_transferred_request_request_id( |
| 2589 | params.transferred_request_request_id); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2590 | if (params.navigation_type == ViewMsg_Navigate_Type::RESTORE) { |
| 2591 | // We're doing a load of a page that was restored from the last session. |
| 2592 | // By default this prefers the cache over loading (LOAD_PREFERRING_CACHE) |
| 2593 | // which can result in stale data for pages that are set to expire. We |
| 2594 | // explicitly override that by setting the policy here so that as |
| 2595 | // necessary we load from the network. |
| 2596 | document_state->set_cache_policy_override( |
| 2597 | WebURLRequest::UseProtocolCachePolicy); |
| 2598 | } |
| 2599 | document_state->set_navigation_state(navigation_state); |
| 2600 | } else { |
| 2601 | document_state->set_navigation_state( |
| 2602 | NavigationState::CreateContentInitiated()); |
| 2603 | } |
| 2604 | |
| 2605 | if (IsReload(params)) |
| 2606 | document_state->set_load_type(DocumentState::RELOAD); |
| 2607 | else if (!params.state.empty()) |
| 2608 | document_state->set_load_type(DocumentState::HISTORY_LOAD); |
| 2609 | else |
| 2610 | document_state->set_load_type(DocumentState::NORMAL_LOAD); |
| 2611 | |
| 2612 | pending_navigation_params_.reset(); |
| 2613 | } |
| 2614 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2615 | void RenderViewImpl::didStartProvisionalLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2616 | WebDataSource* ds = frame->provisionalDataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2617 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2618 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2619 | // Update the request time if WebKit has better knowledge of it. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2620 | if (document_state->request_time().is_null()) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2621 | double event_time = ds->triggeringEventTime(); |
| 2622 | if (event_time != 0.0) |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2623 | document_state->set_request_time(Time::FromDoubleT(event_time)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2624 | } |
| 2625 | |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2626 | // Start time is only set after request time. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2627 | document_state->set_start_load_time(Time::Now()); |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 2628 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2629 | bool is_top_most = !frame->parent(); |
| 2630 | if (is_top_most) { |
| 2631 | navigation_gesture_ = frame->isProcessingUserGesture() ? |
[email protected] | cd44809 | 2010-12-06 23:49:13 | [diff] [blame] | 2632 | NavigationGestureUser : NavigationGestureAuto; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2633 | |
| 2634 | // Make sure redirect tracking state is clear for the new load. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2635 | completed_client_redirect_src_ = Referrer(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2636 | } else if (frame->parent()->isLoading()) { |
| 2637 | // 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] | 2638 | // load an error page. See didFailProvisionalLoad. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2639 | document_state->navigation_state()->set_transition_type( |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2640 | content::PAGE_TRANSITION_AUTO_SUBFRAME); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2641 | } |
| 2642 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2643 | FOR_EACH_OBSERVER( |
| 2644 | RenderViewObserver, observers_, DidStartProvisionalLoad(frame)); |
| 2645 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2646 | Send(new ViewHostMsg_DidStartProvisionalLoadForFrame( |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 2647 | routing_id_, frame->identifier(), is_top_most, GetOpenerUrl(), |
[email protected] | eacb080b | 2011-05-22 19:40:26 | [diff] [blame] | 2648 | ds->request().url())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2649 | } |
| 2650 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2651 | void RenderViewImpl::didReceiveServerRedirectForProvisionalLoad( |
| 2652 | WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2653 | if (frame->parent()) |
| 2654 | return; |
| 2655 | // Received a redirect on the main frame. |
| 2656 | WebDataSource* data_source = frame->provisionalDataSource(); |
| 2657 | if (!data_source) { |
| 2658 | // Should only be invoked when we have a data source. |
| 2659 | NOTREACHED(); |
| 2660 | return; |
| 2661 | } |
| 2662 | std::vector<GURL> redirects; |
| 2663 | GetRedirectChain(data_source, &redirects); |
| 2664 | if (redirects.size() >= 2) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 2665 | Send(new ViewHostMsg_DidRedirectProvisionalLoad(routing_id_, page_id_, |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 2666 | GetOpenerUrl(), redirects[redirects.size() - 2], redirects.back())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2667 | } |
| 2668 | } |
| 2669 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2670 | void RenderViewImpl::didFailProvisionalLoad(WebFrame* frame, |
| 2671 | const WebURLError& error) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2672 | // Notify the browser that we failed a provisional load with an error. |
| 2673 | // |
| 2674 | // Note: It is important this notification occur before DidStopLoading so the |
| 2675 | // SSL manager can react to the provisional load failure before being |
| 2676 | // notified the load stopped. |
| 2677 | // |
| 2678 | WebDataSource* ds = frame->provisionalDataSource(); |
| 2679 | DCHECK(ds); |
| 2680 | |
| 2681 | const WebURLRequest& failed_request = ds->request(); |
| 2682 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2683 | FOR_EACH_OBSERVER( |
| 2684 | RenderViewObserver, observers_, DidFailProvisionalLoad(frame, error)); |
| 2685 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2686 | bool show_repost_interstitial = |
| 2687 | (error.reason == net::ERR_CACHE_MISS && |
| 2688 | EqualsASCII(failed_request.httpMethod(), "POST")); |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 2689 | |
| 2690 | ViewHostMsg_DidFailProvisionalLoadWithError_Params params; |
| 2691 | params.frame_id = frame->identifier(); |
| 2692 | params.is_main_frame = !frame->parent(); |
| 2693 | params.error_code = error.reason; |
| 2694 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 2695 | failed_request, |
| 2696 | error, |
| 2697 | NULL, |
| 2698 | ¶ms.error_description); |
| 2699 | params.url = error.unreachableURL; |
| 2700 | params.showing_repost_interstitial = show_repost_interstitial; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2701 | Send(new ViewHostMsg_DidFailProvisionalLoadWithError( |
[email protected] | d7b175e | 2011-10-11 15:31:58 | [diff] [blame] | 2702 | routing_id_, params)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2703 | |
| 2704 | // Don't display an error page if this is simply a cancelled load. Aside |
| 2705 | // from being dumb, WebCore doesn't expect it and it will cause a crash. |
| 2706 | if (error.reason == net::ERR_ABORTED) |
| 2707 | return; |
[email protected] | b553edd5 | 2012-01-10 12:15:23 | [diff] [blame] | 2708 | // Don't display an error message if the request was handled by an |
| 2709 | // external protocol handler. |
| 2710 | if (error.reason == net::ERR_UNKNOWN_URL_SCHEME) |
| 2711 | return; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2712 | |
| 2713 | // Make sure we never show errors in view source mode. |
| 2714 | frame->enableViewSourceMode(false); |
| 2715 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2716 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2717 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2718 | |
| 2719 | // If this is a failed back/forward/reload navigation, then we need to do a |
| 2720 | // 'replace' load. This is necessary to avoid messing up session history. |
| 2721 | // Otherwise, we do a normal load, which simulates a 'go' navigation as far |
| 2722 | // as session history is concerned. |
| 2723 | // |
| 2724 | // AUTO_SUBFRAME loads should always be treated as loads that do not advance |
| 2725 | // the page id. |
| 2726 | // |
| 2727 | bool replace = |
| 2728 | navigation_state->pending_page_id() != -1 || |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2729 | navigation_state->transition_type() == |
| 2730 | content::PAGE_TRANSITION_AUTO_SUBFRAME; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2731 | |
| 2732 | // If we failed on a browser initiated request, then make sure that our error |
| 2733 | // page load is regarded as the same browser initiated request. |
| 2734 | if (!navigation_state->is_content_initiated()) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2735 | pending_navigation_params_.reset(new ViewMsg_Navigate_Params); |
| 2736 | pending_navigation_params_->page_id = |
| 2737 | navigation_state->pending_page_id(); |
| 2738 | pending_navigation_params_->pending_history_list_offset = |
| 2739 | navigation_state->pending_history_list_offset(); |
| 2740 | pending_navigation_params_->transition = |
| 2741 | navigation_state->transition_type(); |
| 2742 | pending_navigation_params_->request_time = |
| 2743 | document_state->request_time(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2744 | } |
| 2745 | |
| 2746 | // Provide the user with a more helpful error page? |
| 2747 | if (MaybeLoadAlternateErrorPage(frame, error, replace)) |
| 2748 | return; |
| 2749 | |
| 2750 | // Fallback to a local error page. |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 2751 | LoadNavigationErrorPage(frame, failed_request, error, std::string(), replace); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2752 | } |
| 2753 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2754 | void RenderViewImpl::didReceiveDocumentData( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2755 | WebFrame* frame, const char* data, size_t data_len, |
| 2756 | bool& prevent_default) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2757 | DocumentState* document_state = |
| 2758 | DocumentState::FromDataSource(frame->dataSource()); |
| 2759 | document_state->set_use_error_page(false); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2760 | } |
| 2761 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2762 | void RenderViewImpl::didCommitProvisionalLoad(WebFrame* frame, |
| 2763 | bool is_new_navigation) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2764 | DocumentState* document_state = |
| 2765 | DocumentState::FromDataSource(frame->dataSource()); |
| 2766 | NavigationState* navigation_state = document_state->navigation_state(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2767 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2768 | if (document_state->commit_load_time().is_null()) |
| 2769 | document_state->set_commit_load_time(Time::Now()); |
| 2770 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2771 | if (is_new_navigation) { |
[email protected] | e15f68073 | 2010-11-23 22:30:20 | [diff] [blame] | 2772 | // When we perform a new navigation, we need to update the last committed |
| 2773 | // session history entry with state for the page we are leaving. |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2774 | UpdateSessionHistory(frame); |
| 2775 | |
| 2776 | // We bump our Page ID to correspond with the new session history entry. |
| 2777 | page_id_ = next_page_id_++; |
| 2778 | |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 2779 | // Don't update history_page_ids_ (etc) for about:swappedout, since we |
| 2780 | // don't want to forget the entry that was there, and since we will |
| 2781 | // never come back to about:swappedout. Note that we have to call |
| 2782 | // UpdateSessionHistory and update page_id_ even in this case, so that |
| 2783 | // the current entry gets a state update and so that we don't send a |
| 2784 | // state update to the wrong entry when we swap back in. |
| 2785 | if (GetLoadingUrl(frame) != GURL("about:swappedout")) { |
| 2786 | // Advance our offset in session history, applying the length limit. |
| 2787 | // There is now no forward history. |
| 2788 | history_list_offset_++; |
| 2789 | if (history_list_offset_ >= content::kMaxSessionHistoryEntries) |
| 2790 | history_list_offset_ = content::kMaxSessionHistoryEntries - 1; |
| 2791 | history_list_length_ = history_list_offset_ + 1; |
| 2792 | history_page_ids_.resize(history_list_length_, -1); |
| 2793 | history_page_ids_[history_list_offset_] = page_id_; |
| 2794 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2795 | } else { |
| 2796 | // Inspect the navigation_state on this frame to see if the navigation |
| 2797 | // corresponds to a session history navigation... Note: |frame| may or |
| 2798 | // may not be the toplevel frame, but for the case of capturing session |
| 2799 | // history, the first committed frame suffices. We keep track of whether |
| 2800 | // we've seen this commit before so that only capture session history once |
| 2801 | // per navigation. |
| 2802 | // |
| 2803 | // Note that we need to check if the page ID changed. In the case of a |
| 2804 | // reload, the page ID doesn't change, and UpdateSessionHistory gets the |
| 2805 | // previous URL and the current page ID, which would be wrong. |
| 2806 | if (navigation_state->pending_page_id() != -1 && |
| 2807 | navigation_state->pending_page_id() != page_id_ && |
| 2808 | !navigation_state->request_committed()) { |
| 2809 | // This is a successful session history navigation! |
| 2810 | UpdateSessionHistory(frame); |
| 2811 | page_id_ = navigation_state->pending_page_id(); |
[email protected] | 3cc72b1 | 2010-03-18 23:03:00 | [diff] [blame] | 2812 | |
| 2813 | history_list_offset_ = navigation_state->pending_history_list_offset(); |
[email protected] | d466b8a | 2011-07-15 21:48:03 | [diff] [blame] | 2814 | |
| 2815 | // If the history list is valid, our list of page IDs should be correct. |
| 2816 | DCHECK(history_list_length_ <= 0 || |
| 2817 | history_list_offset_ < 0 || |
| 2818 | history_list_offset_ >= history_list_length_ || |
| 2819 | history_page_ids_[history_list_offset_] == page_id_); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2820 | } |
| 2821 | } |
| 2822 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2823 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2824 | DidCommitProvisionalLoad(frame, is_new_navigation)); |
| 2825 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2826 | // Remember that we've already processed this request, so we don't update |
| 2827 | // the session history again. We do this regardless of whether this is |
| 2828 | // a session history navigation, because if we attempted a session history |
| 2829 | // navigation without valid HistoryItem state, WebCore will think it is a |
| 2830 | // new navigation. |
| 2831 | navigation_state->set_request_committed(true); |
| 2832 | |
| 2833 | UpdateURL(frame); |
| 2834 | |
| 2835 | // If this committed load was initiated by a client redirect, we're |
| 2836 | // at the last stop now, so clear it. |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 2837 | completed_client_redirect_src_ = Referrer(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2838 | |
| 2839 | // Check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2840 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2841 | } |
| 2842 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2843 | void RenderViewImpl::didClearWindowObject(WebFrame* frame) { |
[email protected] | 9966325b | 2011-04-18 05:00:10 | [diff] [blame] | 2844 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2845 | DidClearWindowObject(frame)); |
| 2846 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2847 | GURL frame_url = frame->document().url(); |
[email protected] | e091df8 | 2011-10-11 18:13:21 | [diff] [blame] | 2848 | if ((enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) && |
[email protected] | bfa83eb8 | 2010-10-06 08:41:25 | [diff] [blame] | 2849 | (frame_url.SchemeIs(chrome::kChromeUIScheme) || |
| 2850 | frame_url.SchemeIs(chrome::kDataScheme))) { |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 2851 | GetWebUIBindings()->BindToJavascript(frame, "chrome"); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2852 | } |
[email protected] | 766a708 | 2012-02-03 23:39:15 | [diff] [blame] | 2853 | |
| 2854 | if (enabled_bindings_ & content::BINDINGS_POLICY_DOM_AUTOMATION) { |
| 2855 | if (!dom_automation_controller_.get()) |
| 2856 | dom_automation_controller_.reset(new DomAutomationController()); |
| 2857 | dom_automation_controller_->set_message_sender( |
| 2858 | static_cast<content::RenderView*>(this)); |
| 2859 | dom_automation_controller_->set_routing_id(routing_id()); |
| 2860 | dom_automation_controller_->BindToJavascript(frame, |
| 2861 | "domAutomationController"); |
| 2862 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2863 | } |
| 2864 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2865 | void RenderViewImpl::didCreateDocumentElement(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2866 | // Notify the browser about non-blank documents loading in the top frame. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 2867 | GURL url = frame->document().url(); |
[email protected] | e0d48158 | 2009-09-15 21:06:25 | [diff] [blame] | 2868 | if (url.is_valid() && url.spec() != chrome::kAboutBlankURL) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2869 | if (frame == webview()->mainFrame()) |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2870 | Send(new ViewHostMsg_DocumentAvailableInMainFrame(routing_id_)); |
| 2871 | } |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2872 | |
| 2873 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2874 | DidCreateDocumentElement(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2875 | } |
| 2876 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2877 | void RenderViewImpl::didReceiveTitle(WebFrame* frame, const WebString& title, |
| 2878 | WebTextDirection direction) { |
[email protected] | a49e10b | 2011-08-01 23:57:46 | [diff] [blame] | 2879 | UpdateTitle(frame, title, direction); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2880 | |
| 2881 | // Also check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2882 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2883 | } |
| 2884 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2885 | void RenderViewImpl::didChangeIcon(WebFrame* frame, WebIconURL::Type type) { |
[email protected] | 42054a25 | 2011-05-17 18:02:13 | [diff] [blame] | 2886 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2887 | DidChangeIcon(frame, type)); |
[email protected] | 5019ef1 | 2010-04-27 17:26:58 | [diff] [blame] | 2888 | } |
| 2889 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2890 | void RenderViewImpl::didFinishDocumentLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2891 | WebDataSource* ds = frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2892 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2893 | document_state->set_finish_document_load_time(Time::Now()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2894 | |
[email protected] | 622474d | 2010-11-04 09:21:08 | [diff] [blame] | 2895 | Send(new ViewHostMsg_DocumentLoadedInFrame(routing_id_, frame->identifier())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2896 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2897 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 2898 | DidFinishDocumentLoad(frame)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2899 | |
| 2900 | // Check whether we have new encoding name. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 2901 | UpdateEncoding(frame, frame->view()->pageEncoding().utf8()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2902 | } |
| 2903 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2904 | void RenderViewImpl::didHandleOnloadEvents(WebFrame* frame) { |
[email protected] | 2549749 | 2010-09-11 15:15:08 | [diff] [blame] | 2905 | if (webview()->mainFrame() == frame) { |
| 2906 | Send(new ViewHostMsg_DocumentOnLoadCompletedInMainFrame(routing_id_, |
| 2907 | page_id_)); |
| 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::didFailLoad(WebFrame* frame, const WebURLError& error) { |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 2912 | WebDataSource* ds = frame->dataSource(); |
| 2913 | DCHECK(ds); |
| 2914 | |
| 2915 | |
[email protected] | 28685da9 | 2011-02-07 21:49:17 | [diff] [blame] | 2916 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFailLoad(frame, error)); |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 2917 | |
| 2918 | const WebURLRequest& failed_request = ds->request(); |
| 2919 | string16 error_description; |
| 2920 | content::GetContentClient()->renderer()->GetNavigationErrorStrings( |
| 2921 | failed_request, |
| 2922 | error, |
| 2923 | NULL, |
| 2924 | &error_description); |
| 2925 | Send(new ViewHostMsg_DidFailLoadWithError(routing_id_, |
| 2926 | frame->identifier(), |
| 2927 | failed_request.url(), |
| 2928 | !frame->parent(), |
| 2929 | error.reason, |
| 2930 | error_description)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2931 | } |
| 2932 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2933 | void RenderViewImpl::didFinishLoad(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2934 | WebDataSource* ds = frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2935 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
| 2936 | if (document_state->finish_load_time().is_null()) |
| 2937 | document_state->set_finish_load_time(Time::Now()); |
[email protected] | 4d44a1c | 2010-04-28 19:20:41 | [diff] [blame] | 2938 | |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 2939 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidFinishLoad(frame)); |
[email protected] | fdd94a0 | 2010-11-05 08:07:17 | [diff] [blame] | 2940 | |
[email protected] | 1a55c5be | 2011-11-29 11:36:31 | [diff] [blame] | 2941 | Send(new ViewHostMsg_DidFinishLoad(routing_id_, |
| 2942 | frame->identifier(), |
| 2943 | ds->request().url(), |
| 2944 | !frame->parent())); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2945 | } |
| 2946 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2947 | void RenderViewImpl::didNavigateWithinPage( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2948 | WebFrame* frame, bool is_new_navigation) { |
| 2949 | // If this was a reference fragment navigation that we initiated, then we |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2950 | // 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] | 2951 | // update the ExtraData on the datasource so that others who read the |
| 2952 | // ExtraData will get the new NavigationState. Similarly, if we did not |
| 2953 | // initiate this navigation, then we need to take care to reset any pre- |
| 2954 | // existing navigation state to a content-initiated navigation state. |
| 2955 | // DidCreateDataSource conveniently takes care of this for us. |
| 2956 | didCreateDataSource(frame, frame->dataSource()); |
| 2957 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2958 | DocumentState* document_state = |
| 2959 | DocumentState::FromDataSource(frame->dataSource()); |
| 2960 | NavigationState* new_state = document_state->navigation_state(); |
[email protected] | af15bed | 2010-08-25 21:12:09 | [diff] [blame] | 2961 | new_state->set_was_within_same_page(true); |
| 2962 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2963 | didCommitProvisionalLoad(frame, is_new_navigation); |
| 2964 | |
[email protected] | 750fcf87 | 2011-08-03 23:10:47 | [diff] [blame] | 2965 | WebDataSource* datasource = frame->view()->mainFrame()->dataSource(); |
| 2966 | UpdateTitle(frame, datasource->pageTitle(), datasource->pageTitleDirection()); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2967 | } |
| 2968 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2969 | void RenderViewImpl::didUpdateCurrentHistoryItem(WebFrame* frame) { |
[email protected] | 882daa9 | 2009-11-05 16:31:31 | [diff] [blame] | 2970 | StartNavStateSyncTimerIfNecessary(); |
[email protected] | 476b6f8 | 2009-09-10 21:00:59 | [diff] [blame] | 2971 | } |
| 2972 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2973 | void RenderViewImpl::assignIdentifierToRequest( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 2974 | WebFrame* frame, unsigned identifier, const WebURLRequest& request) { |
| 2975 | // Ignore |
| 2976 | } |
| 2977 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 2978 | void RenderViewImpl::willSendRequest(WebFrame* frame, |
| 2979 | unsigned identifier, |
| 2980 | WebURLRequest& request, |
| 2981 | const WebURLResponse& redirect_response) { |
[email protected] | 5e36967 | 2009-11-03 23:48:30 | [diff] [blame] | 2982 | WebFrame* top_frame = frame->top(); |
| 2983 | if (!top_frame) |
| 2984 | top_frame = frame; |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 2985 | WebDataSource* provisional_data_source = top_frame->provisionalDataSource(); |
| 2986 | WebDataSource* top_data_source = top_frame->dataSource(); |
| 2987 | WebDataSource* data_source = |
| 2988 | provisional_data_source ? provisional_data_source : top_data_source; |
[email protected] | 78d5cfe | 2011-02-04 08:43:22 | [diff] [blame] | 2989 | |
[email protected] | 78d5cfe | 2011-02-04 08:43:22 | [diff] [blame] | 2990 | GURL request_url(request.url()); |
[email protected] | e48869a | 2011-04-01 19:56:03 | [diff] [blame] | 2991 | GURL new_url; |
| 2992 | if (content::GetContentClient()->renderer()->WillSendRequest( |
| 2993 | frame, request_url, &new_url)) { |
| 2994 | request.setURL(WebURL(new_url)); |
[email protected] | 78d5cfe | 2011-02-04 08:43:22 | [diff] [blame] | 2995 | } |
| 2996 | |
[email protected] | 2905f74 | 2011-10-13 03:51:58 | [diff] [blame] | 2997 | content::PageTransition transition_type = content::PAGE_TRANSITION_LINK; |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 2998 | DocumentState* document_state = DocumentState::FromDataSource(data_source); |
| 2999 | NavigationState* navigation_state = document_state->navigation_state(); |
| 3000 | if (document_state) { |
| 3001 | if (document_state->is_cache_policy_override_set()) |
| 3002 | request.setCachePolicy(document_state->cache_policy_override()); |
| 3003 | transition_type = navigation_state->transition_type(); |
[email protected] | 5e36967 | 2009-11-03 23:48:30 | [diff] [blame] | 3004 | } |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 3005 | |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 3006 | request.setExtraData( |
[email protected] | 537fbe0 | 2011-11-24 00:58:06 | [diff] [blame] | 3007 | new RequestExtraData(frame->referrerPolicy(), |
| 3008 | (frame == top_frame), |
[email protected] | 91043a823 | 2011-11-04 16:41:19 | [diff] [blame] | 3009 | frame->identifier(), |
| 3010 | frame->parent() == top_frame, |
| 3011 | frame->parent() ? frame->parent()->identifier() : -1, |
[email protected] | 4ad5d77d | 2011-12-03 02:00:48 | [diff] [blame] | 3012 | transition_type, |
| 3013 | navigation_state->transferred_request_child_id(), |
| 3014 | navigation_state->transferred_request_request_id())); |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 3015 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3016 | DocumentState* top_document_state = |
| 3017 | DocumentState::FromDataSource(top_data_source); |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 3018 | // TODO(gavinp): separate out prefetching and prerender field trials |
| 3019 | // if the rel=prerender rel type is sticking around. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3020 | if (top_document_state && |
[email protected] | d88bf0a | 2011-08-30 23:55:57 | [diff] [blame] | 3021 | (request.targetType() == WebURLRequest::TargetIsPrefetch || |
| 3022 | request.targetType() == WebURLRequest::TargetIsPrerender)) |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3023 | top_document_state->set_was_prefetcher(true); |
[email protected] | 8a3125a71 | 2010-08-09 18:58:51 | [diff] [blame] | 3024 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3025 | request.setRequestorID(routing_id_); |
[email protected] | cd44809 | 2010-12-06 23:49:13 | [diff] [blame] | 3026 | request.setHasUserGesture(frame->isProcessingUserGesture()); |
| 3027 | |
[email protected] | 0a8db0d | 2011-04-13 15:15:40 | [diff] [blame] | 3028 | if (!renderer_preferences_.enable_referrers) |
[email protected] | 7deade4 | 2010-03-05 09:33:13 | [diff] [blame] | 3029 | request.clearHTTPHeaderField("Referer"); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3030 | } |
| 3031 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3032 | void RenderViewImpl::didReceiveResponse( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3033 | WebFrame* frame, unsigned identifier, const WebURLResponse& response) { |
[email protected] | fa0a343 | 2010-03-30 16:53:49 | [diff] [blame] | 3034 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3035 | // Only do this for responses that correspond to a provisional data source |
| 3036 | // of the top-most frame. If we have a provisional data source, then we |
| 3037 | // can't have any sub-resources yet, so we know that this response must |
| 3038 | // correspond to a frame load. |
| 3039 | if (!frame->provisionalDataSource() || frame->parent()) |
| 3040 | return; |
| 3041 | |
| 3042 | // 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] | 3043 | // the server's error page. |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3044 | if (frame->isViewSourceModeEnabled()) |
| 3045 | return; |
| 3046 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3047 | DocumentState* document_state = |
| 3048 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 3049 | int http_status_code = response.httpStatusCode(); |
[email protected] | 65041fa | 2010-05-21 06:56:53 | [diff] [blame] | 3050 | |
[email protected] | 972ebdff | 2010-06-10 22:59:07 | [diff] [blame] | 3051 | // Record page load flags. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3052 | document_state->set_was_fetched_via_spdy(response.wasFetchedViaSPDY()); |
| 3053 | document_state->set_was_npn_negotiated(response.wasNpnNegotiated()); |
[email protected] | b9fd01ba | 2012-02-28 01:50:40 | [diff] [blame] | 3054 | WebURLResponseExtraDataImpl* extra_data = GetExtraDataFromResponse(response); |
| 3055 | if (extra_data) { |
| 3056 | document_state->set_npn_negotiated_protocol( |
| 3057 | extra_data->npn_negotiated_protocol()); |
| 3058 | } |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3059 | document_state->set_was_alternate_protocol_available( |
[email protected] | 193b0b89 | 2010-06-26 03:57:57 | [diff] [blame] | 3060 | response.wasAlternateProtocolAvailable()); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3061 | document_state->set_was_fetched_via_proxy(response.wasFetchedViaProxy()); |
| 3062 | document_state->set_http_status_code(http_status_code); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3063 | // Whether or not the http status code actually corresponds to an error is |
| 3064 | // only checked when the page is done loading, if |use_error_page| is |
| 3065 | // still true. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3066 | document_state->set_use_error_page(true); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3067 | } |
| 3068 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3069 | void RenderViewImpl::didFinishResourceLoad( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3070 | WebFrame* frame, unsigned identifier) { |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3071 | DocumentState* document_state = |
| 3072 | DocumentState::FromDataSource(frame->dataSource()); |
| 3073 | if (!document_state->use_error_page()) |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3074 | return; |
| 3075 | |
[email protected] | 7bfc153f | 2011-09-23 22:00:20 | [diff] [blame] | 3076 | // Do not show error page when DevTools is attached. |
| 3077 | if (devtools_agent_->IsAttached()) |
| 3078 | return; |
| 3079 | |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3080 | // Display error page, if appropriate. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3081 | int http_status_code = document_state->http_status_code(); |
[email protected] | 3f853a5 | 2010-09-13 19:15:08 | [diff] [blame] | 3082 | if (http_status_code == 404) { |
| 3083 | // On 404s, try a remote search page as a fallback. |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3084 | const GURL& document_url = frame->document().url(); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3085 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3086 | const GURL& error_page_url = |
| 3087 | GetAlternateErrorPageURL(document_url, HTTP_404); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3088 | if (error_page_url.is_valid()) { |
| 3089 | WebURLError original_error; |
[email protected] | 2e9706c | 2011-06-09 16:49:47 | [diff] [blame] | 3090 | original_error.domain = "http"; |
| 3091 | original_error.reason = 404; |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3092 | original_error.unreachableURL = document_url; |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3093 | |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 3094 | document_state->set_alt_error_page_fetcher( |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3095 | new AltErrorPageResourceFetcher( |
| 3096 | error_page_url, frame, original_error, |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 3097 | base::Bind(&RenderViewImpl::AltErrorPageFinished, |
| 3098 | base::Unretained(this)))); |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 3099 | return; |
| 3100 | } |
| 3101 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3102 | |
[email protected] | e6a2ce5 | 2011-10-08 01:40:13 | [diff] [blame] | 3103 | std::string error_domain; |
| 3104 | if (content::GetContentClient()->renderer()->HasErrorPage( |
| 3105 | http_status_code, &error_domain)) { |
| 3106 | WebURLError error; |
| 3107 | error.unreachableURL = frame->document().url(); |
| 3108 | error.domain = WebString::fromUTF8(error_domain); |
| 3109 | error.reason = http_status_code; |
| 3110 | |
| 3111 | LoadNavigationErrorPage( |
| 3112 | frame, frame->dataSource()->request(), error, std::string(), true); |
| 3113 | } |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3114 | } |
| 3115 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3116 | void RenderViewImpl::didFailResourceLoad( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3117 | WebFrame* frame, unsigned identifier, const WebURLError& error) { |
| 3118 | // Ignore |
| 3119 | } |
| 3120 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3121 | void RenderViewImpl::didLoadResourceFromMemoryCache( |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3122 | WebFrame* frame, const WebURLRequest& request, |
| 3123 | const WebURLResponse& response) { |
[email protected] | 8470329 | 2011-10-28 20:44:00 | [diff] [blame] | 3124 | // The recipients of this message have no use for data: URLs: they don't |
| 3125 | // affect the page's insecure content list and are not in the disk cache. To |
| 3126 | // prevent large (1M+) data: URLs from crashing in the IPC system, we simply |
| 3127 | // filter them out here. |
| 3128 | GURL url(request.url()); |
| 3129 | if (url.SchemeIs("data")) |
| 3130 | return; |
| 3131 | |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3132 | // Let the browser know we loaded a resource from the memory cache. This |
| 3133 | // message is needed to display the correct SSL indicators. |
| 3134 | Send(new ViewHostMsg_DidLoadResourceFromMemoryCache( |
| 3135 | routing_id_, |
[email protected] | 8470329 | 2011-10-28 20:44:00 | [diff] [blame] | 3136 | url, |
[email protected] | 7043596 | 2011-08-02 20:13:28 | [diff] [blame] | 3137 | response.securityInfo(), |
| 3138 | request.httpMethod().utf8(), |
| 3139 | ResourceType::FromTargetType(request.targetType()))); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3140 | } |
| 3141 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3142 | void RenderViewImpl::didDisplayInsecureContent(WebFrame* frame) { |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 3143 | Send(new ViewHostMsg_DidDisplayInsecureContent(routing_id_)); |
| 3144 | } |
| 3145 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3146 | void RenderViewImpl::didRunInsecureContent( |
[email protected] | 9277111 | 2011-01-20 00:13:02 | [diff] [blame] | 3147 | WebFrame* frame, const WebSecurityOrigin& origin, const WebURL& target) { |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 3148 | Send(new ViewHostMsg_DidRunInsecureContent( |
| 3149 | routing_id_, |
[email protected] | 9277111 | 2011-01-20 00:13:02 | [diff] [blame] | 3150 | origin.toString().utf8(), |
| 3151 | target)); |
[email protected] | e3d60e5d | 2009-09-25 21:08:29 | [diff] [blame] | 3152 | } |
| 3153 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3154 | void RenderViewImpl::didAdoptURLLoader(WebKit::WebURLLoader* loader) { |
[email protected] | b00ba70 | 2011-08-17 01:41:03 | [diff] [blame] | 3155 | webkit_glue::WebURLLoaderImpl* loader_impl = |
| 3156 | static_cast<webkit_glue::WebURLLoaderImpl*>(loader); |
| 3157 | loader_impl->UpdateRoutingId(routing_id_); |
| 3158 | } |
| 3159 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3160 | void RenderViewImpl::didExhaustMemoryAvailableForScript(WebFrame* frame) { |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3161 | Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); |
| 3162 | } |
| 3163 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3164 | void RenderViewImpl::didCreateScriptContext(WebFrame* frame, |
| 3165 | v8::Handle<v8::Context> context, |
[email protected] | a00fe69 | 2012-02-27 05:52:58 | [diff] [blame] | 3166 | int extension_group, |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3167 | int world_id) { |
[email protected] | 5bc1093 | 2011-09-21 21:03:30 | [diff] [blame] | 3168 | content::GetContentClient()->renderer()->DidCreateScriptContext( |
[email protected] | a00fe69 | 2012-02-27 05:52:58 | [diff] [blame] | 3169 | frame, context, extension_group, world_id); |
| 3170 | } |
| 3171 | |
| 3172 | void RenderViewImpl::didCreateScriptContext(WebFrame* frame, |
| 3173 | v8::Handle<v8::Context> context, |
| 3174 | int world_id) { |
| 3175 | content::GetContentClient()->renderer()->DidCreateScriptContext( |
| 3176 | frame, context, -1, world_id); |
[email protected] | 0c882b28 | 2009-10-07 17:01:28 | [diff] [blame] | 3177 | } |
| 3178 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3179 | void RenderViewImpl::willReleaseScriptContext(WebFrame* frame, |
| 3180 | v8::Handle<v8::Context> context, |
| 3181 | int world_id) { |
[email protected] | 5bc1093 | 2011-09-21 21:03:30 | [diff] [blame] | 3182 | content::GetContentClient()->renderer()->WillReleaseScriptContext( |
| 3183 | frame, context, world_id); |
[email protected] | 0c882b28 | 2009-10-07 17:01:28 | [diff] [blame] | 3184 | } |
| 3185 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3186 | void RenderViewImpl::CheckPreferredSize() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 3187 | // We don't always want to send the change messages over IPC, only if we've |
| 3188 | // been put in that mode by getting a |ViewMsg_EnablePreferredSizeChangedMode| |
| 3189 | // message. |
| 3190 | if (!send_preferred_size_changes_ || !webview()) |
| 3191 | return; |
| 3192 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 3193 | gfx::Size size(webview()->mainFrame()->contentsPreferredWidth(), |
| 3194 | webview()->mainFrame()->documentElementScrollHeight()); |
[email protected] | 8205d74 | 2010-10-22 23:51:53 | [diff] [blame] | 3195 | |
| 3196 | // In the presence of zoom, these sizes are still reported as if unzoomed, |
| 3197 | // so we need to adjust. |
| 3198 | double zoom_factor = WebView::zoomLevelToZoomFactor(webview()->zoomLevel()); |
| 3199 | size.set_width(static_cast<int>(size.width() * zoom_factor)); |
| 3200 | size.set_height(static_cast<int>(size.height() * zoom_factor)); |
| 3201 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 3202 | if (size == preferred_size_) |
| 3203 | return; |
[email protected] | c27324b | 2009-11-19 22:44:29 | [diff] [blame] | 3204 | |
[email protected] | 705243f | 2010-05-05 19:58:07 | [diff] [blame] | 3205 | preferred_size_ = size; |
| 3206 | Send(new ViewHostMsg_DidContentsPreferredSizeChange(routing_id_, |
| 3207 | preferred_size_)); |
[email protected] | 3d968937 | 2009-09-10 04:29:17 | [diff] [blame] | 3208 | } |
| 3209 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3210 | void RenderViewImpl::EnsureMediaStreamImpl() { |
| 3211 | #if defined(ENABLE_P2P_APIS) |
| 3212 | if (!p2p_socket_dispatcher_) |
| 3213 | p2p_socket_dispatcher_ = new content::P2PSocketDispatcher(this); |
| 3214 | #endif |
| 3215 | |
[email protected] | 5b87e78 | 2012-02-09 18:19:32 | [diff] [blame] | 3216 | #if defined(ENABLE_WEBRTC) |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3217 | if (!media_stream_dispatcher_) |
| 3218 | media_stream_dispatcher_ = new MediaStreamDispatcher(this); |
| 3219 | |
| 3220 | if (!media_stream_impl_.get()) { |
| 3221 | MediaStreamDependencyFactory* factory = new MediaStreamDependencyFactory(); |
| 3222 | media_stream_impl_ = new MediaStreamImpl( |
| 3223 | media_stream_dispatcher_, |
| 3224 | p2p_socket_dispatcher_, |
| 3225 | RenderThreadImpl::current()->video_capture_impl_manager(), |
| 3226 | factory); |
| 3227 | } |
[email protected] | 5b87e78 | 2012-02-09 18:19:32 | [diff] [blame] | 3228 | #endif |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 3229 | } |
| 3230 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3231 | void RenderViewImpl::didChangeContentsSize(WebFrame* frame, |
| 3232 | const WebSize& size) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3233 | if (webview()->mainFrame() != frame) |
| 3234 | return; |
| 3235 | WebView* frameView = frame->view(); |
| 3236 | if (!frameView) |
| 3237 | return; |
| 3238 | |
| 3239 | bool has_horizontal_scrollbar = frame->hasHorizontalScrollbar(); |
| 3240 | bool has_vertical_scrollbar = frame->hasVerticalScrollbar(); |
| 3241 | |
| 3242 | if (has_horizontal_scrollbar != cached_has_main_frame_horizontal_scrollbar_ || |
| 3243 | has_vertical_scrollbar != cached_has_main_frame_vertical_scrollbar_) { |
| 3244 | Send(new ViewHostMsg_DidChangeScrollbarsForMainFrame( |
| 3245 | routing_id_, has_horizontal_scrollbar, has_vertical_scrollbar)); |
| 3246 | |
| 3247 | cached_has_main_frame_horizontal_scrollbar_ = has_horizontal_scrollbar; |
| 3248 | cached_has_main_frame_vertical_scrollbar_ = has_vertical_scrollbar; |
| 3249 | } |
| 3250 | } |
| 3251 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3252 | void RenderViewImpl::UpdateScrollState(WebFrame* frame) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3253 | WebSize offset = frame->scrollOffset(); |
| 3254 | WebSize minimum_offset = frame->minimumScrollOffset(); |
| 3255 | WebSize maximum_offset = frame->maximumScrollOffset(); |
| 3256 | |
| 3257 | bool is_pinned_to_left = offset.width <= minimum_offset.width; |
| 3258 | bool is_pinned_to_right = offset.width >= maximum_offset.width; |
| 3259 | |
| 3260 | if (is_pinned_to_left != cached_is_main_frame_pinned_to_left_ || |
| 3261 | is_pinned_to_right != cached_is_main_frame_pinned_to_right_) { |
| 3262 | Send(new ViewHostMsg_DidChangeScrollOffsetPinningForMainFrame( |
| 3263 | routing_id_, is_pinned_to_left, is_pinned_to_right)); |
| 3264 | |
| 3265 | cached_is_main_frame_pinned_to_left_ = is_pinned_to_left; |
| 3266 | cached_is_main_frame_pinned_to_right_ = is_pinned_to_right; |
| 3267 | } |
| 3268 | } |
| 3269 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3270 | void RenderViewImpl::didChangeScrollOffset(WebFrame* frame) { |
[email protected] | 143dcd59 | 2009-11-06 21:33:49 | [diff] [blame] | 3271 | StartNavStateSyncTimerIfNecessary(); |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3272 | |
| 3273 | if (webview()->mainFrame() == frame) |
| 3274 | UpdateScrollState(frame); |
| 3275 | } |
| 3276 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3277 | void RenderViewImpl::numberOfWheelEventHandlersChanged(unsigned num_handlers) { |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 3278 | Send(new ViewHostMsg_DidChangeNumWheelEvents(routing_id_, num_handlers)); |
[email protected] | 143dcd59 | 2009-11-06 21:33:49 | [diff] [blame] | 3279 | } |
| 3280 | |
[email protected] | ea93125 | 2012-02-15 22:01:03 | [diff] [blame] | 3281 | void RenderViewImpl::numberOfTouchEventHandlersChanged(unsigned num_handlers) { |
| 3282 | Send(new ViewHostMsg_DidChangeNumTouchEvents(routing_id_, num_handlers)); |
| 3283 | } |
| 3284 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3285 | void RenderViewImpl::reportFindInPageMatchCount(int request_id, int count, |
| 3286 | bool final_update) { |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 3287 | int active_match_ordinal = -1; // -1 = don't update active match ordinal |
| 3288 | if (!count) |
| 3289 | active_match_ordinal = 0; |
| 3290 | |
| 3291 | IPC::Message* msg = new ViewHostMsg_Find_Reply( |
| 3292 | routing_id_, |
| 3293 | request_id, |
| 3294 | count, |
| 3295 | gfx::Rect(), |
| 3296 | active_match_ordinal, |
| 3297 | final_update); |
| 3298 | |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3299 | // If we have a message that has been queued up, then we should just replace |
| 3300 | // it. The ACK from the browser will make sure it gets sent when the browser |
| 3301 | // wants it. |
| 3302 | if (queued_find_reply_message_.get()) { |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3303 | queued_find_reply_message_.reset(msg); |
| 3304 | } else { |
| 3305 | // Send the search result over to the browser process. |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 3306 | Send(msg); |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3307 | } |
| 3308 | } |
| 3309 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3310 | void RenderViewImpl::reportFindInPageSelection(int request_id, |
| 3311 | int active_match_ordinal, |
| 3312 | const WebRect& selection_rect) { |
[email protected] | 8922e1f | 2009-10-03 05:01:26 | [diff] [blame] | 3313 | // Send the search result over to the browser process. |
| 3314 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 3315 | request_id, |
| 3316 | -1, |
| 3317 | selection_rect, |
| 3318 | active_match_ordinal, |
| 3319 | false)); |
| 3320 | } |
| 3321 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3322 | void RenderViewImpl::openFileSystem( |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3323 | WebFrame* frame, |
| 3324 | WebFileSystem::Type type, |
| 3325 | long long size, |
[email protected] | d275d7a | 2010-11-03 01:34:49 | [diff] [blame] | 3326 | bool create, |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3327 | WebFileSystemCallbacks* callbacks) { |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3328 | DCHECK(callbacks); |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3329 | |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3330 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3331 | if (origin.isUnique()) { |
| 3332 | // Unique origins cannot store persistent state. |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3333 | callbacks->didFail(WebKit::WebFileErrorAbort); |
| 3334 | return; |
| 3335 | } |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3336 | |
[email protected] | c5a272d | 2010-09-27 18:37:08 | [diff] [blame] | 3337 | ChildThread::current()->file_system_dispatcher()->OpenFileSystem( |
| 3338 | GURL(origin.toString()), static_cast<fileapi::FileSystemType>(type), |
[email protected] | d275d7a | 2010-11-03 01:34:49 | [diff] [blame] | 3339 | size, create, new WebFileSystemCallbackDispatcher(callbacks)); |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 3340 | } |
| 3341 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3342 | void RenderViewImpl::queryStorageUsageAndQuota( |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3343 | WebFrame* frame, |
| 3344 | WebStorageQuotaType type, |
| 3345 | WebStorageQuotaCallbacks* callbacks) { |
| 3346 | DCHECK(frame); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3347 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3348 | if (origin.isUnique()) { |
| 3349 | // Unique origins cannot store persistent state. |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3350 | callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); |
| 3351 | return; |
| 3352 | } |
| 3353 | ChildThread::current()->quota_dispatcher()->QueryStorageUsageAndQuota( |
[email protected] | 666bcc5c | 2011-07-29 06:25:53 | [diff] [blame] | 3354 | GURL(origin.toString()), |
| 3355 | static_cast<quota::StorageType>(type), |
| 3356 | QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3357 | } |
| 3358 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3359 | void RenderViewImpl::requestStorageQuota( |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3360 | WebFrame* frame, |
| 3361 | WebStorageQuotaType type, |
| 3362 | unsigned long long requested_size, |
| 3363 | WebStorageQuotaCallbacks* callbacks) { |
| 3364 | DCHECK(frame); |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 3365 | WebSecurityOrigin origin = frame->document().securityOrigin(); |
[email protected] | 753ab8c8 | 2011-11-21 20:25:56 | [diff] [blame] | 3366 | if (origin.isUnique()) { |
| 3367 | // Unique origins cannot store persistent state. |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3368 | callbacks->didFail(WebKit::WebStorageQuotaErrorAbort); |
| 3369 | return; |
| 3370 | } |
| 3371 | ChildThread::current()->quota_dispatcher()->RequestStorageQuota( |
[email protected] | 666bcc5c | 2011-07-29 06:25:53 | [diff] [blame] | 3372 | routing_id(), GURL(origin.toString()), |
| 3373 | static_cast<quota::StorageType>(type), requested_size, |
| 3374 | QuotaDispatcher::CreateWebStorageQuotaCallbacksWrapper(callbacks)); |
[email protected] | 10e5cf1 | 2011-04-13 04:10:40 | [diff] [blame] | 3375 | } |
| 3376 | |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3377 | void RenderViewImpl::registerIntentService( |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 3378 | WebFrame* frame, const WebIntentServiceInfo& service) { |
[email protected] | e6e35cd | 2011-12-22 19:37:06 | [diff] [blame] | 3379 | string16 title = service.title(); |
| 3380 | if (title.empty()) |
| 3381 | title = webview()->mainFrame()->document().title(); |
| 3382 | |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3383 | Send(new IntentsHostMsg_RegisterIntentService(routing_id_, |
| 3384 | service.action(), |
| 3385 | service.type(), |
| 3386 | service.url().spec().utf16(), |
[email protected] | e6e35cd | 2011-12-22 19:37:06 | [diff] [blame] | 3387 | title, |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3388 | service.disposition())); |
| 3389 | } |
| 3390 | |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 3391 | void RenderViewImpl::dispatchIntent( |
| 3392 | WebFrame* frame, const WebIntentRequest& intentRequest) { |
| 3393 | webkit_glue::WebIntentData intent_data(intentRequest.intent()); |
| 3394 | int id = intents_host_->RegisterWebIntent(intentRequest); |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3395 | Send(new IntentsHostMsg_WebIntentDispatch( |
[email protected] | ffc8bed | 2012-01-21 01:23:15 | [diff] [blame] | 3396 | routing_id_, intent_data, id)); |
[email protected] | 8b5af49 | 2011-11-28 21:50:58 | [diff] [blame] | 3397 | } |
| 3398 | |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 3399 | // WebKit::WebPageSerializerClient implementation ------------------------------ |
| 3400 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3401 | void RenderViewImpl::didSerializeDataForFrame( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 3402 | const WebURL& frame_url, |
| 3403 | const WebCString& data, |
| 3404 | WebPageSerializerClient::PageSerializationStatus status) { |
| 3405 | Send(new ViewHostMsg_SendSerializedHtmlData( |
| 3406 | routing_id(), |
| 3407 | frame_url, |
| 3408 | data.data(), |
| 3409 | static_cast<int32>(status))); |
| 3410 | } |
| 3411 | |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3412 | // content::RenderView implementation ------------------------------------------ |
| 3413 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3414 | bool RenderViewImpl::Send(IPC::Message* message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3415 | return RenderWidget::Send(message); |
| 3416 | } |
| 3417 | |
[email protected] | 9f76c1e | 2012-03-05 15:15:58 | [diff] [blame] | 3418 | int RenderViewImpl::GetRoutingID() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3419 | return routing_id_; |
| 3420 | } |
| 3421 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3422 | int RenderViewImpl::GetPageId() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3423 | return page_id_; |
| 3424 | } |
| 3425 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3426 | gfx::Size RenderViewImpl::GetSize() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3427 | return size(); |
| 3428 | } |
| 3429 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3430 | gfx::NativeViewId RenderViewImpl::GetHostWindow() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3431 | return host_window(); |
| 3432 | } |
| 3433 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3434 | WebPreferences& RenderViewImpl::GetWebkitPreferences() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3435 | return webkit_preferences_; |
| 3436 | } |
| 3437 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3438 | WebKit::WebView* RenderViewImpl::GetWebView() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3439 | return webview(); |
| 3440 | } |
| 3441 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3442 | WebKit::WebNode RenderViewImpl::GetFocusedNode() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3443 | if (!webview()) |
| 3444 | return WebNode(); |
| 3445 | WebFrame* focused_frame = webview()->focusedFrame(); |
| 3446 | if (focused_frame) { |
| 3447 | WebDocument doc = focused_frame->document(); |
| 3448 | if (!doc.isNull()) |
| 3449 | return doc.focusedNode(); |
| 3450 | } |
| 3451 | |
| 3452 | return WebNode(); |
| 3453 | } |
| 3454 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3455 | WebKit::WebNode RenderViewImpl::GetContextMenuNode() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3456 | return context_menu_node_; |
| 3457 | } |
| 3458 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3459 | bool RenderViewImpl::IsEditableNode(const WebKit::WebNode& node) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3460 | bool is_editable_node = false; |
| 3461 | if (!node.isNull()) { |
| 3462 | if (node.isContentEditable()) { |
| 3463 | is_editable_node = true; |
| 3464 | } else if (node.isElementNode()) { |
| 3465 | is_editable_node = |
| 3466 | node.toConst<WebElement>().isTextFormControlElement(); |
| 3467 | } |
| 3468 | } |
| 3469 | return is_editable_node; |
| 3470 | } |
| 3471 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3472 | WebKit::WebPlugin* RenderViewImpl::CreatePlugin( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3473 | WebKit::WebFrame* frame, |
| 3474 | const webkit::WebPluginInfo& info, |
| 3475 | const WebKit::WebPluginParams& params) { |
| 3476 | bool pepper_plugin_was_registered = false; |
| 3477 | scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
| 3478 | pepper_delegate_.CreatePepperPluginModule(info, |
| 3479 | &pepper_plugin_was_registered)); |
| 3480 | if (pepper_plugin_was_registered) { |
| 3481 | if (!pepper_module) |
| 3482 | return NULL; |
| 3483 | return new webkit::ppapi::WebPluginImpl( |
| 3484 | pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); |
| 3485 | } |
| 3486 | |
[email protected] | 34b27e44 | 2012-01-20 20:07:41 | [diff] [blame] | 3487 | #if defined(USE_AURA) |
| 3488 | return NULL; |
| 3489 | #else |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3490 | return new webkit::npapi::WebPluginImpl( |
| 3491 | frame, params, info.path, AsWeakPtr()); |
[email protected] | 34b27e44 | 2012-01-20 20:07:41 | [diff] [blame] | 3492 | #endif |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3493 | } |
| 3494 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3495 | void RenderViewImpl::EvaluateScript(const string16& frame_xpath, |
| 3496 | const string16& jscript, |
| 3497 | int id, |
| 3498 | bool notify_result) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3499 | v8::Handle<v8::Value> result; |
| 3500 | WebFrame* web_frame = GetChildFrame(frame_xpath); |
| 3501 | if (web_frame) |
| 3502 | result = web_frame->executeScriptAndReturnValue(WebScriptSource(jscript)); |
| 3503 | if (notify_result) { |
| 3504 | ListValue list; |
| 3505 | if (!result.IsEmpty() && web_frame) { |
| 3506 | v8::HandleScope handle_scope; |
| 3507 | v8::Local<v8::Context> context = web_frame->mainWorldScriptContext(); |
| 3508 | v8::Context::Scope context_scope(context); |
| 3509 | V8ValueConverterImpl converter; |
| 3510 | converter.set_allow_date(true); |
| 3511 | converter.set_allow_regexp(true); |
| 3512 | list.Set(0, converter.FromV8Value(result, context)); |
| 3513 | } else { |
| 3514 | list.Set(0, Value::CreateNullValue()); |
| 3515 | } |
| 3516 | Send(new ViewHostMsg_ScriptEvalResponse(routing_id_, id, list)); |
| 3517 | } |
| 3518 | } |
| 3519 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3520 | bool RenderViewImpl::ShouldDisplayScrollbars(int width, int height) const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3521 | return (!send_preferred_size_changes_ || |
| 3522 | (disable_scrollbars_size_limit_.width() <= width || |
| 3523 | disable_scrollbars_size_limit_.height() <= height)); |
| 3524 | } |
| 3525 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3526 | int RenderViewImpl::GetEnabledBindings() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3527 | return enabled_bindings_; |
| 3528 | } |
| 3529 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3530 | bool RenderViewImpl::GetContentStateImmediately() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3531 | return send_content_state_immediately_; |
| 3532 | } |
| 3533 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3534 | float RenderViewImpl::GetFilteredTimePerFrame() { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3535 | return filtered_time_per_frame(); |
| 3536 | } |
| 3537 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3538 | void RenderViewImpl::ShowContextMenu(WebKit::WebFrame* frame, |
| 3539 | const WebKit::WebContextMenuData& data) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3540 | showContextMenu(frame, data); |
| 3541 | } |
| 3542 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3543 | WebKit::WebPageVisibilityState RenderViewImpl::GetVisibilityState() const { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3544 | return visibilityState(); |
| 3545 | } |
| 3546 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3547 | void RenderViewImpl::RunModalAlertDialog(WebKit::WebFrame* frame, |
| 3548 | const WebKit::WebString& message) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3549 | return runModalAlertDialog(frame, message); |
| 3550 | } |
| 3551 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3552 | void RenderViewImpl::LoadURLExternally( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3553 | WebKit::WebFrame* frame, |
| 3554 | const WebKit::WebURLRequest& request, |
| 3555 | WebKit::WebNavigationPolicy policy) { |
| 3556 | loadURLExternally(frame, request, policy); |
| 3557 | } |
| 3558 | |
| 3559 | // webkit_glue::WebPluginPageDelegate ------------------------------------------ |
[email protected] | 79dbc66 | 2009-09-04 05:42:51 | [diff] [blame] | 3560 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3561 | webkit::npapi::WebPluginDelegate* RenderViewImpl::CreatePluginDelegate( |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 3562 | const FilePath& file_path, |
| 3563 | const std::string& mime_type) { |
[email protected] | 94752ee | 2012-02-10 10:38:20 | [diff] [blame] | 3564 | if (!PluginChannelHost::IsListening()) { |
| 3565 | LOG(ERROR) << "PluginChannelHost isn't listening"; |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3566 | return NULL; |
[email protected] | 94752ee | 2012-02-10 10:38:20 | [diff] [blame] | 3567 | } |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3568 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 3569 | bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); |
[email protected] | d032f49 | 2009-09-29 00:33:46 | [diff] [blame] | 3570 | if (in_process_plugin) { |
[email protected] | 7398dcc | 2011-09-06 21:40:32 | [diff] [blame] | 3571 | #if defined(OS_WIN) && !defined(USE_AURA) |
[email protected] | e8f7a18 | 2011-03-10 00:50:22 | [diff] [blame] | 3572 | return webkit::npapi::WebPluginDelegateImpl::Create( |
| 3573 | file_path, mime_type, gfx::NativeViewFromId(host_window_)); |
[email protected] | 6876dff | 2010-01-15 19:38:09 | [diff] [blame] | 3574 | #else |
[email protected] | 7398dcc | 2011-09-06 21:40:32 | [diff] [blame] | 3575 | // In-proc plugins aren't supported on non-Windows. |
[email protected] | e8f7a18 | 2011-03-10 00:50:22 | [diff] [blame] | 3576 | NOTIMPLEMENTED(); |
| 3577 | return NULL; |
[email protected] | 7b6616f | 2010-01-14 18:07:55 | [diff] [blame] | 3578 | #endif |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3579 | } |
| 3580 | |
[email protected] | 4e0616e | 2010-05-28 14:55:53 | [diff] [blame] | 3581 | return new WebPluginDelegateProxy(mime_type, AsWeakPtr()); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3582 | } |
| 3583 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3584 | void RenderViewImpl::CreatedPluginWindow(gfx::PluginWindowHandle window) { |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 3585 | #if defined(USE_X11) |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 3586 | Send(new ViewHostMsg_CreatePluginContainer(routing_id(), window)); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3587 | #endif |
| 3588 | } |
| 3589 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3590 | void RenderViewImpl::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { |
[email protected] | 6981f7f | 2010-03-09 00:53:03 | [diff] [blame] | 3591 | #if defined(USE_X11) |
[email protected] | 38024409 | 2011-10-07 17:26:27 | [diff] [blame] | 3592 | Send(new ViewHostMsg_DestroyPluginContainer(routing_id(), window)); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3593 | #endif |
| 3594 | CleanupWindowInPluginMoves(window); |
| 3595 | } |
| 3596 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3597 | void RenderViewImpl::DidMovePlugin( |
| 3598 | const webkit::npapi::WebPluginGeometry& move) { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3599 | SchedulePluginMove(move); |
| 3600 | } |
| 3601 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3602 | void RenderViewImpl::DidStartLoadingForPlugin() { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3603 | // TODO(darin): Make is_loading_ be a counter! |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 3604 | didStartLoading(); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3605 | } |
| 3606 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3607 | void RenderViewImpl::DidStopLoadingForPlugin() { |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3608 | // TODO(darin): Make is_loading_ be a counter! |
[email protected] | 48c9cf2d | 2009-09-16 16:47:52 | [diff] [blame] | 3609 | didStopLoading(); |
[email protected] | f103ab7 | 2009-09-02 17:10:59 | [diff] [blame] | 3610 | } |
| 3611 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3612 | WebCookieJar* RenderViewImpl::GetCookieJar() { |
[email protected] | b921cfd2 | 2010-02-25 16:57:51 | [diff] [blame] | 3613 | return &cookie_jar_; |
| 3614 | } |
| 3615 | |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 3616 | void RenderViewImpl::DidPlay(webkit_media::WebMediaPlayerImpl* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 3617 | Send(new ViewHostMsg_MediaNotification(routing_id_, |
| 3618 | reinterpret_cast<int64>(player), |
| 3619 | player->hasVideo(), |
| 3620 | player->hasAudio(), |
| 3621 | true)); |
| 3622 | } |
| 3623 | |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 3624 | void RenderViewImpl::DidPause(webkit_media::WebMediaPlayerImpl* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 3625 | Send(new ViewHostMsg_MediaNotification(routing_id_, |
| 3626 | reinterpret_cast<int64>(player), |
| 3627 | player->hasVideo(), |
| 3628 | player->hasAudio(), |
| 3629 | false)); |
| 3630 | } |
| 3631 | |
[email protected] | a9288f5 | 2011-11-17 05:18:16 | [diff] [blame] | 3632 | void RenderViewImpl::PlayerGone(webkit_media::WebMediaPlayerImpl* player) { |
[email protected] | baff451 | 2011-10-19 18:21:07 | [diff] [blame] | 3633 | DidPause(player); |
| 3634 | } |
| 3635 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3636 | void RenderViewImpl::SyncNavigationState() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3637 | if (!webview()) |
| 3638 | return; |
| 3639 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3640 | const WebHistoryItem& item = webview()->mainFrame()->currentHistoryItem(); |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 3641 | if (item.isNull()) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3642 | return; |
[email protected] | ca948a2 | 2009-06-25 19:36:17 | [diff] [blame] | 3643 | |
| 3644 | Send(new ViewHostMsg_UpdateState( |
| 3645 | routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3646 | } |
| 3647 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3648 | void RenderViewImpl::SyncSelectionIfRequired() { |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3649 | WebFrame* frame = webview()->focusedFrame(); |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 3650 | if (!frame) |
| 3651 | return; |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3652 | |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 3653 | string16 text; |
| 3654 | size_t offset; |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame^] | 3655 | ui::Range range; |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 3656 | |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame^] | 3657 | if (pepper_delegate_.IsPluginFocused()) { |
| 3658 | pepper_delegate_.GetSurroundingText(&text, &range); |
| 3659 | offset = 0; // Pepper API does not support offset reporting. |
| 3660 | // TODO(kinaba): cut as needed. |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 3661 | } else { |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame^] | 3662 | size_t location, length; |
| 3663 | if (!webview()->caretOrSelectionRange(&location, &length)) |
| 3664 | return; |
| 3665 | |
| 3666 | range = ui::Range(location, location + length); |
| 3667 | |
| 3668 | if (webview()->textInputType() != WebKit::WebTextInputTypeNone) { |
| 3669 | // If current focused element is editable, we will send 100 more chars |
| 3670 | // before and after selection. It is for input method surrounding text |
| 3671 | // feature. |
| 3672 | if (location > kExtraCharsBeforeAndAfterSelection) |
| 3673 | offset = location - kExtraCharsBeforeAndAfterSelection; |
| 3674 | else |
| 3675 | offset = 0; |
| 3676 | length = location + length - offset + kExtraCharsBeforeAndAfterSelection; |
| 3677 | WebRange webrange = WebRange::fromDocumentRange(frame, offset, length); |
| 3678 | if (!webrange.isNull()) |
| 3679 | text = WebRange::fromDocumentRange(frame, offset, length).toPlainText(); |
| 3680 | } else { |
| 3681 | offset = location; |
| 3682 | text = frame->selectionAsText(); |
| 3683 | // http://crbug.com/101435 |
| 3684 | // In some case, frame->selectionAsText() returned text's length is not |
| 3685 | // equal to the length returned from webview()->caretOrSelectionRange(). |
| 3686 | // So we have to set the range according to text.length(). |
| 3687 | range.set_end(range.start() + text.length()); |
| 3688 | } |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3689 | } |
| 3690 | |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3691 | // Sometimes we get repeated didChangeSelection calls from webkit when |
| 3692 | // the selection hasn't actually changed. We don't want to report these |
| 3693 | // because it will cause us to continually claim the X clipboard. |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 3694 | if (selection_text_offset_ != offset || |
| 3695 | selection_range_ != range || |
| 3696 | selection_text_ != text) { |
| 3697 | selection_text_ = text; |
| 3698 | selection_text_offset_ = offset; |
| 3699 | selection_range_ = range; |
| 3700 | Send(new ViewHostMsg_SelectionChanged(routing_id_, text, offset, range)); |
| 3701 | } |
[email protected] | b781ff28 | 2011-08-20 06:19:36 | [diff] [blame] | 3702 | } |
| 3703 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3704 | GURL RenderViewImpl::GetAlternateErrorPageURL(const GURL& failed_url, |
| 3705 | ErrorPageType error_type) { |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 3706 | if (failed_url.SchemeIsSecure()) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3707 | // If the URL that failed was secure, then the embedding web page was not |
| 3708 | // expecting a network attacker to be able to manipulate its contents. As |
| 3709 | // we fetch alternate error pages over HTTP, we would be allowing a network |
| 3710 | // attacker to manipulate the contents of the response if we tried to use |
| 3711 | // the link doctor here. |
[email protected] | 810a52ef | 2010-01-08 01:22:15 | [diff] [blame] | 3712 | return GURL(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3713 | } |
| 3714 | |
| 3715 | // Grab the base URL from the browser process. |
| 3716 | if (!alternate_error_page_url_.is_valid()) |
[email protected] | 810a52ef | 2010-01-08 01:22:15 | [diff] [blame] | 3717 | return GURL(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3718 | |
| 3719 | // Strip query params from the failed URL. |
| 3720 | GURL::Replacements remove_params; |
| 3721 | remove_params.ClearUsername(); |
| 3722 | remove_params.ClearPassword(); |
| 3723 | remove_params.ClearQuery(); |
| 3724 | remove_params.ClearRef(); |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 3725 | const GURL url_to_send = failed_url.ReplaceComponents(remove_params); |
[email protected] | 6fd28f64 | 2010-03-15 17:15:50 | [diff] [blame] | 3726 | std::string spec_to_send = url_to_send.spec(); |
| 3727 | // Notify link doctor of the url truncation by sending of "?" at the end. |
| 3728 | if (failed_url.has_query()) |
| 3729 | spec_to_send.append("?"); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3730 | |
| 3731 | // Construct the query params to send to link doctor. |
| 3732 | std::string params(alternate_error_page_url_.query()); |
| 3733 | params.append("&url="); |
[email protected] | 4a19be9 | 2011-09-22 14:25:02 | [diff] [blame] | 3734 | params.append(net::EscapeQueryParamValue(spec_to_send, true)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3735 | params.append("&sourceid=chrome"); |
| 3736 | params.append("&error="); |
| 3737 | switch (error_type) { |
| 3738 | case DNS_ERROR: |
| 3739 | params.append("dnserror"); |
| 3740 | break; |
| 3741 | |
| 3742 | case HTTP_404: |
| 3743 | params.append("http404"); |
| 3744 | break; |
| 3745 | |
[email protected] | 5df266ac | 2008-10-15 19:50:13 | [diff] [blame] | 3746 | case CONNECTION_ERROR: |
[email protected] | e1f934b | 2009-01-26 20:41:33 | [diff] [blame] | 3747 | params.append("connectionfailure"); |
[email protected] | 5df266ac | 2008-10-15 19:50:13 | [diff] [blame] | 3748 | break; |
| 3749 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3750 | default: |
| 3751 | NOTREACHED() << "unknown ErrorPageType"; |
| 3752 | } |
| 3753 | |
| 3754 | // OK, build the final url to return. |
| 3755 | GURL::Replacements link_doctor_params; |
| 3756 | link_doctor_params.SetQueryStr(params); |
| 3757 | GURL url = alternate_error_page_url_.ReplaceComponents(link_doctor_params); |
| 3758 | return url; |
| 3759 | } |
| 3760 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3761 | GURL RenderViewImpl::GetOpenerUrl() const { |
[email protected] | 57b9396c | 2011-10-07 19:11:59 | [diff] [blame] | 3762 | if (opener_id_ == MSG_ROUTING_NONE || opener_suppressed_) |
| 3763 | return GURL(); |
| 3764 | else |
| 3765 | return creator_url_; |
| 3766 | } |
| 3767 | |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 3768 | GURL RenderViewImpl::GetLoadingUrl(WebKit::WebFrame* frame) const { |
| 3769 | WebDataSource* ds = frame->dataSource(); |
| 3770 | if (ds->hasUnreachableURL()) |
| 3771 | return ds->unreachableURL(); |
| 3772 | |
| 3773 | const WebURLRequest& request = ds->request(); |
| 3774 | return request.url(); |
| 3775 | } |
| 3776 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3777 | WebUIBindings* RenderViewImpl::GetWebUIBindings() { |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 3778 | if (!web_ui_bindings_.get()) { |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 3779 | web_ui_bindings_.reset(new WebUIBindings( |
| 3780 | static_cast<content::RenderView*>(this), routing_id_)); |
[email protected] | c091c2c | 2010-09-17 19:05:46 | [diff] [blame] | 3781 | } |
[email protected] | c5000851 | 2011-02-03 01:17:27 | [diff] [blame] | 3782 | return web_ui_bindings_.get(); |
[email protected] | c091c2c | 2010-09-17 19:05:46 | [diff] [blame] | 3783 | } |
| 3784 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3785 | WebKit::WebPlugin* RenderViewImpl::GetWebPluginFromPluginDocument() { |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 3786 | return webview()->mainFrame()->document().to<WebPluginDocument>().plugin(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3787 | } |
| 3788 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3789 | void RenderViewImpl::OnFind(int request_id, const string16& search_text, |
| 3790 | const WebFindOptions& options) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3791 | WebFrame* main_frame = webview()->mainFrame(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3792 | |
[email protected] | 87254253 | 2011-06-23 00:43:16 | [diff] [blame] | 3793 | // Check if the plugin still exists in the document. |
| 3794 | if (main_frame->document().isPluginDocument() && |
| 3795 | GetWebPluginFromPluginDocument()) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3796 | if (options.findNext) { |
| 3797 | // Just navigate back/forward. |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 3798 | GetWebPluginFromPluginDocument()->selectFindResult(options.forward); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3799 | } else { |
[email protected] | afdbd14 | 2010-07-10 08:01:23 | [diff] [blame] | 3800 | if (GetWebPluginFromPluginDocument()->startFind( |
| 3801 | search_text, options.matchCase, request_id)) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3802 | } else { |
[email protected] | e7c58a3 | 2010-08-13 19:47:11 | [diff] [blame] | 3803 | // Send "no results". |
| 3804 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
| 3805 | request_id, |
| 3806 | 0, |
| 3807 | gfx::Rect(), |
| 3808 | 0, |
| 3809 | true)); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3810 | } |
| 3811 | } |
| 3812 | return; |
| 3813 | } |
| 3814 | |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 3815 | WebFrame* frame_after_main = main_frame->traverseNext(true); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3816 | WebFrame* focused_frame = webview()->focusedFrame(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3817 | WebFrame* search_frame = focused_frame; // start searching focused frame. |
| 3818 | |
| 3819 | bool multi_frame = (frame_after_main != main_frame); |
| 3820 | |
| 3821 | // If we have multiple frames, we don't want to wrap the search within the |
| 3822 | // frame, so we check here if we only have main_frame in the chain. |
| 3823 | bool wrap_within_frame = !multi_frame; |
| 3824 | |
[email protected] | b3f2b91 | 2009-04-09 16:18:52 | [diff] [blame] | 3825 | WebRect selection_rect; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3826 | bool result = false; |
| 3827 | |
[email protected] | 7830da3e | 2009-11-06 16:27:26 | [diff] [blame] | 3828 | // If something is selected when we start searching it means we cannot just |
| 3829 | // increment the current match ordinal; we need to re-generate it. |
| 3830 | WebRange current_selection = focused_frame->selectionRange(); |
| 3831 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3832 | do { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3833 | result = search_frame->find( |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3834 | request_id, search_text, options, wrap_within_frame, &selection_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3835 | |
| 3836 | if (!result) { |
| 3837 | // don't leave text selected as you move to the next frame. |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 3838 | search_frame->executeCommand(WebString::fromUTF8("Unselect")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3839 | |
| 3840 | // Find the next frame, but skip the invisible ones. |
| 3841 | do { |
| 3842 | // What is the next frame to search? (we might be going backwards). Note |
| 3843 | // that we specify wrap=true so that search_frame never becomes NULL. |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3844 | search_frame = options.forward ? |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 3845 | search_frame->traverseNext(true) : |
| 3846 | search_frame->traversePrevious(true); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3847 | } while (!search_frame->hasVisibleContent() && |
| 3848 | search_frame != focused_frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3849 | |
[email protected] | 884db41 | 2008-11-24 23:46:50 | [diff] [blame] | 3850 | // Make sure selection doesn't affect the search operation in new frame. |
[email protected] | a100d76bb | 2009-08-14 17:50:22 | [diff] [blame] | 3851 | search_frame->executeCommand(WebString::fromUTF8("Unselect")); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3852 | |
| 3853 | // If we have multiple frames and we have wrapped back around to the |
| 3854 | // focused frame, we need to search it once more allowing wrap within |
| 3855 | // the frame, otherwise it will report 'no match' if the focused frame has |
| 3856 | // reported matches, but no frames after the focused_frame contain a |
| 3857 | // match for the search word(s). |
| 3858 | if (multi_frame && search_frame == focused_frame) { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3859 | result = search_frame->find( |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3860 | request_id, search_text, options, true, // Force wrapping. |
| 3861 | &selection_rect); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3862 | } |
| 3863 | } |
| 3864 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 3865 | webview()->setFocusedFrame(search_frame); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3866 | } while (!result && search_frame != focused_frame); |
| 3867 | |
[email protected] | 7830da3e | 2009-11-06 16:27:26 | [diff] [blame] | 3868 | if (options.findNext && current_selection.isNull()) { |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3869 | // Force the main_frame to report the actual count. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3870 | main_frame->increaseMatchCount(0, request_id); |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3871 | } else { |
| 3872 | // If nothing is found, set result to "0 of 0", otherwise, set it to |
| 3873 | // "-1 of 1" to indicate that we found at least one item, but we don't know |
| 3874 | // yet what is active. |
| 3875 | int ordinal = result ? -1 : 0; // -1 here means, we might know more later. |
| 3876 | int match_count = result ? 1 : 0; // 1 here means possibly more coming. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3877 | |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3878 | // If we find no matches then this will be our last status update. |
| 3879 | // Otherwise the scoping effort will send more results. |
| 3880 | bool final_status_update = !result; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3881 | |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3882 | // Send the search result over to the browser process. |
[email protected] | 4f99913 | 2009-03-31 18:08:40 | [diff] [blame] | 3883 | Send(new ViewHostMsg_Find_Reply(routing_id_, |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3884 | request_id, |
[email protected] | 4f3dc37 | 2009-02-24 00:10:29 | [diff] [blame] | 3885 | match_count, |
| 3886 | selection_rect, |
| 3887 | ordinal, |
| 3888 | final_status_update)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3889 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3890 | // Scoping effort begins, starting with the mainframe. |
| 3891 | search_frame = main_frame; |
| 3892 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3893 | main_frame->resetMatchCount(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3894 | |
| 3895 | do { |
| 3896 | // Cancel all old scoping requests before starting a new one. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3897 | search_frame->cancelPendingScopingEffort(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3898 | |
| 3899 | // We don't start another scoping effort unless at least one match has |
| 3900 | // been found. |
| 3901 | if (result) { |
| 3902 | // Start new scoping request. If the scoping function determines that it |
| 3903 | // needs to scope, it will defer until later. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 3904 | search_frame->scopeStringMatches(request_id, |
[email protected] | 7ea066a | 2009-04-06 20:21:59 | [diff] [blame] | 3905 | search_text, |
| 3906 | options, |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3907 | true); // reset the tickmarks |
| 3908 | } |
| 3909 | |
| 3910 | // Iterate to the next frame. The frame will not necessarily scope, for |
| 3911 | // example if it is not visible. |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 3912 | search_frame = search_frame->traverseNext(true); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 3913 | } while (search_frame != main_frame); |
| 3914 | } |
| 3915 | } |
| 3916 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 3917 | void RenderViewImpl::OnStopFinding(content::StopFindAction action) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3918 | WebView* view = webview(); |
| 3919 | if (!view) |
| 3920 | return; |
| 3921 | |
| 3922 | WebDocument doc = view->mainFrame()->document(); |
[email protected] | 87254253 | 2011-06-23 00:43:16 | [diff] [blame] | 3923 | if (doc.isPluginDocument() && GetWebPluginFromPluginDocument()) { |
[email protected] | 0fdbf8c | 2010-07-08 20:33:01 | [diff] [blame] | 3924 | GetWebPluginFromPluginDocument()->stopFind(); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3925 | return; |
| 3926 | } |
| 3927 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 3928 | bool clear_selection = action == content::STOP_FIND_ACTION_CLEAR_SELECTION; |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3929 | if (clear_selection) |
| 3930 | view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect")); |
| 3931 | |
| 3932 | WebFrame* frame = view->mainFrame(); |
| 3933 | while (frame) { |
| 3934 | frame->stopFinding(clear_selection); |
| 3935 | frame = frame->traverseNext(false); |
| 3936 | } |
| 3937 | |
[email protected] | 815dd987 | 2011-11-23 18:40:30 | [diff] [blame] | 3938 | if (action == content::STOP_FIND_ACTION_ACTIVATE_SELECTION) { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3939 | WebFrame* focused_frame = view->focusedFrame(); |
| 3940 | if (focused_frame) { |
| 3941 | WebDocument doc = focused_frame->document(); |
| 3942 | if (!doc.isNull()) { |
| 3943 | WebNode node = doc.focusedNode(); |
| 3944 | if (!node.isNull()) |
| 3945 | node.simulateClick(); |
| 3946 | } |
| 3947 | } |
| 3948 | } |
| 3949 | } |
| 3950 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 3951 | void RenderViewImpl::OnFindReplyAck() { |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3952 | // Check if there is any queued up request waiting to be sent. |
| 3953 | if (queued_find_reply_message_.get()) { |
| 3954 | // Send the search result over to the browser process. |
[email protected] | d22d873 | 2010-05-04 19:24:42 | [diff] [blame] | 3955 | Send(queued_find_reply_message_.release()); |
[email protected] | 24a7f3c | 2010-03-25 08:26:49 | [diff] [blame] | 3956 | } |
| 3957 | } |
| 3958 | |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3959 | void RenderViewImpl::OnZoom(content::PageZoom zoom) { |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 3960 | if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 3961 | return; |
| 3962 | |
[email protected] | 258d3112 | 2010-05-09 10:59:41 | [diff] [blame] | 3963 | webview()->hidePopups(); |
[email protected] | 854ab546 | 2011-11-22 20:48:10 | [diff] [blame] | 3964 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3965 | double old_zoom_level = webview()->zoomLevel(); |
| 3966 | double zoom_level; |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3967 | if (zoom == content::PAGE_ZOOM_RESET) { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3968 | zoom_level = 0; |
| 3969 | } else if (static_cast<int>(old_zoom_level) == old_zoom_level) { |
| 3970 | // Previous zoom level is a whole number, so just increment/decrement. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3971 | zoom_level = old_zoom_level + zoom; |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3972 | } else { |
| 3973 | // Either the user hit the zoom factor limit and thus the zoom level is now |
| 3974 | // not a whole number, or a plugin changed it to a custom value. We want |
| 3975 | // to go to the next whole number so that the user can always get back to |
| 3976 | // 100% with the keyboard/menu. |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 3977 | if ((old_zoom_level > 1 && zoom > 0) || |
| 3978 | (old_zoom_level < 1 && zoom < 0)) { |
| 3979 | zoom_level = static_cast<int>(old_zoom_level + zoom); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3980 | } else { |
| 3981 | // We're going towards 100%, so first go to the next whole number. |
| 3982 | zoom_level = static_cast<int>(old_zoom_level); |
| 3983 | } |
| 3984 | } |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 3985 | webview()->setZoomLevel(false, zoom_level); |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 3986 | zoomLevelChanged(); |
| 3987 | } |
| 3988 | |
| 3989 | void RenderViewImpl::OnZoomFactor(content::PageZoom zoom, |
| 3990 | int zoom_center_x, int zoom_center_y) { |
| 3991 | ZoomFactorHelper(zoom, zoom_center_x, zoom_center_y, |
| 3992 | kScalingIncrementForGesture); |
| 3993 | } |
| 3994 | |
| 3995 | void RenderViewImpl::ZoomFactorHelper(content::PageZoom zoom, |
| 3996 | int zoom_center_x, |
| 3997 | int zoom_center_y, |
| 3998 | float scaling_increment) { |
| 3999 | if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 4000 | return; |
| 4001 | |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 4002 | double old_page_scale_factor = webview()->pageScaleFactor(); |
| 4003 | double page_scale_factor; |
[email protected] | 54087fe | 2011-10-28 22:02:48 | [diff] [blame] | 4004 | if (zoom == content::PAGE_ZOOM_RESET) { |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 4005 | page_scale_factor = 1.0; |
| 4006 | } else { |
| 4007 | page_scale_factor = old_page_scale_factor + |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 4008 | (zoom > 0 ? scaling_increment : -scaling_increment); |
[email protected] | c514d637 | 2011-08-16 22:54:44 | [diff] [blame] | 4009 | } |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 4010 | if (page_scale_factor > 0) { |
[email protected] | 8519136 | 2011-11-08 18:53:09 | [diff] [blame] | 4011 | webview()->setPageScaleFactor(page_scale_factor, |
| 4012 | WebPoint(zoom_center_x, zoom_center_y)); |
[email protected] | 47578fa0 | 2011-11-02 19:34:41 | [diff] [blame] | 4013 | } |
[email protected] | 40bd658 | 2009-12-04 23:49:51 | [diff] [blame] | 4014 | } |
| 4015 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4016 | void RenderViewImpl::OnSetZoomLevel(double zoom_level) { |
[email protected] | d0b8d09 | 2010-10-25 04:05:17 | [diff] [blame] | 4017 | webview()->hidePopups(); |
| 4018 | webview()->setZoomLevel(false, zoom_level); |
| 4019 | zoomLevelChanged(); |
| 4020 | } |
| 4021 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4022 | void RenderViewImpl::OnSetZoomLevelForLoadingURL(const GURL& url, |
| 4023 | double zoom_level) { |
[email protected] | 9d797f3 | 2010-04-23 07:17:54 | [diff] [blame] | 4024 | host_zoom_levels_[url] = zoom_level; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4025 | } |
| 4026 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4027 | void RenderViewImpl::OnSetPageEncoding(const std::string& encoding_name) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4028 | webview()->setPageEncoding(WebString::fromUTF8(encoding_name)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4029 | } |
| 4030 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4031 | void RenderViewImpl::OnResetPageEncodingToDefault() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4032 | WebString no_encoding; |
| 4033 | webview()->setPageEncoding(no_encoding); |
[email protected] | a697f4c | 2009-09-14 22:30:18 | [diff] [blame] | 4034 | } |
| 4035 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4036 | WebFrame* RenderViewImpl::GetChildFrame(const string16& xpath) const { |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4037 | if (xpath.empty()) |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4038 | return webview()->mainFrame(); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4039 | |
| 4040 | // xpath string can represent a frame deep down the tree (across multiple |
| 4041 | // frame DOMs). |
| 4042 | // Example, /html/body/table/tbody/tr/td/iframe\n/frameset/frame[0] |
| 4043 | // should break into 2 xpaths |
| 4044 | // /html/body/table/tbody/tr/td/iframe & /frameset/frame[0] |
[email protected] | 318bf580 | 2011-08-08 17:12:41 | [diff] [blame] | 4045 | std::vector<string16> xpaths; |
| 4046 | base::SplitString(xpath, '\n', &xpaths); |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4047 | |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4048 | WebFrame* frame = webview()->mainFrame(); |
[email protected] | 318bf580 | 2011-08-08 17:12:41 | [diff] [blame] | 4049 | for (std::vector<string16>::const_iterator i = xpaths.begin(); |
| 4050 | frame && i != xpaths.end(); ++i) { |
| 4051 | frame = frame->findChildByExpression(*i); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4052 | } |
| 4053 | |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4054 | return frame; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4055 | } |
| 4056 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4057 | void RenderViewImpl::OnScriptEvalRequest(const string16& frame_xpath, |
| 4058 | const string16& jscript, |
| 4059 | int id, |
| 4060 | bool notify_result) { |
[email protected] | 882b7b2 | 2010-10-05 03:34:53 | [diff] [blame] | 4061 | EvaluateScript(frame_xpath, jscript, id, notify_result); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4062 | } |
| 4063 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4064 | void RenderViewImpl::OnCSSInsertRequest(const string16& frame_xpath, |
| 4065 | const std::string& css) { |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 4066 | WebFrame* frame = GetChildFrame(frame_xpath); |
| 4067 | if (!frame) |
[email protected] | 21681395 | 2011-05-19 22:21:26 | [diff] [blame] | 4068 | return; |
[email protected] | ae46154 | 2009-06-19 19:03:41 | [diff] [blame] | 4069 | |
[email protected] | 01cf589c | 2011-07-28 18:04:03 | [diff] [blame] | 4070 | frame->document().insertUserStyleSheet( |
| 4071 | WebString::fromUTF8(css), |
| 4072 | WebDocument::UserStyleAuthorLevel); |
[email protected] | 1810e13 | 2009-03-24 23:35:48 | [diff] [blame] | 4073 | } |
| 4074 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4075 | void RenderViewImpl::OnAllowBindings(int enabled_bindings_flags) { |
[email protected] | 81e6378 | 2009-02-27 19:35:09 | [diff] [blame] | 4076 | enabled_bindings_ |= enabled_bindings_flags; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4077 | } |
| 4078 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4079 | void RenderViewImpl::OnSetWebUIProperty(const std::string& name, |
| 4080 | const std::string& value) { |
[email protected] | 808bda5 | 2012-03-09 22:43:32 | [diff] [blame] | 4081 | if (enabled_bindings_ & content::BINDINGS_POLICY_WEB_UI) |
| 4082 | GetWebUIBindings()->SetProperty(name, value); |
| 4083 | else |
| 4084 | NOTREACHED() << "WebUI bindings not enabled."; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4085 | } |
| 4086 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4087 | void RenderViewImpl::OnDragTargetDragEnter(const WebDropData& drop_data, |
| 4088 | const gfx::Point& client_point, |
| 4089 | const gfx::Point& screen_point, |
| 4090 | WebDragOperationsMask ops) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4091 | WebDragOperation operation = webview()->dragTargetDragEnter( |
| 4092 | drop_data.ToDragData(), |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4093 | client_point, |
| 4094 | screen_point, |
| 4095 | ops); |
| 4096 | |
| 4097 | Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); |
| 4098 | } |
| 4099 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4100 | void RenderViewImpl::OnDragTargetDragOver(const gfx::Point& client_point, |
| 4101 | const gfx::Point& screen_point, |
| 4102 | WebDragOperationsMask ops) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4103 | WebDragOperation operation = webview()->dragTargetDragOver( |
| 4104 | client_point, |
| 4105 | screen_point, |
| 4106 | ops); |
| 4107 | |
| 4108 | Send(new DragHostMsg_UpdateDragCursor(routing_id_, operation)); |
| 4109 | } |
| 4110 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4111 | void RenderViewImpl::OnDragTargetDragLeave() { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4112 | webview()->dragTargetDragLeave(); |
| 4113 | } |
| 4114 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4115 | void RenderViewImpl::OnDragTargetDrop(const gfx::Point& client_point, |
| 4116 | const gfx::Point& screen_point) { |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4117 | webview()->dragTargetDrop(client_point, screen_point); |
[email protected] | fcad4945 | 2011-06-28 17:11:57 | [diff] [blame] | 4118 | |
| 4119 | Send(new DragHostMsg_TargetDrop_ACK(routing_id_)); |
[email protected] | 59f4f2fa | 2011-03-23 01:00:55 | [diff] [blame] | 4120 | } |
| 4121 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4122 | void RenderViewImpl::OnDragSourceEndedOrMoved(const gfx::Point& client_point, |
| 4123 | const gfx::Point& screen_point, |
| 4124 | bool ended, |
| 4125 | WebDragOperation op) { |
[email protected] | 5f9ae6c | 2009-07-08 02:38:03 | [diff] [blame] | 4126 | if (ended) { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4127 | webview()->dragSourceEndedAt(client_point, screen_point, op); |
[email protected] | daec5d6 | 2010-06-04 09:14:20 | [diff] [blame] | 4128 | } else { |
| 4129 | webview()->dragSourceMovedTo(client_point, screen_point, op); |
[email protected] | 5f9ae6c | 2009-07-08 02:38:03 | [diff] [blame] | 4130 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4131 | } |
| 4132 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4133 | void RenderViewImpl::OnDragSourceSystemDragEnded() { |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4134 | webview()->dragSourceSystemDragEnded(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4135 | } |
| 4136 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4137 | void RenderViewImpl::OnUpdateWebPreferences(const WebPreferences& prefs) { |
[email protected] | 2fab253a | 2009-08-17 23:00:59 | [diff] [blame] | 4138 | webkit_preferences_ = prefs; |
| 4139 | webkit_preferences_.Apply(webview()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4140 | } |
| 4141 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4142 | void RenderViewImpl::OnSetAltErrorPageURL(const GURL& url) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4143 | alternate_error_page_url_ = url; |
| 4144 | } |
| 4145 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4146 | void RenderViewImpl::OnCustomContextMenuAction( |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 4147 | const content::CustomContextMenuContext& custom_context, |
[email protected] | b29aa74b | 2011-01-31 21:41:08 | [diff] [blame] | 4148 | unsigned action) { |
| 4149 | if (custom_context.is_pepper_menu) |
| 4150 | pepper_delegate_.OnCustomContextMenuAction(custom_context, action); |
| 4151 | else |
| 4152 | webview()->performCustomContextMenuAction(action); |
[email protected] | 440a0e5 | 2011-09-13 17:38:58 | [diff] [blame] | 4153 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, |
| 4154 | ContextMenuAction(action)); |
[email protected] | a0c7153e | 2009-12-09 14:36:33 | [diff] [blame] | 4155 | } |
| 4156 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4157 | void RenderViewImpl::OnEnumerateDirectoryResponse( |
[email protected] | 600ea40 | 2011-04-12 00:01:51 | [diff] [blame] | 4158 | int id, |
| 4159 | const std::vector<FilePath>& paths) { |
| 4160 | if (!enumeration_completions_[id]) |
| 4161 | return; |
| 4162 | |
| 4163 | WebVector<WebString> ws_file_names(paths.size()); |
| 4164 | for (size_t i = 0; i < paths.size(); ++i) |
| 4165 | ws_file_names[i] = webkit_glue::FilePathToWebString(paths[i]); |
| 4166 | |
| 4167 | enumeration_completions_[id]->didChooseFile(ws_file_names); |
| 4168 | enumeration_completions_.erase(id); |
| 4169 | } |
| 4170 | |
[email protected] | fb11b6a4 | 2012-03-14 07:25:12 | [diff] [blame] | 4171 | void RenderViewImpl::OnFileChooserResponse( |
| 4172 | const std::vector<content::SelectedFileInfo>& files) { |
[email protected] | 8029f567 | 2009-03-20 22:33:36 | [diff] [blame] | 4173 | // This could happen if we navigated to a different page before the user |
| 4174 | // closed the chooser. |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 4175 | if (file_chooser_completions_.empty()) |
[email protected] | 8029f567 | 2009-03-20 22:33:36 | [diff] [blame] | 4176 | return; |
| 4177 | |
[email protected] | b518852 | 2012-03-15 00:18:04 | [diff] [blame] | 4178 | // Convert Chrome's SelectedFileInfo list to WebKit's. |
| 4179 | WebVector<WebFileChooserCompletion::SelectedFileInfo> selected_files( |
| 4180 | files.size()); |
| 4181 | for (size_t i = 0; i < files.size(); ++i) { |
| 4182 | WebFileChooserCompletion::SelectedFileInfo selected_file; |
| 4183 | selected_file.path = webkit_glue::FilePathToWebString(files[i].path); |
| 4184 | selected_file.displayName = webkit_glue::FilePathStringToWebString( |
| 4185 | files[i].display_name); |
| 4186 | selected_files[i] = selected_file; |
| 4187 | } |
[email protected] | a112832 | 2009-10-06 18:38:46 | [diff] [blame] | 4188 | |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 4189 | if (file_chooser_completions_.front()->completion) |
[email protected] | b518852 | 2012-03-15 00:18:04 | [diff] [blame] | 4190 | file_chooser_completions_.front()->completion->didChooseFile( |
| 4191 | selected_files); |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 4192 | file_chooser_completions_.pop_front(); |
| 4193 | |
| 4194 | // If there are more pending file chooser requests, schedule one now. |
| 4195 | if (!file_chooser_completions_.empty()) { |
| 4196 | Send(new ViewHostMsg_RunFileChooser(routing_id_, |
| 4197 | file_chooser_completions_.front()->params)); |
| 4198 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4199 | } |
| 4200 | |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 4201 | void RenderViewImpl::OnEnableAutoResize(const gfx::Size& min_size, |
| 4202 | const gfx::Size& max_size) { |
| 4203 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 4204 | if (!webview()) |
| 4205 | return; |
[email protected] | 61e2b3cc | 2012-03-02 16:13:34 | [diff] [blame] | 4206 | webview()->enableAutoResizeMode(min_size, max_size); |
| 4207 | } |
| 4208 | |
| 4209 | void RenderViewImpl::OnDisableAutoResize(const gfx::Size& new_size) { |
| 4210 | DCHECK(disable_scrollbars_size_limit_.IsEmpty()); |
| 4211 | if (!webview()) |
| 4212 | return; |
| 4213 | webview()->disableAutoResizeMode(); |
| 4214 | |
| 4215 | Resize(new_size, resizer_rect_, is_fullscreen_, NO_RESIZE_ACK); |
[email protected] | 244ac189 | 2011-12-02 17:04:47 | [diff] [blame] | 4216 | } |
| 4217 | |
[email protected] | 2bf834f | 2011-11-17 20:02:21 | [diff] [blame] | 4218 | void RenderViewImpl::OnEnablePreferredSizeChangedMode() { |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 4219 | if (send_preferred_size_changes_) |
| 4220 | return; |
[email protected] | 9fb325e | 2010-05-06 18:23:24 | [diff] [blame] | 4221 | send_preferred_size_changes_ = true; |
[email protected] | 770dd8b | 2010-05-24 18:11:39 | [diff] [blame] | 4222 | |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 4223 | // Start off with an initial preferred size notification (in case |
| 4224 | // |didUpdateLayout| was already called). |
[email protected] | 169d428 | 2011-11-30 19:33:59 | [diff] [blame] | 4225 | didUpdateLayout(); |
[email protected] | 0666aef | 2009-05-13 19:48:08 | [diff] [blame] | 4226 | } |
| 4227 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4228 | void RenderViewImpl::OnDisableScrollbarsForSmallWindows( |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4229 | const gfx::Size& disable_scrollbar_size_limit) { |
| 4230 | disable_scrollbars_size_limit_ = disable_scrollbar_size_limit; |
| 4231 | } |
| 4232 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4233 | void RenderViewImpl::OnSetRendererPrefs( |
[email protected] | daf82f8 | 2011-10-31 22:35:31 | [diff] [blame] | 4234 | const content::RendererPreferences& renderer_prefs) { |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 4235 | double old_zoom_level = renderer_preferences_.default_zoom_level; |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 4236 | renderer_preferences_ = renderer_prefs; |
[email protected] | 6e282c9 | 2009-07-24 01:19:37 | [diff] [blame] | 4237 | UpdateFontRenderingFromRendererPrefs(); |
[email protected] | 0dd6f9b5 | 2010-10-14 16:39:13 | [diff] [blame] | 4238 | #if defined(TOOLKIT_USES_GTK) |
[email protected] | 1c83eb4 | 2009-09-11 21:08:41 | [diff] [blame] | 4239 | WebColorName name = WebKit::WebColorWebkitFocusRingColor; |
| 4240 | WebKit::setNamedColors(&name, &renderer_prefs.focus_ring_color, 1); |
[email protected] | 39cd64ed | 2010-02-05 02:18:46 | [diff] [blame] | 4241 | WebKit::setCaretBlinkInterval(renderer_prefs.caret_blink_interval); |
[email protected] | 42e5c86 | 2011-04-07 22:13:51 | [diff] [blame] | 4242 | gfx::NativeTheme::instance()->SetScrollbarColors( |
[email protected] | 8d1b864d1 | 2010-10-10 00:04:34 | [diff] [blame] | 4243 | renderer_prefs.thumb_inactive_color, |
| 4244 | renderer_prefs.thumb_active_color, |
| 4245 | renderer_prefs.track_color); |
[email protected] | 93623c5d | 2009-12-10 21:40:32 | [diff] [blame] | 4246 | |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 4247 | if (webview()) { |
[email protected] | 93623c5d | 2009-12-10 21:40:32 | [diff] [blame] | 4248 | webview()->setScrollbarColors( |
| 4249 | renderer_prefs.thumb_inactive_color, |
| 4250 | renderer_prefs.thumb_active_color, |
| 4251 | renderer_prefs.track_color); |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 4252 | webview()->setSelectionColors( |
| 4253 | renderer_prefs.active_selection_bg_color, |
| 4254 | renderer_prefs.active_selection_fg_color, |
| 4255 | renderer_prefs.inactive_selection_bg_color, |
| 4256 | renderer_prefs.inactive_selection_fg_color); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 4257 | webview()->themeChanged(); |
[email protected] | 644d77e | 2010-01-27 01:03:10 | [diff] [blame] | 4258 | } |
[email protected] | 7a74e10 | 2009-09-03 00:16:56 | [diff] [blame] | 4259 | #endif |
[email protected] | d051d9a | 2011-12-10 02:02:50 | [diff] [blame] | 4260 | // If the zoom level for this page matches the old zoom default, and this |
| 4261 | // is not a plugin, update the zoom level to match the new default. |
| 4262 | if (webview() && !webview()->mainFrame()->document().isPluginDocument() && |
| 4263 | content::ZoomValuesEqual(webview()->zoomLevel(), old_zoom_level)) { |
| 4264 | webview()->setZoomLevel(false, renderer_preferences_.default_zoom_level); |
| 4265 | zoomLevelChanged(); |
| 4266 | } |
[email protected] | 80d96fa | 2009-06-10 22:34:51 | [diff] [blame] | 4267 | } |
| 4268 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4269 | void RenderViewImpl::OnMediaPlayerActionAt(const gfx::Point& location, |
| 4270 | const WebMediaPlayerAction& action) { |
[email protected] | 952cb70 | 2009-10-07 05:50:28 | [diff] [blame] | 4271 | if (webview()) |
| 4272 | webview()->performMediaPlayerAction(action, location); |
[email protected] | 581b87eb | 2009-07-23 23:06:56 | [diff] [blame] | 4273 | } |
| 4274 | |
[email protected] | 81375e87 | 2012-01-11 21:40:36 | [diff] [blame] | 4275 | void RenderViewImpl::OnPluginActionAt(const gfx::Point& location, |
| 4276 | const WebPluginAction& action) { |
| 4277 | if (webview()) |
| 4278 | webview()->performPluginAction(action, location); |
| 4279 | } |
| 4280 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4281 | void RenderViewImpl::OnGetAllSavableResourceLinksForCurrentPage( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4282 | const GURL& page_url) { |
| 4283 | // Prepare list to storage all savable resource links. |
| 4284 | std::vector<GURL> resources_list; |
| 4285 | std::vector<GURL> referrers_list; |
| 4286 | std::vector<GURL> frames_list; |
| 4287 | webkit_glue::SavableResourcesResult result(&resources_list, |
| 4288 | &referrers_list, |
| 4289 | &frames_list); |
| 4290 | |
[email protected] | 445e104 | 2011-12-03 21:03:15 | [diff] [blame] | 4291 | // FIXME(rdsmith): When GetAllSavableResourceLinksForCurrentPage starts to |
| 4292 | // return referrers, it should also return the referrer policies. |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4293 | if (!webkit_glue::GetAllSavableResourceLinksForCurrentPage( |
| 4294 | webview(), |
| 4295 | page_url, |
| 4296 | &result, |
[email protected] | 0a35efc | 2012-03-13 17:28:13 | [diff] [blame] | 4297 | content::GetSavableSchemes())) { |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4298 | // If something is wrong when collecting all savable resource links, |
| 4299 | // send empty list to embedder(browser) to tell it failed. |
| 4300 | referrers_list.clear(); |
| 4301 | resources_list.clear(); |
| 4302 | frames_list.clear(); |
| 4303 | } |
| 4304 | |
| 4305 | // Send result of all savable resource links to embedder. |
| 4306 | Send(new ViewHostMsg_SendCurrentPageAllSavableResourceLinks(routing_id(), |
| 4307 | resources_list, |
| 4308 | referrers_list, |
| 4309 | frames_list)); |
| 4310 | } |
| 4311 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4312 | void RenderViewImpl::OnGetSerializedHtmlDataForCurrentPageWithLocalLinks( |
[email protected] | 18d5be9 | 2011-07-25 18:00:19 | [diff] [blame] | 4313 | const std::vector<GURL>& links, |
| 4314 | const std::vector<FilePath>& local_paths, |
| 4315 | const FilePath& local_directory_name) { |
| 4316 | |
| 4317 | // Convert std::vector of GURLs to WebVector<WebURL> |
| 4318 | WebVector<WebURL> weburl_links(links); |
| 4319 | |
| 4320 | // Convert std::vector of std::strings to WebVector<WebString> |
| 4321 | WebVector<WebString> webstring_paths(local_paths.size()); |
| 4322 | for (size_t i = 0; i < local_paths.size(); i++) |
| 4323 | webstring_paths[i] = webkit_glue::FilePathToWebString(local_paths[i]); |
| 4324 | |
| 4325 | WebPageSerializer::serialize(webview()->mainFrame(), true, this, weburl_links, |
| 4326 | webstring_paths, |
| 4327 | webkit_glue::FilePathToWebString( |
| 4328 | local_directory_name)); |
| 4329 | } |
| 4330 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4331 | void RenderViewImpl::OnShouldClose() { |
[email protected] | 7a17bac0 | 2012-03-07 21:58:12 | [diff] [blame] | 4332 | base::TimeTicks before_unload_start_time = base::TimeTicks::Now(); |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4333 | bool should_close = webview()->dispatchBeforeUnloadEvent(); |
[email protected] | 7a17bac0 | 2012-03-07 21:58:12 | [diff] [blame] | 4334 | base::TimeTicks before_unload_end_time = base::TimeTicks::Now(); |
| 4335 | Send(new ViewHostMsg_ShouldClose_ACK(routing_id_, should_close, |
| 4336 | before_unload_start_time, |
| 4337 | before_unload_end_time)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4338 | } |
| 4339 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4340 | void RenderViewImpl::OnSwapOut(const ViewMsg_SwapOut_Params& params) { |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 4341 | // Ensure that no other in-progress navigation continues. |
| 4342 | OnStop(); |
| 4343 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 4344 | // Only run unload if we're not swapped out yet, but send the ack either way. |
| 4345 | if (!is_swapped_out_) { |
| 4346 | // Swap this RenderView out so the tab can navigate to a page rendered by a |
| 4347 | // different process. This involves running the unload handler and clearing |
| 4348 | // the page. Once WasSwappedOut is called, we also allow this process to |
| 4349 | // exit if there are no other active RenderViews in it. |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 4350 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 4351 | // Send an UpdateState message before we get swapped out. |
| 4352 | SyncNavigationState(); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 4353 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 4354 | // Synchronously run the unload handler before sending the ACK. |
| 4355 | webview()->dispatchUnloadEvent(); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 4356 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 4357 | // Swap out and stop sending any IPC messages that are not ACKs. |
| 4358 | SetSwappedOut(true); |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 4359 | |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 4360 | // Replace the page with a blank dummy URL. The unload handler will not be |
| 4361 | // run a second time, thanks to a check in FrameLoader::stopLoading. |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 4362 | // We use loadRequest instead of loadHTMLString because the former commits |
| 4363 | // synchronously. Otherwise a new navigation can interrupt the navigation |
| 4364 | // to about:swappedout. If that happens to be to the page we had been |
| 4365 | // showing, then WebKit will never send a commit and we'll be left spinning. |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 4366 | // TODO(creis): Need to add a better way to do this that avoids running the |
| 4367 | // beforeunload handler. For now, we just run it a second time silently. |
[email protected] | 69ddf85 | 2012-02-21 23:21:31 | [diff] [blame] | 4368 | WebURLRequest request(GURL("about:swappedout")); |
| 4369 | webview()->mainFrame()->loadRequest(request); |
[email protected] | 73eb260 | 2012-02-09 19:50:55 | [diff] [blame] | 4370 | } |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 4371 | |
| 4372 | // Just echo back the params in the ACK. |
| 4373 | Send(new ViewHostMsg_SwapOut_ACK(routing_id_, params)); |
| 4374 | } |
| 4375 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4376 | void RenderViewImpl::OnClosePage() { |
[email protected] | 77fc9b9 | 2011-10-15 16:20:37 | [diff] [blame] | 4377 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, ClosePage()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4378 | // TODO(creis): We'd rather use webview()->Close() here, but that currently |
| 4379 | // sets the WebView's delegate_ to NULL, preventing any JavaScript dialogs |
| 4380 | // in the onunload handler from appearing. For now, we're bypassing that and |
| 4381 | // calling the FrameLoader's CloseURL method directly. This should be |
| 4382 | // revisited to avoid having two ways to close a page. Having a single way |
| 4383 | // to close that can run onunload is also useful for fixing |
| 4384 | // http://b/issue?id=753080. |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4385 | webview()->dispatchUnloadEvent(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4386 | |
[email protected] | 992db4c | 2011-05-12 15:37:15 | [diff] [blame] | 4387 | Send(new ViewHostMsg_ClosePage_ACK(routing_id_)); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4388 | } |
| 4389 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4390 | void RenderViewImpl::OnThemeChanged() { |
[email protected] | e8d6b9f | 2011-10-10 22:21:02 | [diff] [blame] | 4391 | #if defined(USE_AURA) |
| 4392 | // Aura doesn't care if we switch themes. |
| 4393 | #elif defined(OS_WIN) |
[email protected] | c6d94221 | 2011-03-30 19:02:16 | [diff] [blame] | 4394 | gfx::NativeThemeWin::instance()->CloseHandles(); |
[email protected] | f98d7e3c | 2010-09-13 22:30:46 | [diff] [blame] | 4395 | if (webview()) |
| 4396 | webview()->themeChanged(); |
[email protected] | 6c8afae5 | 2009-01-22 02:24:57 | [diff] [blame] | 4397 | #else // defined(OS_WIN) |
| 4398 | // TODO(port): we don't support theming on non-Windows platforms yet |
| 4399 | NOTIMPLEMENTED(); |
| 4400 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4401 | } |
| 4402 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4403 | void RenderViewImpl::OnDisassociateFromPopupCount() { |
[email protected] | 0aa5531 | 2008-10-17 21:53:08 | [diff] [blame] | 4404 | if (decrement_shared_popup_at_destruction_) |
| 4405 | shared_popup_counter_->data--; |
| 4406 | shared_popup_counter_ = new SharedRenderViewCounter(0); |
| 4407 | decrement_shared_popup_at_destruction_ = false; |
| 4408 | } |
| 4409 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4410 | bool RenderViewImpl::MaybeLoadAlternateErrorPage(WebFrame* frame, |
| 4411 | const WebURLError& error, |
| 4412 | bool replace) { |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4413 | // We only show alternate error pages in the main frame. They are |
| 4414 | // intended to assist the user when navigating, so there is not much |
| 4415 | // value in showing them for failed subframes. Ideally, we would be |
| 4416 | // able to use the TYPED transition type for this, but that flag is |
| 4417 | // not preserved across page reloads. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4418 | if (frame->parent()) |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4419 | return false; |
| 4420 | |
| 4421 | // Use the alternate error page service if this is a DNS failure or |
[email protected] | c53976d5 | 2009-08-07 18:58:37 | [diff] [blame] | 4422 | // connection failure. |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4423 | int ec = error.reason; |
| 4424 | if (ec != net::ERR_NAME_NOT_RESOLVED && |
| 4425 | ec != net::ERR_CONNECTION_FAILED && |
| 4426 | ec != net::ERR_CONNECTION_REFUSED && |
| 4427 | ec != net::ERR_ADDRESS_UNREACHABLE && |
[email protected] | c53976d5 | 2009-08-07 18:58:37 | [diff] [blame] | 4428 | ec != net::ERR_CONNECTION_TIMED_OUT) |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4429 | return false; |
| 4430 | |
| 4431 | const GURL& error_page_url = GetAlternateErrorPageURL(error.unreachableURL, |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 4432 | ec == net::ERR_NAME_NOT_RESOLVED ? DNS_ERROR : CONNECTION_ERROR); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4433 | if (!error_page_url.is_valid()) |
| 4434 | return false; |
| 4435 | |
| 4436 | // Load an empty page first so there is an immediate response to the error, |
| 4437 | // and then kick off a request for the alternate error page. |
[email protected] | dd7daa8 | 2009-08-10 05:46:45 | [diff] [blame] | 4438 | frame->loadHTMLString(std::string(), |
[email protected] | 144143c | 2010-10-28 08:17:36 | [diff] [blame] | 4439 | GURL(chrome::kUnreachableWebDataURL), |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4440 | error.unreachableURL, |
| 4441 | replace); |
| 4442 | |
| 4443 | // Now, create a fetcher for the error page and associate it with the data |
| 4444 | // source we just created via the LoadHTMLString call. That way if another |
| 4445 | // navigation occurs, the fetcher will get destroyed. |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 4446 | DocumentState* document_state = |
| 4447 | DocumentState::FromDataSource(frame->provisionalDataSource()); |
| 4448 | document_state->set_alt_error_page_fetcher( |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4449 | new AltErrorPageResourceFetcher( |
| 4450 | error_page_url, frame, error, |
[email protected] | 6e80682 | 2011-11-19 01:51:08 | [diff] [blame] | 4451 | base::Bind(&RenderViewImpl::AltErrorPageFinished, |
| 4452 | base::Unretained(this)))); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4453 | return true; |
| 4454 | } |
| 4455 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4456 | void RenderViewImpl::AltErrorPageFinished(WebFrame* frame, |
| 4457 | const WebURLError& original_error, |
| 4458 | const std::string& html) { |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4459 | // Here, we replace the blank page we loaded previously. |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 4460 | // If we failed to download the alternate error page, LoadNavigationErrorPage |
[email protected] | 7ccddb8c | 2009-08-04 17:36:55 | [diff] [blame] | 4461 | // will simply display a default error page. |
[email protected] | 06333afe | 2011-02-24 14:55:09 | [diff] [blame] | 4462 | LoadNavigationErrorPage(frame, WebURLRequest(), original_error, html, true); |
[email protected] | 15d79e1 | 2009-08-02 19:23:45 | [diff] [blame] | 4463 | } |
| 4464 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4465 | void RenderViewImpl::OnMoveOrResizeStarted() { |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 4466 | if (webview()) |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 4467 | webview()->hidePopups(); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 4468 | } |
| 4469 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4470 | void RenderViewImpl::OnResize(const gfx::Size& new_size, |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 4471 | const gfx::Rect& resizer_rect, |
| 4472 | bool is_fullscreen) { |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4473 | if (webview()) { |
[email protected] | 7ddea980 | 2012-02-22 23:08:05 | [diff] [blame] | 4474 | // This setting has no effect if fixed layout is not enabled. |
[email protected] | 43d9d78 | 2012-03-01 15:40:09 | [diff] [blame] | 4475 | if (webkit_preferences_.default_device_scale_factor) |
[email protected] | 7ddea980 | 2012-02-22 23:08:05 | [diff] [blame] | 4476 | webview()->settings()->setLayoutFallbackWidth( |
[email protected] | 43d9d78 | 2012-03-01 15:40:09 | [diff] [blame] | 4477 | new_size.width() / webkit_preferences_.default_device_scale_factor); |
[email protected] | a72a1fa | 2010-05-03 22:18:47 | [diff] [blame] | 4478 | webview()->hidePopups(); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4479 | if (send_preferred_size_changes_) { |
[email protected] | 7339cd2 | 2010-10-27 00:11:20 | [diff] [blame] | 4480 | webview()->mainFrame()->setCanHaveScrollbars( |
[email protected] | a2ef54c | 2011-10-10 16:20:31 | [diff] [blame] | 4481 | ShouldDisplayScrollbars(new_size.width(), new_size.height())); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4482 | } |
[email protected] | dd6afca | 2011-08-13 03:44:31 | [diff] [blame] | 4483 | UpdateScrollState(webview()->mainFrame()); |
[email protected] | cda45c0 | 2010-02-25 19:28:10 | [diff] [blame] | 4484 | } |
| 4485 | |
[email protected] | ee41e7d2 | 2011-10-14 19:34:09 | [diff] [blame] | 4486 | RenderWidget::OnResize(new_size, resizer_rect, is_fullscreen); |
[email protected] | 30f75e6 | 2009-02-25 22:01:00 | [diff] [blame] | 4487 | } |
[email protected] | 0aa477bd | 2009-03-23 22:21:43 | [diff] [blame] | 4488 | |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 4489 | void RenderViewImpl::WillInitiatePaint() { |
| 4490 | // Notify the pepper plugins that we're about to paint. |
| 4491 | pepper_delegate_.ViewWillInitiatePaint(); |
| 4492 | } |
| 4493 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4494 | void RenderViewImpl::DidInitiatePaint() { |
[email protected] | 29ed96a | 2012-02-04 18:12:16 | [diff] [blame] | 4495 | // Notify the pepper plugins that we've painted, and are waiting to flush. |
[email protected] | 53900d5 | 2010-06-16 04:25:01 | [diff] [blame] | 4496 | pepper_delegate_.ViewInitiatedPaint(); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4497 | } |
| 4498 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4499 | void RenderViewImpl::DidFlushPaint() { |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4500 | // Notify any pepper plugins that we painted. This will call into the plugin, |
| 4501 | // and we it may ask to close itself as a result. This will, in turn, modify |
| 4502 | // our set, possibly invalidating the iterator. So we iterate on a copy that |
| 4503 | // won't change out from under us. |
[email protected] | 53900d5 | 2010-06-16 04:25:01 | [diff] [blame] | 4504 | pepper_delegate_.ViewFlushedPaint(); |
| 4505 | |
[email protected] | 5b1dec8c | 2012-02-07 04:35:38 | [diff] [blame] | 4506 | // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
| 4507 | // See crbug.com/112921. |
| 4508 | if (!webview()) |
| 4509 | return; |
| 4510 | |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4511 | WebFrame* main_frame = webview()->mainFrame(); |
| 4512 | |
| 4513 | // If we have a provisional frame we are between the start and commit stages |
| 4514 | // of loading and we don't want to save stats. |
| 4515 | if (!main_frame->provisionalDataSource()) { |
| 4516 | WebDataSource* ds = main_frame->dataSource(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 4517 | DocumentState* document_state = DocumentState::FromDataSource(ds); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4518 | |
[email protected] | 05c8e50 | 2010-08-15 15:13:52 | [diff] [blame] | 4519 | // TODO(jar): The following code should all be inside a method, probably in |
| 4520 | // NavigatorState. |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4521 | Time now = Time::Now(); |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 4522 | if (document_state->first_paint_time().is_null()) { |
| 4523 | document_state->set_first_paint_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4524 | } |
[email protected] | 007733c | 2011-11-17 00:34:07 | [diff] [blame] | 4525 | if (document_state->first_paint_after_load_time().is_null() && |
| 4526 | !document_state->finish_load_time().is_null()) { |
| 4527 | document_state->set_first_paint_after_load_time(now); |
[email protected] | 00c3961 | 2010-03-06 02:53:28 | [diff] [blame] | 4528 | } |
| 4529 | } |
| 4530 | } |
| 4531 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4532 | void RenderViewImpl::OnViewContextSwapBuffersPosted() { |
[email protected] | 37a6f30 | 2011-07-11 23:43:08 | [diff] [blame] | 4533 | RenderWidget::OnSwapBuffersPosted(); |
| 4534 | } |
| 4535 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4536 | void RenderViewImpl::OnViewContextSwapBuffersComplete() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 4537 | RenderWidget::OnSwapBuffersComplete(); |
| 4538 | } |
| 4539 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4540 | void RenderViewImpl::OnViewContextSwapBuffersAborted() { |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 4541 | RenderWidget::OnSwapBuffersAborted(); |
| 4542 | } |
| 4543 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4544 | webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint( |
[email protected] | ca4847f | 2010-09-24 05:39:15 | [diff] [blame] | 4545 | const gfx::Rect& paint_bounds, |
| 4546 | TransportDIB** dib, |
| 4547 | gfx::Rect* location, |
| 4548 | gfx::Rect* clip) { |
| 4549 | return pepper_delegate_.GetBitmapForOptimizedPluginPaint( |
| 4550 | paint_bounds, dib, location, clip); |
| 4551 | } |
| 4552 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4553 | gfx::Point RenderViewImpl::GetScrollOffset() { |
[email protected] | d812fd1 | 2011-05-27 23:05:07 | [diff] [blame] | 4554 | WebSize scroll_offset = webview()->mainFrame()->scrollOffset(); |
[email protected] | bcaf227 | 2011-02-15 15:29:43 | [diff] [blame] | 4555 | return gfx::Point(scroll_offset.width, scroll_offset.height); |
[email protected] | d54169e9 | 2011-01-21 09:19:52 | [diff] [blame] | 4556 | } |
| 4557 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4558 | void RenderViewImpl::OnClearFocusedNode() { |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 4559 | if (webview()) |
[email protected] | 26aa048 | 2009-09-30 16:55:27 | [diff] [blame] | 4560 | webview()->clearFocusedNode(); |
[email protected] | 05d47875 | 2009-04-08 23:38:16 | [diff] [blame] | 4561 | } |
| 4562 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4563 | void RenderViewImpl::OnSetBackground(const SkBitmap& background) { |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 4564 | if (webview()) |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 4565 | webview()->setIsTransparent(!background.empty()); |
[email protected] | 699ab0d | 2009-04-23 23:19:14 | [diff] [blame] | 4566 | |
| 4567 | SetBackground(background); |
| 4568 | } |
| 4569 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4570 | void RenderViewImpl::OnSetActive(bool active) { |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 4571 | if (webview()) |
[email protected] | b4bb250 | 2009-10-01 22:35:27 | [diff] [blame] | 4572 | webview()->setIsActive(active); |
[email protected] | d8fd6fa | 2010-02-01 15:54:26 | [diff] [blame] | 4573 | |
| 4574 | #if defined(OS_MACOSX) |
| 4575 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4576 | for (plugin_it = plugin_delegates_.begin(); |
| 4577 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4578 | (*plugin_it)->SetWindowFocus(active); |
| 4579 | } |
| 4580 | #endif |
[email protected] | 8c66c5a | 2009-07-22 17:26:34 | [diff] [blame] | 4581 | } |
| 4582 | |
[email protected] | 7a17bac0 | 2012-03-07 21:58:12 | [diff] [blame] | 4583 | void RenderViewImpl::OnSetNavigationStartTime( |
| 4584 | const base::TimeTicks& browser_navigation_start) { |
| 4585 | if (!webview()) |
| 4586 | return; |
| 4587 | |
| 4588 | // Only the initial navigation can be a cross-renderer navigation. If we've |
| 4589 | // already navigated away from that page, we can ignore this message. |
| 4590 | if (page_id_ != -1) |
| 4591 | return; |
| 4592 | |
| 4593 | // browser_navigation_start is likely before this process existed, so we can't |
| 4594 | // use InterProcessTimeTicksConverter. Instead, the best we can do is just |
| 4595 | // ensure we don't report a bogus value in the future. |
| 4596 | base::TimeTicks navigation_start = std::min(base::TimeTicks::Now(), |
| 4597 | browser_navigation_start); |
| 4598 | webview()->mainFrame()->provisionalDataSource()->setNavigationStartTime( |
| 4599 | (navigation_start - base::TimeTicks()).InSecondsF()); |
| 4600 | } |
| 4601 | |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 4602 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4603 | void RenderViewImpl::OnSetWindowVisibility(bool visible) { |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 4604 | // Inform plugins that their container has changed visibility. |
| 4605 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4606 | for (plugin_it = plugin_delegates_.begin(); |
| 4607 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4608 | (*plugin_it)->SetContainerVisibility(visible); |
| 4609 | } |
| 4610 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4611 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4612 | void RenderViewImpl::OnWindowFrameChanged(const gfx::Rect& window_frame, |
| 4613 | const gfx::Rect& view_frame) { |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4614 | // Inform plugins that their window's frame has changed. |
| 4615 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4616 | for (plugin_it = plugin_delegates_.begin(); |
| 4617 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4618 | (*plugin_it)->WindowFrameChanged(window_frame, view_frame); |
| 4619 | } |
| 4620 | } |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 4621 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4622 | void RenderViewImpl::OnPluginImeCompositionCompleted(const string16& text, |
| 4623 | int plugin_id) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 4624 | // WebPluginDelegateProxy is responsible for figuring out if this event |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 4625 | // applies to it or not, so inform all the delegates. |
| 4626 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4627 | for (plugin_it = plugin_delegates_.begin(); |
| 4628 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 4629 | (*plugin_it)->ImeCompositionCompleted(text, plugin_id); |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 4630 | } |
| 4631 | } |
[email protected] | 6ce7abc5 | 2010-02-02 18:40:14 | [diff] [blame] | 4632 | #endif // OS_MACOSX |
| 4633 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4634 | void RenderViewImpl::OnSetEditCommandsForNextKeyEvent( |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 4635 | const EditCommands& edit_commands) { |
| 4636 | edit_commands_ = edit_commands; |
| 4637 | } |
| 4638 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4639 | void RenderViewImpl::Close() { |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 4640 | // We need to grab a pointer to the doomed WebView before we destroy it. |
| 4641 | WebView* doomed = webview(); |
| 4642 | RenderWidget::Close(); |
[email protected] | 625332e0 | 2010-12-14 07:48:49 | [diff] [blame] | 4643 | g_view_map.Get().erase(doomed); |
[email protected] | 60c42a8c7 | 2009-10-09 04:08:59 | [diff] [blame] | 4644 | } |
| 4645 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4646 | void RenderViewImpl::DidHandleKeyEvent() { |
[email protected] | 44670587 | 2009-09-10 07:22:48 | [diff] [blame] | 4647 | edit_commands_.clear(); |
| 4648 | } |
| 4649 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4650 | bool RenderViewImpl::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
[email protected] | 217690d | 2012-01-27 07:33:11 | [diff] [blame] | 4651 | pepper_delegate_.WillHandleMouseEvent(); |
| 4652 | |
| 4653 | // If the mouse is locked, only the current owner of the mouse lock can |
| 4654 | // process mouse events. |
| 4655 | return mouse_lock_dispatcher_->WillHandleMouseEvent(event); |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 4656 | } |
| 4657 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4658 | void RenderViewImpl::DidHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 4659 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleMouseEvent(event)); |
[email protected] | 6a8ddba5 | 2010-09-05 04:38:06 | [diff] [blame] | 4660 | } |
| 4661 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4662 | void RenderViewImpl::DidHandleTouchEvent(const WebTouchEvent& event) { |
[email protected] | 2d0f2e9 | 2011-10-03 09:02:24 | [diff] [blame] | 4663 | FOR_EACH_OBSERVER(RenderViewObserver, observers_, DidHandleTouchEvent(event)); |
| 4664 | } |
| 4665 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4666 | void RenderViewImpl::OnWasHidden() { |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4667 | RenderWidget::OnWasHidden(); |
| 4668 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4669 | if (webview()) { |
| 4670 | webview()->settings()->setMinimumTimerInterval( |
| 4671 | webkit_glue::kBackgroundTabTimerInterval); |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 4672 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4673 | } |
| 4674 | |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 4675 | // Inform PPAPI plugins that their page is no longer visible. |
| 4676 | pepper_delegate_.PageVisibilityChanged(false); |
| 4677 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4678 | #if defined(OS_MACOSX) |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 4679 | // Inform NPAPI plugins that their container is no longer visible. |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4680 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4681 | for (plugin_it = plugin_delegates_.begin(); |
| 4682 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4683 | (*plugin_it)->SetContainerVisibility(false); |
| 4684 | } |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4685 | #endif // OS_MACOSX |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4686 | } |
| 4687 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4688 | void RenderViewImpl::OnWasRestored(bool needs_repainting) { |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4689 | RenderWidget::OnWasRestored(needs_repainting); |
| 4690 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4691 | if (webview()) { |
| 4692 | webview()->settings()->setMinimumTimerInterval( |
| 4693 | webkit_glue::kForegroundTabTimerInterval); |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 4694 | webview()->setVisibilityState(visibilityState(), false); |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4695 | } |
| 4696 | |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 4697 | // Inform PPAPI plugins that their page is visible. |
| 4698 | pepper_delegate_.PageVisibilityChanged(true); |
| 4699 | |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4700 | #if defined(OS_MACOSX) |
[email protected] | 204f1df | 2012-01-04 20:21:13 | [diff] [blame] | 4701 | // Inform NPAPI plugins that their container is now visible. |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4702 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4703 | for (plugin_it = plugin_delegates_.begin(); |
| 4704 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
| 4705 | (*plugin_it)->SetContainerVisibility(true); |
| 4706 | } |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 4707 | #endif // OS_MACOSX |
[email protected] | a6939ca4 | 2011-02-18 17:58:07 | [diff] [blame] | 4708 | } |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4709 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4710 | bool RenderViewImpl::SupportsAsynchronousSwapBuffers() { |
[email protected] | 555e75d | 2011-10-08 01:23:38 | [diff] [blame] | 4711 | if (WebWidgetHandlesCompositorScheduling()) |
| 4712 | return false; |
| 4713 | |
[email protected] | 05a980d7a | 2012-02-07 22:16:42 | [diff] [blame] | 4714 | if (queried_for_swapbuffers_complete_callback_) |
| 4715 | return context_has_swapbuffers_complete_callback_; |
| 4716 | |
| 4717 | queried_for_swapbuffers_complete_callback_ = true; |
| 4718 | |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 4719 | WebKit::WebGraphicsContext3D* context = webview()->graphicsContext3D(); |
[email protected] | 05a980d7a | 2012-02-07 22:16:42 | [diff] [blame] | 4720 | if (context && context->makeContextCurrent()) { |
| 4721 | std::string extensions(context->getRequestableExtensionsCHROMIUM().utf8()); |
| 4722 | context_has_swapbuffers_complete_callback_ = |
| 4723 | extensions.find("GL_CHROMIUM_swapbuffers_complete_callback") |
| 4724 | != std::string::npos; |
| 4725 | } |
| 4726 | |
| 4727 | return context_has_swapbuffers_complete_callback_; |
[email protected] | 6522577 | 2011-05-12 21:10:24 | [diff] [blame] | 4728 | } |
| 4729 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4730 | void RenderViewImpl::OnSetFocus(bool enable) { |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4731 | RenderWidget::OnSetFocus(enable); |
| 4732 | |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 4733 | if (webview() && webview()->isActive()) { |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 4734 | // Notify all NPAPI plugins. |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4735 | std::set<WebPluginDelegateProxy*>::iterator plugin_it; |
| 4736 | for (plugin_it = plugin_delegates_.begin(); |
| 4737 | plugin_it != plugin_delegates_.end(); ++plugin_it) { |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 4738 | #if defined(OS_MACOSX) |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 4739 | // RenderWidget's call to setFocus can cause the underlying webview's |
| 4740 | // activation state to change just like a call to setIsActive. |
| 4741 | if (enable) |
| 4742 | (*plugin_it)->SetWindowFocus(true); |
[email protected] | 784ea1ab | 2010-09-18 00:02:34 | [diff] [blame] | 4743 | #endif |
[email protected] | 7d3c02c | 2010-05-05 23:10:31 | [diff] [blame] | 4744 | (*plugin_it)->SetContentAreaFocus(enable); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4745 | } |
[email protected] | 589621b | 2010-09-23 22:01:07 | [diff] [blame] | 4746 | |
| 4747 | // Notify all Pepper plugins. |
| 4748 | pepper_delegate_.OnSetFocus(enable); |
[email protected] | 1e6e3c99 | 2010-02-08 15:52:13 | [diff] [blame] | 4749 | } |
| 4750 | } |
[email protected] | 941e455 | 2010-02-01 21:23:43 | [diff] [blame] | 4751 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4752 | void RenderViewImpl::PpapiPluginFocusChanged() { |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4753 | UpdateTextInputState(); |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 4754 | UpdateSelectionBounds(); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4755 | } |
| 4756 | |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4757 | void RenderViewImpl::PpapiPluginTextInputTypeChanged() { |
[email protected] | e99ef6f | 2011-10-16 01:13:00 | [diff] [blame] | 4758 | UpdateTextInputState(); |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4759 | } |
| 4760 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 4761 | void RenderViewImpl::PpapiPluginCaretPositionChanged() { |
| 4762 | UpdateSelectionBounds(); |
| 4763 | } |
| 4764 | |
[email protected] | b25b3ee | 2012-01-13 05:19:54 | [diff] [blame] | 4765 | bool RenderViewImpl::GetPpapiPluginCaretBounds(gfx::Rect* rect) { |
| 4766 | if (!pepper_delegate_.IsPluginFocused()) |
| 4767 | return false; |
| 4768 | *rect = pepper_delegate_.GetCaretBounds(); |
| 4769 | return true; |
| 4770 | } |
| 4771 | |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4772 | void RenderViewImpl::PpapiPluginCancelComposition() { |
| 4773 | Send(new ViewHostMsg_ImeCancelComposition(routing_id())); |
| 4774 | ui::Range range(ui::Range::InvalidRange()); |
| 4775 | Send(new ViewHostMsg_ImeCompositionRangeChanged(routing_id(), range)); |
| 4776 | } |
| 4777 | |
[email protected] | 3c8c74c | 2012-03-15 07:34:52 | [diff] [blame^] | 4778 | void RenderViewImpl::PpapiPluginSelectionChanged() { |
| 4779 | SyncSelectionIfRequired(); |
| 4780 | } |
| 4781 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4782 | void RenderViewImpl::OnImeSetComposition( |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4783 | const string16& text, |
| 4784 | const std::vector<WebKit::WebCompositionUnderline>& underlines, |
| 4785 | int selection_start, |
| 4786 | int selection_end) { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4787 | if (pepper_delegate_.IsPluginFocused()) { |
| 4788 | // When a PPAPI plugin has focus, we bypass WebKit. |
| 4789 | pepper_delegate_.OnImeSetComposition(text, |
| 4790 | underlines, |
| 4791 | selection_start, |
| 4792 | selection_end); |
| 4793 | } else { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4794 | #if defined(OS_WIN) |
| 4795 | // When a plug-in has focus, we create platform-specific IME data used by |
| 4796 | // our IME emulator and send it directly to the focused plug-in, i.e. we |
| 4797 | // bypass WebKit. (WebPluginDelegate dispatches this IME data only when its |
| 4798 | // instance ID is the same one as the specified ID.) |
| 4799 | if (focused_plugin_id_ >= 0) { |
| 4800 | std::vector<int> clauses; |
| 4801 | std::vector<int> target; |
| 4802 | for (size_t i = 0; i < underlines.size(); ++i) { |
| 4803 | clauses.push_back(underlines[i].startOffset); |
| 4804 | clauses.push_back(underlines[i].endOffset); |
| 4805 | if (underlines[i].thick) { |
| 4806 | target.clear(); |
| 4807 | target.push_back(underlines[i].startOffset); |
| 4808 | target.push_back(underlines[i].endOffset); |
| 4809 | } |
| 4810 | } |
| 4811 | std::set<WebPluginDelegateProxy*>::iterator it; |
| 4812 | for (it = plugin_delegates_.begin(); |
| 4813 | it != plugin_delegates_.end(); ++it) { |
| 4814 | (*it)->ImeCompositionUpdated(text, clauses, target, selection_end, |
| 4815 | focused_plugin_id_); |
| 4816 | } |
| 4817 | return; |
| 4818 | } |
| 4819 | #endif |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4820 | RenderWidget::OnImeSetComposition(text, |
| 4821 | underlines, |
| 4822 | selection_start, |
| 4823 | selection_end); |
| 4824 | } |
| 4825 | } |
| 4826 | |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 4827 | void RenderViewImpl::OnImeConfirmComposition( |
| 4828 | const string16& text, const ui::Range& replacement_range) { |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4829 | if (pepper_delegate_.IsPluginFocused()) { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4830 | // When a PPAPI plugin has focus, we bypass WebKit. |
| 4831 | pepper_delegate_.OnImeConfirmComposition(text); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4832 | } else { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4833 | #if defined(OS_WIN) |
| 4834 | // Same as OnImeSetComposition(), we send the text from IMEs directly to |
| 4835 | // plug-ins. When we send IME text directly to plug-ins, we should not send |
| 4836 | // it to WebKit to prevent WebKit from controlling IMEs. |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 4837 | // TODO(thakis): Honor |replacement_range| for plugins? |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4838 | if (focused_plugin_id_ >= 0) { |
| 4839 | std::set<WebPluginDelegateProxy*>::iterator it; |
| 4840 | for (it = plugin_delegates_.begin(); |
| 4841 | it != plugin_delegates_.end(); ++it) { |
| 4842 | (*it)->ImeCompositionCompleted(text, focused_plugin_id_); |
| 4843 | } |
| 4844 | return; |
| 4845 | } |
| 4846 | #endif |
[email protected] | ebd28ac | 2011-10-13 18:49:05 | [diff] [blame] | 4847 | if (replacement_range.IsValid() && webview()) { |
| 4848 | // Select the text in |replacement_range|, it will then be replaced by |
| 4849 | // text added by the call to RenderWidget::OnImeConfirmComposition(). |
| 4850 | if (WebFrame* frame = webview()->focusedFrame()) { |
[email protected] | 4bacb82 | 2011-11-02 15:10:16 | [diff] [blame] | 4851 | WebRange webrange = WebRange::fromDocumentRange( |
| 4852 | frame, replacement_range.start(), replacement_range.length()); |
| 4853 | if (!webrange.isNull()) |
| 4854 | frame->setSelectionToRange(webrange); |
[email protected] | ebd28ac | 2011-10-13 18:49:05 | [diff] [blame] | 4855 | } |
| 4856 | } |
[email protected] | 4de6d169 | 2011-10-12 08:45:44 | [diff] [blame] | 4857 | RenderWidget::OnImeConfirmComposition(text, replacement_range); |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4858 | } |
| 4859 | } |
| 4860 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4861 | ui::TextInputType RenderViewImpl::GetTextInputType() { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4862 | return pepper_delegate_.IsPluginFocused() ? |
| 4863 | pepper_delegate_.GetTextInputType() : RenderWidget::GetTextInputType(); |
| 4864 | } |
| 4865 | |
[email protected] | 3f78336 | 2011-10-21 22:40:50 | [diff] [blame] | 4866 | void RenderViewImpl::GetSelectionBounds(gfx::Rect* start, gfx::Rect* end) { |
| 4867 | if (pepper_delegate_.IsPluginFocused()) { |
| 4868 | // TODO(kinaba) http://crbug.com/101101 |
| 4869 | // Current Pepper IME API does not handle selection bounds. So we simply |
| 4870 | // use the caret position as an empty range for now. It will be updated |
| 4871 | // after Pepper API equips features related to surrounding text retrieval. |
| 4872 | gfx::Rect caret = pepper_delegate_.GetCaretBounds(); |
| 4873 | *start = caret; |
| 4874 | *end = caret; |
| 4875 | return; |
| 4876 | } |
| 4877 | RenderWidget::GetSelectionBounds(start, end); |
[email protected] | ad26ef4 | 2011-06-17 07:59:45 | [diff] [blame] | 4878 | } |
| 4879 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4880 | bool RenderViewImpl::CanComposeInline() { |
[email protected] | 73bf9581 | 2011-10-12 11:38:32 | [diff] [blame] | 4881 | return pepper_delegate_.IsPluginFocused() ? |
| 4882 | pepper_delegate_.CanComposeInline() : true; |
[email protected] | 56ea1a6 | 2011-05-30 07:05:57 | [diff] [blame] | 4883 | } |
| 4884 | |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4885 | #if defined(OS_WIN) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4886 | void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
[email protected] | e6ae0f6c | 2011-10-04 10:39:23 | [diff] [blame] | 4887 | if (focused) |
| 4888 | focused_plugin_id_ = plugin_id; |
| 4889 | else |
| 4890 | focused_plugin_id_ = -1; |
| 4891 | } |
| 4892 | #endif |
| 4893 | |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4894 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4895 | void RenderViewImpl::PluginFocusChanged(bool focused, int plugin_id) { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 4896 | IPC::Message* msg = new ViewHostMsg_PluginFocusChanged(routing_id(), |
| 4897 | focused, plugin_id); |
| 4898 | Send(msg); |
| 4899 | } |
| 4900 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4901 | void RenderViewImpl::StartPluginIme() { |
[email protected] | b7f7586 | 2011-01-21 21:15:13 | [diff] [blame] | 4902 | IPC::Message* msg = new ViewHostMsg_StartPluginIme(routing_id()); |
[email protected] | 935d63d | 2010-10-15 23:31:55 | [diff] [blame] | 4903 | // This message can be sent during event-handling, and needs to be delivered |
| 4904 | // within that context. |
| 4905 | msg->set_unblock(true); |
| 4906 | Send(msg); |
| 4907 | } |
| 4908 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4909 | gfx::PluginWindowHandle RenderViewImpl::AllocateFakePluginWindowHandle( |
[email protected] | 77e74db | 2010-08-04 17:46:23 | [diff] [blame] | 4910 | bool opaque, bool root) { |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4911 | gfx::PluginWindowHandle window = NULL; |
| 4912 | Send(new ViewHostMsg_AllocateFakePluginWindowHandle( |
[email protected] | 77e74db | 2010-08-04 17:46:23 | [diff] [blame] | 4913 | routing_id(), opaque, root, &window)); |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 4914 | if (window) { |
| 4915 | fake_plugin_window_handles_.insert(window); |
| 4916 | } |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4917 | return window; |
| 4918 | } |
| 4919 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4920 | void RenderViewImpl::DestroyFakePluginWindowHandle( |
| 4921 | gfx::PluginWindowHandle window) { |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 4922 | if (window && fake_plugin_window_handles_.find(window) != |
| 4923 | fake_plugin_window_handles_.end()) { |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4924 | Send(new ViewHostMsg_DestroyFakePluginWindowHandle(routing_id(), window)); |
[email protected] | c36a9b6 | 2010-10-14 00:41:11 | [diff] [blame] | 4925 | fake_plugin_window_handles_.erase(window); |
| 4926 | } |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4927 | } |
| 4928 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4929 | void RenderViewImpl::AcceleratedSurfaceSetIOSurface( |
| 4930 | gfx::PluginWindowHandle window, |
| 4931 | int32 width, |
| 4932 | int32 height, |
| 4933 | uint64 io_surface_identifier) { |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 4934 | Send(new ViewHostMsg_AcceleratedSurfaceSetIOSurface( |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4935 | routing_id(), window, width, height, io_surface_identifier)); |
| 4936 | } |
| 4937 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4938 | void RenderViewImpl::AcceleratedSurfaceSetTransportDIB( |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 4939 | gfx::PluginWindowHandle window, |
| 4940 | int32 width, |
| 4941 | int32 height, |
| 4942 | TransportDIB::Handle transport_dib) { |
| 4943 | Send(new ViewHostMsg_AcceleratedSurfaceSetTransportDIB( |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 4944 | routing_id(), window, width, height, transport_dib)); |
| 4945 | } |
| 4946 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4947 | TransportDIB::Handle RenderViewImpl::AcceleratedSurfaceAllocTransportDIB( |
[email protected] | 44ce0b1 | 2010-03-12 16:45:33 | [diff] [blame] | 4948 | size_t size) { |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 4949 | TransportDIB::Handle dib_handle; |
| 4950 | // Assume this is a synchronous RPC. |
[email protected] | ada848b1 | 2010-04-08 22:35:38 | [diff] [blame] | 4951 | if (Send(new ViewHostMsg_AllocTransportDIB(size, true, &dib_handle))) |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 4952 | return dib_handle; |
| 4953 | // Return an invalid handle if Send() fails. |
| 4954 | return TransportDIB::DefaultHandleValue(); |
| 4955 | } |
| 4956 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4957 | void RenderViewImpl::AcceleratedSurfaceFreeTransportDIB( |
| 4958 | TransportDIB::Id dib_id) { |
[email protected] | 1aef9813 | 2010-02-23 18:00:07 | [diff] [blame] | 4959 | Send(new ViewHostMsg_FreeTransportDIB(dib_id)); |
| 4960 | } |
| 4961 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4962 | void RenderViewImpl::AcceleratedSurfaceBuffersSwapped( |
[email protected] | 7de8fb7 | 2012-03-14 04:24:32 | [diff] [blame] | 4963 | gfx::PluginWindowHandle window, uint64 surface_handle) { |
[email protected] | f35d667 | 2010-10-28 21:39:14 | [diff] [blame] | 4964 | Send(new ViewHostMsg_AcceleratedSurfaceBuffersSwapped( |
[email protected] | 7de8fb7 | 2012-03-14 04:24:32 | [diff] [blame] | 4965 | routing_id(), window, surface_handle)); |
[email protected] | 43f28f83 | 2010-02-03 02:28:48 | [diff] [blame] | 4966 | } |
| 4967 | #endif |
[email protected] | 58c321d | 2010-02-19 12:11:28 | [diff] [blame] | 4968 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4969 | bool RenderViewImpl::ScheduleFileChooser( |
[email protected] | 8caadeb | 2011-11-22 02:45:23 | [diff] [blame] | 4970 | const content::FileChooserParams& params, |
[email protected] | cdaf8d0 | 2010-03-30 19:52:47 | [diff] [blame] | 4971 | WebFileChooserCompletion* completion) { |
| 4972 | static const size_t kMaximumPendingFileChooseRequests = 4; |
| 4973 | if (file_chooser_completions_.size() > kMaximumPendingFileChooseRequests) { |
| 4974 | // This sanity check prevents too many file choose requests from getting |
| 4975 | // queued which could DoS the user. Getting these is most likely a |
| 4976 | // programming error (there are many ways to DoS the user so it's not |
| 4977 | // considered a "real" security check), either in JS requesting many file |
| 4978 | // choosers to pop up, or in a plugin. |
| 4979 | // |
| 4980 | // TODO(brettw) we might possibly want to require a user gesture to open |
| 4981 | // a file picker, which will address this issue in a better way. |
| 4982 | return false; |
| 4983 | } |
| 4984 | |
| 4985 | file_chooser_completions_.push_back(linked_ptr<PendingFileChooser>( |
| 4986 | new PendingFileChooser(params, completion))); |
| 4987 | if (file_chooser_completions_.size() == 1) { |
| 4988 | // Actually show the browse dialog when this is the first request. |
| 4989 | Send(new ViewHostMsg_RunFileChooser(routing_id_, params)); |
| 4990 | } |
| 4991 | return true; |
| 4992 | } |
| 4993 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 4994 | WebKit::WebGeolocationClient* RenderViewImpl::geolocationClient() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 4995 | if (!geolocation_dispatcher_) |
| 4996 | geolocation_dispatcher_ = new GeolocationDispatcher(this); |
| 4997 | return geolocation_dispatcher_; |
[email protected] | 7e0c470 | 2010-12-31 14:06:25 | [diff] [blame] | 4998 | } |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 4999 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5000 | WebKit::WebSpeechInputController* RenderViewImpl::speechInputController( |
[email protected] | 638694c | 2010-08-04 22:24:11 | [diff] [blame] | 5001 | WebKit::WebSpeechInputListener* listener) { |
[email protected] | 9eb100e | 2011-10-14 05:08:22 | [diff] [blame] | 5002 | #if defined(ENABLE_INPUT_SPEECH) |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 5003 | if (!input_tag_speech_dispatcher_) |
| 5004 | input_tag_speech_dispatcher_ = |
| 5005 | new InputTagSpeechDispatcher(this, listener); |
[email protected] | 9eb100e | 2011-10-14 05:08:22 | [diff] [blame] | 5006 | #endif |
[email protected] | c52b289 | 2012-03-07 11:01:02 | [diff] [blame] | 5007 | return input_tag_speech_dispatcher_; |
[email protected] | 638694c | 2010-08-04 22:24:11 | [diff] [blame] | 5008 | } |
| 5009 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5010 | WebKit::WebDeviceOrientationClient* RenderViewImpl::deviceOrientationClient() { |
[email protected] | 676126f7 | 2011-01-15 00:03:51 | [diff] [blame] | 5011 | if (!device_orientation_dispatcher_) |
| 5012 | device_orientation_dispatcher_ = new DeviceOrientationDispatcher(this); |
| 5013 | return device_orientation_dispatcher_; |
[email protected] | 57ead35 | 2010-08-11 14:42:53 | [diff] [blame] | 5014 | } |
| 5015 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5016 | void RenderViewImpl::zoomLimitsChanged(double minimum_level, |
| 5017 | double maximum_level) { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5018 | // For now, don't remember plugin zoom values. We don't want to mix them with |
| 5019 | // normal web content (i.e. a fixed layout plugin would usually want them |
| 5020 | // different). |
| 5021 | bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
| 5022 | |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5023 | int minimum_percent = static_cast<int>( |
| 5024 | WebView::zoomLevelToZoomFactor(minimum_level) * 100); |
| 5025 | int maximum_percent = static_cast<int>( |
| 5026 | WebView::zoomLevelToZoomFactor(maximum_level) * 100); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5027 | |
| 5028 | Send(new ViewHostMsg_UpdateZoomLimits( |
| 5029 | routing_id_, minimum_percent, maximum_percent, remember)); |
| 5030 | } |
| 5031 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5032 | void RenderViewImpl::zoomLevelChanged() { |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5033 | bool remember = !webview()->mainFrame()->document().isPluginDocument(); |
[email protected] | ba51d3b | 2011-08-24 19:53:08 | [diff] [blame] | 5034 | float zoom_level = webview()->zoomLevel(); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5035 | // Tell the browser which url got zoomed so it can update the menu and the |
| 5036 | // saved values if necessary |
| 5037 | Send(new ViewHostMsg_DidZoomURL( |
[email protected] | ba51d3b | 2011-08-24 19:53:08 | [diff] [blame] | 5038 | routing_id_, zoom_level, remember, |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 5039 | GURL(webview()->mainFrame()->document().url()))); |
[email protected] | b75b829 | 2010-10-01 07:28:25 | [diff] [blame] | 5040 | } |
| 5041 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5042 | void RenderViewImpl::registerProtocolHandler(const WebString& scheme, |
| 5043 | const WebString& base_url, |
| 5044 | const WebString& url, |
| 5045 | const WebString& title) { |
[email protected] | a6d36cc | 2011-02-23 00:39:48 | [diff] [blame] | 5046 | GURL base(base_url); |
| 5047 | GURL absolute_url = base.Resolve(UTF16ToUTF8(url)); |
| 5048 | if (base.GetOrigin() != absolute_url.GetOrigin()) { |
| 5049 | return; |
| 5050 | } |
[email protected] | f1a29a0 | 2011-10-06 23:08:44 | [diff] [blame] | 5051 | Send(new ViewHostMsg_RegisterProtocolHandler(routing_id_, |
| 5052 | UTF16ToUTF8(scheme), |
| 5053 | absolute_url, |
| 5054 | title)); |
[email protected] | a6d36cc | 2011-02-23 00:39:48 | [diff] [blame] | 5055 | } |
| 5056 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5057 | WebKit::WebPageVisibilityState RenderViewImpl::visibilityState() const { |
[email protected] | f59203a | 2011-06-07 10:01:44 | [diff] [blame] | 5058 | WebKit::WebPageVisibilityState current_state = is_hidden() ? |
| 5059 | WebKit::WebPageVisibilityStateHidden : |
| 5060 | WebKit::WebPageVisibilityStateVisible; |
| 5061 | WebKit::WebPageVisibilityState override_state = current_state; |
| 5062 | if (content::GetContentClient()->renderer()-> |
| 5063 | ShouldOverridePageVisibilityState(this, |
| 5064 | &override_state)) |
| 5065 | return override_state; |
| 5066 | return current_state; |
[email protected] | 94dec93 | 2011-05-26 20:04:21 | [diff] [blame] | 5067 | } |
| 5068 | |
[email protected] | 273558fb | 2012-01-12 15:03:51 | [diff] [blame] | 5069 | WebKit::WebUserMediaClient* RenderViewImpl::userMediaClient() { |
| 5070 | const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
| 5071 | if (!cmd_line->HasSwitch(switches::kEnableMediaStream)) |
| 5072 | return NULL; |
| 5073 | EnsureMediaStreamImpl(); |
| 5074 | return media_stream_impl_; |
| 5075 | } |
| 5076 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5077 | bool RenderViewImpl::IsNonLocalTopLevelNavigation( |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 5078 | const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) { |
[email protected] | 8079b36 | 2010-05-07 18:37:45 | [diff] [blame] | 5079 | // Must be a top level frame. |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 5080 | if (frame->parent() != NULL) |
| 5081 | return false; |
| 5082 | |
[email protected] | f0a3d0b | 2010-08-06 22:51:53 | [diff] [blame] | 5083 | // Navigations initiated within Webkit are not sent out to the external host |
| 5084 | // in the following cases. |
[email protected] | 900eb2f1 | 2010-08-23 22:36:27 | [diff] [blame] | 5085 | // 1. The url scheme is not http/https |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 5086 | // 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] | 5087 | // opener relationship is maintained. |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 5088 | // 3. Reloads/form submits/back forward navigations |
[email protected] | abbfaec | 2011-05-23 23:57:33 | [diff] [blame] | 5089 | if (!url.SchemeIs(chrome::kHttpScheme) && !url.SchemeIs(chrome::kHttpsScheme)) |
[email protected] | f0a3d0b | 2010-08-06 22:51:53 | [diff] [blame] | 5090 | return false; |
| 5091 | |
[email protected] | 2fc22d1 | 2010-12-02 23:08:16 | [diff] [blame] | 5092 | // Not interested in reloads/form submits/resubmits/back forward navigations. |
[email protected] | d0ed50d | 2010-06-22 01:01:32 | [diff] [blame] | 5093 | if (type != WebKit::WebNavigationTypeReload && |
[email protected] | 070c49c | 2010-07-13 22:22:01 | [diff] [blame] | 5094 | type != WebKit::WebNavigationTypeFormSubmitted && |
[email protected] | 2fc22d1 | 2010-12-02 23:08:16 | [diff] [blame] | 5095 | type != WebKit::WebNavigationTypeFormResubmitted && |
[email protected] | 070c49c | 2010-07-13 22:22:01 | [diff] [blame] | 5096 | type != WebKit::WebNavigationTypeBackForward) { |
[email protected] | d0ed50d | 2010-06-22 01:01:32 | [diff] [blame] | 5097 | // The opener relationship between the new window and the parent allows the |
| 5098 | // new window to script the parent and vice versa. This is not allowed if |
| 5099 | // the origins of the two domains are different. This can be treated as a |
| 5100 | // top level navigation and routed back to the host. |
| 5101 | WebKit::WebFrame* opener = frame->opener(); |
[email protected] | 900eb2f1 | 2010-08-23 22:36:27 | [diff] [blame] | 5102 | if (!opener) { |
[email protected] | 8696536 | 2011-04-21 18:42:51 | [diff] [blame] | 5103 | return true; |
[email protected] | d19ea34 | 2011-04-20 20:31:13 | [diff] [blame] | 5104 | } else { |
[email protected] | b6cb3a84 | 2011-06-24 18:28:41 | [diff] [blame] | 5105 | if (url.GetOrigin() != GURL(opener->document().url()).GetOrigin()) |
[email protected] | d0ed50d | 2010-06-22 01:01:32 | [diff] [blame] | 5106 | return true; |
| 5107 | } |
| 5108 | } |
[email protected] | 61c9f03 | 2010-03-31 23:04:19 | [diff] [blame] | 5109 | return false; |
| 5110 | } |
[email protected] | 2b06a99 | 2010-08-21 05:48:22 | [diff] [blame] | 5111 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5112 | void RenderViewImpl::OnAsyncFileOpened( |
| 5113 | base::PlatformFileError error_code, |
| 5114 | IPC::PlatformFileForTransit file_for_transit, |
| 5115 | int message_id) { |
[email protected] | 27a9ef3 | 2010-09-10 04:06:24 | [diff] [blame] | 5116 | pepper_delegate_.OnAsyncFileOpened( |
| 5117 | error_code, |
| 5118 | IPC::PlatformFileForTransitToPlatformFile(file_for_transit), |
| 5119 | message_id); |
| 5120 | } |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 5121 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5122 | void RenderViewImpl::OnPpapiBrokerChannelCreated( |
[email protected] | 2b657fd | 2011-04-18 16:00:47 | [diff] [blame] | 5123 | int request_id, |
| 5124 | base::ProcessHandle broker_process_handle, |
[email protected] | d5430507 | 2011-06-22 20:58:43 | [diff] [blame] | 5125 | const IPC::ChannelHandle& handle) { |
[email protected] | 2b657fd | 2011-04-18 16:00:47 | [diff] [blame] | 5126 | pepper_delegate_.OnPpapiBrokerChannelCreated(request_id, |
| 5127 | broker_process_handle, |
| 5128 | handle); |
[email protected] | eb415bf0e | 2011-04-14 02:45:42 | [diff] [blame] | 5129 | } |
| 5130 | |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 5131 | #if defined(OS_MACOSX) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5132 | void RenderViewImpl::OnSelectPopupMenuItem(int selected_index) { |
[email protected] | 68dc3ba | 2010-12-06 21:43:15 | [diff] [blame] | 5133 | if (external_popup_menu_ == NULL) { |
| 5134 | // Crash reports from the field indicate that we can be notified with a |
| 5135 | // NULL external popup menu (we probably get notified twice). |
| 5136 | // If you hit this please file a bug against jcivelli and include the page |
| 5137 | // and steps to repro. |
| 5138 | NOTREACHED(); |
| 5139 | return; |
| 5140 | } |
[email protected] | caf706f | 2010-10-26 17:54:08 | [diff] [blame] | 5141 | external_popup_menu_->DidSelectItem(selected_index); |
| 5142 | external_popup_menu_.reset(); |
| 5143 | } |
| 5144 | #endif |
[email protected] | bb46153 | 2010-11-26 21:50:23 | [diff] [blame] | 5145 | |
[email protected] | 1b4209f | 2011-01-07 00:25:40 | [diff] [blame] | 5146 | #if defined(ENABLE_FLAPPER_HACKS) |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5147 | void RenderViewImpl::OnConnectTcpACK( |
[email protected] | 1b4209f | 2011-01-07 00:25:40 | [diff] [blame] | 5148 | int request_id, |
| 5149 | IPC::PlatformFileForTransit socket_for_transit, |
[email protected] | 5a2b68f | 2011-11-10 00:00:49 | [diff] [blame] | 5150 | const PP_NetAddress_Private& local_addr, |
| 5151 | const PP_NetAddress_Private& remote_addr) { |
[email protected] | 1b4209f | 2011-01-07 00:25:40 | [diff] [blame] | 5152 | pepper_delegate_.OnConnectTcpACK( |
| 5153 | request_id, |
| 5154 | IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), |
| 5155 | local_addr, |
| 5156 | remote_addr); |
| 5157 | } |
| 5158 | #endif |
[email protected] | a6097f4 | 2011-01-10 08:50:51 | [diff] [blame] | 5159 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5160 | void RenderViewImpl::OnContextMenuClosed( |
[email protected] | 35be7ec | 2012-02-12 20:42:51 | [diff] [blame] | 5161 | const content::CustomContextMenuContext& custom_context) { |
[email protected] | b29aa74b | 2011-01-31 21:41:08 | [diff] [blame] | 5162 | if (custom_context.is_pepper_menu) |
| 5163 | pepper_delegate_.OnContextMenuClosed(custom_context); |
| 5164 | else |
| 5165 | context_menu_node_.reset(); |
[email protected] | 521b248 | 2011-01-15 00:10:10 | [diff] [blame] | 5166 | } |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 5167 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5168 | void RenderViewImpl::OnEnableViewSourceMode() { |
[email protected] | 5a7b15a | 2011-08-22 22:48:18 | [diff] [blame] | 5169 | if (!webview()) |
| 5170 | return; |
| 5171 | WebFrame* main_frame = webview()->mainFrame(); |
| 5172 | if (!main_frame) |
| 5173 | return; |
| 5174 | main_frame->enableViewSourceMode(true); |
| 5175 | } |
[email protected] | 67bfb83f | 2011-09-22 03:36:37 | [diff] [blame] | 5176 | |
[email protected] | 310ebd630 | 2011-10-10 19:06:28 | [diff] [blame] | 5177 | bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
[email protected] | ab21f2c | 2011-11-19 00:50:08 | [diff] [blame] | 5178 | return !!RenderThreadImpl::current()->compositor_thread(); |
[email protected] | c3d4553 | 2011-10-07 19:20:40 | [diff] [blame] | 5179 | } |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 5180 | |
[email protected] | 64d0e19 | 2011-12-09 14:44:20 | [diff] [blame] | 5181 | void RenderViewImpl::OnJavaBridgeInit() { |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 5182 | DCHECK(!java_bridge_dispatcher_.get()); |
[email protected] | 464750f | 2011-10-24 23:16:18 | [diff] [blame] | 5183 | #if defined(ENABLE_JAVA_BRIDGE) |
[email protected] | 64d0e19 | 2011-12-09 14:44:20 | [diff] [blame] | 5184 | java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
[email protected] | 464750f | 2011-10-24 23:16:18 | [diff] [blame] | 5185 | #endif |
[email protected] | 7f3c7af | 2011-10-20 22:52:51 | [diff] [blame] | 5186 | } |