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/browser_url_handler_impl.h" | 5 #include "content/browser/browser_url_handler_impl.h" |
| 6 | 6 |
| 7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
| 8 #include "content/browser/frame_host/debug_urls.h" | 8 #include "content/browser/frame_host/debug_urls.h" |
| 9 #include "content/browser/webui/web_ui_impl.h" | 9 #include "content/browser/webui/web_ui_impl.h" |
| 10 #include "content/public/browser/content_browser_client.h" | 10 #include "content/public/browser/content_browser_client.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 return true; | 55 return true; |
| 56 } | 56 } |
| 57 return false; | 57 return false; |
| 58 } | 58 } |
| 59 | 59 |
| 60 // Turns a non view-source URL into the corresponding view-source URL. | 60 // Turns a non view-source URL into the corresponding view-source URL. |
| 61 static bool ReverseViewSource(GURL* url, BrowserContext* browser_context) { | 61 static bool ReverseViewSource(GURL* url, BrowserContext* browser_context) { |
| 62 // No action necessary if the URL is already view-source: | 62 // No action necessary if the URL is already view-source: |
| 63 if (url->SchemeIs(kViewSourceScheme)) | 63 if (url->SchemeIs(kViewSourceScheme)) |
| 64 return false; | 64 return false; |
| 65 | 65 // Recreate the url with the view-source scheme. |
| 66 url::Replacements<char> repl; | 66 *url = GURL(kViewSourceScheme + std::string(":") + url->spec()); |
|
sky
2014/10/14 19:56:31
Doesn't gurl have the ability to replace parts of
sgurun-gerrit only
2014/10/14 21:02:52
I could not see an easy way of doing it. Two possi
joth
2014/10/17 20:18:39
Thanks for fixing my bug! (well, bug my cl exposed
sgurun-gerrit only
2014/10/17 20:35:35
Rather then regression tests, I have written a uni
sgurun-gerrit only
2014/10/17 20:37:39
haha I think I read regression as integration test
| |
| 67 repl.SetScheme(kViewSourceScheme, | |
| 68 url::Component(0, strlen(kViewSourceScheme))); | |
| 69 repl.SetPath(url->spec().c_str(), url::Component(0, url->spec().size())); | |
| 70 *url = url->ReplaceComponents(repl); | |
| 71 return true; | 67 return true; |
| 72 } | 68 } |
| 73 | 69 |
| 74 static bool DebugURLHandler(GURL* url, BrowserContext* browser_context) { | 70 static bool DebugURLHandler(GURL* url, BrowserContext* browser_context) { |
| 75 // Circumvent processing URLs that the renderer process will handle. | 71 // Circumvent processing URLs that the renderer process will handle. |
| 76 return IsRendererDebugURL(*url); | 72 return IsRendererDebugURL(*url); |
| 77 } | 73 } |
| 78 | 74 |
| 79 // static | 75 // static |
| 80 BrowserURLHandler* BrowserURLHandler::GetInstance() { | 76 BrowserURLHandler* BrowserURLHandler::GetInstance() { |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 134 return true; | 130 return true; |
| 135 } else if (handler(&test_url, browser_context)) { | 131 } else if (handler(&test_url, browser_context)) { |
| 136 return reverse_rewriter(url, browser_context); | 132 return reverse_rewriter(url, browser_context); |
| 137 } | 133 } |
| 138 } | 134 } |
| 139 } | 135 } |
| 140 return false; | 136 return false; |
| 141 } | 137 } |
| 142 | 138 |
| 143 } // namespace content | 139 } // namespace content |
| OLD | NEW |