| 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/renderer/about_handler.h" | 5 #include "chrome/renderer/about_handler.h" |
| 6 | 6 |
| 7 #include "base/platform_thread.h" | 7 #include "base/platform_thread.h" |
| 8 #include "chrome/common/url_constants.h" |
| 8 #include "googleurl/src/gurl.h" | 9 #include "googleurl/src/gurl.h" |
| 9 | 10 |
| 10 struct AboutHandlerUrl { | 11 struct AboutHandlerUrl { |
| 11 const char *url; | 12 const char *url; |
| 12 void (*action)(); | 13 void (*action)(); |
| 13 }; | 14 }; |
| 14 | 15 |
| 15 static AboutHandlerUrl about_urls[] = { | 16 static AboutHandlerUrl about_urls[] = { |
| 16 { "about:crash", AboutHandler::AboutCrash }, | 17 { chrome::kAboutCrashURL, AboutHandler::AboutCrash }, |
| 17 { "about:hang", AboutHandler::AboutHang }, | 18 { chrome::kAboutHangURL, AboutHandler::AboutHang }, |
| 18 { "about:shorthang", AboutHandler::AboutShortHang }, | 19 { chrome::kAboutShortHangURL, AboutHandler::AboutShortHang }, |
| 19 { NULL, NULL } | 20 { NULL, NULL } |
| 20 }; | 21 }; |
| 21 | 22 |
| 22 bool AboutHandler::WillHandle(const GURL& url) { | 23 bool AboutHandler::WillHandle(const GURL& url) { |
| 23 if (url.scheme() != "about") | 24 if (url.SchemeIs(chrome::kAboutScheme)) |
| 24 return false; | 25 return false; |
| 25 | 26 |
| 26 struct AboutHandlerUrl* url_handler = about_urls; | 27 struct AboutHandlerUrl* url_handler = about_urls; |
| 27 while (url_handler->url) { | 28 while (url_handler->url) { |
| 28 if (url == GURL(url_handler->url)) | 29 if (url == GURL(url_handler->url)) |
| 29 return true; | 30 return true; |
| 30 url_handler++; | 31 url_handler++; |
| 31 } | 32 } |
| 32 return false; | 33 return false; |
| 33 } | 34 } |
| 34 | 35 |
| 35 // static | 36 // static |
| 36 bool AboutHandler::MaybeHandle(const GURL& url) { | 37 bool AboutHandler::MaybeHandle(const GURL& url) { |
| 37 if (url.scheme() != "about") | 38 if (!url.SchemeIs(chrome::kAboutScheme)) |
| 38 return false; | 39 return false; |
| 39 | 40 |
| 40 struct AboutHandlerUrl* url_handler = about_urls; | 41 struct AboutHandlerUrl* url_handler = about_urls; |
| 41 while (url_handler->url) { | 42 while (url_handler->url) { |
| 42 if (url == GURL(url_handler->url)) { | 43 if (url == GURL(url_handler->url)) { |
| 43 url_handler->action(); | 44 url_handler->action(); |
| 44 return true; // theoretically :] | 45 return true; // theoretically :] |
| 45 } | 46 } |
| 46 url_handler++; | 47 url_handler++; |
| 47 } | 48 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 59 for (;;) { | 60 for (;;) { |
| 60 PlatformThread::Sleep(1000); | 61 PlatformThread::Sleep(1000); |
| 61 } | 62 } |
| 62 } | 63 } |
| 63 | 64 |
| 64 // static | 65 // static |
| 65 void AboutHandler::AboutShortHang() { | 66 void AboutHandler::AboutShortHang() { |
| 66 PlatformThread::Sleep(20000); | 67 PlatformThread::Sleep(20000); |
| 67 } | 68 } |
| 68 | 69 |
| OLD | NEW |