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/plugins/npapi/plugin_instance.h" | 12 #include "webkit/glue/plugins/plugin_instance.h" |
13 #include "webkit/plugins/npapi/webplugin.h" | 13 #include "webkit/glue/plugins/webplugin.h" |
14 #include "webkit/plugins/npapi/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/windows_version.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, |
(...skipping 25 matching lines...) Expand all Loading... |
50 } | 50 } |
51 | 51 |
52 NPError NPPaintWidget(NPP instance, | 52 NPError NPPaintWidget(NPP instance, |
53 NPWidgetID id, | 53 NPWidgetID id, |
54 NPDeviceContext2D* context, | 54 NPDeviceContext2D* context, |
55 NPRect* dirty) { | 55 NPRect* dirty) { |
56 WidgetMap::iterator iter = g_widgets.Get().find(id); | 56 WidgetMap::iterator iter = g_widgets.Get().find(id); |
57 if (iter == g_widgets.Get().end()) | 57 if (iter == g_widgets.Get().end()) |
58 return NPERR_INVALID_PARAM; | 58 return NPERR_INVALID_PARAM; |
59 | 59 |
60 webkit::npapi::PluginInstance* plugin = | 60 NPAPI::PluginInstance* plugin = |
61 static_cast<webkit::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 (base::win::GetVersion() == base::win::VERSION_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); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 g_widgets.Get().erase(id_); | 128 g_widgets.Get().erase(id_); |
129 } | 129 } |
130 | 130 |
131 void PepperWidget::Init(NPP instance, int id) { | 131 void PepperWidget::Init(NPP instance, int id) { |
132 instance_ = instance; | 132 instance_ = instance; |
133 id_ = id; | 133 id_ = id; |
134 g_widgets.Get()[id] = this; | 134 g_widgets.Get()[id] = this; |
135 } | 135 } |
136 | 136 |
137 void PepperWidget::WidgetPropertyChanged(NPWidgetProperty property) { | 137 void PepperWidget::WidgetPropertyChanged(NPWidgetProperty property) { |
138 webkit::npapi::PluginInstance* instance = | 138 NPAPI::PluginInstance* instance = |
139 static_cast<webkit::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 |