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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
// Copyright (c) 2009 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 "webkit/glue/webkitclient_impl.h"
#include "WebCString.h"
#include "base/message_loop.h"
#include "base/stats_counters.h"
#include "base/trace_event.h"
#include "grit/webkit_resources.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebClipboard;
using WebKit::WebCString;
using WebKit::WebThemeEngine;
namespace webkit_glue {
WebKitClientImpl::WebKitClientImpl()
: main_loop_(MessageLoop::current()),
shared_timer_func_(NULL) {
}
WebClipboard* WebKitClientImpl::clipboard() {
return &clipboard_;
}
WebThemeEngine* WebKitClientImpl::themeEngine() {
#if defined(OS_WIN)
return &theme_engine_;
#else
return NULL;
#endif
}
void WebKitClientImpl::decrementStatsCounter(const char* name) {
StatsCounter(name).Decrement();
}
void WebKitClientImpl::incrementStatsCounter(const char* name) {
StatsCounter(name).Increment();
}
void WebKitClientImpl::traceEventBegin(const char* name, void* id,
const char* extra) {
TRACE_EVENT_BEGIN(name, id, extra);
}
void WebKitClientImpl::traceEventEnd(const char* name, void* id,
const char* extra) {
TRACE_EVENT_END(name, id, extra);
}
WebCString WebKitClientImpl::loadResource(const char* name) {
struct {
const char* name;
int id;
} resources[] = {
{ "textAreaResizeCorner", IDR_TEXTAREA_RESIZER },
{ "missingImage", IDR_BROKENIMAGE },
{ "tickmarkDash", IDR_TICKMARK_DASH },
{ "panIcon", IDR_PAN_SCROLL_ICON },
#if defined(OS_LINUX)
{ "linuxCheckboxOff", IDR_LINUX_CHECKBOX_OFF },
{ "linuxCheckboxOn", IDR_LINUX_CHECKBOX_ON },
{ "linuxRadioOff", IDR_LINUX_RADIO_OFF },
{ "linuxRadioOn", IDR_LINUX_RADIO_ON },
#endif
};
for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) {
if (!strcmp(name, resources[i].name))
return webkit_glue::GetDataResource(resources[i].id);
}
NOTREACHED() << "Unknown image resource " << name;
return WebCString();
}
double WebKitClientImpl::currentTime() {
return base::Time::Now().ToDoubleT();
}
void WebKitClientImpl::setSharedTimerFiredFunction(void (*func)()) {
shared_timer_func_ = func;
}
void WebKitClientImpl::setSharedTimerFireTime(double fire_time) {
int interval = static_cast<int>((fire_time - currentTime()) * 1000);
if (interval < 0)
interval = 0;
shared_timer_.Stop();
shared_timer_.Start(base::TimeDelta::FromMilliseconds(interval), this,
&WebKitClientImpl::DoTimeout);
}
void WebKitClientImpl::stopSharedTimer() {
shared_timer_.Stop();
}
void WebKitClientImpl::callOnMainThread(void (*func)()) {
main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func));
}
} // namespace webkit_glue
|