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

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

Issue 340057: Add first-class support for user scripts (Closed)
Patch Set: newness Created 11 years, 1 month 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
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/histogram.h" 9 #include "base/histogram.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/browser_process.h" 12 #include "chrome/browser/browser_process.h"
13 #include "chrome/browser/chrome_thread.h" 13 #include "chrome/browser/chrome_thread.h"
14 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h" 14 #include "chrome/browser/renderer_host/download_throttling_resource_handler.h"
15 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 15 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
16 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h" 16 #include "chrome/browser/renderer_host/resource_dispatcher_host_request_info.h"
17 #include "chrome/browser/renderer_host/x509_user_cert_resource_handler.h" 17 #include "chrome/browser/renderer_host/x509_user_cert_resource_handler.h"
18 #include "chrome/common/extensions/user_script.h"
18 #include "chrome/common/url_constants.h" 19 #include "chrome/common/url_constants.h"
19 #include "net/base/io_buffer.h" 20 #include "net/base/io_buffer.h"
20 #include "net/base/mime_sniffer.h" 21 #include "net/base/mime_sniffer.h"
21 #include "net/base/mime_util.h" 22 #include "net/base/mime_util.h"
22 #include "net/base/net_errors.h" 23 #include "net/base/net_errors.h"
23 #include "net/http/http_response_headers.h" 24 #include "net/http/http_response_headers.h"
24 #include "webkit/glue/plugins/plugin_list.h" 25 #include "webkit/glue/plugins/plugin_list.h"
25 26
26 namespace { 27 namespace {
27 28
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 if (disposition.compare(0, 4, "name") == 0) 442 if (disposition.compare(0, 4, "name") == 0)
442 should_download = false; 443 should_download = false;
443 444
444 // We have a content-disposition of "attachment" or unknown. 445 // We have a content-disposition of "attachment" or unknown.
445 // RFC 2183, section 2.8 says that an unknown disposition 446 // RFC 2183, section 2.8 says that an unknown disposition
446 // value should be treated as "attachment". 447 // value should be treated as "attachment".
447 if (should_download) 448 if (should_download)
448 return true; 449 return true;
449 } 450 }
450 451
452 // Special-case user scripts to get downloaded instead of viewed.
453 if (UserScript::HasUserScriptFileExtension(request_->url()))
454 return true;
455
451 // MIME type checking. 456 // MIME type checking.
452 if (net::IsSupportedMimeType(type)) 457 if (net::IsSupportedMimeType(type))
453 return false; 458 return false;
454 459
455 if (need_plugin_list) { 460 if (need_plugin_list) {
456 if (!NPAPI::PluginList::Singleton()->PluginsLoaded()) { 461 if (!NPAPI::PluginList::Singleton()->PluginsLoaded()) {
457 *need_plugin_list = true; 462 *need_plugin_list = true;
458 return true; 463 return true;
459 } 464 }
460 } else { 465 } else {
(...skipping 23 matching lines...) Expand all
484 if (handler->request_) { 489 if (handler->request_) {
485 ResourceDispatcherHostRequestInfo* info = 490 ResourceDispatcherHostRequestInfo* info =
486 ResourceDispatcherHost::InfoForRequest(handler->request_); 491 ResourceDispatcherHost::InfoForRequest(handler->request_);
487 handler->host_->PauseRequest(info->child_id(), info->request_id(), false); 492 handler->host_->PauseRequest(info->child_id(), info->request_id(), false);
488 if (!handler->CompleteResponseStarted(info->request_id(), false)) 493 if (!handler->CompleteResponseStarted(info->request_id(), false))
489 handler->host_->CancelRequest( 494 handler->host_->CancelRequest(
490 info->child_id(), info->request_id(), false); 495 info->child_id(), info->request_id(), false);
491 } 496 }
492 handler->Release(); 497 handler->Release();
493 } 498 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698