OLD | NEW |
1 // Copyright (c) 2011 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/string_util.h" | 7 #include "base/string_util.h" |
8 #include "content/browser/webui/web_ui_impl.h" | 8 #include "content/browser/webui/web_ui_impl.h" |
9 #include "content/public/browser/content_browser_client.h" | 9 #include "content/public/browser/content_browser_client.h" |
10 #include "content/public/common/url_constants.h" | 10 #include "content/public/common/url_constants.h" |
11 #include "googleurl/src/gurl.h" | 11 #include "googleurl/src/gurl.h" |
12 | 12 |
13 using content::BrowserURLHandler; | 13 using content::BrowserURLHandler; |
14 | 14 |
15 // Handles rewriting view-source URLs for what we'll actually load. | 15 // Handles rewriting view-source URLs for what we'll actually load. |
16 static bool HandleViewSource(GURL* url, | 16 static bool HandleViewSource(GURL* url, |
17 content::BrowserContext* browser_context) { | 17 content::BrowserContext* browser_context) { |
18 if (url->SchemeIs(chrome::kViewSourceScheme)) { | 18 if (url->SchemeIs(chrome::kViewSourceScheme)) { |
19 // Load the inner URL instead. | 19 // Load the inner URL instead. |
20 *url = GURL(url->path()); | 20 *url = GURL(url->path()); |
21 | 21 |
22 // Bug 26129: limit view-source to view the content and not any | 22 // Bug 26129: limit view-source to view the content and not any |
23 // other kind of 'active' url scheme like 'javascript' or 'data'. | 23 // other kind of 'active' url scheme like 'javascript' or 'data'. |
24 static const char* const allowed_sub_schemes[] = { | 24 static const char* const allowed_sub_schemes[] = { |
25 chrome::kHttpScheme, chrome::kHttpsScheme, chrome::kFtpScheme, | 25 chrome::kHttpScheme, chrome::kHttpsScheme, chrome::kFtpScheme, |
26 chrome::kChromeDevToolsScheme, chrome::kChromeUIScheme, | 26 chrome::kChromeDevToolsScheme, chrome::kChromeUIScheme, |
27 chrome::kFileScheme | 27 chrome::kFileScheme, chrome::kFileSystemScheme |
28 }; | 28 }; |
29 | 29 |
30 bool is_sub_scheme_allowed = false; | 30 bool is_sub_scheme_allowed = false; |
31 for (size_t i = 0; i < arraysize(allowed_sub_schemes); i++) { | 31 for (size_t i = 0; i < arraysize(allowed_sub_schemes); i++) { |
32 if (url->SchemeIs(allowed_sub_schemes[i])) { | 32 if (url->SchemeIs(allowed_sub_schemes[i])) { |
33 is_sub_scheme_allowed = true; | 33 is_sub_scheme_allowed = true; |
34 break; | 34 break; |
35 } | 35 } |
36 } | 36 } |
37 | 37 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 if (!handler) { | 126 if (!handler) { |
127 if (reverse_rewriter(url, browser_context)) | 127 if (reverse_rewriter(url, browser_context)) |
128 return true; | 128 return true; |
129 } else if (handler(&test_url, browser_context)) { | 129 } else if (handler(&test_url, browser_context)) { |
130 return reverse_rewriter(url, browser_context); | 130 return reverse_rewriter(url, browser_context); |
131 } | 131 } |
132 } | 132 } |
133 } | 133 } |
134 return false; | 134 return false; |
135 } | 135 } |
OLD | NEW |