| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/browser_url_handler.h" | 5 #include "chrome/browser/browser_url_handler.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "chrome/browser/browser_about_handler.h" | 8 #include "chrome/browser/browser_about_handler.h" |
| 9 #include "chrome/browser/dom_ui/web_ui_factory.h" | 9 #include "chrome/browser/dom_ui/web_ui_factory.h" |
| 10 #include "chrome/browser/extensions/extension_web_ui.h" | 10 #include "chrome/browser/extensions/extension_web_ui.h" |
| 11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
| 12 #include "chrome/common/url_constants.h" | 12 #include "chrome/common/url_constants.h" |
| 13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
| 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, Profile* profile) { | 16 static bool HandleViewSource(GURL* url, Profile* profile) { |
| 17 if (url->SchemeIs(chrome::kViewSourceScheme)) { | 17 if (url->SchemeIs(chrome::kViewSourceScheme)) { |
| 18 // Load the inner URL instead. | 18 // Load the inner URL instead. |
| 19 *url = GURL(url->path()); | 19 *url = GURL(url->path()); |
| 20 | 20 |
| 21 // Bug 26129: limit view-source to view the content and not any | 21 // Bug 26129: limit view-source to view the content and not any |
| 22 // other kind of 'active' url scheme like 'javascript' or 'data'. | 22 // other kind of 'active' url scheme like 'javascript' or 'data'. |
| 23 static const char* const allowed_sub_schemes[] = { | 23 static const char* const allowed_sub_schemes[] = { |
| 24 chrome::kHttpScheme, chrome::kHttpsScheme, chrome::kFtpScheme, | 24 chrome::kHttpScheme, chrome::kHttpsScheme, chrome::kHttpsvScheme, |
| 25 chrome::kChromeDevToolsScheme, chrome::kChromeUIScheme, | 25 chrome::kFtpScheme, chrome::kChromeDevToolsScheme, |
| 26 chrome::kFileScheme | 26 chrome::kChromeUIScheme, chrome::kFileScheme |
| 27 }; | 27 }; |
| 28 | 28 |
| 29 bool is_sub_scheme_allowed = false; | 29 bool is_sub_scheme_allowed = false; |
| 30 for (size_t i = 0; i < arraysize(allowed_sub_schemes); i++) { | 30 for (size_t i = 0; i < arraysize(allowed_sub_schemes); i++) { |
| 31 if (url->SchemeIs(allowed_sub_schemes[i])) { | 31 if (url->SchemeIs(allowed_sub_schemes[i])) { |
| 32 is_sub_scheme_allowed = true; | 32 is_sub_scheme_allowed = true; |
| 33 break; | 33 break; |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 GURL test_url(original); | 124 GURL test_url(original); |
| 125 if ((*url_handlers_[i].first)(&test_url, profile)) { | 125 if ((*url_handlers_[i].first)(&test_url, profile)) { |
| 126 if (url_handlers_[i].second) | 126 if (url_handlers_[i].second) |
| 127 return (*url_handlers_[i].second)(url, profile); | 127 return (*url_handlers_[i].second)(url, profile); |
| 128 else | 128 else |
| 129 return false; | 129 return false; |
| 130 } | 130 } |
| 131 } | 131 } |
| 132 return false; | 132 return false; |
| 133 } | 133 } |
| OLD | NEW |