summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/pepper_dir_contents.h18
-rw-r--r--webkit/glue/plugins/pepper_file_ref.h62
-rw-r--r--webkit/glue/plugins/pepper_plugin_object.cc891
-rw-r--r--webkit/glue/plugins/pepper_private.h23
-rw-r--r--webkit/glue/plugins/pepper_transport.h33
-rw-r--r--webkit/glue/plugins/pepper_url_util.h19
-rw-r--r--webkit/glue/plugins/plugin_list.cc2
-rw-r--r--webkit/glue/webkit_glue.gypi165
-rw-r--r--webkit/plugins/plugin_switches.cc (renamed from webkit/glue/plugins/plugin_switches.cc)2
-rw-r--r--webkit/plugins/plugin_switches.h (renamed from webkit/glue/plugins/plugin_switches.h)6
-rw-r--r--webkit/plugins/ppapi/DEPS8
-rw-r--r--webkit/plugins/ppapi/common.h (renamed from webkit/glue/plugins/pepper_common.h)12
-rw-r--r--webkit/plugins/ppapi/dir_contents.h25
-rw-r--r--webkit/plugins/ppapi/error_util.cc (renamed from webkit/glue/plugins/pepper_error_util.cc)9
-rw-r--r--webkit/plugins/ppapi/error_util.h (renamed from webkit/glue/plugins/pepper_error_util.h)12
-rw-r--r--webkit/plugins/ppapi/event_conversion.cc (renamed from webkit/glue/plugins/pepper_event_conversion.cc)15
-rw-r--r--webkit/plugins/ppapi/event_conversion.h (renamed from webkit/glue/plugins/pepper_event_conversion.h)12
-rw-r--r--webkit/plugins/ppapi/file_callbacks.cc (renamed from webkit/glue/plugins/pepper_file_callbacks.cc)28
-rw-r--r--webkit/plugins/ppapi/file_callbacks.h (renamed from webkit/glue/plugins/pepper_file_callbacks.h)24
-rw-r--r--webkit/plugins/ppapi/fullscreen_container.h (renamed from webkit/glue/plugins/pepper_fullscreen_container.h)14
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.cc (renamed from webkit/glue/plugins/mock_plugin_delegate.cc)15
-rw-r--r--webkit/plugins/ppapi/mock_plugin_delegate.h (renamed from webkit/glue/plugins/mock_plugin_delegate.h)20
-rw-r--r--webkit/plugins/ppapi/mock_resource.h (renamed from webkit/glue/plugins/mock_resource.h)14
-rw-r--r--webkit/plugins/ppapi/npapi_glue.cc199
-rw-r--r--webkit/plugins/ppapi/npapi_glue.h188
-rw-r--r--webkit/plugins/ppapi/plugin_delegate.h (renamed from webkit/glue/plugins/pepper_plugin_delegate.h)26
-rw-r--r--webkit/plugins/ppapi/plugin_module.cc (renamed from webkit/glue/plugins/pepper_plugin_module.cc)204
-rw-r--r--webkit/plugins/ppapi/plugin_module.h (renamed from webkit/glue/plugins/pepper_plugin_module.h)14
-rw-r--r--webkit/plugins/ppapi/plugin_object.cc333
-rw-r--r--webkit/plugins/ppapi/plugin_object.h (renamed from webkit/glue/plugins/pepper_plugin_object.h)12
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.cc (renamed from webkit/glue/plugins/pepper_plugin_instance.cc)97
-rw-r--r--webkit/plugins/ppapi/ppapi_plugin_instance.h (renamed from webkit/glue/plugins/pepper_plugin_instance.h)38
-rw-r--r--webkit/plugins/ppapi/ppapi_unittest.cc (renamed from webkit/glue/plugins/ppapi_unittest.cc)22
-rw-r--r--webkit/plugins/ppapi/ppapi_unittest.h (renamed from webkit/glue/plugins/ppapi_unittest.h)12
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.cc (renamed from webkit/glue/plugins/pepper_webplugin_impl.cc)19
-rw-r--r--webkit/plugins/ppapi/ppapi_webplugin_impl.h (renamed from webkit/glue/plugins/pepper_webplugin_impl.h)16
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.cc (renamed from webkit/glue/plugins/pepper_audio.cc)110
-rw-r--r--webkit/plugins/ppapi/ppb_audio_impl.h (renamed from webkit/glue/plugins/pepper_audio.h)49
-rw-r--r--webkit/plugins/ppapi/ppb_buffer_impl.cc (renamed from webkit/glue/plugins/pepper_buffer.cc)54
-rw-r--r--webkit/plugins/ppapi/ppb_buffer_impl.h (renamed from webkit/glue/plugins/pepper_buffer.h)31
-rw-r--r--webkit/plugins/ppapi/ppb_char_set_impl.cc (renamed from webkit/glue/plugins/pepper_char_set.cc)21
-rw-r--r--webkit/plugins/ppapi/ppb_char_set_impl.h (renamed from webkit/glue/plugins/pepper_char_set.h)14
-rw-r--r--webkit/plugins/ppapi/ppb_cursor_control_impl.cc (renamed from webkit/glue/plugins/pepper_cursor_control.cc)26
-rw-r--r--webkit/plugins/ppapi/ppb_cursor_control_impl.h (renamed from webkit/glue/plugins/pepper_cursor_control.h)12
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.cc (renamed from webkit/glue/plugins/pepper_directory_reader.cc)63
-rw-r--r--webkit/plugins/ppapi/ppb_directory_reader_impl.h (renamed from webkit/glue/plugins/pepper_directory_reader.h)26
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.cc (renamed from webkit/glue/plugins/pepper_file_chooser.cc)54
-rw-r--r--webkit/plugins/ppapi/ppb_file_chooser_impl.h (renamed from webkit/glue/plugins/pepper_file_chooser.h)27
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.cc (renamed from webkit/glue/plugins/pepper_file_io.cc)136
-rw-r--r--webkit/plugins/ppapi/ppb_file_io_impl.h (renamed from webkit/glue/plugins/pepper_file_io.h)32
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.cc (renamed from webkit/glue/plugins/pepper_file_ref.cc)114
-rw-r--r--webkit/plugins/ppapi/ppb_file_ref_impl.h66
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.cc (renamed from webkit/glue/plugins/pepper_file_system.cc)37
-rw-r--r--webkit/plugins/ppapi/ppb_file_system_impl.h (renamed from webkit/glue/plugins/pepper_file_system.h)22
-rw-r--r--webkit/plugins/ppapi/ppb_flash.h (renamed from webkit/glue/plugins/ppb_private2.h)10
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.cc (renamed from webkit/glue/plugins/pepper_private2.cc)31
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl.h (renamed from webkit/glue/plugins/pepper_private2.h)26
-rw-r--r--webkit/plugins/ppapi/ppb_flash_impl_linux.cc (renamed from webkit/glue/plugins/pepper_private2_linux.cc)38
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.cc (renamed from webkit/glue/plugins/pepper_font.cc)76
-rw-r--r--webkit/plugins/ppapi/ppb_font_impl.h (renamed from webkit/glue/plugins/pepper_font.h)25
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.cc (renamed from webkit/glue/plugins/pepper_graphics_2d.cc)148
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_2d_impl.h (renamed from webkit/glue/plugins/pepper_graphics_2d.h)34
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.cc (renamed from webkit/glue/plugins/pepper_graphics_3d.cc)67
-rw-r--r--webkit/plugins/ppapi/ppb_graphics_3d_impl.h (renamed from webkit/glue/plugins/pepper_graphics_3d.h)33
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.cc (renamed from webkit/glue/plugins/pepper_image_data.cc)68
-rw-r--r--webkit/plugins/ppapi/ppb_image_data_impl.h (renamed from webkit/glue/plugins/pepper_image_data.h)35
-rw-r--r--webkit/plugins/ppapi/ppb_open_gl_es_impl.cc (renamed from webkit/glue/plugins/pepper_graphics_3d_gl.cc)296
-rw-r--r--webkit/plugins/ppapi/ppb_pdf.h (renamed from webkit/glue/plugins/ppb_private.h)8
-rw-r--r--webkit/plugins/ppapi/ppb_pdf_impl.cc (renamed from webkit/glue/plugins/pepper_private.cc)40
-rw-r--r--webkit/plugins/ppapi/ppb_pdf_impl.h25
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.cc (renamed from webkit/glue/plugins/pepper_scrollbar.cc)84
-rw-r--r--webkit/plugins/ppapi/ppb_scrollbar_impl.h (renamed from webkit/glue/plugins/pepper_scrollbar.h)27
-rw-r--r--webkit/plugins/ppapi/ppb_transport_impl.cc (renamed from webkit/glue/plugins/pepper_transport.cc)29
-rw-r--r--webkit/plugins/ppapi/ppb_transport_impl.h38
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.cc (renamed from webkit/glue/plugins/pepper_url_loader.cc)159
-rw-r--r--webkit/plugins/ppapi/ppb_url_loader_impl.h (renamed from webkit/glue/plugins/pepper_url_loader.h)41
-rw-r--r--webkit/plugins/ppapi/ppb_url_request_info_impl.cc (renamed from webkit/glue/plugins/pepper_url_request_info.cc)73
-rw-r--r--webkit/plugins/ppapi/ppb_url_request_info_impl.h (renamed from webkit/glue/plugins/pepper_url_request_info.h)29
-rw-r--r--webkit/plugins/ppapi/ppb_url_response_info_impl.cc (renamed from webkit/glue/plugins/pepper_url_response_info.cc)43
-rw-r--r--webkit/plugins/ppapi/ppb_url_response_info_impl.h (renamed from webkit/glue/plugins/pepper_url_response_info.h)31
-rw-r--r--webkit/plugins/ppapi/ppb_url_util_impl.cc (renamed from webkit/glue/plugins/pepper_url_util.cc)19
-rw-r--r--webkit/plugins/ppapi/ppb_url_util_impl.h21
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.cc (renamed from webkit/glue/plugins/pepper_video_decoder.cc)65
-rw-r--r--webkit/plugins/ppapi/ppb_video_decoder_impl.h (renamed from webkit/glue/plugins/pepper_video_decoder.h)29
-rw-r--r--webkit/plugins/ppapi/ppb_widget_impl.cc (renamed from webkit/glue/plugins/pepper_widget.cc)52
-rw-r--r--webkit/plugins/ppapi/ppb_widget_impl.h (renamed from webkit/glue/plugins/pepper_widget.h)29
-rw-r--r--webkit/plugins/ppapi/ppp_pdf.h (renamed from webkit/glue/plugins/ppp_private.h)10
-rw-r--r--webkit/plugins/ppapi/resource.cc (renamed from webkit/glue/plugins/pepper_resource.cc)11
-rw-r--r--webkit/plugins/ppapi/resource.h (renamed from webkit/glue/plugins/pepper_resource.h)59
-rw-r--r--webkit/plugins/ppapi/resource_tracker.cc (renamed from webkit/glue/plugins/pepper_resource_tracker.cc)15
-rw-r--r--webkit/plugins/ppapi/resource_tracker.h (renamed from webkit/glue/plugins/pepper_resource_tracker.h)12
-rw-r--r--webkit/plugins/ppapi/resource_tracker_unittest.cc (renamed from webkit/glue/plugins/resource_tracker_unittest.cc)13
-rw-r--r--webkit/plugins/ppapi/string.cc (renamed from webkit/glue/plugins/pepper_string.cc)9
-rw-r--r--webkit/plugins/ppapi/string.h (renamed from webkit/glue/plugins/pepper_string.h)6
-rw-r--r--webkit/plugins/ppapi/var.cc (renamed from webkit/glue/plugins/pepper_var.cc)17
-rw-r--r--webkit/plugins/ppapi/var.h (renamed from webkit/glue/plugins/pepper_var.h)14
-rw-r--r--webkit/plugins/ppapi/var_object_class.cc286
-rw-r--r--webkit/plugins/ppapi/var_object_class.h (renamed from webkit/glue/plugins/pepper_class.h)29
-rw-r--r--webkit/tools/test_shell/test_shell.gypi12
99 files changed, 3097 insertions, 2628 deletions
diff --git a/webkit/glue/plugins/pepper_dir_contents.h b/webkit/glue/plugins/pepper_dir_contents.h
deleted file mode 100644
index 661c577..0000000
--- a/webkit/glue/plugins/pepper_dir_contents.h
+++ /dev/null
@@ -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_
diff --git a/webkit/glue/plugins/pepper_file_ref.h b/webkit/glue/plugins/pepper_file_ref.h
deleted file mode 100644
index d0a0439..0000000
--- a/webkit/glue/plugins/pepper_file_ref.h
+++ /dev/null
@@ -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_
diff --git a/webkit/glue/plugins/pepper_plugin_object.cc b/webkit/glue/plugins/pepper_plugin_object.cc
deleted file mode 100644
index 47fbcaf..0000000
--- a/webkit/glue/plugins/pepper_plugin_object.cc
+++ /dev/null
@@ -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
diff --git a/webkit/glue/plugins/pepper_private.h b/webkit/glue/plugins/pepper_private.h
deleted file mode 100644
index 06016f0..0000000
--- a/webkit/glue/plugins/pepper_private.h
+++ /dev/null
@@ -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_
diff --git a/webkit/glue/plugins/pepper_transport.h b/webkit/glue/plugins/pepper_transport.h
deleted file mode 100644
index 500dda0..0000000
--- a/webkit/glue/plugins/pepper_transport.h
+++ /dev/null
@@ -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_
-
diff --git a/webkit/glue/plugins/pepper_url_util.h b/webkit/glue/plugins/pepper_url_util.h
deleted file mode 100644
index ffb7c76..0000000
--- a/webkit/glue/plugins/pepper_url_util.h
+++ /dev/null
@@ -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_
diff --git a/webkit/glue/plugins/plugin_list.cc b/webkit/glue/plugins/plugin_list.cc
index d682cce..3916100 100644
--- a/webkit/glue/plugins/plugin_list.cc
+++ b/webkit/glue/plugins/plugin_list.cc
@@ -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"
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 53ad0dd..1b9aa85 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -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',
],
diff --git a/webkit/glue/plugins/plugin_switches.cc b/webkit/plugins/plugin_switches.cc
index eb5c958..be3342c 100644
--- a/webkit/glue/plugins/plugin_switches.cc
+++ b/webkit/plugins/plugin_switches.cc
@@ -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 {
diff --git a/webkit/glue/plugins/plugin_switches.h b/webkit/plugins/plugin_switches.h
index 772c0476..7497ec1 100644
--- a/webkit/glue/plugins/plugin_switches.h
+++ b/webkit/plugins/plugin_switches.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_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_
diff --git a/webkit/plugins/ppapi/DEPS b/webkit/plugins/ppapi/DEPS
new file mode 100644
index 0000000..884f203
--- /dev/null
+++ b/webkit/plugins/ppapi/DEPS
@@ -0,0 +1,8 @@
+include_rules = [
+ "+app",
+ "+gpu/command_buffer",
+ "+ppapi/c",
+ "+ppapi/shared_impl",
+ "+printing",
+ "+skia",
+]
diff --git a/webkit/glue/plugins/pepper_common.h b/webkit/plugins/ppapi/common.h
index be9fe3d..542bad9 100644
--- a/webkit/glue/plugins/pepper_common.h
+++ b/webkit/plugins/ppapi/common.h
@@ -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_
diff --git a/webkit/plugins/ppapi/dir_contents.h b/webkit/plugins/ppapi/dir_contents.h
new file mode 100644
index 0000000..f9a6c45
--- /dev/null
+++ b/webkit/plugins/ppapi/dir_contents.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_
diff --git a/webkit/glue/plugins/pepper_error_util.cc b/webkit/plugins/ppapi/error_util.cc
index 7472d4a..0ff127d 100644
--- a/webkit/glue/plugins/pepper_error_util.cc
+++ b/webkit/plugins/ppapi/error_util.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_error_util.h b/webkit/plugins/ppapi/error_util.h
index 12e715c..660f7d2 100644
--- a/webkit/glue/plugins/pepper_error_util.h
+++ b/webkit/plugins/ppapi/error_util.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_event_conversion.cc b/webkit/plugins/ppapi/event_conversion.cc
index 300592f..c5e8fac 100644
--- a/webkit/glue/plugins/pepper_event_conversion.cc
+++ b/webkit/plugins/ppapi/event_conversion.cc
@@ -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
diff --git a/webkit/glue/plugins/pepper_event_conversion.h b/webkit/plugins/ppapi/event_conversion.h
index 9eab3e4..71beee6 100644
--- a/webkit/glue/plugins/pepper_event_conversion.h
+++ b/webkit/plugins/ppapi/event_conversion.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_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_
diff --git a/webkit/glue/plugins/pepper_file_callbacks.cc b/webkit/plugins/ppapi/file_callbacks.cc
index e24927a..9f991be 100644
--- a/webkit/glue/plugins/pepper_file_callbacks.cc
+++ b/webkit/plugins/ppapi/file_callbacks.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_file_callbacks.h b/webkit/plugins/ppapi/file_callbacks.h
index d4a92f2c..4b96d1c 100644
--- a/webkit/glue/plugins/pepper_file_callbacks.h
+++ b/webkit/plugins/ppapi/file_callbacks.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_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_
diff --git a/webkit/glue/plugins/pepper_fullscreen_container.h b/webkit/plugins/ppapi/fullscreen_container.h
index 7d86320..8318282 100644
--- a/webkit/glue/plugins/pepper_fullscreen_container.h
+++ b/webkit/plugins/ppapi/fullscreen_container.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_
diff --git a/webkit/glue/plugins/mock_plugin_delegate.cc b/webkit/plugins/ppapi/mock_plugin_delegate.cc
index 1d2be93..93ace2c 100644
--- a/webkit/glue/plugins/mock_plugin_delegate.cc
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.cc
@@ -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
+
diff --git a/webkit/glue/plugins/mock_plugin_delegate.h b/webkit/plugins/ppapi/mock_plugin_delegate.h
index 41c477e..4f83a80 100644
--- a/webkit/glue/plugins/mock_plugin_delegate.h
+++ b/webkit/plugins/ppapi/mock_plugin_delegate.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.
-#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_
diff --git a/webkit/glue/plugins/mock_resource.h b/webkit/plugins/ppapi/mock_resource.h
index 2b4cb48a..081c990 100644
--- a/webkit/glue/plugins/mock_resource.h
+++ b/webkit/plugins/ppapi/mock_resource.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_
diff --git a/webkit/plugins/ppapi/npapi_glue.cc b/webkit/plugins/ppapi/npapi_glue.cc
new file mode 100644
index 0000000..d22c13f
--- /dev/null
+++ b/webkit/plugins/ppapi/npapi_glue.cc
@@ -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
diff --git a/webkit/plugins/ppapi/npapi_glue.h b/webkit/plugins/ppapi/npapi_glue.h
new file mode 100644
index 0000000..11fd82a
--- /dev/null
+++ b/webkit/plugins/ppapi/npapi_glue.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_plugin_delegate.h b/webkit/plugins/ppapi/plugin_delegate.h
index 37a25d3..fef6cff 100644
--- a/webkit/glue/plugins/pepper_plugin_delegate.h
+++ b/webkit/plugins/ppapi/plugin_delegate.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_
diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/plugins/ppapi/plugin_module.cc
index 24dd4e2..96eadfb 100644
--- a/webkit/glue/plugins/pepper_plugin_module.cc
+++ b/webkit/plugins/ppapi/plugin_module.cc
@@ -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) {
- if (strcmp(name, PPB_CORE_INTERFACE) == 0)
- return &core_interface;
- 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();
+ // Please keep alphabetized by interface macro name with "special" stuff at
+ // the bottom.
if (strcmp(name, PPB_AUDIO_CONFIG_DEV_INTERFACE) == 0)
- return AudioConfig::GetInterface();
+ return PPB_AudioConfig_Impl::GetInterface();
if (strcmp(name, PPB_AUDIO_DEV_INTERFACE) == 0)
- return Audio::GetInterface();
+ return PPB_Audio_Impl::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();
+ return PPB_Audio_Impl::GetTrustedInterface();
if (strcmp(name, PPB_BUFFER_DEV_INTERFACE) == 0)
- return Buffer::GetInterface();
- if (strcmp(name, PPB_FILEREF_DEV_INTERFACE) == 0)
- return FileRef::GetInterface();
+ 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 FileIO::GetInterface();
+ return PPB_FileIO_Impl::GetInterface();
if (strcmp(name, PPB_FILEIOTRUSTED_DEV_INTERFACE) == 0)
- return FileIO::GetTrustedInterface();
+ 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 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();
+ 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 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();
+ 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_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
+
diff --git a/webkit/glue/plugins/pepper_plugin_module.h b/webkit/plugins/ppapi/plugin_module.h
index 5ccd528..39b5f1d 100644
--- a/webkit/glue/plugins/pepper_plugin_module.h
+++ b/webkit/plugins/ppapi/plugin_module.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_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_
diff --git a/webkit/plugins/ppapi/plugin_object.cc b/webkit/plugins/ppapi/plugin_object.cc
new file mode 100644
index 0000000..516f255
--- /dev/null
+++ b/webkit/plugins/ppapi/plugin_object.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_plugin_object.h b/webkit/plugins/ppapi/plugin_object.h
index e31c1b1..01637e5 100644
--- a/webkit/glue/plugins/pepper_plugin_object.h
+++ b/webkit/plugins/ppapi/plugin_object.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_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_
diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
index f705178..3b7aff9 100644
--- a/webkit/glue/plugins/pepper_plugin_instance.cc
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_plugin_instance.h b/webkit/plugins/ppapi/ppapi_plugin_instance.h
index bd99843..c2a87f5 100644
--- a/webkit/glue/plugins/pepper_plugin_instance.h
+++ b/webkit/plugins/ppapi/ppapi_plugin_instance.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_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_
diff --git a/webkit/glue/plugins/ppapi_unittest.cc b/webkit/plugins/ppapi/ppapi_unittest.cc
index 1c5e5b7..12cb99d 100644
--- a/webkit/glue/plugins/ppapi_unittest.cc
+++ b/webkit/plugins/ppapi/ppapi_unittest.cc
@@ -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
diff --git a/webkit/glue/plugins/ppapi_unittest.h b/webkit/plugins/ppapi/ppapi_unittest.h
index 0e0c60f..ae15467 100644
--- a/webkit/glue/plugins/ppapi_unittest.h
+++ b/webkit/plugins/ppapi/ppapi_unittest.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.
-#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_
diff --git a/webkit/glue/plugins/pepper_webplugin_impl.cc b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
index 8da398f..e760198 100644
--- a/webkit/glue/plugins/pepper_webplugin_impl.cc
+++ b/webkit/plugins/ppapi/ppapi_webplugin_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_webplugin_impl.h b/webkit/plugins/ppapi/ppapi_webplugin_impl.h
index 8922143..0f86ca6 100644
--- a/webkit/glue/plugins/pepper_webplugin_impl.h
+++ b/webkit/plugins/ppapi/ppapi_webplugin_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_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_
diff --git a/webkit/glue/plugins/pepper_audio.cc b/webkit/plugins/ppapi/ppb_audio_impl.cc
index dc98415..db11eba 100644
--- a/webkit/glue/plugins/pepper_audio.cc
+++ b/webkit/plugins/ppapi/ppb_audio_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_audio.h b/webkit/plugins/ppapi/ppb_audio_impl.h
index 7417544..bcab4a4 100644
--- a/webkit/glue/plugins/pepper_audio.h
+++ b/webkit/plugins/ppapi/ppb_audio_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_buffer.cc b/webkit/plugins/ppapi/ppb_buffer_impl.cc
index fc3c34d..1c67ec3 100644
--- a/webkit/glue/plugins/pepper_buffer.cc
+++ b/webkit/plugins/ppapi/ppb_buffer_impl.cc
@@ -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
diff --git a/webkit/glue/plugins/pepper_buffer.h b/webkit/plugins/ppapi/ppb_buffer_impl.h
index c00711e..9642e51 100644
--- a/webkit/glue/plugins/pepper_buffer.h
+++ b/webkit/plugins/ppapi/ppb_buffer_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.
-#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_
diff --git a/webkit/glue/plugins/pepper_char_set.cc b/webkit/plugins/ppapi/ppb_char_set_impl.cc
index 1411d59..edab32e 100644
--- a/webkit/glue/plugins/pepper_char_set.cc
+++ b/webkit/plugins/ppapi/ppb_char_set_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_char_set.h b/webkit/plugins/ppapi/ppb_char_set_impl.h
index 5abb54d..9c16e05 100644
--- a/webkit/glue/plugins/pepper_char_set.h
+++ b/webkit/plugins/ppapi/ppb_char_set_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_cursor_control.cc b/webkit/plugins/ppapi/ppb_cursor_control_impl.cc
index 62b4e2f..d7b5119 100644
--- a/webkit/glue/plugins/pepper_cursor_control.cc
+++ b/webkit/plugins/ppapi/ppb_cursor_control_impl.cc
@@ -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
diff --git a/webkit/glue/plugins/pepper_cursor_control.h b/webkit/plugins/ppapi/ppb_cursor_control_impl.h
index 693fb4a..dcce132a 100644
--- a/webkit/glue/plugins/pepper_cursor_control.h
+++ b/webkit/plugins/ppapi/ppb_cursor_control_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_directory_reader.cc b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
index 9f7b819..1f5c97c 100644
--- a/webkit/glue/plugins/pepper_directory_reader.cc
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.cc
@@ -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"
-
-namespace pepper {
+#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 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
+
diff --git a/webkit/glue/plugins/pepper_directory_reader.h b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
index 3f415e2a..6e6dfdf 100644
--- a/webkit/glue/plugins/pepper_directory_reader.h
+++ b/webkit/plugins/ppapi/ppb_directory_reader_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_file_chooser.cc b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
index 52f2b55..b8e4a79 100644
--- a/webkit/glue/plugins/pepper_file_chooser.cc
+++ b/webkit/plugins/ppapi/ppb_file_chooser_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_file_chooser.h b/webkit/plugins/ppapi/ppb_file_chooser_impl.h
index 9d3d9e9..d60b503 100644
--- a/webkit/glue/plugins/pepper_file_chooser.h
+++ b/webkit/plugins/ppapi/ppb_file_chooser_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_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_
diff --git a/webkit/glue/plugins/pepper_file_io.cc b/webkit/plugins/ppapi/ppb_file_io_impl.cc
index b93b635..4597809 100644
--- a/webkit/glue/plugins/pepper_file_io.cc
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_file_io.h b/webkit/plugins/ppapi/ppb_file_io_impl.h
index 0ed2194..be3865e 100644
--- a/webkit/glue/plugins/pepper_file_io.h
+++ b/webkit/plugins/ppapi/ppb_file_io_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_file_ref.cc b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
index c1feca1..79676df 100644
--- a/webkit/glue/plugins/pepper_file_ref.cc
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.cc
@@ -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"
-
-namespace pepper {
+#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 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
+
diff --git a/webkit/plugins/ppapi/ppb_file_ref_impl.h b/webkit/plugins/ppapi/ppb_file_ref_impl.h
new file mode 100644
index 0000000..40924e7
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_file_ref_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_file_system.cc b/webkit/plugins/ppapi/ppb_file_system_impl.cc
index 429162a..fea8327 100644
--- a/webkit/glue/plugins/pepper_file_system.cc
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_file_system.h b/webkit/plugins/ppapi/ppb_file_system_impl.h
index 042a69d..2b3e7af 100644
--- a/webkit/glue/plugins/pepper_file_system.h
+++ b/webkit/plugins/ppapi/ppb_file_system_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/ppb_private2.h b/webkit/plugins/ppapi/ppb_flash.h
index 9eea66d..607adcd 100644
--- a/webkit/glue/plugins/ppb_private2.h
+++ b/webkit/plugins/ppapi/ppb_flash.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_
diff --git a/webkit/glue/plugins/pepper_private2.cc b/webkit/plugins/ppapi/ppb_flash_impl.cc
index 8492b65..b6340df 100644
--- a/webkit/glue/plugins/pepper_private2.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_private2.h b/webkit/plugins/ppapi/ppb_flash_impl.h
index fd767a2..44ed224 100644
--- a/webkit/glue/plugins/pepper_private2.h
+++ b/webkit/plugins/ppapi/ppb_flash_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_private2_linux.cc b/webkit/plugins/ppapi/ppb_flash_impl_linux.cc
index 12ecb9a..23290eb 100644
--- a/webkit/glue/plugins/pepper_private2_linux.cc
+++ b/webkit/plugins/ppapi/ppb_flash_impl_linux.cc
@@ -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"
-
-namespace pepper {
-
-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));
+#include "webkit/plugins/ppapi/ppb_image_data_impl.h"
+#include "webkit/plugins/ppapi/var.h"
+
+namespace webkit {
+namespace ppapi {
+
+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
diff --git a/webkit/glue/plugins/pepper_font.cc b/webkit/plugins/ppapi/ppb_font_impl.cc
index 5d841aa..d0faee9 100644
--- a/webkit/glue/plugins/pepper_font.cc
+++ b/webkit/plugins/ppapi/ppb_font_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_font.h b/webkit/plugins/ppapi/ppb_font_impl.h
index e9fdaff..ff70330 100644
--- a/webkit/glue/plugins/pepper_font.h
+++ b/webkit/plugins/ppapi/ppb_font_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_graphics_2d.cc b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
index f051b89..89435ff 100644
--- a/webkit/glue/plugins/pepper_graphics_2d.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_graphics_2d.h b/webkit/plugins/ppapi/ppb_graphics_2d_impl.h
index 320209a..40f2e5d 100644
--- a/webkit/glue/plugins/pepper_graphics_2d.h
+++ b/webkit/plugins/ppapi/ppb_graphics_2d_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_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_
diff --git a/webkit/glue/plugins/pepper_graphics_3d.cc b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
index 3a5f129..0355262 100644
--- a/webkit/glue/plugins/pepper_graphics_3d.cc
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.cc
@@ -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;
+PPB_Graphics3D_Impl::~PPB_Graphics3D_Impl() {
+ Destroy();
}
-Graphics3D::~Graphics3D() {
- Destroy();
+PPB_Graphics3D_Impl* PPB_Graphics3D_Impl::AsPPB_Graphics3D_Impl() {
+ return this;
}
-bool Graphics3D::Init(PP_Instance instance_id, int32_t config,
- const int32_t* attrib_list) {
+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
diff --git a/webkit/glue/plugins/pepper_graphics_3d.h b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
index 420a364..8124979 100644
--- a/webkit/glue/plugins/pepper_graphics_3d.h
+++ b/webkit/plugins/ppapi/ppb_graphics_3d_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_image_data.cc b/webkit/plugins/ppapi/ppb_image_data_impl.cc
index 13fb4ef..ee89cc3 100644
--- a/webkit/glue/plugins/pepper_image_data.cc
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_image_data.h b/webkit/plugins/ppapi/ppb_image_data_impl.h
index 2c7adde..e036d39 100644
--- a/webkit/glue/plugins/pepper_image_data.h
+++ b/webkit/plugins/ppapi/ppb_image_data_impl.h
@@ -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_
diff --git a/webkit/glue/plugins/pepper_graphics_3d_gl.cc b/webkit/plugins/ppapi/ppb_open_gl_es_impl.cc
index 0a7076f..8d64168 100644
--- a/webkit/glue/plugins/pepper_graphics_3d_gl.cc
+++ b/webkit/plugins/ppapi/ppb_open_gl_es_impl.cc
@@ -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
diff --git a/webkit/glue/plugins/ppb_private.h b/webkit/plugins/ppapi/ppb_pdf.h
index b3d2b67..38d1763 100644
--- a/webkit/glue/plugins/ppb_private.h
+++ b/webkit/plugins/ppapi/ppb_pdf.h
@@ -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);
diff --git a/webkit/glue/plugins/pepper_private.cc b/webkit/plugins/ppapi/ppb_pdf_impl.cc
index 0675bee..4d4721f 100644
--- a/webkit/glue/plugins/pepper_private.cc
+++ b/webkit/plugins/ppapi/ppb_pdf_impl.cc
@@ -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
+
diff --git a/webkit/plugins/ppapi/ppb_pdf_impl.h b/webkit/plugins/ppapi/ppb_pdf_impl.h
new file mode 100644
index 0000000..f630667
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_pdf_impl.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_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_
diff --git a/webkit/glue/plugins/pepper_scrollbar.cc b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
index 9b51c71..c436748 100644
--- a/webkit/glue/plugins/pepper_scrollbar.cc
+++ b/webkit/plugins/ppapi/ppb_scrollbar_impl.cc
@@ -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
+
diff --git a/webkit/glue/plugins/pepper_scrollbar.h b/webkit/plugins/ppapi/ppb_scrollbar_impl.h
index 817666e..532c05b 100644
--- a/webkit/glue/plugins/pepper_scrollbar.h
+++ b/webkit/plugins/ppapi/ppb_scrollbar_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_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_
diff --git a/webkit/glue/plugins/pepper_transport.cc b/webkit/plugins/ppapi/ppb_transport_impl.cc
index f43d502..bcd4f6a 100644
--- a/webkit/glue/plugins/pepper_transport.cc
+++ b/webkit/plugins/ppapi/ppb_transport_impl.cc
@@ -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
diff --git a/webkit/plugins/ppapi/ppb_transport_impl.h b/webkit/plugins/ppapi/ppb_transport_impl.h
new file mode 100644
index 0000000..7a98a37
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_transport_impl.h
@@ -0,0 +1,38 @@
+// 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_TRANSPORT_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_
+
+#include "base/basictypes.h"
+#include "base/scoped_ptr.h"
+#include "ppapi/c/pp_instance.h"
+#include "webkit/plugins/ppapi/plugin_delegate.h"
+#include "webkit/plugins/ppapi/resource.h"
+
+struct PPB_Transport_Dev;
+
+namespace webkit {
+namespace ppapi {
+
+class PPB_Transport_Impl : public Resource {
+ public:
+ explicit PPB_Transport_Impl(PluginModule* module);
+ virtual ~PPB_Transport_Impl();
+
+ static const PPB_Transport_Dev* GetInterface();
+ virtual PPB_Transport_Impl* AsPPB_Transport_Impl();
+
+ bool Init(const char* name,
+ const char* proto);
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PPB_Transport_Impl);
+};
+
+} // namespace ppapi
+} // namespace webkit
+
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_TRANSPORT_IMPL_H_
+
diff --git a/webkit/glue/plugins/pepper_url_loader.cc b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
index 83da95f..14b91f8 100644
--- a/webkit/glue/plugins/pepper_url_loader.cc
+++ b/webkit/plugins/ppapi/ppb_url_loader_impl.cc
@@ -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_url_loader.h"
+#include "webkit/plugins/ppapi/ppb_url_loader_impl.h"
#include "base/logging.h"
#include "ppapi/c/pp_completion_callback.h"
@@ -20,10 +20,10 @@
#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
#include "webkit/appcache/web_application_cache_host_impl.h"
-#include "webkit/glue/plugins/pepper_common.h"
-#include "webkit/glue/plugins/pepper_plugin_instance.h"
-#include "webkit/glue/plugins/pepper_url_request_info.h"
-#include "webkit/glue/plugins/pepper_url_response_info.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
+#include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
using appcache::WebApplicationCacheHostImpl;
using WebKit::WebFrame;
@@ -39,7 +39,8 @@ using WebKit::WebURLResponse;
#pragma warning(disable : 4996)
#endif
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
@@ -48,23 +49,24 @@ PP_Resource Create(PP_Instance instance_id) {
if (!instance)
return 0;
- URLLoader* loader = new URLLoader(instance, false);
+ PPB_URLLoader_Impl* loader = new PPB_URLLoader_Impl(instance, false);
return loader->GetReference();
}
PP_Bool IsURLLoader(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<URLLoader>(resource));
+ return BoolToPPBool(!!Resource::GetAs<PPB_URLLoader_Impl>(resource));
}
int32_t Open(PP_Resource loader_id,
PP_Resource request_id,
PP_CompletionCallback callback) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_ERROR_BADRESOURCE;
- scoped_refptr<URLRequestInfo> request(
- Resource::GetAs<URLRequestInfo>(request_id));
+ scoped_refptr<PPB_URLRequestInfo_Impl> request(
+ Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id));
if (!request)
return PP_ERROR_BADRESOURCE;
@@ -73,7 +75,8 @@ int32_t Open(PP_Resource loader_id,
int32_t FollowRedirect(PP_Resource loader_id,
PP_CompletionCallback callback) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_ERROR_BADRESOURCE;
@@ -81,9 +84,10 @@ int32_t FollowRedirect(PP_Resource loader_id,
}
PP_Bool GetUploadProgress(PP_Resource loader_id,
- int64_t* bytes_sent,
- int64_t* total_bytes_to_be_sent) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ int64_t* bytes_sent,
+ int64_t* total_bytes_to_be_sent) {
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_FALSE;
@@ -94,7 +98,8 @@ PP_Bool GetUploadProgress(PP_Resource loader_id,
PP_Bool GetDownloadProgress(PP_Resource loader_id,
int64_t* bytes_received,
int64_t* total_bytes_to_be_received) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_FALSE;
@@ -103,11 +108,12 @@ PP_Bool GetDownloadProgress(PP_Resource loader_id,
}
PP_Resource GetResponseInfo(PP_Resource loader_id) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return 0;
- URLResponseInfo* response_info = loader->response_info();
+ PPB_URLResponseInfo_Impl* response_info = loader->response_info();
if (!response_info)
return 0;
@@ -118,7 +124,8 @@ int32_t ReadResponseBody(PP_Resource loader_id,
char* buffer,
int32_t bytes_to_read,
PP_CompletionCallback callback) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_ERROR_BADRESOURCE;
@@ -127,7 +134,8 @@ int32_t ReadResponseBody(PP_Resource loader_id,
int32_t FinishStreamingToFile(PP_Resource loader_id,
PP_CompletionCallback callback) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return PP_ERROR_BADRESOURCE;
@@ -135,7 +143,8 @@ int32_t FinishStreamingToFile(PP_Resource loader_id,
}
void Close(PP_Resource loader_id) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return;
@@ -156,7 +165,8 @@ const PPB_URLLoader ppb_urlloader = {
};
void GrantUniversalAccess(PP_Resource loader_id) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return;
@@ -165,7 +175,8 @@ void GrantUniversalAccess(PP_Resource loader_id) {
void SetStatusCallback(PP_Resource loader_id,
PP_URLLoaderTrusted_StatusCallback cb) {
- scoped_refptr<URLLoader> loader(Resource::GetAs<URLLoader>(loader_id));
+ scoped_refptr<PPB_URLLoader_Impl> loader(
+ Resource::GetAs<PPB_URLLoader_Impl>(loader_id));
if (!loader)
return;
loader->SetStatusCallback(cb);
@@ -182,7 +193,8 @@ WebKit::WebFrame* GetFrame(PluginInstance* instance) {
} // namespace
-URLLoader::URLLoader(PluginInstance* instance, bool main_document_loader)
+PPB_URLLoader_Impl::PPB_URLLoader_Impl(PluginInstance* instance,
+ bool main_document_loader)
: Resource(instance->module()),
instance_(instance),
main_document_loader_(main_document_loader),
@@ -199,27 +211,27 @@ URLLoader::URLLoader(PluginInstance* instance, bool main_document_loader)
instance->AddObserver(this);
}
-URLLoader::~URLLoader() {
+PPB_URLLoader_Impl::~PPB_URLLoader_Impl() {
if (instance_)
instance_->RemoveObserver(this);
}
// static
-const PPB_URLLoader* URLLoader::GetInterface() {
+const PPB_URLLoader* PPB_URLLoader_Impl::GetInterface() {
return &ppb_urlloader;
}
// static
-const PPB_URLLoaderTrusted* URLLoader::GetTrustedInterface() {
+const PPB_URLLoaderTrusted* PPB_URLLoader_Impl::GetTrustedInterface() {
return &ppb_urlloadertrusted;
}
-URLLoader* URLLoader::AsURLLoader() {
+PPB_URLLoader_Impl* PPB_URLLoader_Impl::AsPPB_URLLoader_Impl() {
return this;
}
-int32_t URLLoader::Open(URLRequestInfo* request,
- PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::Open(PPB_URLRequestInfo_Impl* request,
+ PP_CompletionCallback callback) {
if (loader_.get())
return PP_ERROR_INPROGRESS;
@@ -250,14 +262,14 @@ int32_t URLLoader::Open(URLRequestInfo* request,
loader_->loadAsynchronously(web_request, this);
- request_info_ = scoped_refptr<URLRequestInfo>(request);
+ request_info_ = scoped_refptr<PPB_URLRequestInfo_Impl>(request);
pending_callback_ = callback;
// Notify completion when we receive a redirect or response headers.
return PP_ERROR_WOULDBLOCK;
}
-int32_t URLLoader::FollowRedirect(PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::FollowRedirect(PP_CompletionCallback callback) {
if (pending_callback_.func)
return PP_ERROR_INPROGRESS;
@@ -276,8 +288,8 @@ int32_t URLLoader::FollowRedirect(PP_CompletionCallback callback) {
return PP_ERROR_WOULDBLOCK;
}
-bool URLLoader::GetUploadProgress(int64_t* bytes_sent,
- int64_t* total_bytes_to_be_sent) {
+bool PPB_URLLoader_Impl::GetUploadProgress(int64_t* bytes_sent,
+ int64_t* total_bytes_to_be_sent) {
if (!RecordUploadProgress()) {
*bytes_sent = 0;
*total_bytes_to_be_sent = 0;
@@ -288,8 +300,9 @@ bool URLLoader::GetUploadProgress(int64_t* bytes_sent,
return true;
}
-bool URLLoader::GetDownloadProgress(int64_t* bytes_received,
- int64_t* total_bytes_to_be_received) {
+bool PPB_URLLoader_Impl::GetDownloadProgress(
+ int64_t* bytes_received,
+ int64_t* total_bytes_to_be_received) {
if (!RecordDownloadProgress()) {
*bytes_received = 0;
*total_bytes_to_be_received = 0;
@@ -300,8 +313,9 @@ bool URLLoader::GetDownloadProgress(int64_t* bytes_received,
return true;
}
-int32_t URLLoader::ReadResponseBody(char* buffer, int32_t bytes_to_read,
- PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::ReadResponseBody(char* buffer,
+ int32_t bytes_to_read,
+ PP_CompletionCallback callback) {
if (!response_info_ || response_info_->body())
return PP_ERROR_FAILED;
if (bytes_to_read <= 0 || !buffer)
@@ -330,7 +344,8 @@ int32_t URLLoader::ReadResponseBody(char* buffer, int32_t bytes_to_read,
return PP_ERROR_WOULDBLOCK;
}
-int32_t URLLoader::FinishStreamingToFile(PP_CompletionCallback callback) {
+int32_t PPB_URLLoader_Impl::FinishStreamingToFile(
+ PP_CompletionCallback callback) {
if (!response_info_ || !response_info_->body())
return PP_ERROR_FAILED;
if (pending_callback_.func)
@@ -345,7 +360,7 @@ int32_t URLLoader::FinishStreamingToFile(PP_CompletionCallback callback) {
return PP_ERROR_WOULDBLOCK;
}
-void URLLoader::Close() {
+void PPB_URLLoader_Impl::Close() {
if (loader_.get()) {
loader_->cancel();
} else if (main_document_loader_) {
@@ -354,17 +369,19 @@ void URLLoader::Close() {
}
}
-void URLLoader::GrantUniversalAccess() {
+void PPB_URLLoader_Impl::GrantUniversalAccess() {
has_universal_access_ = true;
}
-void URLLoader::SetStatusCallback(PP_URLLoaderTrusted_StatusCallback cb) {
+void PPB_URLLoader_Impl::SetStatusCallback(
+ PP_URLLoaderTrusted_StatusCallback cb) {
status_callback_ = cb;
}
-void URLLoader::willSendRequest(WebURLLoader* loader,
- WebURLRequest& new_request,
- const WebURLResponse& redirect_response) {
+void PPB_URLLoader_Impl::willSendRequest(
+ WebURLLoader* loader,
+ WebURLRequest& new_request,
+ const WebURLResponse& redirect_response) {
if (!request_info_->follow_redirects()) {
SaveResponse(redirect_response);
loader_->setDefersLoading(true);
@@ -378,17 +395,18 @@ void URLLoader::willSendRequest(WebURLLoader* loader,
}
}
-void URLLoader::didSendData(WebURLLoader* loader,
- unsigned long long bytes_sent,
- unsigned long long total_bytes_to_be_sent) {
+void PPB_URLLoader_Impl::didSendData(
+ WebURLLoader* loader,
+ unsigned long long bytes_sent,
+ unsigned long long total_bytes_to_be_sent) {
// TODO(darin): Bounds check input?
bytes_sent_ = static_cast<int64_t>(bytes_sent);
total_bytes_to_be_sent_ = static_cast<int64_t>(total_bytes_to_be_sent);
UpdateStatus();
}
-void URLLoader::didReceiveResponse(WebURLLoader* loader,
- const WebURLResponse& response) {
+void PPB_URLLoader_Impl::didReceiveResponse(WebURLLoader* loader,
+ const WebURLResponse& response) {
SaveResponse(response);
// Sets -1 if the content length is unknown.
@@ -398,15 +416,15 @@ void URLLoader::didReceiveResponse(WebURLLoader* loader,
RunCallback(PP_OK);
}
-void URLLoader::didDownloadData(WebURLLoader* loader,
- int data_length) {
+void PPB_URLLoader_Impl::didDownloadData(WebURLLoader* loader,
+ int data_length) {
bytes_received_ += data_length;
UpdateStatus();
}
-void URLLoader::didReceiveData(WebURLLoader* loader,
- const char* data,
- int data_length) {
+void PPB_URLLoader_Impl::didReceiveData(WebURLLoader* loader,
+ const char* data,
+ int data_length) {
bytes_received_ += data_length;
buffer_.insert(buffer_.end(), data, data + data_length);
@@ -417,18 +435,20 @@ void URLLoader::didReceiveData(WebURLLoader* loader,
}
}
-void URLLoader::didFinishLoading(WebURLLoader* loader, double finish_time) {
+void PPB_URLLoader_Impl::didFinishLoading(WebURLLoader* loader,
+ double finish_time) {
done_status_ = PP_OK;
RunCallback(done_status_);
}
-void URLLoader::didFail(WebURLLoader* loader, const WebURLError& error) {
+void PPB_URLLoader_Impl::didFail(WebURLLoader* loader,
+ const WebURLError& error) {
// TODO(darin): Provide more detailed error information.
done_status_ = PP_ERROR_FAILED;
RunCallback(done_status_);
}
-void URLLoader::InstanceDestroyed(PluginInstance* instance) {
+void PPB_URLLoader_Impl::InstanceDestroyed(PluginInstance* instance) {
// When the instance is destroyed, we force delete any associated loads.
DCHECK(instance == instance_);
instance_ = NULL;
@@ -436,7 +456,7 @@ void URLLoader::InstanceDestroyed(PluginInstance* instance) {
// Normally the only ref to this class will be from the plugin which
// ForceDeletePluginResourceRefs will free. We don't want our object to be
// deleted out from under us until the function completes.
- scoped_refptr<URLLoader> death_grip(this);
+ scoped_refptr<PPB_URLLoader_Impl> death_grip(this);
// Force delete any plugin refs to us. If the instance is being deleted, we
// don't want to allow the requests to continue to use bandwidth and send us
@@ -462,7 +482,7 @@ void URLLoader::InstanceDestroyed(PluginInstance* instance) {
// goes out of scope.
}
-void URLLoader::RunCallback(int32_t result) {
+void PPB_URLLoader_Impl::RunCallback(int32_t result) {
if (!pending_callback_.func)
return;
@@ -471,7 +491,7 @@ void URLLoader::RunCallback(int32_t result) {
PP_RunCompletionCallback(&callback, result);
}
-size_t URLLoader::FillUserBuffer() {
+size_t PPB_URLLoader_Impl::FillUserBuffer() {
DCHECK(user_buffer_);
DCHECK(user_buffer_size_);
@@ -485,14 +505,15 @@ size_t URLLoader::FillUserBuffer() {
return bytes_to_copy;
}
-void URLLoader::SaveResponse(const WebKit::WebURLResponse& response) {
- scoped_refptr<URLResponseInfo> response_info(new URLResponseInfo(module()));
+void PPB_URLLoader_Impl::SaveResponse(const WebKit::WebURLResponse& response) {
+ scoped_refptr<PPB_URLResponseInfo_Impl> response_info(
+ new PPB_URLResponseInfo_Impl(module()));
if (response_info->Initialize(response))
response_info_ = response_info;
}
// Checks that the client can request the URL. Returns a PPAPI error code.
-int32_t URLLoader::CanRequest(const WebKit::WebFrame* frame,
+int32_t PPB_URLLoader_Impl::CanRequest(const WebKit::WebFrame* frame,
const WebKit::WebURL& url) {
if (!has_universal_access_ &&
!frame->securityOrigin().canRequest(url))
@@ -501,7 +522,7 @@ int32_t URLLoader::CanRequest(const WebKit::WebFrame* frame,
return PP_OK;
}
-void URLLoader::UpdateStatus() {
+void PPB_URLLoader_Impl::UpdateStatus() {
if (status_callback_ &&
(RecordDownloadProgress() || RecordUploadProgress())) {
PP_Resource pp_resource = GetReferenceNoAddRef();
@@ -525,12 +546,14 @@ void URLLoader::UpdateStatus() {
}
}
-bool URLLoader::RecordDownloadProgress() const {
+bool PPB_URLLoader_Impl::RecordDownloadProgress() const {
return request_info_ && request_info_->record_download_progress();
}
-bool URLLoader::RecordUploadProgress() const {
+bool PPB_URLLoader_Impl::RecordUploadProgress() const {
return request_info_ && request_info_->record_upload_progress();
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_url_loader.h b/webkit/plugins/ppapi/ppb_url_loader_impl.h
index f39a94dd..6b05adc 100644
--- a/webkit/glue/plugins/pepper_url_loader.h
+++ b/webkit/plugins/ppapi/ppb_url_loader_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_PEPPER_URL_LOADER_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
#include <deque>
@@ -11,8 +11,8 @@
#include "ppapi/c/pp_completion_callback.h"
#include "ppapi/c/trusted/ppb_url_loader_trusted.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLLoaderClient.h"
-#include "webkit/glue/plugins/pepper_plugin_instance.h"
-#include "webkit/glue/plugins/pepper_resource.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/resource.h"
struct PPB_URLLoader;
struct PPB_URLLoaderTrusted;
@@ -22,18 +22,19 @@ class WebFrame;
class WebURL;
}
-namespace pepper {
+namespace webkit {
+namespace ppapi {
class PluginInstance;
-class URLRequestInfo;
-class URLResponseInfo;
+class PPB_URLRequestInfo_Impl;
+class PPB_URLResponseInfo_Impl;
-class URLLoader : public Resource,
+class PPB_URLLoader_Impl : public Resource,
public WebKit::WebURLLoaderClient,
public PluginInstance::Observer {
public:
- URLLoader(PluginInstance* instance, bool main_document_loader);
- virtual ~URLLoader();
+ PPB_URLLoader_Impl(PluginInstance* instance, bool main_document_loader);
+ virtual ~PPB_URLLoader_Impl();
// Returns a pointer to the interface implementing PPB_URLLoader that is
// exposed to the plugin.
@@ -44,10 +45,11 @@ class URLLoader : public Resource,
static const PPB_URLLoaderTrusted* GetTrustedInterface();
// Resource overrides.
- virtual URLLoader* AsURLLoader();
+ virtual PPB_URLLoader_Impl* AsPPB_URLLoader_Impl();
// PPB_URLLoader implementation.
- int32_t Open(URLRequestInfo* request, PP_CompletionCallback callback);
+ int32_t Open(PPB_URLRequestInfo_Impl* request,
+ PP_CompletionCallback callback);
int32_t FollowRedirect(PP_CompletionCallback callback);
bool GetUploadProgress(int64_t* bytes_sent,
int64_t* total_bytes_to_be_sent);
@@ -84,7 +86,7 @@ class URLLoader : public Resource,
// PluginInstance::Observer implementation.
virtual void InstanceDestroyed(PluginInstance* instance);
- URLResponseInfo* response_info() const { return response_info_; }
+ PPB_URLResponseInfo_Impl* response_info() const { return response_info_; }
private:
void RunCallback(int32_t result);
@@ -108,7 +110,7 @@ class URLLoader : public Resource,
bool RecordDownloadProgress() const;
bool RecordUploadProgress() const;
- // This will be NULL if the instance has been deleted but this URLLoader was
+ // This will be NULL if the instance has been deleted but this PPB_URLLoader_Impl was
// somehow leaked. In general, you should not need to check this for NULL.
// However, if you see a NULL pointer crash, that means somebody is holding
// a reference to this object longer than the PluginInstance's lifetime.
@@ -118,8 +120,8 @@ class URLLoader : public Resource,
// wrapping the main document's loader (i.e. loader_ is null).
bool main_document_loader_;
scoped_ptr<WebKit::WebURLLoader> loader_;
- scoped_refptr<URLRequestInfo> request_info_;
- scoped_refptr<URLResponseInfo> response_info_;
+ scoped_refptr<PPB_URLRequestInfo_Impl> request_info_;
+ scoped_refptr<PPB_URLResponseInfo_Impl> response_info_;
PP_CompletionCallback pending_callback_;
std::deque<char> buffer_;
int64_t bytes_sent_;
@@ -133,8 +135,11 @@ class URLLoader : public Resource,
bool has_universal_access_;
PP_URLLoaderTrusted_StatusCallback status_callback_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_URLLoader_Impl);
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_URL_LOADER_H_
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_LOADER_IMPL_H_
diff --git a/webkit/glue/plugins/pepper_url_request_info.cc b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc
index 228f124..1886af5 100644
--- a/webkit/glue/plugins/pepper_url_request_info.cc
+++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.cc
@@ -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_url_request_info.h"
+#include "webkit/plugins/ppapi/ppb_url_request_info_impl.h"
#include "base/logging.h"
#include "base/string_util.h"
@@ -15,11 +15,11 @@
#include "third_party/WebKit/WebKit/chromium/public/WebHTTPBody.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLRequest.h"
-#include "webkit/glue/plugins/pepper_common.h"
-#include "webkit/glue/plugins/pepper_file_ref.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_file_ref_impl.h"
+#include "webkit/plugins/ppapi/string.h"
+#include "webkit/plugins/ppapi/var.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebData;
@@ -29,7 +29,8 @@ using WebKit::WebFrame;
using WebKit::WebURL;
using WebKit::WebURLRequest;
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
@@ -52,20 +53,20 @@ PP_Resource Create(PP_Module module_id) {
if (!module)
return 0;
- URLRequestInfo* request = new URLRequestInfo(module);
+ PPB_URLRequestInfo_Impl* request = new PPB_URLRequestInfo_Impl(module);
return request->GetReference();
}
PP_Bool IsURLRequestInfo(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<URLRequestInfo>(resource));
+ return BoolToPPBool(!!Resource::GetAs<PPB_URLRequestInfo_Impl>(resource));
}
PP_Bool SetProperty(PP_Resource request_id,
PP_URLRequestProperty property,
PP_Var var) {
- scoped_refptr<URLRequestInfo> request(
- Resource::GetAs<URLRequestInfo>(request_id));
+ scoped_refptr<PPB_URLRequestInfo_Impl> request(
+ Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id));
if (!request)
return PP_FALSE;
@@ -89,8 +90,8 @@ PP_Bool SetProperty(PP_Resource request_id,
PP_Bool AppendDataToBody(PP_Resource request_id,
const char* data,
uint32_t len) {
- scoped_refptr<URLRequestInfo> request(
- Resource::GetAs<URLRequestInfo>(request_id));
+ scoped_refptr<PPB_URLRequestInfo_Impl> request(
+ Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id));
if (!request)
return PP_FALSE;
@@ -102,12 +103,13 @@ PP_Bool AppendFileToBody(PP_Resource request_id,
int64_t start_offset,
int64_t number_of_bytes,
PP_Time expected_last_modified_time) {
- scoped_refptr<URLRequestInfo> request(
- Resource::GetAs<URLRequestInfo>(request_id));
+ scoped_refptr<PPB_URLRequestInfo_Impl> request(
+ Resource::GetAs<PPB_URLRequestInfo_Impl>(request_id));
if (!request)
return PP_FALSE;
- 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_FALSE;
@@ -127,7 +129,7 @@ const PPB_URLRequestInfo ppb_urlrequestinfo = {
} // namespace
-struct URLRequestInfo::BodyItem {
+struct PPB_URLRequestInfo_Impl::BodyItem {
BodyItem(const std::string& data)
: data(data),
start_offset(0),
@@ -135,7 +137,7 @@ struct URLRequestInfo::BodyItem {
expected_last_modified_time(0.0) {
}
- BodyItem(FileRef* file_ref,
+ BodyItem(PPB_FileRef_Impl* file_ref,
int64_t start_offset,
int64_t number_of_bytes,
PP_Time expected_last_modified_time)
@@ -146,13 +148,13 @@ struct URLRequestInfo::BodyItem {
}
std::string data;
- scoped_refptr<FileRef> file_ref;
+ scoped_refptr<PPB_FileRef_Impl> file_ref;
int64_t start_offset;
int64_t number_of_bytes;
PP_Time expected_last_modified_time;
};
-URLRequestInfo::URLRequestInfo(PluginModule* module)
+PPB_URLRequestInfo_Impl::PPB_URLRequestInfo_Impl(PluginModule* module)
: Resource(module),
stream_to_file_(false),
follow_redirects_(true),
@@ -160,20 +162,20 @@ URLRequestInfo::URLRequestInfo(PluginModule* module)
record_upload_progress_(false) {
}
-URLRequestInfo::~URLRequestInfo() {
+PPB_URLRequestInfo_Impl::~PPB_URLRequestInfo_Impl() {
}
// static
-const PPB_URLRequestInfo* URLRequestInfo::GetInterface() {
+const PPB_URLRequestInfo* PPB_URLRequestInfo_Impl::GetInterface() {
return &ppb_urlrequestinfo;
}
-URLRequestInfo* URLRequestInfo::AsURLRequestInfo() {
+PPB_URLRequestInfo_Impl* PPB_URLRequestInfo_Impl::AsPPB_URLRequestInfo_Impl() {
return this;
}
-bool URLRequestInfo::SetBooleanProperty(PP_URLRequestProperty property,
- bool value) {
+bool PPB_URLRequestInfo_Impl::SetBooleanProperty(PP_URLRequestProperty property,
+ bool value) {
switch (property) {
case PP_URLREQUESTPROPERTY_STREAMTOFILE:
stream_to_file_ = value;
@@ -193,8 +195,8 @@ bool URLRequestInfo::SetBooleanProperty(PP_URLRequestProperty property,
}
}
-bool URLRequestInfo::SetStringProperty(PP_URLRequestProperty property,
- const std::string& value) {
+bool PPB_URLRequestInfo_Impl::SetStringProperty(PP_URLRequestProperty property,
+ const std::string& value) {
// TODO(darin): Validate input. Perhaps at a different layer?
switch (property) {
case PP_URLREQUESTPROPERTY_URL:
@@ -211,16 +213,17 @@ bool URLRequestInfo::SetStringProperty(PP_URLRequestProperty property,
}
}
-bool URLRequestInfo::AppendDataToBody(const std::string& data) {
+bool PPB_URLRequestInfo_Impl::AppendDataToBody(const std::string& data) {
if (!data.empty())
body_.push_back(BodyItem(data));
return true;
}
-bool URLRequestInfo::AppendFileToBody(FileRef* file_ref,
- int64_t start_offset,
- int64_t number_of_bytes,
- PP_Time expected_last_modified_time) {
+bool PPB_URLRequestInfo_Impl::AppendFileToBody(
+ PPB_FileRef_Impl* file_ref,
+ int64_t start_offset,
+ int64_t number_of_bytes,
+ PP_Time expected_last_modified_time) {
// Ignore a call to append nothing.
if (number_of_bytes == 0)
return true;
@@ -236,7 +239,7 @@ bool URLRequestInfo::AppendFileToBody(FileRef* file_ref,
return true;
}
-WebURLRequest URLRequestInfo::ToWebURLRequest(WebFrame* frame) const {
+WebURLRequest PPB_URLRequestInfo_Impl::ToWebURLRequest(WebFrame* frame) const {
WebURLRequest web_request;
web_request.initialize();
web_request.setURL(frame->document().completeURL(WebString::fromUTF8(url_)));
@@ -279,4 +282,6 @@ WebURLRequest URLRequestInfo::ToWebURLRequest(WebFrame* frame) const {
return web_request;
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_url_request_info.h b/webkit/plugins/ppapi/ppb_url_request_info_impl.h
index 207285e..a55edfe 100644
--- a/webkit/glue/plugins/pepper_url_request_info.h
+++ b/webkit/plugins/ppapi/ppb_url_request_info_impl.h
@@ -2,42 +2,44 @@
// 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_REQUEST_INFO_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_URL_REQUEST_INFO_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_
#include <string>
#include <vector>
#include "base/ref_counted.h"
#include "ppapi/c/ppb_url_request_info.h"
-#include "webkit/glue/plugins/pepper_file_ref.h"
-#include "webkit/glue/plugins/pepper_resource.h"
+#include "webkit/plugins/ppapi/resource.h"
namespace WebKit {
class WebFrame;
class WebURLRequest;
}
-namespace pepper {
+namespace webkit {
+namespace ppapi {
-class URLRequestInfo : public Resource {
+class PPB_FileRef_Impl;
+
+class PPB_URLRequestInfo_Impl : public Resource {
public:
- explicit URLRequestInfo(PluginModule* module);
- virtual ~URLRequestInfo();
+ explicit PPB_URLRequestInfo_Impl(PluginModule* module);
+ virtual ~PPB_URLRequestInfo_Impl();
// Returns a pointer to the interface implementing PPB_URLRequestInfo that is
// exposed to the plugin.
static const PPB_URLRequestInfo* GetInterface();
// Resource overrides.
- virtual URLRequestInfo* AsURLRequestInfo();
+ virtual PPB_URLRequestInfo_Impl* AsPPB_URLRequestInfo_Impl();
// PPB_URLRequestInfo implementation.
bool SetBooleanProperty(PP_URLRequestProperty property, bool value);
bool SetStringProperty(PP_URLRequestProperty property,
const std::string& value);
bool AppendDataToBody(const std::string& data);
- bool AppendFileToBody(FileRef* file_ref,
+ bool AppendFileToBody(PPB_FileRef_Impl* file_ref,
int64_t start_offset,
int64_t number_of_bytes,
PP_Time expected_last_modified_time);
@@ -62,8 +64,11 @@ class URLRequestInfo : public Resource {
bool follow_redirects_;
bool record_download_progress_;
bool record_upload_progress_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_URLRequestInfo_Impl);
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_URL_REQUEST_INFO_H_
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_REQUEST_INFO_IMPL_H_
diff --git a/webkit/glue/plugins/pepper_url_response_info.cc b/webkit/plugins/ppapi/ppb_url_response_info_impl.cc
index 47fa51a..43e3d9e 100644
--- a/webkit/glue/plugins/pepper_url_response_info.cc
+++ b/webkit/plugins/ppapi/ppb_url_response_info_impl.cc
@@ -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_url_response_info.h"
+#include "webkit/plugins/ppapi/ppb_url_response_info_impl.h"
#include "base/logging.h"
#include "ppapi/c/pp_var.h"
@@ -10,16 +10,17 @@
#include "third_party/WebKit/WebKit/chromium/public/WebString.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURLResponse.h"
-#include "webkit/glue/plugins/pepper_common.h"
-#include "webkit/glue/plugins/pepper_file_ref.h"
-#include "webkit/glue/plugins/pepper_var.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
+#include "webkit/plugins/ppapi/var.h"
#include "webkit/glue/webkit_glue.h"
using WebKit::WebHTTPHeaderVisitor;
using WebKit::WebString;
using WebKit::WebURLResponse;
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
@@ -40,13 +41,13 @@ class HeaderFlattener : public WebHTTPHeaderVisitor {
};
PP_Bool IsURLResponseInfo(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<URLResponseInfo>(resource));
+ return BoolToPPBool(!!Resource::GetAs<PPB_URLResponseInfo_Impl>(resource));
}
PP_Var GetProperty(PP_Resource response_id,
PP_URLResponseProperty property) {
- scoped_refptr<URLResponseInfo> response(
- Resource::GetAs<URLResponseInfo>(response_id));
+ scoped_refptr<PPB_URLResponseInfo_Impl> response(
+ Resource::GetAs<PPB_URLResponseInfo_Impl>(response_id));
if (!response)
return PP_MakeUndefined();
@@ -54,12 +55,12 @@ PP_Var GetProperty(PP_Resource response_id,
}
PP_Resource GetBody(PP_Resource response_id) {
- scoped_refptr<URLResponseInfo> response(
- Resource::GetAs<URLResponseInfo>(response_id));
+ scoped_refptr<PPB_URLResponseInfo_Impl> response(
+ Resource::GetAs<PPB_URLResponseInfo_Impl>(response_id));
if (!response.get())
return 0;
- FileRef* body = response->body();
+ PPB_FileRef_Impl* body = response->body();
if (!body)
return 0;
body->AddRef(); // AddRef for the caller.
@@ -79,24 +80,25 @@ bool IsRedirect(int32_t status) {
} // namespace
-URLResponseInfo::URLResponseInfo(PluginModule* module)
+PPB_URLResponseInfo_Impl::PPB_URLResponseInfo_Impl(PluginModule* module)
: Resource(module),
status_code_(-1) {
}
-URLResponseInfo::~URLResponseInfo() {
+PPB_URLResponseInfo_Impl::~PPB_URLResponseInfo_Impl() {
}
// static
-const PPB_URLResponseInfo* URLResponseInfo::GetInterface() {
+const PPB_URLResponseInfo* PPB_URLResponseInfo_Impl::GetInterface() {
return &ppb_urlresponseinfo;
}
-URLResponseInfo* URLResponseInfo::AsURLResponseInfo() {
+PPB_URLResponseInfo_Impl*
+PPB_URLResponseInfo_Impl::AsPPB_URLResponseInfo_Impl() {
return this;
}
-PP_Var URLResponseInfo::GetProperty(PP_URLResponseProperty property) {
+PP_Var PPB_URLResponseInfo_Impl::GetProperty(PP_URLResponseProperty property) {
switch (property) {
case PP_URLRESPONSEPROPERTY_URL:
return StringVar::StringToPPVar(module(), url_);
@@ -119,7 +121,7 @@ PP_Var URLResponseInfo::GetProperty(PP_URLResponseProperty property) {
return PP_MakeUndefined();
}
-bool URLResponseInfo::Initialize(const WebURLResponse& response) {
+bool PPB_URLResponseInfo_Impl::Initialize(const WebURLResponse& response) {
url_ = response.url().spec();
status_code_ = response.httpStatusCode();
status_text_ = response.httpStatusText().utf8();
@@ -134,8 +136,11 @@ bool URLResponseInfo::Initialize(const WebURLResponse& response) {
WebString file_path = response.downloadFilePath();
if (!file_path.isEmpty())
- body_ = new FileRef(module(), webkit_glue::WebStringToFilePath(file_path));
+ body_ = new PPB_FileRef_Impl(module(),
+ webkit_glue::WebStringToFilePath(file_path));
return true;
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_url_response_info.h b/webkit/plugins/ppapi/ppb_url_response_info_impl.h
index fa5f972..ee12d35c 100644
--- a/webkit/glue/plugins/pepper_url_response_info.h
+++ b/webkit/plugins/ppapi/ppb_url_response_info_impl.h
@@ -2,38 +2,42 @@
// 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_RESPONSE_INFO_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_URL_RESPONSE_INFO_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_PPB_URL_RESPONSE_INFO_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_URL_RESPONSE_INFO_IMPL_H_
#include <string>
+#include "base/basictypes.h"
#include "ppapi/c/ppb_url_response_info.h"
-#include "webkit/glue/plugins/pepper_resource.h"
+#include "webkit/plugins/ppapi/resource.h"
namespace WebKit {
class WebURLResponse;
}
-namespace pepper {
+namespace webkit {
+namespace ppapi {
-class URLResponseInfo : public Resource {
+class PPB_FileRef_Impl;
+
+class PPB_URLResponseInfo_Impl : public Resource {
public:
- explicit URLResponseInfo(PluginModule* module);
- virtual ~URLResponseInfo();
+ explicit PPB_URLResponseInfo_Impl(PluginModule* module);
+ virtual ~PPB_URLResponseInfo_Impl();
// Returns a pointer to the interface implementing PPB_URLResponseInfo that
// is exposed to the plugin.
static const PPB_URLResponseInfo* GetInterface();
// Resource overrides.
- virtual URLResponseInfo* AsURLResponseInfo();
+ virtual PPB_URLResponseInfo_Impl* AsPPB_URLResponseInfo_Impl();
// PPB_URLResponseInfo implementation.
PP_Var GetProperty(PP_URLResponseProperty property);
bool Initialize(const WebKit::WebURLResponse& response);
- FileRef* body() { return body_; }
+ PPB_FileRef_Impl* body() { return body_; }
std::string redirect_url() { return redirect_url_; }
@@ -43,9 +47,12 @@ class URLResponseInfo : public Resource {
int32_t status_code_;
std::string status_text_;
std::string redirect_url_;
- scoped_refptr<FileRef> body_;
+ scoped_refptr<PPB_FileRef_Impl> body_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_URLResponseInfo_Impl);
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_URL_RESPONSE_INFO_H_
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_RESPONSE_INFO_IMPL_H_
diff --git a/webkit/glue/plugins/pepper_url_util.cc b/webkit/plugins/ppapi/ppb_url_util_impl.cc
index 2f97e6c..47980e4 100644
--- a/webkit/glue/plugins/pepper_url_util.cc
+++ b/webkit/plugins/ppapi/ppb_url_util_impl.cc
@@ -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_url_util.h"
+#include "webkit/plugins/ppapi/ppb_url_util_impl.h"
#include "googleurl/src/gurl.h"
#include "ppapi/c/dev/ppb_url_util_dev.h"
@@ -13,12 +13,13 @@
#include "third_party/WebKit/WebKit/chromium/public/WebPluginContainer.h"
#include "third_party/WebKit/WebKit/chromium/public/WebSecurityOrigin.h"
#include "third_party/WebKit/WebKit/chromium/public/WebURL.h"
-#include "webkit/glue/plugins/pepper_common.h"
-#include "webkit/glue/plugins/pepper_plugin_instance.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/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/string.h"
+#include "webkit/plugins/ppapi/var.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
@@ -170,8 +171,10 @@ const PPB_UrlUtil_Dev ppb_url_util = {
};
// static
-const PPB_UrlUtil_Dev* UrlUtil::GetInterface() {
+const PPB_UrlUtil_Dev* PPB_UrlUtil_Impl::GetInterface() {
return &ppb_url_util;
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/plugins/ppapi/ppb_url_util_impl.h b/webkit/plugins/ppapi/ppb_url_util_impl.h
new file mode 100644
index 0000000..8cba6a9
--- /dev/null
+++ b/webkit/plugins/ppapi/ppb_url_util_impl.h
@@ -0,0 +1,21 @@
+// 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_URL_UTIL_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_URL_UTIL_IMPL_H_
+
+struct PPB_UrlUtil_Dev;
+
+namespace webkit {
+namespace ppapi {
+
+class PPB_UrlUtil_Impl {
+ public:
+ static const PPB_UrlUtil_Dev* GetInterface();
+};
+
+} // namespace ppapi
+} // namespace webkit
+
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_URL_UTIL_IMPL_H_
diff --git a/webkit/glue/plugins/pepper_video_decoder.cc b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
index 034974b..bd7f204 100644
--- a/webkit/glue/plugins/pepper_video_decoder.cc
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.cc
@@ -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_video_decoder.h"
+#include "webkit/plugins/ppapi/ppb_video_decoder_impl.h"
#include "base/logging.h"
#include "ppapi/c/dev/pp_video_dev.h"
#include "ppapi/c/dev/ppb_video_decoder_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_resource_tracker.h"
+#include "webkit/plugins/ppapi/common.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 {
PP_Bool GetConfig(PP_Instance instance_id,
- PP_VideoCodecId_Dev codec,
- PP_VideoConfig_Dev* configs,
- int32_t config_size,
- int32_t *num_config) {
+ PP_VideoCodecId_Dev codec,
+ PP_VideoConfig_Dev* configs,
+ int32_t config_size,
+ int32_t *num_config) {
PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id);
*num_config = 0;
if (!instance)
@@ -45,7 +46,8 @@ PP_Resource Create(PP_Instance instance_id,
if (!instance)
return 0;
- scoped_refptr<VideoDecoder> decoder(new VideoDecoder(instance));
+ scoped_refptr<PPB_VideoDecoder_Impl> decoder(
+ new PPB_VideoDecoder_Impl(instance));
if (!decoder->Init(*decoder_config))
return 0;
@@ -54,9 +56,9 @@ PP_Resource Create(PP_Instance instance_id,
}
PP_Bool Decode(PP_Resource decoder_id,
- PP_VideoCompressedDataBuffer_Dev* input_buffer) {
- scoped_refptr<VideoDecoder> decoder(
- Resource::GetAs<VideoDecoder>(decoder_id));
+ PP_VideoCompressedDataBuffer_Dev* input_buffer) {
+ scoped_refptr<PPB_VideoDecoder_Impl> decoder(
+ Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id));
if (!decoder)
return PP_FALSE;
@@ -65,18 +67,19 @@ PP_Bool Decode(PP_Resource decoder_id,
}
int32_t Flush(PP_Resource decoder_id, PP_CompletionCallback callback) {
- scoped_refptr<VideoDecoder> decoder(
- Resource::GetAs<VideoDecoder>(decoder_id));
+ scoped_refptr<PPB_VideoDecoder_Impl> decoder(
+ Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id));
if (!decoder)
return PP_ERROR_BADRESOURCE;
return decoder->Flush(callback);
}
-PP_Bool ReturnUncompressedDataBuffer(PP_Resource decoder_id,
- PP_VideoUncompressedDataBuffer_Dev* buffer) {
- scoped_refptr<VideoDecoder> decoder(
- Resource::GetAs<VideoDecoder>(decoder_id));
+PP_Bool ReturnUncompressedDataBuffer(
+ PP_Resource decoder_id,
+ PP_VideoUncompressedDataBuffer_Dev* buffer) {
+ scoped_refptr<PPB_VideoDecoder_Impl> decoder(
+ Resource::GetAs<PPB_VideoDecoder_Impl>(decoder_id));
if (!decoder)
return PP_FALSE;
@@ -93,24 +96,25 @@ const PPB_VideoDecoder_Dev ppb_videodecoder = {
} // namespace
-VideoDecoder::VideoDecoder(PluginInstance* instance)
+PPB_VideoDecoder_Impl::PPB_VideoDecoder_Impl(PluginInstance* instance)
: Resource(instance->module()),
instance_(instance) {
}
-VideoDecoder::~VideoDecoder() {
+PPB_VideoDecoder_Impl::~PPB_VideoDecoder_Impl() {
}
// static
-const PPB_VideoDecoder_Dev* VideoDecoder::GetInterface() {
+const PPB_VideoDecoder_Dev* PPB_VideoDecoder_Impl::GetInterface() {
return &ppb_videodecoder;
}
-VideoDecoder* VideoDecoder::AsVideoDecoder() {
+PPB_VideoDecoder_Impl* PPB_VideoDecoder_Impl::AsPPB_VideoDecoder_Impl() {
return this;
}
-bool VideoDecoder::Init(const PP_VideoDecoderConfig_Dev& decoder_config) {
+bool PPB_VideoDecoder_Impl::Init(
+ const PP_VideoDecoderConfig_Dev& decoder_config) {
if (!instance())
return false;
@@ -120,21 +124,22 @@ bool VideoDecoder::Init(const PP_VideoDecoderConfig_Dev& decoder_config) {
return platform_video_decoder_.get()? true : false;
}
-bool VideoDecoder::Decode(PP_VideoCompressedDataBuffer_Dev& input_buffer) {
+bool PPB_VideoDecoder_Impl::Decode(
+ PP_VideoCompressedDataBuffer_Dev& input_buffer) {
if (!platform_video_decoder_.get())
return false;
return platform_video_decoder_->Decode(input_buffer);
}
-int32_t VideoDecoder::Flush(PP_CompletionCallback& callback) {
+int32_t PPB_VideoDecoder_Impl::Flush(PP_CompletionCallback& callback) {
if (!platform_video_decoder_.get())
return PP_ERROR_FAILED;
return platform_video_decoder_->Flush(callback);
}
-bool VideoDecoder::ReturnUncompressedDataBuffer(
+bool PPB_VideoDecoder_Impl::ReturnUncompressedDataBuffer(
PP_VideoUncompressedDataBuffer_Dev& buffer) {
if (!platform_video_decoder_.get())
return false;
@@ -142,4 +147,6 @@ bool VideoDecoder::ReturnUncompressedDataBuffer(
return platform_video_decoder_->ReturnUncompressedDataBuffer(buffer);
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_video_decoder.h b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
index 7a161e62..169ebed 100644
--- a/webkit/glue/plugins/pepper_video_decoder.h
+++ b/webkit/plugins/ppapi/ppb_video_decoder_impl.h
@@ -2,33 +2,35 @@
// 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_VIDEO_DECODER_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_VIDEO_DECODER_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_
+#include "base/basictypes.h"
#include "base/scoped_ptr.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_VideoDecoderConfig_Dev;
struct PP_VideoCompressedDataBuffer_Dev;
struct PP_VideoUncompressedDataBuffer_Dev;
struct PPB_VideoDecoder_Dev;
-namespace pepper {
+namespace webkit {
+namespace ppapi {
class PluginInstance;
-class VideoDecoder : public Resource {
+class PPB_VideoDecoder_Impl : public Resource {
public:
- VideoDecoder(PluginInstance* instance);
- virtual ~VideoDecoder();
+ PPB_VideoDecoder_Impl(PluginInstance* instance);
+ virtual ~PPB_VideoDecoder_Impl();
// Returns a pointer to the interface implementing PPB_VideoDecoder that is
// exposed to the plugin.
static const PPB_VideoDecoder_Dev* GetInterface();
// Resource overrides.
- virtual VideoDecoder* AsVideoDecoder();
+ virtual PPB_VideoDecoder_Impl* AsPPB_VideoDecoder_Impl();
PluginInstance* instance() { return instance_.get(); }
@@ -39,12 +41,15 @@ class VideoDecoder : public Resource {
bool ReturnUncompressedDataBuffer(PP_VideoUncompressedDataBuffer_Dev& buffer);
private:
- // This is NULL before initialization, and if this VideoDecoder is
+ // This is NULL before initialization, and if this PPB_VideoDecoder_Impl is
// swapped with another.
scoped_ptr<PluginDelegate::PlatformVideoDecoder> platform_video_decoder_;
scoped_refptr<PluginInstance> instance_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_VideoDecoder_Impl);
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_VIDEO_DECODER_H_
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_VIDEO_DECODER_IMPL_H_
diff --git a/webkit/glue/plugins/pepper_widget.cc b/webkit/plugins/ppapi/ppb_widget_impl.cc
index 9fc762b..57491b5 100644
--- a/webkit/glue/plugins/pepper_widget.cc
+++ b/webkit/plugins/ppapi/ppb_widget_impl.cc
@@ -2,32 +2,37 @@
// 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_widget.h"
+#include "webkit/plugins/ppapi/ppb_widget_impl.h"
#include "base/logging.h"
#include "ppapi/c/dev/ppb_widget_dev.h"
#include "ppapi/c/dev/ppp_widget_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_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/ppb_image_data_impl.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
+#include "webkit/plugins/ppapi/plugin_module.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
PP_Bool IsWidget(PP_Resource resource) {
- return BoolToPPBool(!!Resource::GetAs<Widget>(resource));
+ return BoolToPPBool(!!Resource::GetAs<PPB_Widget_Impl>(resource));
}
-PP_Bool Paint(PP_Resource resource, const PP_Rect* rect, PP_Resource image_id) {
- scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource));
+PP_Bool Paint(PP_Resource resource,
+ const PP_Rect* rect,
+ PP_Resource image_id) {
+ scoped_refptr<PPB_Widget_Impl> widget(
+ Resource::GetAs<PPB_Widget_Impl>(resource));
if (!widget)
return PP_FALSE;
- scoped_refptr<ImageData> image(Resource::GetAs<ImageData>(image_id));
+ scoped_refptr<PPB_ImageData_Impl> image(
+ Resource::GetAs<PPB_ImageData_Impl>(image_id));
if (!image)
return PP_FALSE;
@@ -35,17 +40,20 @@ PP_Bool Paint(PP_Resource resource, const PP_Rect* rect, PP_Resource image_id) {
}
PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) {
- scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource));
+ scoped_refptr<PPB_Widget_Impl> widget(
+ Resource::GetAs<PPB_Widget_Impl>(resource));
return BoolToPPBool(widget && widget->HandleEvent(event));
}
PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) {
- scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource));
+ scoped_refptr<PPB_Widget_Impl> widget(
+ Resource::GetAs<PPB_Widget_Impl>(resource));
return BoolToPPBool(widget && widget->GetLocation(location));
}
void SetLocation(PP_Resource resource, const PP_Rect* location) {
- scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource));
+ scoped_refptr<PPB_Widget_Impl> widget(
+ Resource::GetAs<PPB_Widget_Impl>(resource));
if (widget)
widget->SetLocation(location);
}
@@ -60,34 +68,34 @@ const PPB_Widget_Dev ppb_widget = {
} // namespace
-Widget::Widget(PluginInstance* instance)
+PPB_Widget_Impl::PPB_Widget_Impl(PluginInstance* instance)
: Resource(instance->module()),
instance_(instance) {
}
-Widget::~Widget() {
+PPB_Widget_Impl::~PPB_Widget_Impl() {
}
// static
-const PPB_Widget_Dev* Widget::GetInterface() {
+const PPB_Widget_Dev* PPB_Widget_Impl::GetInterface() {
return &ppb_widget;
}
-Widget* Widget::AsWidget() {
+PPB_Widget_Impl* PPB_Widget_Impl::AsPPB_Widget_Impl() {
return this;
}
-bool Widget::GetLocation(PP_Rect* location) {
+bool PPB_Widget_Impl::GetLocation(PP_Rect* location) {
*location = location_;
return true;
}
-void Widget::SetLocation(const PP_Rect* location) {
+void PPB_Widget_Impl::SetLocation(const PP_Rect* location) {
location_ = *location;
SetLocationInternal(location);
}
-void Widget::Invalidate(const PP_Rect* dirty) {
+void PPB_Widget_Impl::Invalidate(const PP_Rect* dirty) {
const PPP_Widget_Dev* widget = static_cast<const PPP_Widget_Dev*>(
module()->GetPluginInterface(PPP_WIDGET_DEV_INTERFACE));
if (!widget)
@@ -96,4 +104,6 @@ void Widget::Invalidate(const PP_Rect* dirty) {
widget->Invalidate(instance_->pp_instance(), resource.id, dirty);
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_widget.h b/webkit/plugins/ppapi/ppb_widget_impl.h
index 55d0650..1cd9761 100644
--- a/webkit/glue/plugins/pepper_widget.h
+++ b/webkit/plugins/ppapi/ppb_widget_impl.h
@@ -2,35 +2,37 @@
// 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_WIDGET_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_WIDGET_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_PPB_WIDGET_IMPL_H_
+#define WEBKIT_PLUGINS_PPAPI_PPB_WIDGET_IMPL_H_
+#include "base/basictypes.h"
#include "base/scoped_ptr.h"
#include "ppapi/c/pp_rect.h"
-#include "webkit/glue/plugins/pepper_resource.h"
+#include "webkit/plugins/ppapi/resource.h"
struct PPB_Widget_Dev;
struct PP_InputEvent;
-namespace pepper {
+namespace webkit {
+namespace ppapi {
-class ImageData;
+class PPB_ImageData_Impla;
class PluginInstance;
-class Widget : public Resource {
+class PPB_Widget_Impl : public Resource {
public:
- explicit Widget(PluginInstance* instance);
- virtual ~Widget();
+ explicit PPB_Widget_Impl(PluginInstance* instance);
+ virtual ~PPB_Widget_Impl();
// Returns a pointer to the interface implementing PPB_Widget that is
// exposed to the plugin.
static const PPB_Widget_Dev* GetInterface();
// Resource overrides.
- virtual Widget* AsWidget();
+ virtual PPB_Widget_Impl* AsPPB_Widget_Impl();
// PPB_Widget implementation.
- virtual bool Paint(const PP_Rect* rect, ImageData* image) = 0;
+ virtual bool Paint(const PP_Rect* rect, PPB_ImageData_Impl* image) = 0;
virtual bool HandleEvent(const PP_InputEvent* event) = 0;
bool GetLocation(PP_Rect* location);
void SetLocation(const PP_Rect* location);
@@ -46,8 +48,11 @@ class Widget : public Resource {
private:
scoped_refptr<PluginInstance> instance_;
PP_Rect location_;
+
+ DISALLOW_COPY_AND_ASSIGN(PPB_Widget_Impl);
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_WIDGET_H_
+#endif // WEBKIT_PLUGINS_PPAPI_PPB_WIDGET_IMPL_H_
diff --git a/webkit/glue/plugins/ppp_private.h b/webkit/plugins/ppapi/ppp_pdf.h
index 7f5921e..6405225 100644
--- a/webkit/glue/plugins/ppp_private.h
+++ b/webkit/plugins/ppapi/ppp_pdf.h
@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_GLUE_PLUGINS_PPP_PRIVATE_H_
-#define WEBKIT_GLUE_PLUGINS_PPP_PRIVATE_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_PPP_PDF_H_
+#define WEBKIT_PLUGINS_PPAPI_PPP_PDF_H_
#include "ppapi/c/pp_instance.h"
#include "ppapi/c/pp_point.h"
#include "ppapi/c/pp_var.h"
-#define PPP_PRIVATE_INTERFACE "PPP_Private;1"
+#define PPP_PDF_INTERFACE "PPP_Pdf;1"
-struct PPP_Private {
+struct PPP_Pdf {
// Returns an absolute URL if the position is over a link.
PP_Var (*GetLinkAtPosition)(PP_Instance instance,
PP_Point point);
};
-#endif // WEBKIT_GLUE_PLUGINS_PPP_PRIVATE_H_
+#endif // WEBKIT_PLUGINS_PPAPI_PPP_PDF_H_
diff --git a/webkit/glue/plugins/pepper_resource.cc b/webkit/plugins/ppapi/resource.cc
index 34d6ee3..0f8fbf9 100644
--- a/webkit/glue/plugins/pepper_resource.cc
+++ b/webkit/plugins/ppapi/resource.cc
@@ -2,12 +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_resource.h"
+#include "webkit/plugins/ppapi/resource.h"
#include "base/logging.h"
-#include "webkit/glue/plugins/pepper_resource_tracker.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
Resource::Resource(PluginModule* module)
: resource_id_(0), module_(module) {
@@ -39,4 +40,6 @@ void Resource::StoppedTracking() {
FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER)
#undef DEFINE_TYPE_GETTER
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_resource.h b/webkit/plugins/ppapi/resource.h
index 3d7d307..45f114c 100644
--- a/webkit/glue/plugins/pepper_resource.h
+++ b/webkit/plugins/ppapi/resource.h
@@ -2,44 +2,44 @@
// 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_RESOURCE_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_RESOURCE_H_
+#define WEBKIT_PLUGINS_PPAPI_RESOURCE_H_
#include "base/basictypes.h"
#include "base/ref_counted.h"
#include "ppapi/c/pp_resource.h"
-#include "webkit/glue/plugins/pepper_resource_tracker.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
// If you inherit from resource, make sure you add the class name here.
#define FOR_ALL_RESOURCES(F) \
- F(Audio) \
- F(AudioConfig) \
- F(Buffer) \
- F(DirectoryReader) \
- F(FileChooser) \
- F(FileIO) \
- F(FileRef) \
- F(FileSystem) \
- F(Font) \
- F(Graphics2D) \
- F(Graphics3D) \
- F(ImageData) \
F(MockResource) \
F(ObjectVar) \
- F(PluginModule) \
+ F(PPB_AudioConfig_Impl) \
+ F(PPB_Audio_Impl) \
+ F(PPB_Buffer_Impl) \
+ F(PPB_DirectoryReader_Impl) \
+ F(PPB_FileChooser_Impl) \
+ F(PPB_FileIO_Impl) \
+ F(PPB_FileRef_Impl) \
+ F(PPB_FileSystem_Impl) \
+ F(PPB_Font_Impl) \
+ F(PPB_Graphics2D_Impl) \
+ F(PPB_Graphics3D_Impl) \
+ F(PPB_ImageData_Impl) \
+ F(PPB_Scrollbar_Impl) \
+ F(PPB_Transport_Impl) \
+ F(PPB_URLLoader_Impl) \
+ F(PPB_URLRequestInfo_Impl) \
+ F(PPB_URLResponseInfo_Impl) \
+ F(PPB_VideoDecoder_Impl) \
+ F(PPB_Widget_Impl) \
F(PrivateFontFile) \
- F(Scrollbar) \
F(StringVar) \
- F(Transport) \
- F(URLLoader) \
- F(URLRequestInfo) \
- F(URLResponseInfo) \
F(Var) \
- F(VarObjectClass) \
- F(VideoDecoder) \
- F(Widget)
+ F(VarObjectClass)
// Forward declaration of Resource classes.
#define DECLARE_RESOURCE_CLASS(RESOURCE) class RESOURCE;
@@ -103,7 +103,7 @@ class Resource : public base::RefCountedThreadSafe<Resource> {
// NULL if the resource does not match the specified type. Used by the Cast()
// function.
#define DEFINE_TYPE_GETTER(RESOURCE) \
- virtual RESOURCE* As##RESOURCE();
+ virtual RESOURCE* As##RESOURCE();
FOR_ALL_RESOURCES(DEFINE_TYPE_GETTER)
#undef DEFINE_TYPE_GETTER
@@ -129,12 +129,13 @@ class Resource : public base::RefCountedThreadSafe<Resource> {
// Cast() specializations.
#define DEFINE_RESOURCE_CAST(Type) \
template <> inline Type* Resource::Cast<Type>() { \
- return As##Type(); \
+ return As##Type(); \
}
FOR_ALL_RESOURCES(DEFINE_RESOURCE_CAST)
#undef DEFINE_RESOURCE_CAST
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_H_
+#endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_H_
diff --git a/webkit/glue/plugins/pepper_resource_tracker.cc b/webkit/plugins/ppapi/resource_tracker.cc
index 9623e98..7f66160 100644
--- a/webkit/glue/plugins/pepper_resource_tracker.cc
+++ b/webkit/plugins/ppapi/resource_tracker.cc
@@ -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_resource_tracker.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
#include <limits>
#include <set>
@@ -11,12 +11,13 @@
#include "base/logging.h"
#include "base/rand_util.h"
#include "ppapi/c/pp_resource.h"
-#include "webkit/glue/plugins/pepper_resource.h"
+#include "webkit/plugins/ppapi/resource.h"
-static base::LazyInstance<pepper::ResourceTracker> g_resource_tracker(
- base::LINKER_INITIALIZED);
+namespace webkit {
+namespace ppapi {
-namespace pepper {
+static base::LazyInstance<ResourceTracker> g_resource_tracker(
+ base::LINKER_INITIALIZED);
scoped_refptr<Resource> ResourceTracker::GetResource(PP_Resource res) const {
ResourceMap::const_iterator result = live_resources_.find(res);
@@ -190,4 +191,6 @@ void ResourceTracker::ClearSingletonOverride() {
singleton_override_ = NULL;
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_resource_tracker.h b/webkit/plugins/ppapi/resource_tracker.h
index 0e463b4..7a5e002 100644
--- a/webkit/glue/plugins/pepper_resource_tracker.h
+++ b/webkit/plugins/ppapi/resource_tracker.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_RESOURCE_TRACKER_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_
+#define WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_
#include <map>
#include <utility>
@@ -20,7 +20,8 @@ namespace base {
template <typename T> struct DefaultLazyInstanceTraits;
}
-namespace pepper {
+namespace webkit {
+namespace ppapi {
class PluginInstance;
class PluginModule;
@@ -142,6 +143,7 @@ class ResourceTracker {
DISALLOW_COPY_AND_ASSIGN(ResourceTracker);
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_RESOURCE_TRACKER_H_
+#endif // WEBKIT_PLUGINS_PPAPI_RESOURCE_TRACKER_H_
diff --git a/webkit/glue/plugins/resource_tracker_unittest.cc b/webkit/plugins/ppapi/resource_tracker_unittest.cc
index 3b9fce3..60910df 100644
--- a/webkit/glue/plugins/resource_tracker_unittest.cc
+++ b/webkit/plugins/ppapi/resource_tracker_unittest.cc
@@ -2,12 +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/ppapi_unittest.h"
+#include "webkit/plugins/ppapi/ppapi_unittest.h"
-#include "webkit/glue/plugins/pepper_resource_tracker.h"
-#include "webkit/glue/plugins/mock_resource.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
+#include "webkit/plugins/ppapi/mock_resource.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
@@ -113,4 +114,6 @@ TEST_F(ResourceTrackerTest, ForceDelete) {
ASSERT_EQ(0, TrackedMockResource::tracked_objects_alive);
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_string.cc b/webkit/plugins/ppapi/string.cc
index 53c8943..d8b95de 100644
--- a/webkit/glue/plugins/pepper_string.cc
+++ b/webkit/plugins/ppapi/string.cc
@@ -2,12 +2,15 @@
// 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_string.h"
+#include "webkit/plugins/ppapi/string.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
String::String(const char* str, uint32 len) : value_(str, len) {}
String::~String() {}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_string.h b/webkit/plugins/ppapi/string.h
index fa1ab2ff..6880b3b 100644
--- a/webkit/glue/plugins/pepper_string.h
+++ b/webkit/plugins/ppapi/string.h
@@ -10,7 +10,8 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
class String : public base::RefCountedThreadSafe<String> {
public:
@@ -25,6 +26,7 @@ class String : public base::RefCountedThreadSafe<String> {
DISALLOW_COPY_AND_ASSIGN(String);
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
#endif // WEBKIT_GLUE_PLUGINS_PEPPER_STRING_H_
diff --git a/webkit/glue/plugins/pepper_var.cc b/webkit/plugins/ppapi/var.cc
index c9c354c..132cdfb 100644
--- a/webkit/glue/plugins/pepper_var.cc
+++ b/webkit/plugins/ppapi/var.cc
@@ -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_var.h"
+#include "webkit/plugins/ppapi/var.h"
#include <limits>
@@ -13,15 +13,16 @@
#include "ppapi/c/ppb_var.h"
#include "ppapi/c/pp_var.h"
#include "third_party/WebKit/WebKit/chromium/public/WebBindings.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/glue/plugins/pepper_plugin_object.h"
+#include "webkit/plugins/ppapi/common.h"
+#include "webkit/plugins/ppapi/plugin_module.h"
+#include "webkit/plugins/ppapi/plugin_object.h"
+#include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
#include "v8/include/v8.h"
using WebKit::WebBindings;
-namespace pepper {
+namespace webkit {
+namespace ppapi {
namespace {
@@ -866,4 +867,6 @@ void TryCatch::Catch(void* self, const char* message) {
static_cast<TryCatch*>(self)->SetException(message);
}
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
+
diff --git a/webkit/glue/plugins/pepper_var.h b/webkit/plugins/ppapi/var.h
index e59920a..8f74733 100644
--- a/webkit/glue/plugins/pepper_var.h
+++ b/webkit/plugins/ppapi/var.h
@@ -2,12 +2,12 @@
// 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_VAR_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_VAR_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_VAR_H_
+#define WEBKIT_PLUGINS_PPAPI_VAR_H_
#include <string>
-#include "webkit/glue/plugins/pepper_resource.h"
+#include "webkit/plugins/ppapi/resource.h"
struct PP_Var;
struct PPB_Var;
@@ -16,7 +16,8 @@ typedef struct NPObject NPObject;
typedef struct _NPVariant NPVariant;
typedef void* NPIdentifier;
-namespace pepper {
+namespace webkit {
+namespace ppapi {
// Var -------------------------------------------------------------------------
@@ -246,6 +247,7 @@ class TryCatch {
PP_Var* exception_;
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_VAR_H_
+#endif // WEBKIT_PLUGINS_PPAPI_VAR_H_
diff --git a/webkit/plugins/ppapi/var_object_class.cc b/webkit/plugins/ppapi/var_object_class.cc
new file mode 100644
index 0000000..282ad72
--- /dev/null
+++ b/webkit/plugins/ppapi/var_object_class.cc
@@ -0,0 +1,286 @@
+// 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/var_object_class.h"
+
+#include "third_party/WebKit/WebKit/chromium/public/WebBindings.h"
+#include "webkit/plugins/ppapi/npapi_glue.h"
+#include "webkit/plugins/ppapi/resource_tracker.h"
+#include "webkit/plugins/ppapi/var.h"
+
+using WebKit::WebBindings;
+
+namespace webkit {
+namespace ppapi {
+
+namespace {
+
+// 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* 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 -------------------------------------------------------------------
+
+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::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)) {
+}
+
+VarObjectClass::InstanceData::InstanceData() : native_data(NULL) {
+}
+
+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;
+ }
+}
+
+// virtual
+VarObjectClass::~VarObjectClass() {
+}
+
+VarObjectClass* VarObjectClass::AsVarObjectClass() {
+ return this;
+}
+
+// static
+const PPB_Class* VarObjectClass::GetInterface() {
+ static PPB_Class interface = {
+ &Create,
+ &Instantiate
+ };
+ return &interface;
+}
+
+} // namespace ppapi
+} // namespace webkit
diff --git a/webkit/glue/plugins/pepper_class.h b/webkit/plugins/ppapi/var_object_class.h
index b2365a2..7f9cb98 100644
--- a/webkit/glue/plugins/pepper_class.h
+++ b/webkit/plugins/ppapi/var_object_class.h
@@ -2,17 +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_CLASS_H_
-#define WEBKIT_GLUE_PLUGINS_PEPPER_CLASS_H_
+#ifndef WEBKIT_PLUGINS_PPAPI_CLASS_H_
+#define WEBKIT_PLUGINS_PPAPI_CLASS_H_
-#include "webkit/glue/plugins/pepper_resource.h"
+#include "webkit/plugins/ppapi/resource.h"
#include <string>
#include "base/hash_tables.h"
+#include "base/ref_counted.h"
#include "ppapi/c/ppb_class.h"
+#include "third_party/npapi/bindings/npruntime.h"
-namespace pepper {
+namespace webkit {
+namespace ppapi {
class PluginModule;
@@ -28,12 +31,14 @@ class VarObjectClass : public Resource {
const bool enumerable;
};
- struct InstanceData;
+ struct InstanceData : public NPObject {
+ InstanceData();
- typedef base::hash_map<std::string, Property> PropertyMap;
+ scoped_refptr<VarObjectClass> object_class;
+ void* native_data;
+ };
- // Returns the PPB_Var interface for the plugin to use.
- static const PPB_Class* GetInterface();
+ typedef base::hash_map<std::string, Property> PropertyMap;
VarObjectClass(PluginModule* module, PP_ClassDestructor destruct,
PP_ClassFunction invoke, PP_ClassProperty* properties);
@@ -42,6 +47,9 @@ class VarObjectClass : public Resource {
// Resource override.
virtual VarObjectClass* AsVarObjectClass();
+ // Returns the PPB_Var interface for the plugin to use.
+ static const PPB_Class* GetInterface();
+
const PropertyMap &properties() const { return properties_; }
PP_ClassDestructor instance_native_destructor() {
@@ -60,7 +68,8 @@ class VarObjectClass : public Resource {
DISALLOW_COPY_AND_ASSIGN(VarObjectClass);
};
-} // namespace pepper
+} // namespace ppapi
+} // namespace webkit
-#endif // WEBKIT_GLUE_PLUGINS_PEPPER_CLASS_H_
+#endif // WEBKIT_PLUGINS_PPAPI_CLASS_H_
diff --git a/webkit/tools/test_shell/test_shell.gypi b/webkit/tools/test_shell/test_shell.gypi
index 088773f..79191c6 100644
--- a/webkit/tools/test_shell/test_shell.gypi
+++ b/webkit/tools/test_shell/test_shell.gypi
@@ -404,14 +404,8 @@
'../../glue/mock_webframe.h',
'../../glue/mock_weburlloader_impl.h',
'../../glue/multipart_response_delegate_unittest.cc',
- '../../glue/plugins/mock_plugin_delegate.cc',
- '../../glue/plugins/mock_plugin_delegate.h',
- '../../glue/plugins/mock_resource.h',
'../../glue/plugins/plugin_group_unittest.cc',
'../../glue/plugins/plugin_lib_unittest.cc',
- '../../glue/plugins/ppapi_unittest.cc',
- '../../glue/plugins/ppapi_unittest.h',
- '../../glue/plugins/resource_tracker_unittest.cc',
'../../glue/plugins/webplugin_impl_unittest.cc',
'../../glue/plugins/webplugin_impl_unittest.cc',
'../../glue/regular_expression_unittest.cc',
@@ -422,6 +416,12 @@
'../../glue/webkit_glue_unittest.cc',
'../../glue/webpasswordautocompletelistener_unittest.cc',
'../../glue/webview_unittest.cc',
+ '../../plugins/ppapi/mock_plugin_delegate.cc',
+ '../../plugins/ppapi/mock_plugin_delegate.h',
+ '../../plugins/ppapi/mock_resource.h',
+ '../../plugins/ppapi/ppapi_unittest.cc',
+ '../../plugins/ppapi/ppapi_unittest.h',
+ '../../plugins/ppapi/resource_tracker_unittest.cc',
'../webcore_unit_tests/BMPImageDecoder_unittest.cpp',
'../webcore_unit_tests/ICOImageDecoder_unittest.cpp',
'event_listener_unittest.cc',