OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/pepper_widget.h" | 5 #include "chrome/renderer/pepper_widget.h" |
6 | 6 |
7 #include "base/hash_tables.h" | 7 #include "base/hash_tables.h" |
8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
9 #include "chrome/renderer/pepper_scrollbar_widget.h" | 9 #include "chrome/renderer/pepper_scrollbar_widget.h" |
10 #include "chrome/renderer/webplugin_delegate_pepper.h" | 10 #include "chrome/renderer/webplugin_delegate_pepper.h" |
11 #include "skia/ext/platform_canvas.h" | 11 #include "skia/ext/platform_canvas.h" |
12 #include "webkit/glue/plugins/plugin_instance.h" | 12 #include "webkit/glue/plugins/plugin_instance.h" |
13 #include "webkit/glue/plugins/webplugin.h" | 13 #include "webkit/glue/plugins/webplugin.h" |
14 #include "webkit/glue/plugins/webplugin_delegate.h" | 14 #include "webkit/glue/plugins/webplugin_delegate.h" |
15 | 15 |
16 #if defined(OS_WIN) | 16 #if defined(OS_WIN) |
17 #include "base/win_util.h" | 17 #include "base/win/windows_version.h" |
18 #endif | 18 #endif |
19 | 19 |
20 static int g_next_id; | 20 static int g_next_id; |
21 typedef base::hash_map<int, PepperWidget*> WidgetMap; | 21 typedef base::hash_map<int, PepperWidget*> WidgetMap; |
22 static base::LazyInstance<WidgetMap> g_widgets(base::LINKER_INITIALIZED); | 22 static base::LazyInstance<WidgetMap> g_widgets(base::LINKER_INITIALIZED); |
23 | 23 |
24 NPError NPCreateWidget(NPP instance, | 24 NPError NPCreateWidget(NPP instance, |
25 NPWidgetType type, | 25 NPWidgetType type, |
26 void* params, | 26 void* params, |
27 NPWidgetID* id) { | 27 NPWidgetID* id) { |
(...skipping 30 matching lines...) Expand all Loading... |
58 return NPERR_INVALID_PARAM; | 58 return NPERR_INVALID_PARAM; |
59 | 59 |
60 NPAPI::PluginInstance* plugin = | 60 NPAPI::PluginInstance* plugin = |
61 static_cast<NPAPI::PluginInstance*>(instance->ndata); | 61 static_cast<NPAPI::PluginInstance*>(instance->ndata); |
62 WebPluginDelegatePepper* delegate = | 62 WebPluginDelegatePepper* delegate = |
63 static_cast<WebPluginDelegatePepper*>(plugin->webplugin()->delegate()); | 63 static_cast<WebPluginDelegatePepper*>(plugin->webplugin()->delegate()); |
64 Graphics2DDeviceContext* gdc = delegate->GetGraphicsContext(context); | 64 Graphics2DDeviceContext* gdc = delegate->GetGraphicsContext(context); |
65 iter->second->Paint(gdc, *dirty); | 65 iter->second->Paint(gdc, *dirty); |
66 | 66 |
67 #if defined(OS_WIN) | 67 #if defined(OS_WIN) |
68 if (win_util::GetWinVersion() == win_util::WINVERSION_XP) { | 68 if (base::win::GetVersion() == base::win::VERSION_XP) { |
69 gdc->canvas()->getTopPlatformDevice().makeOpaque( | 69 gdc->canvas()->getTopPlatformDevice().makeOpaque( |
70 dirty->left, dirty->top, dirty->right - dirty->left, | 70 dirty->left, dirty->top, dirty->right - dirty->left, |
71 dirty->bottom - dirty->top); | 71 dirty->bottom - dirty->top); |
72 } | 72 } |
73 #endif | 73 #endif |
74 return NPERR_NO_ERROR; | 74 return NPERR_NO_ERROR; |
75 } | 75 } |
76 | 76 |
77 bool NPHandleWidgetEvent(NPP instance, NPWidgetID id, NPPepperEvent* event) { | 77 bool NPHandleWidgetEvent(NPP instance, NPWidgetID id, NPPepperEvent* event) { |
78 WidgetMap::iterator iter = g_widgets.Get().find(id); | 78 WidgetMap::iterator iter = g_widgets.Get().find(id); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 void PepperWidget::WidgetPropertyChanged(NPWidgetProperty property) { | 137 void PepperWidget::WidgetPropertyChanged(NPWidgetProperty property) { |
138 NPAPI::PluginInstance* instance = | 138 NPAPI::PluginInstance* instance = |
139 static_cast<NPAPI::PluginInstance*>(instance_->ndata); | 139 static_cast<NPAPI::PluginInstance*>(instance_->ndata); |
140 NPPExtensions* extensions = NULL; | 140 NPPExtensions* extensions = NULL; |
141 instance->NPP_GetValue(NPPVPepperExtensions, &extensions); | 141 instance->NPP_GetValue(NPPVPepperExtensions, &extensions); |
142 if (!extensions) | 142 if (!extensions) |
143 return; | 143 return; |
144 | 144 |
145 extensions->widgetPropertyChanged(instance_, id_, property); | 145 extensions->widgetPropertyChanged(instance_, id_, property); |
146 } | 146 } |
OLD | NEW |