| 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 "content/browser/frame_host/debug_urls.h" | 9 #include "content/browser/frame_host/debug_urls.h" |
| 10 #include "content/browser/webui/web_ui_impl.h" | 10 #include "content/browser/webui/web_ui_impl.h" |
| 11 #include "content/public/browser/content_browser_client.h" | 11 #include "content/public/browser/content_browser_client.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // Handles rewriting view-source URLs for what we'll actually load. | 18 // Handles rewriting view-source URLs for what we'll actually load. |
| 19 static bool HandleViewSource(GURL* url, BrowserContext* browser_context) { | 19 static bool HandleViewSource(GURL* url, BrowserContext* browser_context) { |
| 20 if (url->SchemeIs(kViewSourceScheme)) { | 20 if (url->SchemeIs(kViewSourceScheme)) { |
| 21 // Load the inner URL instead. | 21 // Load the inner URL instead. |
| 22 *url = GURL(url->GetContent()); | 22 *url = GURL(url->GetContent()); |
| 23 | 23 |
| 24 // Bug 26129: limit view-source to view the content and not any | 24 // Bug 26129: limit view-source to view the content and not any |
| 25 // other kind of 'active' url scheme like 'javascript' or 'data'. | 25 // other kind of 'active' url scheme like 'javascript' or 'data'. |
| 26 static const char* const allowed_sub_schemes[] = { | 26 static const char* const allowed_sub_schemes[] = { |
| 27 kHttpScheme, kHttpsScheme, kFtpScheme, | 27 kHttpScheme, kHttpsScheme, kFtpScheme, |
| 28 chrome::kChromeDevToolsScheme, chrome::kChromeUIScheme, | 28 chrome::kChromeDevToolsScheme, chrome::kChromeUIScheme, |
| 29 chrome::kFileScheme, chrome::kFileSystemScheme | 29 chrome::kFileScheme, kFileSystemScheme |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 bool is_sub_scheme_allowed = false; | 32 bool is_sub_scheme_allowed = false; |
| 33 for (size_t i = 0; i < arraysize(allowed_sub_schemes); i++) { | 33 for (size_t i = 0; i < arraysize(allowed_sub_schemes); i++) { |
| 34 if (url->SchemeIs(allowed_sub_schemes[i])) { | 34 if (url->SchemeIs(allowed_sub_schemes[i])) { |
| 35 is_sub_scheme_allowed = true; | 35 is_sub_scheme_allowed = true; |
| 36 break; | 36 break; |
| 37 } | 37 } |
| 38 } | 38 } |
| 39 | 39 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 return true; | 139 return true; |
| 140 } else if (handler(&test_url, browser_context)) { | 140 } else if (handler(&test_url, browser_context)) { |
| 141 return reverse_rewriter(url, browser_context); | 141 return reverse_rewriter(url, browser_context); |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 return false; | 145 return false; |
| 146 } | 146 } |
| 147 | 147 |
| 148 } // namespace content | 148 } // namespace content |
| OLD | NEW |