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