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 "webkit/glue/plugins/pepper_plugin_instance.h" | 5 #include "webkit/glue/plugins/pepper_plugin_instance.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "gfx/rect.h" | 10 #include "gfx/rect.h" |
11 #include "third_party/ppapi/c/pp_instance.h" | 11 #include "third_party/ppapi/c/pp_instance.h" |
12 #include "third_party/ppapi/c/pp_event.h" | 12 #include "third_party/ppapi/c/pp_event.h" |
13 #include "third_party/ppapi/c/pp_rect.h" | 13 #include "third_party/ppapi/c/pp_rect.h" |
14 #include "third_party/ppapi/c/pp_resource.h" | 14 #include "third_party/ppapi/c/pp_resource.h" |
15 #include "third_party/ppapi/c/pp_var.h" | 15 #include "third_party/ppapi/c/pp_var.h" |
16 #include "third_party/ppapi/c/ppb_find.h" | 16 #include "third_party/ppapi/c/ppb_find.h" |
17 #include "third_party/ppapi/c/ppb_instance.h" | 17 #include "third_party/ppapi/c/ppb_instance.h" |
18 #include "third_party/ppapi/c/ppp_find.h" | 18 #include "third_party/ppapi/c/ppp_find.h" |
19 #include "third_party/ppapi/c/ppp_instance.h" | 19 #include "third_party/ppapi/c/ppp_instance.h" |
| 20 #include "third_party/ppapi/c/ppp_zoom.h" |
20 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" | 21 #include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h" |
21 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" | 22 #include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" |
22 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" | 23 #include "third_party/WebKit/WebKit/chromium/public/WebElement.h" |
23 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 24 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
24 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" | 25 #include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h" |
25 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" | 26 #include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h" |
26 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" | 27 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" |
27 #include "webkit/glue/plugins/pepper_device_context_2d.h" | 28 #include "webkit/glue/plugins/pepper_device_context_2d.h" |
28 #include "webkit/glue/plugins/pepper_event_conversion.h" | 29 #include "webkit/glue/plugins/pepper_event_conversion.h" |
29 #include "webkit/glue/plugins/pepper_image_data.h" | 30 #include "webkit/glue/plugins/pepper_image_data.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 | 194 |
194 PluginInstance::PluginInstance(PluginDelegate* delegate, | 195 PluginInstance::PluginInstance(PluginDelegate* delegate, |
195 PluginModule* module, | 196 PluginModule* module, |
196 const PPP_Instance* instance_interface) | 197 const PPP_Instance* instance_interface) |
197 : delegate_(delegate), | 198 : delegate_(delegate), |
198 module_(module), | 199 module_(module), |
199 instance_interface_(instance_interface), | 200 instance_interface_(instance_interface), |
200 container_(NULL), | 201 container_(NULL), |
201 full_frame_(false), | 202 full_frame_(false), |
202 find_identifier_(-1), | 203 find_identifier_(-1), |
203 plugin_find_interface_(NULL) { | 204 plugin_find_interface_(NULL), |
| 205 plugin_zoom_interface_(NULL) { |
204 DCHECK(delegate); | 206 DCHECK(delegate); |
205 module_->InstanceCreated(this); | 207 module_->InstanceCreated(this); |
206 delegate_->InstanceCreated(this); | 208 delegate_->InstanceCreated(this); |
207 } | 209 } |
208 | 210 |
209 PluginInstance::~PluginInstance() { | 211 PluginInstance::~PluginInstance() { |
210 delegate_->InstanceDeleted(this); | 212 delegate_->InstanceDeleted(this); |
211 module_->InstanceDeleted(this); | 213 module_->InstanceDeleted(this); |
212 } | 214 } |
213 | 215 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 | 376 |
375 string16 PluginInstance::GetSelectedText(bool html) { | 377 string16 PluginInstance::GetSelectedText(bool html) { |
376 PP_Var rv = instance_interface_->GetSelectedText(GetPPInstance(), html); | 378 PP_Var rv = instance_interface_->GetSelectedText(GetPPInstance(), html); |
377 String* string = GetString(rv); | 379 String* string = GetString(rv); |
378 if (!string) | 380 if (!string) |
379 return string16(); | 381 return string16(); |
380 return UTF8ToUTF16(string->value()); | 382 return UTF8ToUTF16(string->value()); |
381 } | 383 } |
382 | 384 |
383 void PluginInstance::Zoom(float factor, bool text_only) { | 385 void PluginInstance::Zoom(float factor, bool text_only) { |
384 // TODO: implement me | 386 if (!LoadZoomInterface()) |
| 387 return; |
| 388 plugin_zoom_interface_->Zoom(GetPPInstance(), factor, text_only); |
385 } | 389 } |
386 | 390 |
387 bool PluginInstance::StartFind(const string16& search_text, | 391 bool PluginInstance::StartFind(const string16& search_text, |
388 bool case_sensitive, | 392 bool case_sensitive, |
389 int identifier) { | 393 int identifier) { |
390 if (!LoadFindInterface()) | 394 if (!LoadFindInterface()) |
391 return false; | 395 return false; |
392 find_identifier_ = identifier; | 396 find_identifier_ = identifier; |
393 return plugin_find_interface_->StartFind( | 397 return plugin_find_interface_->StartFind( |
394 GetPPInstance(), | 398 GetPPInstance(), |
(...skipping 16 matching lines...) Expand all Loading... |
411 bool PluginInstance::LoadFindInterface() { | 415 bool PluginInstance::LoadFindInterface() { |
412 if (!plugin_find_interface_) { | 416 if (!plugin_find_interface_) { |
413 plugin_find_interface_ = | 417 plugin_find_interface_ = |
414 reinterpret_cast<const PPP_Find*>(module_->GetPluginInterface( | 418 reinterpret_cast<const PPP_Find*>(module_->GetPluginInterface( |
415 PPP_FIND_INTERFACE)); | 419 PPP_FIND_INTERFACE)); |
416 } | 420 } |
417 | 421 |
418 return !!plugin_find_interface_; | 422 return !!plugin_find_interface_; |
419 } | 423 } |
420 | 424 |
| 425 bool PluginInstance::LoadZoomInterface() { |
| 426 if (!plugin_zoom_interface_) { |
| 427 plugin_zoom_interface_ = |
| 428 reinterpret_cast<const PPP_Zoom*>(module_->GetPluginInterface( |
| 429 PPP_ZOOM_INTERFACE)); |
| 430 } |
| 431 |
| 432 return !!plugin_zoom_interface_; |
| 433 } |
| 434 |
421 } // namespace pepper | 435 } // namespace pepper |
OLD | NEW |