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

Side by Side Diff: content/browser/plugin_service_impl.cc

Issue 12114045: Broke ContentSettingBubbleModelTest.Plugins on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/plugin_service_impl.h" 5 #include "content/browser/plugin_service_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 const FilePath& broker_path) { 252 const FilePath& broker_path) {
253 for (PpapiBrokerProcessHostIterator iter; !iter.Done(); ++iter) { 253 for (PpapiBrokerProcessHostIterator iter; !iter.Done(); ++iter) {
254 if (iter->plugin_path() == broker_path) 254 if (iter->plugin_path() == broker_path)
255 return *iter; 255 return *iter;
256 } 256 }
257 257
258 return NULL; 258 return NULL;
259 } 259 }
260 260
261 PluginProcessHost* PluginServiceImpl::FindOrStartNpapiPluginProcess( 261 PluginProcessHost* PluginServiceImpl::FindOrStartNpapiPluginProcess(
262 int render_process_id,
263 const FilePath& plugin_path) { 262 const FilePath& plugin_path) {
264 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 263 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
265 264
266 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path))
267 return NULL;
268
269 PluginProcessHost* plugin_host = FindNpapiPluginProcess(plugin_path); 265 PluginProcessHost* plugin_host = FindNpapiPluginProcess(plugin_path);
270 if (plugin_host) 266 if (plugin_host)
271 return plugin_host; 267 return plugin_host;
272 268
273 webkit::WebPluginInfo info; 269 webkit::WebPluginInfo info;
274 if (!GetPluginInfoByPath(plugin_path, &info)) { 270 if (!GetPluginInfoByPath(plugin_path, &info)) {
275 return NULL; 271 return NULL;
276 } 272 }
277 273
278 // This plugin isn't loaded by any plugin process, so create a new process. 274 // This plugin isn't loaded by any plugin process, so create a new process.
279 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost()); 275 scoped_ptr<PluginProcessHost> new_host(new PluginProcessHost());
280 if (!new_host->Init(info)) { 276 if (!new_host->Init(info)) {
281 NOTREACHED(); // Init is not expected to fail. 277 NOTREACHED(); // Init is not expected to fail.
282 return NULL; 278 return NULL;
283 } 279 }
284 return new_host.release(); 280 return new_host.release();
285 } 281 }
286 282
287 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess( 283 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiPluginProcess(
288 int render_process_id,
289 const FilePath& plugin_path, 284 const FilePath& plugin_path,
290 const FilePath& profile_data_directory, 285 const FilePath& profile_data_directory,
291 PpapiPluginProcessHost::PluginClient* client) { 286 PpapiPluginProcessHost::PluginClient* client) {
292 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 287 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
293 288
294 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path))
295 return NULL;
296
297 PpapiPluginProcessHost* plugin_host = 289 PpapiPluginProcessHost* plugin_host =
298 FindPpapiPluginProcess(plugin_path, profile_data_directory); 290 FindPpapiPluginProcess(plugin_path, profile_data_directory);
299 if (plugin_host) 291 if (plugin_host)
300 return plugin_host; 292 return plugin_host;
301 293
302 // Validate that the plugin is actually registered. 294 // Validate that the plugin is actually registered.
303 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); 295 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path);
304 if (!info) 296 if (!info)
305 return NULL; 297 return NULL;
306 298
307 // This plugin isn't loaded by any plugin process, so create a new process. 299 // This plugin isn't loaded by any plugin process, so create a new process.
308 return PpapiPluginProcessHost::CreatePluginHost( 300 return PpapiPluginProcessHost::CreatePluginHost(
309 *info, profile_data_directory, 301 *info, profile_data_directory,
310 client->GetResourceContext()->GetHostResolver()); 302 client->GetResourceContext()->GetHostResolver());
311 } 303 }
312 304
313 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess( 305 PpapiPluginProcessHost* PluginServiceImpl::FindOrStartPpapiBrokerProcess(
314 int render_process_id,
315 const FilePath& plugin_path) { 306 const FilePath& plugin_path) {
316 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 307 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
317 308
318 if (filter_ && !filter_->CanLoadPlugin(render_process_id, plugin_path))
319 return NULL;
320
321 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path); 309 PpapiPluginProcessHost* plugin_host = FindPpapiBrokerProcess(plugin_path);
322 if (plugin_host) 310 if (plugin_host)
323 return plugin_host; 311 return plugin_host;
324 312
325 // Validate that the plugin is actually registered. 313 // Validate that the plugin is actually registered.
326 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path); 314 PepperPluginInfo* info = GetRegisteredPpapiPluginInfo(plugin_path);
327 if (!info) 315 if (!info)
328 return NULL; 316 return NULL;
329 317
330 // TODO(ddorwin): Uncomment once out of process is supported. 318 // TODO(ddorwin): Uncomment once out of process is supported.
(...skipping 20 matching lines...) Expand all
351 render_view_id, 339 render_view_id,
352 page_url, 340 page_url,
353 client->GetResourceContext() 341 client->GetResourceContext()
354 }; 342 };
355 GetPlugins(base::Bind( 343 GetPlugins(base::Bind(
356 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin, 344 &PluginServiceImpl::ForwardGetAllowedPluginForOpenChannelToPlugin,
357 base::Unretained(this), params, url, mime_type, client)); 345 base::Unretained(this), params, url, mime_type, client));
358 } 346 }
359 347
360 void PluginServiceImpl::OpenChannelToPpapiPlugin( 348 void PluginServiceImpl::OpenChannelToPpapiPlugin(
361 int render_process_id,
362 const FilePath& plugin_path, 349 const FilePath& plugin_path,
363 const FilePath& profile_data_directory, 350 const FilePath& profile_data_directory,
364 PpapiPluginProcessHost::PluginClient* client) { 351 PpapiPluginProcessHost::PluginClient* client) {
365 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess( 352 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiPluginProcess(
366 render_process_id, plugin_path, profile_data_directory, client); 353 plugin_path, profile_data_directory, client);
367 if (plugin_host) { 354 if (plugin_host) {
368 plugin_host->OpenChannelToPlugin(client); 355 plugin_host->OpenChannelToPlugin(client);
369 } else { 356 } else {
370 // Send error. 357 // Send error.
371 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0); 358 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0);
372 } 359 }
373 } 360 }
374 361
375 void PluginServiceImpl::OpenChannelToPpapiBroker( 362 void PluginServiceImpl::OpenChannelToPpapiBroker(
376 int render_process_id,
377 const FilePath& path, 363 const FilePath& path,
378 PpapiPluginProcessHost::BrokerClient* client) { 364 PpapiPluginProcessHost::BrokerClient* client) {
379 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess( 365 PpapiPluginProcessHost* plugin_host = FindOrStartPpapiBrokerProcess(path);
380 render_process_id, path);
381 if (plugin_host) { 366 if (plugin_host) {
382 plugin_host->OpenChannelToPlugin(client); 367 plugin_host->OpenChannelToPlugin(client);
383 } else { 368 } else {
384 // Send error. 369 // Send error.
385 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0); 370 client->OnPpapiChannelOpened(IPC::ChannelHandle(), base::kNullProcessId, 0);
386 } 371 }
387 } 372 }
388 373
389 void PluginServiceImpl::CancelOpenChannelToNpapiPlugin( 374 void PluginServiceImpl::CancelOpenChannelToNpapiPlugin(
390 PluginProcessHost::Client* client) { 375 PluginProcessHost::Client* client) {
(...skipping 28 matching lines...) Expand all
419 url, page_url, mime_type, allow_wildcard, 404 url, page_url, mime_type, allow_wildcard,
420 NULL, &info, NULL); 405 NULL, &info, NULL);
421 FilePath plugin_path; 406 FilePath plugin_path;
422 if (found) 407 if (found)
423 plugin_path = info.path; 408 plugin_path = info.path;
424 409
425 // Now we jump back to the IO thread to finish opening the channel. 410 // Now we jump back to the IO thread to finish opening the channel.
426 BrowserThread::PostTask( 411 BrowserThread::PostTask(
427 BrowserThread::IO, FROM_HERE, 412 BrowserThread::IO, FROM_HERE,
428 base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin, 413 base::Bind(&PluginServiceImpl::FinishOpenChannelToPlugin,
429 base::Unretained(this), 414 base::Unretained(this), plugin_path, client));
430 render_process_id,
431 plugin_path,
432 client));
433 } 415 }
434 416
435 void PluginServiceImpl::FinishOpenChannelToPlugin( 417 void PluginServiceImpl::FinishOpenChannelToPlugin(
436 int render_process_id,
437 const FilePath& plugin_path, 418 const FilePath& plugin_path,
438 PluginProcessHost::Client* client) { 419 PluginProcessHost::Client* client) {
439 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 420 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
440 421
441 // Make sure it hasn't been canceled yet. 422 // Make sure it hasn't been canceled yet.
442 if (!ContainsKey(pending_plugin_clients_, client)) 423 if (!ContainsKey(pending_plugin_clients_, client))
443 return; 424 return;
444 pending_plugin_clients_.erase(client); 425 pending_plugin_clients_.erase(client);
445 426
446 PluginProcessHost* plugin_host = FindOrStartNpapiPluginProcess( 427 PluginProcessHost* plugin_host = FindOrStartNpapiPluginProcess(plugin_path);
447 render_process_id, plugin_path);
448 if (plugin_host) { 428 if (plugin_host) {
449 client->OnFoundPluginProcessHost(plugin_host); 429 client->OnFoundPluginProcessHost(plugin_host);
450 plugin_host->OpenChannelToPlugin(client); 430 plugin_host->OpenChannelToPlugin(client);
451 } else { 431 } else {
452 client->OnError(); 432 client->OnError();
453 } 433 }
454 } 434 }
455 435
456 bool PluginServiceImpl::GetPluginInfoArray( 436 bool PluginServiceImpl::GetPluginInfoArray(
457 const GURL& url, 437 const GURL& url,
(...skipping 18 matching lines...) Expand all
476 webkit::WebPluginInfo* info, 456 webkit::WebPluginInfo* info,
477 std::string* actual_mime_type) { 457 std::string* actual_mime_type) {
478 std::vector<webkit::WebPluginInfo> plugins; 458 std::vector<webkit::WebPluginInfo> plugins;
479 std::vector<std::string> mime_types; 459 std::vector<std::string> mime_types;
480 bool stale = GetPluginInfoArray( 460 bool stale = GetPluginInfoArray(
481 url, mime_type, allow_wildcard, &plugins, &mime_types); 461 url, mime_type, allow_wildcard, &plugins, &mime_types);
482 if (is_stale) 462 if (is_stale)
483 *is_stale = stale; 463 *is_stale = stale;
484 464
485 for (size_t i = 0; i < plugins.size(); ++i) { 465 for (size_t i = 0; i < plugins.size(); ++i) {
486 if (!filter_ || filter_->IsPluginEnabled(render_process_id, 466 if (!filter_ || filter_->ShouldUsePlugin(render_process_id,
487 render_view_id, 467 render_view_id,
488 context, 468 context,
489 url, 469 url,
490 page_url, 470 page_url,
491 &plugins[i])) { 471 &plugins[i])) {
492 *info = plugins[i]; 472 *info = plugins[i];
493 if (actual_mime_type) 473 if (actual_mime_type)
494 *actual_mime_type = mime_types[i]; 474 *actual_mime_type = mime_types[i];
495 return true; 475 return true;
496 } 476 }
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 void PluginServiceImpl::GetInternalPlugins( 720 void PluginServiceImpl::GetInternalPlugins(
741 std::vector<webkit::WebPluginInfo>* plugins) { 721 std::vector<webkit::WebPluginInfo>* plugins) {
742 plugin_list_->GetInternalPlugins(plugins); 722 plugin_list_->GetInternalPlugins(plugins);
743 } 723 }
744 724
745 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() { 725 webkit::npapi::PluginList* PluginServiceImpl::GetPluginList() {
746 return plugin_list_; 726 return plugin_list_;
747 } 727 }
748 728
749 } // namespace content 729 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/plugin_service_impl.h ('k') | content/browser/plugin_service_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698