diff options
author | dmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-05 14:45:44 +0000 |
---|---|---|
committer | dmichael@google.com <dmichael@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-05 14:45:44 +0000 |
commit | 6f2e3919c4709404d8d7b6742f9cd9989b799c98 (patch) | |
tree | 55a933f7e2988625f0f3ded5a562203c7e3921c9 /webkit/glue/plugins | |
parent | 79ba2d8a26fe6c9b343c57fef57896a90baa3878 (diff) | |
download | chromium_src-6f2e3919c4709404d8d7b6742f9cd9989b799c98.zip chromium_src-6f2e3919c4709404d8d7b6742f9cd9989b799c98.tar.gz chromium_src-6f2e3919c4709404d8d7b6742f9cd9989b799c98.tar.bz2 |
Make PPAPI headers compile with C compilers (gcc on Linux & Mac and MSVS on Windows). This includes changing bool to PP_Bool and adding a PP_INLINE macro.
TEST=tests/test_c_includes.c
BUG=59791,53451
The first patch set is a straight copy of http://codereview.chromium.org/4019010/show which got LGTMed when PPAPI was in its own repo, but had to be rolled back in order to include chrome changes.
IMPORTANT: This change will break plugin implementations that use the C interface, and might break others as well.
Review URL: http://codereview.chromium.org/4310002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65200 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/plugins')
26 files changed, 318 insertions, 228 deletions
diff --git a/webkit/glue/plugins/pepper_audio.cc b/webkit/glue/plugins/pepper_audio.cc index e5babec..d98ef1b 100644 --- a/webkit/glue/plugins/pepper_audio.cc +++ b/webkit/glue/plugins/pepper_audio.cc @@ -7,6 +7,7 @@ #include "base/logging.h" #include "ppapi/c/dev/ppb_audio_dev.h" #include "ppapi/c/dev/ppb_audio_trusted_dev.h" +#include "webkit/glue/plugins/pepper_common.h" namespace pepper { @@ -50,9 +51,9 @@ uint32_t RecommendSampleFrameCount(uint32_t requested_sample_frame_count) { return requested_sample_frame_count; } -bool IsAudioConfig(PP_Resource resource) { +PP_Bool IsAudioConfig(PP_Resource resource) { scoped_refptr<AudioConfig> config = Resource::GetAs<AudioConfig>(resource); - return !!config; + return BoolToPPBool(!!config); } PP_AudioSampleRate_Dev GetSampleRate(PP_Resource config_id) { @@ -87,9 +88,9 @@ PP_Resource Create(PP_Instance instance_id, PP_Resource config_id, return audio->GetReference(); } -bool IsAudio(PP_Resource resource) { +PP_Bool IsAudio(PP_Resource resource) { scoped_refptr<Audio> audio = Resource::GetAs<Audio>(resource); - return !!audio; + return BoolToPPBool(!!audio); } PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { @@ -97,14 +98,14 @@ PP_Resource GetCurrentConfiguration(PP_Resource audio_id) { return audio ? audio->GetCurrentConfiguration() : 0; } -bool StartPlayback(PP_Resource audio_id) { +PP_Bool StartPlayback(PP_Resource audio_id) { scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id); - return audio ? audio->StartPlayback() : false; + return audio ? BoolToPPBool(audio->StartPlayback()) : PP_FALSE; } -bool StopPlayback(PP_Resource audio_id) { +PP_Bool StopPlayback(PP_Resource audio_id) { scoped_refptr<Audio> audio = Resource::GetAs<Audio>(audio_id); - return audio ? audio->StopPlayback() : false; + return audio ? BoolToPPBool(audio->StopPlayback()) : PP_FALSE; } const PPB_Audio_Dev ppb_audio = { diff --git a/webkit/glue/plugins/pepper_audio.h b/webkit/glue/plugins/pepper_audio.h index 705192c..ccba021 100644 --- a/webkit/glue/plugins/pepper_audio.h +++ b/webkit/glue/plugins/pepper_audio.h @@ -2,6 +2,9 @@ // 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_ + #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/shared_memory.h" @@ -15,9 +18,6 @@ #include "webkit/glue/plugins/pepper_plugin_module.h" #include "webkit/glue/plugins/pepper_resource.h" -#ifndef WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ -#define WEBKIT_GLUE_PLUGINS_PEPPER_DEVICE_CONTEXT_AUDIO_H_ - namespace pepper { class PluginInstance; diff --git a/webkit/glue/plugins/pepper_buffer.cc b/webkit/glue/plugins/pepper_buffer.cc index 7b52e69..cee10c9 100644 --- a/webkit/glue/plugins/pepper_buffer.cc +++ b/webkit/glue/plugins/pepper_buffer.cc @@ -12,6 +12,7 @@ #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" @@ -31,16 +32,16 @@ PP_Resource Create(PP_Module module_id, int32_t size) { return buffer->GetReference(); } -bool IsBuffer(PP_Resource resource) { - return !!Resource::GetAs<Buffer>(resource); +PP_Bool IsBuffer(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Buffer>(resource)); } -bool Describe(PP_Resource resource, int32_t* size_in_bytes) { +PP_Bool Describe(PP_Resource resource, int32_t* size_in_bytes) { scoped_refptr<Buffer> buffer(Resource::GetAs<Buffer>(resource)); if (!buffer) - return false; + return PP_FALSE; buffer->Describe(size_in_bytes); - return true; + return PP_TRUE; } void* Map(PP_Resource resource) { diff --git a/webkit/glue/plugins/pepper_common.h b/webkit/glue/plugins/pepper_common.h new file mode 100644 index 0000000..be9fe3d --- /dev/null +++ b/webkit/glue/plugins/pepper_common.h @@ -0,0 +1,24 @@ +// 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_COMMON_H_ +#define WEBKIT_GLUE_PLUGINS_PEPPER_COMMON_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_var.h" + +namespace pepper { + +inline PP_Bool BoolToPPBool(bool value) { + return value ? PP_TRUE : PP_FALSE; +} + +inline bool PPBoolToBool(PP_Bool value) { + return (PP_TRUE == value); +} + +} // namespace pepper + +#endif // WEBKIT_GLUE_PLUGINS_PEPPER_COMMON_H_ + diff --git a/webkit/glue/plugins/pepper_cursor_control.cc b/webkit/glue/plugins/pepper_cursor_control.cc index f515deb..62b4e2f 100644 --- a/webkit/glue/plugins/pepper_cursor_control.cc +++ b/webkit/glue/plugins/pepper_cursor_control.cc @@ -10,6 +10,7 @@ #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" @@ -18,59 +19,59 @@ namespace pepper { namespace { -bool SetCursor(PP_Instance instance_id, +PP_Bool SetCursor(PP_Instance instance_id, PP_CursorType_Dev type, PP_Resource custom_image_id, const PP_Point* hot_spot) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; scoped_refptr<ImageData> custom_image( Resource::GetAs<ImageData>(custom_image_id)); if (custom_image.get()) { // TODO(neb): implement custom cursors. NOTIMPLEMENTED(); - return false; + return PP_FALSE; } - return instance->SetCursor(type); + return BoolToPPBool(instance->SetCursor(type)); } -bool LockCursor(PP_Instance instance_id) { +PP_Bool LockCursor(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; // TODO(neb): implement cursor locking. - return false; + return PP_FALSE; } -bool UnlockCursor(PP_Instance instance_id) { +PP_Bool UnlockCursor(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; // TODO(neb): implement cursor locking. - return false; + return PP_FALSE; } -bool HasCursorLock(PP_Instance instance_id) { +PP_Bool HasCursorLock(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; // TODO(neb): implement cursor locking. - return false; + return PP_FALSE; } -bool CanLockCursor(PP_Instance instance_id) { +PP_Bool CanLockCursor(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; + return PP_FALSE; // TODO(neb): implement cursor locking. - return false; + return PP_FALSE; } const PPB_CursorControl_Dev cursor_control_interface = { diff --git a/webkit/glue/plugins/pepper_directory_reader.cc b/webkit/glue/plugins/pepper_directory_reader.cc index 558560e..c476b76 100644 --- a/webkit/glue/plugins/pepper_directory_reader.cc +++ b/webkit/glue/plugins/pepper_directory_reader.cc @@ -10,6 +10,7 @@ #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" @@ -51,8 +52,8 @@ PP_Resource Create(PP_Resource directory_ref_id) { return reader->GetReference(); } -bool IsDirectoryReader(PP_Resource resource) { - return !!Resource::GetAs<DirectoryReader>(resource); +PP_Bool IsDirectoryReader(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<DirectoryReader>(resource)); } int32_t GetNextEntry(PP_Resource reader_id, diff --git a/webkit/glue/plugins/pepper_event_conversion.cc b/webkit/glue/plugins/pepper_event_conversion.cc index bc60af2..300592f 100644 --- a/webkit/glue/plugins/pepper_event_conversion.cc +++ b/webkit/glue/plugins/pepper_event_conversion.cc @@ -12,6 +12,7 @@ #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" using WebKit::WebInputEvent; using WebKit::WebKeyboardEvent; @@ -142,7 +143,8 @@ void AppendMouseWheelEvent(const WebInputEvent& event, result.u.wheel.delta_y = mouse_wheel_event.deltaY; 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 = !!mouse_wheel_event.scrollByPage; + result.u.wheel.scroll_by_page = + pepper::BoolToPPBool(!!mouse_wheel_event.scrollByPage); pp_events->push_back(result); } diff --git a/webkit/glue/plugins/pepper_file_chooser.cc b/webkit/glue/plugins/pepper_file_chooser.cc index 576e205..fd3ade1 100644 --- a/webkit/glue/plugins/pepper_file_chooser.cc +++ b/webkit/glue/plugins/pepper_file_chooser.cc @@ -15,6 +15,7 @@ #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" @@ -41,8 +42,8 @@ PP_Resource Create(PP_Instance instance_id, return chooser->GetReference(); } -bool IsFileChooser(PP_Resource resource) { - return !!Resource::GetAs<FileChooser>(resource); +PP_Bool IsFileChooser(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<FileChooser>(resource)); } int32_t Show(PP_Resource chooser_id, PP_CompletionCallback callback) { diff --git a/webkit/glue/plugins/pepper_file_io.cc b/webkit/glue/plugins/pepper_file_io.cc index 41ce5b6..1d3d66e 100644 --- a/webkit/glue/plugins/pepper_file_io.cc +++ b/webkit/glue/plugins/pepper_file_io.cc @@ -15,6 +15,7 @@ #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" @@ -33,8 +34,8 @@ PP_Resource Create(PP_Module module_id) { return file_io->GetReference(); } -bool IsFileIO(PP_Resource resource) { - return !!Resource::GetAs<FileIO>(resource); +PP_Bool IsFileIO(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<FileIO>(resource)); } int32_t Open(PP_Resource file_io_id, diff --git a/webkit/glue/plugins/pepper_file_ref.cc b/webkit/glue/plugins/pepper_file_ref.cc index a135cf6..67e39e3 100644 --- a/webkit/glue/plugins/pepper_file_ref.cc +++ b/webkit/glue/plugins/pepper_file_ref.cc @@ -7,6 +7,7 @@ #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" @@ -58,8 +59,8 @@ PP_Resource Create(PP_Resource file_system_id, const char* path) { return file_ref->GetReference(); } -bool IsFileRef(PP_Resource resource) { - return !!Resource::GetAs<FileRef>(resource); +PP_Bool IsFileRef(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<FileRef>(resource)); } PP_FileSystemType_Dev GetFileSystemType(PP_Resource file_ref_id) { @@ -103,7 +104,7 @@ PP_Resource GetParent(PP_Resource file_ref_id) { } int32_t MakeDirectory(PP_Resource directory_ref_id, - bool make_ancestors, + PP_Bool make_ancestors, PP_CompletionCallback callback) { scoped_refptr<FileRef> directory_ref( Resource::GetAs<FileRef>(directory_ref_id)); @@ -117,7 +118,7 @@ int32_t MakeDirectory(PP_Resource directory_ref_id, PluginInstance* instance = file_system->instance(); if (!instance->delegate()->MakeDirectory( - directory_ref->GetSystemPath(), make_ancestors, + directory_ref->GetSystemPath(), PPBoolToBool(make_ancestors), new FileCallbacks(instance->module()->AsWeakPtr(), callback, NULL, NULL, NULL))) return PP_ERROR_FAILED; diff --git a/webkit/glue/plugins/pepper_font.cc b/webkit/glue/plugins/pepper_font.cc index 340e076..553c8ed 100644 --- a/webkit/glue/plugins/pepper_font.cc +++ b/webkit/glue/plugins/pepper_font.cc @@ -14,6 +14,7 @@ #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" @@ -87,8 +88,8 @@ WebFontDescription PPFontDescToWebFontDesc(const PP_FontDescription_Dev& font) { result.family = UTF8ToUTF16(face_name->value()); result.genericFamily = PP_FONTFAMILY_TO_WEB_FONTFAMILY(font.family); result.size = static_cast<float>(font.size); - result.italic = font.italic; - result.smallCaps = font.small_caps; + result.italic = PPBoolToBool(font.italic); + result.smallCaps = PPBoolToBool(font.small_caps); result.weight = static_cast<WebFontDescription::Weight>(font.weight); result.letterSpacing = static_cast<short>(font.letter_spacing); result.wordSpacing = static_cast<short>(font.word_spacing); @@ -102,7 +103,8 @@ bool PPTextRunToWebTextRun(const PP_TextRun_Dev* run, WebTextRun* output) { if (!text_string) return false; *output = WebTextRun(UTF8ToUTF16(text_string->value()), - run->rtl, run->override_direction); + PPBoolToBool(run->rtl), + PPBoolToBool(run->override_direction)); return true; } @@ -119,31 +121,31 @@ PP_Resource Create(PP_Module module_id, return font->GetReference(); } -bool IsFont(PP_Resource resource) { - return !!Resource::GetAs<Font>(resource).get(); +PP_Bool IsFont(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Font>(resource).get()); } -bool Describe(PP_Resource font_id, +PP_Bool Describe(PP_Resource font_id, PP_FontDescription_Dev* description, PP_FontMetrics_Dev* metrics) { scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); if (!font.get()) - return false; - return font->Describe(description, metrics); + return PP_FALSE; + return BoolToPPBool(font->Describe(description, metrics)); } -bool DrawTextAt(PP_Resource font_id, +PP_Bool DrawTextAt(PP_Resource font_id, 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) { + PP_Bool image_data_is_opaque) { scoped_refptr<Font> font(Resource::GetAs<Font>(font_id)); if (!font.get()) - return false; - return font->DrawTextAt(image_data, text, position, color, clip, - image_data_is_opaque); + return PP_FALSE; + return BoolToPPBool(font->DrawTextAt(image_data, text, position, color, clip, + PPBoolToBool(image_data_is_opaque))); } int32_t MeasureText(PP_Resource font_id, const PP_TextRun_Dev* text) { @@ -211,8 +213,8 @@ bool Font::Describe(PP_FontDescription_Dev* description, description->family = static_cast<PP_FontFamily_Dev>(web_desc.genericFamily); description->size = static_cast<uint32_t>(web_desc.size); description->weight = static_cast<PP_FontWeight_Dev>(web_desc.weight); - description->italic = web_desc.italic; - description->small_caps = web_desc.smallCaps; + description->italic = BoolToPPBool(web_desc.italic); + description->small_caps = BoolToPPBool(web_desc.smallCaps); metrics->height = font_->height(); metrics->ascent = font_->ascent(); diff --git a/webkit/glue/plugins/pepper_graphics_2d.cc b/webkit/glue/plugins/pepper_graphics_2d.cc index 720d1d8..a8d5091 100644 --- a/webkit/glue/plugins/pepper_graphics_2d.cc +++ b/webkit/glue/plugins/pepper_graphics_2d.cc @@ -19,6 +19,7 @@ #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" @@ -112,28 +113,28 @@ void ConvertImageData(ImageData* src_image, const SkIRect& src_rect, PP_Resource Create(PP_Module module_id, const PP_Size* size, - bool is_always_opaque) { + PP_Bool is_always_opaque) { PluginModule* module = ResourceTracker::Get()->GetModule(module_id); if (!module) return 0; scoped_refptr<Graphics2D> context(new Graphics2D(module)); - if (!context->Init(size->width, size->height, is_always_opaque)) + if (!context->Init(size->width, size->height, PPBoolToBool(is_always_opaque))) return 0; return context->GetReference(); } -bool IsGraphics2D(PP_Resource resource) { - return !!Resource::GetAs<Graphics2D>(resource); +PP_Bool IsGraphics2D(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Graphics2D>(resource)); } -bool Describe(PP_Resource graphics_2d, +PP_Bool Describe(PP_Resource graphics_2d, PP_Size* size, - bool* is_always_opaque) { + PP_Bool* is_always_opaque) { scoped_refptr<Graphics2D> context( Resource::GetAs<Graphics2D>(graphics_2d)); if (!context) - return false; + return PP_FALSE; return context->Describe(size, is_always_opaque); } @@ -242,11 +243,11 @@ bool Graphics2D::Init(int width, int height, bool is_always_opaque) { return true; } -bool Graphics2D::Describe(PP_Size* size, bool* is_always_opaque) { +PP_Bool Graphics2D::Describe(PP_Size* size, PP_Bool* is_always_opaque) { size->width = image_data_->width(); size->height = image_data_->height(); - *is_always_opaque = false; // TODO(brettw) implement this. - return true; + *is_always_opaque = PP_FALSE; // TODO(brettw) implement this. + return PP_TRUE; } void Graphics2D::PaintImageData(PP_Resource image_data, diff --git a/webkit/glue/plugins/pepper_graphics_2d.h b/webkit/glue/plugins/pepper_graphics_2d.h index 6caac83..78170ab 100644 --- a/webkit/glue/plugins/pepper_graphics_2d.h +++ b/webkit/glue/plugins/pepper_graphics_2d.h @@ -42,7 +42,7 @@ class Graphics2D : public Resource { virtual Graphics2D* AsGraphics2D() { return this; } // PPB_Graphics2D functions. - bool Describe(PP_Size* size, bool* is_always_opaque); + PP_Bool Describe(PP_Size* size, PP_Bool* is_always_opaque); void PaintImageData(PP_Resource image_data, const PP_Point* top_left, const PP_Rect* src_rect); diff --git a/webkit/glue/plugins/pepper_graphics_3d.cc b/webkit/glue/plugins/pepper_graphics_3d.cc index 47b587e..fa9c2ec1c 100644 --- a/webkit/glue/plugins/pepper_graphics_3d.cc +++ b/webkit/glue/plugins/pepper_graphics_3d.cc @@ -8,6 +8,7 @@ #include "base/singleton.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" namespace pepper { @@ -22,24 +23,24 @@ typedef Singleton<base::ThreadLocalPointer<Graphics3D>, // Size of the transfer buffer. enum { kTransferBufferSize = 512 * 1024 }; -bool IsGraphics3D(PP_Resource resource) { - return !!Resource::GetAs<Graphics3D>(resource); +PP_Bool IsGraphics3D(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Graphics3D>(resource)); } -bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) { +PP_Bool GetConfigs(int32_t* configs, int32_t config_size, int32_t* num_config) { // TODO(neb): Implement me! - return false; + return PP_FALSE; } -bool ChooseConfig(const int32_t* attrib_list, int32_t* configs, - int32_t config_size, int32_t* num_config) { +PP_Bool ChooseConfig(const int32_t* attrib_list, int32_t* configs, + int32_t config_size, int32_t* num_config) { // TODO(neb): Implement me! - return false; + return PP_FALSE; } -bool GetConfigAttrib(int32_t config, int32_t attribute, int32_t* value) { +PP_Bool GetConfigAttrib(int32_t config, int32_t attribute, int32_t* value) { // TODO(neb): Implement me! - return false; + return PP_FALSE; } const char* QueryString(int32_t name) { @@ -80,13 +81,13 @@ void* GetProcAddress(const char* name) { return NULL; } -bool MakeCurrent(PP_Resource graphics3d) { +PP_Bool MakeCurrent(PP_Resource graphics3d) { if (!graphics3d) { Graphics3D::ResetCurrent(); - return true; + return PP_TRUE; } else { scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); - return context.get() && context->MakeCurrent(); + return BoolToPPBool(context.get() && context->MakeCurrent()); } } @@ -95,9 +96,9 @@ PP_Resource GetCurrentContext() { return currentContext ? currentContext->GetReference() : 0; } -bool SwapBuffers(PP_Resource graphics3d) { +PP_Bool SwapBuffers(PP_Resource graphics3d) { scoped_refptr<Graphics3D> context(Resource::GetAs<Graphics3D>(graphics3d)); - return context && context->SwapBuffers(); + return BoolToPPBool(context && context->SwapBuffers()); } uint32_t GetError() { diff --git a/webkit/glue/plugins/pepper_image_data.cc b/webkit/glue/plugins/pepper_image_data.cc index 6dc9be5..702abee 100644 --- a/webkit/glue/plugins/pepper_image_data.cc +++ b/webkit/glue/plugins/pepper_image_data.cc @@ -16,6 +16,7 @@ #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" @@ -27,38 +28,42 @@ PP_ImageDataFormat GetNativeImageDataFormat() { return ImageData::GetNativeImageDataFormat(); } -bool IsImageDataFormatSupported(PP_ImageDataFormat format) { - return ImageData::IsImageDataFormatSupported(format); +PP_Bool IsImageDataFormatSupported(PP_ImageDataFormat format) { + return BoolToPPBool(ImageData::IsImageDataFormatSupported(format)); } PP_Resource Create(PP_Module module_id, PP_ImageDataFormat format, const PP_Size* size, - bool init_to_zero) { + PP_Bool init_to_zero) { PluginModule* module = ResourceTracker::Get()->GetModule(module_id); if (!module) return 0; scoped_refptr<ImageData> data(new ImageData(module)); - if (!data->Init(format, size->width, size->height, init_to_zero)) + if (!data->Init(format, + size->width, + size->height, + PPBoolToBool(init_to_zero))) { return 0; + } return data->GetReference(); } -bool IsImageData(PP_Resource resource) { - return !!Resource::GetAs<ImageData>(resource); +PP_Bool IsImageData(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<ImageData>(resource)); } -bool Describe(PP_Resource resource, PP_ImageDataDesc* desc) { +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)); if (!image_data) - return false; + return PP_FALSE; image_data->Describe(desc); - return true; + return PP_TRUE; } void* Map(PP_Resource resource) { diff --git a/webkit/glue/plugins/pepper_plugin_instance.cc b/webkit/glue/plugins/pepper_plugin_instance.cc index f735591..b40874a 100644 --- a/webkit/glue/plugins/pepper_plugin_instance.cc +++ b/webkit/glue/plugins/pepper_plugin_instance.cc @@ -48,6 +48,7 @@ #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_event_conversion.h" #include "webkit/glue/plugins/pepper_fullscreen_container.h" @@ -160,18 +161,18 @@ PP_Var GetOwnerElementObject(PP_Instance instance_id) { return instance->GetOwnerElementObject(); } -bool BindGraphics(PP_Instance instance_id, PP_Resource device_id) { +PP_Bool BindGraphics(PP_Instance instance_id, PP_Resource device_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; - return instance->BindGraphics(device_id); + return PP_FALSE; + return BoolToPPBool(instance->BindGraphics(device_id)); } -bool IsFullFrame(PP_Instance instance_id) { +PP_Bool IsFullFrame(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; - return instance->full_frame(); + return PP_FALSE; + return BoolToPPBool(instance->full_frame()); } PP_Var ExecuteScript(PP_Instance instance_id, @@ -193,14 +194,14 @@ const PPB_Instance ppb_instance = { void NumberOfFindResultsChanged(PP_Instance instance_id, int32_t total, - bool final_result) { + PP_Bool final_result) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) return; DCHECK_NE(instance->find_identifier(), -1); instance->delegate()->NumberOfFindResultsChanged( - instance->find_identifier(), total, final_result); + instance->find_identifier(), total, PPBoolToBool(final_result)); } void SelectedFindResultChanged(PP_Instance instance_id, @@ -219,18 +220,18 @@ const PPB_Find_Dev ppb_find = { &SelectedFindResultChanged, }; -bool IsFullscreen(PP_Instance instance_id) { +PP_Bool IsFullscreen(PP_Instance instance_id) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; - return instance->IsFullscreen(); + return PP_FALSE; + return BoolToPPBool(instance->IsFullscreen()); } -bool SetFullscreen(PP_Instance instance_id, bool fullscreen) { +PP_Bool SetFullscreen(PP_Instance instance_id, PP_Bool fullscreen) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) - return false; - return instance->SetFullscreen(fullscreen); + return PP_FALSE; + return BoolToPPBool(instance->SetFullscreen(PPBoolToBool(fullscreen))); } const PPB_Fullscreen_Dev ppb_fullscreen = { @@ -502,13 +503,16 @@ bool PluginInstance::Initialize(WebPluginContainer* container, argc++; } - return instance_interface_->DidCreate(pp_instance(), - argc, argn.get(), argv.get()); + return PPBoolToBool(instance_interface_->DidCreate(pp_instance(), + argc, + argn.get(), + argv.get())); } bool PluginInstance::HandleDocumentLoad(URLLoader* loader) { Resource::ScopedResourceId resource(loader); - return instance_interface_->HandleDocumentLoad(pp_instance(), resource.id); + return PPBoolToBool(instance_interface_->HandleDocumentLoad(pp_instance(), + resource.id)); } bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, @@ -518,8 +522,10 @@ bool PluginInstance::HandleInputEvent(const WebKit::WebInputEvent& event, // Each input event may generate more than one PP_InputEvent. bool rv = false; - for (size_t i = 0; i < pp_events.size(); i++) - rv |= instance_interface_->HandleInputEvent(pp_instance(), &pp_events[i]); + for (size_t i = 0; i < pp_events.size(); i++) { + rv |= PPBoolToBool(instance_interface_->HandleInputEvent(pp_instance(), + &pp_events[i])); + } if (cursor_.get()) *cursor_info = *cursor_; @@ -555,8 +561,10 @@ void PluginInstance::SetWebKitFocus(bool has_focus) { bool old_plugin_focus = PluginHasFocus(); has_webkit_focus_ = has_focus; - if (PluginHasFocus() != old_plugin_focus) - instance_interface_->DidChangeFocus(pp_instance(), PluginHasFocus()); + if (PluginHasFocus() != old_plugin_focus) { + instance_interface_->DidChangeFocus(pp_instance(), + BoolToPPBool(PluginHasFocus())); + } } void PluginInstance::SetContentAreaFocus(bool has_focus) { @@ -565,8 +573,10 @@ void PluginInstance::SetContentAreaFocus(bool has_focus) { bool old_plugin_focus = PluginHasFocus(); has_content_area_focus_ = has_focus; - if (PluginHasFocus() != old_plugin_focus) - instance_interface_->DidChangeFocus(pp_instance(), PluginHasFocus()); + if (PluginHasFocus() != old_plugin_focus) { + instance_interface_->DidChangeFocus(pp_instance(), + BoolToPPBool(PluginHasFocus())); + } } void PluginInstance::ViewInitiatedPaint() { @@ -610,7 +620,8 @@ string16 PluginInstance::GetSelectedText(bool html) { if (!LoadSelectionInterface()) return string16(); - PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(), html); + PP_Var rv = plugin_selection_interface_->GetSelectedText(pp_instance(), + BoolToPPBool(html)); scoped_refptr<StringVar> string(StringVar::FromPPVar(rv)); Var::PluginReleasePPVar(rv); // Release the ref the plugin transfered to us. if (!string) @@ -636,7 +647,7 @@ string16 PluginInstance::GetLinkAtPosition(const gfx::Point& point) { void PluginInstance::Zoom(double factor, bool text_only) { if (!LoadZoomInterface()) return; - plugin_zoom_interface_->Zoom(pp_instance(), factor, text_only); + plugin_zoom_interface_->Zoom(pp_instance(), factor, BoolToPPBool(text_only)); } bool PluginInstance::StartFind(const string16& search_text, @@ -645,15 +656,17 @@ bool PluginInstance::StartFind(const string16& search_text, if (!LoadFindInterface()) return false; find_identifier_ = identifier; - return plugin_find_interface_->StartFind( - pp_instance(), - UTF16ToUTF8(search_text.c_str()).c_str(), - case_sensitive); + return PPBoolToBool( + plugin_find_interface_->StartFind( + pp_instance(), + UTF16ToUTF8(search_text.c_str()).c_str(), + BoolToPPBool(case_sensitive))); } void PluginInstance::SelectFindResult(bool forward) { if (LoadFindInterface()) - plugin_find_interface_->SelectFindResult(pp_instance(), forward); + plugin_find_interface_->SelectFindResult(pp_instance(), + BoolToPPBool(forward)); } void PluginInstance::StopFind() { @@ -759,7 +772,7 @@ int PluginInstance::PrintBegin(const gfx::Rect& printable_area, RectToPPRect(printable_area, &print_settings.printable_area); print_settings.dpi = printer_dpi; print_settings.orientation = PP_PRINTORIENTATION_NORMAL; - print_settings.grayscale = false; + print_settings.grayscale = PP_FALSE; print_settings.format = format; int num_pages = plugin_print_interface_->Begin(pp_instance(), &print_settings); diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc index a639f71..09e5369 100644 --- a/webkit/glue/plugins/pepper_plugin_module.cc +++ b/webkit/glue/plugins/pepper_plugin_module.cc @@ -49,6 +49,7 @@ #include "ppapi/c/ppp_instance.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_cursor_control.h" #include "webkit/glue/plugins/pepper_directory_reader.h" @@ -141,8 +142,8 @@ void CallOnMainThread(int delay_in_msec, delay_in_msec); } -bool IsMainThread() { - return GetMainThreadMessageLoop()->BelongsToCurrentThread(); +PP_Bool IsMainThread() { + return BoolToPPBool(GetMainThreadMessageLoop()->BelongsToCurrentThread()); } const PPB_Core core_interface = { @@ -158,14 +159,14 @@ const PPB_Core core_interface = { // PPB_Testing ----------------------------------------------------------------- -bool ReadImageData(PP_Resource device_context_2d, +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)); if (!context.get()) - return false; - return context->ReadImageData(image, top_left); + return PP_FALSE; + return BoolToPPBool(context->ReadImageData(image, top_left)); } void RunMessageLoop() { diff --git a/webkit/glue/plugins/pepper_scrollbar.cc b/webkit/glue/plugins/pepper_scrollbar.cc index 624f114..2b96259 100644 --- a/webkit/glue/plugins/pepper_scrollbar.cc +++ b/webkit/glue/plugins/pepper_scrollbar.cc @@ -12,6 +12,7 @@ #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" @@ -30,17 +31,18 @@ namespace pepper { namespace { -PP_Resource Create(PP_Instance instance_id, bool vertical) { +PP_Resource Create(PP_Instance instance_id, PP_Bool vertical) { PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); if (!instance) return 0; - scoped_refptr<Scrollbar> scrollbar(new Scrollbar(instance, vertical)); + scoped_refptr<Scrollbar> scrollbar(new Scrollbar(instance, + PPBoolToBool(vertical))); return scrollbar->GetReference(); } -bool IsScrollbar(PP_Resource resource) { - return !!Resource::GetAs<Scrollbar>(resource); +PP_Bool IsScrollbar(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Scrollbar>(resource)); } uint32_t GetThickness() { diff --git a/webkit/glue/plugins/pepper_transport.cc b/webkit/glue/plugins/pepper_transport.cc index 3e60a2c..29a4495 100644 --- a/webkit/glue/plugins/pepper_transport.cc +++ b/webkit/glue/plugins/pepper_transport.cc @@ -7,6 +7,7 @@ #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" @@ -25,15 +26,15 @@ PP_Resource CreateTransport(PP_Module module, } // Returns whether or not resource is Transport -bool IsTransport(PP_Resource resource) { - return !!Resource::GetAs<Transport>(resource); +PP_Bool IsTransport(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Transport>(resource)); } // Returns whether the transport is currently writable // (i.e. can send data to the remote peer) -bool IsWritable(PP_Resource transport) { +PP_Bool IsWritable(PP_Resource transport) { // TODO(juberti): impelement me - return false; + return PP_FALSE; } diff --git a/webkit/glue/plugins/pepper_url_loader.cc b/webkit/glue/plugins/pepper_url_loader.cc index 2e68adb..9c3b03a 100644 --- a/webkit/glue/plugins/pepper_url_loader.cc +++ b/webkit/glue/plugins/pepper_url_loader.cc @@ -19,6 +19,7 @@ #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" @@ -50,8 +51,8 @@ PP_Resource Create(PP_Instance instance_id) { return loader->GetReference(); } -bool IsURLLoader(PP_Resource resource) { - return !!Resource::GetAs<URLLoader>(resource); +PP_Bool IsURLLoader(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<URLLoader>(resource)); } int32_t Open(PP_Resource loader_id, @@ -78,24 +79,26 @@ int32_t FollowRedirect(PP_Resource loader_id, return loader->FollowRedirect(callback); } -bool GetUploadProgress(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)); if (!loader) - return false; - return loader->GetUploadProgress(bytes_sent, total_bytes_to_be_sent); - return true; + return PP_FALSE; + + return BoolToPPBool(loader->GetUploadProgress(bytes_sent, + total_bytes_to_be_sent)); } -bool GetDownloadProgress(PP_Resource loader_id, - int64_t* bytes_received, - int64_t* total_bytes_to_be_received) { +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)); if (!loader) - return false; - return loader->GetDownloadProgress(bytes_received, - total_bytes_to_be_received); + return PP_FALSE; + + return BoolToPPBool(loader->GetDownloadProgress(bytes_received, + total_bytes_to_be_received)); } PP_Resource GetResponseInfo(PP_Resource loader_id) { diff --git a/webkit/glue/plugins/pepper_url_request_info.cc b/webkit/glue/plugins/pepper_url_request_info.cc index 723b327..a7a6589 100644 --- a/webkit/glue/plugins/pepper_url_request_info.cc +++ b/webkit/glue/plugins/pepper_url_request_info.cc @@ -15,6 +15,7 @@ #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" @@ -38,12 +39,12 @@ const char* const kIgnoredRequestHeaders[] = { "content-length" }; -bool IsIgnoredRequestHeader(const std::string& name) { +PP_Bool IsIgnoredRequestHeader(const std::string& name) { for (size_t i = 0; i < arraysize(kIgnoredRequestHeaders); ++i) { if (LowerCaseEqualsASCII(name, kIgnoredRequestHeaders[i])) - return true; + return PP_TRUE; } - return false; + return PP_FALSE; } PP_Resource Create(PP_Module module_id) { @@ -56,40 +57,47 @@ PP_Resource Create(PP_Module module_id) { return request->GetReference(); } -bool IsURLRequestInfo(PP_Resource resource) { - return !!Resource::GetAs<URLRequestInfo>(resource); +PP_Bool IsURLRequestInfo(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<URLRequestInfo>(resource)); } -bool SetProperty(PP_Resource request_id, - PP_URLRequestProperty_Dev property, - PP_Var var) { +PP_Bool SetProperty(PP_Resource request_id, + PP_URLRequestProperty_Dev property, + PP_Var var) { scoped_refptr<URLRequestInfo> request( Resource::GetAs<URLRequestInfo>(request_id)); if (!request) - return false; + return PP_FALSE; - if (var.type == PP_VARTYPE_BOOL) - return request->SetBooleanProperty(property, var.value.as_bool); + if (var.type == PP_VARTYPE_BOOL) { + return BoolToPPBool( + request->SetBooleanProperty(property, + PPBoolToBool(var.value.as_bool))); + } if (var.type == PP_VARTYPE_STRING) { scoped_refptr<StringVar> string(StringVar::FromPPVar(var)); - if (string) - return request->SetStringProperty(property, string->value()); + if (string) { + return BoolToPPBool(request->SetStringProperty(property, + string->value())); + } } - return false; + return PP_FALSE; } -bool AppendDataToBody(PP_Resource request_id, const char* data, uint32_t len) { +PP_Bool AppendDataToBody(PP_Resource request_id, + const char* data, + uint32_t len) { scoped_refptr<URLRequestInfo> request( Resource::GetAs<URLRequestInfo>(request_id)); if (!request) - return false; + return PP_FALSE; - return request->AppendDataToBody(std::string(data, len)); + return BoolToPPBool(request->AppendDataToBody(std::string(data, len))); } -bool AppendFileToBody(PP_Resource request_id, +PP_Bool AppendFileToBody(PP_Resource request_id, PP_Resource file_ref_id, int64_t start_offset, int64_t number_of_bytes, @@ -97,16 +105,16 @@ bool AppendFileToBody(PP_Resource request_id, scoped_refptr<URLRequestInfo> request( Resource::GetAs<URLRequestInfo>(request_id)); if (!request) - return false; + return PP_FALSE; scoped_refptr<FileRef> file_ref(Resource::GetAs<FileRef>(file_ref_id)); if (!file_ref) - return false; + return PP_FALSE; - return request->AppendFileToBody(file_ref, - start_offset, - number_of_bytes, - expected_last_modified_time); + return BoolToPPBool(request->AppendFileToBody(file_ref, + start_offset, + number_of_bytes, + expected_last_modified_time)); } const PPB_URLRequestInfo_Dev ppb_urlrequestinfo = { diff --git a/webkit/glue/plugins/pepper_url_response_info.cc b/webkit/glue/plugins/pepper_url_response_info.cc index bcb54ef..ee27003 100644 --- a/webkit/glue/plugins/pepper_url_response_info.cc +++ b/webkit/glue/plugins/pepper_url_response_info.cc @@ -10,6 +10,7 @@ #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/glue/webkit_glue.h" @@ -38,8 +39,8 @@ class HeaderFlattener : public WebHTTPHeaderVisitor { std::string buffer_; }; -bool IsURLResponseInfo(PP_Resource resource) { - return !!Resource::GetAs<URLResponseInfo>(resource); +PP_Bool IsURLResponseInfo(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<URLResponseInfo>(resource)); } PP_Var GetProperty(PP_Resource response_id, diff --git a/webkit/glue/plugins/pepper_url_util.cc b/webkit/glue/plugins/pepper_url_util.cc index c6ea5f8..2f97e6c 100644 --- a/webkit/glue/plugins/pepper_url_util.cc +++ b/webkit/glue/plugins/pepper_url_util.cc @@ -13,6 +13,7 @@ #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" @@ -115,46 +116,46 @@ PP_Var ResolveRelativeToDocument(PP_Instance instance_id, components); } -bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { +PP_Bool IsSameSecurityOrigin(PP_Var url_a, PP_Var url_b) { scoped_refptr<StringVar> url_a_string(StringVar::FromPPVar(url_a)); scoped_refptr<StringVar> url_b_string(StringVar::FromPPVar(url_b)); if (!url_a_string || !url_b_string) - return false; + return PP_FALSE; GURL gurl_a(url_a_string->value()); GURL gurl_b(url_b_string->value()); if (!gurl_a.is_valid() || !gurl_b.is_valid()) - return false; + return PP_FALSE; - return gurl_a.GetOrigin() == gurl_b.GetOrigin(); + return BoolToPPBool(gurl_a.GetOrigin() == gurl_b.GetOrigin()); } -bool DocumentCanRequest(PP_Instance instance, PP_Var url) { +PP_Bool DocumentCanRequest(PP_Instance instance, PP_Var url) { scoped_refptr<StringVar> url_string(StringVar::FromPPVar(url)); if (!url_string) - return false; + return PP_FALSE; WebKit::WebSecurityOrigin security_origin; if (!SecurityOriginForInstance(instance, &security_origin)) - return false; + return PP_FALSE; GURL gurl(url_string->value()); if (!gurl.is_valid()) - return false; + return PP_FALSE; - return security_origin.canRequest(gurl); + return BoolToPPBool(security_origin.canRequest(gurl)); } -bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) { +PP_Bool DocumentCanAccessDocument(PP_Instance active, PP_Instance target) { WebKit::WebSecurityOrigin active_origin; if (!SecurityOriginForInstance(active, &active_origin)) - return false; + return PP_FALSE; WebKit::WebSecurityOrigin target_origin; if (!SecurityOriginForInstance(active, &target_origin)) - return false; + return PP_FALSE; - return active_origin.canAccess(target_origin); + return BoolToPPBool(active_origin.canAccess(target_origin)); } } // namespace diff --git a/webkit/glue/plugins/pepper_var.cc b/webkit/glue/plugins/pepper_var.cc index 9a1f6cb..db83229 100644 --- a/webkit/glue/plugins/pepper_var.cc +++ b/webkit/glue/plugins/pepper_var.cc @@ -13,6 +13,7 @@ #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" @@ -297,20 +298,24 @@ PP_Var ConvertType(PP_Instance instance, return result; } +PP_Var BoolToPPVar(bool value) { + return PP_MakeBool(BoolToPPBool(value)); +} + void DefineProperty(struct PP_Var object, struct PP_ObjectProperty property, PP_Var* exception) { PP_Var params[] = { object, property.name, - PP_MakeBool(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_HASVALUE)), + BoolToPPVar(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_HASVALUE)), property.value, - PP_MakeBool(property.getter.type == PP_VARTYPE_OBJECT), + BoolToPPVar(property.getter.type == PP_VARTYPE_OBJECT), property.getter, - PP_MakeBool(property.setter.type == PP_VARTYPE_OBJECT), + BoolToPPVar(property.setter.type == PP_VARTYPE_OBJECT), property.setter, - PP_MakeBool(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_READONLY)), - PP_MakeBool(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTDELETE)), - PP_MakeBool(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTENUM)) + BoolToPPVar(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_READONLY)), + BoolToPPVar(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTDELETE)), + BoolToPPVar(!!(property.modifiers & PP_OBJECTPROPERTY_MODIFIER_DONTENUM)) }; RunJSFunction(object, @@ -329,14 +334,21 @@ void DefineProperty(struct PP_Var object, params, sizeof(params) / sizeof(PP_Var), exception); } -bool HasProperty(PP_Var var, - PP_Var name, - PP_Var* exception) { +PP_Bool HasProperty(PP_Var var, + PP_Var name, + PP_Var* exception) { ObjectAccessorWithIdentifierTryCatch accessor(var, name, exception); if (accessor.has_exception()) - return false; - return WebBindings::hasProperty(NULL, accessor.object()->np_object(), - accessor.identifier()); + return PP_FALSE; + return BoolToPPBool(WebBindings::hasProperty(NULL, + accessor.object()->np_object(), + accessor.identifier())); +} + +bool HasPropertyDeprecated(PP_Var var, + PP_Var name, + PP_Var* exception) { + return PPBoolToBool(HasProperty(var, name, exception)); } bool HasMethodDeprecated(PP_Var var, @@ -418,15 +430,17 @@ void SetPropertyDeprecated(PP_Var var, accessor.SetException(kUnableToSetPropertyException); } -bool DeleteProperty(PP_Var var, - PP_Var name, - PP_Var* exception) { +PP_Bool DeleteProperty(PP_Var var, + PP_Var name, + PP_Var* exception) { ObjectAccessorWithIdentifierTryCatch accessor(var, name, exception); if (accessor.has_exception()) - return false; + return PP_FALSE; - return WebBindings::removeProperty(NULL, accessor.object()->np_object(), - accessor.identifier()); + return BoolToPPBool( + WebBindings::removeProperty(NULL, + accessor.object()->np_object(), + accessor.identifier())); } void DeletePropertyDeprecated(PP_Var var, @@ -441,10 +455,12 @@ void DeletePropertyDeprecated(PP_Var var, accessor.SetException(kUnableToRemovePropertyException); } -bool IsCallable(struct PP_Var object) { +PP_Bool IsCallable(struct PP_Var object) { PP_Var result = RunJSFunction(object, "(function() { return typeof(this) == 'function' })", NULL, 0, NULL); - return result.type == PP_VARTYPE_BOOL && result.value.as_bool; + if (result.type == PP_VARTYPE_BOOL) + return result.value.as_bool; + return PP_FALSE; } struct PP_Var Call(struct PP_Var object, @@ -597,7 +613,7 @@ const PPB_Var_Deprecated var_deprecated_interface = { &Var::PluginReleasePPVar, &VarFromUtf8, &VarToUtf8, - &HasProperty, + &HasPropertyDeprecated, &HasMethodDeprecated, &GetProperty, &EnumerateProperties, @@ -644,7 +660,7 @@ PP_Var Var::NPVariantToPPVar(PluginModule* module, const NPVariant* variant) { case NPVariantType_Null: return PP_MakeNull(); case NPVariantType_Bool: - return PP_MakeBool(NPVARIANT_TO_BOOLEAN(*variant)); + return BoolToPPVar(NPVARIANT_TO_BOOLEAN(*variant)); case NPVariantType_Int32: return PP_MakeInt32(NPVARIANT_TO_INT32(*variant)); case NPVariantType_Double: diff --git a/webkit/glue/plugins/pepper_video_decoder.cc b/webkit/glue/plugins/pepper_video_decoder.cc index b0c1135..cd4d3b5 100644 --- a/webkit/glue/plugins/pepper_video_decoder.cc +++ b/webkit/glue/plugins/pepper_video_decoder.cc @@ -9,6 +9,7 @@ #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" @@ -17,7 +18,7 @@ namespace pepper { namespace { -bool GetConfig(PP_Instance instance_id, +PP_Bool GetConfig(PP_Instance instance_id, PP_VideoCodecId_Dev codec, PP_VideoConfig_Dev* configs, int32_t config_size, @@ -25,7 +26,7 @@ bool GetConfig(PP_Instance instance_id, PluginInstance* instance = ResourceTracker::Get()->GetInstance(instance_id); *num_config = 0; if (!instance) - return false; + return PP_FALSE; // Get configs based on codec. @@ -35,7 +36,7 @@ bool GetConfig(PP_Instance instance_id, // Update *num_config. - return true; + return PP_TRUE; } PP_Resource Create(PP_Instance instance_id, @@ -52,15 +53,15 @@ PP_Resource Create(PP_Instance instance_id, return decoder->GetReference(); } -bool Decode(PP_Resource decoder_id, +PP_Bool Decode(PP_Resource decoder_id, PP_VideoCompressedDataBuffer_Dev* input_buffer) { scoped_refptr<VideoDecoder> decoder( Resource::GetAs<VideoDecoder>(decoder_id)); if (!decoder) - return false; + return PP_FALSE; decoder->Decode(*input_buffer); - return true; + return PP_TRUE; } int32_t Flush(PP_Resource decoder_id, PP_CompletionCallback callback) { @@ -72,14 +73,14 @@ int32_t Flush(PP_Resource decoder_id, PP_CompletionCallback callback) { return decoder->Flush(callback); } -bool ReturnUncompressedDataBuffer(PP_Resource decoder_id, +PP_Bool ReturnUncompressedDataBuffer(PP_Resource decoder_id, PP_VideoUncompressedDataBuffer_Dev* buffer) { scoped_refptr<VideoDecoder> decoder( Resource::GetAs<VideoDecoder>(decoder_id)); if (!decoder) - return false; + return PP_FALSE; - return decoder->ReturnUncompressedDataBuffer(*buffer); + return BoolToPPBool(decoder->ReturnUncompressedDataBuffer(*buffer)); } const PPB_VideoDecoder_Dev ppb_videodecoder = { diff --git a/webkit/glue/plugins/pepper_widget.cc b/webkit/glue/plugins/pepper_widget.cc index 2418220..e704e8c 100644 --- a/webkit/glue/plugins/pepper_widget.cc +++ b/webkit/glue/plugins/pepper_widget.cc @@ -9,6 +9,7 @@ #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" @@ -17,30 +18,30 @@ namespace pepper { namespace { -bool IsWidget(PP_Resource resource) { - return !!Resource::GetAs<Widget>(resource); +PP_Bool IsWidget(PP_Resource resource) { + return BoolToPPBool(!!Resource::GetAs<Widget>(resource)); } -bool Paint(PP_Resource resource, const PP_Rect* rect, PP_Resource image_id) { +PP_Bool Paint(PP_Resource resource, const PP_Rect* rect, PP_Resource image_id) { scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); if (!widget) - return false; + return PP_FALSE; scoped_refptr<ImageData> image(Resource::GetAs<ImageData>(image_id)); if (!image) - return false; + return PP_FALSE; - return widget->Paint(rect, image); + return BoolToPPBool(widget->Paint(rect, image)); } -bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) { +PP_Bool HandleEvent(PP_Resource resource, const PP_InputEvent* event) { scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); - return widget && widget->HandleEvent(event); + return BoolToPPBool(widget && widget->HandleEvent(event)); } -bool GetLocation(PP_Resource resource, PP_Rect* location) { +PP_Bool GetLocation(PP_Resource resource, PP_Rect* location) { scoped_refptr<Widget> widget(Resource::GetAs<Widget>(resource)); - return widget && widget->GetLocation(location); + return BoolToPPBool(widget && widget->GetLocation(location)); } void SetLocation(PP_Resource resource, const PP_Rect* location) { |