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 14 matching lines...) Expand all Loading... |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "chrome/common/appcache/appcache_dispatcher.h" | 26 #include "chrome/common/appcache/appcache_dispatcher.h" |
27 #include "chrome/common/bindings_policy.h" | 27 #include "chrome/common/bindings_policy.h" |
28 #include "chrome/common/child_process_logging.h" | 28 #include "chrome/common/child_process_logging.h" |
29 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
30 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/extensions/extension_constants.h" | 32 #include "chrome/common/extensions/extension_constants.h" |
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/render_messages.h" | 36 #include "chrome/common/render_messages.h" |
36 #include "chrome/common/renderer_preferences.h" | 37 #include "chrome/common/renderer_preferences.h" |
37 #include "chrome/common/thumbnail_score.h" | 38 #include "chrome/common/thumbnail_score.h" |
38 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
39 #include "chrome/common/window_container_type.h" | 40 #include "chrome/common/window_container_type.h" |
40 #include "chrome/renderer/about_handler.h" | 41 #include "chrome/renderer/about_handler.h" |
41 #include "chrome/renderer/audio_message_filter.h" | 42 #include "chrome/renderer/audio_message_filter.h" |
42 #include "chrome/renderer/devtools_agent.h" | 43 #include "chrome/renderer/devtools_agent.h" |
43 #include "chrome/renderer/devtools_client.h" | 44 #include "chrome/renderer/devtools_client.h" |
44 #include "chrome/renderer/extension_groups.h" | 45 #include "chrome/renderer/extension_groups.h" |
45 #include "chrome/renderer/extensions/event_bindings.h" | 46 #include "chrome/renderer/extensions/event_bindings.h" |
46 #include "chrome/renderer/extensions/extension_process_bindings.h" | 47 #include "chrome/renderer/extensions/extension_process_bindings.h" |
47 #include "chrome/renderer/extensions/renderer_extension_bindings.h" | 48 #include "chrome/renderer/extensions/renderer_extension_bindings.h" |
48 #include "chrome/renderer/geolocation_dispatcher.h" | 49 #include "chrome/renderer/geolocation_dispatcher.h" |
49 #include "chrome/renderer/localized_error.h" | 50 #include "chrome/renderer/localized_error.h" |
50 #include "chrome/renderer/media/audio_renderer_impl.h" | 51 #include "chrome/renderer/media/audio_renderer_impl.h" |
51 #include "chrome/renderer/media/ipc_video_renderer.h" | 52 #include "chrome/renderer/media/ipc_video_renderer.h" |
52 #include "chrome/renderer/navigation_state.h" | 53 #include "chrome/renderer/navigation_state.h" |
53 #include "chrome/renderer/notification_provider.h" | 54 #include "chrome/renderer/notification_provider.h" |
54 #include "chrome/renderer/pepper_plugin_registry.h" | |
55 #include "chrome/renderer/plugin_channel_host.h" | 55 #include "chrome/renderer/plugin_channel_host.h" |
56 #include "chrome/renderer/print_web_view_helper.h" | 56 #include "chrome/renderer/print_web_view_helper.h" |
57 #include "chrome/renderer/render_process.h" | 57 #include "chrome/renderer/render_process.h" |
58 #include "chrome/renderer/render_thread.h" | 58 #include "chrome/renderer/render_thread.h" |
59 #include "chrome/renderer/renderer_webapplicationcachehost_impl.h" | 59 #include "chrome/renderer/renderer_webapplicationcachehost_impl.h" |
60 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" | 60 #include "chrome/renderer/renderer_webstoragenamespace_impl.h" |
61 #include "chrome/renderer/spellchecker/spellcheck.h" | 61 #include "chrome/renderer/spellchecker/spellcheck.h" |
62 #include "chrome/renderer/user_script_slave.h" | 62 #include "chrome/renderer/user_script_slave.h" |
63 #include "chrome/renderer/visitedlink_slave.h" | 63 #include "chrome/renderer/visitedlink_slave.h" |
64 #include "chrome/renderer/webplugin_delegate_pepper.h" | 64 #include "chrome/renderer/webplugin_delegate_pepper.h" |
(...skipping 2023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2088 if (RenderThread::current()) // Will be NULL during unit tests. | 2088 if (RenderThread::current()) // Will be NULL during unit tests. |
2089 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); | 2089 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); |
2090 | 2090 |
2091 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); | 2091 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); |
2092 } | 2092 } |
2093 | 2093 |
2094 // WebKit::WebFrameClient ----------------------------------------------------- | 2094 // WebKit::WebFrameClient ----------------------------------------------------- |
2095 | 2095 |
2096 WebPlugin* RenderView::createPlugin( | 2096 WebPlugin* RenderView::createPlugin( |
2097 WebFrame* frame, const WebPluginParams& params) { | 2097 WebFrame* frame, const WebPluginParams& params) { |
| 2098 FilePath path; |
| 2099 std::string actual_mime_type; |
| 2100 render_thread_->Send(new ViewHostMsg_GetPluginPath( |
| 2101 params.url, frame->top()->url(), params.mimeType.utf8(), &path, |
| 2102 &actual_mime_type)); |
| 2103 if (path.value().empty()) |
| 2104 return NULL; |
| 2105 |
| 2106 if (actual_mime_type.empty()) |
| 2107 actual_mime_type = params.mimeType.utf8(); |
| 2108 |
2098 scoped_refptr<pepper::PluginModule> pepper_module = | 2109 scoped_refptr<pepper::PluginModule> pepper_module = |
2099 PepperPluginRegistry::GetInstance()->GetModule(params.mimeType.utf8()); | 2110 PepperPluginRegistry::GetInstance()->GetModule(path); |
2100 if (pepper_module) { | 2111 if (pepper_module) { |
2101 return new pepper::WebPluginImpl(pepper_module, frame, params, | 2112 return new pepper::WebPluginImpl(pepper_module, params, |
2102 pepper_delegate_.AsWeakPtr()); | 2113 pepper_delegate_.AsWeakPtr()); |
2103 } | 2114 } |
2104 return new webkit_glue::WebPluginImpl(frame, params, AsWeakPtr()); | 2115 |
| 2116 return new webkit_glue::WebPluginImpl(frame, params, path, actual_mime_type, |
| 2117 AsWeakPtr()); |
2105 } | 2118 } |
2106 | 2119 |
2107 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { | 2120 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { |
2108 WebApplicationCacheHostImpl* appcache_host = | 2121 WebApplicationCacheHostImpl* appcache_host = |
2109 WebApplicationCacheHostImpl::FromFrame(frame); | 2122 WebApplicationCacheHostImpl::FromFrame(frame); |
2110 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; | 2123 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; |
2111 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, | 2124 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, |
2112 appcache_host_id); | 2125 appcache_host_id); |
2113 } | 2126 } |
2114 | 2127 |
(...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3093 request_id, | 3106 request_id, |
3094 0, | 3107 0, |
3095 gfx::Rect(), | 3108 gfx::Rect(), |
3096 0, | 3109 0, |
3097 true)); | 3110 true)); |
3098 } | 3111 } |
3099 | 3112 |
3100 // webkit_glue::WebPluginPageDelegate ----------------------------------------- | 3113 // webkit_glue::WebPluginPageDelegate ----------------------------------------- |
3101 | 3114 |
3102 webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( | 3115 webkit_glue::WebPluginDelegate* RenderView::CreatePluginDelegate( |
3103 const GURL& url, | 3116 const FilePath& file_path, |
3104 const std::string& mime_type, | 3117 const std::string& mime_type) { |
3105 std::string* actual_mime_type) { | |
3106 if (!PluginChannelHost::IsListening()) | 3118 if (!PluginChannelHost::IsListening()) |
3107 return NULL; | 3119 return NULL; |
3108 | 3120 |
3109 GURL policy_url; | |
3110 WebFrame* main_frame = webview()->mainFrame(); | |
3111 if (main_frame) | |
3112 policy_url = main_frame->url(); | |
3113 | |
3114 FilePath path; | |
3115 render_thread_->Send(new ViewHostMsg_GetPluginPath( | |
3116 url, policy_url, mime_type, &path, actual_mime_type)); | |
3117 if (path.value().empty()) | |
3118 return NULL; | |
3119 | |
3120 FilePath internal_pdf_path; | |
3121 PathService::Get(chrome::FILE_PDF_PLUGIN, &internal_pdf_path); | |
3122 | |
3123 const std::string* mime_type_to_use; | |
3124 if (!actual_mime_type->empty()) | |
3125 mime_type_to_use = actual_mime_type; | |
3126 else | |
3127 mime_type_to_use = &mime_type; | |
3128 | |
3129 bool use_pepper_host = false; | 3121 bool use_pepper_host = false; |
3130 bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); | 3122 bool in_process_plugin = RenderProcess::current()->UseInProcessPlugins(); |
3131 // Check for trusted Pepper plugins. | 3123 // Check for trusted Pepper plugins. |
3132 const char kPepperPrefix[] = "pepper-"; | 3124 const char kPepperPrefix[] = "pepper-"; |
3133 if (StartsWithASCII(*mime_type_to_use, kPepperPrefix, true)) { | 3125 if (StartsWithASCII(mime_type, kPepperPrefix, true)) { |
3134 if (CommandLine::ForCurrentProcess()-> | 3126 if (CommandLine::ForCurrentProcess()-> |
3135 HasSwitch(switches::kInternalPepper)) { | 3127 HasSwitch(switches::kInternalPepper)) { |
3136 in_process_plugin = true; | 3128 in_process_plugin = true; |
3137 use_pepper_host = true; | 3129 use_pepper_host = true; |
3138 } else { | 3130 } else { |
3139 // In process Pepper plugins must be explicitly enabled. | 3131 // In process Pepper plugins must be explicitly enabled. |
3140 return NULL; | 3132 return NULL; |
3141 } | 3133 } |
3142 } else if (path == internal_pdf_path) { | 3134 } else { |
3143 in_process_plugin = true; | 3135 FilePath internal_pdf_path; |
3144 use_pepper_host = true; | 3136 PathService::Get(chrome::FILE_PDF_PLUGIN, &internal_pdf_path); |
| 3137 if (file_path == internal_pdf_path) { |
| 3138 in_process_plugin = true; |
| 3139 use_pepper_host = true; |
| 3140 } |
3145 } | 3141 } |
| 3142 |
3146 // Check for Native Client modules. | 3143 // Check for Native Client modules. |
3147 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInternalNaCl)) { | 3144 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInternalNaCl)) { |
3148 if (mime_type == "application/x-nacl-srpc") { | 3145 if (mime_type == "application/x-nacl-srpc") { |
3149 in_process_plugin = true; | 3146 in_process_plugin = true; |
3150 use_pepper_host = true; | 3147 use_pepper_host = true; |
3151 } | 3148 } |
3152 } | 3149 } |
| 3150 |
3153 if (in_process_plugin) { | 3151 if (in_process_plugin) { |
3154 if (use_pepper_host) { | 3152 if (use_pepper_host) { |
3155 WebPluginDelegatePepper* pepper_plugin = | 3153 WebPluginDelegatePepper* pepper_plugin = |
3156 WebPluginDelegatePepper::Create(path, *mime_type_to_use, | 3154 WebPluginDelegatePepper::Create(file_path, mime_type, AsWeakPtr()); |
3157 AsWeakPtr()); | |
3158 current_pepper_plugins_.insert(pepper_plugin); | 3155 current_pepper_plugins_.insert(pepper_plugin); |
3159 return pepper_plugin; | 3156 return pepper_plugin; |
3160 } else { | 3157 } else { |
3161 #if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. | 3158 #if defined(OS_WIN) // In-proc plugins aren't supported on Linux or Mac. |
3162 return WebPluginDelegateImpl::Create( | 3159 return WebPluginDelegateImpl::Create( |
3163 path, *mime_type_to_use, gfx::NativeViewFromId(host_window_)); | 3160 file_path, mime_type, gfx::NativeViewFromId(host_window_)); |
3164 #else | 3161 #else |
3165 NOTIMPLEMENTED(); | 3162 NOTIMPLEMENTED(); |
3166 return NULL; | 3163 return NULL; |
3167 #endif | 3164 #endif |
3168 } | 3165 } |
3169 } | 3166 } |
3170 | 3167 |
3171 return new WebPluginDelegateProxy(*mime_type_to_use, AsWeakPtr()); | 3168 return new WebPluginDelegateProxy(mime_type, AsWeakPtr()); |
3172 } | 3169 } |
3173 | 3170 |
3174 void RenderView::CreatedPluginWindow(gfx::PluginWindowHandle window) { | 3171 void RenderView::CreatedPluginWindow(gfx::PluginWindowHandle window) { |
3175 #if defined(USE_X11) | 3172 #if defined(USE_X11) |
3176 RenderThread::current()->Send(new ViewHostMsg_CreatePluginContainer( | 3173 RenderThread::current()->Send(new ViewHostMsg_CreatePluginContainer( |
3177 routing_id(), window)); | 3174 routing_id(), window)); |
3178 #endif | 3175 #endif |
3179 } | 3176 } |
3180 | 3177 |
3181 void RenderView::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { | 3178 void RenderView::WillDestroyPluginWindow(gfx::PluginWindowHandle window) { |
(...skipping 1846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5028 | 5025 |
5029 if (last_top_level_navigation_page_id_ != page_id_ && | 5026 if (last_top_level_navigation_page_id_ != page_id_ && |
5030 // Not interested in reloads. | 5027 // Not interested in reloads. |
5031 type != WebKit::WebNavigationTypeReload && | 5028 type != WebKit::WebNavigationTypeReload && |
5032 type != WebKit::WebNavigationTypeFormSubmitted) { | 5029 type != WebKit::WebNavigationTypeFormSubmitted) { |
5033 return true; | 5030 return true; |
5034 } | 5031 } |
5035 } | 5032 } |
5036 return false; | 5033 return false; |
5037 } | 5034 } |
OLD | NEW |