Chromium Code Reviews| 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/webui/url_data_manager_backend.h" | 5 #include "content/browser/webui/url_data_manager_backend.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 if (!url.is_valid()) { | 75 if (!url.is_valid()) { |
| 76 NOTREACHED(); | 76 NOTREACHED(); |
| 77 return false; | 77 return false; |
| 78 } | 78 } |
| 79 | 79 |
| 80 return true; | 80 return true; |
| 81 } | 81 } |
| 82 | 82 |
| 83 // Parse |url| to get the path which will be used to resolve the request. The | 83 // Parse |url| to get the path which will be used to resolve the request. The |
| 84 // path is the remaining portion after the scheme and hostname. | 84 // path is the remaining portion after the scheme and hostname. |
| 85 void URLToRequestPath(const GURL& url, std::string* path) { | 85 std::string URLToRequestPath(const GURL& url) { |
|
Charlie Reis
2015/07/16 19:25:03
Why can't we just use GURL::path()? This seems to
raymes
2015/07/17 01:58:29
I don't know the answer to that, I didn't write th
Charlie Reis
2015/07/17 23:45:22
Wow, this goes back to the initial commit:
https:/
raymes
2015/07/20 06:46:22
I no longer change this file in the latest patchse
| |
| 86 const std::string& spec = url.possibly_invalid_spec(); | 86 const std::string& spec = url.possibly_invalid_spec(); |
| 87 const url::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); | 87 const url::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); |
| 88 // + 1 to skip the slash at the beginning of the path. | 88 // + 1 to skip the slash at the beginning of the path. |
| 89 int offset = parsed.CountCharactersBefore(url::Parsed::PATH, false) + 1; | 89 int offset = parsed.CountCharactersBefore(url::Parsed::PATH, false) + 1; |
| 90 | 90 |
| 91 std::string path; | |
| 91 if (offset < static_cast<int>(spec.size())) | 92 if (offset < static_cast<int>(spec.size())) |
| 92 path->assign(spec.substr(offset)); | 93 path = spec.substr(offset); |
| 94 | |
| 95 // Remove the query string if there is one. | |
| 96 return path.substr(0, path.find_last_of('?')); | |
| 93 } | 97 } |
| 94 | 98 |
| 95 // Returns a value of 'Origin:' header for the |request| if the header is set. | 99 // Returns a value of 'Origin:' header for the |request| if the header is set. |
| 96 // Otherwise returns an empty string. | 100 // Otherwise returns an empty string. |
| 97 std::string GetOriginHeaderValue(const net::URLRequest* request) { | 101 std::string GetOriginHeaderValue(const net::URLRequest* request) { |
| 98 std::string result; | 102 std::string result; |
| 99 if (request->extra_request_headers().GetHeader( | 103 if (request->extra_request_headers().GetHeader( |
| 100 net::HttpRequestHeaders::kOrigin, &result)) | 104 net::HttpRequestHeaders::kOrigin, &result)) |
| 101 return result; | 105 return result; |
| 102 net::HttpRequestHeaders headers; | 106 net::HttpRequestHeaders headers; |
| (...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 if (!CheckURLIsValid(request->url())) | 582 if (!CheckURLIsValid(request->url())) |
| 579 return false; | 583 return false; |
| 580 | 584 |
| 581 URLDataSourceImpl* source = GetDataSourceFromURL(request->url()); | 585 URLDataSourceImpl* source = GetDataSourceFromURL(request->url()); |
| 582 if (!source) | 586 if (!source) |
| 583 return false; | 587 return false; |
| 584 | 588 |
| 585 if (!source->source()->ShouldServiceRequest(request)) | 589 if (!source->source()->ShouldServiceRequest(request)) |
| 586 return false; | 590 return false; |
| 587 | 591 |
| 588 std::string path; | 592 std::string path = URLToRequestPath(request->url()); |
| 589 URLToRequestPath(request->url(), &path); | |
| 590 source->source()->WillServiceRequest(request, &path); | 593 source->source()->WillServiceRequest(request, &path); |
| 591 | 594 |
| 592 // Save this request so we know where to send the data. | 595 // Save this request so we know where to send the data. |
| 593 RequestID request_id = next_request_id_++; | 596 RequestID request_id = next_request_id_++; |
| 594 pending_requests_.insert(std::make_pair(request_id, job)); | 597 pending_requests_.insert(std::make_pair(request_id, job)); |
| 595 | 598 |
| 596 job->set_allow_caching(source->source()->AllowCaching()); | 599 job->set_allow_caching(source->source()->AllowCaching()); |
| 597 job->set_add_content_security_policy( | 600 job->set_add_content_security_policy( |
| 598 source->source()->ShouldAddContentSecurityPolicy()); | 601 source->source()->ShouldAddContentSecurityPolicy()); |
| 599 job->set_content_security_policy_object_source( | 602 job->set_content_security_policy_object_source( |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 764 | 767 |
| 765 } // namespace | 768 } // namespace |
| 766 | 769 |
| 767 net::URLRequestJobFactory::ProtocolHandler* | 770 net::URLRequestJobFactory::ProtocolHandler* |
| 768 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, | 771 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, |
| 769 bool is_incognito) { | 772 bool is_incognito) { |
| 770 return new DevToolsJobFactory(resource_context, is_incognito); | 773 return new DevToolsJobFactory(resource_context, is_incognito); |
| 771 } | 774 } |
| 772 | 775 |
| 773 } // namespace content | 776 } // namespace content |
| OLD | NEW |