OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
2 // source code is governed by a BSD-style license that can be found in the | 2 // source code is governed by a BSD-style license that can be found in the |
3 // LICENSE file. | 3 // LICENSE file. |
4 | 4 |
5 #include "webkit/glue/webkitclient_impl.h" | 5 #include "webkit/glue/webkitclient_impl.h" |
6 | 6 |
7 #include "base/message_loop.h" | 7 #include "base/message_loop.h" |
8 #include "base/stats_counters.h" | 8 #include "base/stats_counters.h" |
| 9 #include "base/string_util.h" |
9 #include "base/trace_event.h" | 10 #include "base/trace_event.h" |
10 #include "grit/webkit_resources.h" | 11 #include "grit/webkit_resources.h" |
11 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" | 12 #include "third_party/WebKit/WebKit/chromium/public/WebData.h" |
| 13 #include "third_party/WebKit/WebKit/chromium/public/WebPluginListBuilder.h" |
| 14 #include "third_party/WebKit/WebKit/chromium/public/WebString.h" |
12 #include "webkit/glue/webkit_glue.h" | 15 #include "webkit/glue/webkit_glue.h" |
| 16 #include "webkit/glue/webplugininfo.h" |
13 | 17 |
14 using WebKit::WebData; | 18 using WebKit::WebData; |
| 19 using WebKit::WebPluginListBuilder; |
15 using WebKit::WebThemeEngine; | 20 using WebKit::WebThemeEngine; |
16 | 21 |
17 namespace webkit_glue { | 22 namespace webkit_glue { |
18 | 23 |
19 WebKitClientImpl::WebKitClientImpl() | 24 WebKitClientImpl::WebKitClientImpl() |
20 : main_loop_(MessageLoop::current()), | 25 : main_loop_(MessageLoop::current()), |
21 shared_timer_func_(NULL) { | 26 shared_timer_func_(NULL) { |
22 } | 27 } |
23 | 28 |
24 WebThemeEngine* WebKitClientImpl::themeEngine() { | 29 WebThemeEngine* WebKitClientImpl::themeEngine() { |
25 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
26 return &theme_engine_; | 31 return &theme_engine_; |
27 #else | 32 #else |
28 return NULL; | 33 return NULL; |
29 #endif | 34 #endif |
30 } | 35 } |
31 | 36 |
| 37 void WebKitClientImpl::getPluginList(bool refresh, |
| 38 WebPluginListBuilder* builder) { |
| 39 std::vector<WebPluginInfo> plugins; |
| 40 if (!GetPlugins(refresh, &plugins)) |
| 41 return; |
| 42 |
| 43 for (size_t i = 0; i < plugins.size(); ++i) { |
| 44 const WebPluginInfo& plugin = plugins[i]; |
| 45 |
| 46 builder->addPlugin( |
| 47 WideToUTF16Hack(plugin.name), |
| 48 WideToUTF16Hack(plugin.desc), |
| 49 FilePathStringToWebString(plugin.path.BaseName().value())); |
| 50 |
| 51 for (size_t j = 0; j < plugin.mime_types.size(); ++ j) { |
| 52 const WebPluginMimeType& mime_type = plugin.mime_types[j]; |
| 53 |
| 54 builder->addMediaTypeToLastPlugin( |
| 55 UTF8ToUTF16(mime_type.mime_type), |
| 56 WideToUTF16Hack(mime_type.description)); |
| 57 |
| 58 for (size_t k = 0; k < mime_type.file_extensions.size(); ++k) { |
| 59 builder->addFileExtensionToLastMediaType( |
| 60 UTF8ToUTF16(mime_type.file_extensions[k])); |
| 61 } |
| 62 } |
| 63 } |
| 64 } |
| 65 |
32 void WebKitClientImpl::decrementStatsCounter(const char* name) { | 66 void WebKitClientImpl::decrementStatsCounter(const char* name) { |
33 StatsCounter(name).Decrement(); | 67 StatsCounter(name).Decrement(); |
34 } | 68 } |
35 | 69 |
36 void WebKitClientImpl::incrementStatsCounter(const char* name) { | 70 void WebKitClientImpl::incrementStatsCounter(const char* name) { |
37 StatsCounter(name).Increment(); | 71 StatsCounter(name).Increment(); |
38 } | 72 } |
39 | 73 |
40 void WebKitClientImpl::traceEventBegin(const char* name, void* id, | 74 void WebKitClientImpl::traceEventBegin(const char* name, void* id, |
41 const char* extra) { | 75 const char* extra) { |
(...skipping 20 matching lines...) Expand all Loading... |
62 { "searchMagnifierResults", IDR_SEARCH_MAGNIFIER_RESULTS }, | 96 { "searchMagnifierResults", IDR_SEARCH_MAGNIFIER_RESULTS }, |
63 #if defined(OS_LINUX) | 97 #if defined(OS_LINUX) |
64 { "linuxCheckboxOff", IDR_LINUX_CHECKBOX_OFF }, | 98 { "linuxCheckboxOff", IDR_LINUX_CHECKBOX_OFF }, |
65 { "linuxCheckboxOn", IDR_LINUX_CHECKBOX_ON }, | 99 { "linuxCheckboxOn", IDR_LINUX_CHECKBOX_ON }, |
66 { "linuxRadioOff", IDR_LINUX_RADIO_OFF }, | 100 { "linuxRadioOff", IDR_LINUX_RADIO_OFF }, |
67 { "linuxRadioOn", IDR_LINUX_RADIO_ON }, | 101 { "linuxRadioOn", IDR_LINUX_RADIO_ON }, |
68 #endif | 102 #endif |
69 }; | 103 }; |
70 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { | 104 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { |
71 if (!strcmp(name, resources[i].name)) { | 105 if (!strcmp(name, resources[i].name)) { |
72 StringPiece resource = webkit_glue::GetDataResource(resources[i].id); | 106 StringPiece resource = GetDataResource(resources[i].id); |
73 return WebData(resource.data(), resource.size()); | 107 return WebData(resource.data(), resource.size()); |
74 } | 108 } |
75 } | 109 } |
76 NOTREACHED() << "Unknown image resource " << name; | 110 NOTREACHED() << "Unknown image resource " << name; |
77 return WebData(); | 111 return WebData(); |
78 } | 112 } |
79 | 113 |
80 double WebKitClientImpl::currentTime() { | 114 double WebKitClientImpl::currentTime() { |
81 return base::Time::Now().ToDoubleT(); | 115 return base::Time::Now().ToDoubleT(); |
82 } | 116 } |
(...skipping 14 matching lines...) Expand all Loading... |
97 | 131 |
98 void WebKitClientImpl::stopSharedTimer() { | 132 void WebKitClientImpl::stopSharedTimer() { |
99 shared_timer_.Stop(); | 133 shared_timer_.Stop(); |
100 } | 134 } |
101 | 135 |
102 void WebKitClientImpl::callOnMainThread(void (*func)()) { | 136 void WebKitClientImpl::callOnMainThread(void (*func)()) { |
103 main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); | 137 main_loop_->PostTask(FROM_HERE, NewRunnableFunction(func)); |
104 } | 138 } |
105 | 139 |
106 } // namespace webkit_glue | 140 } // namespace webkit_glue |
OLD | NEW |