| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 url::kHttpScheme, | 28 url::kHttpScheme, |
| 29 url::kHttpsScheme, | 29 url::kHttpsScheme, |
| 30 url::kFtpScheme, | 30 url::kFtpScheme, |
| 31 kChromeDevToolsScheme, | 31 kChromeDevToolsScheme, |
| 32 kChromeUIScheme, | 32 kChromeUIScheme, |
| 33 url::kFileScheme, | 33 url::kFileScheme, |
| 34 url::kFileSystemScheme | 34 url::kFileSystemScheme |
| 35 }; | 35 }; |
| 36 | 36 |
| 37 // Merge all the schemes for which view-source is allowed by default, with | 37 // Merge all the schemes for which view-source is allowed by default, with |
| 38 // the WebUI schemes defined by the ContentBrowserClient. | 38 // the view-source schemes defined by the ContentBrowserClient. |
| 39 std::vector<std::string> all_allowed_sub_schemes; | 39 std::vector<std::string> all_allowed_sub_schemes; |
| 40 for (size_t i = 0; i < arraysize(default_allowed_sub_schemes); ++i) | 40 for (size_t i = 0; i < arraysize(default_allowed_sub_schemes); ++i) |
| 41 all_allowed_sub_schemes.push_back(default_allowed_sub_schemes[i]); | 41 all_allowed_sub_schemes.push_back(default_allowed_sub_schemes[i]); |
| 42 GetContentClient()->browser()->GetAdditionalWebUISchemes( | 42 GetContentClient()->browser()->GetAdditionalViewSourceSchemes( |
| 43 &all_allowed_sub_schemes); | 43 &all_allowed_sub_schemes); |
| 44 | 44 |
| 45 bool is_sub_scheme_allowed = false; | 45 bool is_sub_scheme_allowed = false; |
| 46 for (size_t i = 0; i < all_allowed_sub_schemes.size(); ++i) { | 46 for (size_t i = 0; i < all_allowed_sub_schemes.size(); ++i) { |
| 47 if (url->SchemeIs(all_allowed_sub_schemes[i].c_str())) { | 47 if (url->SchemeIs(all_allowed_sub_schemes[i].c_str())) { |
| 48 is_sub_scheme_allowed = true; | 48 is_sub_scheme_allowed = true; |
| 49 break; | 49 break; |
| 50 } | 50 } |
| 51 } | 51 } |
| 52 | 52 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 88 |
| 89 // static | 89 // static |
| 90 BrowserURLHandlerImpl* BrowserURLHandlerImpl::GetInstance() { | 90 BrowserURLHandlerImpl* BrowserURLHandlerImpl::GetInstance() { |
| 91 return base::Singleton<BrowserURLHandlerImpl>::get(); | 91 return base::Singleton<BrowserURLHandlerImpl>::get(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 BrowserURLHandlerImpl::BrowserURLHandlerImpl() : | 94 BrowserURLHandlerImpl::BrowserURLHandlerImpl() : |
| 95 fixup_handler_(nullptr) { | 95 fixup_handler_(nullptr) { |
| 96 AddHandlerPair(&DebugURLHandler, BrowserURLHandlerImpl::null_handler()); | 96 AddHandlerPair(&DebugURLHandler, BrowserURLHandlerImpl::null_handler()); |
| 97 | 97 |
| 98 // view-source: should take precedence over other rewriters, so it's |
| 99 // important to add it before calling up to the content client. |
| 100 AddHandlerPair(&HandleViewSource, &ReverseViewSource); |
| 101 |
| 98 GetContentClient()->browser()->BrowserURLHandlerCreated(this); | 102 GetContentClient()->browser()->BrowserURLHandlerCreated(this); |
| 99 | |
| 100 // view-source: | |
| 101 AddHandlerPair(&HandleViewSource, &ReverseViewSource); | |
| 102 } | 103 } |
| 103 | 104 |
| 104 BrowserURLHandlerImpl::~BrowserURLHandlerImpl() { | 105 BrowserURLHandlerImpl::~BrowserURLHandlerImpl() { |
| 105 } | 106 } |
| 106 | 107 |
| 107 void BrowserURLHandlerImpl::SetFixupHandler(URLHandler handler) { | 108 void BrowserURLHandlerImpl::SetFixupHandler(URLHandler handler) { |
| 108 DCHECK(fixup_handler_ == nullptr); | 109 DCHECK(fixup_handler_ == nullptr); |
| 109 fixup_handler_ = handler; | 110 fixup_handler_ = handler; |
| 110 } | 111 } |
| 111 | 112 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 return true; | 147 return true; |
| 147 } else if (handler(&test_url, browser_context)) { | 148 } else if (handler(&test_url, browser_context)) { |
| 148 return reverse_rewriter(url, browser_context); | 149 return reverse_rewriter(url, browser_context); |
| 149 } | 150 } |
| 150 } | 151 } |
| 151 } | 152 } |
| 152 return false; | 153 return false; |
| 153 } | 154 } |
| 154 | 155 |
| 155 } // namespace content | 156 } // namespace content |
| OLD | NEW |