| 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/browser_url_handler_impl.h" | 5 #include "content/browser/browser_url_handler_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "cc/base/switches.h" | 9 #include "cc/base/switches.h" |
| 10 #include "content/browser/frame_host/debug_urls.h" | 10 #include "content/browser/frame_host/debug_urls.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 } | 58 } |
| 59 return false; | 59 return false; |
| 60 } | 60 } |
| 61 | 61 |
| 62 // Turns a non view-source URL into the corresponding view-source URL. | 62 // Turns a non view-source URL into the corresponding view-source URL. |
| 63 static bool ReverseViewSource(GURL* url, BrowserContext* browser_context) { | 63 static bool ReverseViewSource(GURL* url, BrowserContext* browser_context) { |
| 64 // No action necessary if the URL is already view-source: | 64 // No action necessary if the URL is already view-source: |
| 65 if (url->SchemeIs(kViewSourceScheme)) | 65 if (url->SchemeIs(kViewSourceScheme)) |
| 66 return false; | 66 return false; |
| 67 | 67 |
| 68 url_canon::Replacements<char> repl; | 68 url::Replacements<char> repl; |
| 69 repl.SetScheme(kViewSourceScheme, | 69 repl.SetScheme(kViewSourceScheme, |
| 70 url_parse::Component(0, strlen(kViewSourceScheme))); | 70 url::Component(0, strlen(kViewSourceScheme))); |
| 71 repl.SetPath(url->spec().c_str(), | 71 repl.SetPath(url->spec().c_str(), url::Component(0, url->spec().size())); |
| 72 url_parse::Component(0, url->spec().size())); | |
| 73 *url = url->ReplaceComponents(repl); | 72 *url = url->ReplaceComponents(repl); |
| 74 return true; | 73 return true; |
| 75 } | 74 } |
| 76 | 75 |
| 77 static bool DebugURLHandler(GURL* url, BrowserContext* browser_context) { | 76 static bool DebugURLHandler(GURL* url, BrowserContext* browser_context) { |
| 78 // If running inside the Telemetry test harness, allow automated | 77 // If running inside the Telemetry test harness, allow automated |
| 79 // navigations to access browser-side debug URLs. They must use the | 78 // navigations to access browser-side debug URLs. They must use the |
| 80 // chrome:// scheme, since the about: scheme won't be rewritten in | 79 // chrome:// scheme, since the about: scheme won't be rewritten in |
| 81 // this code path. | 80 // this code path. |
| 82 if (CommandLine::ForCurrentProcess()->HasSwitch( | 81 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return true; | 147 return true; |
| 149 } else if (handler(&test_url, browser_context)) { | 148 } else if (handler(&test_url, browser_context)) { |
| 150 return reverse_rewriter(url, browser_context); | 149 return reverse_rewriter(url, browser_context); |
| 151 } | 150 } |
| 152 } | 151 } |
| 153 } | 152 } |
| 154 return false; | 153 return false; |
| 155 } | 154 } |
| 156 | 155 |
| 157 } // namespace content | 156 } // namespace content |
| OLD | NEW |