OLD | NEW |
---|---|
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/loader/mime_type_resource_handler.h" | 5 #include "content/browser/loader/mime_type_resource_handler.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
13 #include "base/single_thread_task_runner.h" | 13 #include "base/single_thread_task_runner.h" |
14 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
15 #include "base/strings/utf_string_conversions.h" | |
15 #include "base/thread_task_runner_handle.h" | 16 #include "base/thread_task_runner_handle.h" |
16 #include "components/mime_util/mime_util.h" | 17 #include "components/mime_util/mime_util.h" |
17 #include "content/browser/download/download_resource_handler.h" | 18 #include "content/browser/download/download_resource_handler.h" |
18 #include "content/browser/download/download_stats.h" | 19 #include "content/browser/download/download_stats.h" |
19 #include "content/browser/loader/certificate_resource_handler.h" | 20 #include "content/browser/loader/certificate_resource_handler.h" |
20 #include "content/browser/loader/resource_dispatcher_host_impl.h" | 21 #include "content/browser/loader/resource_dispatcher_host_impl.h" |
21 #include "content/browser/loader/resource_request_info_impl.h" | 22 #include "content/browser/loader/resource_request_info_impl.h" |
22 #include "content/browser/loader/stream_resource_handler.h" | 23 #include "content/browser/loader/stream_resource_handler.h" |
23 #include "content/public/browser/content_browser_client.h" | 24 #include "content/public/browser/content_browser_client.h" |
24 #include "content/public/browser/download_item.h" | 25 #include "content/public/browser/download_item.h" |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
374 if (mime_util::IsSupportedMimeType(mime_type)) | 375 if (mime_util::IsSupportedMimeType(mime_type)) |
375 return true; | 376 return true; |
376 | 377 |
377 bool handled_by_plugin; | 378 bool handled_by_plugin; |
378 if (!SelectPluginHandler(defer, &handled_by_plugin)) | 379 if (!SelectPluginHandler(defer, &handled_by_plugin)) |
379 return false; | 380 return false; |
380 if (handled_by_plugin || *defer) | 381 if (handled_by_plugin || *defer) |
381 return true; | 382 return true; |
382 } | 383 } |
383 | 384 |
385 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo); | |
386 if (base::ToLowerASCII(mime_type) == "application/x-x509-user-cert") | |
387 save_info->suggested_name = base::UTF8ToUTF16("user_cert.crt"); | |
mmenke
2015/10/29 15:34:56
Why not put this in GetSuggestedFilename? Also, w
svaldez
2015/10/29 16:32:19
Done.
| |
388 | |
384 // Install download handler | 389 // Install download handler |
385 info->set_is_download(true); | 390 info->set_is_download(true); |
386 scoped_ptr<ResourceHandler> handler( | 391 scoped_ptr<ResourceHandler> handler( |
387 host_->CreateResourceHandlerForDownload( | 392 host_->CreateResourceHandlerForDownload( |
388 request(), | 393 request(), |
389 true, // is_content_initiated | 394 true, // is_content_initiated |
390 must_download, | 395 must_download, |
391 DownloadItem::kInvalidId, | 396 DownloadItem::kInvalidId, |
392 scoped_ptr<DownloadSaveInfo>(new DownloadSaveInfo()), | 397 save_info.Pass(), |
393 DownloadUrlParameters::OnStartedCallback())); | 398 DownloadUrlParameters::OnStartedCallback())); |
394 return UseAlternateNextHandler(handler.Pass(), std::string()); | 399 return UseAlternateNextHandler(handler.Pass(), std::string()); |
395 } | 400 } |
396 | 401 |
397 bool MimeTypeResourceHandler::UseAlternateNextHandler( | 402 bool MimeTypeResourceHandler::UseAlternateNextHandler( |
398 scoped_ptr<ResourceHandler> new_handler, | 403 scoped_ptr<ResourceHandler> new_handler, |
399 const std::string& payload_for_old_handler) { | 404 const std::string& payload_for_old_handler) { |
400 if (response_->head.headers.get() && // Can be NULL if FTP. | 405 if (response_->head.headers.get() && // Can be NULL if FTP. |
401 response_->head.headers->response_code() / 100 != 2) { | 406 response_->head.headers->response_code() / 100 != 2) { |
402 // The response code indicates that this is an error page, but we don't | 407 // The response code indicates that this is an error page, but we don't |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
514 request()->LogUnblocked(); | 519 request()->LogUnblocked(); |
515 bool defer = false; | 520 bool defer = false; |
516 if (!ProcessResponse(&defer)) { | 521 if (!ProcessResponse(&defer)) { |
517 controller()->Cancel(); | 522 controller()->Cancel(); |
518 } else if (!defer) { | 523 } else if (!defer) { |
519 controller()->Resume(); | 524 controller()->Resume(); |
520 } | 525 } |
521 } | 526 } |
522 | 527 |
523 } // namespace content | 528 } // namespace content |
OLD | NEW |