| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/plugins/ppapi/ppapi_plugin_instance.h" | 5 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 &IsFullFrame, | 226 &IsFullFrame, |
| 227 &ExecuteScript | 227 &ExecuteScript |
| 228 }; | 228 }; |
| 229 | 229 |
| 230 const PPB_Instance_Private ppb_instance_private = { | 230 const PPB_Instance_Private ppb_instance_private = { |
| 231 &GetWindowObject, | 231 &GetWindowObject, |
| 232 &GetOwnerElementObject, | 232 &GetOwnerElementObject, |
| 233 &ExecuteScript | 233 &ExecuteScript |
| 234 }; | 234 }; |
| 235 | 235 |
| 236 void NumberOfFindResultsChanged(PP_Instance instance_id, |
| 237 int32_t total, |
| 238 PP_Bool final_result) { |
| 239 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 240 if (!instance) |
| 241 return; |
| 242 |
| 243 DCHECK_NE(instance->find_identifier(), -1); |
| 244 instance->delegate()->NumberOfFindResultsChanged( |
| 245 instance->find_identifier(), total, PPBoolToBool(final_result)); |
| 246 } |
| 247 |
| 248 void SelectedFindResultChanged(PP_Instance instance_id, |
| 249 int32_t index) { |
| 250 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 251 if (!instance) |
| 252 return; |
| 253 |
| 254 DCHECK_NE(instance->find_identifier(), -1); |
| 255 instance->delegate()->SelectedFindResultChanged( |
| 256 instance->find_identifier(), index); |
| 257 } |
| 258 |
| 259 const PPB_Find_Dev ppb_find = { |
| 260 &NumberOfFindResultsChanged, |
| 261 &SelectedFindResultChanged, |
| 262 }; |
| 263 |
| 236 PP_Bool IsFullscreen(PP_Instance instance_id) { | 264 PP_Bool IsFullscreen(PP_Instance instance_id) { |
| 237 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 265 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 238 if (!instance) | 266 if (!instance) |
| 239 return PP_FALSE; | 267 return PP_FALSE; |
| 240 return BoolToPPBool(instance->IsFullscreen()); | 268 return BoolToPPBool(instance->IsFullscreen()); |
| 241 } | 269 } |
| 242 | 270 |
| 243 PP_Bool SetFullscreen(PP_Instance instance_id, PP_Bool fullscreen) { | 271 PP_Bool SetFullscreen(PP_Instance instance_id, PP_Bool fullscreen) { |
| 244 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); | 272 PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); |
| 245 if (!instance) | 273 if (!instance) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 const void* PluginInstance::GetInterface(const char* if_name) { | 403 const void* PluginInstance::GetInterface(const char* if_name) { |
| 376 if (strcmp(if_name, PPB_INSTANCE_INTERFACE) == 0) { | 404 if (strcmp(if_name, PPB_INSTANCE_INTERFACE) == 0) { |
| 377 return &ppb_instance; | 405 return &ppb_instance; |
| 378 } else if (strcmp(if_name, PPB_INSTANCE_INTERFACE_0_4) == 0) { | 406 } else if (strcmp(if_name, PPB_INSTANCE_INTERFACE_0_4) == 0) { |
| 379 return &ppb_instance_0_4; | 407 return &ppb_instance_0_4; |
| 380 } | 408 } |
| 381 return NULL; | 409 return NULL; |
| 382 } | 410 } |
| 383 | 411 |
| 384 // static | 412 // static |
| 413 const PPB_Find_Dev* PluginInstance::GetFindInterface() { |
| 414 return &ppb_find; |
| 415 } |
| 416 |
| 417 // static |
| 385 const PPB_Fullscreen_Dev* PluginInstance::GetFullscreenInterface() { | 418 const PPB_Fullscreen_Dev* PluginInstance::GetFullscreenInterface() { |
| 386 return &ppb_fullscreen; | 419 return &ppb_fullscreen; |
| 387 } | 420 } |
| 388 | 421 |
| 389 // static | 422 // static |
| 390 const PPB_Messaging* PluginInstance::GetMessagingInterface() { | 423 const PPB_Messaging* PluginInstance::GetMessagingInterface() { |
| 391 return &ppb_messaging; | 424 return &ppb_messaging; |
| 392 } | 425 } |
| 393 | 426 |
| 394 // static | 427 // static |
| (...skipping 1183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 return found->second; | 1611 return found->second; |
| 1579 } | 1612 } |
| 1580 | 1613 |
| 1581 bool PluginInstance::IsFullPagePlugin() const { | 1614 bool PluginInstance::IsFullPagePlugin() const { |
| 1582 WebFrame* frame = container()->element().document().frame(); | 1615 WebFrame* frame = container()->element().document().frame(); |
| 1583 return frame->view()->mainFrame()->document().isPluginDocument(); | 1616 return frame->view()->mainFrame()->document().isPluginDocument(); |
| 1584 } | 1617 } |
| 1585 | 1618 |
| 1586 } // namespace ppapi | 1619 } // namespace ppapi |
| 1587 } // namespace webkit | 1620 } // namespace webkit |
| OLD | NEW |