0

Move the Pepper implementation from webkit/glue/plugins/pepper_* to

webkit/plugins/ppapi/*. This renamed the files and interface implementation
classes from foo.cc/Foo to ppb_foo_impl/PPB_Foo_Impl to match the proxy
ppb_foo_proxy/PPB_Foo_Proxy.

This moves plugin_switches.* from webkit/glue/plugins to webkit/plugins.
Review URL: http://codereview.chromium.org/5828003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69424 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
brettw@chromium.org
2010-12-16 18:15:52 +00:00
parent d1d0afe664
commit 0bd753681a
126 changed files with 3275 additions and 2771 deletions
chrome
ppapi/proxy
webkit
glue
plugins
plugin_switches.ccplugin_switches.h
ppapi
DEPScommon.hdir_contents.herror_util.ccerror_util.hevent_conversion.ccevent_conversion.hfile_callbacks.ccfile_callbacks.hfullscreen_container.hmock_plugin_delegate.ccmock_plugin_delegate.hmock_resource.hnpapi_glue.ccnpapi_glue.hplugin_delegate.hplugin_module.ccplugin_module.hplugin_object.ccplugin_object.hppapi_plugin_instance.ccppapi_plugin_instance.hppapi_unittest.ccppapi_unittest.hppapi_webplugin_impl.ccppapi_webplugin_impl.hppb_audio_impl.ccppb_audio_impl.hppb_buffer_impl.ccppb_buffer_impl.hppb_char_set_impl.ccppb_char_set_impl.hppb_cursor_control_impl.ccppb_cursor_control_impl.hppb_directory_reader_impl.ccppb_directory_reader_impl.hppb_file_chooser_impl.ccppb_file_chooser_impl.hppb_file_io_impl.ccppb_file_io_impl.hppb_file_ref_impl.ccppb_file_ref_impl.hppb_file_system_impl.ccppb_file_system_impl.hppb_flash.hppb_flash_impl.ccppb_flash_impl.hppb_flash_impl_linux.ccppb_font_impl.ccppb_font_impl.hppb_graphics_2d_impl.ccppb_graphics_2d_impl.hppb_graphics_3d_impl.ccppb_graphics_3d_impl.hppb_image_data_impl.ccppb_image_data_impl.hppb_open_gl_es_impl.ccppb_pdf.hppb_pdf_impl.ccppb_pdf_impl.hppb_scrollbar_impl.ccppb_scrollbar_impl.hppb_transport_impl.ccppb_transport_impl.hppb_url_loader_impl.ccppb_url_loader_impl.hppb_url_request_info_impl.ccppb_url_request_info_impl.hppb_url_response_info_impl.ccppb_url_response_info_impl.hppb_url_util_impl.ccppb_url_util_impl.hppb_video_decoder_impl.ccppb_video_decoder_impl.hppb_widget_impl.ccppb_widget_impl.hppp_pdf.hresource.ccresource.hresource_tracker.ccresource_tracker.hresource_tracker_unittest.ccstring.ccstring.hvar.ccvar.hvar_object_class.ccvar_object_class.h
tools
test_shell

@ -17,6 +17,7 @@ include_rules = [
"+skia/include",
"+webkit/database",
"+webkit/glue", # Defines some types that are marshalled over IPC.
"+webkit/plugins", # Defines some types that are marshalled over IPC.
"+xib_localizers", # For generated mac localization helpers
# Other libraries.

@ -89,7 +89,7 @@
#include "ipc/ipc_switches.h"
#include "media/base/media_switches.h"
#include "webkit/fileapi/file_system_path_manager.h"
#include "webkit/glue/plugins/plugin_switches.h"
#include "webkit/plugins/plugin_switches.h"
#if defined(OS_WIN)
#include "app/win_util.h"

@ -164,7 +164,7 @@ void PepperFileMessageFilter::OnPepperQueryFile(
void PepperFileMessageFilter::OnPepperGetDirContents(
const FilePath& path,
PepperDirContents* contents,
webkit::ppapi::DirContents* contents,
base::PlatformFileError* error) {
FilePath full_path = MakePepperPath(path);
if (full_path.empty()) {
@ -184,7 +184,7 @@ void PepperFileMessageFilter::OnPepperGetDirContents(
while (!enumerator.Next().empty()) {
file_util::FileEnumerator::FindInfo info;
enumerator.GetFindInfo(&info);
PepperDirEntry entry = {
webkit::ppapi::DirEntry entry = {
file_util::FileEnumerator::GetFilename(info),
file_util::FileEnumerator::IsDirectory(info)
};

@ -16,7 +16,7 @@
#include "build/build_config.h"
#include "chrome/browser/browser_message_filter.h"
#include "ipc/ipc_platform_file.h"
#include "webkit/glue/plugins/pepper_dir_contents.h"
#include "webkit/plugins/ppapi/dir_contents.h"
class Profile;
@ -54,7 +54,7 @@ class PepperFileMessageFilter : public BrowserMessageFilter {
base::PlatformFileInfo* info,
base::PlatformFileError* error);
void OnPepperGetDirContents(const FilePath& path,
PepperDirContents* contents,
webkit::ppapi::DirContents* contents,
base::PlatformFileError* error);
FilePath MakePepperPath(const FilePath& base_path);

@ -9,6 +9,7 @@ include_rules = [
"+sandbox/src",
"+skia",
"+webkit/glue",
"+webkit/plugins",
# Other libraries.
"+chrome/third_party/xdg_user_dirs",

@ -9,19 +9,21 @@
namespace IPC {
void ParamTraits<PepperDirEntry>::Write(Message* m, const param_type& p) {
void ParamTraits<webkit::ppapi::DirEntry>::Write(Message* m,
const param_type& p) {
WriteParam(m, p.name);
WriteParam(m, p.is_dir);
}
bool ParamTraits<PepperDirEntry>::Read(const Message* m,
void** iter,
param_type* p) {
bool ParamTraits<webkit::ppapi::DirEntry>::Read(const Message* m,
void** iter,
param_type* p) {
return ReadParam(m, iter, &p->name) &&
ReadParam(m, iter, &p->is_dir);
}
void ParamTraits<PepperDirEntry>::Log(const param_type& p, std::string* l) {
void ParamTraits<webkit::ppapi::DirEntry>::Log(const param_type& p,
std::string* l) {
l->append("(");
LogParam(p.name, l);
l->append(", ");

@ -10,15 +10,16 @@
#include "ipc/ipc_message_macros.h"
#include "ipc/ipc_param_traits.h"
#include "ipc/ipc_platform_file.h"
#include "webkit/glue/plugins/pepper_dir_contents.h"
#include "webkit/plugins/ppapi/dir_contents.h"
#define IPC_MESSAGE_START PepperFileMsgStart
namespace IPC {
// Also needed for Serializing DirContents, which is just a vector of DirEntry.
template <>
struct ParamTraits<PepperDirEntry> {
typedef PepperDirEntry param_type;
struct ParamTraits<webkit::ppapi::DirEntry> {
typedef webkit::ppapi::DirEntry param_type;
static void Write(Message* m, const param_type& p);
static bool Read(const Message* m, void** iter, param_type* p);
static void Log(const param_type& p, std::string* l);
@ -61,7 +62,7 @@ IPC_SYNC_MESSAGE_CONTROL1_2(PepperFileMsg_QueryFile,
// Get the directory's contents.
IPC_SYNC_MESSAGE_CONTROL1_2(PepperFileMsg_GetDirContents,
FilePath /* path */,
PepperDirContents, /* contents */
webkit::ppapi::DirContents, /* contents */
base::PlatformFileError /* error_code */)
#endif // CHROME_COMMON_PEPPER_FILE_MESSAGES_H_

