summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_url_handler.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/browser_url_handler.cc')
-rw-r--r--chrome/browser/browser_url_handler.cc23
1 files changed, 17 insertions, 6 deletions
diff --git a/chrome/browser/browser_url_handler.cc b/chrome/browser/browser_url_handler.cc
index 98bdaa0..88cb0e2 100644
--- a/chrome/browser/browser_url_handler.cc
+++ b/chrome/browser/browser_url_handler.cc
@@ -4,8 +4,21 @@
#include "chrome/browser/browser_url_handler.h"
+#include "base/string_util.h"
#include "chrome/browser/browser_about_handler.h"
#include "chrome/browser/dom_ui/dom_ui_contents.h"
+#include "chrome/common/url_constants.h"
+
+// Handles rewriting view-source URLs for what we'll actually load.
+static bool HandleViewSource(GURL* url, TabContentsType* type) {
+ if (url->SchemeIs(chrome::kViewSourceScheme)) {
+ // Load the inner URL instead.
+ *url = GURL(url->path());
+ *type = TAB_CONTENTS_WEB;
+ return true;
+ }
+ return false;
+}
std::vector<BrowserURLHandler::URLHandler> BrowserURLHandler::url_handlers_;
@@ -14,11 +27,10 @@ void BrowserURLHandler::InitURLHandlers() {
if (!url_handlers_.empty())
return;
- // Here is where we initialize the global list of handlers for special URLs.
- // about:*
- url_handlers_.push_back(&BrowserAboutHandler::MaybeHandle);
- // chrome-ui:*
- url_handlers_.push_back(&DOMUIContentsCanHandleURL);
+ // Add the default URL handlers.
+ url_handlers_.push_back(&WillHandleBrowserAboutURL); // about:
+ url_handlers_.push_back(&DOMUIContentsCanHandleURL); // chrome-ui:
+ url_handlers_.push_back(&HandleViewSource); // view-source:
}
// static
@@ -31,4 +43,3 @@ bool BrowserURLHandler::HandleBrowserURL(GURL* url, TabContentsType* type) {
}
return false;
}
-