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