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 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2193 if (RenderThread::current()) // Will be NULL during unit tests. | 2193 if (RenderThread::current()) // Will be NULL during unit tests. |
2194 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); | 2194 RenderThread::current()->DoNotSuspendWebKitSharedTimer(); |
2195 | 2195 |
2196 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); | 2196 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); |
2197 } | 2197 } |
2198 | 2198 |
2199 // WebKit::WebFrameClient ----------------------------------------------------- | 2199 // WebKit::WebFrameClient ----------------------------------------------------- |
2200 | 2200 |
2201 WebPlugin* RenderView::createPlugin(WebFrame* frame, | 2201 WebPlugin* RenderView::createPlugin(WebFrame* frame, |
2202 const WebPluginParams& params) { | 2202 const WebPluginParams& params) { |
2203 FilePath path; | 2203 bool found = false; |
| 2204 WebPluginInfo info; |
| 2205 GURL url(params.url); |
| 2206 std::string mime_type(params.mimeType.utf8()); |
2204 std::string actual_mime_type; | 2207 std::string actual_mime_type; |
2205 render_thread_->Send(new ViewHostMsg_GetPluginPath( | 2208 Send(new ViewHostMsg_GetPluginInfo(url, |
2206 params.url, frame->top()->url(), params.mimeType.utf8(), &path, | 2209 frame->top()->url(), |
| 2210 mime_type, |
| 2211 &found, |
| 2212 &info, |
2207 &actual_mime_type)); | 2213 &actual_mime_type)); |
2208 if (path.value().empty()) | 2214 |
| 2215 if (!found || !info.enabled) |
2209 return NULL; | 2216 return NULL; |
2210 | 2217 |
2211 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2218 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2212 switches::kEnableClickToPlay)) { | 2219 switches::kEnableClickToPlay)) { |
2213 if (!AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS) && | 2220 if (!AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS) && |
2214 path.value() != kDefaultPluginLibraryName) { | 2221 info.path.value() != kDefaultPluginLibraryName) { |
2215 didNotAllowPlugins(frame); | 2222 didNotAllowPlugins(frame); |
2216 return CreatePluginPlaceholder(frame, params); | 2223 return CreatePluginPlaceholder(frame, params); |
2217 } | 2224 } |
2218 } | 2225 } |
2219 return CreatePluginInternal(frame, params, actual_mime_type, path); | 2226 return CreatePluginInternal(frame, params, &info, actual_mime_type); |
2220 } | 2227 } |
2221 | 2228 |
2222 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { | 2229 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { |
2223 WebApplicationCacheHostImpl* appcache_host = | 2230 WebApplicationCacheHostImpl* appcache_host = |
2224 WebApplicationCacheHostImpl::FromFrame(frame); | 2231 WebApplicationCacheHostImpl::FromFrame(frame); |
2225 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; | 2232 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; |
2226 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, | 2233 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, |
2227 appcache_host_id); | 2234 appcache_host_id); |
2228 } | 2235 } |
2229 | 2236 |
(...skipping 1438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3668 } | 3675 } |
3669 } | 3676 } |
3670 | 3677 |
3671 void RenderView::ClearBlockedContentSettings() { | 3678 void RenderView::ClearBlockedContentSettings() { |
3672 for (size_t i = 0; i < arraysize(content_blocked_); ++i) | 3679 for (size_t i = 0; i < arraysize(content_blocked_); ++i) |
3673 content_blocked_[i] = false; | 3680 content_blocked_[i] = false; |
3674 } | 3681 } |
3675 | 3682 |
3676 WebPlugin* RenderView::CreatePluginInternal(WebFrame* frame, | 3683 WebPlugin* RenderView::CreatePluginInternal(WebFrame* frame, |
3677 const WebPluginParams& params, | 3684 const WebPluginParams& params, |
3678 const std::string& mime_type, | 3685 WebPluginInfo* plugin_info, |
3679 const FilePath& plugin_path) { | 3686 const std::string& mime_type) { |
3680 FilePath path(plugin_path); | |
3681 std::string actual_mime_type(mime_type); | 3687 std::string actual_mime_type(mime_type); |
3682 if (path.value().empty()) { | 3688 WebPluginInfo info; |
3683 render_thread_->Send(new ViewHostMsg_GetPluginPath( | 3689 if (plugin_info != NULL) { |
3684 params.url, frame->top()->url(), params.mimeType.utf8(), &path, | 3690 info = *plugin_info; |
3685 &actual_mime_type)); | 3691 } else { |
| 3692 bool found; |
| 3693 std::string actual_mime_type(mime_type); |
| 3694 Send(new ViewHostMsg_GetPluginInfo( |
| 3695 params.url, frame->top()->url(), params.mimeType.utf8(), &found, |
| 3696 &info, &actual_mime_type)); |
| 3697 if (!found) |
| 3698 info.enabled = false; |
3686 } | 3699 } |
3687 if (path.value().empty()) | 3700 if (!info.enabled) |
3688 return NULL; | 3701 return NULL; |
3689 | 3702 |
3690 if (actual_mime_type.empty()) | 3703 if (actual_mime_type.empty()) |
3691 actual_mime_type = params.mimeType.utf8(); | 3704 actual_mime_type = params.mimeType.utf8(); |
3692 | 3705 |
3693 scoped_refptr<pepper::PluginModule> pepper_module = | 3706 scoped_refptr<pepper::PluginModule> pepper_module = |
3694 PepperPluginRegistry::GetInstance()->GetModule(path); | 3707 PepperPluginRegistry::GetInstance()->GetModule(info.path); |
3695 if (pepper_module) { | 3708 if (pepper_module) { |
3696 WebPlugin* plugin = new pepper::WebPluginImpl(pepper_module, params, | 3709 WebPlugin* plugin = new pepper::WebPluginImpl(pepper_module, params, |
3697 pepper_delegate_.AsWeakPtr()); | 3710 pepper_delegate_.AsWeakPtr()); |
3698 if (plugin && !frame->parent() && frame->document().isPluginDocument()) { | 3711 if (plugin && !frame->parent() && frame->document().isPluginDocument()) { |
3699 // If this is a full-page plugin hosting the internal PDF plugin, we want | 3712 // If this is a full-page plugin hosting the internal PDF plugin, we want |
3700 // to notify the browser so that it can treat things like zooming | 3713 // to notify the browser so that it can treat things like zooming |
3701 // differently. | 3714 // differently. |
3702 // TODO(sanjeevr): Use a Pepper interface to determine this rather than | 3715 // TODO(sanjeevr): Use a Pepper interface to determine this rather than |
3703 // hardcode this for the PDF plugin path. | 3716 // hardcode this for the PDF plugin path. |
3704 FilePath pdf_path; | 3717 FilePath pdf_path; |
3705 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); | 3718 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path); |
3706 if (path == pdf_path) | 3719 if (info.path == pdf_path) |
3707 Send(new ViewHostMsg_SetDisplayingPDFContent(routing_id_)); | 3720 Send(new ViewHostMsg_SetDisplayingPDFContent(routing_id_)); |
3708 } | 3721 } |
3709 return plugin; | 3722 return plugin; |
3710 } | 3723 } |
3711 | 3724 |
3712 return new webkit_glue::WebPluginImpl(frame, params, path, actual_mime_type, | 3725 return new webkit_glue::WebPluginImpl(frame, params, info.path, |
3713 AsWeakPtr()); | 3726 actual_mime_type, AsWeakPtr()); |
3714 } | 3727 } |
3715 | 3728 |
3716 WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame, | 3729 WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame, |
3717 const WebPluginParams& params) { | 3730 const WebPluginParams& params) { |
3718 // |blocked_plugin| will delete itself when the WebViewPlugin is destroyed. | 3731 // |blocked_plugin| will delete itself when the WebViewPlugin is destroyed. |
3719 BlockedPlugin* blocked_plugin = new BlockedPlugin(this, frame, params); | 3732 BlockedPlugin* blocked_plugin = new BlockedPlugin(this, frame, params); |
3720 WebViewPlugin* plugin = blocked_plugin->plugin(); | 3733 WebViewPlugin* plugin = blocked_plugin->plugin(); |
3721 webkit_preferences_.Apply(plugin->web_view()); | 3734 webkit_preferences_.Apply(plugin->web_view()); |
3722 return plugin; | 3735 return plugin; |
3723 } | 3736 } |
(...skipping 1511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5235 // the origins of the two domains are different. This can be treated as a | 5248 // the origins of the two domains are different. This can be treated as a |
5236 // top level navigation and routed back to the host. | 5249 // top level navigation and routed back to the host. |
5237 WebKit::WebFrame* opener = frame->opener(); | 5250 WebKit::WebFrame* opener = frame->opener(); |
5238 if (opener) { | 5251 if (opener) { |
5239 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) | 5252 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) |
5240 return true; | 5253 return true; |
5241 } | 5254 } |
5242 } | 5255 } |
5243 return false; | 5256 return false; |
5244 } | 5257 } |
OLD | NEW |