@ -220,7 +220,7 @@ bool PepperPluginRegistry::RunOutOfProcessForPlugin(
return false;
}
pepper::PluginModule* PepperPluginRegistry::GetModule(
webkit::ppapi::PluginModule* PepperPluginRegistry::GetModule(
const FilePath& path) const {
ModuleMap::const_iterator it = modules_.find(path);
if (it == modules_.end())
@ -240,7 +240,7 @@ PepperPluginRegistry::PepperPluginRegistry() {
it != internal_plugin_info.end();
++it) {
const FilePath& path = it->path;
ModuleHandle module(new pepper::PluginModule);
ModuleHandle module(new webkit::ppapi::PluginModule);
if (!module->InitAsInternalPlugin(it->entry_points)) {
DLOG(ERROR) << "Failed to load pepper module: " << path.value();
continue;
@ -259,7 +259,7 @@ PepperPluginRegistry::PepperPluginRegistry() {
continue; // Only preload in-process plugins.
const FilePath& path = plugins[i].path;
ModuleHandle module(new pepper::PluginModule);
ModuleHandle module(new webkit::ppapi::PluginModule);
if (!module->InitAsLibrary(path)) {
DLOG(ERROR) << "Failed to load pepper module: " << path.value();
continue;

@ -11,7 +11,7 @@
#include <vector>
#include "base/file_path.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/plugins/ppapi/plugin_module.h"
struct PepperPluginInfo {
PepperPluginInfo();
@ -64,7 +64,7 @@ class PepperPluginRegistry {
// Returns a preloaded module for the given path. This only works for
// non-out-of-process plugins since we preload them so they will run in the
// sandbox. Returns NULL if the plugin hasn't been preloaded.
pepper::PluginModule* GetModule(const FilePath& path) const;
webkit::ppapi::PluginModule* GetModule(const FilePath& path) const;
~PepperPluginRegistry();
@ -74,14 +74,14 @@ class PepperPluginRegistry {
struct InternalPluginInfo : public PepperPluginInfo {
InternalPluginInfo(); // Sets |is_internal|.
pepper::PluginModule::EntryPoints entry_points;
webkit::ppapi::PluginModule::EntryPoints entry_points;
};
typedef std::vector<InternalPluginInfo> InternalPluginInfoList;
static void GetInternalPluginInfo(InternalPluginInfoList* plugin_info);
PepperPluginRegistry();
typedef scoped_refptr<pepper::PluginModule> ModuleHandle;
typedef scoped_refptr<webkit::ppapi::PluginModule> ModuleHandle;
typedef std::map<FilePath, ModuleHandle> ModuleMap;
ModuleMap modules_;
};

@ -14,6 +14,7 @@ include_rules = [
"+webkit/extensions",
"+webkit/glue",
"+webkit/glue/plugins",
"+webkit/plugins",
"+v8/include",
"+third_party/cld/encodings/compact_lang_det/win",
"+third_party/npapi/bindings",

@ -10,7 +10,7 @@
#ifdef ENABLE_GPU
PlatformContext3DImpl::PlatformContext3DImpl(ggl::Context* parent_context)
: parent_context_(parent_context),
: parent_context_(parent_context),
context_(NULL) {
}

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#ifdef ENABLE_GPU
@ -12,7 +12,8 @@ class Context;
} // namespace ggl;
class PlatformContext3DImpl : public pepper::PluginDelegate::PlatformContext3D {
class PlatformContext3DImpl
: public webkit::ppapi::PluginDelegate::PlatformContext3D {
public:
explicit PlatformContext3DImpl(ggl::Context* parent_context);
virtual ~PlatformContext3DImpl();

@ -41,10 +41,10 @@
#include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/fileapi/file_system_callback_dispatcher.h"
#include "webkit/glue/plugins/pepper_file_io.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/webplugin.h"
#include "webkit/plugins/ppapi/ppb_file_io_impl.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#if defined(OS_MACOSX)
#include "chrome/common/render_messages.h"
@ -62,7 +62,8 @@ namespace {
const int32 kDefaultCommandBufferSize = 1024 * 1024;
// Implements the Image2D using a TransportDIB.
class PlatformImage2DImpl : public pepper::PluginDelegate::PlatformImage2D {
class PlatformImage2DImpl
: public webkit::ppapi::PluginDelegate::PlatformImage2D {
public:
// This constructor will take ownership of the dib pointer.
PlatformImage2DImpl(int width, int height, TransportDIB* dib)
@ -100,7 +101,7 @@ class PlatformImage2DImpl : public pepper::PluginDelegate::PlatformImage2D {
class PlatformAudioImpl
: public pepper::PluginDelegate::PlatformAudio,
: public webkit::ppapi::PluginDelegate::PlatformAudio,
public AudioMessageFilter::Delegate,
public base::RefCountedThreadSafe<PlatformAudioImpl> {
public:
@ -119,7 +120,7 @@ class PlatformAudioImpl
// Initialize this audio context. StreamCreated() will be called when the
// stream is created.
bool Initialize(uint32_t sample_rate, uint32_t sample_count,
pepper::PluginDelegate::PlatformAudio::Client* client);
webkit::ppapi::PluginDelegate::PlatformAudio::Client* client);
virtual bool StartPlayback() {
return filter_ && filter_->Send(
@ -151,7 +152,7 @@ class PlatformAudioImpl
virtual void OnVolume(double volume) { }
// The client to notify when the stream is created.
pepper::PluginDelegate::PlatformAudio::Client* client_;
webkit::ppapi::PluginDelegate::PlatformAudio::Client* client_;
// MessageFilter used to send/receive IPC.
scoped_refptr<AudioMessageFilter> filter_;
// Our ID on the MessageFilter.
@ -164,7 +165,7 @@ class PlatformAudioImpl
bool PlatformAudioImpl::Initialize(
uint32_t sample_rate, uint32_t sample_count,
pepper::PluginDelegate::PlatformAudio::Client* client) {
webkit::ppapi::PluginDelegate::PlatformAudio::Client* client) {
DCHECK(client);
// Make sure we don't call init more than once.
@ -224,7 +225,7 @@ void PlatformAudioImpl::ShutDown() {
// Implements the VideoDecoder.
class PlatformVideoDecoderImpl
: public pepper::PluginDelegate::PlatformVideoDecoder {
: public webkit::ppapi::PluginDelegate::PlatformVideoDecoder {
public:
PlatformVideoDecoderImpl()
: input_buffer_size_(0),
@ -308,7 +309,8 @@ class PlatformVideoDecoderImpl
DISALLOW_COPY_AND_ASSIGN(PlatformVideoDecoderImpl);
};
class DispatcherWrapper : public pepper::PluginDelegate::OutOfProcessProxy {
class DispatcherWrapper
: public webkit::ppapi::PluginDelegate::OutOfProcessProxy {
public:
DispatcherWrapper() {}
virtual ~DispatcherWrapper() {}
@ -366,7 +368,7 @@ PepperPluginDelegateImpl::PepperPluginDelegateImpl(RenderView* render_view)
PepperPluginDelegateImpl::~PepperPluginDelegateImpl() {
}
scoped_refptr<pepper::PluginModule>
scoped_refptr<webkit::ppapi::PluginModule>
PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) {
// Easy case is in-process plugins.
if (!PepperPluginRegistry::GetInstance()->RunOutOfProcessForPlugin(path))
@ -378,16 +380,18 @@ PepperPluginDelegateImpl::CreatePepperPlugin(const FilePath& path) {
render_view_->Send(new ViewHostMsg_OpenChannelToPepperPlugin(
path, &plugin_process_handle, &channel_handle));
if (channel_handle.name.empty())
return scoped_refptr<pepper::PluginModule>(); // Couldn't be initialized.
return scoped_refptr<webkit::ppapi::PluginModule>(); // Couldn't be initialized.
// Create a new HostDispatcher for the proxying, and hook it to a new
// PluginModule.
scoped_refptr<pepper::PluginModule> module(new pepper::PluginModule);
scoped_refptr<webkit::ppapi::PluginModule> module(
new webkit::ppapi::PluginModule);
scoped_ptr<DispatcherWrapper> dispatcher(new DispatcherWrapper);
if (!dispatcher->Init(plugin_process_handle, channel_handle,
module->pp_module(),
pepper::PluginModule::GetLocalGetInterfaceFunc()))
return scoped_refptr<pepper::PluginModule>();
if (!dispatcher->Init(
plugin_process_handle, channel_handle,
module->pp_module(),
webkit::ppapi::PluginModule::GetLocalGetInterfaceFunc()))
return scoped_refptr<webkit::ppapi::PluginModule>();
module->InitAsProxied(dispatcher.release());
return module;
}
@ -396,7 +400,7 @@ void PepperPluginDelegateImpl::ViewInitiatedPaint() {
// Notify all of our instances that we started painting. This is used for
// internal bookkeeping only, so we know that the set can not change under
// us.
for (std::set<pepper::PluginInstance*>::iterator i =
for (std::set<webkit::ppapi::PluginInstance*>::iterator i =
active_instances_.begin();
i != active_instances_.end(); ++i)
(*i)->ViewInitiatedPaint();
@ -407,8 +411,8 @@ void PepperPluginDelegateImpl::ViewFlushedPaint() {
// we it may ask to close itself as a result. This will, in turn, modify our
// set, possibly invalidating the iterator. So we iterate on a copy that
// won't change out from under us.
std::set<pepper::PluginInstance*> plugins = active_instances_;
for (std::set<pepper::PluginInstance*>::iterator i = plugins.begin();
std::set<webkit::ppapi::PluginInstance*> plugins = active_instances_;
for (std::set<webkit::ppapi::PluginInstance*>::iterator i = plugins.begin();
i != plugins.end(); ++i) {
// The copy above makes sure our iterator is never invalid if some plugins
// are destroyed. But some plugin may decide to close all of its views in
@ -436,10 +440,10 @@ bool PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint(
TransportDIB** dib,
gfx::Rect* location,
gfx::Rect* clip) {
for (std::set<pepper::PluginInstance*>::iterator i =
for (std::set<webkit::ppapi::PluginInstance*>::iterator i =
active_instances_.begin();
i != active_instances_.end(); ++i) {
pepper::PluginInstance* instance = *i;
webkit::ppapi::PluginInstance* instance = *i;
if (instance->GetBitmapForOptimizedPluginPaint(
paint_bounds, dib, location, clip))
return true;
@ -448,7 +452,7 @@ bool PepperPluginDelegateImpl::GetBitmapForOptimizedPluginPaint(
}
void PepperPluginDelegateImpl::InstanceCreated(
pepper::PluginInstance* instance) {
webkit::ppapi::PluginInstance* instance) {
active_instances_.insert(instance);
// Set the initial focus.
@ -456,11 +460,11 @@ void PepperPluginDelegateImpl::InstanceCreated(
}
void PepperPluginDelegateImpl::InstanceDeleted(
pepper::PluginInstance* instance) {
webkit::ppapi::PluginInstance* instance) {
active_instances_.erase(instance);
}
pepper::PluginDelegate::PlatformImage2D*
webkit::ppapi::PluginDelegate::PlatformImage2D*
PepperPluginDelegateImpl::CreateImage2D(int width, int height) {
uint32 buffer_size = width * height * 4;
@ -496,7 +500,7 @@ PepperPluginDelegateImpl::CreateImage2D(int width, int height) {
return new PlatformImage2DImpl(width, height, dib);
}
pepper::PluginDelegate::PlatformContext3D*
webkit::ppapi::PluginDelegate::PlatformContext3D*
PepperPluginDelegateImpl::CreateContext3D() {
#ifdef ENABLE_GPU
WebGraphicsContext3DCommandBufferImpl* context =
@ -515,7 +519,7 @@ pepper::PluginDelegate::PlatformContext3D*
#endif
}
pepper::PluginDelegate::PlatformVideoDecoder*
webkit::ppapi::PluginDelegate::PlatformVideoDecoder*
PepperPluginDelegateImpl::CreateVideoDecoder(
const PP_VideoDecoderConfig_Dev& decoder_config) {
scoped_ptr<PlatformVideoDecoderImpl> decoder(new PlatformVideoDecoderImpl());
@ -538,9 +542,10 @@ void PepperPluginDelegateImpl::SelectedFindResultChanged(int identifier,
identifier, index + 1, WebKit::WebRect());
}
pepper::PluginDelegate::PlatformAudio* PepperPluginDelegateImpl::CreateAudio(
webkit::ppapi::PluginDelegate::PlatformAudio*
PepperPluginDelegateImpl::CreateAudio(
uint32_t sample_rate, uint32_t sample_count,
pepper::PluginDelegate::PlatformAudio::Client* client) {
webkit::ppapi::PluginDelegate::PlatformAudio::Client* client) {
scoped_refptr<PlatformAudioImpl> audio(
new PlatformAudioImpl(render_view_->audio_message_filter()));
if (audio->Initialize(sample_rate, sample_count, client)) {
@ -582,7 +587,7 @@ void PepperPluginDelegateImpl::OnAsyncFileOpened(
}
void PepperPluginDelegateImpl::OnSetFocus(bool has_focus) {
for (std::set<pepper::PluginInstance*>::iterator i =
for (std::set<webkit::ppapi::PluginInstance*>::iterator i =
active_instances_.begin();
i != active_instances_.end(); ++i)
(*i)->SetContentAreaFocus(has_focus);
@ -755,7 +760,7 @@ base::PlatformFileError PepperPluginDelegateImpl::QueryModuleLocalFile(
base::PlatformFileError PepperPluginDelegateImpl::GetModuleLocalDirContents(
const std::string& module_name,
const FilePath& path,
PepperDirContents* contents) {
webkit::ppapi::DirContents* contents) {
FilePath full_path = GetModuleLocalFilePath(module_name, path);
if (full_path.empty()) {
return base::PLATFORM_FILE_ERROR_ACCESS_DENIED;
@ -774,9 +779,9 @@ PepperPluginDelegateImpl::GetFileThreadMessageLoopProxy() {
return RenderThread::current()->GetFileThreadMessageLoopProxy();
}
pepper::FullscreenContainer*
webkit::ppapi::FullscreenContainer*
PepperPluginDelegateImpl::CreateFullscreenContainer(
pepper::PluginInstance* instance) {
webkit::ppapi::PluginInstance* instance) {
return render_view_->CreatePepperFullscreenContainer(instance);
}

@ -14,8 +14,8 @@
#include "base/ref_counted.h"
#include "base/weak_ptr.h"
#include "ppapi/c/pp_errors.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
class FilePath;
class RenderView;
@ -24,11 +24,14 @@ namespace gfx {
class Rect;
}
namespace pepper {
class FileIO;
namespace webkit {
namespace ppapi {
class PluginInstance;
class PluginModule;
}
} // namespace ppapi
} // namespace webkit
namespace WebKit {
class WebFileChooserCompletion;
@ -38,13 +41,14 @@ struct WebFileChooserParams;
class TransportDIB;
class PepperPluginDelegateImpl
: public pepper::PluginDelegate,
: public webkit::ppapi::PluginDelegate,
public base::SupportsWeakPtr<PepperPluginDelegateImpl> {
public:
explicit PepperPluginDelegateImpl(RenderView* render_view);
virtual ~PepperPluginDelegateImpl();
scoped_refptr<pepper::PluginModule> CreatePepperPlugin(const FilePath& path);
scoped_refptr<webkit::ppapi::PluginModule> CreatePepperPlugin(
const FilePath& path);
// Called by RenderView to tell us about painting events, these two functions
// just correspond to the DidInitiatePaint and DidFlushPaint in R.V..
@ -68,13 +72,15 @@ class PepperPluginDelegateImpl
// notifies all of the plugins.
void OnSetFocus(bool has_focus);
// pepper::PluginDelegate implementation.
virtual void InstanceCreated(pepper::PluginInstance* instance);
virtual void InstanceDeleted(pepper::PluginInstance* instance);
// PluginDelegate implementation.
virtual void InstanceCreated(
webkit::ppapi::PluginInstance* instance);
virtual void InstanceDeleted(
webkit::ppapi::PluginInstance* instance);
virtual PlatformAudio* CreateAudio(
uint32_t sample_rate,
uint32_t sample_count,
pepper::PluginDelegate::PlatformAudio::Client* client);
PlatformAudio::Client* client);
virtual PlatformImage2D* CreateImage2D(int width, int height);
virtual PlatformContext3D* CreateContext3D();
virtual PlatformVideoDecoder* CreateVideoDecoder(
@ -133,10 +139,11 @@ class PepperPluginDelegateImpl
virtual base::PlatformFileError GetModuleLocalDirContents(
const std::string& module_name,
const FilePath& path,
PepperDirContents* contents);
webkit::ppapi::DirContents* contents);
virtual scoped_refptr<base::MessageLoopProxy> GetFileThreadMessageLoopProxy();
virtual pepper::FullscreenContainer* CreateFullscreenContainer(
pepper::PluginInstance* instance);
virtual webkit::ppapi::FullscreenContainer*
CreateFullscreenContainer(
webkit::ppapi::PluginInstance* instance);
virtual std::string GetDefaultEncoding();
virtual void ZoomLimitsChanged(double minimum_factor, double maximum_factor);
virtual std::string ResolveProxy(const GURL& url);
@ -148,7 +155,7 @@ class PepperPluginDelegateImpl
// Pointer to the RenderView that owns us.
RenderView* render_view_;
std::set<pepper::PluginInstance*> active_instances_;
std::set<webkit::ppapi::PluginInstance*> active_instances_;
int id_generator_;
IDMap<AsyncOpenFileCallback> messages_waiting_replies_;

@ -175,7 +175,6 @@
#include "webkit/glue/media/video_renderer_impl.h"
#include "webkit/glue/password_form_dom_manager.h"
#include "webkit/glue/plugins/default_plugin_shared.h"
#include "webkit/glue/plugins/pepper_webplugin_impl.h"
#include "webkit/glue/plugins/plugin_list.h"
#include "webkit/glue/plugins/webplugin_delegate.h"
#include "webkit/glue/plugins/webplugin_delegate_impl.h"
@ -187,6 +186,7 @@
#include "webkit/glue/webdropdata.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/webmediaplayer_impl.h"
#include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
#if defined(OS_WIN)
// TODO(port): these files are currently Windows only because they concern:
@ -845,7 +845,7 @@ WebPlugin* RenderView::CreatePluginNoCheck(WebFrame* frame,
if (!found || !info.enabled)
return NULL;
scoped_refptr<pepper::PluginModule> pepper_module(
scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
pepper_delegate_.CreatePepperPlugin(info.path));
if (pepper_module)
return CreatePepperPlugin(frame, params, info.path, pepper_module.get());
@ -2128,8 +2128,9 @@ WebWidget* RenderView::createFullscreenWindow(WebKit::WebPopupType popup_type) {
return widget->webwidget();
}
pepper::FullscreenContainer* RenderView::CreatePepperFullscreenContainer(
pepper::PluginInstance* plugin) {
webkit::ppapi::FullscreenContainer*
RenderView::CreatePepperFullscreenContainer(
webkit::ppapi::PluginInstance* plugin) {
RenderWidgetFullscreenPepper* widget =
RenderWidgetFullscreenPepper::Create(routing_id_, render_thread_, plugin);
widget->show(WebKit::WebNavigationPolicyIgnore);
@ -2781,7 +2782,7 @@ WebPlugin* RenderView::createPlugin(WebFrame* frame,
if (info.path.value() == kDefaultPluginLibraryName ||
plugin_setting == CONTENT_SETTING_ALLOW ||
host_setting == CONTENT_SETTING_ALLOW) {
scoped_refptr<pepper::PluginModule> pepper_module(
scoped_refptr<webkit::ppapi::PluginModule> pepper_module(
pepper_delegate_.CreatePepperPlugin(info.path));
if (pepper_module)
return CreatePepperPlugin(frame, params, info.path, pepper_module.get());
@ -4429,11 +4430,12 @@ void RenderView::ClearBlockedContentSettings() {
content_blocked_[i] = false;
}
WebPlugin* RenderView::CreatePepperPlugin(WebFrame* frame,
const WebPluginParams& params,
const FilePath& path,
pepper::PluginModule* pepper_module) {
return new pepper::WebPluginImpl(
WebPlugin* RenderView::CreatePepperPlugin(
WebFrame* frame,
const WebPluginParams& params,
const FilePath& path,
webkit::ppapi::PluginModule* pepper_module) {
return new webkit::ppapi::WebPluginImpl(
pepper_module, params, pepper_delegate_.AsWeakPtr());
}

@ -96,10 +96,14 @@ class Point;
class Rect;
}
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginInstance;
class FullscreenContainer;
}
} // namespace ppapi
} // namespace webkit
namespace safe_browsing {
class PhishingClassifierDelegate;
@ -331,8 +335,8 @@ class RenderView : public RenderWidget,
void OnPepperPluginDestroy(WebPluginDelegatePepper* pepper_plugin);
// Creates a fullscreen container for a pepper plugin instance.
pepper::FullscreenContainer* CreatePepperFullscreenContainer(
pepper::PluginInstance* plugin);
webkit::ppapi::FullscreenContainer* CreatePepperFullscreenContainer(
webkit::ppapi::PluginInstance* plugin);
// Create a new plugin without checking the content settings.
WebKit::WebPlugin* CreatePluginNoCheck(WebKit::WebFrame* frame,
@ -1013,10 +1017,11 @@ class RenderView : public RenderWidget,
const std::string& mime_type);
// Create a new Pepper plugin.
WebKit::WebPlugin* CreatePepperPlugin(WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params,
const FilePath& path,
pepper::PluginModule* pepper_module);
WebKit::WebPlugin* CreatePepperPlugin(
WebKit::WebFrame* frame,
const WebKit::WebPluginParams& params,
const FilePath& path,
webkit::ppapi::PluginModule* pepper_module);
WebKit::WebPlugin* CreateOutdatedPluginPlaceholder(
WebKit::WebFrame* frame,

@ -9,8 +9,8 @@
#include "third_party/WebKit/WebKit/chromium/public/WebCursorInfo.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSize.h"
#include "third_party/WebKit/WebKit/chromium/public/WebWidget.h"
#include "webkit/glue/plugins/pepper_fullscreen_container.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/plugins/ppapi/fullscreen_container.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
using WebKit::WebCanvas;
using WebKit::WebCompositionUnderline;
@ -29,7 +29,7 @@ namespace {
// WebWidget that simply wraps the pepper plugin.
class PepperWidget : public WebWidget {
public:
PepperWidget(pepper::PluginInstance* plugin,
PepperWidget(webkit::ppapi::PluginInstance* plugin,
RenderWidgetFullscreenPepper* widget)
: plugin_(plugin),
widget_(widget),
@ -119,7 +119,7 @@ class PepperWidget : public WebWidget {
}
private:
pepper::PluginInstance* plugin_;
webkit::ppapi::PluginInstance* plugin_;
RenderWidgetFullscreenPepper* widget_;
WebSize size_;
WebCursorInfo cursor_;
@ -130,7 +130,8 @@ class PepperWidget : public WebWidget {
// A FullscreenContainer that forwards the API calls to the
// RenderWidgetFullscreenPepper.
class WidgetFullscreenContainer : public pepper::FullscreenContainer {
class WidgetFullscreenContainer
: public webkit::ppapi::FullscreenContainer {
public:
explicit WidgetFullscreenContainer(RenderWidgetFullscreenPepper* widget)
: widget_(widget) {
@ -164,7 +165,7 @@ class WidgetFullscreenContainer : public pepper::FullscreenContainer {
// static
RenderWidgetFullscreenPepper* RenderWidgetFullscreenPepper::Create(
int32 opener_id, RenderThreadBase* render_thread,
pepper::PluginInstance* plugin) {
webkit::ppapi::PluginInstance* plugin) {
DCHECK_NE(MSG_ROUTING_NONE, opener_id);
scoped_refptr<RenderWidgetFullscreenPepper> widget(
new RenderWidgetFullscreenPepper(render_thread, plugin));
@ -173,7 +174,8 @@ RenderWidgetFullscreenPepper* RenderWidgetFullscreenPepper::Create(
}
RenderWidgetFullscreenPepper::RenderWidgetFullscreenPepper(
RenderThreadBase* render_thread, pepper::PluginInstance* plugin)
RenderThreadBase* render_thread,
webkit::ppapi::PluginInstance* plugin)
: RenderWidgetFullscreen(render_thread, WebKit::WebPopupTypeSelect),
plugin_(plugin),
ALLOW_THIS_IN_INITIALIZER_LIST(

@ -8,10 +8,14 @@
#include "chrome/renderer/render_widget_fullscreen.h"
#include "third_party/WebKit/WebKit/chromium/public/WebWidget.h"
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginInstance;
class FullscreenContainer;
}
} // namespace ppapi
} // namespace webkit
// A RenderWidget that hosts a fullscreen pepper plugin. This provides a
// FullscreenContainer that the plugin instance can callback into to e.g.
@ -21,7 +25,7 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen {
static RenderWidgetFullscreenPepper* Create(
int32 opener_id,
RenderThreadBase* render_thread,
pepper::PluginInstance* plugin);
webkit::ppapi::PluginInstance* plugin);
// Asks the browser to close this view, which will tear off the window and
// close this widget.
@ -30,11 +34,13 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen {
// Invalidate the whole widget to force a redraw.
void GenerateFullRepaint();
pepper::FullscreenContainer* container() const { return container_.get(); }
webkit::ppapi::FullscreenContainer* container() const {
return container_.get();
}
protected:
RenderWidgetFullscreenPepper(RenderThreadBase* render_thread,
pepper::PluginInstance* plugin);
webkit::ppapi::PluginInstance* plugin);
virtual ~RenderWidgetFullscreenPepper();
// RenderWidget API.
@ -52,10 +58,10 @@ class RenderWidgetFullscreenPepper : public RenderWidgetFullscreen {
private:
// The plugin instance this widget wraps.
pepper::PluginInstance* plugin_;
webkit::ppapi::PluginInstance* plugin_;
// The FullscreenContainer that the plugin instance can callback into.
scoped_ptr<pepper::FullscreenContainer> container_;
scoped_ptr<webkit::ppapi::FullscreenContainer> container_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetFullscreenPepper);
};

@ -5,5 +5,6 @@ include_rules = [
"+sandbox/src",
"+sandbox/tests",
"+webkit/glue",
"+webkit/plugins",
"+v8/include", # We have unit tests which use v8 to exercise JavaScript.
]

@ -11,7 +11,7 @@
#include "chrome/test/ui/ui_test.h"
#include "net/base/net_util.h"
#include "net/test/test_server.h"
#include "webkit/glue/plugins/plugin_switches.h"
#include "webkit/plugins/plugin_switches.h"
namespace {

@ -5,8 +5,8 @@ include_rules = [
# These files are really Chrome-only and we don't want to expose them, but
# we need to use them for the proxy. Allow the code here to pull these
# headers (which don't depend on anything else).
"+webkit/glue/plugins/ppb_private.h",
"+webkit/glue/plugins/ppb_private2.h",
"+webkit/plugins/ppapi/ppb_pdf.h",
"+webkit/plugins/ppapi/ppb_flash.h",
# We don't want the proxy to depend on the C++ layer, which is appropriate
# for plugins only. However, the completion callback factory is a very useful

@ -55,8 +55,8 @@
#include "ppapi/proxy/ppp_class_proxy.h"
#include "ppapi/proxy/ppp_instance_proxy.h"
#include "ppapi/proxy/var_serialization_rules.h"
#include "webkit/glue/plugins/ppb_private.h"
#include "webkit/glue/plugins/ppb_private2.h"
#include "webkit/plugins/ppapi/ppb_pdf.h"
#include "webkit/plugins/ppapi/ppb_flash.h"
namespace pp {
namespace proxy {
@ -262,10 +262,10 @@ InterfaceProxy* Dispatcher::CreateProxyForInterface(
// Trusted interfaces.
if (!disallow_trusted_interfaces_) {
if (interface_name == PPB_PRIVATE2_INTERFACE)
if (interface_name == PPB_FLASH_INTERFACE)
return new PPB_Flash_Proxy(this, interface_functions);
if (interface_name == PPB_PRIVATE_INTERFACE)
return new PPB_Pdf_Proxy(this, interface_functions);
if (interface_name == PPB_PDF_INTERFACE)
return new PPB_PDF_Proxy(this, interface_functions);
if (interface_name == PPB_URLLOADERTRUSTED_INTERFACE)
return new PPB_URLLoaderTrusted_Proxy(this, interface_functions);
}

@ -377,13 +377,13 @@ IPC_SYNC_MESSAGE_ROUTED2_2(PpapiHostMsg_PPBInstance_ExecuteScript,
pp::proxy::SerializedVar /* result */)
IPC_SYNC_MESSAGE_ROUTED3_1(
PpapiHostMsg_PPBPdf_GetFontFileWithFallback,
PpapiHostMsg_PPBPDF_GetFontFileWithFallback,
PP_Module /* module */,
pp::proxy::SerializedFontDescription /* description */,
int32_t /* charset */,
PP_Resource /* result */)
IPC_SYNC_MESSAGE_ROUTED2_1(
PpapiHostMsg_PPBPdf_GetFontTableForPrivateFontFile,
PpapiHostMsg_PPBPDF_GetFontTableForPrivateFontFile,
PP_Resource /* font_file */,
uint32_t /* table */,
std::string /* result */)

@ -15,7 +15,7 @@
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_var.h"
#include "webkit/glue/plugins/ppb_private2.h"
#include "webkit/plugins/ppapi/ppb_flash.h"
namespace pp {
namespace proxy {
@ -192,7 +192,7 @@ bool NavigateToURL(PP_Instance pp_instance,
return result;
}
const PPB_Private2 ppb_flash = {
const PPB_Flash ppb_flash = {
&SetInstanceAlwaysOnTop,
&DrawGlyphs,
&GetProxyForURL,

@ -13,7 +13,7 @@
#include "ppapi/proxy/interface_proxy.h"
struct PP_FileInfo_Dev;
struct PPB_Private2;
struct PPB_Flash;
namespace pp {
namespace proxy {
@ -28,8 +28,8 @@ class PPB_Flash_Proxy : public InterfaceProxy {
PPB_Flash_Proxy(Dispatcher* dispatcher, const void* target_interface);
virtual ~PPB_Flash_Proxy();
const PPB_Private2* ppb_flash_target() const {
return static_cast<const PPB_Private2*>(target_interface());
const PPB_Flash* ppb_flash_target() const {
return static_cast<const PPB_Flash*>(target_interface());
}
// InterfaceProxy implementation.

@ -14,7 +14,7 @@
#include "ppapi/proxy/plugin_dispatcher.h"
#include "ppapi/proxy/plugin_resource.h"
#include "ppapi/proxy/ppapi_messages.h"
#include "webkit/glue/plugins/ppb_private.h"
#include "webkit/plugins/ppapi/ppb_pdf.h"
namespace pp {
namespace proxy {
@ -65,7 +65,7 @@ PP_Resource GetFontFileWithFallback(
desc.SetFromPPFontDescription(dispatcher, *description, true);
PP_Resource result = 0;
dispatcher->Send(new PpapiHostMsg_PPBPdf_GetFontFileWithFallback(
dispatcher->Send(new PpapiHostMsg_PPBPDF_GetFontFileWithFallback(
INTERFACE_ID_PPB_PDF, module_id, desc, charset, &result));
if (!result)
return 0;
@ -87,7 +87,7 @@ bool GetFontTableForPrivateFontFile(PP_Resource font_file,
if (!contents) {
std::string deserialized;
PluginDispatcher::Get()->Send(
new PpapiHostMsg_PPBPdf_GetFontTableForPrivateFontFile(
new PpapiHostMsg_PPBPDF_GetFontTableForPrivateFontFile(
INTERFACE_ID_PPB_PDF, font_file, table, &deserialized));
if (deserialized.empty())
return false;
@ -100,7 +100,7 @@ bool GetFontTableForPrivateFontFile(PP_Resource font_file,
return true;
}
const PPB_Private ppb_private = {
const PPB_PDF ppb_pdf = {
NULL, // &GetLocalizedString,
NULL, // &GetResourceImage,
&GetFontFileWithFallback,
@ -109,33 +109,33 @@ const PPB_Private ppb_private = {
} // namespace
PPB_Pdf_Proxy::PPB_Pdf_Proxy(Dispatcher* dispatcher,
PPB_PDF_Proxy::PPB_PDF_Proxy(Dispatcher* dispatcher,
const void* target_interface)
: InterfaceProxy(dispatcher, target_interface) {
}
PPB_Pdf_Proxy::~PPB_Pdf_Proxy() {
PPB_PDF_Proxy::~PPB_PDF_Proxy() {
}
const void* PPB_Pdf_Proxy::GetSourceInterface() const {
return &ppb_private;
const void* PPB_PDF_Proxy::GetSourceInterface() const {
return &ppb_pdf;
}
InterfaceID PPB_Pdf_Proxy::GetInterfaceId() const {
InterfaceID PPB_PDF_Proxy::GetInterfaceId() const {
return INTERFACE_ID_PPB_PDF;
}
void PPB_Pdf_Proxy::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(PPB_Pdf_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPdf_GetFontFileWithFallback,
void PPB_PDF_Proxy::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP(PPB_PDF_Proxy, msg)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPDF_GetFontFileWithFallback,
OnMsgGetFontFileWithFallback)
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPdf_GetFontTableForPrivateFontFile,
IPC_MESSAGE_HANDLER(PpapiHostMsg_PPBPDF_GetFontTableForPrivateFontFile,
OnMsgGetFontTableForPrivateFontFile)
IPC_END_MESSAGE_MAP()
// TODO(brettw): handle bad messages!
}
void PPB_Pdf_Proxy::OnMsgGetFontFileWithFallback(
void PPB_PDF_Proxy::OnMsgGetFontFileWithFallback(
PP_Module module,
const SerializedFontDescription& in_desc,
int32_t charset,
@ -146,7 +146,7 @@ void PPB_Pdf_Proxy::OnMsgGetFontFileWithFallback(
static_cast<PP_PrivateFontCharset>(charset));
}
void PPB_Pdf_Proxy::OnMsgGetFontTableForPrivateFontFile(PP_Resource font_file,
void PPB_PDF_Proxy::OnMsgGetFontTableForPrivateFontFile(PP_Resource font_file,
uint32_t table,
std::string* result) {
// TODO(brettw): It would be nice not to copy here. At least on Linux,

@ -8,20 +8,20 @@
#include "ppapi/c/pp_module.h"
#include "ppapi/proxy/interface_proxy.h"
struct PPB_Private;
struct PPB_PDF;
namespace pp {
namespace proxy {
struct SerializedFontDescription;
class PPB_Pdf_Proxy : public InterfaceProxy {
class PPB_PDF_Proxy : public InterfaceProxy {
public:
PPB_Pdf_Proxy(Dispatcher* dispatcher, const void* target_interface);
virtual ~PPB_Pdf_Proxy();
PPB_PDF_Proxy(Dispatcher* dispatcher, const void* target_interface);
virtual ~PPB_PDF_Proxy();
const PPB_Private* ppb_pdf_target() const {
return static_cast<const PPB_Private*>(target_interface());
const PPB_PDF* ppb_pdf_target() const {
return static_cast<const PPB_PDF*>(target_interface());
}
// InterfaceProxy implementation.

@ -1,18 +0,0 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_DIR_CONTENTS_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_DIR_CONTENTS_H_
#include <vector>
#include "base/file_path.h"
struct PepperDirEntry {
FilePath name;
bool is_dir;
};
typedef std::vector<PepperDirEntry> PepperDirContents;
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_DIR_CONTENTS_H_

@ -1,62 +0,0 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FILE_REF_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_FILE_REF_H_
#include <string>
#include "base/file_path.h"
#include "ppapi/c/dev/ppb_file_ref_dev.h"
#include "webkit/glue/plugins/pepper_resource.h"
namespace pepper {
class FileSystem;
class PluginInstance;
class PluginModule;
class FileRef : public Resource {
public:
FileRef();
FileRef(PluginModule* module,
scoped_refptr<FileSystem> file_system,
const std::string& validated_path);
FileRef(PluginModule* module,
const FilePath& external_file_path);
virtual ~FileRef();
// Returns a pointer to the interface implementing PPB_FileRef that is
// exposed to the plugin.
static const PPB_FileRef_Dev* GetInterface();
// Resource overrides.
virtual FileRef* AsFileRef();
// PPB_FileRef implementation.
std::string GetName() const;
scoped_refptr<FileRef> GetParent();
// Returns the file system to which this FileRef belongs.
scoped_refptr<FileSystem> GetFileSystem() const;
// Returns the type of the file system to which this FileRef belongs.
PP_FileSystemType_Dev GetFileSystemType() const;
// Returns the virtual path (i.e., the path that the pepper plugin sees)
// corresponding to this file.
std::string GetPath() const;
// Returns the system path corresponding to this file.
FilePath GetSystemPath() const;
private:
scoped_refptr<FileSystem> file_system_;
std::string virtual_path_; // UTF-8 encoded
FilePath system_path_;
};
} // namespace pepper
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FILE_REF_H_

@ -1,891 +0,0 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_plugin_object.h"
#include "base/logging.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npruntime.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/dev/ppp_class_deprecated.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/c/ppb_class.h"
#include "third_party/WebKit/WebKit/chromium/public/WebBindings.h"
#include "webkit/glue/plugins/pepper_class.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/glue/plugins/pepper_string.h"
#include "webkit/glue/plugins/pepper_var.h"
using WebKit::WebBindings;
namespace pepper {
namespace {
const char kInvalidValueException[] = "Error: Invalid value";
const char kInvalidPluginValue[] = "Error: Plugin returned invalid value.";
// -----------------------------------------------------------------------------
// Utilities
// Converts the given PP_Var to an NPVariant, returning true on success.
// False means that the given variant is invalid. In this case, the result
// NPVariant will be set to a void one.
//
// The contents of the PP_Var will be copied unless the PP_Var corresponds to
// an object.
bool PPVarToNPVariant(PP_Var var, NPVariant* result) {
switch (var.type) {
case PP_VARTYPE_UNDEFINED:
VOID_TO_NPVARIANT(*result);
break;
case PP_VARTYPE_NULL:
NULL_TO_NPVARIANT(*result);
break;
case PP_VARTYPE_BOOL:
BOOLEAN_TO_NPVARIANT(var.value.as_bool, *result);
break;
case PP_VARTYPE_INT32:
INT32_TO_NPVARIANT(var.value.as_int, *result);
break;
case PP_VARTYPE_DOUBLE:
DOUBLE_TO_NPVARIANT(var.value.as_double, *result);
break;
case PP_VARTYPE_STRING: {
scoped_refptr<StringVar> string(StringVar::FromPPVar(var));
if (!string) {
VOID_TO_NPVARIANT(*result);
return false;
}
const std::string& value = string->value();
STRINGN_TO_NPVARIANT(base::strdup(value.c_str()), value.size(), *result);
break;
}
case PP_VARTYPE_OBJECT: {
scoped_refptr<ObjectVar> object(ObjectVar::FromPPVar(var));
if (!object) {
VOID_TO_NPVARIANT(*result);
return false;
}
OBJECT_TO_NPVARIANT(WebBindings::retainObject(object->np_object()),
*result);
break;
}
}
return true;
}
// PPVarArrayFromNPVariantArray ------------------------------------------------
// Converts an array of NPVariants to an array of PP_Var, and scopes the
// ownership of the PP_Var. This is used when converting argument lists from
// WebKit to the plugin.
class PPVarArrayFromNPVariantArray {
public:
PPVarArrayFromNPVariantArray(PluginModule* module,
size_t size,
const NPVariant* variants)
: size_(size) {
if (size_ > 0) {
array_.reset(new PP_Var[size_]);
for (size_t i = 0; i < size_; i++)
array_[i] = Var::NPVariantToPPVar(module, &variants[i]);
}
}
~PPVarArrayFromNPVariantArray() {
for (size_t i = 0; i < size_; i++)
Var::PluginReleasePPVar(array_[i]);
}
PP_Var* array() { return array_.get(); }
private:
size_t size_;
scoped_array<PP_Var> array_;
DISALLOW_COPY_AND_ASSIGN(PPVarArrayFromNPVariantArray);
};
// PPVarFromNPObject -----------------------------------------------------------
// Converts an NPObject tp PP_Var, and scopes the ownership of the PP_Var. This
// is used when converting 'this' pointer from WebKit to the plugin.
class PPVarFromNPObject {
public:
PPVarFromNPObject(PluginModule* module, NPObject* object)
: var_(ObjectVar::NPObjectToPPVar(module, object)) {
}
~PPVarFromNPObject() {
Var::PluginReleasePPVar(var_);
}
PP_Var var() const { return var_; }
private:
const PP_Var var_;
DISALLOW_COPY_AND_ASSIGN(PPVarFromNPObject);
};
// PPResultAndExceptionToNPResult ----------------------------------------------
// Convenience object for converting a PPAPI call that can throw an exception
// and optionally return a value, back to the NPAPI layer which expects a
// NPVariant as a result.
//
// Normal usage is that you will pass the result of exception() to the
// PPAPI function as the exception output parameter. Then you will either
// call SetResult with the result of the PPAPI call, or
// CheckExceptionForNoResult if the PPAPI call doesn't return a PP_Var.
//
// Both SetResult and CheckExceptionForNoResult will throw an exception to
// the JavaScript library if the plugin reported an exception. SetResult
// will additionally convert the result to an NPVariant and write it to the
// output parameter given in the constructor.
class PPResultAndExceptionToNPResult {
public:
// The object_var parameter is the object to associate any exception with.
// It may not be NULL.
//
// The np_result parameter is the NPAPI result output parameter. This may be
// NULL if there is no NPVariant result (like for HasProperty). If this is
// specified, you must call SetResult() to set it. If it is not, you must
// call CheckExceptionForNoResult to do the exception checking with no result
// conversion.
PPResultAndExceptionToNPResult(NPObject* object_var,
NPVariant* np_result)
: object_var_(object_var),
np_result_(np_result),
exception_(PP_MakeUndefined()),
success_(false),
checked_exception_(false) {
}
~PPResultAndExceptionToNPResult() {
// The user should have called SetResult or CheckExceptionForNoResult
// before letting this class go out of scope, or the exception will have
// been lost.
DCHECK(checked_exception_);
ObjectVar::PluginReleasePPVar(exception_);
}
// Returns true if an exception has been set.
bool has_exception() const { return exception_.type != PP_VARTYPE_UNDEFINED; }
// Returns a pointer to the exception. You would pass this to the PPAPI
// function as the exception parameter. If it is set to non-void, this object
// will take ownership of destroying it.
PP_Var* exception() { return &exception_; }
// Returns true if everything succeeded with no exception. This is valid only
// after calling SetResult/CheckExceptionForNoResult.
bool success() const {
DCHECK(checked_exception_);
return success_;
}
// Call this with the return value of the PPAPI function. It will convert
// the result to the NPVariant output parameter and pass any exception on to
// the JS engine. It will update the success flag and return it.
bool SetResult(PP_Var result) {
DCHECK(!checked_exception_); // Don't call more than once.
DCHECK(np_result_); // Should be expecting a result.
checked_exception_ = true;
if (has_exception()) {
ThrowException();
success_ = false;
} else if (!PPVarToNPVariant(result, np_result_)) {
WebBindings::setException(object_var_, kInvalidPluginValue);
success_ = false;
} else {
success_ = true;
}
// No matter what happened, we need to release the reference to the
// value passed in. On success, a reference to this value will be in
// the np_result_.
Var::PluginReleasePPVar(result);
return success_;
}
// Call this after calling a PPAPI function that could have set the
// exception. It will pass the exception on to the JS engine and update
// the success flag.
//
// The success flag will be returned.
bool CheckExceptionForNoResult() {
DCHECK(!checked_exception_); // Don't call more than once.
DCHECK(!np_result_); // Can't have a result when doing this.
checked_exception_ = true;
if (has_exception()) {
ThrowException();
success_ = false;
return false;
}
success_ = true;
return true;
}
// Call this to ignore any exception. This prevents the DCHECK from failing
// in the destructor.
void IgnoreException() {
checked_exception_ = true;
}
private:
// Throws the current exception to JS. The exception must be set.
void ThrowException() {
scoped_refptr<StringVar> string(StringVar::FromPPVar(exception_));
if (string) {
WebBindings::setException(object_var_, string->value().c_str());
}
}
NPObject* object_var_; // Non-owning ref (see constructor).
NPVariant* np_result_; // Output value, possibly NULL (see constructor).
PP_Var exception_; // Exception set by the PPAPI call. We own a ref to it.
bool success_; // See the success() function above.
bool checked_exception_; // SetResult/CheckExceptionForNoResult was called.
DISALLOW_COPY_AND_ASSIGN(PPResultAndExceptionToNPResult);
};
// NPObjectAccessorWithIdentifier ----------------------------------------------
// Helper class for our NPObject wrapper. This converts a call from WebKit
// where it gives us an NPObject and an NPIdentifier to an easily-accessible
// ObjectVar (corresponding to the NPObject) and PP_Var (corresponding to the
// NPIdentifier).
//
// If the NPObject or identifier is invalid, we'll set is_valid() to false.
// The caller should check is_valid() before doing anything with the class.
//
// JS can't have integer functions, so when dealing with these, we don't want
// to allow integer identifiers. The calling code can decode if it wants to
// allow integer identifiers (like for property access) or prohibit them
// (like for method calling) by setting |allow_integer_identifier|. If this
// is false and the identifier is an integer, we'll set is_valid() to false.
//
// Getting an integer identifier in this case should be impossible. V8
// shouldn't be allowing this, and the Pepper Var calls from the plugin are
// supposed to error out before calling into V8 (which will then call us back).
// Aside from an egregious error, the only time this could happen is an NPAPI
// plugin calling us.
class NPObjectAccessorWithIdentifier {
public:
NPObjectAccessorWithIdentifier(NPObject* object,
NPIdentifier identifier,
bool allow_integer_identifier)
: object_(PluginObject::FromNPObject(object)),
identifier_(PP_MakeUndefined()) {
if (object_) {
identifier_ = Var::NPIdentifierToPPVar(object_->module(), identifier);
if (identifier_.type == PP_VARTYPE_INT32 && !allow_integer_identifier)
identifier_.type = PP_VARTYPE_UNDEFINED; // Mark it invalid.
}
}
~NPObjectAccessorWithIdentifier() {
Var::PluginReleasePPVar(identifier_);
}
// Returns true if both the object and identifier are valid.
bool is_valid() const {
return object_ && identifier_.type != PP_VARTYPE_UNDEFINED;
}
PluginObject* object() { return object_; }
PP_Var identifier() const { return identifier_; }
private:
PluginObject* object_;
PP_Var identifier_;
DISALLOW_COPY_AND_ASSIGN(NPObjectAccessorWithIdentifier);
};
// NPObject implementation in terms of PPP_Class_Deprecated --------------------
NPObject* WrapperClass_Allocate(NPP npp, NPClass* unused) {
return PluginObject::AllocateObjectWrapper();
}
void WrapperClass_Deallocate(NPObject* np_object) {
PluginObject* plugin_object = PluginObject::FromNPObject(np_object);
if (!plugin_object)
return;
plugin_object->ppp_class()->Deallocate(plugin_object->ppp_class_data());
delete plugin_object;
}
void WrapperClass_Invalidate(NPObject* object) {
}
bool WrapperClass_HasMethod(NPObject* object, NPIdentifier method_name) {
NPObjectAccessorWithIdentifier accessor(object, method_name, false);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
bool rv = accessor.object()->ppp_class()->HasMethod(
accessor.object()->ppp_class_data(), accessor.identifier(),
result_converter.exception());
result_converter.CheckExceptionForNoResult();
return rv;
}
bool WrapperClass_Invoke(NPObject* object, NPIdentifier method_name,
const NPVariant* argv, uint32_t argc,
NPVariant* result) {
NPObjectAccessorWithIdentifier accessor(object, method_name, false);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), result);
PPVarArrayFromNPVariantArray args(accessor.object()->module(), argc, argv);
return result_converter.SetResult(accessor.object()->ppp_class()->Call(
accessor.object()->ppp_class_data(), accessor.identifier(),
argc, args.array(), result_converter.exception()));
}
bool WrapperClass_InvokeDefault(NPObject* np_object, const NPVariant* argv,
uint32_t argc, NPVariant* result) {
PluginObject* obj = PluginObject::FromNPObject(np_object);
if (!obj)
return false;
PPVarArrayFromNPVariantArray args(obj->module(), argc, argv);
PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), result);
result_converter.SetResult(obj->ppp_class()->Call(
obj->ppp_class_data(), PP_MakeUndefined(), argc, args.array(),
result_converter.exception()));
return result_converter.success();
}
bool WrapperClass_HasProperty(NPObject* object, NPIdentifier property_name) {
NPObjectAccessorWithIdentifier accessor(object, property_name, true);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
bool rv = accessor.object()->ppp_class()->HasProperty(
accessor.object()->ppp_class_data(), accessor.identifier(),
result_converter.exception());
result_converter.CheckExceptionForNoResult();
return rv;
}
bool WrapperClass_GetProperty(NPObject* object, NPIdentifier property_name,
NPVariant* result) {
NPObjectAccessorWithIdentifier accessor(object, property_name, true);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), result);
return result_converter.SetResult(accessor.object()->ppp_class()->GetProperty(
accessor.object()->ppp_class_data(), accessor.identifier(),
result_converter.exception()));
}
bool WrapperClass_SetProperty(NPObject* object, NPIdentifier property_name,
const NPVariant* value) {
NPObjectAccessorWithIdentifier accessor(object, property_name, true);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
PP_Var value_var = Var::NPVariantToPPVar(accessor.object()->module(), value);
accessor.object()->ppp_class()->SetProperty(
accessor.object()->ppp_class_data(), accessor.identifier(), value_var,
result_converter.exception());
Var::PluginReleasePPVar(value_var);
return result_converter.CheckExceptionForNoResult();
}
bool WrapperClass_RemoveProperty(NPObject* object, NPIdentifier property_name) {
NPObjectAccessorWithIdentifier accessor(object, property_name, true);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
accessor.object()->ppp_class()->RemoveProperty(
accessor.object()->ppp_class_data(), accessor.identifier(),
result_converter.exception());
return result_converter.CheckExceptionForNoResult();
}
bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values,
uint32_t* count) {
*values = NULL;
*count = 0;
PluginObject* obj = PluginObject::FromNPObject(object);
if (!obj)
return false;
uint32_t property_count = 0;
PP_Var* properties = NULL; // Must be freed!
PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), NULL);
obj->ppp_class()->GetAllPropertyNames(obj->ppp_class_data(),
&property_count, &properties,
result_converter.exception());
// Convert the array of PP_Var to an array of NPIdentifiers. If any
// conversions fail, we will set the exception.
if (!result_converter.has_exception()) {
if (property_count > 0) {
*values = static_cast<NPIdentifier*>(
malloc(sizeof(NPIdentifier) * property_count));
*count = 0; // Will be the number of items successfully converted.
for (uint32_t i = 0; i < property_count; ++i) {
if (!((*values)[i] = Var::PPVarToNPIdentifier(properties[i]))) {
// Throw an exception for the failed convertion.
*result_converter.exception() = StringVar::StringToPPVar(
obj->module(), kInvalidValueException);
break;
}
(*count)++;
}
if (result_converter.has_exception()) {
// We don't actually have to free the identifiers we converted since
// all identifiers leak anyway :( .
free(*values);
*values = NULL;
*count = 0;
}
}
}
// This will actually throw the exception, either from GetAllPropertyNames,
// or if anything was set during the conversion process.
result_converter.CheckExceptionForNoResult();
// Release the PP_Var that the plugin allocated. On success, they will all
// be converted to NPVariants, and on failure, we want them to just go away.
for (uint32_t i = 0; i < property_count; ++i)
Var::PluginReleasePPVar(properties[i]);
free(properties);
return result_converter.success();
}
bool WrapperClass_Construct(NPObject* object, const NPVariant* argv,
uint32_t argc, NPVariant* result) {
PluginObject* obj = PluginObject::FromNPObject(object);
if (!obj)
return false;
PPVarArrayFromNPVariantArray args(obj->module(), argc, argv);
PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), result);
return result_converter.SetResult(obj->ppp_class()->Construct(
obj->ppp_class_data(), argc, args.array(),
result_converter.exception()));
}
const NPClass wrapper_class = {
NP_CLASS_STRUCT_VERSION,
WrapperClass_Allocate,
WrapperClass_Deallocate,
WrapperClass_Invalidate,
WrapperClass_HasMethod,
WrapperClass_Invoke,
WrapperClass_InvokeDefault,
WrapperClass_HasProperty,
WrapperClass_GetProperty,
WrapperClass_SetProperty,
WrapperClass_RemoveProperty,
WrapperClass_Enumerate,
WrapperClass_Construct
};
} // namespace
// PluginObject ----------------------------------------------------------------
struct PluginObject::NPObjectWrapper : public NPObject {
// Points to the var object that owns this wrapper. This value may be NULL
// if there is no var owning this wrapper. This can happen if the plugin
// releases all references to the var, but a reference to the underlying
// NPObject is still held by script on the page.
PluginObject* obj;
};
PluginObject::PluginObject(PluginModule* module,
NPObjectWrapper* object_wrapper,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data)
: module_(module),
object_wrapper_(object_wrapper),
ppp_class_(ppp_class),
ppp_class_data_(ppp_class_data) {
// Make the object wrapper refer back to this class so our NPObject
// implementation can call back into the Pepper layer.
object_wrapper_->obj = this;
module_->AddPluginObject(this);
}
PluginObject::~PluginObject() {
// The wrapper we made for this NPObject may still have a reference to it
// from JavaScript, so we clear out its ObjectVar back pointer which will
// cause all calls "up" to the plugin to become NOPs. Our ObjectVar base
// class will release our reference to the object, which may or may not
// delete the NPObject.
DCHECK(object_wrapper_->obj == this);
object_wrapper_->obj = NULL;
module_->RemovePluginObject(this);
}
PP_Var PluginObject::Create(PluginModule* module,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data) {
// This will internally end up calling our AllocateObjectWrapper via the
// WrapperClass_Allocated function which will have created an object wrapper
// appropriate for this class (derived from NPObject).
NPObjectWrapper* wrapper = static_cast<NPObjectWrapper*>(
WebBindings::createObject(NULL, const_cast<NPClass*>(&wrapper_class)));
// This object will register itself both with the NPObject and with the
// PluginModule. The NPObject will normally handle its lifetime, and it
// will get deleted in the destroy method. It may also get deleted when the
// plugin module is deallocated.
new PluginObject(module, wrapper, ppp_class, ppp_class_data);
// We can just use a normal ObjectVar to refer to this object from the
// plugin. It will hold a ref to the underlying NPObject which will in turn
// hold our pluginObject.
return ObjectVar::NPObjectToPPVar(module, wrapper);
}
NPObject* PluginObject::GetNPObject() const {
return object_wrapper_;
}
// static
bool PluginObject::IsInstanceOf(NPObject* np_object,
const PPP_Class_Deprecated* ppp_class,
void** ppp_class_data) {
// Validate that this object is implemented by our wrapper class before
// trying to get the PluginObject.
if (np_object->_class != &wrapper_class)
return false;
PluginObject* plugin_object = FromNPObject(np_object);
if (!plugin_object)
return false; // Object is no longer alive.
if (plugin_object->ppp_class() != ppp_class)
return false;
if (ppp_class_data)
*ppp_class_data = plugin_object->ppp_class_data();
return true;
}
// static
PluginObject* PluginObject::FromNPObject(NPObject* object) {
return static_cast<NPObjectWrapper*>(object)->obj;
}
// static
NPObject* PluginObject::AllocateObjectWrapper() {
NPObjectWrapper* wrapper = new NPObjectWrapper;
memset(wrapper, 0, sizeof(NPObjectWrapper));
return wrapper;
}
// VarObjectClass::InstanceData -----------------------------------------------
struct VarObjectClass::InstanceData : public NPObject {
InstanceData() : native_data(NULL) {}
scoped_refptr<VarObjectClass> object_class;
void* native_data;
};
// VarObjectClass::Property ---------------------------------------------------
VarObjectClass::Property::Property(const PP_ClassProperty& prop)
: method(prop.method),
getter(prop.getter),
setter(prop.setter),
writable(!(prop.modifiers & PP_OBJECTPROPERTY_MODIFIER_READONLY)),
enumerable(!(prop.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTENUM)) {
}
// VarObjectAccessorWithIdentifier ---------------------------------------------
// Helper class for the new (PPB_Class) NPObject wrapper. This converts a call
// from WebKit where it gives us an NPObject and an NPIdentifier to an
// easily-accessible InstanceData (corresponding to the NPObject) and
// std::string and Property (corresponding to the NPIdentifier).
class VarObjectAccessorWithIdentifier {
public:
VarObjectAccessorWithIdentifier(NPObject* object, NPIdentifier identifier)
: exists_(false),
instance_(static_cast<VarObjectClass::InstanceData*>(object)),
property_(NULL) {
if (instance_) {
const NPUTF8* string_value = NULL;
int32_t int_value = 0;
bool is_string = false;
WebBindings::extractIdentifierData(identifier, string_value, int_value,
is_string);
if (is_string) {
property_name_ = string_value;
const VarObjectClass::PropertyMap& properties =
instance_->object_class->properties();
VarObjectClass::PropertyMap::const_iterator it =
properties.find(property_name_);
if (it != properties.end()) {
property_ = &it->second;
exists_ = true;
}
}
}
}
// Return true if the object is valid, the identifier is valid, and the
// property with said name exists.
bool exists() const { return exists_; }
bool is_method() const { return exists() && property_->method; }
bool is_readable() const { return exists() && property_->getter; }
bool is_writable() const {
return exists() && property_->setter && property_->writable;
}
const VarObjectClass::InstanceData* instance() const { return instance_; }
const VarObjectClass::Property* property() const { return property_; }
PluginModule* module() const {
return instance_ ? instance_->object_class->module() : NULL;
}
private:
bool exists_;
const VarObjectClass::InstanceData* instance_;
std::string property_name_;
const VarObjectClass::Property* property_;
DISALLOW_COPY_AND_ASSIGN(VarObjectAccessorWithIdentifier);
};
// NPObject implementation in terms of PPB_Class -------------------------------
namespace {
NPObject* VarObjectClassAllocate(NPP npp, NPClass* the_class) {
return new VarObjectClass::InstanceData;
}
void VarObjectClassDeallocate(NPObject* object) {
VarObjectClass::InstanceData* instance =
static_cast<VarObjectClass::InstanceData*>(object);
if (instance->object_class->instance_native_destructor())
instance->object_class->instance_native_destructor()(instance->native_data);
delete instance;
}
bool VarObjectClassHasMethod(NPObject* np_obj, NPIdentifier name) {
VarObjectAccessorWithIdentifier accessor(np_obj, name);
return accessor.is_method();
}
bool VarObjectClassInvoke(NPObject* np_obj, NPIdentifier name,
const NPVariant* args, uint32 arg_count,
NPVariant* result) {
VarObjectAccessorWithIdentifier accessor(np_obj, name);
if (!accessor.is_method())
return false;
PPResultAndExceptionToNPResult result_converter(np_obj, result);
PPVarArrayFromNPVariantArray arguments(accessor.module(), arg_count, args);
PPVarFromNPObject self(accessor.module(), np_obj);
return result_converter.SetResult(accessor.property()->method(
accessor.instance()->native_data, self.var(), arguments.array(), arg_count,
result_converter.exception()));
}
bool VarObjectClassInvokeDefault(NPObject* np_obj,
const NPVariant* args,
uint32 arg_count,
NPVariant* result) {
VarObjectClass::InstanceData* instance =
static_cast<VarObjectClass::InstanceData*>(np_obj);
if (!instance || !instance->object_class->instance_invoke())
return false;
PPResultAndExceptionToNPResult result_converter(np_obj, result);
PPVarArrayFromNPVariantArray arguments(instance->object_class->module(),
arg_count, args);
PPVarFromNPObject self(instance->object_class->module(), np_obj);
return result_converter.SetResult(instance->object_class->instance_invoke()(
instance->native_data, self.var(), arguments.array(), arg_count,
result_converter.exception()));
}
bool VarObjectClassHasProperty(NPObject* np_obj, NPIdentifier name) {
VarObjectAccessorWithIdentifier accessor(np_obj, name);
return accessor.is_readable();
}
bool VarObjectClassGetProperty(NPObject* np_obj, NPIdentifier name,
NPVariant* result) {
VarObjectAccessorWithIdentifier accessor(np_obj, name);
if (!accessor.is_readable()) {
return false;
}
PPResultAndExceptionToNPResult result_converter(np_obj, result);
PPVarFromNPObject self(accessor.module(), np_obj);
return result_converter.SetResult(accessor.property()->getter(
accessor.instance()->native_data, self.var(), 0, 0,
result_converter.exception()));
}
bool VarObjectClassSetProperty(NPObject* np_obj, NPIdentifier name,
const NPVariant* variant) {
VarObjectAccessorWithIdentifier accessor(np_obj, name);
if (!accessor.is_writable()) {
return false;
}
PPResultAndExceptionToNPResult result_converter(np_obj, NULL);
PPVarArrayFromNPVariantArray arguments(accessor.module(), 1, variant);
PPVarFromNPObject self(accessor.module(), np_obj);
// Ignore return value.
Var::PluginReleasePPVar(accessor.property()->setter(
accessor.instance()->native_data, self.var(), arguments.array(), 1,
result_converter.exception()));
return result_converter.CheckExceptionForNoResult();
}
bool VarObjectClassEnumerate(NPObject *np_obj, NPIdentifier **value,
uint32_t *count) {
VarObjectClass::InstanceData* instance =
static_cast<VarObjectClass::InstanceData*>(np_obj);
*count = 0;
*value = NULL;
if (!instance)
return false;
const VarObjectClass::PropertyMap& properties =
instance->object_class->properties();
// Don't bother calculating the size of enumerable properties, just allocate
// enough for all and then fill it partially.
*value = static_cast<NPIdentifier*>(
malloc(sizeof(NPIdentifier) * properties.size()));
NPIdentifier* inserter = *value;
for (VarObjectClass::PropertyMap::const_iterator i = properties.begin();
i != properties.end(); ++i)
if (i->second.enumerable)
*inserter++ = WebBindings::getStringIdentifier(i->first.c_str());
*count = inserter - *value;
return true;
}
NPClass objectclassvar_class = {
NP_CLASS_STRUCT_VERSION,
&VarObjectClassAllocate,
&VarObjectClassDeallocate,
NULL,
&VarObjectClassHasMethod,
&VarObjectClassInvoke,
&VarObjectClassInvokeDefault,
&VarObjectClassHasProperty,
&VarObjectClassGetProperty,
&VarObjectClassSetProperty,
NULL,
&VarObjectClassEnumerate,
};
// PPB_Class interface ---------------------------------------------------------
PP_Resource Create(PP_Module module, PP_ClassDestructor destruct,
PP_ClassFunction invoke, PP_ClassProperty* properties) {
PluginModule* plugin_module = ResourceTracker::Get()->GetModule(module);
if (!properties || !plugin_module)
return 0;
scoped_refptr<VarObjectClass> cls = new VarObjectClass(plugin_module,
destruct,
invoke,
properties);
if (!cls)
return 0;
return cls->GetReference();
}
PP_Var Instantiate(PP_Resource class_object, void* native_data,
PP_Var* exception) {
scoped_refptr<VarObjectClass> object_class =
Resource::GetAs<VarObjectClass>(class_object);
if (!object_class)
return PP_MakeUndefined();
NPObject* obj = WebBindings::createObject(NULL, &objectclassvar_class);
VarObjectClass::InstanceData* instance_data =
static_cast<VarObjectClass::InstanceData*>(obj);
instance_data->object_class = object_class;
instance_data->native_data = native_data;
return ObjectVar::NPObjectToPPVar(object_class->module(), obj);
}
} // namespace
// VarObjectClass --------------------------------------------------------------
VarObjectClass::VarObjectClass(PluginModule* module,
PP_ClassDestructor destruct,
PP_ClassFunction invoke,
PP_ClassProperty* properties)
: Resource(module),
instance_native_destructor_(destruct),
instance_invoke_(invoke) {
PP_ClassProperty* prop = properties;
while (prop->name) {
properties_.insert(std::make_pair(std::string(prop->name),
Property(*prop)));
++prop;
}
}
// static
const PPB_Class* VarObjectClass::GetInterface() {
static PPB_Class interface = {
&Create,
&Instantiate
};
return &interface;
}
// virtual
VarObjectClass::~VarObjectClass() { }
VarObjectClass* VarObjectClass::AsVarObjectClass() {
return this;
}
} // namespace pepper

@ -1,23 +0,0 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PRIVATE_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_PRIVATE_H_
#include "webkit/glue/plugins/pepper_resource.h"
struct PPB_Private;
namespace pepper {
class Private {
public:
// Returns a pointer to the interface implementing PPB_Private that is exposed
// to the plugin.
static const PPB_Private* GetInterface();
};
} // namespace pepper
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_PRIVATE_H_

@ -1,33 +0,0 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_TRANSPORT_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_TRANSPORT_H_
#include "base/scoped_ptr.h"
#include "ppapi/c/pp_instance.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_resource.h"
struct PPB_Transport_Dev;
namespace pepper {
class Transport : public Resource {
public:
explicit Transport(PluginModule* module);
virtual ~Transport();
static const PPB_Transport_Dev* GetInterface();
virtual Transport* AsTransport();
bool Init(const char* name,
const char* proto);
private:
DISALLOW_COPY_AND_ASSIGN(Transport);
};
} // namespace pepper
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_TRANSPORT_H_

@ -1,19 +0,0 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_URL_UTIL_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_URL_UTIL_H_
struct PPB_UrlUtil_Dev;
namespace pepper {
class UrlUtil {
public:
static const PPB_UrlUtil_Dev* GetInterface();
};
} // namespace pepper
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_URL_UTIL_H_

@ -17,8 +17,8 @@
#include "net/base/mime_util.h"
#include "webkit/glue/plugins/plugin_constants_win.h"
#include "webkit/glue/plugins/plugin_lib.h"
#include "webkit/glue/plugins/plugin_switches.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/plugins/plugin_switches.h"
#if defined(OS_POSIX)
#include "base/stl_util-inl.h"

@ -168,6 +168,88 @@
# This list contains all .h, .cc, and .mm files in glue except for
# those in the test subdirectory and those with unittest in in their
# names.
'../plugins/plugin_switches.cc',
'../plugins/plugin_switches.h',
'../plugins/ppapi/common.h',
'../plugins/ppapi/dir_contents.h',
'../plugins/ppapi/error_util.cc',
'../plugins/ppapi/error_util.h',
'../plugins/ppapi/event_conversion.cc',
'../plugins/ppapi/event_conversion.h',
'../plugins/ppapi/file_callbacks.cc',
'../plugins/ppapi/file_callbacks.h',
'../plugins/ppapi/fullscreen_container.h',
'../plugins/ppapi/npapi_glue.cc',
'../plugins/ppapi/npapi_glue.h',
'../plugins/ppapi/plugin_delegate.h',
'../plugins/ppapi/ppapi_plugin_instance.cc',
'../plugins/ppapi/ppapi_plugin_instance.h',
'../plugins/ppapi/ppapi_webplugin_impl.cc',
'../plugins/ppapi/ppapi_webplugin_impl.h',
'../plugins/ppapi/plugin_module.cc',
'../plugins/ppapi/plugin_module.h',
'../plugins/ppapi/plugin_object.cc',
'../plugins/ppapi/plugin_object.h',
'../plugins/ppapi/ppb_audio_impl.cc',
'../plugins/ppapi/ppb_audio_impl.h',
'../plugins/ppapi/ppb_buffer_impl.cc',
'../plugins/ppapi/ppb_buffer_impl.h',
'../plugins/ppapi/ppb_char_set_impl.cc',
'../plugins/ppapi/ppb_char_set_impl.h',
'../plugins/ppapi/ppb_cursor_control_impl.cc',
'../plugins/ppapi/ppb_cursor_control_impl.h',
'../plugins/ppapi/ppb_directory_reader_impl.cc',
'../plugins/ppapi/ppb_directory_reader_impl.h',
'../plugins/ppapi/ppb_file_chooser_impl.cc',
'../plugins/ppapi/ppb_file_chooser_impl.h',
'../plugins/ppapi/ppb_file_io_impl.cc',
'../plugins/ppapi/ppb_file_io_impl.h',
'../plugins/ppapi/ppb_file_ref_impl.cc',
'../plugins/ppapi/ppb_file_ref_impl.h',
'../plugins/ppapi/ppb_file_system_impl.cc',
'../plugins/ppapi/ppb_file_system_impl.h',
'../plugins/ppapi/ppb_flash.h',
'../plugins/ppapi/ppb_flash_impl.cc',
'../plugins/ppapi/ppb_flash_impl.h',
'../plugins/ppapi/ppb_flash_impl_linux.cc',
'../plugins/ppapi/ppb_font_impl.cc',
'../plugins/ppapi/ppb_font_impl.h',
'../plugins/ppapi/ppb_graphics_2d_impl.cc',
'../plugins/ppapi/ppb_graphics_2d_impl.h',
'../plugins/ppapi/ppb_graphics_3d_impl.cc',
'../plugins/ppapi/ppb_graphics_3d_impl.h',
'../plugins/ppapi/ppb_image_data_impl.cc',
'../plugins/ppapi/ppb_image_data_impl.h',
'../plugins/ppapi/ppb_open_gl_es_impl.cc',
'../plugins/ppapi/ppb_pdf.h',
'../plugins/ppapi/ppb_pdf_impl.cc',
'../plugins/ppapi/ppb_pdf_impl.h',
'../plugins/ppapi/ppb_scrollbar_impl.cc',
'../plugins/ppapi/ppb_scrollbar_impl.h',
'../plugins/ppapi/ppb_transport_impl.cc',
'../plugins/ppapi/ppb_transport_impl.h',
'../plugins/ppapi/ppb_url_loader_impl.cc',
'../plugins/ppapi/ppb_url_loader_impl.h',
'../plugins/ppapi/ppb_url_request_info_impl.cc',
'../plugins/ppapi/ppb_url_request_info_impl.h',
'../plugins/ppapi/ppb_url_response_info_impl.cc',
'../plugins/ppapi/ppb_url_response_info_impl.h',
'../plugins/ppapi/ppb_url_util_impl.cc',
'../plugins/ppapi/ppb_url_util_impl.h',
'../plugins/ppapi/ppb_video_decoder_impl.cc',
'../plugins/ppapi/ppb_video_decoder_impl.h',
'../plugins/ppapi/ppb_widget_impl.cc',
'../plugins/ppapi/ppb_widget_impl.h',
'../plugins/ppapi/resource.cc',
'../plugins/ppapi/resource.h',
'../plugins/ppapi/resource_tracker.cc',
'../plugins/ppapi/resource_tracker.h',
'../plugins/ppapi/string.cc',
'../plugins/ppapi/string.h',
'../plugins/ppapi/var.cc',
'../plugins/ppapi/var.h',
'../plugins/ppapi/var_object_class.cc',
'../plugins/ppapi/var_object_class.h',
'media/buffered_data_source.cc',
'media/buffered_data_source.h',
'media/media_resource_loader_bridge_factory.cc',
@ -190,75 +272,6 @@
'plugins/gtk_plugin_container_manager.cc',
'plugins/npapi_extension_thunk.cc',
'plugins/npapi_extension_thunk.h',
'plugins/pepper_audio.cc',
'plugins/pepper_audio.h',
'plugins/pepper_buffer.cc',
'plugins/pepper_buffer.h',
'plugins/pepper_char_set.cc',
'plugins/pepper_char_set.h',
'plugins/pepper_class.h',
'plugins/pepper_cursor_control.cc',
'plugins/pepper_cursor_control.h',
'plugins/pepper_directory_reader.cc',
'plugins/pepper_directory_reader.h',
'plugins/pepper_error_util.cc',
'plugins/pepper_error_util.h',
'plugins/pepper_event_conversion.cc',
'plugins/pepper_event_conversion.h',
'plugins/pepper_file_callbacks.cc',
'plugins/pepper_file_callbacks.h',
'plugins/pepper_file_chooser.cc',
'plugins/pepper_file_chooser.h',
'plugins/pepper_file_io.cc',
'plugins/pepper_file_io.h',
'plugins/pepper_file_ref.cc',
'plugins/pepper_file_ref.h',
'plugins/pepper_file_system.cc',
'plugins/pepper_file_system.h',
'plugins/pepper_font.cc',
'plugins/pepper_font.h',
'plugins/pepper_graphics_2d.cc',
'plugins/pepper_graphics_2d.h',
'plugins/pepper_image_data.cc',
'plugins/pepper_image_data.h',
'plugins/pepper_plugin_delegate.h',
'plugins/pepper_plugin_instance.cc',
'plugins/pepper_plugin_instance.h',
'plugins/pepper_plugin_module.cc',
'plugins/pepper_plugin_module.h',
'plugins/pepper_plugin_object.cc',
'plugins/pepper_plugin_object.h',
'plugins/pepper_private.cc',
'plugins/pepper_private.h',
'plugins/pepper_private2.cc',
'plugins/pepper_private2.h',
'plugins/pepper_private2_linux.cc',
'plugins/pepper_resource_tracker.cc',
'plugins/pepper_resource_tracker.h',
'plugins/pepper_resource.cc',
'plugins/pepper_resource.h',
'plugins/pepper_scrollbar.cc',
'plugins/pepper_scrollbar.h',
'plugins/pepper_string.cc',
'plugins/pepper_string.h',
'plugins/pepper_transport.cc',
'plugins/pepper_transport.h',
'plugins/pepper_url_loader.cc',
'plugins/pepper_url_loader.h',
'plugins/pepper_url_request_info.cc',
'plugins/pepper_url_request_info.h',
'plugins/pepper_url_response_info.cc',
'plugins/pepper_url_response_info.h',
'plugins/pepper_url_util.cc',
'plugins/pepper_url_util.h',
'plugins/pepper_var.cc',
'plugins/pepper_var.h',
'plugins/pepper_video_decoder.cc',
'plugins/pepper_video_decoder.h',
'plugins/pepper_webplugin_impl.cc',
'plugins/pepper_webplugin_impl.h',
'plugins/pepper_widget.cc',
'plugins/pepper_widget.h',
'plugins/plugin_constants_win.h',
'plugins/plugin_group.cc',
'plugins/plugin_group.h',
@ -286,8 +299,6 @@
'plugins/plugin_string_stream.cc',
'plugins/plugin_string_stream.h',
'plugins/plugin_stubs.cc',
'plugins/plugin_switches.cc',
'plugins/plugin_switches.h',
'plugins/plugin_web_event_converter_mac.h',
'plugins/plugin_web_event_converter_mac.mm',
'plugins/ppb_private.h',
@ -449,12 +460,14 @@
],
},
}],
['enable_gpu==1', {
'sources': [
'plugins/pepper_graphics_3d_gl.cc',
'plugins/pepper_graphics_3d.cc',
'plugins/pepper_graphics_3d.h',
['enable_gpu!=1', {
'sources!': [
'../plugins/ppapi/ppb_graphics_3d_impl.cc',
'../plugins/ppapi/ppb_graphics_3d_impl.h',
'../plugins/ppapi/ppb_open_gl_es_impl.cc',
],
}],
['enable_gpu==1', {
'dependencies': [
'<(DEPTH)/gpu/gpu.gyp:gpu_plugin',
],

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/plugin_switches.h"
#include "webkit/plugins/plugin_switches.h"
namespace switches {

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PLUGIN_SWITCHES_H_
#define WEBKIT_GLUE_PLUGINS_PLUGIN_SWITCHES_H_
#ifndef WEBKIT_PLUGINS_PLUGIN_SWITCHES_H_
#define WEBKIT_PLUGINS_PLUGIN_SWITCHES_H_
namespace switches {
@ -12,4 +12,4 @@ extern const char kEnablePepperTesting[];
} // namespace switches
#endif // WEBKIT_GLUE_PLUGINS_PLUGIN_SWITCHES_H_
#endif // WEBKIT_PLUGINS_PLUGIN_SWITCHES_H_

@ -0,0 +1,8 @@
include_rules = [
"+app",
"+gpu/command_buffer",
"+ppapi/c",
"+ppapi/shared_impl",
"+printing",
"+skia",
]

@ -2,13 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_COMMON_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_COMMON_H_
#ifndef WEBKIT_PLUGINS_PPAPI_COMMON_H_
#define WEBKIT_PLUGINS_PPAPI_COMMON_H_
#include "ppapi/c/pp_bool.h"
#include "ppapi/c/pp_var.h"
namespace pepper {
namespace webkit {
namespace ppapi {
inline PP_Bool BoolToPPBool(bool value) {
return value ? PP_TRUE : PP_FALSE;
@ -18,7 +19,8 @@ inline bool PPBoolToBool(PP_Bool value) {
return (PP_TRUE == value);
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_COMMON_H_
#endif // WEBKIT_PLUGINS_PPAPI_COMMON_H_

@ -0,0 +1,25 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_PLUGINS_PPAPI_DIR_CONTENTS_H_
#define WEBKIT_PLUGINS_PPAPI_DIR_CONTENTS_H_
#include <vector>
#include "base/file_path.h"
namespace webkit {
namespace ppapi {
struct DirEntry {
FilePath name;
bool is_dir;
};
typedef std::vector<DirEntry> DirContents;
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_PLUGINS_PPAPI_DIR_CONTENTS_H_

@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_error_util.h"
#include "webkit/plugins/ppapi/error_util.h"
#include "ppapi/c/pp_errors.h"
namespace pepper {
namespace webkit {
namespace ppapi {
int PlatformFileErrorToPepperError(base::PlatformFileError error_code) {
switch (error_code) {
@ -30,4 +31,6 @@ int PlatformFileErrorToPepperError(base::PlatformFileError error_code) {
}
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_ERROR_UTIL_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_ERROR_UTIL_H_
#ifndef WEBKIT_PLUGINS_PPAPI_ERROR_UTIL_H_
#define WEBKIT_PLUGINS_PPAPI_ERROR_UTIL_H_
#include "base/platform_file.h"
namespace pepper {
namespace webkit {
namespace ppapi {
int PlatformFileErrorToPepperError(base::PlatformFileError error_code);
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_ERROR_UTIL_H_
#endif // WEBKIT_PLUGINS_PPAPI_ERROR_UTIL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_event_conversion.h"
#include "webkit/plugins/ppapi/event_conversion.h"
#include "base/i18n/char_iterator.h"
#include "base/logging.h"
@ -12,13 +12,16 @@
#include "base/utf_string_conversion_utils.h"
#include "ppapi/c/pp_input_event.h"
#include "third_party/WebKit/WebKit/chromium/public/WebInputEvent.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/plugins/ppapi/common.h"
using WebKit::WebInputEvent;
using WebKit::WebKeyboardEvent;
using WebKit::WebMouseEvent;
using WebKit::WebMouseWheelEvent;
namespace webkit {
namespace ppapi {
namespace {
PP_InputEvent_Type ConvertEventTypes(WebInputEvent::Type wetype) {
@ -144,11 +147,10 @@ void AppendMouseWheelEvent(const WebInputEvent& event,
result.u.wheel.wheel_ticks_x = mouse_wheel_event.wheelTicksX;
result.u.wheel.wheel_ticks_y = mouse_wheel_event.wheelTicksY;
result.u.wheel.scroll_by_page =
pepper::BoolToPPBool(!!mouse_wheel_event.scrollByPage);
BoolToPPBool(!!mouse_wheel_event.scrollByPage);
pp_events->push_back(result);
}
WebKeyboardEvent* BuildKeyEvent(const PP_InputEvent& event) {
WebKeyboardEvent* key_event = new WebKeyboardEvent();
switch (event.type) {
@ -239,8 +241,6 @@ WebMouseWheelEvent* BuildMouseWheelEvent(const PP_InputEvent& event) {
} // namespace
namespace pepper {
void CreatePPEvent(const WebInputEvent& event,
std::vector<PP_InputEvent>* pp_events) {
pp_events->clear();
@ -297,5 +297,6 @@ WebInputEvent* CreateWebInputEvent(const PP_InputEvent& event) {
return web_input_event.release();
}
} // namespace ppapi
} // namespace webkit
} // namespace pepper

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_EVENT_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_EVENT_H_
#ifndef WEBKIT_PLUGINS_PPAPI_EVENT_CONVERSION_H_
#define WEBKIT_PLUGINS_PPAPI_EVENT_CONVERSION_H_
#include <vector>
@ -13,7 +13,8 @@ namespace WebKit {
class WebInputEvent;
}
namespace pepper {
namespace webkit {
namespace ppapi {
// Converts the given WebKit event to one or possibly multiple PP_InputEvents.
// The generated events will be filled into the given vector. On failure, no
@ -25,6 +26,7 @@ void CreatePPEvent(const WebKit::WebInputEvent& event,
// NULL. The caller owns the created object on success.
WebKit::WebInputEvent* CreateWebInputEvent(const PP_InputEvent& event);
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_EVENT_H_
#endif // WEBKIT_PLUGINS_PPAPI_EVENT_CONVERSION_H_

@ -2,25 +2,27 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_file_callbacks.h"
#include "webkit/plugins/ppapi/file_callbacks.h"
#include "base/file_path.h"
#include "base/logging.h"
#include "ppapi/c/dev/ppb_file_system_dev.h"
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/pp_errors.h"
#include "webkit/glue/plugins/pepper_directory_reader.h"
#include "webkit/glue/plugins/pepper_error_util.h"
#include "webkit/glue/plugins/pepper_file_system.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/error_util.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/fileapi/file_system_types.h"
namespace pepper {
namespace webkit {
namespace ppapi {
FileCallbacks::FileCallbacks(const base::WeakPtr<PluginModule>& module,
PP_CompletionCallback callback,
PP_FileInfo_Dev* info,
scoped_refptr<FileSystem> file_system,
scoped_refptr<DirectoryReader> directory_reader)
FileCallbacks::FileCallbacks(
const base::WeakPtr<PluginModule>& module,
PP_CompletionCallback callback,
PP_FileInfo_Dev* info,
scoped_refptr<PPB_FileSystem_Impl> file_system,
scoped_refptr<PPB_DirectoryReader_Impl> directory_reader)
: module_(module),
callback_(callback),
info_(info),
@ -93,7 +95,9 @@ void FileCallbacks::RunCallback(base::PlatformFileError error_code) {
return;
PP_RunCompletionCallback(
&callback_, pepper::PlatformFileErrorToPepperError(error_code));
&callback_, PlatformFileErrorToPepperError(error_code));
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FILE_CALLBACKS_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_FILE_CALLBACKS_H_
#ifndef WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_
#define WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_
#include "base/platform_file.h"
#include "base/weak_ptr.h"
@ -16,10 +16,11 @@ namespace base {
class FilePath;
}
namespace pepper {
namespace webkit {
namespace ppapi {
class DirectoryReader;
class FileSystem;
class PPB_DirectoryReader_Impl;
class PPB_FileSystem_Impl;
class PluginModule;
// Instances of this class are deleted by FileSystemDispatcher.
@ -28,8 +29,8 @@ class FileCallbacks : public fileapi::FileSystemCallbackDispatcher {
FileCallbacks(const base::WeakPtr<PluginModule>& module,
PP_CompletionCallback callback,
PP_FileInfo_Dev* info,
scoped_refptr<FileSystem> file_system,
scoped_refptr<DirectoryReader> directory_reader);
scoped_refptr<PPB_FileSystem_Impl> file_system,
scoped_refptr<PPB_DirectoryReader_Impl> directory_reader);
virtual ~FileCallbacks();
// FileSystemCallbackDispatcher implementation.
@ -48,10 +49,11 @@ class FileCallbacks : public fileapi::FileSystemCallbackDispatcher {
base::WeakPtr<PluginModule> module_;
PP_CompletionCallback callback_;
PP_FileInfo_Dev* info_;
scoped_refptr<FileSystem> file_system_;
scoped_refptr<DirectoryReader> directory_reader_;
scoped_refptr<PPB_FileSystem_Impl> file_system_;
scoped_refptr<PPB_DirectoryReader_Impl> directory_reader_;
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FILE_CALLBACKS_H_
#endif // WEBKIT_PLUGINS_PPAPI_FILE_CALLBACKS_H_

@ -2,16 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FULLSCREEN_CONTAINER_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_FULLSCREEN_CONTAINER_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_FULLSCREEN_CONTAINER_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_FULLSCREEN_CONTAINER_IMPL_H_
namespace WebKit {
struct WebRect;
} // namespace WebKit
namespace pepper {
namespace webkit {
namespace ppapi {
// This class is like a lightweight WebPluginContainer for fullscreen pepper
// This class is like a lightweight WebPluginContainer for fullscreen PPAPI
// plugins, that only handles painting.
class FullscreenContainer {
public:
@ -31,6 +32,7 @@ class FullscreenContainer {
virtual void Destroy() = 0;
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FULLSCREEN_CONTAINER_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_FULLSCREEN_CONTAINER_IMPL_H_

@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/mock_plugin_delegate.h"
#include "webkit/plugins/ppapi/mock_plugin_delegate.h"
#include "base/message_loop_proxy.h"
namespace pepper {
namespace webkit {
namespace ppapi {
MockPluginDelegate::MockPluginDelegate() {
}
@ -14,10 +15,10 @@ MockPluginDelegate::MockPluginDelegate() {
MockPluginDelegate::~MockPluginDelegate() {
}
void MockPluginDelegate::InstanceCreated(pepper::PluginInstance* instance) {
void MockPluginDelegate::InstanceCreated(PluginInstance* instance) {
}
void MockPluginDelegate::InstanceDeleted(pepper::PluginInstance* instance) {
void MockPluginDelegate::InstanceDeleted(PluginInstance* instance) {
}
MockPluginDelegate::PlatformImage2D* MockPluginDelegate::CreateImage2D(
@ -149,7 +150,7 @@ base::PlatformFileError MockPluginDelegate::QueryModuleLocalFile(
base::PlatformFileError MockPluginDelegate::GetModuleLocalDirContents(
const std::string& module_name,
const FilePath& path,
PepperDirContents* contents) {
DirContents* contents) {
return base::PLATFORM_FILE_ERROR_FAILED;
}
@ -184,4 +185,6 @@ void MockPluginDelegate::DidStopLoading() {
void MockPluginDelegate::SetContentRestriction(int restrictions) {
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,20 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_MOCK_PLUGIN_DELEGATE_H_
#define WEBKIT_GLUE_PLUGINS_MOCK_PLUGIN_DELEGATE_H_
#ifndef WEBKIT_PLUGINS_PPAPI_MOCK_PLUGIN_DELEGATE_H_
#define WEBKIT_PLUGINS_PPAPI_MOCK_PLUGIN_DELEGATE_H_
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
namespace pepper {
namespace webkit {
namespace ppapi {
class MockPluginDelegate : public PluginDelegate {
public:
MockPluginDelegate();
~MockPluginDelegate();
virtual void InstanceCreated(pepper::PluginInstance* instance);
virtual void InstanceDeleted(pepper::PluginInstance* instance);
virtual void InstanceCreated(PluginInstance* instance);
virtual void InstanceDeleted(PluginInstance* instance);
virtual PlatformImage2D* CreateImage2D(int width, int height);
virtual PlatformContext3D* CreateContext3D();
virtual PlatformVideoDecoder* CreateVideoDecoder(
@ -79,7 +80,7 @@ class MockPluginDelegate : public PluginDelegate {
virtual base::PlatformFileError GetModuleLocalDirContents(
const std::string& module_name,
const FilePath& path,
PepperDirContents* contents);
DirContents* contents);
virtual scoped_refptr<base::MessageLoopProxy>
GetFileThreadMessageLoopProxy();
virtual FullscreenContainer* CreateFullscreenContainer(
@ -93,6 +94,7 @@ class MockPluginDelegate : public PluginDelegate {
virtual void SetContentRestriction(int restrictions);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_MOCK_PLUGIN_DELEGATE_H_
#endif // WEBKIT_PLUGINS_PPAPI_MOCK_PLUGIN_DELEGATE_H_

@ -2,12 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_MOCK_RESOURCE_H_
#define WEBKIT_GLUE_PLUGINS_MOCK_RESOURCE_H_
#ifndef WEBKIT_PLUGINS_PPAPI_MOCK_RESOURCE_H_
#define WEBKIT_PLUGINS_PPAPI_MOCK_RESOURCE_H_
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/resource.h"
namespace pepper {
namespace webkit {
namespace ppapi {
// Tests can derive from this to implement special test-specific resources.
// It's assumed that a test will only need one mock resource, so it can
@ -20,6 +21,7 @@ class MockResource : public Resource {
virtual MockResource* AsMockResource() { return this; }
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_MOCK_RESOURCE_H_
#endif // WEBKIT_PLUGINS_PPAPI_MOCK_RESOURCE_H_

@ -0,0 +1,199 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/plugins/ppapi/npapi_glue.h"
#include "base/logging.h"
#include "base/ref_counted.h"
#include "base/string_util.h"
#include "webkit/plugins/ppapi/plugin_object.h"
#include "webkit/plugins/ppapi/var.h"
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npruntime.h"
#include "third_party/WebKit/WebKit/chromium/public/WebBindings.h"
using WebKit::WebBindings;
namespace webkit {
namespace ppapi {
namespace {
const char kInvalidPluginValue[] = "Error: Plugin returned invalid value.";
} // namespace
// Utilities -------------------------------------------------------------------
bool PPVarToNPVariant(PP_Var var, NPVariant* result) {
switch (var.type) {
case PP_VARTYPE_UNDEFINED:
VOID_TO_NPVARIANT(*result);
break;
case PP_VARTYPE_NULL:
NULL_TO_NPVARIANT(*result);
break;
case PP_VARTYPE_BOOL:
BOOLEAN_TO_NPVARIANT(var.value.as_bool, *result);
break;
case PP_VARTYPE_INT32:
INT32_TO_NPVARIANT(var.value.as_int, *result);
break;
case PP_VARTYPE_DOUBLE:
DOUBLE_TO_NPVARIANT(var.value.as_double, *result);
break;
case PP_VARTYPE_STRING: {
scoped_refptr<StringVar> string(StringVar::FromPPVar(var));
if (!string) {
VOID_TO_NPVARIANT(*result);
return false;
}
const std::string& value = string->value();
STRINGN_TO_NPVARIANT(base::strdup(value.c_str()), value.size(), *result);
break;
}
case PP_VARTYPE_OBJECT: {
scoped_refptr<ObjectVar> object(ObjectVar::FromPPVar(var));
if (!object) {
VOID_TO_NPVARIANT(*result);
return false;
}
OBJECT_TO_NPVARIANT(WebBindings::retainObject(object->np_object()),
*result);
break;
}
}
return true;
}
// PPResultAndExceptionToNPResult ----------------------------------------------
PPResultAndExceptionToNPResult::PPResultAndExceptionToNPResult(
NPObject* object_var,
NPVariant* np_result)
: object_var_(object_var),
np_result_(np_result),
exception_(PP_MakeUndefined()),
success_(false),
checked_exception_(false) {
}
PPResultAndExceptionToNPResult::~PPResultAndExceptionToNPResult() {
// The user should have called SetResult or CheckExceptionForNoResult
// before letting this class go out of scope, or the exception will have
// been lost.
DCHECK(checked_exception_);
ObjectVar::PluginReleasePPVar(exception_);
}
// Call this with the return value of the PPAPI function. It will convert
// the result to the NPVariant output parameter and pass any exception on to
// the JS engine. It will update the success flag and return it.
bool PPResultAndExceptionToNPResult::SetResult(PP_Var result) {
DCHECK(!checked_exception_); // Don't call more than once.
DCHECK(np_result_); // Should be expecting a result.
checked_exception_ = true;
if (has_exception()) {
ThrowException();
success_ = false;
} else if (!PPVarToNPVariant(result, np_result_)) {
WebBindings::setException(object_var_, kInvalidPluginValue);
success_ = false;
} else {
success_ = true;
}
// No matter what happened, we need to release the reference to the
// value passed in. On success, a reference to this value will be in
// the np_result_.
Var::PluginReleasePPVar(result);
return success_;
}
// Call this after calling a PPAPI function that could have set the
// exception. It will pass the exception on to the JS engine and update
// the success flag.
//
// The success flag will be returned.
bool PPResultAndExceptionToNPResult::CheckExceptionForNoResult() {
DCHECK(!checked_exception_); // Don't call more than once.
DCHECK(!np_result_); // Can't have a result when doing this.
checked_exception_ = true;
if (has_exception()) {
ThrowException();
success_ = false;
return false;
}
success_ = true;
return true;
}
// Call this to ignore any exception. This prevents the DCHECK from failing
// in the destructor.
void PPResultAndExceptionToNPResult::IgnoreException() {
checked_exception_ = true;
}
// Throws the current exception to JS. The exception must be set.
void PPResultAndExceptionToNPResult::ThrowException() {
scoped_refptr<StringVar> string(StringVar::FromPPVar(exception_));
if (string) {
WebBindings::setException(object_var_, string->value().c_str());
}
}
// PPVarArrayFromNPVariantArray ------------------------------------------------
PPVarArrayFromNPVariantArray::PPVarArrayFromNPVariantArray(PluginModule* module,
size_t size,
const NPVariant* variants)
: size_(size) {
if (size_ > 0) {
array_.reset(new PP_Var[size_]);
for (size_t i = 0; i < size_; i++)
array_[i] = Var::NPVariantToPPVar(module, &variants[i]);
}
}
PPVarArrayFromNPVariantArray::~PPVarArrayFromNPVariantArray() {
for (size_t i = 0; i < size_; i++)
Var::PluginReleasePPVar(array_[i]);
}
// PPVarFromNPObject -----------------------------------------------------------
PPVarFromNPObject::PPVarFromNPObject(PluginModule* module, NPObject* object)
: var_(ObjectVar::NPObjectToPPVar(module, object)) {
}
PPVarFromNPObject::~PPVarFromNPObject() {
Var::PluginReleasePPVar(var_);
}
// NPObjectAccessorWithIdentifier ----------------------------------------------
NPObjectAccessorWithIdentifier::NPObjectAccessorWithIdentifier(
NPObject* object,
NPIdentifier identifier,
bool allow_integer_identifier)
: object_(PluginObject::FromNPObject(object)),
identifier_(PP_MakeUndefined()) {
if (object_) {
identifier_ = Var::NPIdentifierToPPVar(object_->module(), identifier);
if (identifier_.type == PP_VARTYPE_INT32 && !allow_integer_identifier)
identifier_.type = PP_VARTYPE_UNDEFINED; // Mark it invalid.
}
}
NPObjectAccessorWithIdentifier::~NPObjectAccessorWithIdentifier() {
Var::PluginReleasePPVar(identifier_);
}
} // namespace ppapi
} // namespace webkit

@ -0,0 +1,188 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_
#define WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "ppapi/c/pp_var.h"
struct NPObject;
typedef struct _NPVariant NPVariant;
typedef void* NPIdentifier;
namespace webkit {
namespace ppapi {
class PluginModule;
class PluginObject;
// Utilities -------------------------------------------------------------------
// Converts the given PP_Var to an NPVariant, returning true on success.
// False means that the given variant is invalid. In this case, the result
// NPVariant will be set to a void one.
//
// The contents of the PP_Var will be copied unless the PP_Var corresponds to
// an object.
bool PPVarToNPVariant(PP_Var var, NPVariant* result);
// PPResultAndExceptionToNPResult ----------------------------------------------
// Convenience object for converting a PPAPI call that can throw an exception
// and optionally return a value, back to the NPAPI layer which expects a
// NPVariant as a result.
//
// Normal usage is that you will pass the result of exception() to the
// PPAPI function as the exception output parameter. Then you will either
// call SetResult with the result of the PPAPI call, or
// CheckExceptionForNoResult if the PPAPI call doesn't return a PP_Var.
//
// Both SetResult and CheckExceptionForNoResult will throw an exception to
// the JavaScript library if the plugin reported an exception. SetResult
// will additionally convert the result to an NPVariant and write it to the
// output parameter given in the constructor.
class PPResultAndExceptionToNPResult {
public:
// The object_var parameter is the object to associate any exception with.
// It may not be NULL.
//
// The np_result parameter is the NPAPI result output parameter. This may be
// NULL if there is no NPVariant result (like for HasProperty). If this is
// specified, you must call SetResult() to set it. If it is not, you must
// call CheckExceptionForNoResult to do the exception checking with no result
// conversion.
PPResultAndExceptionToNPResult(NPObject* object_var, NPVariant* np_result);
~PPResultAndExceptionToNPResult();
// Returns true if an exception has been set.
bool has_exception() const { return exception_.type != PP_VARTYPE_UNDEFINED; }
// Returns a pointer to the exception. You would pass this to the PPAPI
// function as the exception parameter. If it is set to non-void, this object
// will take ownership of destroying it.
PP_Var* exception() { return &exception_; }
// Returns true if everything succeeded with no exception. This is valid only
// after calling SetResult/CheckExceptionForNoResult.
bool success() const {
return success_;
}
// Call this with the return value of the PPAPI function. It will convert
// the result to the NPVariant output parameter and pass any exception on to
// the JS engine. It will update the success flag and return it.
bool SetResult(PP_Var result);
// Call this after calling a PPAPI function that could have set the
// exception. It will pass the exception on to the JS engine and update
// the success flag.
//
// The success flag will be returned.
bool CheckExceptionForNoResult();
// Call this to ignore any exception. This prevents the DCHECK from failing
// in the destructor.
void IgnoreException();
private:
// Throws the current exception to JS. The exception must be set.
void ThrowException();
NPObject* object_var_; // Non-owning ref (see constructor).
NPVariant* np_result_; // Output value, possibly NULL (see constructor).
PP_Var exception_; // Exception set by the PPAPI call. We own a ref to it.
bool success_; // See the success() function above.
bool checked_exception_; // SetResult/CheckExceptionForNoResult was called.
DISALLOW_COPY_AND_ASSIGN(PPResultAndExceptionToNPResult);
};
// PPVarArrayFromNPVariantArray ------------------------------------------------
// Converts an array of NPVariants to an array of PP_Var, and scopes the
// ownership of the PP_Var. This is used when converting argument lists from
// WebKit to the plugin.
class PPVarArrayFromNPVariantArray {
public:
PPVarArrayFromNPVariantArray(PluginModule* module,
size_t size,
const NPVariant* variants);
~PPVarArrayFromNPVariantArray();
PP_Var* array() { return array_.get(); }
private:
size_t size_;
scoped_array<PP_Var> array_;
DISALLOW_COPY_AND_ASSIGN(PPVarArrayFromNPVariantArray);
};
// PPVarFromNPObject -----------------------------------------------------------
// Converts an NPObject tp PP_Var, and scopes the ownership of the PP_Var. This
// is used when converting 'this' pointer from WebKit to the plugin.
class PPVarFromNPObject {
public:
PPVarFromNPObject(PluginModule* module, NPObject* object);
~PPVarFromNPObject();
PP_Var var() const { return var_; }
private:
const PP_Var var_;
DISALLOW_COPY_AND_ASSIGN(PPVarFromNPObject);
};
// NPObjectAccessorWithIdentifier ----------------------------------------------
// Helper class for our NPObject wrapper. This converts a call from WebKit
// where it gives us an NPObject and an NPIdentifier to an easily-accessible
// ObjectVar (corresponding to the NPObject) and PP_Var (corresponding to the
// NPIdentifier).
//
// If the NPObject or identifier is invalid, we'll set is_valid() to false.
// The caller should check is_valid() before doing anything with the class.
//
// JS can't have integer functions, so when dealing with these, we don't want
// to allow integer identifiers. The calling code can decode if it wants to
// allow integer identifiers (like for property access) or prohibit them
// (like for method calling) by setting |allow_integer_identifier|. If this
// is false and the identifier is an integer, we'll set is_valid() to false.
//
// Getting an integer identifier in this case should be impossible. V8
// shouldn't be allowing this, and the Pepper Var calls from the plugin are
// supposed to error out before calling into V8 (which will then call us back).
// Aside from an egregious error, the only time this could happen is an NPAPI
// plugin calling us.
class NPObjectAccessorWithIdentifier {
public:
NPObjectAccessorWithIdentifier(NPObject* object,
NPIdentifier identifier,
bool allow_integer_identifier);
~NPObjectAccessorWithIdentifier();
// Returns true if both the object and identifier are valid.
bool is_valid() const {
return object_ && identifier_.type != PP_VARTYPE_UNDEFINED;
}
PluginObject* object() { return object_; }
PP_Var identifier() const { return identifier_; }
private:
PluginObject* object_;
PP_Var identifier_;
DISALLOW_COPY_AND_ASSIGN(NPObjectAccessorWithIdentifier);
};
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_PLUGINS_PPAPI_NPAPI_GLUE_H_

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_DELEGATE_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_DELEGATE_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PLUGIN_DELEGATE_H_
#define WEBKIT_PLUGINS_PPAPI_PLUGIN_DELEGATE_H_
#include <string>
@ -19,7 +19,7 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_stdint.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/glue/plugins/pepper_dir_contents.h"
#include "webkit/plugins/ppapi/dir_contents.h"
class AudioMessageFilter;
class GURL;
@ -58,21 +58,22 @@ struct PP_VideoUncompressedDataBuffer_Dev;
class TransportDIB;
namespace pepper {
namespace webkit {
namespace ppapi {
class FileIO;
class PluginInstance;
class FullscreenContainer;
// Virtual interface that the browser implements to implement features for
// Pepper plugins.
// PPAPI plugins.
class PluginDelegate {
public:
// This class is implemented by the PluginDelegate implementation and is
// designed to manage the lifetime and communicatin with the proxy's
// HostDispatcher for out-of-process pepper plugins.
// HostDispatcher for out-of-process PPAPI plugins.
//
// The point of this is to avoid having a relationship from the pepper plugin
// The point of this is to avoid having a relationship from the PPAPI plugin
// implementation to the ppapi proxy code. Otherwise, things like the IPC
// system will be dependencies of the webkit directory, which we don't want.
//
@ -188,12 +189,12 @@ class PluginDelegate {
};
// Indicates that the given instance has been created.
virtual void InstanceCreated(pepper::PluginInstance* instance) = 0;
virtual void InstanceCreated(PluginInstance* instance) = 0;
// Indicates that the given instance is being destroyed. This is called from
// the destructor, so it's important that the instance is not dereferenced
// from this call.
virtual void InstanceDeleted(pepper::PluginInstance* instance) = 0;
virtual void InstanceDeleted(PluginInstance* instance) = 0;
// The caller will own the pointer returned from this.
virtual PlatformImage2D* CreateImage2D(int width, int height) = 0;
@ -276,7 +277,7 @@ class PluginDelegate {
virtual base::PlatformFileError GetModuleLocalDirContents(
const std::string& module_name,
const FilePath& path,
PepperDirContents* contents) = 0;
DirContents* contents) = 0;
// Returns a MessageLoopProxy instance associated with the message loop
// of the file thread in this renderer.
@ -307,6 +308,7 @@ class PluginDelegate {
virtual void SetContentRestriction(int restrictions) = 0;
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_DELEGATE_H_
#endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_DELEGATE_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include <set>
@ -48,42 +48,43 @@
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/trusted/ppb_image_data_trusted.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
#include "webkit/glue/plugins/pepper_audio.h"
#include "webkit/glue/plugins/pepper_buffer.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_char_set.h"
#include "webkit/glue/plugins/pepper_class.h"
#include "webkit/glue/plugins/pepper_cursor_control.h"
#include "webkit/glue/plugins/pepper_directory_reader.h"
#include "webkit/glue/plugins/pepper_file_chooser.h"
#include "webkit/glue/plugins/pepper_file_io.h"
#include "webkit/glue/plugins/pepper_file_ref.h"
#include "webkit/glue/plugins/pepper_file_system.h"
#include "webkit/glue/plugins/pepper_font.h"
#include "webkit/glue/plugins/pepper_graphics_2d.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_object.h"
#include "webkit/glue/plugins/pepper_private.h"
#include "webkit/glue/plugins/pepper_private2.h"
#include "webkit/glue/plugins/pepper_resource_tracker.h"
#include "webkit/glue/plugins/pepper_scrollbar.h"
#include "webkit/glue/plugins/pepper_transport.h"
#include "webkit/glue/plugins/pepper_url_loader.h"
#include "webkit/glue/plugins/pepper_url_request_info.h"
#include "webkit/glue/plugins/pepper_url_response_info.h"
#include "webkit/glue/plugins/pepper_url_util.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/glue/plugins/pepper_video_decoder.h"
#include "webkit/glue/plugins/pepper_widget.h"
#include "webkit/glue/plugins/ppb_private.h"
#include "webkit/glue/plugins/ppb_private2.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_object.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_audio_impl.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
#include "webkit/plugins/ppapi/ppb_char_set_impl.h"
#include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_chooser_impl.h"
#include "webkit/plugins/ppapi/ppb_file_io_impl.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/ppb_flash.h"
#include "webkit/plugins/ppapi/ppb_flash_impl.h"
#include "webkit/plugins/ppapi/ppb_font_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/ppb_pdf.h"
#include "webkit/plugins/ppapi/ppb_pdf_impl.h"
#include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
#include "webkit/plugins/ppapi/ppb_transport_impl.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
#include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
#include "webkit/plugins/ppapi/ppb_url_util_impl.h"
#include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
#include "webkit/plugins/ppapi/ppb_widget_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/plugins/ppapi/var.h"
#include "webkit/plugins/ppapi/var_object_class.h"
#ifdef ENABLE_GPU
#include "webkit/glue/plugins/pepper_graphics_3d.h"
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#endif // ENABLE_GPU
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -162,10 +163,10 @@ const PPB_Core core_interface = {
// PPB_Testing -----------------------------------------------------------------
PP_Bool ReadImageData(PP_Resource device_context_2d,
PP_Resource image,
const PP_Point* top_left) {
scoped_refptr<Graphics2D> context(
Resource::GetAs<Graphics2D>(device_context_2d));
PP_Resource image,
const PP_Point* top_left) {
scoped_refptr<PPB_Graphics2D_Impl> context(
Resource::GetAs<PPB_Graphics2D_Impl>(device_context_2d));
if (!context.get())
return PP_FALSE;
return BoolToPPBool(context->ReadImageData(image, top_left));
@ -199,82 +200,85 @@ const PPB_Testing_Dev testing_interface = {
// GetInterface ----------------------------------------------------------------
const void* GetInterface(const char* name) {
// Please keep alphabetized by interface macro name with "special" stuff at
// the bottom.
if (strcmp(name, PPB_AUDIO_CONFIG_DEV_INTERFACE) == 0)
return PPB_AudioConfig_Impl::GetInterface();
if (strcmp(name, PPB_AUDIO_DEV_INTERFACE) == 0)
return PPB_Audio_Impl::GetInterface();
if (strcmp(name, PPB_AUDIO_TRUSTED_DEV_INTERFACE) == 0)
return PPB_Audio_Impl::GetTrustedInterface();
if (strcmp(name, PPB_BUFFER_DEV_INTERFACE) == 0)
return PPB_Buffer_Impl::GetInterface();
if (strcmp(name, PPB_CHAR_SET_DEV_INTERFACE) == 0)
return PPB_CharSet_Impl::GetInterface();
if (strcmp(name, PPB_CLASS_INTERFACE) == 0)
return VarObjectClass::GetInterface();
if (strcmp(name, PPB_CORE_INTERFACE) == 0)
return &core_interface;
if (strcmp(name, PPB_CURSOR_CONTROL_DEV_INTERFACE) == 0)
return GetCursorControlInterface();
if (strcmp(name, PPB_DIRECTORYREADER_DEV_INTERFACE) == 0)
return PPB_DirectoryReader_Impl::GetInterface();
if (strcmp(name, PPB_FILECHOOSER_DEV_INTERFACE) == 0)
return PPB_FileChooser_Impl::GetInterface();
if (strcmp(name, PPB_FILEIO_DEV_INTERFACE) == 0)
return PPB_FileIO_Impl::GetInterface();
if (strcmp(name, PPB_FILEIOTRUSTED_DEV_INTERFACE) == 0)
return PPB_FileIO_Impl::GetTrustedInterface();
if (strcmp(name, PPB_FILEREF_DEV_INTERFACE) == 0)
return PPB_FileRef_Impl::GetInterface();
if (strcmp(name, PPB_FILESYSTEM_DEV_INTERFACE) == 0)
return PPB_FileSystem_Impl::GetInterface();
if (strcmp(name, PPB_FIND_DEV_INTERFACE) == 0)
return PluginInstance::GetFindInterface();
if (strcmp(name, PPB_FLASH_INTERFACE) == 0)
return PPB_Flash_Impl::GetInterface();
if (strcmp(name, PPB_FONT_DEV_INTERFACE) == 0)
return PPB_Font_Impl::GetInterface();
if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0)
return PluginInstance::GetFullscreenInterface();
if (strcmp(name, PPB_GRAPHICS_2D_INTERFACE) == 0)
return PPB_Graphics2D_Impl::GetInterface();
if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0)
return PPB_ImageData_Impl::GetInterface();
if (strcmp(name, PPB_IMAGEDATA_TRUSTED_INTERFACE) == 0)
return PPB_ImageData_Impl::GetTrustedInterface();
if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0)
return PluginInstance::GetInterface();
if (strcmp(name, PPB_PDF_INTERFACE) == 0)
return PPB_PDF_Impl::GetInterface();
if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0)
return PPB_Scrollbar_Impl::GetInterface();
if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0)
return PPB_Transport_Impl::GetInterface();
if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0)
return PPB_URLLoader_Impl::GetInterface();
if (strcmp(name, PPB_URLLOADERTRUSTED_INTERFACE) == 0)
return PPB_URLLoader_Impl::GetTrustedInterface();
if (strcmp(name, PPB_URLREQUESTINFO_INTERFACE) == 0)
return PPB_URLRequestInfo_Impl::GetInterface();
if (strcmp(name, PPB_URLRESPONSEINFO_INTERFACE) == 0)
return PPB_URLResponseInfo_Impl::GetInterface();
if (strcmp(name, PPB_URLUTIL_DEV_INTERFACE) == 0)
return PPB_UrlUtil_Impl::GetInterface();
if (strcmp(name, PPB_VAR_DEPRECATED_INTERFACE) == 0)
return Var::GetDeprecatedInterface();
if (strcmp(name, PPB_VAR_INTERFACE) == 0)
return Var::GetInterface();
if (strcmp(name, PPB_INSTANCE_INTERFACE) == 0)
return PluginInstance::GetInterface();
if (strcmp(name, PPB_IMAGEDATA_INTERFACE) == 0)
return ImageData::GetInterface();
if (strcmp(name, PPB_IMAGEDATA_TRUSTED_INTERFACE) == 0)
return ImageData::GetTrustedInterface();
if (strcmp(name, PPB_AUDIO_CONFIG_DEV_INTERFACE) == 0)
return AudioConfig::GetInterface();
if (strcmp(name, PPB_AUDIO_DEV_INTERFACE) == 0)
return Audio::GetInterface();
if (strcmp(name, PPB_AUDIO_TRUSTED_DEV_INTERFACE) == 0)
return Audio::GetTrustedInterface();
if (strcmp(name, PPB_GRAPHICS_2D_INTERFACE) == 0)
return Graphics2D::GetInterface();
#ifdef ENABLE_GPU
if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0)
return Graphics3D::GetInterface();
if (strcmp(name, PPB_OPENGLES_DEV_INTERFACE) == 0)
return Graphics3D::GetOpenGLESInterface();
#endif // ENABLE_GPU
if (strcmp(name, PPB_TRANSPORT_DEV_INTERFACE) == 0)
return Transport::GetInterface();
if (strcmp(name, PPB_URLLOADER_INTERFACE) == 0)
return URLLoader::GetInterface();
if (strcmp(name, PPB_URLLOADERTRUSTED_INTERFACE) == 0)
return URLLoader::GetTrustedInterface();
if (strcmp(name, PPB_URLREQUESTINFO_INTERFACE) == 0)
return URLRequestInfo::GetInterface();
if (strcmp(name, PPB_URLRESPONSEINFO_INTERFACE) == 0)
return URLResponseInfo::GetInterface();
if (strcmp(name, PPB_BUFFER_DEV_INTERFACE) == 0)
return Buffer::GetInterface();
if (strcmp(name, PPB_FILEREF_DEV_INTERFACE) == 0)
return FileRef::GetInterface();
if (strcmp(name, PPB_FILEIO_DEV_INTERFACE) == 0)
return FileIO::GetInterface();
if (strcmp(name, PPB_FILEIOTRUSTED_DEV_INTERFACE) == 0)
return FileIO::GetTrustedInterface();
if (strcmp(name, PPB_FILESYSTEM_DEV_INTERFACE) == 0)
return FileSystem::GetInterface();
if (strcmp(name, PPB_DIRECTORYREADER_DEV_INTERFACE) == 0)
return DirectoryReader::GetInterface();
if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0)
return Widget::GetInterface();
if (strcmp(name, PPB_SCROLLBAR_DEV_INTERFACE) == 0)
return Scrollbar::GetInterface();
if (strcmp(name, PPB_FONT_DEV_INTERFACE) == 0)
return Font::GetInterface();
if (strcmp(name, PPB_FIND_DEV_INTERFACE) == 0)
return PluginInstance::GetFindInterface();
if (strcmp(name, PPB_FULLSCREEN_DEV_INTERFACE) == 0)
return PluginInstance::GetFullscreenInterface();
if (strcmp(name, PPB_URLUTIL_DEV_INTERFACE) == 0)
return UrlUtil::GetInterface();
if (strcmp(name, PPB_PRIVATE_INTERFACE) == 0)
return Private::GetInterface();
if (strcmp(name, PPB_PRIVATE2_INTERFACE) == 0)
return Private2::GetInterface();
if (strcmp(name, PPB_FILECHOOSER_DEV_INTERFACE) == 0)
return FileChooser::GetInterface();
if (strcmp(name, PPB_VIDEODECODER_DEV_INTERFACE) == 0)
return VideoDecoder::GetInterface();
if (strcmp(name, PPB_CHAR_SET_DEV_INTERFACE) == 0)
return CharSet::GetInterface();
if (strcmp(name, PPB_CURSOR_CONTROL_DEV_INTERFACE) == 0)
return GetCursorControlInterface();
return PPB_VideoDecoder_Impl::GetInterface();
if (strcmp(name, PPB_WIDGET_DEV_INTERFACE) == 0)
return PPB_Widget_Impl::GetInterface();
if (strcmp(name, PPB_ZOOM_DEV_INTERFACE) == 0)
return PluginInstance::GetZoomInterface();
if (strcmp(name, PPB_CLASS_INTERFACE) == 0)
return VarObjectClass::GetInterface();
#ifdef ENABLE_GPU
if (strcmp(name, PPB_GRAPHICS_3D_DEV_INTERFACE) == 0)
return PPB_Graphics3D_Impl::GetInterface();
if (strcmp(name, PPB_OPENGLES_DEV_INTERFACE) == 0)
return PPB_Graphics3D_Impl::GetOpenGLESInterface();
#endif // ENABLE_GPU
// Only support the testing interface when the command line switch is
// specified. This allows us to prevent people from (ab)using this interface
@ -489,4 +493,6 @@ bool PluginModule::InitializeModule() {
return true;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_
#define WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_
#include <map>
#include <set>
@ -16,7 +16,7 @@
#include "base/weak_ptr.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/ppb.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
class FilePath;
class MessageLoop;
@ -38,7 +38,8 @@ namespace IPC {
struct ChannelHandle;
}
namespace pepper {
namespace webkit {
namespace ppapi {
class ObjectVar;
class PluginDelegate;
@ -175,6 +176,7 @@ class PluginModule : public base::RefCounted<PluginModule>,
DISALLOW_COPY_AND_ASSIGN(PluginModule);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_MODULE_H_
#endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_MODULE_H_

@ -0,0 +1,333 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/plugins/ppapi/plugin_object.h"
#include "base/logging.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "base/string_number_conversions.h"
#include "base/string_util.h"
#include "third_party/npapi/bindings/npapi.h"
#include "third_party/npapi/bindings/npruntime.h"
#include "ppapi/c/dev/ppb_var_deprecated.h"
#include "ppapi/c/dev/ppp_class_deprecated.h"
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/c/ppb_class.h"
#include "third_party/WebKit/WebKit/chromium/public/WebBindings.h"
#include "webkit/plugins/ppapi/npapi_glue.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/resource.h"
#include "webkit/plugins/ppapi/string.h"
#include "webkit/plugins/ppapi/var.h"
#include "webkit/plugins/ppapi/var_object_class.h"
using WebKit::WebBindings;
namespace webkit {
namespace ppapi {
namespace {
const char kInvalidValueException[] = "Error: Invalid value";
// NPObject implementation in terms of PPP_Class_Deprecated --------------------
NPObject* WrapperClass_Allocate(NPP npp, NPClass* unused) {
return PluginObject::AllocateObjectWrapper();
}
void WrapperClass_Deallocate(NPObject* np_object) {
PluginObject* plugin_object = PluginObject::FromNPObject(np_object);
if (!plugin_object)
return;
plugin_object->ppp_class()->Deallocate(plugin_object->ppp_class_data());
delete plugin_object;
}
void WrapperClass_Invalidate(NPObject* object) {
}
bool WrapperClass_HasMethod(NPObject* object, NPIdentifier method_name) {
NPObjectAccessorWithIdentifier accessor(object, method_name, false);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
bool rv = accessor.object()->ppp_class()->HasMethod(
accessor.object()->ppp_class_data(), accessor.identifier(),
result_converter.exception());
result_converter.CheckExceptionForNoResult();
return rv;
}
bool WrapperClass_Invoke(NPObject* object, NPIdentifier method_name,
const NPVariant* argv, uint32_t argc,
NPVariant* result) {
NPObjectAccessorWithIdentifier accessor(object, method_name, false);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), result);
PPVarArrayFromNPVariantArray args(accessor.object()->module(), argc, argv);
return result_converter.SetResult(accessor.object()->ppp_class()->Call(
accessor.object()->ppp_class_data(), accessor.identifier(),
argc, args.array(), result_converter.exception()));
}
bool WrapperClass_InvokeDefault(NPObject* np_object, const NPVariant* argv,
uint32_t argc, NPVariant* result) {
PluginObject* obj = PluginObject::FromNPObject(np_object);
if (!obj)
return false;
PPVarArrayFromNPVariantArray args(obj->module(), argc, argv);
PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), result);
result_converter.SetResult(obj->ppp_class()->Call(
obj->ppp_class_data(), PP_MakeUndefined(), argc, args.array(),
result_converter.exception()));
return result_converter.success();
}
bool WrapperClass_HasProperty(NPObject* object, NPIdentifier property_name) {
NPObjectAccessorWithIdentifier accessor(object, property_name, true);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
bool rv = accessor.object()->ppp_class()->HasProperty(
accessor.object()->ppp_class_data(), accessor.identifier(),
result_converter.exception());
result_converter.CheckExceptionForNoResult();
return rv;
}
bool WrapperClass_GetProperty(NPObject* object, NPIdentifier property_name,
NPVariant* result) {
NPObjectAccessorWithIdentifier accessor(object, property_name, true);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), result);
return result_converter.SetResult(accessor.object()->ppp_class()->GetProperty(
accessor.object()->ppp_class_data(), accessor.identifier(),
result_converter.exception()));
}
bool WrapperClass_SetProperty(NPObject* object, NPIdentifier property_name,
const NPVariant* value) {
NPObjectAccessorWithIdentifier accessor(object, property_name, true);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
PP_Var value_var = Var::NPVariantToPPVar(accessor.object()->module(), value);
accessor.object()->ppp_class()->SetProperty(
accessor.object()->ppp_class_data(), accessor.identifier(), value_var,
result_converter.exception());
Var::PluginReleasePPVar(value_var);
return result_converter.CheckExceptionForNoResult();
}
bool WrapperClass_RemoveProperty(NPObject* object, NPIdentifier property_name) {
NPObjectAccessorWithIdentifier accessor(object, property_name, true);
if (!accessor.is_valid())
return false;
PPResultAndExceptionToNPResult result_converter(
accessor.object()->GetNPObject(), NULL);
accessor.object()->ppp_class()->RemoveProperty(
accessor.object()->ppp_class_data(), accessor.identifier(),
result_converter.exception());
return result_converter.CheckExceptionForNoResult();
}
bool WrapperClass_Enumerate(NPObject* object, NPIdentifier** values,
uint32_t* count) {
*values = NULL;
*count = 0;
PluginObject* obj = PluginObject::FromNPObject(object);
if (!obj)
return false;
uint32_t property_count = 0;
PP_Var* properties = NULL; // Must be freed!
PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), NULL);
obj->ppp_class()->GetAllPropertyNames(obj->ppp_class_data(),
&property_count, &properties,
result_converter.exception());
// Convert the array of PP_Var to an array of NPIdentifiers. If any
// conversions fail, we will set the exception.
if (!result_converter.has_exception()) {
if (property_count > 0) {
*values = static_cast<NPIdentifier*>(
malloc(sizeof(NPIdentifier) * property_count));
*count = 0; // Will be the number of items successfully converted.
for (uint32_t i = 0; i < property_count; ++i) {
if (!((*values)[i] = Var::PPVarToNPIdentifier(properties[i]))) {
// Throw an exception for the failed convertion.
*result_converter.exception() = StringVar::StringToPPVar(
obj->module(), kInvalidValueException);
break;
}
(*count)++;
}
if (result_converter.has_exception()) {
// We don't actually have to free the identifiers we converted since
// all identifiers leak anyway :( .
free(*values);
*values = NULL;
*count = 0;
}
}
}
// This will actually throw the exception, either from GetAllPropertyNames,
// or if anything was set during the conversion process.
result_converter.CheckExceptionForNoResult();
// Release the PP_Var that the plugin allocated. On success, they will all
// be converted to NPVariants, and on failure, we want them to just go away.
for (uint32_t i = 0; i < property_count; ++i)
Var::PluginReleasePPVar(properties[i]);
free(properties);
return result_converter.success();
}
bool WrapperClass_Construct(NPObject* object, const NPVariant* argv,
uint32_t argc, NPVariant* result) {
PluginObject* obj = PluginObject::FromNPObject(object);
if (!obj)
return false;
PPVarArrayFromNPVariantArray args(obj->module(), argc, argv);
PPResultAndExceptionToNPResult result_converter(obj->GetNPObject(), result);
return result_converter.SetResult(obj->ppp_class()->Construct(
obj->ppp_class_data(), argc, args.array(),
result_converter.exception()));
}
const NPClass wrapper_class = {
NP_CLASS_STRUCT_VERSION,
WrapperClass_Allocate,
WrapperClass_Deallocate,
WrapperClass_Invalidate,
WrapperClass_HasMethod,
WrapperClass_Invoke,
WrapperClass_InvokeDefault,
WrapperClass_HasProperty,
WrapperClass_GetProperty,
WrapperClass_SetProperty,
WrapperClass_RemoveProperty,
WrapperClass_Enumerate,
WrapperClass_Construct
};
} // namespace
// PluginObject ----------------------------------------------------------------
struct PluginObject::NPObjectWrapper : public NPObject {
// Points to the var object that owns this wrapper. This value may be NULL
// if there is no var owning this wrapper. This can happen if the plugin
// releases all references to the var, but a reference to the underlying
// NPObject is still held by script on the page.
PluginObject* obj;
};
PluginObject::PluginObject(PluginModule* module,
NPObjectWrapper* object_wrapper,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data)
: module_(module),
object_wrapper_(object_wrapper),
ppp_class_(ppp_class),
ppp_class_data_(ppp_class_data) {
// Make the object wrapper refer back to this class so our NPObject
// implementation can call back into the Pepper layer.
object_wrapper_->obj = this;
module_->AddPluginObject(this);
}
PluginObject::~PluginObject() {
// The wrapper we made for this NPObject may still have a reference to it
// from JavaScript, so we clear out its ObjectVar back pointer which will
// cause all calls "up" to the plugin to become NOPs. Our ObjectVar base
// class will release our reference to the object, which may or may not
// delete the NPObject.
DCHECK(object_wrapper_->obj == this);
object_wrapper_->obj = NULL;
module_->RemovePluginObject(this);
}
PP_Var PluginObject::Create(PluginModule* module,
const PPP_Class_Deprecated* ppp_class,
void* ppp_class_data) {
// This will internally end up calling our AllocateObjectWrapper via the
// WrapperClass_Allocated function which will have created an object wrapper
// appropriate for this class (derived from NPObject).
NPObjectWrapper* wrapper = static_cast<NPObjectWrapper*>(
WebBindings::createObject(NULL, const_cast<NPClass*>(&wrapper_class)));
// This object will register itself both with the NPObject and with the
// PluginModule. The NPObject will normally handle its lifetime, and it
// will get deleted in the destroy method. It may also get deleted when the
// plugin module is deallocated.
new PluginObject(module, wrapper, ppp_class, ppp_class_data);
// We can just use a normal ObjectVar to refer to this object from the
// plugin. It will hold a ref to the underlying NPObject which will in turn
// hold our pluginObject.
return ObjectVar::NPObjectToPPVar(module, wrapper);
}
NPObject* PluginObject::GetNPObject() const {
return object_wrapper_;
}
// static
bool PluginObject::IsInstanceOf(NPObject* np_object,
const PPP_Class_Deprecated* ppp_class,
void** ppp_class_data) {
// Validate that this object is implemented by our wrapper class before
// trying to get the PluginObject.
if (np_object->_class != &wrapper_class)
return false;
PluginObject* plugin_object = FromNPObject(np_object);
if (!plugin_object)
return false; // Object is no longer alive.
if (plugin_object->ppp_class() != ppp_class)
return false;
if (ppp_class_data)
*ppp_class_data = plugin_object->ppp_class_data();
return true;
}
// static
PluginObject* PluginObject::FromNPObject(NPObject* object) {
return static_cast<NPObjectWrapper*>(object)->obj;
}
// static
NPObject* PluginObject::AllocateObjectWrapper() {
NPObjectWrapper* wrapper = new NPObjectWrapper;
memset(wrapper, 0, sizeof(NPObjectWrapper));
return wrapper;
}
} // namespace ppapi
} // namespace webkit

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_OBJECT_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_OBJECT_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_
#define WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_
#include <string>
@ -14,7 +14,8 @@ struct PPP_Class_Deprecated;
typedef struct NPObject NPObject;
typedef struct _NPVariant NPVariant;
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginModule;
@ -84,6 +85,7 @@ class PluginObject {
DISALLOW_COPY_AND_ASSIGN(PluginObject);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_OBJECT_H_
#endif // WEBKIT_PLUGINS_PPAPI_PLUGIN_OBJECT_H_

@ -2,21 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
#if defined(OS_MACOSX)
#include "base/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#endif
#include "base/scoped_ptr.h"
#include "base/utf_string_conversions.h"
#include "gfx/rect.h"
#if defined(OS_WIN)
#include "gfx/codec/jpeg_codec.h"
#include "gfx/gdi_util.h"
#endif
#include "gfx/skia_util.h"
#include "ppapi/c/dev/ppb_find_dev.h"
#include "ppapi/c/dev/ppb_fullscreen_dev.h"
@ -47,19 +39,29 @@
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/glue/plugins/pepper_buffer.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_graphics_2d.h"
#include "webkit/glue/plugins/pepper_graphics_3d.h"
#include "webkit/glue/plugins/pepper_event_conversion.h"
#include "webkit/glue/plugins/pepper_fullscreen_container.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_string.h"
#include "webkit/glue/plugins/pepper_url_loader.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/glue/plugins/ppp_private.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/event_conversion.h"
#include "webkit/plugins/ppapi/fullscreen_container.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/ppp_pdf.h"
#include "webkit/plugins/ppapi/string.h"
#include "webkit/plugins/ppapi/var.h"
#if defined(OS_MACOSX)
#include "base/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#endif
#if defined(OS_WIN)
#include "gfx/codec/jpeg_codec.h"
#include "gfx/gdi_util.h"
#endif
using WebKit::WebBindings;
using WebKit::WebCanvas;
@ -72,7 +74,8 @@ using WebKit::WebString;
using WebKit::WebURLRequest;
using WebKit::WebView;
namespace pepper {
namespace webkit {
namespace ppapi {
#if defined(OS_WIN)
// Exported by pdf.dll
@ -298,7 +301,7 @@ PluginInstance::PluginInstance(PluginDelegate* delegate,
has_content_area_focus_(false),
find_identifier_(-1),
plugin_find_interface_(NULL),
plugin_private_interface_(NULL),
plugin_pdf_interface_(NULL),
plugin_selection_interface_(NULL),
plugin_zoom_interface_(NULL),
#if defined (OS_LINUX)
@ -436,10 +439,10 @@ bool PluginInstance::BindGraphics(PP_Resource graphics_id) {
return true;
}
scoped_refptr<Graphics2D> graphics_2d =
Resource::GetAs<Graphics2D>(graphics_id);
scoped_refptr<Graphics3D> graphics_3d =
Resource::GetAs<Graphics3D>(graphics_id);
scoped_refptr<PPB_Graphics2D_Impl> graphics_2d =
Resource::GetAs<PPB_Graphics2D_Impl>(graphics_id);
scoped_refptr<PPB_Graphics3D_Impl> graphics_3d =
Resource::GetAs<PPB_Graphics3D_Impl>(graphics_id);
if (graphics_2d) {
if (!graphics_2d->BindToInstance(this))
@ -553,7 +556,7 @@ bool PluginInstance::Initialize(WebPluginContainer* container,
argv.get()));
}
bool PluginInstance::HandleDocumentLoad(URLLoader* loader) {
bool PluginInstance::HandleDocumentLoad(PPB_URLLoader_Impl* loader) {
Resource::ScopedResourceId resource(loader);
return PPBoolToBool(instance_interface_->HandleDocumentLoad(pp_instance(),
resource.id));
@ -656,7 +659,7 @@ bool PluginInstance::GetBitmapForOptimizedPluginPaint(
// We specifically want to compare against the area covered by the backing
// store when seeing if we cover the given paint bounds, since the backing
// store could be smaller than the declared plugin area.
ImageData* image_data = bound_graphics_2d()->image_data();
PPB_ImageData_Impl* image_data = bound_graphics_2d()->image_data();
gfx::Rect plugin_backing_store_rect(position_.origin(),
gfx::Size(image_data->width(),
image_data->height()));
@ -686,13 +689,13 @@ string16 PluginInstance::GetSelectedText(bool html) {
}
string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) {
if (!LoadPrivateInterface())
if (!LoadPdfInterface())
return string16();
PP_Point p;
p.x = point.x();
p.y = point.y();
PP_Var rv = plugin_private_interface_->GetLinkAtPosition(pp_instance(), p);
PP_Var rv = plugin_pdf_interface_->GetLinkAtPosition(pp_instance(), p);
scoped_refptr<StringVar> string(StringVar::FromPPVar(rv));
Var::PluginReleasePPVar(rv); // Release the ref the plugin transfered to us.
if (!string)
@ -742,14 +745,14 @@ bool PluginInstance::LoadFindInterface() {
return !!plugin_find_interface_;
}
bool PluginInstance::LoadPrivateInterface() {
if (!plugin_private_interface_) {
plugin_private_interface_ =
reinterpret_cast<const PPP_Private*>(module_->GetPluginInterface(
PPP_PRIVATE_INTERFACE));
bool PluginInstance::LoadPdfInterface() {
if (!plugin_pdf_interface_) {
plugin_pdf_interface_ =
reinterpret_cast<const PPP_Pdf*>(module_->GetPluginInterface(
PPP_PDF_INTERFACE));
}
return !!plugin_private_interface_;
return !!plugin_pdf_interface_;
}
bool PluginInstance::LoadSelectionInterface() {
@ -939,7 +942,8 @@ bool PluginInstance::NavigateToURL(const char* url, const char* target) {
bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
WebKit::WebCanvas* canvas) {
scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(print_output));
scoped_refptr<PPB_Buffer_Impl> buffer(
Resource::GetAs<PPB_Buffer_Impl>(print_output));
if (!buffer.get() || !buffer->is_mapped() || !buffer->size()) {
NOTREACHED();
return false;
@ -1023,7 +1027,8 @@ bool PluginInstance::PrintPDFOutput(PP_Resource print_output,
bool PluginInstance::PrintRasterOutput(PP_Resource print_output,
WebKit::WebCanvas* canvas) {
scoped_refptr<ImageData> image(Resource::GetAs<ImageData>(print_output));
scoped_refptr<PPB_ImageData_Impl> image(
Resource::GetAs<PPB_ImageData_Impl>(print_output));
if (!image.get() || !image->is_mapped())
return false;
@ -1162,18 +1167,20 @@ void PluginInstance::DrawSkBitmapToCanvas(
}
#endif // defined(OS_MACOSX)
Graphics2D* PluginInstance::bound_graphics_2d() const {
PPB_Graphics2D_Impl* PluginInstance::bound_graphics_2d() const {
if (bound_graphics_.get() == NULL)
return NULL;
return bound_graphics_->Cast<Graphics2D>();
return bound_graphics_->Cast<PPB_Graphics2D_Impl>();
}
Graphics3D* PluginInstance::bound_graphics_3d() const {
PPB_Graphics3D_Impl* PluginInstance::bound_graphics_3d() const {
if (bound_graphics_.get() == NULL)
return NULL;
return bound_graphics_->Cast<Graphics3D>();
return bound_graphics_->Cast<PPB_Graphics3D_Impl>();
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_
#define WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_
#include <string>
#include <vector>
@ -29,7 +29,7 @@ struct PPB_Fullscreen_Dev;
struct PPB_Zoom_Dev;
struct PPP_Find_Dev;
struct PPP_Instance;
struct PPP_Private;
struct PPP_Pdf;
struct PPP_Selection_Dev;
struct PPP_Zoom_Dev;
@ -46,16 +46,17 @@ class WebInputEvent;
class WebPluginContainer;
}
namespace pepper {
namespace webkit {
namespace ppapi {
class Graphics2D;
class Graphics3D;
class ImageData;
class FullscreenContainer;
class PluginDelegate;
class PluginModule;
class PPB_Graphics2D_Impl;
class PPB_Graphics3D_Impl;
class PPB_ImageData_Impl;
class PPB_URLLoader_Impl;
class Resource;
class URLLoader;
class FullscreenContainer;
// Represents one time a plugin appears on one web page.
//
@ -144,7 +145,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
const std::vector<std::string>& arg_names,
const std::vector<std::string>& arg_values,
bool full_frame);
bool HandleDocumentLoad(URLLoader* loader);
bool HandleDocumentLoad(PPB_URLLoader_Impl* loader);
bool HandleInputEvent(const WebKit::WebInputEvent& event,
WebKit::WebCursorInfo* cursor_info);
PP_Var GetInstanceObject();
@ -190,12 +191,12 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
bool IsFullscreen();
bool SetFullscreen(bool fullscreen);
// Implementation of PPB_Private2.
// Implementation of PPB_Flash.
bool NavigateToURL(const char* url, const char* target);
private:
bool LoadFindInterface();
bool LoadPrivateInterface();
bool LoadPdfInterface();
bool LoadSelectionInterface();
bool LoadZoomInterface();
@ -222,11 +223,11 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// Get the bound graphics context as a concrete 2D graphics context or returns
// null if the context is not 2D.
Graphics2D* bound_graphics_2d() const;
PPB_Graphics2D_Impl* bound_graphics_2d() const;
// Get the bound graphics context as a concrete 3D graphics context or returns
// null if the context is not 3D.
Graphics3D* bound_graphics_3d() const;
PPB_Graphics3D_Impl* bound_graphics_3d() const;
PluginDelegate* delegate_;
scoped_refptr<PluginModule> module_;
@ -266,7 +267,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// The plugin-provided interfaces.
const PPP_Find_Dev* plugin_find_interface_;
const PPP_Private* plugin_private_interface_;
const PPP_Pdf* plugin_pdf_interface_;
const PPP_Selection_Dev* plugin_selection_interface_;
const PPP_Zoom_Dev* plugin_zoom_interface_;
@ -277,7 +278,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
// On the Mac, when we draw the bitmap to the PDFContext, it seems necessary
// to keep the pixels valid until CGContextEndPage is called. We use this
// variable to hold on to the pixels.
scoped_refptr<ImageData> last_printed_page_;
scoped_refptr<PPB_ImageData_Impl> last_printed_page_;
#elif defined(OS_LINUX)
// On Linux, we always send all pages from the renderer to the browser.
// So, if the plugin supports printPagesAsPDF we print the entire output
@ -313,6 +314,7 @@ class PluginInstance : public base::RefCounted<PluginInstance> {
DISALLOW_COPY_AND_ASSIGN(PluginInstance);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_PLUGIN_INSTANCE_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPAPI_PLUGIN_INSTANCE_H_

@ -2,20 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/ppapi_unittest.h"
#include "webkit/plugins/ppapi/ppapi_unittest.h"
#include "ppapi/c/pp_var.h"
#include "ppapi/c/ppp_instance.h"
#include "webkit/glue/plugins/mock_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/plugins/ppapi/mock_plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
PpapiUnittest* current_unittest = NULL;
const void* MockGetInterface(const char* interface_name) {
return current_unittest->GetMockInterface(interface_name);
}
@ -24,8 +25,6 @@ int MockInitializeModule(PP_Module, PPB_GetInterface) {
return PP_OK;
}
// PepperPluginDelegate -------------------------------------
// PPP_Instance implementation ------------------------------------------------
PP_Bool Instance_DidCreate(PP_Instance pp_instance,
@ -86,14 +85,14 @@ PpapiUnittest::~PpapiUnittest() {
void PpapiUnittest::SetUp() {
delegate_.reset(new MockPluginDelegate);
// Initialize the mock module.
module_ = new PluginModule;
PluginModule::EntryPoints entry_points;
entry_points.get_interface = &MockGetInterface;
entry_points.initialize_module = &MockInitializeModule;
ASSERT_TRUE(module_->InitAsInternalPlugin(entry_points));
// Initialize the mock instance.
instance_ = new PluginInstance(delegate_.get(), module(),
static_cast<const PPP_Instance*>(
@ -109,5 +108,6 @@ const void* PpapiUnittest::GetMockInterface(const char* interface_name) const {
return NULL;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,15 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PPAPI_UNITTEST_H_
#define WEBKIT_GLUE_PLUGINS_PPAPI_UNITTEST_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_
#define WEBKIT_PLUGINS_PPAPI_PPAPI_UNITTEST_H_
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace pepper {
namespace webkit {
namespace ppapi {
class MockPluginDelegate;
class PluginInstance;
@ -41,6 +42,7 @@ class PpapiUnittest : public testing::Test {
DISALLOW_COPY_AND_ASSIGN(PpapiUnittest);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PPAPI_UNITTEST_H_
#endif // WEBKIT_GLUE_PPAPI_PLUGINS_PPAPI_UNITTEST_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_webplugin_impl.h"
#include "webkit/plugins/ppapi/ppapi_webplugin_impl.h"
#include <cmath>
@ -12,10 +12,10 @@
#include "third_party/WebKit/WebKit/chromium/public/WebPoint.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebView.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_url_loader.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "webkit/plugins/ppapi/var.h"
using WebKit::WebCanvas;
using WebKit::WebPluginContainer;
@ -27,7 +27,8 @@ using WebKit::WebURL;
using WebKit::WebVector;
using WebKit::WebView;
namespace pepper {
namespace webkit {
namespace ppapi {
struct WebPluginImpl::InitData {
scoped_refptr<PluginModule> module;
@ -135,7 +136,7 @@ void WebPluginImpl::didReceiveResponse(
const WebKit::WebURLResponse& response) {
DCHECK(!document_loader_);
document_loader_ = new URLLoader(instance_, true);
document_loader_ = new PPB_URLLoader_Impl(instance_, true);
document_loader_->didReceiveResponse(NULL, response);
if (!instance_->HandleDocumentLoad(document_loader_))
@ -223,4 +224,6 @@ void WebPluginImpl::printEnd() {
return instance_->PrintEnd();
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_WEBPLUGIN_IMPL_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_WEBPLUGIN_IMPL_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPAPI_WEBPLUGIN_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPAPI_WEBPLUGIN_IMPL_H_
#include <string>
#include <vector>
@ -18,12 +18,13 @@ namespace WebKit {
struct WebPluginParams;
}
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginDelegate;
class PluginInstance;
class PluginModule;
class URLLoader;
class PPB_URLLoader_Impl;
class WebPluginImpl : public WebKit::WebPlugin {
public:
@ -84,12 +85,13 @@ class WebPluginImpl : public WebKit::WebPlugin {
// being an embedded resource.
bool full_frame_;
scoped_refptr<PluginInstance> instance_;
scoped_refptr<URLLoader> document_loader_;
scoped_refptr<PPB_URLLoader_Impl> document_loader_;
gfx::Rect plugin_rect_;
DISALLOW_COPY_AND_ASSIGN(WebPluginImpl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_WEBPLUGIN_IMPL_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPAPI_WEBPLUGIN_IMPL_H_

@ -2,15 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_audio.h"
#include "webkit/plugins/ppapi/ppb_audio_impl.h"
#include "base/logging.h"
#include "ppapi/c/dev/ppb_audio_dev.h"
#include "ppapi/c/dev/ppb_audio_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/plugins/ppapi/common.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -36,9 +37,8 @@ PP_Resource CreateStereo16bit(PP_Module module_id,
if (RecommendSampleFrameCount(sample_frame_count) != sample_frame_count)
return 0;
scoped_refptr<AudioConfig> config(new AudioConfig(module,
sample_rate,
sample_frame_count));
scoped_refptr<PPB_AudioConfig_Impl> config(
new PPB_AudioConfig_Impl(module, sample_rate, sample_frame_count));
return config->GetReference();
}
@ -53,17 +53,20 @@ uint32_t RecommendSampleFrameCount(uint32_t requested_sample_frame_count) {
}
PP_Bool IsAudioConfig(PP_Resource resource) {
scoped_refptr<AudioConfig> config = Resource::GetAs<AudioConfig>(resource);
scoped_refptr<PPB_AudioConfig_Impl> config =
Resource::GetAs<PPB_AudioConfig_Impl>(resource);
return BoolToPPBool(!!config);
}
PP_AudioSampleRate_Dev GetSampleRate(PP_Resource config_id) {
scoped_refptr<AudioConfig> config = Resource::GetAs<AudioConfig>(config_id);
scoped_refptr<PPB_AudioConfig_Impl> config =
Resource::GetAs<PPB_AudioConfig_Impl>(config_id);
return config ? config->sample_rate() : PP_AUDIOSAMPLERATE_NONE;
}
uint32_t GetSampleFrameCount(PP_Resource config_id) {
scoped_refptr<AudioConfig> config = Resource::GetAs<AudioConfig>(config_id);
scoped_refptr<PPB_AudioConfig_Impl> config =
Resource::GetAs<PPB_AudioConfig_Impl>(config_id);
return config ? config->sample_frame_count() : 0;
}
@ -84,7 +87,8 @@ PP_Resource Create(PP_Instance instance_id, PP_Resource config_id,
return 0;
if (!user_callback)
return 0;
scoped_refptr<Audio> audio(new Audio(instance->module(), instance_id));
scoped_refptr<PPB_Audio_Impl> audio(
new PPB_Audio_Impl(instance->module(), instance_id));
if (!audio->Init(instance->delegate(), config_id,
user_callback, user_data))
return 0;
@ -92,22 +96,25 @@ PP_Resource Create(PP_Instance instance_id, PP_Resource config_id,
}
PP_Bool IsAudio(PP_Resource resource) {
scoped_refptr<Audio> audio = Resource::GetAs<Audio>(resource);
scoped_refptr<PPB_Audio_Impl> audio =
Resource::GetAs<PPB_Audio_Impl>(resource);
return BoolToPPBool(!!audio);
}
PP_Resource GetCurrentConfig(PP_Resource audio_id) {
scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id);
scoped_refptr<PPB_Audio_Impl> audio = Resource::GetAs<PPB_Audio_Impl>(audio_id);
return audio ? audio->GetCurrentConfig() : 0;
}
PP_Bool StartPlayback(PP_Resource audio_id) {
scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id);
scoped_refptr<PPB_Audio_Impl> audio =
Resource::GetAs<PPB_Audio_Impl>(audio_id);
return audio ? BoolToPPBool(audio->StartPlayback()) : PP_FALSE;
}
PP_Bool StopPlayback(PP_Resource audio_id) {
scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id);
scoped_refptr<PPB_Audio_Impl> audio =
Resource::GetAs<PPB_Audio_Impl>(audio_id);
return audio ? BoolToPPBool(audio->StopPlayback()) : PP_FALSE;
}
@ -125,14 +132,15 @@ PP_Resource CreateTrusted(PP_Instance instance_id) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance)
return 0;
scoped_refptr<Audio> audio(new Audio(instance->module(), instance_id));
scoped_refptr<PPB_Audio_Impl> audio(new PPB_Audio_Impl(instance->module(), instance_id));
return audio->GetReference();
}
int32_t Open(PP_Resource audio_id,
PP_Resource config_id,
PP_CompletionCallback created) {
scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id);
scoped_refptr<PPB_Audio_Impl> audio =
Resource::GetAs<PPB_Audio_Impl>(audio_id);
if (!audio)
return PP_ERROR_BADRESOURCE;
if (!created.func)
@ -145,7 +153,8 @@ int32_t Open(PP_Resource audio_id,
}
int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) {
scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id);
scoped_refptr<PPB_Audio_Impl> audio =
Resource::GetAs<PPB_Audio_Impl>(audio_id);
if (audio)
return audio->GetSyncSocket(sync_socket);
return PP_ERROR_BADRESOURCE;
@ -154,7 +163,8 @@ int32_t GetSyncSocket(PP_Resource audio_id, int* sync_socket) {
int32_t GetSharedMemory(PP_Resource audio_id,
int* shm_handle,
uint32_t* shm_size) {
scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id);
scoped_refptr<PPB_Audio_Impl> audio =
Resource::GetAs<PPB_Audio_Impl>(audio_id);
if (audio)
return audio->GetSharedMemory(shm_handle, shm_size);
return PP_ERROR_BADRESOURCE;
@ -169,21 +179,22 @@ const PPB_AudioTrusted_Dev ppb_audiotrusted = {
} // namespace
// AudioConfig -----------------------------------------------------------------
// PPB_AudioConfig_Impl --------------------------------------------------------
AudioConfig::AudioConfig(PluginModule* module,
PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count)
PPB_AudioConfig_Impl::PPB_AudioConfig_Impl(
PluginModule* module,
PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count)
: Resource(module),
sample_rate_(sample_rate),
sample_frame_count_(sample_frame_count) {
}
const PPB_AudioConfig_Dev* AudioConfig::GetInterface() {
const PPB_AudioConfig_Dev* PPB_AudioConfig_Impl::GetInterface() {
return &ppb_audioconfig;
}
size_t AudioConfig::BufferSize() {
size_t PPB_AudioConfig_Impl::BufferSize() {
// TODO(audio): as more options become available, we'll need to
// have additional code here to correctly calculate the size in
// bytes of an audio buffer. For now, only support two channel
@ -193,13 +204,13 @@ size_t AudioConfig::BufferSize() {
return static_cast<size_t>(sample_frame_count_ * kSizeOfSample * kChannels);
}
AudioConfig* AudioConfig::AsAudioConfig() {
PPB_AudioConfig_Impl* PPB_AudioConfig_Impl::AsPPB_AudioConfig_Impl() {
return this;
}
// Audio -----------------------------------------------------------------------
// PPB_Audio_Impl --------------------------------------------------------------
Audio::Audio(PluginModule* module, PP_Instance instance_id)
PPB_Audio_Impl::PPB_Audio_Impl(PluginModule* module, PP_Instance instance_id)
: Resource(module),
pp_instance_(instance_id),
audio_(NULL),
@ -207,7 +218,7 @@ Audio::Audio(PluginModule* module, PP_Instance instance_id)
create_callback_ = PP_MakeCompletionCallback(NULL, NULL);
}
Audio::~Audio() {
PPB_Audio_Impl::~PPB_Audio_Impl() {
// Calling ShutDown() makes sure StreamCreated cannot be called anymore.
audio_->ShutDown();
audio_ = NULL;
@ -220,23 +231,23 @@ Audio::~Audio() {
}
}
const PPB_Audio_Dev* Audio::GetInterface() {
const PPB_Audio_Dev* PPB_Audio_Impl::GetInterface() {
return &ppb_audio;
}
const PPB_AudioTrusted_Dev* Audio::GetTrustedInterface() {
const PPB_AudioTrusted_Dev* PPB_Audio_Impl::GetTrustedInterface() {
return &ppb_audiotrusted;
}
Audio* Audio::AsAudio() {
PPB_Audio_Impl* PPB_Audio_Impl::AsPPB_Audio_Impl() {
return this;
}
bool Audio::Init(PluginDelegate* plugin_delegate,
PP_Resource config_id,
PPB_Audio_Callback callback, void* user_data) {
bool PPB_Audio_Impl::Init(PluginDelegate* plugin_delegate,
PP_Resource config_id,
PPB_Audio_Callback callback, void* user_data) {
CHECK(!audio_);
config_ = Resource::GetAs<AudioConfig>(config_id);
config_ = Resource::GetAs<PPB_AudioConfig_Impl>(config_id);
if (!config_)
return false;
SetCallback(callback, user_data);
@ -248,18 +259,18 @@ bool Audio::Init(PluginDelegate* plugin_delegate,
return audio_ != NULL;
}
PP_Resource Audio::GetCurrentConfig() {
PP_Resource PPB_Audio_Impl::GetCurrentConfig() {
return config_->GetReference();
}
bool Audio::StartPlayback() {
bool PPB_Audio_Impl::StartPlayback() {
if (playing())
return true;
SetStartPlaybackState();
return audio_->StartPlayback();
}
bool Audio::StopPlayback() {
bool PPB_Audio_Impl::StopPlayback() {
if (!playing())
return true;
if (!audio_->StopPlayback())
@ -268,11 +279,11 @@ bool Audio::StopPlayback() {
return true;
}
int32_t Audio::Open(PluginDelegate* plugin_delegate,
PP_Resource config_id,
PP_CompletionCallback create_callback) {
int32_t PPB_Audio_Impl::Open(PluginDelegate* plugin_delegate,
PP_Resource config_id,
PP_CompletionCallback create_callback) {
DCHECK(!audio_);
config_ = Resource::GetAs<AudioConfig>(config_id);
config_ = Resource::GetAs<PPB_AudioConfig_Impl>(config_id);
if (!config_)
return PP_ERROR_BADRESOURCE;
@ -291,7 +302,7 @@ int32_t Audio::Open(PluginDelegate* plugin_delegate,
return PP_ERROR_WOULDBLOCK;
}
int32_t Audio::GetSyncSocket(int* sync_socket) {
int32_t PPB_Audio_Impl::GetSyncSocket(int* sync_socket) {
if (socket_for_create_callback_.get()) {
#if defined(OS_POSIX)
*sync_socket = socket_for_create_callback_->handle();
@ -305,7 +316,7 @@ int32_t Audio::GetSyncSocket(int* sync_socket) {
return PP_ERROR_FAILED;
}
int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) {
int32_t PPB_Audio_Impl::GetSharedMemory(int* shm_handle, uint32_t* shm_size) {
if (shared_memory_for_create_callback_.get()) {
#if defined(OS_POSIX)
*shm_handle = shared_memory_for_create_callback_->handle().fd;
@ -321,9 +332,10 @@ int32_t Audio::GetSharedMemory(int* shm_handle, uint32_t* shm_size) {
return PP_ERROR_FAILED;
}
void Audio::StreamCreated(base::SharedMemoryHandle shared_memory_handle,
size_t shared_memory_size,
base::SyncSocket::Handle socket_handle) {
void PPB_Audio_Impl::StreamCreated(
base::SharedMemoryHandle shared_memory_handle,
size_t shared_memory_size,
base::SyncSocket::Handle socket_handle) {
if (create_callback_pending_) {
// Trusted side of proxy can specify a callback to recieve handles. In
// this case we don't need to map any data or start the thread since it
@ -348,4 +360,6 @@ void Audio::StreamCreated(base::SharedMemoryHandle shared_memory_handle,
}
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_
#ifndef WEBKIT_PLUGINS_PPAPI_DEVICE_CONTEXT_AUDIO_H_
#define WEBKIT_PLUGINS_PPAPI_DEVICE_CONTEXT_AUDIO_H_
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "base/shared_memory.h"
#include "base/sync_socket.h"
@ -13,21 +14,22 @@
#include "ppapi/c/dev/ppb_audio_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/shared_impl/audio_impl.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource.h"
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginInstance;
class PluginModule;
class AudioConfig : public Resource {
class PPB_AudioConfig_Impl : public Resource {
public:
AudioConfig(PluginModule* module,
PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count);
PPB_AudioConfig_Impl(PluginModule* module,
PP_AudioSampleRate_Dev sample_rate,
uint32_t sample_frame_count);
size_t BufferSize();
static const PPB_AudioConfig_Dev* GetInterface();
@ -36,7 +38,7 @@ class AudioConfig : public Resource {
private:
// Resource override.
virtual AudioConfig* AsAudioConfig();
virtual PPB_AudioConfig_Impl* AsPPB_AudioConfig_Impl();
PP_AudioSampleRate_Dev sample_rate_;
uint32_t sample_frame_count_;
@ -44,12 +46,12 @@ class AudioConfig : public Resource {
// Some of the backend functionality of this class is implemented by the
// AudioImpl so it can be shared with the proxy.
class Audio : public Resource,
public pp::shared_impl::AudioImpl,
public PluginDelegate::PlatformAudio::Client {
class PPB_Audio_Impl : public Resource,
public pp::shared_impl::AudioImpl,
public PluginDelegate::PlatformAudio::Client {
public:
explicit Audio(PluginModule* module, PP_Instance instance_id);
virtual ~Audio();
explicit PPB_Audio_Impl(PluginModule* module, PP_Instance instance_id);
virtual ~PPB_Audio_Impl();
static const PPB_Audio_Dev* GetInterface();
static const PPB_AudioTrusted_Dev* GetTrustedInterface();
@ -74,16 +76,16 @@ class Audio : public Resource,
int32_t GetSharedMemory(int* shm_handle, uint32_t* shm_size);
// Resource override.
virtual Audio* AsAudio();
virtual PPB_Audio_Impl* AsPPB_Audio_Impl();
private:
// pepper::PluginDelegate::PlatformAudio::Client implementation.
// PluginDelegate::PlatformAudio::Client implementation.
virtual void StreamCreated(base::SharedMemoryHandle shared_memory_handle,
size_t shared_memory_size_,
base::SyncSocket::Handle socket);
// AudioConfig used for creating this Audio object.
scoped_refptr<AudioConfig> config_;
scoped_refptr<PPB_AudioConfig_Impl> config_;
// Plugin instance that owns this audio object.
PP_Instance pp_instance_;
@ -104,8 +106,11 @@ class Audio : public Resource,
scoped_ptr<base::SharedMemory> shared_memory_for_create_callback_;
size_t shared_memory_size_for_create_callback_;
scoped_ptr<base::SyncSocket> socket_for_create_callback_;
DISALLOW_COPY_AND_ASSIGN(PPB_Audio_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_
#endif // WEBKIT_PLUGINS_PPAPI_DEVICE_CONTEXT_AUDIO_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_buffer.h"
#include "webkit/plugins/ppapi/ppb_buffer_impl.h"
#include <algorithm>
@ -12,11 +12,12 @@
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_module.h"
#include "ppapi/c/pp_resource.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -25,19 +26,20 @@ PP_Resource Create(PP_Module module_id, uint32_t size) {
if (!module)
return 0;
scoped_refptr<Buffer> buffer(new Buffer(module));
scoped_refptr<PPB_Buffer_Impl> buffer(new PPB_Buffer_Impl(module));
if (!buffer->Init(size))
return 0;
return buffer->GetReference();
}
PP_Bool IsBuffer(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<Buffer>(resource));
PP_Bool IsPPB_Buffer_Impl(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<PPB_Buffer_Impl>(resource));
}
PP_Bool Describe(PP_Resource resource, uint32_t* size_in_bytes) {
scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(resource));
scoped_refptr<PPB_Buffer_Impl> buffer(
Resource::GetAs<PPB_Buffer_Impl>(resource));
if (!buffer)
return PP_FALSE;
buffer->Describe(size_in_bytes);
@ -45,14 +47,16 @@ PP_Bool Describe(PP_Resource resource, uint32_t* size_in_bytes) {
}
void* Map(PP_Resource resource) {
scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(resource));
scoped_refptr<PPB_Buffer_Impl> buffer(
Resource::GetAs<PPB_Buffer_Impl>(resource));
if (!buffer)
return NULL;
return buffer->Map();
}
void Unmap(PP_Resource resource) {
scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(resource));
scoped_refptr<PPB_Buffer_Impl> buffer(
Resource::GetAs<PPB_Buffer_Impl>(resource));
if (!buffer)
return;
return buffer->Unmap();
@ -60,7 +64,7 @@ void Unmap(PP_Resource resource) {
const PPB_Buffer_Dev ppb_buffer = {
&Create,
&IsBuffer,
&IsPPB_Buffer_Impl,
&Describe,
&Map,
&Unmap,
@ -68,22 +72,24 @@ const PPB_Buffer_Dev ppb_buffer = {
} // namespace
Buffer::Buffer(PluginModule* module)
PPB_Buffer_Impl::PPB_Buffer_Impl(PluginModule* module)
: Resource(module),
size_(0) {
}
Buffer::~Buffer() {
PPB_Buffer_Impl::~PPB_Buffer_Impl() {
}
// static
const PPB_Buffer_Dev* Buffer::GetInterface() {
const PPB_Buffer_Dev* PPB_Buffer_Impl::GetInterface() {
return &ppb_buffer;
}
Buffer* Buffer::AsBuffer() { return this; }
PPB_Buffer_Impl* PPB_Buffer_Impl::AsPPB_Buffer_Impl() {
return this;
}
bool Buffer::Init(uint32_t size) {
bool PPB_Buffer_Impl::Init(uint32_t size) {
if (size == 0)
return false;
Unmap();
@ -91,11 +97,11 @@ bool Buffer::Init(uint32_t size) {
return true;
}
void Buffer::Describe(uint32_t* size_in_bytes) const {
void PPB_Buffer_Impl::Describe(uint32_t* size_in_bytes) const {
*size_in_bytes = size_;
}
void* Buffer::Map() {
void* PPB_Buffer_Impl::Map() {
if (size_ == 0)
return NULL;
@ -106,14 +112,10 @@ void* Buffer::Map() {
return mem_buffer_.get();
}
void Buffer::Unmap() {
void PPB_Buffer_Impl::Unmap() {
mem_buffer_.reset();
}
void Buffer::Swap(Buffer* other) {
swap(other->mem_buffer_, mem_buffer_);
std::swap(other->size_, size_);
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,23 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_BUFFER_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_BUFFER_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/resource.h"
struct PPB_Buffer_Dev;
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginInstance;
class Buffer : public Resource {
class PPB_Buffer_Impl : public Resource {
public:
explicit Buffer(PluginModule* module);
virtual ~Buffer();
explicit PPB_Buffer_Impl(PluginModule* module);
virtual ~PPB_Buffer_Impl();
uint32_t size() const { return size_; }
unsigned char* mapped_buffer() { return mem_buffer_.get(); }
@ -27,30 +28,28 @@ class Buffer : public Resource {
// either invalid or not mapped.
bool is_mapped() const { return !!mem_buffer_.get(); }
// Returns a pointer to the interface implementing PPB_Buffer that is
// Returns a pointer to the interface implementing PPB_PPB_Buffer_Impl that is
// exposed to the plugin.
static const PPB_Buffer_Dev* GetInterface();
// Resource overrides.
virtual Buffer* AsBuffer();
virtual PPB_Buffer_Impl* AsPPB_Buffer_Impl();
// PPB_Buffer implementation.
// PPB_PPB_Buffer_Impl implementation.
bool Init(uint32_t size);
void Describe(uint32_t* size_in_bytes) const;
void* Map();
void Unmap();
// Swaps the guts of this buffer with another.
void Swap(Buffer* other);
private:
uint32_t size_;
scoped_array<unsigned char> mem_buffer_;
DISALLOW_COPY_AND_ASSIGN(Buffer);
DISALLOW_COPY_AND_ASSIGN(PPB_Buffer_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_BUFFER_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_BUFFER_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_char_set.h"
#include "webkit/plugins/ppapi/ppb_char_set_impl.h"
#include <stdlib.h>
@ -12,12 +12,13 @@
#include "unicode/ucnv_cb.h"
#include "unicode/ucnv_err.h"
#include "unicode/ustring.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/var.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -44,7 +45,7 @@ bool PPToBaseConversionError(PP_CharSet_ConversionError on_error,
// The "substitution" behavior of this function does not match the
// implementation in base, so we partially duplicate the code from
// icu_string_conversions.cc with the correct error handling setup required
// by this pepper interface.
// by this PPAPI interface.
char* UTF16ToCharSet(const uint16_t* utf16, uint32_t utf16_len,
const char* output_char_set,
PP_CharSet_ConversionError on_error,
@ -159,8 +160,10 @@ const PPB_CharSet_Dev ppb_charset = {
} // namespace
// static
const struct PPB_CharSet_Dev* CharSet::GetInterface() {
const struct PPB_CharSet_Dev* PPB_CharSet_Impl::GetInterface() {
return &ppb_charset;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,20 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_CHAR_SET_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_CHAR_SET_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_CHAR_SET_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_CHAR_SET_IMPL_H_
struct PPB_CharSet_Dev;
namespace pepper {
namespace webkit {
namespace ppapi {
class CharSet {
class PPB_CharSet_Impl {
public:
// Returns a pointer to the interface implementing PPB_CharSet that is
// exposed to the plugin.
static const PPB_CharSet_Dev* GetInterface();
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_CHAR_SET_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_CHAR_SET_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_cursor_control.h"
#include "webkit/plugins/ppapi/ppb_cursor_control_impl.h"
#include "base/logging.h"
#include "base/ref_counted.h"
@ -10,25 +10,26 @@
#include "ppapi/c/dev/ppb_cursor_control_dev.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_resource.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
PP_Bool SetCursor(PP_Instance instance_id,
PP_CursorType_Dev type,
PP_Resource custom_image_id,
const PP_Point* hot_spot) {
PP_CursorType_Dev type,
PP_Resource custom_image_id,
const PP_Point* hot_spot) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance)
return PP_FALSE;
scoped_refptr<ImageData> custom_image(
Resource::GetAs<ImageData>(custom_image_id));
scoped_refptr<PPB_ImageData_Impl> custom_image(
Resource::GetAs<PPB_ImageData_Impl>(custom_image_id));
if (custom_image.get()) {
// TODO(neb): implement custom cursors.
NOTIMPLEMENTED();
@ -88,5 +89,6 @@ const PPB_CursorControl_Dev* GetCursorControlInterface() {
return &cursor_control_interface;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,18 +2,20 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_CURSOR_CONTROL_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_CURSOR_CONTROL_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_CURSOR_CONTROL_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_CURSOR_CONTROL_IMPL_H_
struct PPB_CursorControl_Dev;
namespace pepper {
namespace webkit {
namespace ppapi {
// There's no class implementing CursorControl so we just expose a getter for
// the interface implemented in the .cc file here.
const PPB_CursorControl_Dev* GetCursorControlInterface();
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_CURSOR_CONTROL_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_CURSOR_CONTROL_IMPL_H_

@ -2,23 +2,24 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_directory_reader.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "ppapi/c/dev/ppb_directory_reader_dev.h"
#include "webkit/glue/plugins/pepper_file_callbacks.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_file_ref.h"
#include "webkit/glue/plugins/pepper_file_system.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_resource_tracker.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/file_callbacks.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -43,24 +44,24 @@ FilePath::StringType UTF8StringToFilePathString(const std::string& str) {
}
PP_Resource Create(PP_Resource directory_ref_id) {
scoped_refptr<FileRef> directory_ref(
Resource::GetAs<FileRef>(directory_ref_id));
scoped_refptr<PPB_FileRef_Impl> directory_ref(
Resource::GetAs<PPB_FileRef_Impl>(directory_ref_id));
if (!directory_ref)
return 0;
DirectoryReader* reader = new DirectoryReader(directory_ref);
PPB_DirectoryReader_Impl* reader = new PPB_DirectoryReader_Impl(directory_ref);
return reader->GetReference();
}
PP_Bool IsDirectoryReader(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<DirectoryReader>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_DirectoryReader_Impl>(resource));
}
int32_t GetNextEntry(PP_Resource reader_id,
PP_DirectoryEntry_Dev* entry,
PP_CompletionCallback callback) {
scoped_refptr<DirectoryReader> reader(
Resource::GetAs<DirectoryReader>(reader_id));
scoped_refptr<PPB_DirectoryReader_Impl> reader(
Resource::GetAs<PPB_DirectoryReader_Impl>(reader_id));
if (!reader)
return PP_ERROR_BADRESOURCE;
@ -75,26 +76,29 @@ const PPB_DirectoryReader_Dev ppb_directoryreader = {
} // namespace
DirectoryReader::DirectoryReader(FileRef* directory_ref)
PPB_DirectoryReader_Impl::PPB_DirectoryReader_Impl(
PPB_FileRef_Impl* directory_ref)
: Resource(directory_ref->module()),
directory_ref_(directory_ref),
has_more_(true),
entry_(NULL) {
}
DirectoryReader::~DirectoryReader() {
PPB_DirectoryReader_Impl::~PPB_DirectoryReader_Impl() {
}
const PPB_DirectoryReader_Dev* DirectoryReader::GetInterface() {
const PPB_DirectoryReader_Dev* PPB_DirectoryReader_Impl::GetInterface() {
return &ppb_directoryreader;
}
DirectoryReader* DirectoryReader::AsDirectoryReader() {
PPB_DirectoryReader_Impl*
PPB_DirectoryReader_Impl::AsPPB_DirectoryReader_Impl() {
return this;
}
int32_t DirectoryReader::GetNextEntry(PP_DirectoryEntry_Dev* entry,
PP_CompletionCallback callback) {
int32_t PPB_DirectoryReader_Impl::GetNextEntry(
PP_DirectoryEntry_Dev* entry,
PP_CompletionCallback callback) {
if (directory_ref_->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
return PP_ERROR_FAILED;
@ -114,7 +118,7 @@ int32_t DirectoryReader::GetNextEntry(PP_DirectoryEntry_Dev* entry,
return PP_ERROR_WOULDBLOCK;
}
void DirectoryReader::AddNewEntries(
void PPB_DirectoryReader_Impl::AddNewEntries(
const std::vector<base::FileUtilProxy::Entry>& entries, bool has_more) {
DCHECK(!entries.empty());
has_more_ = has_more;
@ -134,15 +138,16 @@ void DirectoryReader::AddNewEntries(
entry_ = NULL;
}
bool DirectoryReader::FillUpEntry() {
bool PPB_DirectoryReader_Impl::FillUpEntry() {
DCHECK(entry_);
if (!entries_.empty()) {
base::FileUtilProxy::Entry dir_entry = entries_.front();
entries_.pop();
if (entry_->file_ref)
ResourceTracker::Get()->UnrefResource(entry_->file_ref);
FileRef* file_ref = new FileRef(module(), directory_ref_->GetFileSystem(),
FilePathStringToUTF8String(dir_entry.name));
PPB_FileRef_Impl* file_ref =
new PPB_FileRef_Impl(module(), directory_ref_->GetFileSystem(),
FilePathStringToUTF8String(dir_entry.name));
entry_->file_ref = file_ref->GetReference();
entry_->file_type =
(dir_entry.is_directory ? PP_FILETYPE_DIRECTORY : PP_FILETYPE_REGULAR);
@ -157,4 +162,6 @@ bool DirectoryReader::FillUpEntry() {
return false;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,33 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_DIRECTORY_READER_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_DIRECTORY_READER_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_DIRECTORY_READER_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_DIRECTORY_READER_IMPL_H_
#include <queue>
#include "base/file_util_proxy.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/resource.h"
struct PP_CompletionCallback;
struct PP_DirectoryEntry_Dev;
struct PPB_DirectoryReader_Dev;
namespace pepper {
namespace webkit {
namespace ppapi {
class FileRef;
class PPB_FileRef_Impl;
class DirectoryReader : public Resource {
class PPB_DirectoryReader_Impl : public Resource {
public:
explicit DirectoryReader(FileRef* directory_ref);
virtual ~DirectoryReader();
explicit PPB_DirectoryReader_Impl(PPB_FileRef_Impl* directory_ref);
virtual ~PPB_DirectoryReader_Impl();
// Returns a pointer to the interface implementing PPB_DirectoryReader that
// is exposed to the plugin.
static const PPB_DirectoryReader_Dev* GetInterface();
// Resource overrides.
virtual DirectoryReader* AsDirectoryReader();
virtual PPB_DirectoryReader_Impl* AsPPB_DirectoryReader_Impl();
// PPB_DirectoryReader implementation.
int32_t GetNextEntry(PP_DirectoryEntry_Dev* entry,
@ -40,12 +41,13 @@ class DirectoryReader : public Resource {
private:
bool FillUpEntry();
scoped_refptr<FileRef> directory_ref_;
scoped_refptr<PPB_FileRef_Impl> directory_ref_;
std::queue<base::FileUtilProxy::Entry> entries_;
bool has_more_;
PP_DirectoryEntry_Dev* entry_;
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_DIRECTORY_READER_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_DIRECTORY_READER_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_file_chooser.h"
#include "webkit/plugins/ppapi/ppb_file_chooser_impl.h"
#include <string>
#include <vector>
@ -15,11 +15,11 @@
#include "third_party/WebKit/WebKit/chromium/public/WebFileChooserParams.h"
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_file_ref.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_resource_tracker.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebCString;
@ -28,7 +28,8 @@ using WebKit::WebFileChooserParams;
using WebKit::WebString;
using WebKit::WebVector;
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -42,17 +43,17 @@ PP_Resource Create(PP_Instance instance_id,
(options->mode != PP_FILECHOOSERMODE_OPENMULTIPLE))
return 0;
FileChooser* chooser = new FileChooser(instance, options);
PPB_FileChooser_Impl* chooser = new PPB_FileChooser_Impl(instance, options);
return chooser->GetReference();
}
PP_Bool IsFileChooser(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<FileChooser>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_FileChooser_Impl>(resource));
}
int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) {
scoped_refptr<FileChooser> chooser(
Resource::GetAs<FileChooser>(chooser_id));
scoped_refptr<PPB_FileChooser_Impl> chooser(
Resource::GetAs<PPB_FileChooser_Impl>(chooser_id));
if (!chooser)
return PP_ERROR_BADRESOURCE;
@ -60,12 +61,12 @@ int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) {
}
PP_Resource GetNextChosenFile(PP_Resource chooser_id) {
scoped_refptr<FileChooser> chooser(
Resource::GetAs<FileChooser>(chooser_id));
scoped_refptr<PPB_FileChooser_Impl> chooser(
Resource::GetAs<PPB_FileChooser_Impl>(chooser_id));
if (!chooser)
return 0;
scoped_refptr<FileRef> file_ref(chooser->GetNextChosenFile());
scoped_refptr<PPB_FileRef_Impl> file_ref(chooser->GetNextChosenFile());
if (!file_ref)
return 0;
@ -81,7 +82,7 @@ const PPB_FileChooser_Dev ppb_filechooser = {
class FileChooserCompletionImpl : public WebFileChooserCompletion {
public:
FileChooserCompletionImpl(pepper::FileChooser* file_chooser)
FileChooserCompletionImpl(PPB_FileChooser_Impl* file_chooser)
: file_chooser_(file_chooser) {
DCHECK(file_chooser_);
}
@ -97,12 +98,12 @@ class FileChooserCompletionImpl : public WebFileChooserCompletion {
}
private:
FileChooser* file_chooser_;
PPB_FileChooser_Impl* file_chooser_;
};
} // namespace
FileChooser::FileChooser(PluginInstance* instance,
PPB_FileChooser_Impl::PPB_FileChooser_Impl(PluginInstance* instance,
const PP_FileChooserOptions_Dev* options)
: Resource(instance->module()),
delegate_(instance->delegate()),
@ -111,25 +112,26 @@ FileChooser::FileChooser(PluginInstance* instance,
completion_callback_() {
}
FileChooser::~FileChooser() {
PPB_FileChooser_Impl::~PPB_FileChooser_Impl() {
}
// static
const PPB_FileChooser_Dev* FileChooser::GetInterface() {
const PPB_FileChooser_Dev* PPB_FileChooser_Impl::GetInterface() {
return &ppb_filechooser;
}
FileChooser* FileChooser::AsFileChooser() {
PPB_FileChooser_Impl* PPB_FileChooser_Impl::AsPPB_FileChooser_Impl() {
return this;
}
void FileChooser::StoreChosenFiles(const std::vector<std::string>& files) {
void PPB_FileChooser_Impl::StoreChosenFiles(
const std::vector<std::string>& files) {
next_chosen_file_index_ = 0;
std::vector<std::string>::const_iterator end_it = files.end();
for (std::vector<std::string>::const_iterator it = files.begin();
it != end_it; it++) {
chosen_files_.push_back(make_scoped_refptr(
new FileRef(module(), FilePath().AppendASCII(*it))));
new PPB_FileRef_Impl(module(), FilePath().AppendASCII(*it))));
}
if (!completion_callback_.func)
@ -140,7 +142,7 @@ void FileChooser::StoreChosenFiles(const std::vector<std::string>& files) {
PP_RunCompletionCallback(&callback, 0);
}
int32_t FileChooser::Show(PP_CompletionCallback callback) {
int32_t PPB_FileChooser_Impl::Show(PP_CompletionCallback callback) {
DCHECK((mode_ == PP_FILECHOOSERMODE_OPEN) ||
(mode_ == PP_FILECHOOSERMODE_OPENMULTIPLE));
DCHECK(!completion_callback_.func);
@ -155,11 +157,13 @@ int32_t FileChooser::Show(PP_CompletionCallback callback) {
params, new FileChooserCompletionImpl(this));
}
scoped_refptr<FileRef> FileChooser::GetNextChosenFile() {
scoped_refptr<PPB_FileRef_Impl> PPB_FileChooser_Impl::GetNextChosenFile() {
if (next_chosen_file_index_ >= chosen_files_.size())
return NULL;
return chosen_files_[next_chosen_file_index_++];
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FILE_CHOOSER_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_FILE_CHOOSER_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_
#include <string>
#include <vector>
@ -11,42 +11,45 @@
#include "base/scoped_ptr.h"
#include "ppapi/c/dev/ppb_file_chooser_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/resource.h"
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginDelegate;
class PluginInstance;
class PPB_FileRef_Impl;
class FileChooser : public Resource {
class PPB_FileChooser_Impl : public Resource {
public:
FileChooser(PluginInstance* instance,
PPB_FileChooser_Impl(PluginInstance* instance,
const PP_FileChooserOptions_Dev* options);
virtual ~FileChooser();
virtual ~PPB_FileChooser_Impl();
// Returns a pointer to the interface implementing PPB_FileChooser that is
// exposed to the plugin.
static const PPB_FileChooser_Dev* GetInterface();
// Resource overrides.
virtual FileChooser* AsFileChooser();
virtual PPB_FileChooser_Impl* AsPPB_FileChooser_Impl();
// Stores the list of selected files.
void StoreChosenFiles(const std::vector<std::string>& files);
// PPB_FileChooser implementation.
int32_t Show(PP_CompletionCallback callback);
scoped_refptr<FileRef> GetNextChosenFile();
scoped_refptr<PPB_FileRef_Impl> GetNextChosenFile();
private:
PluginDelegate* delegate_;
PP_FileChooserMode_Dev mode_;
std::string accept_mime_types_;
PP_CompletionCallback completion_callback_;
std::vector< scoped_refptr<FileRef> > chosen_files_;
std::vector< scoped_refptr<PPB_FileRef_Impl> > chosen_files_;
size_t next_chosen_file_index_;
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FILE_CHOOSER_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_CHOOSER_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_file_io.h"
#include "webkit/plugins/ppapi/ppb_file_io_impl.h"
#include "base/callback.h"
#include "base/file_util.h"
@ -15,13 +15,14 @@
#include "ppapi/c/dev/ppb_file_io_trusted_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_errors.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_file_ref.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_resource_tracker.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -30,23 +31,24 @@ PP_Resource Create(PP_Module module_id) {
if (!module)
return 0;
FileIO* file_io = new FileIO(module);
PPB_FileIO_Impl* file_io = new PPB_FileIO_Impl(module);
return file_io->GetReference();
}
PP_Bool IsFileIO(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<FileIO>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_FileIO_Impl>(resource));
}
int32_t Open(PP_Resource file_io_id,
PP_Resource file_ref_id,
int32_t open_flags,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_ERROR_BADRESOURCE;
@ -56,7 +58,7 @@ int32_t Open(PP_Resource file_io_id,
int32_t Query(PP_Resource file_io_id,
PP_FileInfo_Dev* info,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Query(info, callback);
@ -66,7 +68,7 @@ int32_t Touch(PP_Resource file_io_id,
PP_Time last_access_time,
PP_Time last_modified_time,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Touch(last_access_time, last_modified_time, callback);
@ -77,7 +79,7 @@ int32_t Read(PP_Resource file_io_id,
char* buffer,
int32_t bytes_to_read,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Read(offset, buffer, bytes_to_read, callback);
@ -88,7 +90,7 @@ int32_t Write(PP_Resource file_io_id,
const char* buffer,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Write(offset, buffer, bytes_to_write, callback);
@ -97,7 +99,7 @@ int32_t Write(PP_Resource file_io_id,
int32_t SetLength(PP_Resource file_io_id,
int64_t length,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->SetLength(length, callback);
@ -105,14 +107,14 @@ int32_t SetLength(PP_Resource file_io_id,
int32_t Flush(PP_Resource file_io_id,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->Flush(callback);
}
void Close(PP_Resource file_io_id) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return;
file_io->Close();
@ -132,7 +134,7 @@ const PPB_FileIO_Dev ppb_fileio = {
};
int32_t GetOSFileDescriptor(PP_Resource file_io_id) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->GetOSFileDescriptor();
@ -142,7 +144,7 @@ int32_t WillWrite(PP_Resource file_io_id,
int64_t offset,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->WillWrite(offset, bytes_to_write, callback);
@ -151,7 +153,7 @@ int32_t WillWrite(PP_Resource file_io_id,
int32_t WillSetLength(PP_Resource file_io_id,
int64_t length,
PP_CompletionCallback callback) {
scoped_refptr<FileIO> file_io(Resource::GetAs<FileIO>(file_io_id));
scoped_refptr<PPB_FileIO_Impl> file_io(Resource::GetAs<PPB_FileIO_Impl>(file_io_id));
if (!file_io)
return PP_ERROR_BADRESOURCE;
return file_io->WillSetLength(length, callback);
@ -187,7 +189,7 @@ int PlatformFileErrorToPepperError(base::PlatformFileError error_code) {
} // namespace
FileIO::FileIO(PluginModule* module)
PPB_FileIO_Impl::PPB_FileIO_Impl(PluginModule* module)
: Resource(module),
delegate_(module->GetSomeInstance()->delegate()),
ALLOW_THIS_IN_INITIALIZER_LIST(callback_factory_(this)),
@ -196,27 +198,27 @@ FileIO::FileIO(PluginModule* module)
info_(NULL) {
}
FileIO::~FileIO() {
PPB_FileIO_Impl::~PPB_FileIO_Impl() {
Close();
}
// static
const PPB_FileIO_Dev* FileIO::GetInterface() {
const PPB_FileIO_Dev* PPB_FileIO_Impl::GetInterface() {
return &ppb_fileio;
}
// static
const PPB_FileIOTrusted_Dev* FileIO::GetTrustedInterface() {
const PPB_FileIOTrusted_Dev* PPB_FileIO_Impl::GetTrustedInterface() {
return &ppb_fileiotrusted;
}
FileIO* FileIO::AsFileIO() {
PPB_FileIO_Impl* PPB_FileIO_Impl::AsPPB_FileIO_Impl() {
return this;
}
int32_t FileIO::Open(FileRef* file_ref,
int32_t open_flags,
PP_CompletionCallback callback) {
int32_t PPB_FileIO_Impl::Open(PPB_FileRef_Impl* file_ref,
int32_t open_flags,
PP_CompletionCallback callback) {
if (file_ != base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@ -245,14 +247,14 @@ int32_t FileIO::Open(FileRef* file_ref,
file_system_type_ = file_ref->GetFileSystemType();
if (!delegate_->AsyncOpenFile(
file_ref->GetSystemPath(), flags,
callback_factory_.NewCallback(&FileIO::AsyncOpenFileCallback)))
callback_factory_.NewCallback(&PPB_FileIO_Impl::AsyncOpenFileCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
int32_t FileIO::Query(PP_FileInfo_Dev* info,
PP_CompletionCallback callback) {
int32_t PPB_FileIO_Impl::Query(PP_FileInfo_Dev* info,
PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@ -265,13 +267,13 @@ int32_t FileIO::Query(PP_FileInfo_Dev* info,
if (!base::FileUtilProxy::GetFileInfoFromPlatformFile(
delegate_->GetFileThreadMessageLoopProxy(), file_,
callback_factory_.NewCallback(&FileIO::QueryInfoCallback)))
callback_factory_.NewCallback(&PPB_FileIO_Impl::QueryInfoCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
int32_t FileIO::Touch(PP_Time last_access_time,
int32_t PPB_FileIO_Impl::Touch(PP_Time last_access_time,
PP_Time last_modified_time,
PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
@ -284,16 +286,16 @@ int32_t FileIO::Touch(PP_Time last_access_time,
delegate_->GetFileThreadMessageLoopProxy(),
file_, base::Time::FromDoubleT(last_access_time),
base::Time::FromDoubleT(last_modified_time),
callback_factory_.NewCallback(&FileIO::StatusCallback)))
callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
int32_t FileIO::Read(int64_t offset,
char* buffer,
int32_t bytes_to_read,
PP_CompletionCallback callback) {
int32_t PPB_FileIO_Impl::Read(int64_t offset,
char* buffer,
int32_t bytes_to_read,
PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@ -303,16 +305,16 @@ int32_t FileIO::Read(int64_t offset,
if (!base::FileUtilProxy::Read(
delegate_->GetFileThreadMessageLoopProxy(),
file_, offset, buffer, bytes_to_read,
callback_factory_.NewCallback(&FileIO::ReadWriteCallback)))
callback_factory_.NewCallback(&PPB_FileIO_Impl::ReadWriteCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
int32_t FileIO::Write(int64_t offset,
const char* buffer,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
int32_t PPB_FileIO_Impl::Write(int64_t offset,
const char* buffer,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@ -322,13 +324,13 @@ int32_t FileIO::Write(int64_t offset,
if (!base::FileUtilProxy::Write(
delegate_->GetFileThreadMessageLoopProxy(),
file_, offset, buffer, bytes_to_write,
callback_factory_.NewCallback(&FileIO::ReadWriteCallback)))
callback_factory_.NewCallback(&PPB_FileIO_Impl::ReadWriteCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
int32_t FileIO::SetLength(int64_t length,
int32_t PPB_FileIO_Impl::SetLength(int64_t length,
PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@ -339,13 +341,13 @@ int32_t FileIO::SetLength(int64_t length,
if (!base::FileUtilProxy::Truncate(
delegate_->GetFileThreadMessageLoopProxy(),
file_, length,
callback_factory_.NewCallback(&FileIO::StatusCallback)))
callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
int32_t FileIO::Flush(PP_CompletionCallback callback) {
int32_t PPB_FileIO_Impl::Flush(PP_CompletionCallback callback) {
if (file_ == base::kInvalidPlatformFileValue)
return PP_ERROR_FAILED;
@ -354,19 +356,19 @@ int32_t FileIO::Flush(PP_CompletionCallback callback) {
if (!base::FileUtilProxy::Flush(
delegate_->GetFileThreadMessageLoopProxy(), file_,
callback_factory_.NewCallback(&FileIO::StatusCallback)))
callback_factory_.NewCallback(&PPB_FileIO_Impl::StatusCallback)))
return PP_ERROR_FAILED;
return PP_ERROR_WOULDBLOCK;
}
void FileIO::Close() {
void PPB_FileIO_Impl::Close() {
if (file_ != base::kInvalidPlatformFileValue)
base::FileUtilProxy::Close(
delegate_->GetFileThreadMessageLoopProxy(), file_, NULL);
}
int32_t FileIO::GetOSFileDescriptor() {
int32_t PPB_FileIO_Impl::GetOSFileDescriptor() {
#if defined(OS_POSIX)
return file_;
#elif defined(OS_WIN)
@ -376,20 +378,20 @@ int32_t FileIO::GetOSFileDescriptor() {
#endif
}
int32_t FileIO::WillWrite(int64_t offset,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
int32_t PPB_FileIO_Impl::WillWrite(int64_t offset,
int32_t bytes_to_write,
PP_CompletionCallback callback) {
// TODO(dumi): implement me
return PP_OK;
}
int32_t FileIO::WillSetLength(int64_t length,
PP_CompletionCallback callback) {
int32_t PPB_FileIO_Impl::WillSetLength(int64_t length,
PP_CompletionCallback callback) {
// TODO(dumi): implement me
return PP_OK;
}
void FileIO::RunPendingCallback(int result) {
void PPB_FileIO_Impl::RunPendingCallback(int result) {
if (!callback_.func)
return;
@ -398,19 +400,21 @@ void FileIO::RunPendingCallback(int result) {
PP_RunCompletionCallback(&callback, result);
}
void FileIO::StatusCallback(base::PlatformFileError error_code) {
void PPB_FileIO_Impl::StatusCallback(base::PlatformFileError error_code) {
RunPendingCallback(PlatformFileErrorToPepperError(error_code));
}
void FileIO::AsyncOpenFileCallback(base::PlatformFileError error_code,
base::PlatformFile file) {
void PPB_FileIO_Impl::AsyncOpenFileCallback(
base::PlatformFileError error_code,
base::PlatformFile file) {
DCHECK(file_ == base::kInvalidPlatformFileValue);
file_ = file;
RunPendingCallback(PlatformFileErrorToPepperError(error_code));
}
void FileIO::QueryInfoCallback(base::PlatformFileError error_code,
const base::PlatformFileInfo& file_info) {
void PPB_FileIO_Impl::QueryInfoCallback(
base::PlatformFileError error_code,
const base::PlatformFileInfo& file_info) {
DCHECK(info_);
if (error_code == base::PLATFORM_FILE_OK) {
info_->size = file_info.size;
@ -426,12 +430,14 @@ void FileIO::QueryInfoCallback(base::PlatformFileError error_code,
RunPendingCallback(PlatformFileErrorToPepperError(error_code));
}
void FileIO::ReadWriteCallback(base::PlatformFileError error_code,
int bytes_read_or_written) {
void PPB_FileIO_Impl::ReadWriteCallback(base::PlatformFileError error_code,
int bytes_read_or_written) {
if (error_code != base::PLATFORM_FILE_OK)
RunPendingCallback(PlatformFileErrorToPepperError(error_code));
else
RunPendingCallback(bytes_read_or_written);
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FILE_IO_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_FILE_IO_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_
#include "base/basictypes.h"
#include "base/file_path.h"
#include "base/platform_file.h"
#include "base/scoped_callback_factory.h"
@ -12,21 +13,23 @@
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/pp_time.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/resource.h"
struct PP_CompletionCallback;
struct PPB_FileIO_Dev;
struct PPB_FileIOTrusted_Dev;
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginModule;
class PPB_FileRef_Impl;
class FileIO : public Resource {
class PPB_FileIO_Impl : public Resource {
public:
explicit FileIO(PluginModule* module);
virtual ~FileIO();
explicit PPB_FileIO_Impl(PluginModule* module);
virtual ~PPB_FileIO_Impl();
// Returns a pointer to the interface implementing PPB_FileIO that is exposed
// to the plugin.
@ -37,10 +40,10 @@ class FileIO : public Resource {
static const PPB_FileIOTrusted_Dev* GetTrustedInterface();
// Resource overrides.
virtual FileIO* AsFileIO();
virtual PPB_FileIO_Impl* AsPPB_FileIO_Impl();
// PPB_FileIO implementation.
int32_t Open(FileRef* file_ref,
int32_t Open(PPB_FileRef_Impl* file_ref,
int32_t open_flags,
PP_CompletionCallback callback);
int32_t Query(PP_FileInfo_Dev* info,
@ -80,15 +83,18 @@ class FileIO : public Resource {
private:
PluginDelegate* delegate_;
base::ScopedCallbackFactory<FileIO> callback_factory_;
base::ScopedCallbackFactory<PPB_FileIO_Impl> callback_factory_;
base::PlatformFile file_;
PP_FileSystemType_Dev file_system_type_;
PP_CompletionCallback callback_;
PP_FileInfo_Dev* info_;
DISALLOW_COPY_AND_ASSIGN(PPB_FileIO_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FILE_IO_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_IO_IMPL_H_

@ -2,21 +2,22 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_file_ref.h"
#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "ppapi/c/pp_errors.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_directory_reader.h"
#include "webkit/glue/plugins/pepper_file_callbacks.h"
#include "webkit/glue/plugins/pepper_file_system.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/file_callbacks.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "webkit/plugins/ppapi/var.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -40,8 +41,8 @@ void TrimTrailingSlash(std::string* path) {
}
PP_Resource Create(PP_Resource file_system_id, const char* path) {
scoped_refptr<FileSystem> file_system(
Resource::GetAs<FileSystem>(file_system_id));
scoped_refptr<PPB_FileSystem_Impl> file_system(
Resource::GetAs<PPB_FileSystem_Impl>(file_system_id));
if (!file_system)
return 0;
@ -53,32 +54,35 @@ PP_Resource Create(PP_Resource file_system_id, const char* path) {
return 0;
TrimTrailingSlash(&validated_path);
FileRef* file_ref = new FileRef(file_system->instance()->module(),
file_system,
validated_path);
PPB_FileRef_Impl* file_ref =
new PPB_FileRef_Impl(file_system->instance()->module(),
file_system, validated_path);
return file_ref->GetReference();
}
PP_Bool IsFileRef(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<FileRef>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_FileRef_Impl>(resource));
}
PP_FileSystemType_Dev GetFileSystemType(PP_Resource file_ref_id) {
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_FILESYSTEMTYPE_EXTERNAL;
return file_ref->GetFileSystemType();
}
PP_Var GetName(PP_Resource file_ref_id) {
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_MakeUndefined();
return StringVar::StringToPPVar(file_ref->module(), file_ref->GetName());
}
PP_Var GetPath(PP_Resource file_ref_id) {
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_MakeUndefined();
@ -89,14 +93,15 @@ PP_Var GetPath(PP_Resource file_ref_id) {
}
PP_Resource GetParent(PP_Resource file_ref_id) {
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return 0;
if (file_ref->GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
return 0;
scoped_refptr<FileRef> parent_ref(file_ref->GetParent());
scoped_refptr<PPB_FileRef_Impl> parent_ref(file_ref->GetParent());
if (!parent_ref)
return 0;
@ -106,12 +111,12 @@ PP_Resource GetParent(PP_Resource file_ref_id) {
int32_t MakeDirectory(PP_Resource directory_ref_id,
PP_Bool make_ancestors,
PP_CompletionCallback callback) {
scoped_refptr<FileRef> directory_ref(
Resource::GetAs<FileRef>(directory_ref_id));
scoped_refptr<PPB_FileRef_Impl> directory_ref(
Resource::GetAs<PPB_FileRef_Impl>(directory_ref_id));
if (!directory_ref)
return PP_ERROR_BADRESOURCE;
scoped_refptr<FileSystem> file_system = directory_ref->GetFileSystem();
scoped_refptr<PPB_FileSystem_Impl> file_system = directory_ref->GetFileSystem();
if (!file_system || !file_system->opened() ||
(file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
return PP_ERROR_NOACCESS;
@ -129,11 +134,12 @@ int32_t MakeDirectory(PP_Resource directory_ref_id,
int32_t Query(PP_Resource file_ref_id,
PP_FileInfo_Dev* info,
PP_CompletionCallback callback) {
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_ERROR_BADRESOURCE;
scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem();
scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
if (!file_system || !file_system->opened() ||
(file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
return PP_ERROR_NOACCESS;
@ -152,11 +158,12 @@ int32_t Touch(PP_Resource file_ref_id,
PP_Time last_access_time,
PP_Time last_modified_time,
PP_CompletionCallback callback) {
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_ERROR_BADRESOURCE;
scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem();
scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
if (!file_system || !file_system->opened() ||
(file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
return PP_ERROR_NOACCESS;
@ -174,11 +181,12 @@ int32_t Touch(PP_Resource file_ref_id,
int32_t Delete(PP_Resource file_ref_id,
PP_CompletionCallback callback) {
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_ERROR_BADRESOURCE;
scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem();
scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
if (!file_system || !file_system->opened() ||
(file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
return PP_ERROR_NOACCESS;
@ -196,16 +204,17 @@ int32_t Delete(PP_Resource file_ref_id,
int32_t Rename(PP_Resource file_ref_id,
PP_Resource new_file_ref_id,
PP_CompletionCallback callback) {
scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id));
scoped_refptr<PPB_FileRef_Impl> file_ref(
Resource::GetAs<PPB_FileRef_Impl>(file_ref_id));
if (!file_ref)
return PP_ERROR_BADRESOURCE;
scoped_refptr<FileRef> new_file_ref(
Resource::GetAs<FileRef>(new_file_ref_id));
scoped_refptr<PPB_FileRef_Impl> new_file_ref(
Resource::GetAs<PPB_FileRef_Impl>(new_file_ref_id));
if (!new_file_ref)
return PP_ERROR_BADRESOURCE;
scoped_refptr<FileSystem> file_system = file_ref->GetFileSystem();
scoped_refptr<PPB_FileSystem_Impl> file_system = file_ref->GetFileSystem();
if (!file_system || !file_system->opened() ||
(file_system != new_file_ref->GetFileSystem()) ||
(file_system->type() == PP_FILESYSTEMTYPE_EXTERNAL))
@ -237,39 +246,39 @@ const PPB_FileRef_Dev ppb_fileref = {
} // namespace
FileRef::FileRef()
PPB_FileRef_Impl::PPB_FileRef_Impl()
: Resource(NULL),
file_system_(NULL) {
}
FileRef::FileRef(PluginModule* module,
scoped_refptr<FileSystem> file_system,
PPB_FileRef_Impl::PPB_FileRef_Impl(PluginModule* module,
scoped_refptr<PPB_FileSystem_Impl> file_system,
const std::string& validated_path)
: Resource(module),
file_system_(file_system),
virtual_path_(validated_path) {
}
FileRef::FileRef(PluginModule* module,
PPB_FileRef_Impl::PPB_FileRef_Impl(PluginModule* module,
const FilePath& external_file_path)
: Resource(module),
file_system_(NULL),
system_path_(external_file_path) {
}
FileRef::~FileRef() {
PPB_FileRef_Impl::~PPB_FileRef_Impl() {
}
// static
const PPB_FileRef_Dev* FileRef::GetInterface() {
const PPB_FileRef_Dev* PPB_FileRef_Impl::GetInterface() {
return &ppb_fileref;
}
FileRef* FileRef::AsFileRef() {
PPB_FileRef_Impl* PPB_FileRef_Impl::AsPPB_FileRef_Impl() {
return this;
}
std::string FileRef::GetName() const {
std::string PPB_FileRef_Impl::GetName() const {
if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL) {
FilePath::StringType path = system_path_.value();
size_t pos = path.rfind(FilePath::kSeparators[0]);
@ -293,9 +302,9 @@ std::string FileRef::GetName() const {
return virtual_path_.substr(pos + 1);
}
scoped_refptr<FileRef> FileRef::GetParent() {
scoped_refptr<PPB_FileRef_Impl> PPB_FileRef_Impl::GetParent() {
if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
return new FileRef();
return new PPB_FileRef_Impl();
// There should always be a leading slash at least!
size_t pos = virtual_path_.rfind('/');
@ -306,26 +315,27 @@ scoped_refptr<FileRef> FileRef::GetParent() {
pos++;
std::string parent_path = virtual_path_.substr(0, pos);
FileRef* parent_ref = new FileRef(module(), file_system_, parent_path);
PPB_FileRef_Impl* parent_ref = new PPB_FileRef_Impl(module(), file_system_,
parent_path);
return parent_ref;
}
scoped_refptr<FileSystem> FileRef::GetFileSystem() const {
scoped_refptr<PPB_FileSystem_Impl> PPB_FileRef_Impl::GetFileSystem() const {
return file_system_;
}
PP_FileSystemType_Dev FileRef::GetFileSystemType() const {
PP_FileSystemType_Dev PPB_FileRef_Impl::GetFileSystemType() const {
if (!file_system_)
return PP_FILESYSTEMTYPE_EXTERNAL;
return file_system_->type();
}
std::string FileRef::GetPath() const {
std::string PPB_FileRef_Impl::GetPath() const {
return virtual_path_;
}
FilePath FileRef::GetSystemPath() const {
FilePath PPB_FileRef_Impl::GetSystemPath() const {
if (GetFileSystemType() == PP_FILESYSTEMTYPE_EXTERNAL)
return system_path_;
@ -344,4 +354,6 @@ FilePath FileRef::GetSystemPath() const {
return file_system_->root_path().Append(virtual_file_path);
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -0,0 +1,66 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_
#include <string>
#include "base/file_path.h"
#include "ppapi/c/dev/ppb_file_ref_dev.h"
#include "webkit/plugins/ppapi/resource.h"
namespace webkit {
namespace ppapi {
class PPB_FileSystem_Impl;
class PluginInstance;
class PluginModule;
class PPB_FileRef_Impl : public Resource {
public:
PPB_FileRef_Impl();
PPB_FileRef_Impl(PluginModule* module,
scoped_refptr<PPB_FileSystem_Impl> file_system,
const std::string& validated_path);
PPB_FileRef_Impl(PluginModule* module,
const FilePath& external_file_path);
virtual ~PPB_FileRef_Impl();
// Returns a pointer to the interface implementing PPB_FileRef that is
// exposed to the plugin.
static const PPB_FileRef_Dev* GetInterface();
// Resource overrides.
virtual PPB_FileRef_Impl* AsPPB_FileRef_Impl();
// PPB_FileRef implementation.
std::string GetName() const;
scoped_refptr<PPB_FileRef_Impl> GetParent();
// Returns the file system to which this PPB_FileRef_Impl belongs.
scoped_refptr<PPB_FileSystem_Impl> GetFileSystem() const;
// Returns the type of the file system to which this PPB_FileRef_Impl belongs.
PP_FileSystemType_Dev GetFileSystemType() const;
// Returns the virtual path (i.e., the path that the pepper plugin sees)
// corresponding to this file.
std::string GetPath() const;
// Returns the system path corresponding to this file.
FilePath GetSystemPath() const;
private:
scoped_refptr<PPB_FileSystem_Impl> file_system_;
std::string virtual_path_; // UTF-8 encoded
FilePath system_path_;
DISALLOW_COPY_AND_ASSIGN(PPB_FileRef_Impl);
};
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_REF_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_file_system.h"
#include "webkit/plugins/ppapi/ppb_file_system_impl.h"
#include "base/ref_counted.h"
#include "ppapi/c/dev/ppb_file_system_dev.h"
@ -12,15 +12,16 @@
#include "third_party/WebKit/WebKit/chromium/public/WebFrame.h"
#include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
#include "webkit/fileapi/file_system_types.h"
#include "webkit/glue/plugins/pepper_directory_reader.h"
#include "webkit/glue/plugins/pepper_file_callbacks.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/glue/plugins/pepper_resource_tracker.h"
#include "webkit/plugins/ppapi/file_callbacks.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_directory_reader_impl.h"
#include "webkit/plugins/ppapi/resource.h"
#include "webkit/plugins/ppapi/resource_tracker.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -30,15 +31,16 @@ PP_Resource Create(PP_Instance instance, PP_FileSystemType_Dev type) {
if (!plugin_instance)
return 0;
FileSystem* file_system = new FileSystem(plugin_instance, type);
PPB_FileSystem_Impl* file_system =
new PPB_FileSystem_Impl(plugin_instance, type);
return file_system->GetReference();
}
int32_t Open(PP_Resource file_system_id,
int64 expected_size,
PP_CompletionCallback callback) {
scoped_refptr<FileSystem> file_system(
Resource::GetAs<FileSystem>(file_system_id));
scoped_refptr<PPB_FileSystem_Impl> file_system(
Resource::GetAs<PPB_FileSystem_Impl>(file_system_id));
if (!file_system)
return PP_ERROR_BADRESOURCE;
@ -71,19 +73,22 @@ const PPB_FileSystem_Dev ppb_filesystem = {
} // namespace
FileSystem::FileSystem(PluginInstance* instance, PP_FileSystemType_Dev type)
PPB_FileSystem_Impl::PPB_FileSystem_Impl(PluginInstance* instance,
PP_FileSystemType_Dev type)
: Resource(instance->module()),
instance_(instance),
type_(type),
opened_(false) {
}
FileSystem* FileSystem::AsFileSystem() {
PPB_FileSystem_Impl* PPB_FileSystem_Impl::AsPPB_FileSystem_Impl() {
return this;
}
const PPB_FileSystem_Dev* FileSystem::GetInterface() {
const PPB_FileSystem_Dev* PPB_FileSystem_Impl::GetInterface() {
return &ppb_filesystem;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,28 +2,29 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FILE_SYSTEM_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_FILE_SYSTEM_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_FILE_SYSTEM_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_FILE_SYSTEM_IMPL_H_
#include "base/basictypes.h"
#include "base/file_path.h"
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/resource.h"
struct PPB_FileSystem_Dev;
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginInstance;
class FileSystem : public Resource {
class PPB_FileSystem_Impl : public Resource {
public:
// Returns a pointer to the interface implementing PPB_FileSystem that is
// exposed to the plugin.
static const PPB_FileSystem_Dev* GetInterface();
FileSystem(PluginInstance* instance, PP_FileSystemType_Dev type);
virtual FileSystem* AsFileSystem();
PPB_FileSystem_Impl(PluginInstance* instance, PP_FileSystemType_Dev type);
virtual PPB_FileSystem_Impl* AsPPB_FileSystem_Impl();
PluginInstance* instance() { return instance_; }
PP_FileSystemType_Dev type() { return type_; }
@ -37,8 +38,11 @@ class FileSystem : public Resource {
PP_FileSystemType_Dev type_;
FilePath root_path_;
bool opened_;
DISALLOW_COPY_AND_ASSIGN(PPB_FileSystem_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FILE_SYSTEM_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_FILE_SYSTEM_IMPL_H_

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PPB_PRIVATE2_H_
#define WEBKIT_GLUE_PLUGINS_PPB_PRIVATE2_H_
#ifndef WEBKIT_PLUGINS_PEPPER_PPB_FLASH_H_
#define WEBKIT_PLUGINS_PEPPER_PPB_FLASH_H_
#ifdef _WIN32
#include <windows.h>
@ -17,7 +17,7 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
#define PPB_PRIVATE2_INTERFACE "PPB_Private2;4"
#define PPB_FLASH_INTERFACE "PPB_Flash;1"
#ifdef _WIN32
typedef HANDLE PP_FileHandle;
@ -40,7 +40,7 @@ struct PP_DirContents_Dev {
PP_DirEntry_Dev* entries;
};
struct PPB_Private2 {
struct PPB_Flash {
// Sets or clears the rendering hint that the given plugin instance is always
// on top of page content. Somewhat more optimized painting can be used in
// this case.
@ -114,4 +114,4 @@ struct PPB_Private2 {
const char* target);
};
#endif // WEBKIT_GLUE_PLUGINS_PPB_PRIVATE2_H_
#endif // WEBKIT_GLUE_PLUGINS_PPB_FLASH_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_private2.h"
#include "webkit/plugins/ppapi/ppb_flash_impl.h"
#include <string.h>
@ -12,14 +12,15 @@
#include "googleurl/src/gurl.h"
#include "ppapi/c/dev/pp_file_info_dev.h"
#include "ppapi/c/dev/ppb_file_io_dev.h"
#include "webkit/glue/plugins/pepper_error_util.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/glue/plugins/ppb_private2.h"
#include "webkit/plugins/ppapi/error_util.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_flash.h"
#include "webkit/plugins/ppapi/var.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -170,7 +171,7 @@ int32_t GetModuleLocalDirContents(PP_Module module,
return PP_ERROR_FAILED;
*contents = NULL;
PepperDirContents pepper_contents;
DirContents pepper_contents;
base::PlatformFileError result =
instance->delegate()->GetModuleLocalDirContents(
instance->module()->name(),
@ -219,9 +220,9 @@ bool NavigateToURL(PP_Instance pp_instance,
return instance->NavigateToURL(url, target);
}
const PPB_Private2 ppb_private2 = {
const PPB_Flash ppb_flash = {
&SetInstanceAlwaysOnTop,
&Private2::DrawGlyphs,
&PPB_Flash_Impl::DrawGlyphs,
&GetProxyForURL,
&OpenModuleLocalFile,
&RenameModuleLocalFile,
@ -236,8 +237,10 @@ const PPB_Private2 ppb_private2 = {
} // namespace
// static
const PPB_Private2* Private2::GetInterface() {
return &ppb_private2;
const PPB_Flash* PPB_Flash_Impl::GetInterface() {
return &ppb_flash;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,24 +2,26 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_PRIVATE2_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_PRIVATE2_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_FLASH_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_FLASH_IMPL_H_
#include "base/basictypes.h"
#include "build/build_config.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_rect.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/resource.h"
struct PP_FontDescription_Dev;
struct PPB_Private2;
struct PPB_Flash;
namespace pepper {
namespace webkit {
namespace ppapi {
class Private2 {
class PPB_Flash_Impl {
public:
// Returns a pointer to the interface implementing PPB_Private2 that is
// Returns a pointer to the interface implementing PPB_Flash that is
// exposed to the plugin.
static const PPB_Private2* GetInterface();
static const PPB_Flash* GetInterface();
static bool DrawGlyphs(PP_Resource pp_image_data,
const PP_FontDescription_Dev* font_desc,
@ -35,8 +37,12 @@ class Private2 {
#else
{ return false; }
#endif
private:
DISALLOW_COPY_AND_ASSIGN(PPB_Flash_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_PRIVATE2_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_FLASH_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_private2.h"
#include "webkit/plugins/ppapi/ppb_flash_impl.h"
#include "skia/ext/platform_canvas.h"
#include "ppapi/c/pp_point.h"
@ -14,22 +14,23 @@
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkTemplates.h"
#include "third_party/skia/include/core/SkTypeface.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/var.h"
namespace pepper {
namespace webkit {
namespace ppapi {
bool Private2::DrawGlyphs(PP_Resource pp_image_data,
const PP_FontDescription_Dev* font_desc,
uint32_t color,
PP_Point position,
PP_Rect clip,
const float transformation[3][3],
uint32_t glyph_count,
const uint16_t glyph_indices[],
const PP_Point glyph_advances[]) {
scoped_refptr<ImageData> image_resource(
Resource::GetAs<ImageData>(pp_image_data));
bool PPB_Flash_Impl::DrawGlyphs(PP_Resource pp_image_data,
const PP_FontDescription_Dev* font_desc,
uint32_t color,
PP_Point position,
PP_Rect clip,
const float transformation[3][3],
uint32_t glyph_count,
const uint16_t glyph_indices[],
const PP_Point glyph_advances[]) {
scoped_refptr<PPB_ImageData_Impl> image_resource(
Resource::GetAs<PPB_ImageData_Impl>(pp_image_data));
if (!image_resource.get())
return false;
ImageDataAutoMapper mapper(image_resource);
@ -106,5 +107,6 @@ bool Private2::DrawGlyphs(PP_Resource pp_image_data,
return true;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_font.h"
#include "webkit/plugins/ppapi/ppb_font_impl.h"
#include "base/logging.h"
#include "base/utf_string_conversions.h"
@ -14,11 +14,11 @@
#include "third_party/WebKit/WebKit/chromium/public/WebFloatPoint.h"
#include "third_party/WebKit/WebKit/chromium/public/WebFloatRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebTextRun.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_string.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/string.h"
#include "webkit/plugins/ppapi/var.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebFloatPoint;
@ -28,7 +28,8 @@ using WebKit::WebFontDescription;
using WebKit::WebRect;
using WebKit::WebTextRun;
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -117,18 +118,18 @@ PP_Resource Create(PP_Module module_id,
if (!IsPPFontDescriptionValid(*description))
return 0;
scoped_refptr<Font> font(new Font(module, *description));
scoped_refptr<PPB_Font_Impl> font(new PPB_Font_Impl(module, *description));
return font->GetReference();
}
PP_Bool IsFont(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<Font>(resource).get());
return BoolToPPBool(!!Resource::GetAs<PPB_Font_Impl>(resource).get());
}
PP_Bool Describe(PP_Resource font_id,
PP_FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) {
scoped_refptr<Font> font(Resource::GetAs<Font>(font_id));
PP_FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) {
scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id));
if (!font.get())
return PP_FALSE;
return BoolToPPBool(font->Describe(description, metrics));
@ -141,7 +142,7 @@ PP_Bool DrawTextAt(PP_Resource font_id,
uint32_t color,
const PP_Rect* clip,
PP_Bool image_data_is_opaque) {
scoped_refptr<Font> font(Resource::GetAs<Font>(font_id));
scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id));
if (!font.get())
return PP_FALSE;
return BoolToPPBool(font->DrawTextAt(image_data, text, position, color, clip,
@ -149,7 +150,7 @@ PP_Bool DrawTextAt(PP_Resource font_id,
}
int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) {
scoped_refptr<Font> font(Resource::GetAs<Font>(font_id));
scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id));
if (!font.get())
return -1;
return font->MeasureText(text);
@ -158,7 +159,7 @@ int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) {
uint32_t CharacterOffsetForPixel(PP_Resource font_id,
const PP_TextRun_Dev* text,
int32_t pixel_position) {
scoped_refptr<Font> font(Resource::GetAs<Font>(font_id));
scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id));
if (!font.get())
return false;
return font->CharacterOffsetForPixel(text, pixel_position);
@ -167,7 +168,7 @@ uint32_t CharacterOffsetForPixel(PP_Resource font_id,
int32_t PixelOffsetForCharacter(PP_Resource font_id,
const PP_TextRun_Dev* text,
uint32_t char_offset) {
scoped_refptr<Font> font(Resource::GetAs<Font>(font_id));
scoped_refptr<PPB_Font_Impl> font(Resource::GetAs<PPB_Font_Impl>(font_id));
if (!font.get())
return false;
return font->PixelOffsetForCharacter(text, char_offset);
@ -185,26 +186,27 @@ const PPB_Font_Dev ppb_font = {
} // namespace
Font::Font(PluginModule* module, const PP_FontDescription_Dev& desc)
PPB_Font_Impl::PPB_Font_Impl(PluginModule* module,
const PP_FontDescription_Dev& desc)
: Resource(module) {
WebFontDescription web_font_desc = PPFontDescToWebFontDesc(desc);
font_.reset(WebFont::create(web_font_desc));
}
Font::~Font() {
PPB_Font_Impl::~PPB_Font_Impl() {
}
// static
const PPB_Font_Dev* Font::GetInterface() {
const PPB_Font_Dev* PPB_Font_Impl::GetInterface() {
return &ppb_font;
}
Font* Font::AsFont() {
PPB_Font_Impl* PPB_Font_Impl::AsPPB_Font_Impl() {
return this;
}
bool Font::Describe(PP_FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) {
bool PPB_Font_Impl::Describe(PP_FontDescription_Dev* description,
PP_FontMetrics_Dev* metrics) {
if (description->face.type != PP_VARTYPE_UNDEFINED)
return false;
@ -229,19 +231,19 @@ bool Font::Describe(PP_FontDescription_Dev* description,
return true;
}
bool Font::DrawTextAt(PP_Resource image_data,
const PP_TextRun_Dev* text,
const PP_Point* position,
uint32_t color,
const PP_Rect* clip,
bool image_data_is_opaque) {
bool PPB_Font_Impl::DrawTextAt(PP_Resource image_data,
const PP_TextRun_Dev* text,
const PP_Point* position,
uint32_t color,
const PP_Rect* clip,
bool image_data_is_opaque) {
WebTextRun run;
if (!PPTextRunToWebTextRun(text, &run))
return false;
// Get and map the image data we're painting to.
scoped_refptr<ImageData> image_resource(
Resource::GetAs<ImageData>(image_data));
scoped_refptr<PPB_ImageData_Impl> image_resource(
Resource::GetAs<PPB_ImageData_Impl>(image_data));
if (!image_resource.get())
return false;
ImageDataAutoMapper mapper(image_resource);
@ -265,15 +267,15 @@ bool Font::DrawTextAt(PP_Resource image_data,
return true;
}
int32_t Font::MeasureText(const PP_TextRun_Dev* text) {
int32_t PPB_Font_Impl::MeasureText(const PP_TextRun_Dev* text) {
WebTextRun run;
if (!PPTextRunToWebTextRun(text, &run))
return -1;
return font_->calculateWidth(run);
}
uint32_t Font::CharacterOffsetForPixel(const PP_TextRun_Dev* text,
int32_t pixel_position) {
uint32_t PPB_Font_Impl::CharacterOffsetForPixel(const PP_TextRun_Dev* text,
int32_t pixel_position) {
WebTextRun run;
if (!PPTextRunToWebTextRun(text, &run))
return -1;
@ -282,8 +284,8 @@ uint32_t Font::CharacterOffsetForPixel(const PP_TextRun_Dev* text,
run, static_cast<float>(pixel_position)));
}
int32_t Font::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
uint32_t char_offset) {
int32_t PPB_Font_Impl::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
uint32_t char_offset) {
WebTextRun run;
if (!PPTextRunToWebTextRun(text, &run))
return -1;
@ -295,4 +297,6 @@ int32_t Font::PixelOffsetForCharacter(const PP_TextRun_Dev* text,
return static_cast<int>(rect.width);
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,32 +2,34 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_FONT_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_FONT_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_FONT_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_FONT_IMPL_H_
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "ppapi/c/dev/ppb_font_dev.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/resource.h"
namespace WebKit {
class WebFont;
}
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginInstance;
class Font : public Resource {
class PPB_Font_Impl : public Resource {
public:
Font(PluginModule* module, const PP_FontDescription_Dev& desc);
virtual ~Font();
PPB_Font_Impl(PluginModule* module, const PP_FontDescription_Dev& desc);
virtual ~PPB_Font_Impl();
// Returns a pointer to the interface implementing PPB_Font that is exposed to
// the plugin.
static const PPB_Font_Dev* GetInterface();
// Resource overrides.
virtual Font* AsFont();
virtual PPB_Font_Impl* AsPPB_Font_Impl();
// PPB_Font implementation.
bool Describe(PP_FontDescription_Dev* description,
@ -46,8 +48,11 @@ class Font : public Resource {
private:
scoped_ptr<WebKit::WebFont> font_;
DISALLOW_COPY_AND_ASSIGN(PPB_Font_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_FONT_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_FONT_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_graphics_2d.h"
#include "webkit/plugins/ppapi/ppb_graphics_2d_impl.h"
#include <iterator>
@ -19,17 +19,18 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/ppb_graphics_2d.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#if defined(OS_MACOSX)
#include "base/mac_util.h"
#include "base/mac/scoped_cftyperef.h"
#endif
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -81,11 +82,11 @@ void ConvertBetweenBGRAandRGBA(const uint32_t* input,
// Converts ImageData from PP_IMAGEDATAFORMAT_BGRA_PREMUL to
// PP_IMAGEDATAFORMAT_RGBA_PREMUL, or reverse.
void ConvertImageData(ImageData* src_image, const SkIRect& src_rect,
ImageData* dest_image, const SkRect& dest_rect) {
void ConvertImageData(PPB_ImageData_Impl* src_image, const SkIRect& src_rect,
PPB_ImageData_Impl* dest_image, const SkRect& dest_rect) {
DCHECK(src_image->format() != dest_image->format());
DCHECK(ImageData::IsImageDataFormatSupported(src_image->format()));
DCHECK(ImageData::IsImageDataFormatSupported(dest_image->format()));
DCHECK(PPB_ImageData_Impl::IsImageDataFormatSupported(src_image->format()));
DCHECK(PPB_ImageData_Impl::IsImageDataFormatSupported(dest_image->format()));
const SkBitmap* src_bitmap = src_image->GetMappedBitmap();
const SkBitmap* dest_bitmap = dest_image->GetMappedBitmap();
@ -118,21 +119,21 @@ PP_Resource Create(PP_Module module_id,
if (!module)
return 0;
scoped_refptr<Graphics2D> context(new Graphics2D(module));
scoped_refptr<PPB_Graphics2D_Impl> context(new PPB_Graphics2D_Impl(module));
if (!context->Init(size->width, size->height, PPBoolToBool(is_always_opaque)))
return 0;
return context->GetReference();
}
PP_Bool IsGraphics2D(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<Graphics2D>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_Graphics2D_Impl>(resource));
}
PP_Bool Describe(PP_Resource graphics_2d,
PP_Size* size,
PP_Bool* is_always_opaque) {
scoped_refptr<Graphics2D> context(
Resource::GetAs<Graphics2D>(graphics_2d));
scoped_refptr<PPB_Graphics2D_Impl> context(
Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d));
if (!context)
return PP_FALSE;
return context->Describe(size, is_always_opaque);
@ -142,8 +143,8 @@ void PaintImageData(PP_Resource graphics_2d,
PP_Resource image_data,
const PP_Point* top_left,
const PP_Rect* src_rect) {
scoped_refptr<Graphics2D> context(
Resource::GetAs<Graphics2D>(graphics_2d));
scoped_refptr<PPB_Graphics2D_Impl> context(
Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d));
if (context)
context->PaintImageData(image_data, top_left, src_rect);
}
@ -151,23 +152,23 @@ void PaintImageData(PP_Resource graphics_2d,
void Scroll(PP_Resource graphics_2d,
const PP_Rect* clip_rect,
const PP_Point* amount) {
scoped_refptr<Graphics2D> context(
Resource::GetAs<Graphics2D>(graphics_2d));
scoped_refptr<PPB_Graphics2D_Impl> context(
Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d));
if (context)
context->Scroll(clip_rect, amount);
}
void ReplaceContents(PP_Resource graphics_2d, PP_Resource image_data) {
scoped_refptr<Graphics2D> context(
Resource::GetAs<Graphics2D>(graphics_2d));
scoped_refptr<PPB_Graphics2D_Impl> context(
Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d));
if (context)
context->ReplaceContents(image_data);
}
int32_t Flush(PP_Resource graphics_2d,
PP_CompletionCallback callback) {
scoped_refptr<Graphics2D> context(
Resource::GetAs<Graphics2D>(graphics_2d));
scoped_refptr<PPB_Graphics2D_Impl> context(
Resource::GetAs<PPB_Graphics2D_Impl>(graphics_2d));
if (!context)
return PP_ERROR_BADRESOURCE;
return context->Flush(callback);
@ -185,7 +186,7 @@ const PPB_Graphics2D ppb_graphics_2d = {
} // namespace
struct Graphics2D::QueuedOperation {
struct PPB_Graphics2D_Impl::QueuedOperation {
enum Type {
PAINT,
SCROLL,
@ -203,7 +204,7 @@ struct Graphics2D::QueuedOperation {
Type type;
// Valid when type == PAINT.
scoped_refptr<ImageData> paint_image;
scoped_refptr<PPB_ImageData_Impl> paint_image;
int paint_x, paint_y;
gfx::Rect paint_src_rect;
@ -212,10 +213,10 @@ struct Graphics2D::QueuedOperation {
int scroll_dx, scroll_dy;
// Valid when type == REPLACE.
scoped_refptr<ImageData> replace_image;
scoped_refptr<PPB_ImageData_Impl> replace_image;
};
Graphics2D::Graphics2D(PluginModule* module)
PPB_Graphics2D_Impl::PPB_Graphics2D_Impl(PluginModule* module)
: Resource(module),
bound_instance_(NULL),
flushed_any_data_(false),
@ -223,19 +224,20 @@ Graphics2D::Graphics2D(PluginModule* module)
is_always_opaque_(false) {
}
Graphics2D::~Graphics2D() {
PPB_Graphics2D_Impl::~PPB_Graphics2D_Impl() {
}
// static
const PPB_Graphics2D* Graphics2D::GetInterface() {
const PPB_Graphics2D* PPB_Graphics2D_Impl::GetInterface() {
return &ppb_graphics_2d;
}
bool Graphics2D::Init(int width, int height, bool is_always_opaque) {
// The underlying ImageData will validate the dimensions.
image_data_ = new ImageData(module());
if (!image_data_->Init(ImageData::GetNativeImageDataFormat(), width, height,
true) || !image_data_->Map()) {
bool PPB_Graphics2D_Impl::Init(int width, int height, bool is_always_opaque) {
// The underlying PPB_ImageData_Impl will validate the dimensions.
image_data_ = new PPB_ImageData_Impl(module());
if (!image_data_->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
width, height, true) ||
!image_data_->Map()) {
image_data_ = NULL;
return false;
}
@ -243,25 +245,25 @@ bool Graphics2D::Init(int width, int height, bool is_always_opaque) {
return true;
}
Graphics2D* Graphics2D::AsGraphics2D() {
PPB_Graphics2D_Impl* PPB_Graphics2D_Impl::AsPPB_Graphics2D_Impl() {
return this;
}
PP_Bool Graphics2D::Describe(PP_Size* size, PP_Bool* is_always_opaque) {
PP_Bool PPB_Graphics2D_Impl::Describe(PP_Size* size, PP_Bool* is_always_opaque) {
size->width = image_data_->width();
size->height = image_data_->height();
*is_always_opaque = PP_FALSE; // TODO(brettw) implement this.
return PP_TRUE;
}
void Graphics2D::PaintImageData(PP_Resource image_data,
const PP_Point* top_left,
const PP_Rect* src_rect) {
void PPB_Graphics2D_Impl::PaintImageData(PP_Resource image_data,
const PP_Point* top_left,
const PP_Rect* src_rect) {
if (!top_left)
return;
scoped_refptr<ImageData> image_resource(
Resource::GetAs<ImageData>(image_data));
scoped_refptr<PPB_ImageData_Impl> image_resource(
Resource::GetAs<PPB_ImageData_Impl>(image_data));
if (!image_resource)
return;
@ -290,7 +292,8 @@ void Graphics2D::PaintImageData(PP_Resource image_data,
queued_operations_.push_back(operation);
}
void Graphics2D::Scroll(const PP_Rect* clip_rect, const PP_Point* amount) {
void PPB_Graphics2D_Impl::Scroll(const PP_Rect* clip_rect,
const PP_Point* amount) {
QueuedOperation operation(QueuedOperation::SCROLL);
if (!ValidateAndConvertRect(clip_rect,
image_data_->width(),
@ -312,12 +315,13 @@ void Graphics2D::Scroll(const PP_Rect* clip_rect, const PP_Point* amount) {
queued_operations_.push_back(operation);
}
void Graphics2D::ReplaceContents(PP_Resource image_data) {
scoped_refptr<ImageData> image_resource(
Resource::GetAs<ImageData>(image_data));
void PPB_Graphics2D_Impl::ReplaceContents(PP_Resource image_data) {
scoped_refptr<PPB_ImageData_Impl> image_resource(
Resource::GetAs<PPB_ImageData_Impl>(image_data));
if (!image_resource)
return;
if (!ImageData::IsImageDataFormatSupported(image_resource->format()))
if (!PPB_ImageData_Impl::IsImageDataFormatSupported(
image_resource->format()))
return;
if (image_resource->width() != image_data_->width() ||
@ -329,7 +333,7 @@ void Graphics2D::ReplaceContents(PP_Resource image_data) {
queued_operations_.push_back(operation);
}
int32_t Graphics2D::Flush(const PP_CompletionCallback& callback) {
int32_t PPB_Graphics2D_Impl::Flush(const PP_CompletionCallback& callback) {
// Don't allow more than one pending flush at a time.
if (HasPendingFlush())
return PP_ERROR_INPROGRESS;
@ -391,13 +395,15 @@ int32_t Graphics2D::Flush(const PP_CompletionCallback& callback) {
return PP_ERROR_WOULDBLOCK;
}
bool Graphics2D::ReadImageData(PP_Resource image,
const PP_Point* top_left) {
bool PPB_Graphics2D_Impl::ReadImageData(PP_Resource image,
const PP_Point* top_left) {
// Get and validate the image object to paint into.
scoped_refptr<ImageData> image_resource(Resource::GetAs<ImageData>(image));
scoped_refptr<PPB_ImageData_Impl> image_resource(
Resource::GetAs<PPB_ImageData_Impl>(image));
if (!image_resource)
return false;
if (!ImageData::IsImageDataFormatSupported(image_resource->format()))
if (!PPB_ImageData_Impl::IsImageDataFormatSupported(
image_resource->format()))
return false; // Must be in the right format.
// Validate the bitmap position.
@ -440,7 +446,7 @@ bool Graphics2D::ReadImageData(PP_Resource image,
return true;
}
bool Graphics2D::BindToInstance(PluginInstance* new_instance) {
bool PPB_Graphics2D_Impl::BindToInstance(PluginInstance* new_instance) {
if (bound_instance_ == new_instance)
return true; // Rebinding the same device, nothing to do.
if (bound_instance_ && new_instance)
@ -474,9 +480,9 @@ bool Graphics2D::BindToInstance(PluginInstance* new_instance) {
return true;
}
void Graphics2D::Paint(WebKit::WebCanvas* canvas,
const gfx::Rect& plugin_rect,
const gfx::Rect& paint_rect) {
void PPB_Graphics2D_Impl::Paint(WebKit::WebCanvas* canvas,
const gfx::Rect& plugin_rect,
const gfx::Rect& paint_rect) {
ImageDataAutoMapper auto_mapper(image_data_);
const SkBitmap& backing_bitmap = *image_data_->GetMappedBitmap();
@ -529,7 +535,7 @@ void Graphics2D::Paint(WebKit::WebCanvas* canvas,
#endif
}
void Graphics2D::ViewInitiatedPaint() {
void PPB_Graphics2D_Impl::ViewInitiatedPaint() {
// Move any "unpainted" callback to the painted state. See
// |unpainted_flush_callback_| in the header for more.
if (!unpainted_flush_callback_.is_null()) {
@ -538,7 +544,7 @@ void Graphics2D::ViewInitiatedPaint() {
}
}
void Graphics2D::ViewFlushedPaint() {
void PPB_Graphics2D_Impl::ViewFlushedPaint() {
// Notify any "painted" callback. See |unpainted_flush_callback_| in the
// header for more.
if (!painted_flush_callback_.is_null()) {
@ -551,10 +557,10 @@ void Graphics2D::ViewFlushedPaint() {
}
}
void Graphics2D::ExecutePaintImageData(ImageData* image,
int x, int y,
const gfx::Rect& src_rect,
gfx::Rect* invalidated_rect) {
void PPB_Graphics2D_Impl::ExecutePaintImageData(PPB_ImageData_Impl* image,
int x, int y,
const gfx::Rect& src_rect,
gfx::Rect* invalidated_rect) {
// Ensure the source image is mapped to read from it.
ImageDataAutoMapper auto_mapper(image);
if (!auto_mapper.is_valid())
@ -587,15 +593,16 @@ void Graphics2D::ExecutePaintImageData(ImageData* image,
}
}
void Graphics2D::ExecuteScroll(const gfx::Rect& clip, int dx, int dy,
gfx::Rect* invalidated_rect) {
void PPB_Graphics2D_Impl::ExecuteScroll(const gfx::Rect& clip,
int dx, int dy,
gfx::Rect* invalidated_rect) {
gfx::ScrollCanvas(image_data_->mapped_canvas(),
clip, gfx::Point(dx, dy));
*invalidated_rect = clip;
}
void Graphics2D::ExecuteReplaceContents(ImageData* image,
gfx::Rect* invalidated_rect) {
void PPB_Graphics2D_Impl::ExecuteReplaceContents(PPB_ImageData_Impl* image,
gfx::Rect* invalidated_rect) {
if (image->format() != image_data_->format()) {
DCHECK(image->width() == image_data_->width() &&
image->height() == image_data_->height());
@ -613,17 +620,18 @@ void Graphics2D::ExecuteReplaceContents(ImageData* image,
image_data_->width(), image_data_->height());
}
void Graphics2D::ScheduleOffscreenCallback(const FlushCallbackData& callback) {
void PPB_Graphics2D_Impl::ScheduleOffscreenCallback(
const FlushCallbackData& callback) {
DCHECK(!HasPendingFlush());
offscreen_flush_pending_ = true;
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this,
&Graphics2D::ExecuteOffscreenCallback,
&PPB_Graphics2D_Impl::ExecuteOffscreenCallback,
callback));
}
void Graphics2D::ExecuteOffscreenCallback(FlushCallbackData data) {
void PPB_Graphics2D_Impl::ExecuteOffscreenCallback(FlushCallbackData data) {
DCHECK(offscreen_flush_pending_);
// We must clear this flag before issuing the callback. It will be
@ -633,10 +641,12 @@ void Graphics2D::ExecuteOffscreenCallback(FlushCallbackData data) {
data.Execute(PP_OK);
}
bool Graphics2D::HasPendingFlush() const {
bool PPB_Graphics2D_Impl::HasPendingFlush() const {
return !unpainted_flush_callback_.is_null() ||
!painted_flush_callback_.is_null() ||
offscreen_flush_pending_;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_2D_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_2D_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_
#include <vector>
@ -11,7 +11,7 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/ppb_graphics_2d.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCanvas.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/resource.h"
struct PPB_Graphics2D;
@ -19,16 +19,17 @@ namespace gfx {
class Rect;
}
namespace pepper {
namespace webkit {
namespace ppapi {
class ImageData;
class PPB_ImageData_Impl;
class PluginInstance;
class PluginModule;
class Graphics2D : public Resource {
class PPB_Graphics2D_Impl : public Resource {
public:
Graphics2D(PluginModule* module);
virtual ~Graphics2D();
PPB_Graphics2D_Impl(PluginModule* module);
virtual ~PPB_Graphics2D_Impl();
// Returns a pointer to the interface implementing PPB_ImageData that is
// exposed to the plugin.
@ -39,7 +40,7 @@ class Graphics2D : public Resource {
bool is_always_opaque() const { return is_always_opaque_; }
// Resource override.
virtual Graphics2D* AsGraphics2D();
virtual PPB_Graphics2D_Impl* AsPPB_Graphics2D_Impl();
// PPB_Graphics2D functions.
PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque);
@ -69,7 +70,7 @@ class Graphics2D : public Resource {
void ViewInitiatedPaint();
void ViewFlushedPaint();
ImageData* image_data() { return image_data_.get(); }
PPB_ImageData_Impl* image_data() { return image_data_.get(); }
private:
// Tracks a call to flush that requires a callback.
@ -106,13 +107,13 @@ class Graphics2D : public Resource {
// rect argument will be filled by each function with the area affected by
// the update that requires invalidation. If there were no pixels changed,
// this rect can be untouched.
void ExecutePaintImageData(ImageData* image,
void ExecutePaintImageData(PPB_ImageData_Impl* image,
int x, int y,
const gfx::Rect& src_rect,
gfx::Rect* invalidated_rect);
void ExecuteScroll(const gfx::Rect& clip, int dx, int dy,
gfx::Rect* invalidated_rect);
void ExecuteReplaceContents(ImageData* image,
void ExecuteReplaceContents(PPB_ImageData_Impl* image,
gfx::Rect* invalidated_rect);
// Schedules the offscreen callback to be fired at a future time. This
@ -126,7 +127,7 @@ class Graphics2D : public Resource {
// Returns true if there is any type of flush callback pending.
bool HasPendingFlush() const;
scoped_refptr<ImageData> image_data_;
scoped_refptr<PPB_ImageData_Impl> image_data_;
// Non-owning pointer to the plugin instance this context is currently bound
// to, if any. If the context is currently unbound, this will be NULL.
@ -172,9 +173,10 @@ class Graphics2D : public Resource {
// This allows us to do more optimized painting in some cases.
bool is_always_opaque_;
DISALLOW_COPY_AND_ASSIGN(Graphics2D);
DISALLOW_COPY_AND_ASSIGN(PPB_Graphics2D_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_2D_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_2D_IMPL_H_

@ -2,27 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_graphics_3d.h"
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "gpu/command_buffer/common/command_buffer.h"
#include "base/lazy_instance.h"
#include "base/thread_local.h"
#include "ppapi/c/dev/ppb_graphics_3d_dev.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
static base::LazyInstance<base::ThreadLocalPointer<Graphics3D> >
static base::LazyInstance<base::ThreadLocalPointer<PPB_Graphics3D_Impl> >
g_current_context_key(base::LINKER_INITIALIZED);
// Size of the transfer buffer.
enum { kTransferBufferSize = 512 * 1024 };
PP_Bool IsGraphics3D(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<Graphics3D>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_Graphics3D_Impl>(resource));
}
PP_Bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) {
@ -66,7 +67,8 @@ PP_Resource CreateContext(PP_Instance instance_id, int32_t config,
return 0;
}
scoped_refptr<Graphics3D> context(new Graphics3D(instance->module()));
scoped_refptr<PPB_Graphics3D_Impl> context(
new PPB_Graphics3D_Impl(instance->module()));
if (!context->Init(instance_id, config, attrib_list)) {
return 0;
}
@ -81,21 +83,23 @@ void* GetProcAddress(const char* name) {
PP_Bool MakeCurrent(PP_Resource graphics3d) {
if (!graphics3d) {
Graphics3D::ResetCurrent();
PPB_Graphics3D_Impl::ResetCurrent();
return PP_TRUE;
} else {
scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d));
scoped_refptr<PPB_Graphics3D_Impl> context(
Resource::GetAs<PPB_Graphics3D_Impl>(graphics3d));
return BoolToPPBool(context.get() && context->MakeCurrent());
}
}
PP_Resource GetCurrentContext() {
Graphics3D* current_context = Graphics3D::GetCurrent();
PPB_Graphics3D_Impl* current_context = PPB_Graphics3D_Impl::GetCurrent();
return current_context ? current_context->GetReference() : 0;
}
PP_Bool SwapBuffers(PP_Resource graphics3d) {
scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d));
scoped_refptr<PPB_Graphics3D_Impl> context(
Resource::GetAs<PPB_Graphics3D_Impl>(graphics3d));
return BoolToPPBool(context && context->SwapBuffers());
}
@ -103,7 +107,7 @@ uint32_t GetError() {
// Technically, this should return the last error that occurred on the current
// thread, rather than an error associated with a particular context.
// TODO(apatrick): Fix this.
Graphics3D* current_context = Graphics3D::GetCurrent();
PPB_Graphics3D_Impl* current_context = PPB_Graphics3D_Impl::GetCurrent();
if (!current_context)
return 0;
@ -126,33 +130,33 @@ const PPB_Graphics3D_Dev ppb_graphics3d = {
} // namespace
Graphics3D::Graphics3D(PluginModule* module)
PPB_Graphics3D_Impl::PPB_Graphics3D_Impl(PluginModule* module)
: Resource(module),
bound_instance_(NULL) {
}
const PPB_Graphics3D_Dev* Graphics3D::GetInterface() {
const PPB_Graphics3D_Dev* PPB_Graphics3D_Impl::GetInterface() {
return &ppb_graphics3d;
}
Graphics3D* Graphics3D::GetCurrent() {
PPB_Graphics3D_Impl* PPB_Graphics3D_Impl::GetCurrent() {
return g_current_context_key.Get().Get();
}
void Graphics3D::ResetCurrent() {
void PPB_Graphics3D_Impl::ResetCurrent() {
g_current_context_key.Get().Set(NULL);
}
Graphics3D* Graphics3D::AsGraphics3D() {
return this;
}
Graphics3D::~Graphics3D() {
PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
Destroy();
}
bool Graphics3D::Init(PP_Instance instance_id, int32_t config,
const int32_t* attrib_list) {
PPB_Graphics3D_Impl* PPB_Graphics3D_Impl::AsPPB_Graphics3D_Impl() {
return this;
}
bool PPB_Graphics3D_Impl::Init(PP_Instance instance_id, int32_t config,
const int32_t* attrib_list) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
if (!instance) {
return false;
@ -176,7 +180,7 @@ bool Graphics3D::Init(PP_Instance instance_id, int32_t config,
return true;
}
bool Graphics3D::BindToInstance(PluginInstance* new_instance) {
bool PPB_Graphics3D_Impl::BindToInstance(PluginInstance* new_instance) {
if (bound_instance_ == new_instance)
return true; // Rebinding the same device, nothing to do.
if (bound_instance_ && new_instance)
@ -199,7 +203,7 @@ bool Graphics3D::BindToInstance(PluginInstance* new_instance) {
return true;
}
bool Graphics3D::MakeCurrent() {
bool PPB_Graphics3D_Impl::MakeCurrent() {
if (!platform_context_.get())
return false;
@ -209,42 +213,42 @@ bool Graphics3D::MakeCurrent() {
return true;
}
bool Graphics3D::SwapBuffers() {
bool PPB_Graphics3D_Impl::SwapBuffers() {
if (!platform_context_.get())
return false;
return platform_context_->SwapBuffers();
}
unsigned Graphics3D::GetError() {
unsigned PPB_Graphics3D_Impl::GetError() {
if (!platform_context_.get())
return 0;
return platform_context_->GetError();
}
void Graphics3D::ResizeBackingTexture(const gfx::Size& size) {
void PPB_Graphics3D_Impl::ResizeBackingTexture(const gfx::Size& size) {
if (!platform_context_.get())
return;
platform_context_->ResizeBackingTexture(size);
}
void Graphics3D::SetSwapBuffersCallback(Callback0::Type* callback) {
void PPB_Graphics3D_Impl::SetSwapBuffersCallback(Callback0::Type* callback) {
if (!platform_context_.get())
return;
platform_context_->SetSwapBuffersCallback(callback);
}
unsigned Graphics3D::GetBackingTextureId() {
unsigned PPB_Graphics3D_Impl::GetBackingTextureId() {
if (!platform_context_.get())
return 0;
return platform_context_->GetBackingTextureId();
}
void Graphics3D::Destroy() {
void PPB_Graphics3D_Impl::Destroy() {
if (GetCurrent() == this) {
ResetCurrent();
}
@ -254,5 +258,6 @@ void Graphics3D::Destroy() {
platform_context_.reset();
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,51 +2,53 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/scoped_ptr.h"
#include "gfx/size.h"
#include "gpu/command_buffer/client/gles2_cmd_helper.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "ppapi/c/pp_instance.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/resource.h"
namespace gpu {
namespace gles2 {
class GLES2Implementation;
}
} // namespace gles2
} // namespace gpu
struct PPB_Graphics3D_Dev;
struct PPB_OpenGLES_Dev;
namespace pepper {
namespace webkit {
namespace ppapi {
class Graphics3D : public Resource {
class PPB_Graphics3D_Impl : public Resource {
public:
explicit Graphics3D(PluginModule* module);
explicit PPB_Graphics3D_Impl(PluginModule* module);
virtual ~Graphics3D();
virtual ~PPB_Graphics3D_Impl();
static const PPB_Graphics3D_Dev* GetInterface();
static const PPB_OpenGLES_Dev* GetOpenGLESInterface();
static bool Shutdown();
static Graphics3D* GetCurrent();
static PPB_Graphics3D_Impl* GetCurrent();
static void ResetCurrent();
// Resource override.
virtual Graphics3D* AsGraphics3D();
virtual PPB_Graphics3D_Impl* AsPPB_Graphics3D_Impl();
bool Init(PP_Instance instance_id, int32_t config,
const int32_t* attrib_list);
// Associates this Graphics3D with the given plugin instance. You can pass
// Associates this PPB_Graphics3D_Impl with the given plugin instance. You can pass
// NULL to clear the existing device. Returns true on success. In this case,
// the last rendered frame is displayed.
// TODO(apatrick): Figure out the best semantics here.
@ -80,9 +82,12 @@ class Graphics3D : public Resource {
// GLES2 Implementation instance. Owned by the platform context's GGL context.
gpu::gles2::GLES2Implementation* gles2_implementation_;
DISALLOW_COPY_AND_ASSIGN(PPB_Graphics3D_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_GRAPHICS_3D_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_GRAPHICS_3D_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include <algorithm>
#include <limits>
@ -16,20 +16,21 @@
#include "ppapi/c/ppb_image_data.h"
#include "ppapi/c/trusted/ppb_image_data_trusted.h"
#include "third_party/skia/include/core/SkColorPriv.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
PP_ImageDataFormat GetNativeImageDataFormat() {
return ImageData::GetNativeImageDataFormat();
return PPB_ImageData_Impl::GetNativeImageDataFormat();
}
PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) {
return BoolToPPBool(ImageData::IsImageDataFormatSupported(format));
return BoolToPPBool(PPB_ImageData_Impl::IsImageDataFormatSupported(format));
}
PP_Resource Create(PP_Module module_id,
@ -40,7 +41,7 @@ PP_Resource Create(PP_Module module_id,
if (!module)
return 0;
scoped_refptr<ImageData> data(new ImageData(module));
scoped_refptr<PPB_ImageData_Impl> data(new PPB_ImageData_Impl(module));
if (!data->Init(format,
size->width,
size->height,
@ -52,14 +53,15 @@ PP_Resource Create(PP_Module module_id,
}
PP_Bool IsImageData(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<ImageData>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_ImageData_Impl>(resource));
}
PP_Bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) {
// Give predictable values on failure.
memset(desc, 0, sizeof(PP_ImageDataDesc));
scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource));
scoped_refptr<PPB_ImageData_Impl> image_data(
Resource::GetAs<PPB_ImageData_Impl>(resource));
if (!image_data)
return PP_FALSE;
image_data->Describe(desc);
@ -67,14 +69,16 @@ PP_Bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) {
}
void* Map(PP_Resource resource) {
scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource));
scoped_refptr<PPB_ImageData_Impl> image_data(
Resource::GetAs<PPB_ImageData_Impl>(resource));
if (!image_data)
return NULL;
return image_data->Map();
}
void Unmap(PP_Resource resource) {
scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource));
scoped_refptr<PPB_ImageData_Impl> image_data(
Resource::GetAs<PPB_ImageData_Impl>(resource));
if (image_data)
image_data->Unmap();
}
@ -82,7 +86,8 @@ void Unmap(PP_Resource resource) {
int32_t GetSharedMemory(PP_Resource resource,
int* handle,
uint32_t* byte_count) {
scoped_refptr<ImageData> image_data(Resource::GetAs<ImageData>(resource));
scoped_refptr<PPB_ImageData_Impl> image_data(
Resource::GetAs<PPB_ImageData_Impl>(resource));
if (image_data) {
*handle = image_data->GetSharedMemoryHandle(byte_count);
return PP_OK;
@ -106,28 +111,28 @@ const PPB_ImageDataTrusted ppb_imagedata_trusted = {
} // namespace
ImageData::ImageData(PluginModule* module)
PPB_ImageData_Impl::PPB_ImageData_Impl(PluginModule* module)
: Resource(module),
format_(PP_IMAGEDATAFORMAT_BGRA_PREMUL),
width_(0),
height_(0) {
}
ImageData::~ImageData() {
PPB_ImageData_Impl::~PPB_ImageData_Impl() {
}
// static
const PPB_ImageData* ImageData::GetInterface() {
const PPB_ImageData* PPB_ImageData_Impl::GetInterface() {
return &ppb_imagedata;
}
// static
const PPB_ImageDataTrusted* ImageData::GetTrustedInterface() {
const PPB_ImageDataTrusted* PPB_ImageData_Impl::GetTrustedInterface() {
return &ppb_imagedata_trusted;
}
// static
PP_ImageDataFormat ImageData::GetNativeImageDataFormat() {
PP_ImageDataFormat PPB_ImageData_Impl::GetNativeImageDataFormat() {
if (SK_B32_SHIFT == 0)
return PP_IMAGEDATAFORMAT_BGRA_PREMUL;
else if (SK_R32_SHIFT == 0)
@ -137,18 +142,19 @@ PP_ImageDataFormat ImageData::GetNativeImageDataFormat() {
}
// static
bool ImageData::IsImageDataFormatSupported(PP_ImageDataFormat format) {
bool PPB_ImageData_Impl::IsImageDataFormatSupported(
PP_ImageDataFormat format) {
return format == PP_IMAGEDATAFORMAT_BGRA_PREMUL ||
format == PP_IMAGEDATAFORMAT_RGBA_PREMUL;
}
ImageData* ImageData::AsImageData() {
PPB_ImageData_Impl* PPB_ImageData_Impl::AsPPB_ImageData_Impl() {
return this;
}
bool ImageData::Init(PP_ImageDataFormat format,
int width, int height,
bool init_to_zero) {
bool PPB_ImageData_Impl::Init(PP_ImageDataFormat format,
int width, int height,
bool init_to_zero) {
// TODO(brettw) this should be called only on the main thread!
// TODO(brettw) use init_to_zero when we implement caching.
if (!IsImageDataFormatSupported(format))
@ -167,14 +173,14 @@ bool ImageData::Init(PP_ImageDataFormat format,
return !!platform_image_.get();
}
void ImageData::Describe(PP_ImageDataDesc* desc) const {
void PPB_ImageData_Impl::Describe(PP_ImageDataDesc* desc) const {
desc->format = format_;
desc->size.width = width_;
desc->size.height = height_;
desc->stride = width_ * 4;
}
void* ImageData::Map() {
void* PPB_ImageData_Impl::Map() {
if (!mapped_canvas_.get()) {
mapped_canvas_.reset(platform_image_->Map());
if (!mapped_canvas_.get())
@ -190,24 +196,24 @@ void* ImageData::Map() {
return bitmap.getAddr32(0, 0);
}
void ImageData::Unmap() {
void PPB_ImageData_Impl::Unmap() {
// This is currently unimplemented, which is OK. The data will just always
// be around once it's mapped. Chrome's TransportDIB isn't currently
// unmappable without freeing it, but this may be something we want to support
// in the future to save some memory.
}
int ImageData::GetSharedMemoryHandle(uint32* byte_count) const {
int PPB_ImageData_Impl::GetSharedMemoryHandle(uint32* byte_count) const {
return platform_image_->GetSharedMemoryHandle(byte_count);
}
const SkBitmap* ImageData::GetMappedBitmap() const {
const SkBitmap* PPB_ImageData_Impl::GetMappedBitmap() const {
if (!mapped_canvas_.get())
return NULL;
return &mapped_canvas_->getTopPlatformDevice().accessBitmap(false);
}
void ImageData::Swap(ImageData* other) {
void PPB_ImageData_Impl::Swap(PPB_ImageData_Impl* other) {
swap(other->platform_image_, platform_image_);
swap(other->mapped_canvas_, mapped_canvas_);
std::swap(other->format_, format_);
@ -215,4 +221,6 @@ void ImageData::Swap(ImageData* other) {
std::swap(other->height_, height_);
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_IMAGE_DATA_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_IMAGE_DATA_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "ppapi/c/ppb_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_resource.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/resource.h"
namespace skia {
class PlatformCanvas;
@ -18,12 +18,13 @@ class PlatformCanvas;
struct PPB_ImageDataTrusted;
class SkBitmap;
namespace pepper {
namespace webkit {
namespace ppapi {
class ImageData : public Resource {
class PPB_ImageData_Impl : public Resource {
public:
explicit ImageData(PluginModule* module);
virtual ~ImageData();
explicit PPB_ImageData_Impl(PluginModule* module);
virtual ~PPB_ImageData_Impl();
int width() const { return width_; }
int height() const { return height_; }
@ -53,7 +54,7 @@ class ImageData : public Resource {
static bool IsImageDataFormatSupported(PP_ImageDataFormat format);
// Resource overrides.
virtual ImageData* AsImageData();
virtual PPB_ImageData_Impl* AsPPB_ImageData_Impl();
// PPB_ImageData implementation.
bool Init(PP_ImageDataFormat format,
@ -71,10 +72,10 @@ class ImageData : public Resource {
const SkBitmap* GetMappedBitmap() const;
// Swaps the guts of this image data with another.
void Swap(ImageData* other);
void Swap(PPB_ImageData_Impl* other);
private:
// This will be NULL before initialization, and if this ImageData is
// This will be NULL before initialization, and if this PPB_ImageData_Impl is
// swapped with another.
scoped_ptr<PluginDelegate::PlatformImage2D> platform_image_;
@ -85,7 +86,7 @@ class ImageData : public Resource {
int width_;
int height_;
DISALLOW_COPY_AND_ASSIGN(ImageData);
DISALLOW_COPY_AND_ASSIGN(PPB_ImageData_Impl);
};
// Manages mapping an image resource if necessary. Use this to ensure the
@ -100,7 +101,8 @@ class ImageData : public Resource {
// image_data->mapped_canvas()->blah(); // Guaranteed valid.
class ImageDataAutoMapper {
public:
ImageDataAutoMapper(ImageData* image_data) : image_data_(image_data) {
ImageDataAutoMapper(PPB_ImageData_Impl* image_data)
: image_data_(image_data) {
if (image_data_->is_mapped()) {
is_valid_ = true;
needs_unmap_ = false;
@ -119,13 +121,14 @@ class ImageDataAutoMapper {
bool is_valid() const { return is_valid_; }
private:
ImageData* image_data_;
PPB_ImageData_Impl* image_data_;
bool is_valid_;
bool needs_unmap_;
DISALLOW_COPY_AND_ASSIGN(ImageDataAutoMapper);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_IMAGE_DATA_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_IMAGE_DATA_IMPL_H_

@ -4,515 +4,516 @@
// This file is auto-generated. DO NOT EDIT!
#include "webkit/glue/plugins/pepper_graphics_3d.h"
#include "webkit/plugins/ppapi/ppb_graphics_3d_impl.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
#include "ppapi/c/dev/ppb_opengles_dev.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
void ActiveTexture(GLenum texture) {
Graphics3D::GetCurrent()->impl()->ActiveTexture(texture);
PPB_Graphics3D_Impl::GetCurrent()->impl()->ActiveTexture(texture);
}
void AttachShader(GLuint program, GLuint shader) {
Graphics3D::GetCurrent()->impl()->AttachShader(program, shader);
PPB_Graphics3D_Impl::GetCurrent()->impl()->AttachShader(program, shader);
}
void BindAttribLocation(GLuint program, GLuint index, const char* name) {
Graphics3D::GetCurrent()->impl()->BindAttribLocation(program, index, name);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BindAttribLocation(program, index, name);
}
void BindBuffer(GLenum target, GLuint buffer) {
Graphics3D::GetCurrent()->impl()->BindBuffer(target, buffer);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BindBuffer(target, buffer);
}
void BindFramebuffer(GLenum target, GLuint framebuffer) {
Graphics3D::GetCurrent()->impl()->BindFramebuffer(target, framebuffer);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BindFramebuffer(target, framebuffer);
}
void BindRenderbuffer(GLenum target, GLuint renderbuffer) {
Graphics3D::GetCurrent()->impl()->BindRenderbuffer(target, renderbuffer);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BindRenderbuffer(target, renderbuffer);
}
void BindTexture(GLenum target, GLuint texture) {
Graphics3D::GetCurrent()->impl()->BindTexture(target, texture);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BindTexture(target, texture);
}
void BlendColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
Graphics3D::GetCurrent()->impl()->BlendColor(red, green, blue, alpha);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BlendColor(red, green, blue, alpha);
}
void BlendEquation(GLenum mode) {
Graphics3D::GetCurrent()->impl()->BlendEquation(mode);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BlendEquation(mode);
}
void BlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) {
Graphics3D::GetCurrent()->impl()->BlendEquationSeparate(modeRGB, modeAlpha);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BlendEquationSeparate(modeRGB, modeAlpha);
}
void BlendFunc(GLenum sfactor, GLenum dfactor) {
Graphics3D::GetCurrent()->impl()->BlendFunc(sfactor, dfactor);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BlendFunc(sfactor, dfactor);
}
void BlendFuncSeparate(
GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha) {
Graphics3D::GetCurrent()->impl()->BlendFuncSeparate(
PPB_Graphics3D_Impl::GetCurrent()->impl()->BlendFuncSeparate(
srcRGB, dstRGB, srcAlpha, dstAlpha);
}
void BufferData(
GLenum target, GLsizeiptr size, const void* data, GLenum usage) {
Graphics3D::GetCurrent()->impl()->BufferData(target, size, data, usage);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BufferData(target, size, data, usage);
}
void BufferSubData(
GLenum target, GLintptr offset, GLsizeiptr size, const void* data) {
Graphics3D::GetCurrent()->impl()->BufferSubData(target, offset, size, data);
PPB_Graphics3D_Impl::GetCurrent()->impl()->BufferSubData(target, offset, size, data);
}
GLenum CheckFramebufferStatus(GLenum target) {
return Graphics3D::GetCurrent()->impl()->CheckFramebufferStatus(target);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->CheckFramebufferStatus(target);
}
void Clear(GLbitfield mask) {
Graphics3D::GetCurrent()->impl()->Clear(mask);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Clear(mask);
}
void ClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) {
Graphics3D::GetCurrent()->impl()->ClearColor(red, green, blue, alpha);
PPB_Graphics3D_Impl::GetCurrent()->impl()->ClearColor(red, green, blue, alpha);
}
void ClearDepthf(GLclampf depth) {
Graphics3D::GetCurrent()->impl()->ClearDepthf(depth);
PPB_Graphics3D_Impl::GetCurrent()->impl()->ClearDepthf(depth);
}
void ClearStencil(GLint s) {
Graphics3D::GetCurrent()->impl()->ClearStencil(s);
PPB_Graphics3D_Impl::GetCurrent()->impl()->ClearStencil(s);
}
void ColorMask(
GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) {
Graphics3D::GetCurrent()->impl()->ColorMask(red, green, blue, alpha);
PPB_Graphics3D_Impl::GetCurrent()->impl()->ColorMask(red, green, blue, alpha);
}
void CompileShader(GLuint shader) {
Graphics3D::GetCurrent()->impl()->CompileShader(shader);
PPB_Graphics3D_Impl::GetCurrent()->impl()->CompileShader(shader);
}
void CompressedTexImage2D(
GLenum target, GLint level, GLenum internalformat, GLsizei width,
GLsizei height, GLint border, GLsizei imageSize, const void* data) {
Graphics3D::GetCurrent()->impl()->CompressedTexImage2D(
PPB_Graphics3D_Impl::GetCurrent()->impl()->CompressedTexImage2D(
target, level, internalformat, width, height, border, imageSize, data);
}
void CompressedTexSubImage2D(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLsizei imageSize, const void* data) {
Graphics3D::GetCurrent()->impl()->CompressedTexSubImage2D(
PPB_Graphics3D_Impl::GetCurrent()->impl()->CompressedTexSubImage2D(
target, level, xoffset, yoffset, width, height, format, imageSize, data);
}
void CopyTexImage2D(
GLenum target, GLint level, GLenum internalformat, GLint x, GLint y,
GLsizei width, GLsizei height, GLint border) {
Graphics3D::GetCurrent()->impl()->CopyTexImage2D(
PPB_Graphics3D_Impl::GetCurrent()->impl()->CopyTexImage2D(
target, level, internalformat, x, y, width, height, border);
}
void CopyTexSubImage2D(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y,
GLsizei width, GLsizei height) {
Graphics3D::GetCurrent()->impl()->CopyTexSubImage2D(
PPB_Graphics3D_Impl::GetCurrent()->impl()->CopyTexSubImage2D(
target, level, xoffset, yoffset, x, y, width, height);
}
GLuint CreateProgram() {
return Graphics3D::GetCurrent()->impl()->CreateProgram();
return PPB_Graphics3D_Impl::GetCurrent()->impl()->CreateProgram();
}
GLuint CreateShader(GLenum type) {
return Graphics3D::GetCurrent()->impl()->CreateShader(type);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->CreateShader(type);
}
void CullFace(GLenum mode) {
Graphics3D::GetCurrent()->impl()->CullFace(mode);
PPB_Graphics3D_Impl::GetCurrent()->impl()->CullFace(mode);
}
void DeleteBuffers(GLsizei n, const GLuint* buffers) {
Graphics3D::GetCurrent()->impl()->DeleteBuffers(n, buffers);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DeleteBuffers(n, buffers);
}
void DeleteFramebuffers(GLsizei n, const GLuint* framebuffers) {
Graphics3D::GetCurrent()->impl()->DeleteFramebuffers(n, framebuffers);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DeleteFramebuffers(n, framebuffers);
}
void DeleteProgram(GLuint program) {
Graphics3D::GetCurrent()->impl()->DeleteProgram(program);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DeleteProgram(program);
}
void DeleteRenderbuffers(GLsizei n, const GLuint* renderbuffers) {
Graphics3D::GetCurrent()->impl()->DeleteRenderbuffers(n, renderbuffers);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DeleteRenderbuffers(n, renderbuffers);
}
void DeleteShader(GLuint shader) {
Graphics3D::GetCurrent()->impl()->DeleteShader(shader);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DeleteShader(shader);
}
void DeleteTextures(GLsizei n, const GLuint* textures) {
Graphics3D::GetCurrent()->impl()->DeleteTextures(n, textures);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DeleteTextures(n, textures);
}
void DepthFunc(GLenum func) {
Graphics3D::GetCurrent()->impl()->DepthFunc(func);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DepthFunc(func);
}
void DepthMask(GLboolean flag) {
Graphics3D::GetCurrent()->impl()->DepthMask(flag);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DepthMask(flag);
}
void DepthRangef(GLclampf zNear, GLclampf zFar) {
Graphics3D::GetCurrent()->impl()->DepthRangef(zNear, zFar);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DepthRangef(zNear, zFar);
}
void DetachShader(GLuint program, GLuint shader) {
Graphics3D::GetCurrent()->impl()->DetachShader(program, shader);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DetachShader(program, shader);
}
void Disable(GLenum cap) {
Graphics3D::GetCurrent()->impl()->Disable(cap);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Disable(cap);
}
void DisableVertexAttribArray(GLuint index) {
Graphics3D::GetCurrent()->impl()->DisableVertexAttribArray(index);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DisableVertexAttribArray(index);
}
void DrawArrays(GLenum mode, GLint first, GLsizei count) {
Graphics3D::GetCurrent()->impl()->DrawArrays(mode, first, count);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DrawArrays(mode, first, count);
}
void DrawElements(
GLenum mode, GLsizei count, GLenum type, const void* indices) {
Graphics3D::GetCurrent()->impl()->DrawElements(mode, count, type, indices);
PPB_Graphics3D_Impl::GetCurrent()->impl()->DrawElements(mode, count, type, indices);
}
void Enable(GLenum cap) {
Graphics3D::GetCurrent()->impl()->Enable(cap);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Enable(cap);
}
void EnableVertexAttribArray(GLuint index) {
Graphics3D::GetCurrent()->impl()->EnableVertexAttribArray(index);
PPB_Graphics3D_Impl::GetCurrent()->impl()->EnableVertexAttribArray(index);
}
void Finish() {
Graphics3D::GetCurrent()->impl()->Finish();
PPB_Graphics3D_Impl::GetCurrent()->impl()->Finish();
}
void Flush() {
Graphics3D::GetCurrent()->impl()->Flush();
PPB_Graphics3D_Impl::GetCurrent()->impl()->Flush();
}
void FramebufferRenderbuffer(
GLenum target, GLenum attachment, GLenum renderbuffertarget,
GLuint renderbuffer) {
Graphics3D::GetCurrent()->impl()->FramebufferRenderbuffer(
PPB_Graphics3D_Impl::GetCurrent()->impl()->FramebufferRenderbuffer(
target, attachment, renderbuffertarget, renderbuffer);
}
void FramebufferTexture2D(
GLenum target, GLenum attachment, GLenum textarget, GLuint texture,
GLint level) {
Graphics3D::GetCurrent()->impl()->FramebufferTexture2D(
PPB_Graphics3D_Impl::GetCurrent()->impl()->FramebufferTexture2D(
target, attachment, textarget, texture, level);
}
void FrontFace(GLenum mode) {
Graphics3D::GetCurrent()->impl()->FrontFace(mode);
PPB_Graphics3D_Impl::GetCurrent()->impl()->FrontFace(mode);
}
void GenBuffers(GLsizei n, GLuint* buffers) {
Graphics3D::GetCurrent()->impl()->GenBuffers(n, buffers);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GenBuffers(n, buffers);
}
void GenerateMipmap(GLenum target) {
Graphics3D::GetCurrent()->impl()->GenerateMipmap(target);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GenerateMipmap(target);
}
void GenFramebuffers(GLsizei n, GLuint* framebuffers) {
Graphics3D::GetCurrent()->impl()->GenFramebuffers(n, framebuffers);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GenFramebuffers(n, framebuffers);
}
void GenRenderbuffers(GLsizei n, GLuint* renderbuffers) {
Graphics3D::GetCurrent()->impl()->GenRenderbuffers(n, renderbuffers);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GenRenderbuffers(n, renderbuffers);
}
void GenTextures(GLsizei n, GLuint* textures) {
Graphics3D::GetCurrent()->impl()->GenTextures(n, textures);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GenTextures(n, textures);
}
void GetActiveAttrib(
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
GLenum* type, char* name) {
Graphics3D::GetCurrent()->impl()->GetActiveAttrib(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetActiveAttrib(
program, index, bufsize, length, size, type, name);
}
void GetActiveUniform(
GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size,
GLenum* type, char* name) {
Graphics3D::GetCurrent()->impl()->GetActiveUniform(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetActiveUniform(
program, index, bufsize, length, size, type, name);
}
void GetAttachedShaders(
GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders) {
Graphics3D::GetCurrent()->impl()->GetAttachedShaders(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetAttachedShaders(
program, maxcount, count, shaders);
}
GLint GetAttribLocation(GLuint program, const char* name) {
return Graphics3D::GetCurrent()->impl()->GetAttribLocation(program, name);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->GetAttribLocation(program, name);
}
void GetBooleanv(GLenum pname, GLboolean* params) {
Graphics3D::GetCurrent()->impl()->GetBooleanv(pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetBooleanv(pname, params);
}
void GetBufferParameteriv(GLenum target, GLenum pname, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetBufferParameteriv(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetBufferParameteriv(
target, pname, params);
}
GLenum GetError() {
return Graphics3D::GetCurrent()->impl()->GetError();
return PPB_Graphics3D_Impl::GetCurrent()->impl()->GetError();
}
void GetFloatv(GLenum pname, GLfloat* params) {
Graphics3D::GetCurrent()->impl()->GetFloatv(pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetFloatv(pname, params);
}
void GetFramebufferAttachmentParameteriv(
GLenum target, GLenum attachment, GLenum pname, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetFramebufferAttachmentParameteriv(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetFramebufferAttachmentParameteriv(
target, attachment, pname, params);
}
void GetIntegerv(GLenum pname, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetIntegerv(pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetIntegerv(pname, params);
}
void GetProgramiv(GLuint program, GLenum pname, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetProgramiv(program, pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetProgramiv(program, pname, params);
}
void GetProgramInfoLog(
GLuint program, GLsizei bufsize, GLsizei* length, char* infolog) {
Graphics3D::GetCurrent()->impl()->GetProgramInfoLog(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetProgramInfoLog(
program, bufsize, length, infolog);
}
void GetRenderbufferParameteriv(GLenum target, GLenum pname, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetRenderbufferParameteriv(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetRenderbufferParameteriv(
target, pname, params);
}
void GetShaderiv(GLuint shader, GLenum pname, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetShaderiv(shader, pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetShaderiv(shader, pname, params);
}
void GetShaderInfoLog(
GLuint shader, GLsizei bufsize, GLsizei* length, char* infolog) {
Graphics3D::GetCurrent()->impl()->GetShaderInfoLog(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetShaderInfoLog(
shader, bufsize, length, infolog);
}
void GetShaderPrecisionFormat(
GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision) {
Graphics3D::GetCurrent()->impl()->GetShaderPrecisionFormat(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetShaderPrecisionFormat(
shadertype, precisiontype, range, precision);
}
void GetShaderSource(
GLuint shader, GLsizei bufsize, GLsizei* length, char* source) {
Graphics3D::GetCurrent()->impl()->GetShaderSource(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetShaderSource(
shader, bufsize, length, source);
}
const GLubyte* GetString(GLenum name) {
return Graphics3D::GetCurrent()->impl()->GetString(name);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->GetString(name);
}
void GetTexParameterfv(GLenum target, GLenum pname, GLfloat* params) {
Graphics3D::GetCurrent()->impl()->GetTexParameterfv(target, pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetTexParameterfv(target, pname, params);
}
void GetTexParameteriv(GLenum target, GLenum pname, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetTexParameteriv(target, pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetTexParameteriv(target, pname, params);
}
void GetUniformfv(GLuint program, GLint location, GLfloat* params) {
Graphics3D::GetCurrent()->impl()->GetUniformfv(program, location, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetUniformfv(program, location, params);
}
void GetUniformiv(GLuint program, GLint location, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetUniformiv(program, location, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetUniformiv(program, location, params);
}
GLint GetUniformLocation(GLuint program, const char* name) {
return Graphics3D::GetCurrent()->impl()->GetUniformLocation(program, name);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->GetUniformLocation(program, name);
}
void GetVertexAttribfv(GLuint index, GLenum pname, GLfloat* params) {
Graphics3D::GetCurrent()->impl()->GetVertexAttribfv(index, pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetVertexAttribfv(index, pname, params);
}
void GetVertexAttribiv(GLuint index, GLenum pname, GLint* params) {
Graphics3D::GetCurrent()->impl()->GetVertexAttribiv(index, pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetVertexAttribiv(index, pname, params);
}
void GetVertexAttribPointerv(GLuint index, GLenum pname, void** pointer) {
Graphics3D::GetCurrent()->impl()->GetVertexAttribPointerv(
PPB_Graphics3D_Impl::GetCurrent()->impl()->GetVertexAttribPointerv(
index, pname, pointer);
}
void Hint(GLenum target, GLenum mode) {
Graphics3D::GetCurrent()->impl()->Hint(target, mode);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Hint(target, mode);
}
GLboolean IsBuffer(GLuint buffer) {
return Graphics3D::GetCurrent()->impl()->IsBuffer(buffer);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->IsBuffer(buffer);
}
GLboolean IsEnabled(GLenum cap) {
return Graphics3D::GetCurrent()->impl()->IsEnabled(cap);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->IsEnabled(cap);
}
GLboolean IsFramebuffer(GLuint framebuffer) {
return Graphics3D::GetCurrent()->impl()->IsFramebuffer(framebuffer);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->IsFramebuffer(framebuffer);
}
GLboolean IsProgram(GLuint program) {
return Graphics3D::GetCurrent()->impl()->IsProgram(program);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->IsProgram(program);
}
GLboolean IsRenderbuffer(GLuint renderbuffer) {
return Graphics3D::GetCurrent()->impl()->IsRenderbuffer(renderbuffer);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->IsRenderbuffer(renderbuffer);
}
GLboolean IsShader(GLuint shader) {
return Graphics3D::GetCurrent()->impl()->IsShader(shader);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->IsShader(shader);
}
GLboolean IsTexture(GLuint texture) {
return Graphics3D::GetCurrent()->impl()->IsTexture(texture);
return PPB_Graphics3D_Impl::GetCurrent()->impl()->IsTexture(texture);
}
void LineWidth(GLfloat width) {
Graphics3D::GetCurrent()->impl()->LineWidth(width);
PPB_Graphics3D_Impl::GetCurrent()->impl()->LineWidth(width);
}
void LinkProgram(GLuint program) {
Graphics3D::GetCurrent()->impl()->LinkProgram(program);
PPB_Graphics3D_Impl::GetCurrent()->impl()->LinkProgram(program);
}
void PixelStorei(GLenum pname, GLint param) {
Graphics3D::GetCurrent()->impl()->PixelStorei(pname, param);
PPB_Graphics3D_Impl::GetCurrent()->impl()->PixelStorei(pname, param);
}
void PolygonOffset(GLfloat factor, GLfloat units) {
Graphics3D::GetCurrent()->impl()->PolygonOffset(factor, units);
PPB_Graphics3D_Impl::GetCurrent()->impl()->PolygonOffset(factor, units);
}
void ReadPixels(
GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
void* pixels) {
Graphics3D::GetCurrent()->impl()->ReadPixels(
PPB_Graphics3D_Impl::GetCurrent()->impl()->ReadPixels(
x, y, width, height, format, type, pixels);
}
void ReleaseShaderCompiler() {
Graphics3D::GetCurrent()->impl()->ReleaseShaderCompiler();
PPB_Graphics3D_Impl::GetCurrent()->impl()->ReleaseShaderCompiler();
}
void RenderbufferStorage(
GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
Graphics3D::GetCurrent()->impl()->RenderbufferStorage(
PPB_Graphics3D_Impl::GetCurrent()->impl()->RenderbufferStorage(
target, internalformat, width, height);
}
void SampleCoverage(GLclampf value, GLboolean invert) {
Graphics3D::GetCurrent()->impl()->SampleCoverage(value, invert);
PPB_Graphics3D_Impl::GetCurrent()->impl()->SampleCoverage(value, invert);
}
void Scissor(GLint x, GLint y, GLsizei width, GLsizei height) {
Graphics3D::GetCurrent()->impl()->Scissor(x, y, width, height);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Scissor(x, y, width, height);
}
void ShaderBinary(
GLsizei n, const GLuint* shaders, GLenum binaryformat, const void* binary,
GLsizei length) {
Graphics3D::GetCurrent()->impl()->ShaderBinary(
PPB_Graphics3D_Impl::GetCurrent()->impl()->ShaderBinary(
n, shaders, binaryformat, binary, length);
}
void ShaderSource(
GLuint shader, GLsizei count, const char** str, const GLint* length) {
Graphics3D::GetCurrent()->impl()->ShaderSource(shader, count, str, length);
PPB_Graphics3D_Impl::GetCurrent()->impl()->ShaderSource(shader, count, str, length);
}
void StencilFunc(GLenum func, GLint ref, GLuint mask) {
Graphics3D::GetCurrent()->impl()->StencilFunc(func, ref, mask);
PPB_Graphics3D_Impl::GetCurrent()->impl()->StencilFunc(func, ref, mask);
}
void StencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask) {
Graphics3D::GetCurrent()->impl()->StencilFuncSeparate(face, func, ref, mask);
PPB_Graphics3D_Impl::GetCurrent()->impl()->StencilFuncSeparate(face, func, ref, mask);
}
void StencilMask(GLuint mask) {
Graphics3D::GetCurrent()->impl()->StencilMask(mask);
PPB_Graphics3D_Impl::GetCurrent()->impl()->StencilMask(mask);
}
void StencilMaskSeparate(GLenum face, GLuint mask) {
Graphics3D::GetCurrent()->impl()->StencilMaskSeparate(face, mask);
PPB_Graphics3D_Impl::GetCurrent()->impl()->StencilMaskSeparate(face, mask);
}
void StencilOp(GLenum fail, GLenum zfail, GLenum zpass) {
Graphics3D::GetCurrent()->impl()->StencilOp(fail, zfail, zpass);
PPB_Graphics3D_Impl::GetCurrent()->impl()->StencilOp(fail, zfail, zpass);
}
void StencilOpSeparate(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) {
Graphics3D::GetCurrent()->impl()->StencilOpSeparate(
PPB_Graphics3D_Impl::GetCurrent()->impl()->StencilOpSeparate(
face, fail, zfail, zpass);
}
void TexImage2D(
GLenum target, GLint level, GLint internalformat, GLsizei width,
GLsizei height, GLint border, GLenum format, GLenum type,
const void* pixels) {
Graphics3D::GetCurrent()->impl()->TexImage2D(
PPB_Graphics3D_Impl::GetCurrent()->impl()->TexImage2D(
target, level, internalformat, width, height, border, format, type,
pixels);
}
void TexParameterf(GLenum target, GLenum pname, GLfloat param) {
Graphics3D::GetCurrent()->impl()->TexParameterf(target, pname, param);
PPB_Graphics3D_Impl::GetCurrent()->impl()->TexParameterf(target, pname, param);
}
void TexParameterfv(GLenum target, GLenum pname, const GLfloat* params) {
Graphics3D::GetCurrent()->impl()->TexParameterfv(target, pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->TexParameterfv(target, pname, params);
}
void TexParameteri(GLenum target, GLenum pname, GLint param) {
Graphics3D::GetCurrent()->impl()->TexParameteri(target, pname, param);
PPB_Graphics3D_Impl::GetCurrent()->impl()->TexParameteri(target, pname, param);
}
void TexParameteriv(GLenum target, GLenum pname, const GLint* params) {
Graphics3D::GetCurrent()->impl()->TexParameteriv(target, pname, params);
PPB_Graphics3D_Impl::GetCurrent()->impl()->TexParameteriv(target, pname, params);
}
void TexSubImage2D(
GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width,
GLsizei height, GLenum format, GLenum type, const void* pixels) {
Graphics3D::GetCurrent()->impl()->TexSubImage2D(
PPB_Graphics3D_Impl::GetCurrent()->impl()->TexSubImage2D(
target, level, xoffset, yoffset, width, height, format, type, pixels);
}
void Uniform1f(GLint location, GLfloat x) {
Graphics3D::GetCurrent()->impl()->Uniform1f(location, x);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform1f(location, x);
}
void Uniform1fv(GLint location, GLsizei count, const GLfloat* v) {
Graphics3D::GetCurrent()->impl()->Uniform1fv(location, count, v);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform1fv(location, count, v);
}
void Uniform1i(GLint location, GLint x) {
Graphics3D::GetCurrent()->impl()->Uniform1i(location, x);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform1i(location, x);
}
void Uniform1iv(GLint location, GLsizei count, const GLint* v) {
Graphics3D::GetCurrent()->impl()->Uniform1iv(location, count, v);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform1iv(location, count, v);
}
void Uniform2f(GLint location, GLfloat x, GLfloat y) {
Graphics3D::GetCurrent()->impl()->Uniform2f(location, x, y);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform2f(location, x, y);
}
void Uniform2fv(GLint location, GLsizei count, const GLfloat* v) {
Graphics3D::GetCurrent()->impl()->Uniform2fv(location, count, v);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform2fv(location, count, v);
}
void Uniform2i(GLint location, GLint x, GLint y) {
Graphics3D::GetCurrent()->impl()->Uniform2i(location, x, y);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform2i(location, x, y);
}
void Uniform2iv(GLint location, GLsizei count, const GLint* v) {
Graphics3D::GetCurrent()->impl()->Uniform2iv(location, count, v);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform2iv(location, count, v);
}
void Uniform3f(GLint location, GLfloat x, GLfloat y, GLfloat z) {
Graphics3D::GetCurrent()->impl()->Uniform3f(location, x, y, z);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform3f(location, x, y, z);
}
void Uniform3fv(GLint location, GLsizei count, const GLfloat* v) {
Graphics3D::GetCurrent()->impl()->Uniform3fv(location, count, v);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform3fv(location, count, v);
}
void Uniform3i(GLint location, GLint x, GLint y, GLint z) {
Graphics3D::GetCurrent()->impl()->Uniform3i(location, x, y, z);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform3i(location, x, y, z);
}
void Uniform3iv(GLint location, GLsizei count, const GLint* v) {
Graphics3D::GetCurrent()->impl()->Uniform3iv(location, count, v);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform3iv(location, count, v);
}
void Uniform4f(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
Graphics3D::GetCurrent()->impl()->Uniform4f(location, x, y, z, w);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform4f(location, x, y, z, w);
}
void Uniform4fv(GLint location, GLsizei count, const GLfloat* v) {
Graphics3D::GetCurrent()->impl()->Uniform4fv(location, count, v);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform4fv(location, count, v);
}
void Uniform4i(GLint location, GLint x, GLint y, GLint z, GLint w) {
Graphics3D::GetCurrent()->impl()->Uniform4i(location, x, y, z, w);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform4i(location, x, y, z, w);
}
void Uniform4iv(GLint location, GLsizei count, const GLint* v) {
Graphics3D::GetCurrent()->impl()->Uniform4iv(location, count, v);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Uniform4iv(location, count, v);
}
void UniformMatrix2fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
Graphics3D::GetCurrent()->impl()->UniformMatrix2fv(
PPB_Graphics3D_Impl::GetCurrent()->impl()->UniformMatrix2fv(
location, count, transpose, value);
}
void UniformMatrix3fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
Graphics3D::GetCurrent()->impl()->UniformMatrix3fv(
PPB_Graphics3D_Impl::GetCurrent()->impl()->UniformMatrix3fv(
location, count, transpose, value);
}
void UniformMatrix4fv(
GLint location, GLsizei count, GLboolean transpose, const GLfloat* value) {
Graphics3D::GetCurrent()->impl()->UniformMatrix4fv(
PPB_Graphics3D_Impl::GetCurrent()->impl()->UniformMatrix4fv(
location, count, transpose, value);
}
void UseProgram(GLuint program) {
Graphics3D::GetCurrent()->impl()->UseProgram(program);
PPB_Graphics3D_Impl::GetCurrent()->impl()->UseProgram(program);
}
void ValidateProgram(GLuint program) {
Graphics3D::GetCurrent()->impl()->ValidateProgram(program);
PPB_Graphics3D_Impl::GetCurrent()->impl()->ValidateProgram(program);
}
void VertexAttrib1f(GLuint indx, GLfloat x) {
Graphics3D::GetCurrent()->impl()->VertexAttrib1f(indx, x);
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttrib1f(indx, x);
}
void VertexAttrib1fv(GLuint indx, const GLfloat* values) {
Graphics3D::GetCurrent()->impl()->VertexAttrib1fv(indx, values);
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttrib1fv(indx, values);
}
void VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y) {
Graphics3D::GetCurrent()->impl()->VertexAttrib2f(indx, x, y);
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttrib2f(indx, x, y);
}
void VertexAttrib2fv(GLuint indx, const GLfloat* values) {
Graphics3D::GetCurrent()->impl()->VertexAttrib2fv(indx, values);
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttrib2fv(indx, values);
}
void VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z) {
Graphics3D::GetCurrent()->impl()->VertexAttrib3f(indx, x, y, z);
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttrib3f(indx, x, y, z);
}
void VertexAttrib3fv(GLuint indx, const GLfloat* values) {
Graphics3D::GetCurrent()->impl()->VertexAttrib3fv(indx, values);
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttrib3fv(indx, values);
}
void VertexAttrib4f(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) {
Graphics3D::GetCurrent()->impl()->VertexAttrib4f(indx, x, y, z, w);
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttrib4f(indx, x, y, z, w);
}
void VertexAttrib4fv(GLuint indx, const GLfloat* values) {
Graphics3D::GetCurrent()->impl()->VertexAttrib4fv(indx, values);
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttrib4fv(indx, values);
}
void VertexAttribPointer(
GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride,
const void* ptr) {
Graphics3D::GetCurrent()->impl()->VertexAttribPointer(
PPB_Graphics3D_Impl::GetCurrent()->impl()->VertexAttribPointer(
indx, size, type, normalized, stride, ptr);
}
void Viewport(GLint x, GLint y, GLsizei width, GLsizei height) {
Graphics3D::GetCurrent()->impl()->Viewport(x, y, width, height);
PPB_Graphics3D_Impl::GetCurrent()->impl()->Viewport(x, y, width, height);
}
void SwapBuffers() {
Graphics3D::GetCurrent()->impl()->SwapBuffers();
PPB_Graphics3D_Impl::GetCurrent()->impl()->SwapBuffers();
}
const struct PPB_OpenGLES_Dev ppb_opengles = {
@ -663,9 +664,10 @@ const struct PPB_OpenGLES_Dev ppb_opengles = {
} // namespace
const PPB_OpenGLES_Dev* Graphics3D::GetOpenGLESInterface() {
const PPB_OpenGLES_Dev* PPB_Graphics3D_Impl::GetOpenGLESInterface() {
return &ppb_opengles;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -11,7 +11,7 @@
#include "ppapi/c/pp_resource.h"
#include "ppapi/c/pp_var.h"
#define PPB_PRIVATE_INTERFACE "PPB_Private;1"
#define PPB_PDF_INTERFACE "PPB_PDF;1"
// From the public PPB_Font_Dev file.
struct PP_FontDescription_Dev;
@ -81,7 +81,7 @@ struct PP_PrivateFindResult {
int length;
};
struct PPB_Private {
struct PPB_PDF {
// Returns a localized string.
PP_Var (*GetLocalizedString)(PP_Module module, PP_ResourceString string_id);
@ -115,9 +115,9 @@ struct PPB_Private {
PP_PrivateFindResult** results,
int* count);
// Since WebFrame doesn't know about Pepper requests, it'll think the page has
// Since WebFrame doesn't know about PPAPI requests, it'll think the page has
// finished loading even if there are outstanding requests by the plugin.
// Take this out once WebFrame knows about requests by pepper plugins.
// Take this out once WebFrame knows about requests by PPAPI plugins.
void (*DidStartLoading)(PP_Instance instance);
void (*DidStopLoading)(PP_Instance instance);

@ -2,30 +2,28 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "build/build_config.h"
#include "webkit/glue/plugins/pepper_private.h"
#include "unicode/usearch.h"
#include "webkit/plugins/ppapi/ppb_pdf_impl.h"
#include "app/resource_bundle.h"
#include "base/metrics/histogram.h"
#include "base/utf_string_conversions.h"
#include "build/build_config.h"
#include "grit/webkit_resources.h"
#include "grit/webkit_strings.h"
#include "skia/ext/platform_canvas.h"
#include "ppapi/c/pp_resource.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/icu/public/i18n/unicode/usearch.h"
#include "webkit/glue/webkit_glue.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_delegate.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/glue/plugins/ppb_private.h"
#include "webkit/glue/plugins/pepper_var.h"
#include "webkit/plugins/ppapi/plugin_delegate.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/plugins/ppapi/ppb_pdf.h"
#include "webkit/plugins/ppapi/var.h"
namespace pepper {
namespace webkit {
namespace ppapi {
#if defined(OS_LINUX)
class PrivateFontFile : public Resource {
@ -120,8 +118,8 @@ PP_Resource GetResourceImage(PP_Module module_id, PP_ResourceImage image_id) {
PluginModule* module = ResourceTracker::Get()->GetModule(module_id);
if (!module)
return 0;
scoped_refptr<pepper::ImageData> image_data(new pepper::ImageData(module));
if (!image_data->Init(ImageData::GetNativeImageDataFormat(),
scoped_refptr<PPB_ImageData_Impl> image_data(new PPB_ImageData_Impl(module));
if (!image_data->Init(PPB_ImageData_Impl::GetNativeImageDataFormat(),
res_bitmap->width(), res_bitmap->height(), false)) {
return 0;
}
@ -165,7 +163,7 @@ PP_Resource GetFontFileWithFallback(
return font->GetReference();
#else
// For trusted pepper plugins, this is only needed in Linux since font loading
// For trusted PPAPI plugins, this is only needed in Linux since font loading
// on Windows and Mac works through the renderer sandbox.
return 0;
#endif
@ -267,7 +265,7 @@ void UserMetricsRecordAction(PP_Var action) {
webkit_glue::UserMetricsRecordAction(action_str->value());
}
const PPB_Private ppb_private = {
const PPB_PDF ppb_pdf = {
&GetLocalizedString,
&GetResourceImage,
&GetFontFileWithFallback,
@ -283,8 +281,8 @@ const PPB_Private ppb_private = {
} // namespace
// static
const PPB_Private* Private::GetInterface() {
return &ppb_private;
const PPB_PDF* PPB_PDF_Impl::GetInterface() {
return &ppb_pdf;
}
#if defined(OS_LINUX)
@ -299,4 +297,6 @@ bool PrivateFontFile::GetFontTable(uint32_t table,
}
#endif
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -0,0 +1,25 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PPB_PDF_IMPL_H_
#define WEBKIT_GLUE_PLUGINS_PPB_PDF_IMPL_H_
#include "webkit/plugins/ppapi/resource.h"
struct PPB_PDF;
namespace webkit {
namespace ppapi {
class PPB_PDF_Impl {
public:
// Returns a pointer to the interface implementing PPB_PDF that is exposed
// to the plugin.
static const PPB_PDF* GetInterface();
};
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PPB_PDF_IMPL_H_

@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_scrollbar.h"
#include "webkit/plugins/ppapi/ppb_scrollbar_impl.h"
#include "base/logging.h"
#include "base/message_loop.h"
@ -12,11 +12,11 @@
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScrollbar.h"
#include "third_party/WebKit/WebKit/chromium/public/WebVector.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_event_conversion.h"
#include "webkit/glue/plugins/pepper_image_data.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/event_conversion.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
#include "webkit/glue/webkit_glue.h"
#if defined(OS_WIN)
@ -27,7 +27,8 @@ using WebKit::WebInputEvent;
using WebKit::WebRect;
using WebKit::WebScrollbar;
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -36,13 +37,13 @@ PP_Resource Create(PP_Instance instance_id, PP_Bool vertical) {
if (!instance)
return 0;
scoped_refptr<Scrollbar> scrollbar(new Scrollbar(instance,
PPBoolToBool(vertical)));
scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
new PPB_Scrollbar_Impl(instance, PPBoolToBool(vertical)));
return scrollbar->GetReference();
}
PP_Bool IsScrollbar(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<Scrollbar>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_Scrollbar_Impl>(resource));
}
uint32_t GetThickness() {
@ -50,20 +51,23 @@ uint32_t GetThickness() {
}
uint32_t GetValue(PP_Resource resource) {
scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource));
scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
Resource::GetAs<PPB_Scrollbar_Impl>(resource));
if (!scrollbar)
return 0;
return scrollbar->GetValue();
}
void SetValue(PP_Resource resource, uint32_t value) {
scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource));
scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
Resource::GetAs<PPB_Scrollbar_Impl>(resource));
if (scrollbar)
scrollbar->SetValue(value);
}
void SetDocumentSize(PP_Resource resource, uint32_t size) {
scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource));
scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
Resource::GetAs<PPB_Scrollbar_Impl>(resource));
if (scrollbar)
scrollbar->SetDocumentSize(size);
}
@ -71,13 +75,15 @@ void SetDocumentSize(PP_Resource resource, uint32_t size) {
void SetTickMarks(PP_Resource resource,
const PP_Rect* tick_marks,
uint32_t count) {
scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource));
scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
Resource::GetAs<PPB_Scrollbar_Impl>(resource));
if (scrollbar)
scrollbar->SetTickMarks(tick_marks, count);
}
void ScrollBy(PP_Resource resource, PP_ScrollBy_Dev unit, int32_t multiplier) {
scoped_refptr<Scrollbar> scrollbar(Resource::GetAs<Scrollbar>(resource));
scoped_refptr<PPB_Scrollbar_Impl> scrollbar(
Resource::GetAs<PPB_Scrollbar_Impl>(resource));
if (scrollbar)
scrollbar->ScrollBy(unit, multiplier);
}
@ -95,38 +101,39 @@ const PPB_Scrollbar_Dev ppb_scrollbar = {
} // namespace
Scrollbar::Scrollbar(PluginInstance* instance, bool vertical)
: Widget(instance) {
PPB_Scrollbar_Impl::PPB_Scrollbar_Impl(PluginInstance* instance, bool vertical)
: PPB_Widget_Impl(instance) {
scrollbar_.reset(WebScrollbar::create(
static_cast<WebKit::WebScrollbarClient*>(this),
vertical ? WebScrollbar::Vertical : WebScrollbar::Horizontal));
}
Scrollbar::~Scrollbar() {
PPB_Scrollbar_Impl::~PPB_Scrollbar_Impl() {
}
// static
const PPB_Scrollbar_Dev* Scrollbar::GetInterface() {
const PPB_Scrollbar_Dev* PPB_Scrollbar_Impl::GetInterface() {
return &ppb_scrollbar;
}
Scrollbar* Scrollbar::AsScrollbar() {
PPB_Scrollbar_Impl* PPB_Scrollbar_Impl::AsPPB_Scrollbar_Impl() {
return this;
}
uint32_t Scrollbar::GetValue() {
uint32_t PPB_Scrollbar_Impl::GetValue() {
return scrollbar_->value();
}
void Scrollbar::SetValue(uint32_t value) {
void PPB_Scrollbar_Impl::SetValue(uint32_t value) {
scrollbar_->setValue(value);
}
void Scrollbar::SetDocumentSize(uint32_t size) {
void PPB_Scrollbar_Impl::SetDocumentSize(uint32_t size) {
scrollbar_->setDocumentSize(size);
}
void Scrollbar::SetTickMarks(const PP_Rect* tick_marks, uint32_t count) {
void PPB_Scrollbar_Impl::SetTickMarks(const PP_Rect* tick_marks,
uint32_t count) {
tickmarks_.resize(count);
for (uint32 i = 0; i < count; ++i) {
tickmarks_[i] = WebRect(tick_marks[i].point.x,
@ -138,7 +145,7 @@ void Scrollbar::SetTickMarks(const PP_Rect* tick_marks, uint32_t count) {
Invalidate(&rect);
}
void Scrollbar::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) {
void PPB_Scrollbar_Impl::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) {
WebScrollbar::ScrollDirection direction = multiplier >= 0 ?
WebScrollbar::ScrollForward : WebScrollbar::ScrollBackward;
float fmultiplier = 1.0;
@ -159,7 +166,7 @@ void Scrollbar::ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier) {
scrollbar_->scroll(direction, granularity, fmultiplier);
}
bool Scrollbar::Paint(const PP_Rect* rect, ImageData* image) {
bool PPB_Scrollbar_Impl::Paint(const PP_Rect* rect, PPB_ImageData_Impl* image) {
gfx::Rect gfx_rect(rect->point.x,
rect->point.y,
rect->size.width,
@ -179,7 +186,7 @@ bool Scrollbar::Paint(const PP_Rect* rect, ImageData* image) {
return true;
}
bool Scrollbar::HandleEvent(const PP_InputEvent* event) {
bool PPB_Scrollbar_Impl::HandleEvent(const PP_InputEvent* event) {
scoped_ptr<WebInputEvent> web_input_event(CreateWebInputEvent(*event));
if (!web_input_event.get())
return false;
@ -187,14 +194,14 @@ bool Scrollbar::HandleEvent(const PP_InputEvent* event) {
return scrollbar_->handleInputEvent(*web_input_event.get());
}
void Scrollbar::SetLocationInternal(const PP_Rect* location) {
void PPB_Scrollbar_Impl::SetLocationInternal(const PP_Rect* location) {
scrollbar_->setLocation(WebRect(location->point.x,
location->point.y,
location->size.width,
location->size.height));
}
void Scrollbar::valueChanged(WebKit::WebScrollbar* scrollbar) {
void PPB_Scrollbar_Impl::valueChanged(WebKit::WebScrollbar* scrollbar) {
const PPP_Scrollbar_Dev* ppp_scrollbar =
static_cast<const PPP_Scrollbar_Dev*>(
module()->GetPluginInterface(PPP_SCROLLBAR_DEV_INTERFACE));
@ -205,22 +212,23 @@ void Scrollbar::valueChanged(WebKit::WebScrollbar* scrollbar) {
instance()->pp_instance(), resource.id, scrollbar_->value());
}
void Scrollbar::invalidateScrollbarRect(WebKit::WebScrollbar* scrollbar,
const WebKit::WebRect& rect) {
void PPB_Scrollbar_Impl::invalidateScrollbarRect(
WebKit::WebScrollbar* scrollbar,
const WebKit::WebRect& rect) {
gfx::Rect gfx_rect(rect.x,
rect.y,
rect.width,
rect.height);
dirty_ = dirty_.Union(gfx_rect);
// Can't call into the client to tell them about the invalidate right away,
// since the Scrollbar code is still in the middle of updating its internal
// state.
// since the PPB_Scrollbar_Impl code is still in the middle of updating its
// internal state.
MessageLoop::current()->PostTask(
FROM_HERE,
NewRunnableMethod(this, &Scrollbar::NotifyInvalidate));
NewRunnableMethod(this, &PPB_Scrollbar_Impl::NotifyInvalidate));
}
void Scrollbar::getTickmarks(
void PPB_Scrollbar_Impl::getTickmarks(
WebKit::WebScrollbar* scrollbar,
WebKit::WebVector<WebKit::WebRect>* tick_marks) const {
if (tickmarks_.empty()) {
@ -231,7 +239,7 @@ void Scrollbar::getTickmarks(
}
}
void Scrollbar::NotifyInvalidate() {
void PPB_Scrollbar_Impl::NotifyInvalidate() {
if (dirty_.IsEmpty())
return;
PP_Rect pp_rect;
@ -243,4 +251,6 @@ void Scrollbar::NotifyInvalidate() {
Invalidate(&pp_rect);
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_SCROLLBAR_H_
#define WEBKIT_GLUE_PLUGINS_PEPPER_SCROLLBAR_H_
#ifndef WEBKIT_PLUGINS_PPAPI_PPB_SCROLLBAR_IMPL_H_
#define WEBKIT_PLUGINS_PPAPI_PPB_SCROLLBAR_IMPL_H_
#include <vector>
@ -11,23 +11,25 @@
#include "ppapi/c/dev/ppb_scrollbar_dev.h"
#include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
#include "third_party/WebKit/WebKit/chromium/public/WebScrollbarClient.h"
#include "webkit/glue/plugins/pepper_widget.h"
#include "webkit/plugins/ppapi/ppb_widget_impl.h"
namespace pepper {
namespace webkit {
namespace ppapi {
class PluginInstance;
class Scrollbar : public Widget, public WebKit::WebScrollbarClient {
class PPB_Scrollbar_Impl : public PPB_Widget_Impl,
public WebKit::WebScrollbarClient {
public:
Scrollbar(PluginInstance* instance, bool vertical);
virtual ~Scrollbar();
PPB_Scrollbar_Impl(PluginInstance* instance, bool vertical);
virtual ~PPB_Scrollbar_Impl();
// Returns a pointer to the interface implementing PPB_Scrollbar that is
// exposed to the plugin.
static const PPB_Scrollbar_Dev* GetInterface();
// Resource overrides.
virtual Scrollbar* AsScrollbar();
virtual PPB_Scrollbar_Impl* AsPPB_Scrollbar_Impl();
// PPB_Scrollbar implementation.
uint32_t GetValue();
@ -37,7 +39,7 @@ class Scrollbar : public Widget, public WebKit::WebScrollbarClient {
void ScrollBy(PP_ScrollBy_Dev unit, int32_t multiplier);
// PPB_Widget implementation.
virtual bool Paint(const PP_Rect* rect, ImageData* image);
virtual bool Paint(const PP_Rect* rect, PPB_ImageData_Impl* image);
virtual bool HandleEvent(const PP_InputEvent* event);
virtual void SetLocationInternal(const PP_Rect* location);
@ -55,8 +57,11 @@ class Scrollbar : public Widget, public WebKit::WebScrollbarClient {
gfx::Rect dirty_;
std::vector<WebKit::WebRect> tickmarks_;
scoped_ptr<WebKit::WebScrollbar> scrollbar_;
DISALLOW_COPY_AND_ASSIGN(PPB_Scrollbar_Impl);
};
} // namespace pepper
} // namespace ppapi
} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_SCROLLBAR_H_
#endif // WEBKIT_PLUGINS_PPAPI_PPB_SCROLLBAR_IMPL_H_

@ -2,16 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "webkit/glue/plugins/pepper_transport.h"
#include "webkit/plugins/ppapi/ppb_transport_impl.h"
#include "base/singleton.h"
#include "base/thread_local.h"
#include "ppapi/c/dev/ppb_transport_dev.h"
#include "webkit/glue/plugins/pepper_common.h"
#include "webkit/glue/plugins/pepper_plugin_instance.h"
#include "webkit/glue/plugins/pepper_plugin_module.h"
#include "webkit/plugins/ppapi/common.h"
#include "webkit/plugins/ppapi/plugin_module.h"
#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
namespace pepper {
namespace webkit {
namespace ppapi {
namespace {
@ -25,9 +26,9 @@ PP_Resource CreateTransport(PP_Module module,
return p;
}
// Returns whether or not resource is Transport
// Returns whether or not resource is PPB_Transport_Impl
PP_Bool IsTransport(PP_Resource resource) {
return BoolToPPBool(!!Resource::GetAs<Transport>(resource));
return BoolToPPBool(!!Resource::GetAs<PPB_Transport_Impl>(resource));
}
// Returns whether the transport is currently writable
@ -117,28 +118,28 @@ const PPB_Transport_Dev ppb_transport = {
} // namespace
Transport::Transport(PluginModule* module)
PPB_Transport_Impl::PPB_Transport_Impl(PluginModule* module)
: Resource(module) {
// TODO(juberti): impl
}
const PPB_Transport_Dev* Transport::GetInterface() {
const PPB_Transport_Dev* PPB_Transport_Impl::GetInterface() {
return &ppb_transport;
}
Transport::~Transport() {
PPB_Transport_Impl::~PPB_Transport_Impl() {
// TODO(juberti): teardown
}
Transport* Transport::AsTransport() {
PPB_Transport_Impl* PPB_Transport_Impl::AsPPB_Transport_Impl() {
return this;
}
bool Transport::Init(const char* name,
const char* proto) {
bool PPB_Transport_Impl::Init(const char* name, const char* proto) {
// TODO(juberti): impl
return false;
}
} // namespace pepper
} // namespace ppapi
} // namespace webkit

Some files were not shown because too many files have changed in this diff Show More