| 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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 return std::find(schemes.begin(), schemes.end(), scheme) != schemes.end(); | 60 return std::find(schemes.begin(), schemes.end(), scheme) != schemes.end(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 // Parse a URL into the components used to resolve its request. |source_name| | 63 // Parse a URL into the components used to resolve its request. |source_name| |
| 64 // is the hostname and |path| is the remaining portion of the URL. | 64 // is the hostname and |path| is the remaining portion of the URL. |
| 65 void URLToRequest(const GURL& url, std::string* source_name, | 65 void URLToRequest(const GURL& url, std::string* source_name, |
| 66 std::string* path) { | 66 std::string* path) { |
| 67 std::vector<std::string> additional_schemes; | 67 std::vector<std::string> additional_schemes; |
| 68 DCHECK(url.SchemeIs(chrome::kChromeDevToolsScheme) || | 68 DCHECK(url.SchemeIs(chrome::kChromeDevToolsScheme) || |
| 69 url.SchemeIs(chrome::kChromeUIScheme) || | 69 url.SchemeIs(chrome::kChromeUIScheme) || |
| 70 url.SchemeIs(chrome::kDomDistillerScheme) || |
| 70 (GetContentClient()->browser()->GetAdditionalWebUISchemes( | 71 (GetContentClient()->browser()->GetAdditionalWebUISchemes( |
| 71 &additional_schemes), | 72 &additional_schemes), |
| 72 SchemeIsInSchemes(url.scheme(), additional_schemes))); | 73 SchemeIsInSchemes(url.scheme(), additional_schemes))); |
| 73 | 74 |
| 74 if (!url.is_valid()) { | 75 if (!url.is_valid()) { |
| 75 NOTREACHED(); | 76 NOTREACHED(); |
| 76 return; | 77 return; |
| 77 } | 78 } |
| 78 | 79 |
| 79 // Our input looks like: chrome://source_name/extra_bits?foo . | 80 if (url.SchemeIs(chrome::kDomDistillerScheme)) { |
| 80 // So the url's "host" is our source, and everything after the host is | 81 // Our input looks like: chrome-distiller://some-entry , so the scheme of |
| 81 // the path. | 82 // the URL is the source name. |
| 82 source_name->assign(url.host()); | 83 source_name->assign(chrome::kDomDistillerScheme); |
| 84 } else { |
| 85 // Our input looks like: chrome://source_name/extra_bits?foo . |
| 86 // So the url's "host" is our source, and everything after the host is |
| 87 // the path. |
| 88 source_name->assign(url.host()); |
| 89 } |
| 83 | 90 |
| 84 const std::string& spec = url.possibly_invalid_spec(); | 91 const std::string& spec = url.possibly_invalid_spec(); |
| 85 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); | 92 const url_parse::Parsed& parsed = url.parsed_for_possibly_invalid_spec(); |
| 86 // + 1 to skip the slash at the beginning of the path. | 93 // + 1 to skip the slash at the beginning of the path. |
| 87 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false) + 1; | 94 int offset = parsed.CountCharactersBefore(url_parse::Parsed::PATH, false) + 1; |
| 88 | 95 |
| 89 if (offset < static_cast<int>(spec.size())) | 96 if (offset < static_cast<int>(spec.size())) |
| 90 path->assign(spec.substr(offset)); | 97 path->assign(spec.substr(offset)); |
| 91 } | 98 } |
| 92 | 99 |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 671 |
| 665 } // namespace | 672 } // namespace |
| 666 | 673 |
| 667 net::URLRequestJobFactory::ProtocolHandler* | 674 net::URLRequestJobFactory::ProtocolHandler* |
| 668 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, | 675 CreateDevToolsProtocolHandler(content::ResourceContext* resource_context, |
| 669 bool is_incognito) { | 676 bool is_incognito) { |
| 670 return new DevToolsJobFactory(resource_context, is_incognito); | 677 return new DevToolsJobFactory(resource_context, is_incognito); |
| 671 } | 678 } |
| 672 | 679 |
| 673 } // namespace content | 680 } // namespace content |
| OLD | NEW |