Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/renderer/render_view.cc

Issue 3040034: Block non-sandboxed plugins. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: fix indentation; sync Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 using WebKit::WebMediaPlayer; 193 using WebKit::WebMediaPlayer;
194 using WebKit::WebMediaPlayerAction; 194 using WebKit::WebMediaPlayerAction;
195 using WebKit::WebMediaPlayerClient; 195 using WebKit::WebMediaPlayerClient;
196 using WebKit::WebNavigationPolicy; 196 using WebKit::WebNavigationPolicy;
197 using WebKit::WebNavigationType; 197 using WebKit::WebNavigationType;
198 using WebKit::WebNode; 198 using WebKit::WebNode;
199 using WebKit::WebPageSerializer; 199 using WebKit::WebPageSerializer;
200 using WebKit::WebPageSerializerClient; 200 using WebKit::WebPageSerializerClient;
201 using WebKit::WebPlugin; 201 using WebKit::WebPlugin;
202 using WebKit::WebPluginContainer; 202 using WebKit::WebPluginContainer;
203 using WebKit::WebPluginDocument;
203 using WebKit::WebPluginParams; 204 using WebKit::WebPluginParams;
204 using WebKit::WebPluginDocument;
205 using WebKit::WebPoint; 205 using WebKit::WebPoint;
206 using WebKit::WebPopupMenuInfo; 206 using WebKit::WebPopupMenuInfo;
207 using WebKit::WebRange; 207 using WebKit::WebRange;
208 using WebKit::WebRect; 208 using WebKit::WebRect;
209 using WebKit::WebScriptSource; 209 using WebKit::WebScriptSource;
210 using WebKit::WebSearchableFormData; 210 using WebKit::WebSearchableFormData;
211 using WebKit::WebSecurityOrigin; 211 using WebKit::WebSecurityOrigin;
212 using WebKit::WebSettings; 212 using WebKit::WebSettings;
213 using WebKit::WebSharedWorker; 213 using WebKit::WebSharedWorker;
214 using WebKit::WebSize; 214 using WebKit::WebSize;
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 } 542 }
543 543
544 void RenderView::UserMetricsRecordAction(const std::string& action) { 544 void RenderView::UserMetricsRecordAction(const std::string& action) {
545 Send(new ViewHostMsg_UserMetricsRecordAction(routing_id_, action)); 545 Send(new ViewHostMsg_UserMetricsRecordAction(routing_id_, action));
546 } 546 }
547 547
548 void RenderView::PluginCrashed(const FilePath& plugin_path) { 548 void RenderView::PluginCrashed(const FilePath& plugin_path) {
549 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); 549 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path));
550 } 550 }
551 551
552 WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame,
553 const WebPluginParams& params) {
554 WebPluginInfo info;
555 bool found;
556 std::string mime_type;
557 Send(new ViewHostMsg_GetPluginInfo(
558 params.url, frame->top()->url(), params.mimeType.utf8(), &found,
559 &info, &mime_type));
560 if (!found || !info.enabled)
561 return NULL;
562 scoped_refptr<pepper::PluginModule> pepper_module =
563 PepperPluginRegistry::GetInstance()->GetModule(info.path);
564 if (pepper_module)
565 return CreatePepperPlugin(frame, params, info.path, pepper_module.get());
566 else
567 return CreateNPAPIPlugin(frame, params, info.path, mime_type);
568 }
569
552 #if defined(OS_MACOSX) 570 #if defined(OS_MACOSX)
553 void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) { 571 void RenderView::RegisterPluginDelegate(WebPluginDelegateProxy* delegate) {
554 plugin_delegates_.insert(delegate); 572 plugin_delegates_.insert(delegate);
555 } 573 }
556 574
557 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) { 575 void RenderView::UnregisterPluginDelegate(WebPluginDelegateProxy* delegate) {
558 plugin_delegates_.erase(delegate); 576 plugin_delegates_.erase(delegate);
559 } 577 }
560 #endif 578 #endif
561 579
(...skipping 1641 matching lines...) Expand 10 before | Expand all | Expand 10 after
2203 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_)); 2221 SendAndRunNestedMessageLoop(new ViewHostMsg_RunModal(routing_id_));
2204 } 2222 }
2205 2223
2206 // WebKit::WebFrameClient ----------------------------------------------------- 2224 // WebKit::WebFrameClient -----------------------------------------------------
2207 2225
2208 WebPlugin* RenderView::createPlugin(WebFrame* frame, 2226 WebPlugin* RenderView::createPlugin(WebFrame* frame,
2209 const WebPluginParams& params) { 2227 const WebPluginParams& params) {
2210 bool found = false; 2228 bool found = false;
2211 WebPluginInfo info; 2229 WebPluginInfo info;
2212 GURL url(params.url); 2230 GURL url(params.url);
2213 std::string mime_type(params.mimeType.utf8());
2214 std::string actual_mime_type; 2231 std::string actual_mime_type;
2215 Send(new ViewHostMsg_GetPluginInfo(url, 2232 Send(new ViewHostMsg_GetPluginInfo(url,
2216 frame->top()->url(), 2233 frame->top()->url(),
2217 mime_type, 2234 params.mimeType.utf8(),
2218 &found, 2235 &found,
2219 &info, 2236 &info,
2220 &actual_mime_type)); 2237 &actual_mime_type));
2221 2238
2222 if (!found || !info.enabled) 2239 if (!found || !info.enabled)
2223 return NULL; 2240 return NULL;
2224 2241
2225 if (!AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS) && 2242 if (info.path.value() != kDefaultPluginLibraryName) {
2226 info.path.value() != kDefaultPluginLibraryName) { 2243 if (!AllowContentType(CONTENT_SETTINGS_TYPE_PLUGINS)) {
2227 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch( 2244 DCHECK(CommandLine::ForCurrentProcess()->HasSwitch(
2228 switches::kEnableClickToPlay)); 2245 switches::kEnableClickToPlay));
2229 didNotAllowPlugins(frame); 2246 didNotAllowPlugins(frame);
2230 return CreatePluginPlaceholder(frame, params); 2247 return CreatePluginPlaceholder(frame, params);
2248 }
2249 scoped_refptr<pepper::PluginModule> pepper_module =
2250 PepperPluginRegistry::GetInstance()->GetModule(info.path);
2251 if (pepper_module)
2252 return CreatePepperPlugin(frame, params, info.path, pepper_module.get());
2253 if (CommandLine::ForCurrentProcess()->HasSwitch(
2254 switches::kBlockNonSandboxedPlugins)) {
2255 Send(new ViewHostMsg_NonSandboxedPluginBlocked(routing_id_, info.name));
2256 return CreatePluginPlaceholder(frame, params);
2257 }
2231 } 2258 }
2232 return CreatePluginInternal(frame, params, &info, actual_mime_type); 2259 return CreateNPAPIPlugin(frame, params, info.path, actual_mime_type);
2233 } 2260 }
2234 2261
2235 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) { 2262 WebWorker* RenderView::createWorker(WebFrame* frame, WebWorkerClient* client) {
2236 WebApplicationCacheHostImpl* appcache_host = 2263 WebApplicationCacheHostImpl* appcache_host =
2237 WebApplicationCacheHostImpl::FromFrame(frame); 2264 WebApplicationCacheHostImpl::FromFrame(frame);
2238 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0; 2265 int appcache_host_id = appcache_host ? appcache_host->host_id() : 0;
2239 return new WebWorkerProxy(client, RenderThread::current(), routing_id_, 2266 return new WebWorkerProxy(client, RenderThread::current(), routing_id_,
2240 appcache_host_id); 2267 appcache_host_id);
2241 } 2268 }
2242 2269
(...skipping 1436 matching lines...) Expand 10 before | Expand all | Expand 10 after
3679 content_blocked_[settings_type] = true; 3706 content_blocked_[settings_type] = true;
3680 Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type)); 3707 Send(new ViewHostMsg_ContentBlocked(routing_id_, settings_type));
3681 } 3708 }
3682 } 3709 }
3683 3710
3684 void RenderView::ClearBlockedContentSettings() { 3711 void RenderView::ClearBlockedContentSettings() {
3685 for (size_t i = 0; i < arraysize(content_blocked_); ++i) 3712 for (size_t i = 0; i < arraysize(content_blocked_); ++i)
3686 content_blocked_[i] = false; 3713 content_blocked_[i] = false;
3687 } 3714 }
3688 3715
3689 WebPlugin* RenderView::CreatePluginInternal(WebFrame* frame, 3716 WebPlugin* RenderView::CreatePepperPlugin(WebFrame* frame,
3690 const WebPluginParams& params, 3717 const WebPluginParams& params,
3691 WebPluginInfo* plugin_info, 3718 const FilePath& path,
3692 const std::string& mime_type) { 3719 pepper::PluginModule* pepper_module) {
3720 WebPlugin* plugin = new pepper::WebPluginImpl(pepper_module, params,
3721 pepper_delegate_.AsWeakPtr());
3722 if (plugin && !frame->parent() && frame->document().isPluginDocument()) {
3723 // If this is a full-page plugin hosting the internal PDF plugin, we want
3724 // to notify the browser so that it can treat things like zooming
3725 // differently.
3726 // TODO(sanjeevr): Use a Pepper interface to determine this rather than
3727 // hardcode this for the PDF plugin path.
3728 FilePath pdf_path;
3729 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
3730 if (path == pdf_path)
3731 Send(new ViewHostMsg_SetDisplayingPDFContent(routing_id_));
3732 }
3733 return plugin;
3734 }
3735
3736 WebPlugin* RenderView::CreateNPAPIPlugin(WebFrame* frame,
3737 const WebPluginParams& params,
3738 const FilePath& path,
3739 const std::string& mime_type) {
3693 std::string actual_mime_type(mime_type); 3740 std::string actual_mime_type(mime_type);
3694 WebPluginInfo info;
3695 if (plugin_info != NULL) {
3696 info = *plugin_info;
3697 } else {
3698 bool found;
3699 std::string actual_mime_type(mime_type);
3700 Send(new ViewHostMsg_GetPluginInfo(
3701 params.url, frame->top()->url(), params.mimeType.utf8(), &found,
3702 &info, &actual_mime_type));
3703 if (!found)
3704 info.enabled = false;
3705 }
3706 if (!info.enabled)
3707 return NULL;
3708
3709 if (actual_mime_type.empty()) 3741 if (actual_mime_type.empty())
3710 actual_mime_type = params.mimeType.utf8(); 3742 actual_mime_type = params.mimeType.utf8();
3711 3743
3712 scoped_refptr<pepper::PluginModule> pepper_module = 3744 return new webkit_glue::WebPluginImpl(frame, params, path,
3713 PepperPluginRegistry::GetInstance()->GetModule(info.path);
3714 if (pepper_module) {
3715 WebPlugin* plugin = new pepper::WebPluginImpl(pepper_module, params,
3716 pepper_delegate_.AsWeakPtr());
3717 if (plugin && !frame->parent() && frame->document().isPluginDocument()) {
3718 // If this is a full-page plugin hosting the internal PDF plugin, we want
3719 // to notify the browser so that it can treat things like zooming
3720 // differently.
3721 // TODO(sanjeevr): Use a Pepper interface to determine this rather than
3722 // hardcode this for the PDF plugin path.
3723 FilePath pdf_path;
3724 PathService::Get(chrome::FILE_PDF_PLUGIN, &pdf_path);
3725 if (info.path == pdf_path)
3726 Send(new ViewHostMsg_SetDisplayingPDFContent(routing_id_));
3727 }
3728 return plugin;
3729 }
3730
3731 return new webkit_glue::WebPluginImpl(frame, params, info.path,
3732 actual_mime_type, AsWeakPtr()); 3745 actual_mime_type, AsWeakPtr());
3733 } 3746 }
3734 3747
3735 WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame, 3748 WebPlugin* RenderView::CreatePluginPlaceholder(WebFrame* frame,
3736 const WebPluginParams& params) { 3749 const WebPluginParams& params) {
3737 // |blocked_plugin| will delete itself when the WebViewPlugin is destroyed. 3750 // |blocked_plugin| will delete itself when the WebViewPlugin is destroyed.
3738 BlockedPlugin* blocked_plugin = new BlockedPlugin(this, frame, params); 3751 BlockedPlugin* blocked_plugin = new BlockedPlugin(this, frame, params);
3739 WebViewPlugin* plugin = blocked_plugin->plugin(); 3752 WebViewPlugin* plugin = blocked_plugin->plugin();
3740 webkit_preferences_.Apply(plugin->web_view()); 3753 webkit_preferences_.Apply(plugin->web_view());
3741 return plugin; 3754 return plugin;
(...skipping 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after
5301 // the origins of the two domains are different. This can be treated as a 5314 // the origins of the two domains are different. This can be treated as a
5302 // top level navigation and routed back to the host. 5315 // top level navigation and routed back to the host.
5303 WebKit::WebFrame* opener = frame->opener(); 5316 WebKit::WebFrame* opener = frame->opener();
5304 if (opener) { 5317 if (opener) {
5305 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) 5318 if (url.GetOrigin() != GURL(opener->url()).GetOrigin())
5306 return true; 5319 return true;
5307 } 5320 }
5308 } 5321 }
5309 return false; 5322 return false;
5310 } 5323 }
OLDNEW
« no previous file with comments | « chrome/renderer/render_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698