blob: d0fb504d976688b67bdc94f4b2f8f754e2eb995b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/renderer/about_handler.h"
#include "base/platform_thread.h"
#include "chrome/common/url_constants.h"
#include "googleurl/src/gurl.h"
struct AboutHandlerUrl {
const char *url;
void (*action)();
};
static AboutHandlerUrl about_urls[] = {
{ chrome::kAboutCrashURL, AboutHandler::AboutCrash },
{ chrome::kAboutHangURL, AboutHandler::AboutHang },
{ chrome::kAboutShortHangURL, AboutHandler::AboutShortHang },
{ NULL, NULL }
};
bool AboutHandler::WillHandle(const GURL& url) {
if (url.SchemeIs(chrome::kAboutScheme))
return false;
struct AboutHandlerUrl* url_handler = about_urls;
while (url_handler->url) {
if (url == GURL(url_handler->url))
return true;
url_handler++;
}
return false;
}
// static
bool AboutHandler::MaybeHandle(const GURL& url) {
if (!url.SchemeIs(chrome::kAboutScheme))
return false;
struct AboutHandlerUrl* url_handler = about_urls;
while (url_handler->url) {
if (url == GURL(url_handler->url)) {
url_handler->action();
return true; // theoretically :]
}
url_handler++;
}
return false;
}
// static
void AboutHandler::AboutCrash() {
int *zero = NULL;
*zero = 0; // Null pointer dereference: kaboom!
}
// static
void AboutHandler::AboutHang() {
for (;;) {
PlatformThread::Sleep(1000);
}
}
// static
void AboutHandler::AboutShortHang() {
PlatformThread::Sleep(20000);
}
|