OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/pepper_plugin_instance_impl.h" | 5 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bit_cast.h" | 10 #include "base/bit_cast.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 using blink::WebURLRequest; | 177 using blink::WebURLRequest; |
178 using blink::WebURLResponse; | 178 using blink::WebURLResponse; |
179 using blink::WebUserGestureIndicator; | 179 using blink::WebUserGestureIndicator; |
180 using blink::WebUserGestureToken; | 180 using blink::WebUserGestureToken; |
181 using blink::WebView; | 181 using blink::WebView; |
182 | 182 |
183 namespace content { | 183 namespace content { |
184 | 184 |
185 namespace { | 185 namespace { |
186 | 186 |
187 #define STATIC_ASSERT_PP_MATCHING_ENUM(a, b) \ | 187 #define STATIC_ASSERT_ENUM(a, b) \ |
188 static_assert(static_cast<int>(a) == static_cast<int>(b), \ | 188 static_assert(static_cast<int>(a) == static_cast<int>(b), \ |
189 "mismatching enums: " #a) | 189 "mismatching enums: " #a) |
190 | 190 |
191 // Check PP_TextInput_Type and ui::TextInputType are kept in sync. | 191 // Check PP_TextInput_Type and ui::TextInputType are kept in sync. |
192 STATIC_ASSERT_PP_MATCHING_ENUM(ui::TEXT_INPUT_TYPE_NONE, | 192 STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_NONE, PP_TEXTINPUT_TYPE_NONE); |
193 PP_TEXTINPUT_TYPE_NONE); | 193 STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_TEXT, PP_TEXTINPUT_TYPE_TEXT); |
194 STATIC_ASSERT_PP_MATCHING_ENUM(ui::TEXT_INPUT_TYPE_TEXT, | 194 STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_PASSWORD, PP_TEXTINPUT_TYPE_PASSWORD); |
195 PP_TEXTINPUT_TYPE_TEXT); | 195 STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_SEARCH, PP_TEXTINPUT_TYPE_SEARCH); |
196 STATIC_ASSERT_PP_MATCHING_ENUM(ui::TEXT_INPUT_TYPE_PASSWORD, | 196 STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_EMAIL, PP_TEXTINPUT_TYPE_EMAIL); |
197 PP_TEXTINPUT_TYPE_PASSWORD); | 197 STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_NUMBER, PP_TEXTINPUT_TYPE_NUMBER); |
198 STATIC_ASSERT_PP_MATCHING_ENUM(ui::TEXT_INPUT_TYPE_SEARCH, | 198 STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_TELEPHONE, PP_TEXTINPUT_TYPE_TELEPHONE); |
199 PP_TEXTINPUT_TYPE_SEARCH); | 199 STATIC_ASSERT_ENUM(ui::TEXT_INPUT_TYPE_URL, PP_TEXTINPUT_TYPE_URL); |
200 STATIC_ASSERT_PP_MATCHING_ENUM(ui::TEXT_INPUT_TYPE_EMAIL, | |
201 PP_TEXTINPUT_TYPE_EMAIL); | |
202 STATIC_ASSERT_PP_MATCHING_ENUM(ui::TEXT_INPUT_TYPE_NUMBER, | |
203 PP_TEXTINPUT_TYPE_NUMBER); | |
204 STATIC_ASSERT_PP_MATCHING_ENUM(ui::TEXT_INPUT_TYPE_TELEPHONE, | |
205 PP_TEXTINPUT_TYPE_TELEPHONE); | |
206 STATIC_ASSERT_PP_MATCHING_ENUM(ui::TEXT_INPUT_TYPE_URL, | |
207 PP_TEXTINPUT_TYPE_URL); | |
208 | 200 |
209 // The default text input type is to regard the plugin always accept text input. | 201 // The default text input type is to regard the plugin always accept text input. |
210 // This is for allowing users to use input methods even on completely-IME- | 202 // This is for allowing users to use input methods even on completely-IME- |
211 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). | 203 // unaware plugins (e.g., PPAPI Flash or PDF plugin for M16). |
212 // Plugins need to explicitly opt out the text input mode if they know | 204 // Plugins need to explicitly opt out the text input mode if they know |
213 // that they don't accept texts. | 205 // that they don't accept texts. |
214 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; | 206 const ui::TextInputType kPluginDefaultTextInputType = ui::TEXT_INPUT_TYPE_TEXT; |
215 | 207 |
216 // <embed>/<object> attributes. | 208 // <embed>/<object> attributes. |
217 const char kWidth[] = "width"; | 209 const char kWidth[] = "width"; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 STATIC_ASSERT_MATCHING_ENUM(TypeCopy, PP_MOUSECURSOR_TYPE_COPY); | 272 STATIC_ASSERT_MATCHING_ENUM(TypeCopy, PP_MOUSECURSOR_TYPE_COPY); |
281 STATIC_ASSERT_MATCHING_ENUM(TypeNone, PP_MOUSECURSOR_TYPE_NONE); | 273 STATIC_ASSERT_MATCHING_ENUM(TypeNone, PP_MOUSECURSOR_TYPE_NONE); |
282 STATIC_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_MOUSECURSOR_TYPE_NOTALLOWED); | 274 STATIC_ASSERT_MATCHING_ENUM(TypeNotAllowed, PP_MOUSECURSOR_TYPE_NOTALLOWED); |
283 STATIC_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_MOUSECURSOR_TYPE_ZOOMIN); | 275 STATIC_ASSERT_MATCHING_ENUM(TypeZoomIn, PP_MOUSECURSOR_TYPE_ZOOMIN); |
284 STATIC_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_MOUSECURSOR_TYPE_ZOOMOUT); | 276 STATIC_ASSERT_MATCHING_ENUM(TypeZoomOut, PP_MOUSECURSOR_TYPE_ZOOMOUT); |
285 STATIC_ASSERT_MATCHING_ENUM(TypeGrab, PP_MOUSECURSOR_TYPE_GRAB); | 277 STATIC_ASSERT_MATCHING_ENUM(TypeGrab, PP_MOUSECURSOR_TYPE_GRAB); |
286 STATIC_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); | 278 STATIC_ASSERT_MATCHING_ENUM(TypeGrabbing, PP_MOUSECURSOR_TYPE_GRABBING); |
287 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; | 279 // Do not assert WebCursorInfo::TypeCustom == PP_CURSORTYPE_CUSTOM; |
288 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. | 280 // PP_CURSORTYPE_CUSTOM is pinned to allow new cursor types. |
289 | 281 |
290 STATIC_ASSERT_PP_MATCHING_ENUM(blink::WebPrintScalingOptionNone, | 282 STATIC_ASSERT_ENUM(blink::WebPrintScalingOptionNone, |
291 PP_PRINTSCALINGOPTION_NONE); | 283 PP_PRINTSCALINGOPTION_NONE); |
292 STATIC_ASSERT_PP_MATCHING_ENUM( | 284 STATIC_ASSERT_ENUM(blink::WebPrintScalingOptionFitToPrintableArea, |
293 blink::WebPrintScalingOptionFitToPrintableArea, | 285 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); |
294 PP_PRINTSCALINGOPTION_FIT_TO_PRINTABLE_AREA); | 286 STATIC_ASSERT_ENUM(blink::WebPrintScalingOptionSourceSize, |
295 STATIC_ASSERT_PP_MATCHING_ENUM( | 287 PP_PRINTSCALINGOPTION_SOURCE_SIZE); |
296 blink::WebPrintScalingOptionSourceSize, | |
297 PP_PRINTSCALINGOPTION_SOURCE_SIZE); | |
298 | 288 |
299 // Sets |*security_origin| to be the WebKit security origin associated with the | 289 // Sets |*security_origin| to be the WebKit security origin associated with the |
300 // document containing the given plugin instance. On success, returns true. If | 290 // document containing the given plugin instance. On success, returns true. If |
301 // the instance is invalid, returns false and |*security_origin| will be | 291 // the instance is invalid, returns false and |*security_origin| will be |
302 // unchanged. | 292 // unchanged. |
303 bool SecurityOriginForInstance(PP_Instance instance_id, | 293 bool SecurityOriginForInstance(PP_Instance instance_id, |
304 blink::WebSecurityOrigin* security_origin) { | 294 blink::WebSecurityOrigin* security_origin) { |
305 PepperPluginInstanceImpl* instance = | 295 PepperPluginInstanceImpl* instance = |
306 HostGlobals::Get()->GetInstance(instance_id); | 296 HostGlobals::Get()->GetInstance(instance_id); |
307 if (!instance) | 297 if (!instance) |
(...skipping 3023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3331 } | 3321 } |
3332 | 3322 |
3333 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const { | 3323 void PepperPluginInstanceImpl::ConvertDIPToViewport(gfx::Rect* rect) const { |
3334 rect->set_x(rect->x() / viewport_to_dip_scale_); | 3324 rect->set_x(rect->x() / viewport_to_dip_scale_); |
3335 rect->set_y(rect->y() / viewport_to_dip_scale_); | 3325 rect->set_y(rect->y() / viewport_to_dip_scale_); |
3336 rect->set_width(rect->width() / viewport_to_dip_scale_); | 3326 rect->set_width(rect->width() / viewport_to_dip_scale_); |
3337 rect->set_height(rect->height() / viewport_to_dip_scale_); | 3327 rect->set_height(rect->height() / viewport_to_dip_scale_); |
3338 } | 3328 } |
3339 | 3329 |
3340 } // namespace content | 3330 } // namespace content |
OLD | NEW |