| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "chrome/common/jstemplate_builder.h" | 33 #include "chrome/common/jstemplate_builder.h" |
| 34 #include "chrome/common/page_zoom.h" | 34 #include "chrome/common/page_zoom.h" |
| 35 #include "chrome/common/pepper_plugin_registry.h" | 35 #include "chrome/common/pepper_plugin_registry.h" |
| 36 #include "chrome/common/render_messages.h" | 36 #include "chrome/common/render_messages.h" |
| 37 #include "chrome/common/renderer_preferences.h" | 37 #include "chrome/common/renderer_preferences.h" |
| 38 #include "chrome/common/thumbnail_score.h" | 38 #include "chrome/common/thumbnail_score.h" |
| 39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
| 40 #include "chrome/common/window_container_type.h" | 40 #include "chrome/common/window_container_type.h" |
| 41 #include "chrome/renderer/about_handler.h" | 41 #include "chrome/renderer/about_handler.h" |
| 42 #include "chrome/renderer/audio_message_filter.h" | 42 #include "chrome/renderer/audio_message_filter.h" |
| 43 #include "chrome/renderer/blocked_plugin.h" |
| 43 #include "chrome/renderer/devtools_agent.h" | 44 #include "chrome/renderer/devtools_agent.h" |
| 44 #include "chrome/renderer/devtools_client.h" | 45 #include "chrome/renderer/devtools_client.h" |
| 45 #include "chrome/renderer/extension_groups.h" | 46 #include "chrome/renderer/extension_groups.h" |
| 46 #include "chrome/renderer/extensions/event_bindings.h" | 47 #include "chrome/renderer/extensions/event_bindings.h" |
| 47 #include "chrome/renderer/extensions/extension_process_bindings.h" | 48 #include "chrome/renderer/extensions/extension_process_bindings.h" |
| 48 #include "chrome/renderer/extensions/renderer_extension_bindings.h" | 49 #include "chrome/renderer/extensions/renderer_extension_bindings.h" |
| 49 #include "chrome/renderer/geolocation_dispatcher.h" | 50 #include "chrome/renderer/geolocation_dispatcher.h" |
| 50 #include "chrome/renderer/localized_error.h" | 51 #include "chrome/renderer/localized_error.h" |
| 51 #include "chrome/renderer/media/audio_renderer_impl.h" | 52 #include "chrome/renderer/media/audio_renderer_impl.h" |
| 52 #include "chrome/renderer/media/ipc_video_renderer.h" | 53 #include "chrome/renderer/media/ipc_video_renderer.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" | 88 #include "third_party/WebKit/WebKit/chromium/public/WebFormControlElement.h" |
| 88 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" | 89 #include "third_party/WebKit/WebKit/chromium/public/WebFormElement.h" |
| 89 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 90 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
| 90 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" | 91 #include "third_party/WebKit/WebKit/chromium/public/WebHistoryItem.h" |
| 91 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" | 92 #include "third_party/WebKit/WebKit/chromium/public/WebImage.h" |
| 92 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" | 93 #include "third_party/WebKit/WebKit/chromium/public/WebInputElement.h" |
| 93 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" | 94 #include "third_party/WebKit/WebKit/chromium/public/WebNode.h" |
| 94 #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" | 95 #include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h" |
| 95 #include "third_party/WebKit/WebKit/chromium/public/WebPageSerializer.h" | 96 #include "third_party/WebKit/WebKit/chromium/public/WebPageSerializer.h" |
| 96 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" | 97 #include "third_party/WebKit/WebKit/chromium/public/WebPlugin.h" |
| 98 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" |
| 97 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" | 99 #include "third_party/WebKit/WebKit/chromium/public/WebPluginParams.h" |
| 98 #include "third_party/WebKit/WebKit/chromium/public/WebPluginDocument.h" | 100 #include "third_party/WebKit/WebKit/chromium/public/WebPluginDocument.h" |
| 99 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" | 101 #include "third_party/WebKit/WebKit/chromium/public/WebPoint.h" |
| 100 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" | 102 #include "third_party/WebKit/WebKit/chromium/public/WebRange.h" |
| 101 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" | 103 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" |
| 102 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" | 104 #include "third_party/WebKit/WebKit/chromium/public/WebScriptSource.h" |
| 103 #include "third_party/WebKit/WebKit/chromium/public/WebSearchableFormData.h" | 105 #include "third_party/WebKit/WebKit/chromium/public/WebSearchableFormData.h" |
| 104 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" | 106 #include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h" |
| 107 #include "third_party/WebKit/WebKit/chromium/public/WebSettings.h" |
| 105 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" | 108 #include "third_party/WebKit/WebKit/chromium/public/WebSize.h" |
| 106 #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" | 109 #include "third_party/WebKit/WebKit/chromium/public/WebStorageNamespace.h" |
| 107 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" | 110 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
| 108 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" | 111 #include "third_party/WebKit/WebKit/chromium/public/WebURL.h" |
| 109 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" | 112 #include "third_party/WebKit/WebKit/chromium/public/WebURLError.h" |
| 110 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" | 113 #include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h" |
| 111 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" | 114 #include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h" |
| 112 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" | 115 #include "third_party/WebKit/WebKit/chromium/public/WebVector.h" |
| 113 #include "third_party/WebKit/WebKit/chromium/public/WebWindowFeatures.h" | 116 #include "third_party/WebKit/WebKit/chromium/public/WebWindowFeatures.h" |
| 114 #include "webkit/appcache/web_application_cache_host_impl.h" | 117 #include "webkit/appcache/web_application_cache_host_impl.h" |
| 115 #include "webkit/glue/dom_operations.h" | 118 #include "webkit/glue/dom_operations.h" |
| 116 #include "webkit/glue/form_data.h" | 119 #include "webkit/glue/form_data.h" |
| 117 #include "webkit/glue/form_field.h" | 120 #include "webkit/glue/form_field.h" |
| 118 #include "webkit/glue/glue_serialize.h" | 121 #include "webkit/glue/glue_serialize.h" |
| 119 #include "webkit/glue/image_decoder.h" | 122 #include "webkit/glue/image_decoder.h" |
| 120 #include "webkit/glue/media/buffered_data_source.h" | 123 #include "webkit/glue/media/buffered_data_source.h" |
| 121 #include "webkit/glue/media/simple_data_source.h" | 124 #include "webkit/glue/media/simple_data_source.h" |
| 122 #include "webkit/glue/media/video_renderer_impl.h" | 125 #include "webkit/glue/media/video_renderer_impl.h" |
| 123 #include "webkit/glue/password_form.h" | 126 #include "webkit/glue/password_form.h" |
| 124 #include "webkit/glue/plugins/default_plugin_shared.h" | 127 #include "webkit/glue/plugins/default_plugin_shared.h" |
| 125 #include "webkit/glue/plugins/pepper_webplugin_impl.h" | 128 #include "webkit/glue/plugins/pepper_webplugin_impl.h" |
| 126 #include "webkit/glue/plugins/plugin_list.h" | 129 #include "webkit/glue/plugins/plugin_list.h" |
| 127 #include "webkit/glue/plugins/webplugin_delegate.h" | 130 #include "webkit/glue/plugins/webplugin_delegate.h" |
| 128 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | 131 #include "webkit/glue/plugins/webplugin_delegate_impl.h" |
| 129 #include "webkit/glue/plugins/webplugin_impl.h" | 132 #include "webkit/glue/plugins/webplugin_impl.h" |
| 133 #include "webkit/glue/plugins/webview_plugin.h" |
| 130 #include "webkit/glue/site_isolation_metrics.h" | 134 #include "webkit/glue/site_isolation_metrics.h" |
| 131 #include "webkit/glue/webdropdata.h" | 135 #include "webkit/glue/webdropdata.h" |
| 132 #include "webkit/glue/webkit_glue.h" | 136 #include "webkit/glue/webkit_glue.h" |
| 133 #include "webkit/glue/webmediaplayer_impl.h" | 137 #include "webkit/glue/webmediaplayer_impl.h" |
| 134 | 138 |
| 135 #if defined(OS_WIN) | 139 #if defined(OS_WIN) |
| 136 // TODO(port): these files are currently Windows only because they concern: | 140 // TODO(port): these files are currently Windows only because they concern: |
| 137 // * theming | 141 // * theming |
| 138 #include "gfx/native_theme_win.h" | 142 #include "gfx/native_theme_win.h" |
| 139 #elif defined(USE_X11) | 143 #elif defined(USE_X11) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 using WebKit::WebInputElement; | 184 using WebKit::WebInputElement; |
| 181 using WebKit::WebMediaPlayer; | 185 using WebKit::WebMediaPlayer; |
| 182 using WebKit::WebMediaPlayerAction; | 186 using WebKit::WebMediaPlayerAction; |
| 183 using WebKit::WebMediaPlayerClient; | 187 using WebKit::WebMediaPlayerClient; |
| 184 using WebKit::WebNavigationPolicy; | 188 using WebKit::WebNavigationPolicy; |
| 185 using WebKit::WebNavigationType; | 189 using WebKit::WebNavigationType; |
| 186 using WebKit::WebNode; | 190 using WebKit::WebNode; |
| 187 using WebKit::WebPageSerializer; | 191 using WebKit::WebPageSerializer; |
| 188 using WebKit::WebPageSerializerClient; | 192 using WebKit::WebPageSerializerClient; |
| 189 using WebKit::WebPlugin; | 193 using WebKit::WebPlugin; |
| 194 using WebKit::WebPluginContainer; |
| 190 using WebKit::WebPluginParams; | 195 using WebKit::WebPluginParams; |
| 191 using WebKit::WebPluginDocument; | 196 using WebKit::WebPluginDocument; |
| 192 using WebKit::WebPoint; | 197 using WebKit::WebPoint; |
| 193 using WebKit::WebPopupMenuInfo; | 198 using WebKit::WebPopupMenuInfo; |
| 194 using WebKit::WebRange; | 199 using WebKit::WebRange; |
| 195 using WebKit::WebRect; | 200 using WebKit::WebRect; |
| 196 using WebKit::WebScriptSource; | 201 using WebKit::WebScriptSource; |
| 197 using WebKit::WebSearchableFormData; | 202 using WebKit::WebSearchableFormData; |
| 198 using WebKit::WebSecurityOrigin; | 203 using WebKit::WebSecurityOrigin; |
| 199 using WebKit::WebSettings; | 204 using WebKit::WebSettings; |
| (...skipping 2068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2268 // handed manner. | 2273 // handed manner. |
| 2269 // | 2274 // |
| 2270 if (RenderThread::current()) // Will be NULL during unit tests. | 2275 if (RenderThread::current()) // Will be NULL during unit tests. |
| 2271 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); | 2276 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); |
| 2272 | 2277 |
| 2273 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); | 2278 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); |
| 2274 } | 2279 } |
| 2275 | 2280 |
| 2276 // WebKit::WebFrameClient ----------------------------------------------------- | 2281 // WebKit::WebFrameClient ----------------------------------------------------- |
| 2277 | 2282 |
| 2278 WebPlugin* RenderView::createPlugin( | 2283 WebPlugin* RenderView::createPlugin(WebFrame* frame, |
| 2279 WebFrame* frame, const WebPluginParams& params) { | 2284 const WebPluginParams& params) { |
| 2280 FilePath path; | 2285 if (AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS)) |
| 2281 std::string actual_mime_type; | 2286 return CreatePluginInternal(frame, params); |
| 2282 render_thread_->Send(new ViewHostMsg_GetPluginPath( | |
| 2283 params.url, frame->top()->url(), params.mimeType.utf8(), &path, | |
| 2284 &actual_mime_type)); | |
| 2285 if (path.value().empty()) | |
| 2286 return NULL; | |
| 2287 | 2287 |
| 2288 if (actual_mime_type.empty()) | 2288 didNotAllowPlugins(frame); |
| 2289 actual_mime_type = params.mimeType.utf8(); | 2289 return CreatePluginPlaceholder(frame, params); |
| 2290 | |
| 2291 scoped_refptr<pepper::PluginModule> pepper_module = | |
| 2292 PepperPluginRegistry::GetInstance()->GetModule(path); | |
| 2293 if (pepper_module) { | |
| 2294 return new pepper::WebPluginImpl(pepper_module, params, | |
| 2295 pepper_delegate_.AsWeakPtr()); | |
| 2296 } | |
| 2297 | |
| 2298 return new webkit_glue::WebPluginImpl(frame, params, path, actual_mime_type, | |
| 2299 AsWeakPtr()); | |
| 2300 } | 2290 } |
| 2301 | 2291 |
| 2302 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { | 2292 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { |
| 2303 WebApplicationCacheHostImpl* appcache_host = | 2293 WebApplicationCacheHostImpl* appcache_host = |
| 2304 WebApplicationCacheHostImpl::FromFrame(frame); | 2294 WebApplicationCacheHostImpl::FromFrame(frame); |
| 2305 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; | 2295 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; |
| 2306 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, | 2296 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, |
| 2307 appcache_host_id); | 2297 appcache_host_id); |
| 2308 } | 2298 } |
| 2309 | 2299 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2407 DumpLoadHistograms(); | 2397 DumpLoadHistograms(); |
| 2408 } | 2398 } |
| 2409 | 2399 |
| 2410 WebDataSource* ds = frame->dataSource(); | 2400 WebDataSource* ds = frame->dataSource(); |
| 2411 NavigationState* navigation_state = NavigationState::FromDataSource(ds); | 2401 NavigationState* navigation_state = NavigationState::FromDataSource(ds); |
| 2412 navigation_state->user_script_idle_scheduler()->Cancel(); | 2402 navigation_state->user_script_idle_scheduler()->Cancel(); |
| 2413 | 2403 |
| 2414 form_manager_.ResetFrame(frame); | 2404 form_manager_.ResetFrame(frame); |
| 2415 } | 2405 } |
| 2416 | 2406 |
| 2417 bool RenderView::allowPlugins(WebFrame* frame, bool enabled_per_settings) { | |
| 2418 if (!enabled_per_settings) | |
| 2419 return false; | |
| 2420 return AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS); | |
| 2421 } | |
| 2422 | |
| 2423 bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) { | 2407 bool RenderView::allowImages(WebFrame* frame, bool enabled_per_settings) { |
| 2424 if (enabled_per_settings && | 2408 if (enabled_per_settings && |
| 2425 AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) | 2409 AllowContentType(CONTENT_SETTINGS_TYPE_IMAGES)) |
| 2426 return true; | 2410 return true; |
| 2427 | 2411 |
| 2428 if (IsWhitelistedForContentSettings(frame)) | 2412 if (IsWhitelistedForContentSettings(frame)) |
| 2429 return true; | 2413 return true; |
| 2430 | 2414 |
| 2431 DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES); | 2415 DidBlockContentType(CONTENT_SETTINGS_TYPE_IMAGES); |
| 2432 return false; // Other protocols fall through here. | 2416 return false; // Other protocols fall through here. |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3721 content_blocked_[settings_type] = true; | 3705 content_blocked_[settings_type] = true; |
| 3722 Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type)); | 3706 Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type)); |
| 3723 } | 3707 } |
| 3724 } | 3708 } |
| 3725 | 3709 |
| 3726 void RenderView::ClearBlockedContentSettings() { | 3710 void RenderView::ClearBlockedContentSettings() { |
| 3727 for (size_t i = 0; i < arraysize(content_blocked_); ++i) | 3711 for (size_t i = 0; i < arraysize(content_blocked_); ++i) |
| 3728 content_blocked_[i] = false; | 3712 content_blocked_[i] = false; |
| 3729 } | 3713 } |
| 3730 | 3714 |
| 3715 WebPlugin* RenderView::CreatePluginInternal(WebFrame* frame, |
| 3716 const WebPluginParams& params) { |
| 3717 FilePath path; |
| 3718 std::string actual_mime_type; |
| 3719 render_thread_->Send(new ViewHostMsg_GetPluginPath( |
| 3720 params.url, frame->top()->url(), params.mimeType.utf8(), &path, |
| 3721 &actual_mime_type)); |
| 3722 if (path.value().empty()) |
| 3723 return NULL; |
| 3724 |
| 3725 if (actual_mime_type.empty()) |
| 3726 actual_mime_type = params.mimeType.utf8(); |
| 3727 |
| 3728 scoped_refptr<pepper::PluginModule> pepper_module = |
| 3729 PepperPluginRegistry::GetInstance()->GetModule(path); |
| 3730 if (pepper_module) { |
| 3731 return new pepper::WebPluginImpl(pepper_module, params, |
| 3732 pepper_delegate_.AsWeakPtr()); |
| 3733 } |
| 3734 |
| 3735 return new webkit_glue::WebPluginImpl(frame, params, path, actual_mime_type, |
| 3736 AsWeakPtr()); |
| 3737 } |
| 3738 |
| 3739 WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame, |
| 3740 const WebPluginParams& params) { |
| 3741 // |blocked_plugin| will delete itself when the WebViewPlugin is destroyed. |
| 3742 BlockedPlugin* blocked_plugin = new BlockedPlugin(this, frame, params); |
| 3743 WebViewPlugin* plugin = blocked_plugin->plugin(); |
| 3744 webkit_preferences_.Apply(plugin->web_view()); |
| 3745 return plugin; |
| 3746 } |
| 3747 |
| 3731 void RenderView::OnZoom(PageZoom::Function function) { | 3748 void RenderView::OnZoom(PageZoom::Function function) { |
| 3732 if (!webview()) // Not sure if this can happen, but no harm in being safe. | 3749 if (!webview()) // Not sure if this can happen, but no harm in being safe. |
| 3733 return; | 3750 return; |
| 3734 | 3751 |
| 3735 webview()->hidePopups(); | 3752 webview()->hidePopups(); |
| 3736 | 3753 |
| 3737 int zoom_level = webview()->zoomLevel(); | 3754 int zoom_level = webview()->zoomLevel(); |
| 3738 int new_zoom_level = webview()->setZoomLevel(false, | 3755 int new_zoom_level = webview()->setZoomLevel(false, |
| 3739 (function == PageZoom::RESET) ? 0 : (zoom_level + function)); | 3756 (function == PageZoom::RESET) ? 0 : (zoom_level + function)); |
| 3740 | 3757 |
| (...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5313 webkit_glue::FormData form; | 5330 webkit_glue::FormData form; |
| 5314 const WebInputElement element = node.toConst<WebInputElement>(); | 5331 const WebInputElement element = node.toConst<WebInputElement>(); |
| 5315 if (!form_manager_.FindFormWithFormControlElement( | 5332 if (!form_manager_.FindFormWithFormControlElement( |
| 5316 element, FormManager::REQUIRE_NONE, &form)) | 5333 element, FormManager::REQUIRE_NONE, &form)) |
| 5317 return; | 5334 return; |
| 5318 | 5335 |
| 5319 autofill_action_ = action; | 5336 autofill_action_ = action; |
| 5320 Send(new ViewHostMsg_FillAutoFillFormData( | 5337 Send(new ViewHostMsg_FillAutoFillFormData( |
| 5321 routing_id_, autofill_query_id_, form, value, label)); | 5338 routing_id_, autofill_query_id_, form, value, label)); |
| 5322 } | 5339 } |
| OLD | NEW |