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

Side by Side Diff: chrome/browser/renderer_host/buffered_resource_handler.cc

Issue 5961004: Revert 69755 - Move the NPAPI files from webkit/glue/plugins to webkit/plugin... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years 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) 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/browser/renderer_host/buffered_resource_handler.h" 5 #include "chrome/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"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/browser_thread.h" 12 #include "chrome/browser/browser_thread.h"
13 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" 13 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
14 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 14 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
15 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" 15 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
16 #include "chrome/browser/renderer_host/x509_user_cert_resource_handler.h" 16 #include "chrome/browser/renderer_host/x509_user_cert_resource_handler.h"
17 #include "chrome/common/extensions/user_script.h" 17 #include "chrome/common/extensions/user_script.h"
18 #include "chrome/common/resource_response.h" 18 #include "chrome/common/resource_response.h"
19 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
20 #include "net/base/io_buffer.h" 20 #include "net/base/io_buffer.h"
21 #include "net/base/mime_sniffer.h" 21 #include "net/base/mime_sniffer.h"
22 #include "net/base/mime_util.h" 22 #include "net/base/mime_util.h"
23 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
24 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
25 #include "webkit/plugins/npapi/plugin_list.h" 25 #include "webkit/glue/plugins/plugin_list.h"
26 26
27 namespace { 27 namespace {
28 28
29 void RecordSnifferMetrics(bool sniffing_blocked, 29 void RecordSnifferMetrics(bool sniffing_blocked,
30 bool we_would_like_to_sniff, 30 bool we_would_like_to_sniff,
31 const std::string& mime_type) { 31 const std::string& mime_type) {
32 static scoped_refptr<base::Histogram> nosniff_usage = 32 static scoped_refptr<base::Histogram> nosniff_usage =
33 base::BooleanHistogram::FactoryGet( 33 base::BooleanHistogram::FactoryGet(
34 "nosniff.usage", base::Histogram::kUmaTargetedHistogramFlag); 34 "nosniff.usage", base::Histogram::kUmaTargetedHistogramFlag);
35 nosniff_usage->AddBoolean(sniffing_blocked); 35 nosniff_usage->AddBoolean(sniffing_blocked);
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 415
416 // Special-case user scripts to get downloaded instead of viewed. 416 // Special-case user scripts to get downloaded instead of viewed.
417 if (UserScript::HasUserScriptFileExtension(request_->url())) 417 if (UserScript::HasUserScriptFileExtension(request_->url()))
418 return true; 418 return true;
419 419
420 // MIME type checking. 420 // MIME type checking.
421 if (net::IsSupportedMimeType(type)) 421 if (net::IsSupportedMimeType(type))
422 return false; 422 return false;
423 423
424 if (need_plugin_list) { 424 if (need_plugin_list) {
425 if (!webkit::npapi::PluginList::Singleton()->PluginsLoaded()) { 425 if (!NPAPI::PluginList::Singleton()->PluginsLoaded()) {
426 *need_plugin_list = true; 426 *need_plugin_list = true;
427 return true; 427 return true;
428 } 428 }
429 } else { 429 } else {
430 DCHECK(webkit::npapi::PluginList::Singleton()->PluginsLoaded()); 430 DCHECK(NPAPI::PluginList::Singleton()->PluginsLoaded());
431 } 431 }
432 432
433 // Finally, check the plugin list. 433 // Finally, check the plugin list.
434 webkit::npapi::WebPluginInfo info; 434 WebPluginInfo info;
435 bool allow_wildcard = false; 435 bool allow_wildcard = false;
436 return !webkit::npapi::PluginList::Singleton()->GetPluginInfo( 436 return !NPAPI::PluginList::Singleton()->GetPluginInfo(
437 GURL(), type, allow_wildcard, &info, NULL) || !info.enabled; 437 GURL(), type, allow_wildcard, &info, NULL) || !info.enabled;
438 } 438 }
439 439
440 void BufferedResourceHandler::UseAlternateResourceHandler( 440 void BufferedResourceHandler::UseAlternateResourceHandler(
441 int request_id, 441 int request_id,
442 ResourceHandler* handler) { 442 ResourceHandler* handler) {
443 ResourceDispatcherHostRequestInfo* info = 443 ResourceDispatcherHostRequestInfo* info =
444 ResourceDispatcherHost::InfoForRequest(request_); 444 ResourceDispatcherHost::InfoForRequest(request_);
445 if (bytes_read_) { 445 if (bytes_read_) {
446 // A Read has already occured and we need to copy the data into the new 446 // A Read has already occured and we need to copy the data into the new
(...skipping 15 matching lines...) Expand all
462 // from the extra request info because the CrossSiteResourceHandler (part of 462 // from the extra request info because the CrossSiteResourceHandler (part of
463 // the original ResourceHandler chain) will be deleted by the next statement. 463 // the original ResourceHandler chain) will be deleted by the next statement.
464 info->set_cross_site_handler(NULL); 464 info->set_cross_site_handler(NULL);
465 465
466 // This is handled entirely within the new ResourceHandler, so just reset the 466 // This is handled entirely within the new ResourceHandler, so just reset the
467 // original ResourceHandler. 467 // original ResourceHandler.
468 real_handler_ = handler; 468 real_handler_ = handler;
469 } 469 }
470 470
471 void BufferedResourceHandler::LoadPlugins() { 471 void BufferedResourceHandler::LoadPlugins() {
472 std::vector<webkit::npapi::WebPluginInfo> plugins; 472 std::vector<WebPluginInfo> plugins;
473 webkit::npapi::PluginList::Singleton()->GetPlugins(false, &plugins); 473 NPAPI::PluginList::Singleton()->GetPlugins(false, &plugins);
474 474
475 BrowserThread::PostTask( 475 BrowserThread::PostTask(
476 BrowserThread::IO, FROM_HERE, 476 BrowserThread::IO, FROM_HERE,
477 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded)); 477 NewRunnableMethod(this, &BufferedResourceHandler::OnPluginsLoaded));
478 } 478 }
479 479
480 void BufferedResourceHandler::OnPluginsLoaded() { 480 void BufferedResourceHandler::OnPluginsLoaded() {
481 wait_for_plugins_ = false; 481 wait_for_plugins_ = false;
482 if (!request_) 482 if (!request_)
483 return; 483 return;
484 484
485 ResourceDispatcherHostRequestInfo* info = 485 ResourceDispatcherHostRequestInfo* info =
486 ResourceDispatcherHost::InfoForRequest(request_); 486 ResourceDispatcherHost::InfoForRequest(request_);
487 host_->PauseRequest(info->child_id(), info->request_id(), false); 487 host_->PauseRequest(info->child_id(), info->request_id(), false);
488 if (!CompleteResponseStarted(info->request_id(), false)) 488 if (!CompleteResponseStarted(info->request_id(), false))
489 host_->CancelRequest(info->child_id(), info->request_id(), false); 489 host_->CancelRequest(info->child_id(), info->request_id(), false);
490 } 490 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698