OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/browser_about_handler.h" | 7 #include "chrome/browser/browser_about_handler.h" |
8 #include "chrome/browser/dom_ui/new_tab_ui.h" | |
9 #include "chrome/browser/dom_ui/dom_ui_contents.h" | 8 #include "chrome/browser/dom_ui/dom_ui_contents.h" |
10 | 9 |
11 std::vector<BrowserURLHandler::URLHandler> BrowserURLHandler::url_handlers_; | 10 std::vector<BrowserURLHandler::URLHandler> BrowserURLHandler::url_handlers_; |
12 | 11 |
13 // static | 12 // static |
14 void BrowserURLHandler::InitURLHandlers() { | 13 void BrowserURLHandler::InitURLHandlers() { |
15 if (!url_handlers_.empty()) | 14 if (!url_handlers_.empty()) |
16 return; | 15 return; |
17 | 16 |
18 // Here is where we initialize the global list of handlers for special URLs. | 17 // Here is where we initialize the global list of handlers for special URLs. |
19 // about:* | 18 // about:* |
20 url_handlers_.push_back(&BrowserAboutHandler::MaybeHandle); | 19 url_handlers_.push_back(&BrowserAboutHandler::MaybeHandle); |
21 // chrome-internal:* | |
22 url_handlers_.push_back(&NewTabUIHandleURL); | |
23 // chrome-ui:* | 20 // chrome-ui:* |
24 url_handlers_.push_back(&DOMUIContentsCanHandleURL); | 21 url_handlers_.push_back(&DOMUIContentsCanHandleURL); |
25 } | 22 } |
26 | 23 |
27 // static | 24 // static |
28 bool BrowserURLHandler::HandleBrowserURL(GURL* url, TabContentsType* type) { | 25 bool BrowserURLHandler::HandleBrowserURL(GURL* url, TabContentsType* type) { |
29 if (url_handlers_.empty()) | 26 if (url_handlers_.empty()) |
30 InitURLHandlers(); | 27 InitURLHandlers(); |
31 for (size_t i = 0; i < url_handlers_.size(); ++i) { | 28 for (size_t i = 0; i < url_handlers_.size(); ++i) { |
32 if ((*url_handlers_[i])(url, type)) | 29 if ((*url_handlers_[i])(url, type)) |
33 return true; | 30 return true; |
34 } | 31 } |
35 return false; | 32 return false; |
36 } | 33 } |
37 | 34 |
38 | |
OLD | NEW |