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 // This file contains an implementation of the ResourceLoaderBridge class. | 5 // This file contains an implementation of the ResourceLoaderBridge class. |
6 // The class is implemented using net::URLRequest, meaning it is a "simple" | 6 // The class is implemented using net::URLRequest, meaning it is a "simple" |
7 // version that directly issues requests. The more complicated one used in the | 7 // version that directly issues requests. The more complicated one used in the |
8 // browser uses IPC. | 8 // browser uses IPC. |
9 // | 9 // |
10 // Because net::URLRequest only provides an asynchronous resource loading API, | 10 // Because net::URLRequest only provides an asynchronous resource loading API, |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 | 578 |
579 // Called on owner thread | 579 // Called on owner thread |
580 void ConvertRequestParamsForFileOverHTTPIfNeeded(RequestParams* params) { | 580 void ConvertRequestParamsForFileOverHTTPIfNeeded(RequestParams* params) { |
581 // Reset the status. | 581 // Reset the status. |
582 file_url_prefix_ .clear(); | 582 file_url_prefix_ .clear(); |
583 failed_file_request_status_.reset(); | 583 failed_file_request_status_.reset(); |
584 // Only do this when enabling file-over-http and request is file scheme. | 584 // Only do this when enabling file-over-http and request is file scheme. |
585 if (!g_file_over_http_params || !params->url.SchemeIsFile()) | 585 if (!g_file_over_http_params || !params->url.SchemeIsFile()) |
586 return; | 586 return; |
587 | 587 |
588 // For file protocol, method must be GET or NULL. | 588 // For file protocol, method must be GET, POST or NULL. |
589 DCHECK(params->method == "GET" || params->method.empty()); | 589 DCHECK(params->method == "GET" || params->method == "POST" || |
590 // File protocol doesn't support upload. | 590 params->method.empty()); |
591 DCHECK(!params->upload); | |
592 DCHECK(params->referrer.is_empty()); | |
593 DCHECK(!params->download_to_file); | 591 DCHECK(!params->download_to_file); |
594 | 592 |
595 // "GET" is the only method we allow. | 593 if (params->method.empty()) |
596 params->method = "GET"; | 594 params->method = "GET"; |
597 std::string original_request = params->url.spec(); | 595 std::string original_request = params->url.spec(); |
598 std::string::size_type found = | 596 std::string::size_type found = |
599 original_request.find(g_file_over_http_params->file_path_template); | 597 original_request.find(g_file_over_http_params->file_path_template); |
600 if (found == std::string::npos) | 598 if (found == std::string::npos) |
601 return; | 599 return; |
602 found += g_file_over_http_params->file_path_template.size(); | 600 found += g_file_over_http_params->file_path_template.size(); |
603 file_url_prefix_ = original_request.substr(0, found); | 601 file_url_prefix_ = original_request.substr(0, found); |
604 original_request.replace(0, found, | 602 original_request.replace(0, found, |
605 g_file_over_http_params->http_prefix.spec()); | 603 g_file_over_http_params->http_prefix.spec()); |
606 params->url = GURL(original_request); | 604 params->url = GURL(original_request); |
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 | 1038 |
1041 // static | 1039 // static |
1042 void SimpleResourceLoaderBridge::AllowFileOverHTTP( | 1040 void SimpleResourceLoaderBridge::AllowFileOverHTTP( |
1043 const std::string& file_path_template, const GURL& http_prefix) { | 1041 const std::string& file_path_template, const GURL& http_prefix) { |
1044 DCHECK(!file_path_template.empty()); | 1042 DCHECK(!file_path_template.empty()); |
1045 DCHECK(http_prefix.is_valid() && | 1043 DCHECK(http_prefix.is_valid() && |
1046 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); | 1044 (http_prefix.SchemeIs("http") || http_prefix.SchemeIs("https"))); |
1047 g_file_over_http_params = new FileOverHTTPParams(file_path_template, | 1045 g_file_over_http_params = new FileOverHTTPParams(file_path_template, |
1048 http_prefix); | 1046 http_prefix); |
1049 } | 1047 } |
OLD | NEW |