diff --git a/cef.gyp b/cef.gyp index e6654a62e..6c7952933 100644 --- a/cef.gyp +++ b/cef.gyp @@ -520,6 +520,8 @@ 'libcef_dll/cpptoc/v8exception_cpptoc.h', 'libcef_dll/cpptoc/v8value_cpptoc.cc', 'libcef_dll/cpptoc/v8value_cpptoc.h', + 'libcef_dll/cpptoc/web_plugin_info_cpptoc.cc', + 'libcef_dll/cpptoc/web_plugin_info_cpptoc.h', 'libcef_dll/cpptoc/web_urlrequest_cpptoc.cc', 'libcef_dll/cpptoc/web_urlrequest_cpptoc.h', 'libcef_dll/cpptoc/xml_reader_cpptoc.cc', @@ -869,6 +871,7 @@ 'libcef/tracker.h', 'libcef/v8_impl.cc', 'libcef/v8_impl.h', + 'libcef/web_plugin_impl.cc', 'libcef/web_urlrequest_impl.cc', 'libcef/web_urlrequest_impl.h', 'libcef/webview_host.cc', diff --git a/cef_paths.gypi b/cef_paths.gypi index 46b5190e3..56a71b2f9 100644 --- a/cef_paths.gypi +++ b/cef_paths.gypi @@ -227,6 +227,8 @@ 'libcef_dll/ctocpp/v8exception_ctocpp.h', 'libcef_dll/ctocpp/v8value_ctocpp.cc', 'libcef_dll/ctocpp/v8value_ctocpp.h', + 'libcef_dll/ctocpp/web_plugin_info_ctocpp.cc', + 'libcef_dll/ctocpp/web_plugin_info_ctocpp.h', 'libcef_dll/ctocpp/web_urlrequest_ctocpp.cc', 'libcef_dll/ctocpp/web_urlrequest_ctocpp.h', 'libcef_dll/ctocpp/xml_reader_ctocpp.cc', diff --git a/include/cef.h b/include/cef.h index eb361a960..163247c8a 100644 --- a/include/cef.h +++ b/include/cef.h @@ -81,6 +81,7 @@ class CefTask; class CefV8Context; class CefV8Handler; class CefV8Value; +class CefWebPluginInfo; class CefWebURLRequest; class CefWebURLRequestClient; @@ -416,6 +417,27 @@ bool CefDeleteStorage(CefStorageType type, const CefString& origin, /*--cef(optional_param=path)--*/ bool CefSetStoragePath(CefStorageType type, const CefString& path); +/// +// Returns the number of installed web plugins. This method must be called on +// the UI thread. +/// +/*--cef()--*/ +size_t CefGetWebPluginCount(); + +/// +// Returns information for web plugin at the specified zero-based index. This +// method must be called on the UI thread. +/// +/*--cef()--*/ +CefRefPtr CefGetWebPluginInfo(int index); + +/// +// Returns information for web plugin with the specified name. This method must +// be called on the UI thread. +/// +/*--cef(capi_name=cef_get_web_plugin_info_byname)--*/ +CefRefPtr CefGetWebPluginInfo(const CefString& name); + /// // Interface defining the reference count implementation methods. All framework @@ -4047,5 +4069,36 @@ public: }; +/// +// Information about a specific web plugin. +/// +/*--cef(source=library)--*/ +class CefWebPluginInfo : public virtual CefBase +{ +public: + /// + // Returns the plugin name (i.e. Flash). + /// + /*--cef()--*/ + virtual CefString GetName() =0; + + /// + // Returns the plugin file path (DLL/bundle/library). + /// + /*--cef()--*/ + virtual CefString GetPath() =0; + + /// + // Returns the version of the plugin (may be OS-specific). + /// + /*--cef()--*/ + virtual CefString GetVersion() =0; + + /// + // Returns a description of the plugin from the version information. + /// + /*--cef()--*/ + virtual CefString GetDescription() =0; +}; #endif // _CEF_H diff --git a/include/cef_capi.h b/include/cef_capi.h index 8d4c97865..8de8a7028 100644 --- a/include/cef_capi.h +++ b/include/cef_capi.h @@ -350,6 +350,25 @@ CEF_EXPORT int cef_delete_storage(enum cef_storage_type_t type, CEF_EXPORT int cef_set_storage_path(enum cef_storage_type_t type, const cef_string_t* path); +/// +// Returns the number of installed web plugins. This function must be called on +// the UI thread. +/// +CEF_EXPORT size_t cef_get_web_plugin_count(); + +/// +// Returns information for web plugin at the specified zero-based index. This +// function must be called on the UI thread. +/// +CEF_EXPORT struct _cef_web_plugin_info_t* cef_get_web_plugin_info(int index); + +/// +// Returns information for web plugin with the specified name. This function +// must be called on the UI thread. +/// +CEF_EXPORT struct _cef_web_plugin_info_t* cef_get_web_plugin_info_byname( + const cef_string_t* name); + typedef struct _cef_base_t { // Size of the data structure. @@ -3835,6 +3854,45 @@ typedef struct _cef_command_line_t CEF_EXPORT cef_command_line_t* cef_command_line_create(); +/// +// Information about a specific web plugin. +/// +typedef struct _cef_web_plugin_info_t +{ + // Base structure. + cef_base_t base; + + /// + // Returns the plugin name (i.e. Flash). + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_name)( + struct _cef_web_plugin_info_t* self); + + /// + // Returns the plugin file path (DLL/bundle/library). + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_path)( + struct _cef_web_plugin_info_t* self); + + /// + // Returns the version of the plugin (may be OS-specific). + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_version)( + struct _cef_web_plugin_info_t* self); + + /// + // Returns a description of the plugin from the version information. + /// + // The resulting string must be freed by calling cef_string_userfree_free(). + cef_string_userfree_t (CEF_CALLBACK *get_description)( + struct _cef_web_plugin_info_t* self); + +} cef_web_plugin_info_t; + + #ifdef __cplusplus } #endif diff --git a/libcef/web_plugin_impl.cc b/libcef/web_plugin_impl.cc new file mode 100644 index 000000000..9c1c7532f --- /dev/null +++ b/libcef/web_plugin_impl.cc @@ -0,0 +1,105 @@ +// Copyright (c) 2012 The Chromium Embedded Framework 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 "include/cef.h" +#include "libcef/cef_context.h" +#include "libcef/cef_thread.h" + +#include "base/file_path.h" +#include "base/string_util.h" +#include "webkit/plugins/npapi/plugin_list.h" + +namespace { + +class CefWebPluginInfoImpl : public CefWebPluginInfo { + public: + explicit CefWebPluginInfoImpl(const webkit::WebPluginInfo& plugin_info) + : plugin_info_(plugin_info) { + } + + virtual CefString GetName() OVERRIDE { + return plugin_info_.name; + } + + virtual CefString GetPath() OVERRIDE { + return plugin_info_.path.value(); + } + + virtual CefString GetVersion() OVERRIDE { + return plugin_info_.version; + } + + virtual CefString GetDescription() OVERRIDE { + return plugin_info_.desc; + } + + private: + webkit::WebPluginInfo plugin_info_; + + IMPLEMENT_REFCOUNTING(CefWebPluginInfoImpl); +}; + +} // namespace + +size_t CefGetWebPluginCount() { + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return 0; + } + + if (!CefThread::CurrentlyOn(CefThread::UI)) { + NOTREACHED() << "called on invalid thread"; + return 0; + } + + std::vector plugins; + webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); + return plugins.size(); +} + +CefRefPtr CefGetWebPluginInfo(int index) { + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return 0; + } + + if (!CefThread::CurrentlyOn(CefThread::UI)) { + NOTREACHED() << "called on invalid thread"; + return 0; + } + + std::vector plugins; + webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); + + if (index < 0 || index >= static_cast(plugins.size())) + return NULL; + + return new CefWebPluginInfoImpl(plugins[index]); +} + +CefRefPtr CefGetWebPluginInfo(const CefString& name) { + if (!CONTEXT_STATE_VALID()) { + NOTREACHED() << "context not valid"; + return 0; + } + + if (!CefThread::CurrentlyOn(CefThread::UI)) { + NOTREACHED() << "called on invalid thread"; + return 0; + } + + std::vector plugins; + webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins); + + std::string nameStr = name; + StringToLowerASCII(&nameStr); + + std::vector::const_iterator it = plugins.begin(); + for (; it != plugins.end(); ++it) { + if (LowerCaseEqualsASCII(it->name, nameStr.c_str())) + return new CefWebPluginInfoImpl(*it); + } + + return NULL; +} diff --git a/libcef_dll/cpptoc/web_plugin_info_cpptoc.cc b/libcef_dll/cpptoc/web_plugin_info_cpptoc.cc new file mode 100644 index 000000000..e52398e78 --- /dev/null +++ b/libcef_dll/cpptoc/web_plugin_info_cpptoc.cc @@ -0,0 +1,103 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h" + + +// MEMBER FUNCTIONS - Body may be edited by hand. + +cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_name( + struct _cef_web_plugin_info_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetName(); + + // Return type: string + return _retval.DetachToUserFree(); +} + + +cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_path( + struct _cef_web_plugin_info_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetPath(); + + // Return type: string + return _retval.DetachToUserFree(); +} + + +cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_version( + struct _cef_web_plugin_info_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetVersion(); + + // Return type: string + return _retval.DetachToUserFree(); +} + + +cef_string_userfree_t CEF_CALLBACK web_plugin_info_get_description( + struct _cef_web_plugin_info_t* self) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + DCHECK(self); + if (!self) + return NULL; + + // Execute + CefString _retval = CefWebPluginInfoCppToC::Get(self)->GetDescription(); + + // Return type: string + return _retval.DetachToUserFree(); +} + + + +// CONSTRUCTOR - Do not edit by hand. + +CefWebPluginInfoCppToC::CefWebPluginInfoCppToC(CefWebPluginInfo* cls) + : CefCppToC(cls) +{ + struct_.struct_.get_name = web_plugin_info_get_name; + struct_.struct_.get_path = web_plugin_info_get_path; + struct_.struct_.get_version = web_plugin_info_get_version; + struct_.struct_.get_description = web_plugin_info_get_description; +} + +#ifndef NDEBUG +template<> long CefCppToC::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/cpptoc/web_plugin_info_cpptoc.h b/libcef_dll/cpptoc/web_plugin_info_cpptoc.h new file mode 100644 index 000000000..a820a7492 --- /dev/null +++ b/libcef_dll/cpptoc/web_plugin_info_cpptoc.h @@ -0,0 +1,37 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _WEBPLUGININFO_CPPTOC_H +#define _WEBPLUGININFO_CPPTOC_H + +#ifndef BUILDING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed DLL-side only") +#else // BUILDING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/cpptoc/cpptoc.h" + +// Wrap a C++ class with a C structure. +// This class may be instantiated and accessed DLL-side only. +class CefWebPluginInfoCppToC + : public CefCppToC +{ +public: + CefWebPluginInfoCppToC(CefWebPluginInfo* cls); + virtual ~CefWebPluginInfoCppToC() {} +}; + +#endif // BUILDING_CEF_SHARED +#endif // _WEBPLUGININFO_CPPTOC_H + diff --git a/libcef_dll/ctocpp/web_plugin_info_ctocpp.cc b/libcef_dll/ctocpp/web_plugin_info_ctocpp.cc new file mode 100644 index 000000000..655348de3 --- /dev/null +++ b/libcef_dll/ctocpp/web_plugin_info_ctocpp.cc @@ -0,0 +1,91 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h" + + +// VIRTUAL METHODS - Body may be edited by hand. + +CefString CefWebPluginInfoCToCpp::GetName() +{ + if (CEF_MEMBER_MISSING(struct_, get_name)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_name(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefWebPluginInfoCToCpp::GetPath() +{ + if (CEF_MEMBER_MISSING(struct_, get_path)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_path(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefWebPluginInfoCToCpp::GetVersion() +{ + if (CEF_MEMBER_MISSING(struct_, get_version)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_version(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + +CefString CefWebPluginInfoCToCpp::GetDescription() +{ + if (CEF_MEMBER_MISSING(struct_, get_description)) + return CefString(); + + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_string_userfree_t _retval = struct_->get_description(struct_); + + // Return type: string + CefString _retvalStr; + _retvalStr.AttachToUserFree(_retval); + return _retvalStr; +} + + + +#ifndef NDEBUG +template<> long CefCToCpp::DebugObjCt = 0; +#endif + diff --git a/libcef_dll/ctocpp/web_plugin_info_ctocpp.h b/libcef_dll/ctocpp/web_plugin_info_ctocpp.h new file mode 100644 index 000000000..3a1639da3 --- /dev/null +++ b/libcef_dll/ctocpp/web_plugin_info_ctocpp.h @@ -0,0 +1,45 @@ +// Copyright (c) 2012 The Chromium Embedded Framework Authors. All rights +// reserved. Use of this source code is governed by a BSD-style license that +// can be found in the LICENSE file. +// +// --------------------------------------------------------------------------- +// +// This file was generated by the CEF translator tool. If making changes by +// hand only do so within the body of existing method and function +// implementations. See the translator.README.txt file in the tools directory +// for more information. +// + +#ifndef _WEBPLUGININFO_CTOCPP_H +#define _WEBPLUGININFO_CTOCPP_H + +#ifndef USING_CEF_SHARED +#pragma message("Warning: "__FILE__" may be accessed wrapper-side only") +#else // USING_CEF_SHARED + +#include "include/cef.h" +#include "include/cef_capi.h" +#include "libcef_dll/ctocpp/ctocpp.h" + +// Wrap a C structure with a C++ class. +// This class may be instantiated and accessed wrapper-side only. +class CefWebPluginInfoCToCpp + : public CefCToCpp +{ +public: + CefWebPluginInfoCToCpp(cef_web_plugin_info_t* str) + : CefCToCpp(str) {} + virtual ~CefWebPluginInfoCToCpp() {} + + // CefWebPluginInfo methods + virtual CefString GetName() OVERRIDE; + virtual CefString GetPath() OVERRIDE; + virtual CefString GetVersion() OVERRIDE; + virtual CefString GetDescription() OVERRIDE; +}; + +#endif // USING_CEF_SHARED +#endif // _WEBPLUGININFO_CTOCPP_H + diff --git a/libcef_dll/libcef_dll.cc b/libcef_dll/libcef_dll.cc index f0bcdaf3e..522c38122 100644 --- a/libcef_dll/libcef_dll.cc +++ b/libcef_dll/libcef_dll.cc @@ -27,6 +27,7 @@ #include "libcef_dll/cpptoc/v8context_cpptoc.h" #include "libcef_dll/cpptoc/v8exception_cpptoc.h" #include "libcef_dll/cpptoc/v8value_cpptoc.h" +#include "libcef_dll/cpptoc/web_plugin_info_cpptoc.h" #include "libcef_dll/cpptoc/web_urlrequest_cpptoc.h" #include "libcef_dll/cpptoc/xml_reader_cpptoc.h" #include "libcef_dll/cpptoc/zip_reader_cpptoc.h" @@ -143,6 +144,7 @@ CEF_EXPORT void cef_shutdown() DCHECK(CefV8ExceptionCppToC::DebugObjCt == 0); DCHECK(CefV8HandlerCToCpp::DebugObjCt == 0); DCHECK(CefV8ValueCppToC::DebugObjCt == 0); + DCHECK(CefWebPluginInfoCppToC::DebugObjCt == 0); DCHECK(CefWebURLRequestClientCToCpp::DebugObjCt == 0); DCHECK(CefWebURLRequestCppToC::DebugObjCt == 0); DCHECK(CefWriteHandlerCToCpp::DebugObjCt == 0); @@ -543,3 +545,47 @@ CEF_EXPORT int cef_set_storage_path(enum cef_storage_type_t type, } +CEF_EXPORT size_t cef_get_web_plugin_count() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = CefGetWebPluginCount(); + + // Return type: simple + return _retval; +} + + +CEF_EXPORT struct _cef_web_plugin_info_t* cef_get_web_plugin_info(int index) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + CefRefPtr _retval = CefGetWebPluginInfo( + index); + + // Return type: refptr_same + return CefWebPluginInfoCppToC::Wrap(_retval); +} + + +CEF_EXPORT struct _cef_web_plugin_info_t* cef_get_web_plugin_info_byname( + const cef_string_t* name) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(name); + if (!name) + return NULL; + + // Execute + CefRefPtr _retval = CefGetWebPluginInfo( + CefString(name)); + + // Return type: refptr_same + return CefWebPluginInfoCppToC::Wrap(_retval); +} + + diff --git a/libcef_dll/wrapper/libcef_dll_wrapper.cc b/libcef_dll/wrapper/libcef_dll_wrapper.cc index f2a99aa94..536043b1d 100644 --- a/libcef_dll/wrapper/libcef_dll_wrapper.cc +++ b/libcef_dll/wrapper/libcef_dll_wrapper.cc @@ -58,6 +58,7 @@ #include "libcef_dll/ctocpp/v8context_ctocpp.h" #include "libcef_dll/ctocpp/v8exception_ctocpp.h" #include "libcef_dll/ctocpp/v8value_ctocpp.h" +#include "libcef_dll/ctocpp/web_plugin_info_ctocpp.h" #include "libcef_dll/ctocpp/web_urlrequest_ctocpp.h" #include "libcef_dll/ctocpp/xml_reader_ctocpp.h" #include "libcef_dll/ctocpp/zip_reader_ctocpp.h" @@ -145,6 +146,7 @@ CEF_GLOBAL void CefShutdown() DCHECK(CefV8ExceptionCToCpp::DebugObjCt == 0); DCHECK(CefV8HandlerCppToC::DebugObjCt == 0); DCHECK(CefV8ValueCToCpp::DebugObjCt == 0); + DCHECK(CefWebPluginInfoCToCpp::DebugObjCt == 0); DCHECK(CefWebURLRequestCToCpp::DebugObjCt == 0); DCHECK(CefWebURLRequestClientCppToC::DebugObjCt == 0); DCHECK(CefWriteHandlerCppToC::DebugObjCt == 0); @@ -510,3 +512,47 @@ CEF_GLOBAL bool CefSetStoragePath(CefStorageType type, const CefString& path) } +CEF_GLOBAL size_t CefGetWebPluginCount() +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + size_t _retval = cef_get_web_plugin_count(); + + // Return type: simple + return _retval; +} + + +CEF_GLOBAL CefRefPtr CefGetWebPluginInfo(int index) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Execute + cef_web_plugin_info_t* _retval = cef_get_web_plugin_info( + index); + + // Return type: refptr_same + return CefWebPluginInfoCToCpp::Wrap(_retval); +} + + +CEF_GLOBAL CefRefPtr CefGetWebPluginInfo( + const CefString& name) +{ + // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING + + // Verify param: name; type: string_byref_const + DCHECK(!name.empty()); + if (name.empty()) + return NULL; + + // Execute + cef_web_plugin_info_t* _retval = cef_get_web_plugin_info_byname( + name.GetStruct()); + + // Return type: refptr_same + return CefWebPluginInfoCToCpp::Wrap(_retval); +} + + diff --git a/tests/cefclient/cefclient.cpp b/tests/cefclient/cefclient.cpp index 81fb8ce2b..2ac06624c 100644 --- a/tests/cefclient/cefclient.cpp +++ b/tests/cefclient/cefclient.cpp @@ -63,6 +63,46 @@ void UIT_InvokeScript(CefRefPtr browser) } } +void UIT_RunPluginInfoTest(CefRefPtr browser) { + std::string html = "Plugin Info Test"; + + // Find the flash plugin first to test that get by name works. + std::string flash_name; + CefRefPtr info = CefGetWebPluginInfo("Shockwave Flash"); + if (info.get()) { + flash_name = info->GetName(); + html += "\nFlash is installed!" + "
Name: " + flash_name + + "\n
Description: " + info->GetDescription().ToString() + + "\n
Version: " + info->GetVersion().ToString() + + "\n
Path: " + info->GetPath().ToString(); + } + + if (!flash_name.empty()) { + html += "\n

Other installed plugins:"; + } else { + html += "\nInstalled plugins:"; + } + + // Display all other plugins. + size_t count = CefGetWebPluginCount(); + for (size_t i = 0; i < count; ++i) { + CefRefPtr info = CefGetWebPluginInfo(i); + ASSERT(info.get()); + if (!flash_name.empty() && info->GetName() == flash_name) + continue; + + html += "\n

Name: " + info->GetName().ToString() + + "\n
Description: " + info->GetDescription().ToString() + + "\n
Version: " + info->GetVersion().ToString() + + "\n
Path: " + info->GetPath().ToString(); + } + + html += ""; + + browser->GetMainFrame()->LoadString(html, "http://tests/plugin_info"); +} + // Return the int representation of the specified string. int GetIntValue(const CefString& str) { @@ -628,3 +668,13 @@ void RunModalDialogTest(CefRefPtr browser) { browser->GetMainFrame()->LoadURL("http://tests/modalmain"); } + +void RunPluginInfoTest(CefRefPtr browser) { + if (CefCurrentlyOn(TID_UI)) { + UIT_RunPluginInfoTest(browser); + } else { + // Execute on the UI thread. + CefPostTask(TID_UI, + NewCefRunnableFunction(&UIT_RunPluginInfoTest, browser)); + } +} diff --git a/tests/cefclient/cefclient.h b/tests/cefclient/cefclient.h index ad768d30d..ddf6c1c4e 100644 --- a/tests/cefclient/cefclient.h +++ b/tests/cefclient/cefclient.h @@ -45,6 +45,7 @@ void RunWebURLRequestTest(CefRefPtr browser); void RunDOMAccessTest(CefRefPtr browser); void RunDragDropTest(CefRefPtr browser); void RunModalDialogTest(CefRefPtr browser); +void RunPluginInfoTest(CefRefPtr browser); #if defined(OS_WIN) void RunTransparentPopupTest(CefRefPtr browser); diff --git a/tests/cefclient/cefclient.rc b/tests/cefclient/cefclient.rc index a058a5686..277ca44b7 100644 --- a/tests/cefclient/cefclient.rc +++ b/tests/cefclient/cefclient.rc @@ -79,6 +79,7 @@ BEGIN MENUITEM "JavaScript Execute", ID_TESTS_JAVASCRIPT_EXECUTE MENUITEM "JavaScript Invoke", ID_TESTS_JAVASCRIPT_INVOKE MENUITEM "Plugin", ID_TESTS_PLUGIN + MENUITEM "Plugin Info", ID_TESTS_PLUGIN_INFO MENUITEM "Popup Window", ID_TESTS_POPUP MENUITEM "Transparent Popup Window", ID_TESTS_TRANSPARENT_POPUP MENUITEM "Request", ID_TESTS_REQUEST diff --git a/tests/cefclient/cefclient_gtk.cpp b/tests/cefclient/cefclient_gtk.cpp index e62d3d217..e84a440da 100644 --- a/tests/cefclient/cefclient_gtk.cpp +++ b/tests/cefclient/cefclient_gtk.cpp @@ -204,6 +204,14 @@ gboolean ShowDevtoolsActivated(GtkWidget* widget) { return FALSE; // Don't stop this message. } +// Callback for Debug > Plugin Info... menu item. +gboolean PluginInfoActivated(GtkWidget* widget) { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunPluginInfoTest(g_handler->GetBrowser()); + + return FALSE; // Don't stop this message. +} + // Callback for when you click the back button. void BackButtonClicked(GtkButton* button) { if (g_handler.get() && g_handler->GetBrowserHwnd()) @@ -299,6 +307,8 @@ GtkWidget* CreateMenuBar() { G_CALLBACK(DragDropActivated)); AddMenuEntry(debug_menu, "Show DevTools", G_CALLBACK(ShowDevtoolsActivated)); + AddMenuEntry(debug_menu, "Plugin Info", + G_CALLBACK(PluginInfoActivated)); return menu_bar; } diff --git a/tests/cefclient/cefclient_mac.mm b/tests/cefclient/cefclient_mac.mm index 3e07303b3..c404de0c3 100644 --- a/tests/cefclient/cefclient_mac.mm +++ b/tests/cefclient/cefclient_mac.mm @@ -208,6 +208,7 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { - (IBAction)testZoomReset:(id)sender; - (IBAction)testDevToolsShow:(id)sender; - (IBAction)testDevToolsClose:(id)sender; +- (IBAction)testPluginInfo:(id)sender; @end @implementation ClientAppDelegate @@ -298,6 +299,9 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { [testMenu addItemWithTitle:@"Close DevTools" action:@selector(testDevToolsClose:) keyEquivalent:@""]; + [testMenu addItemWithTitle:@"Plugin Info" + action:@selector(testPluginInfo:) + keyEquivalent:@""]; [testItem setSubmenu:testMenu]; [menubar addItem:testItem]; @@ -519,6 +523,11 @@ NSButton* MakeButton(NSRect* rect, NSString* title, NSView* parent) { } } +- (IBAction)testPluginInfo:(id)sender { + if(g_handler.get() && g_handler->GetBrowserHwnd()) + RunPluginInfoTest(g_handler->GetBrowser()); +} + // Sent by the default notification center immediately before the application // terminates. - (void)applicationWillTerminate:(NSNotification *)aNotification { diff --git a/tests/cefclient/cefclient_win.cpp b/tests/cefclient/cefclient_win.cpp index c5fcc6e38..f55f6a258 100644 --- a/tests/cefclient/cefclient_win.cpp +++ b/tests/cefclient/cefclient_win.cpp @@ -484,6 +484,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) if(browser.get()) RunPluginTest(browser); return 0; + case ID_TESTS_PLUGIN_INFO: // Test plugin info + if(browser.get()) + RunPluginInfoTest(browser); + return 0; case ID_TESTS_POPUP: // Test a popup window if(browser.get()) RunPopupTest(browser); diff --git a/tests/cefclient/resource.h b/tests/cefclient/resource.h index 7ca2da3bd..725f12b88 100644 --- a/tests/cefclient/resource.h +++ b/tests/cefclient/resource.h @@ -57,6 +57,7 @@ #define ID_TESTS_TRANSPARENT_OSRAPP 32797 #define ID_TESTS_JAVASCRIPT_INVOKE 32798 #define ID_TESTS_GETIMAGE 32799 +#define ID_TESTS_PLUGIN_INFO 32800 #define IDC_STATIC -1 #define IDS_LOGO 1000 #define IDS_UIPLUGIN 1001