OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/renderer_host/buffered_resource_handler.h" | 5 #include "content/browser/renderer_host/buffered_resource_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) | 382 host_->delegate()->ShouldForceDownloadResource(request_->url(), type)) |
383 return true; | 383 return true; |
384 | 384 |
385 // MIME type checking. | 385 // MIME type checking. |
386 if (net::IsSupportedMimeType(type)) | 386 if (net::IsSupportedMimeType(type)) |
387 return false; | 387 return false; |
388 | 388 |
389 // Finally, check the plugin list. | 389 // Finally, check the plugin list. |
390 bool allow_wildcard = false; | 390 bool allow_wildcard = false; |
391 bool stale = false; | 391 bool stale = false; |
392 std::vector<webkit::npapi::WebPluginInfo> plugins; | 392 std::vector<webkit::WebPluginInfo> plugins; |
393 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( | 393 webkit::npapi::PluginList::Singleton()->GetPluginInfoArray( |
394 request_->url(), type, allow_wildcard, &stale, &plugins, NULL); | 394 request_->url(), type, allow_wildcard, &stale, &plugins, NULL); |
395 if (need_plugin_list) { | 395 if (need_plugin_list) { |
396 if (stale) { | 396 if (stale) { |
397 *need_plugin_list = true; | 397 *need_plugin_list = true; |
398 return true; | 398 return true; |
399 } | 399 } |
400 } else { | 400 } else { |
401 DCHECK(!stale); | 401 DCHECK(!stale); |
402 } | 402 } |
403 | 403 |
404 for (size_t i = 0; i < plugins.size(); ++i) { | 404 for (size_t i = 0; i < plugins.size(); ++i) { |
405 if (webkit::npapi::IsPluginEnabled(plugins[i])) | 405 if (webkit::IsPluginEnabled(plugins[i])) |
406 return false; | 406 return false; |
407 } | 407 } |
408 return true; | 408 return true; |
409 } | 409 } |
410 | 410 |
411 void BufferedResourceHandler::UseAlternateResourceHandler( | 411 void BufferedResourceHandler::UseAlternateResourceHandler( |
412 int request_id, | 412 int request_id, |
413 ResourceHandler* handler) { | 413 ResourceHandler* handler) { |
414 ResourceDispatcherHostRequestInfo* info = | 414 ResourceDispatcherHostRequestInfo* info = |
415 ResourceDispatcherHost::InfoForRequest(request_); | 415 ResourceDispatcherHost::InfoForRequest(request_); |
(...skipping 17 matching lines...) Expand all Loading... |
433 // from the extra request info because the CrossSiteResourceHandler (part of | 433 // from the extra request info because the CrossSiteResourceHandler (part of |
434 // the original ResourceHandler chain) will be deleted by the next statement. | 434 // the original ResourceHandler chain) will be deleted by the next statement. |
435 info->set_cross_site_handler(NULL); | 435 info->set_cross_site_handler(NULL); |
436 | 436 |
437 // This is handled entirely within the new ResourceHandler, so just reset the | 437 // This is handled entirely within the new ResourceHandler, so just reset the |
438 // original ResourceHandler. | 438 // original ResourceHandler. |
439 real_handler_ = handler; | 439 real_handler_ = handler; |
440 } | 440 } |
441 | 441 |
442 void BufferedResourceHandler::LoadPlugins() { | 442 void BufferedResourceHandler::LoadPlugins() { |
443 std::vector<webkit::npapi::WebPluginInfo> plugins; | 443 std::vector<webkit::WebPluginInfo> plugins; |
444 webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); | 444 webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); |
445 | 445 |
446 BrowserThread::PostTask( | 446 BrowserThread::PostTask( |
447 BrowserThread::IO, FROM_HERE, | 447 BrowserThread::IO, FROM_HERE, |
448 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded)); | 448 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded)); |
449 } | 449 } |
450 | 450 |
451 void BufferedResourceHandler::OnPluginsLoaded() { | 451 void BufferedResourceHandler::OnPluginsLoaded() { |
452 wait_for_plugins_ = false; | 452 wait_for_plugins_ = false; |
453 if (!request_) | 453 if (!request_) |
454 return; | 454 return; |
455 | 455 |
456 ResourceDispatcherHostRequestInfo* info = | 456 ResourceDispatcherHostRequestInfo* info = |
457 ResourceDispatcherHost::InfoForRequest(request_); | 457 ResourceDispatcherHost::InfoForRequest(request_); |
458 host_->PauseRequest(info->child_id(), info->request_id(), false); | 458 host_->PauseRequest(info->child_id(), info->request_id(), false); |
459 if (!CompleteResponseStarted(info->request_id(), false)) | 459 if (!CompleteResponseStarted(info->request_id(), false)) |
460 host_->CancelRequest(info->child_id(), info->request_id(), false); | 460 host_->CancelRequest(info->child_id(), info->request_id(), false); |
461 } | 461 } |
OLD | NEW |