Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: content/browser/browser_url_handler.cc

Issue 9349010: Move handling of debug urls like chrome://crash, chrome://gpuclean to content. These are for test... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "content/browser/browser_url_handler.h" 5 #include "content/browser/browser_url_handler.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"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 url_canon::Replacements<char> repl; 53 url_canon::Replacements<char> repl;
54 repl.SetScheme(chrome::kViewSourceScheme, 54 repl.SetScheme(chrome::kViewSourceScheme,
55 url_parse::Component(0, strlen(chrome::kViewSourceScheme))); 55 url_parse::Component(0, strlen(chrome::kViewSourceScheme)));
56 repl.SetPath(url->spec().c_str(), 56 repl.SetPath(url->spec().c_str(),
57 url_parse::Component(0, url->spec().size())); 57 url_parse::Component(0, url->spec().size()));
58 *url = url->ReplaceComponents(repl); 58 *url = url->ReplaceComponents(repl);
59 return true; 59 return true;
60 } 60 }
61 61
62 static bool HandleDebugUrl(GURL* url,
63 content::BrowserContext* browser_context) {
64 // Circumvent processing URLs that the renderer process will handle.
65 return *url == GURL(chrome::kChromeUICrashURL) ||
66 *url == GURL(chrome::kChromeUIHangURL) ||
67 *url == GURL(chrome::kChromeUIKillURL) ||
68 *url == GURL(chrome::kChromeUIShorthangURL);
69 }
70
62 // static 71 // static
63 BrowserURLHandler* BrowserURLHandler::GetInstance() { 72 BrowserURLHandler* BrowserURLHandler::GetInstance() {
64 return Singleton<BrowserURLHandler>::get(); 73 return Singleton<BrowserURLHandler>::get();
65 } 74 }
66 75
67 // static 76 // static
68 BrowserURLHandler::URLHandler BrowserURLHandler::null_handler() { 77 BrowserURLHandler::URLHandler BrowserURLHandler::null_handler() {
69 // Visual Studio 2010 has problems converting NULL to the null pointer for 78 // Visual Studio 2010 has problems converting NULL to the null pointer for
70 // std::pair. See http://connect.microsoft.com/VisualStudio/feedback/details/ 520043/error-converting-from-null-to-a-pointer-type-in-std-pair 79 // std::pair. See http://connect.microsoft.com/VisualStudio/feedback/details/ 520043/error-converting-from-null-to-a-pointer-type-in-std-pair
71 // It will work if we pass nullptr. 80 // It will work if we pass nullptr.
72 #if defined(_MSC_VER) && _MSC_VER >= 1600 81 #if defined(_MSC_VER) && _MSC_VER >= 1600
73 return nullptr; 82 return nullptr;
74 #else 83 #else
75 return NULL; 84 return NULL;
76 #endif 85 #endif
77 } 86 }
78 87
79 BrowserURLHandler::BrowserURLHandler() { 88 BrowserURLHandler::BrowserURLHandler() {
89 AddHandlerPair(&HandleDebugUrl, BrowserURLHandler::null_handler());
90
80 content::GetContentClient()->browser()->BrowserURLHandlerCreated(this); 91 content::GetContentClient()->browser()->BrowserURLHandlerCreated(this);
81 92
82 // view-source: 93 // view-source:
83 AddHandlerPair(&HandleViewSource, &ReverseViewSource); 94 AddHandlerPair(&HandleViewSource, &ReverseViewSource);
84 } 95 }
85 96
86 BrowserURLHandler::~BrowserURLHandler() { 97 BrowserURLHandler::~BrowserURLHandler() {
87 } 98 }
88 99
89 void BrowserURLHandler::AddHandlerPair(URLHandler handler, 100 void BrowserURLHandler::AddHandlerPair(URLHandler handler,
(...skipping 24 matching lines...) Expand all
114 if (!handler) { 125 if (!handler) {
115 if (reverse_rewriter(url, browser_context)) 126 if (reverse_rewriter(url, browser_context))
116 return true; 127 return true;
117 } else if (handler(&test_url, browser_context)) { 128 } else if (handler(&test_url, browser_context)) {
118 return reverse_rewriter(url, browser_context); 129 return reverse_rewriter(url, browser_context);
119 } 130 }
120 } 131 }
121 } 132 }
122 return false; 133 return false;
123 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698