| 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" |
| 11 #include "content/browser/webui/web_ui_impl.h" | 11 #include "content/browser/webui/web_ui_impl.h" |
| 12 #include "content/public/browser/content_browser_client.h" | 12 #include "content/public/browser/content_browser_client.h" |
| 13 #include "content/public/common/url_constants.h" | 13 #include "content/public/common/url_constants.h" |
| 14 #include "net/base/url_constants.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 namespace content { | 17 namespace content { |
| 17 | 18 |
| 18 // Handles rewriting view-source URLs for what we'll actually load. | 19 // Handles rewriting view-source URLs for what we'll actually load. |
| 19 static bool HandleViewSource(GURL* url, BrowserContext* browser_context) { | 20 static bool HandleViewSource(GURL* url, BrowserContext* browser_context) { |
| 20 if (url->SchemeIs(kViewSourceScheme)) { | 21 if (url->SchemeIs(kViewSourceScheme)) { |
| 21 // Load the inner URL instead. | 22 // Load the inner URL instead. |
| 22 *url = GURL(url->GetContent()); | 23 *url = GURL(url->GetContent()); |
| 23 | 24 |
| 24 // Bug 26129: limit view-source to view the content and not any | 25 // Bug 26129: limit view-source to view the content and not any |
| 25 // other kind of 'active' url scheme like 'javascript' or 'data'. | 26 // other kind of 'active' url scheme like 'javascript' or 'data'. |
| 26 static const char* const default_allowed_sub_schemes[] = { | 27 static const char* const default_allowed_sub_schemes[] = { |
| 27 kHttpScheme, | 28 net::kHttpScheme, net::kHttpsScheme, kFtpScheme, |
| 28 kHttpsScheme, | 29 kChromeDevToolsScheme, kChromeUIScheme, kFileScheme, |
| 29 kFtpScheme, | 30 kFileSystemScheme}; |
| 30 kChromeDevToolsScheme, | |
| 31 kChromeUIScheme, | |
| 32 kFileScheme, | |
| 33 kFileSystemScheme | |
| 34 }; | |
| 35 | 31 |
| 36 // Merge all the schemes for which view-source is allowed by default, with | 32 // Merge all the schemes for which view-source is allowed by default, with |
| 37 // the WebUI schemes defined by the ContentBrowserClient. | 33 // the WebUI schemes defined by the ContentBrowserClient. |
| 38 std::vector<std::string> all_allowed_sub_schemes; | 34 std::vector<std::string> all_allowed_sub_schemes; |
| 39 for (size_t i = 0; i < arraysize(default_allowed_sub_schemes); ++i) | 35 for (size_t i = 0; i < arraysize(default_allowed_sub_schemes); ++i) |
| 40 all_allowed_sub_schemes.push_back(default_allowed_sub_schemes[i]); | 36 all_allowed_sub_schemes.push_back(default_allowed_sub_schemes[i]); |
| 41 GetContentClient()->browser()->GetAdditionalWebUISchemes( | 37 GetContentClient()->browser()->GetAdditionalWebUISchemes( |
| 42 &all_allowed_sub_schemes); | 38 &all_allowed_sub_schemes); |
| 43 | 39 |
| 44 bool is_sub_scheme_allowed = false; | 40 bool is_sub_scheme_allowed = false; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 return true; | 144 return true; |
| 149 } else if (handler(&test_url, browser_context)) { | 145 } else if (handler(&test_url, browser_context)) { |
| 150 return reverse_rewriter(url, browser_context); | 146 return reverse_rewriter(url, browser_context); |
| 151 } | 147 } |
| 152 } | 148 } |
| 153 } | 149 } |
| 154 return false; | 150 return false; |
| 155 } | 151 } |
| 156 | 152 |
| 157 } // namespace content | 153 } // namespace content |
| OLD | NEW |