Add ability to directly retrieve plugin information (issue #575).

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@600 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-04-20 20:40:53 +00:00
parent ecec216eb9
commit 97561ac51a
18 changed files with 739 additions and 0 deletions

View File

@ -769,6 +769,7 @@
'libcef/url_impl.cc',
'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',

View File

@ -47,6 +47,7 @@
'include/cef_url.h',
'include/cef_v8.h',
'include/cef_v8context_handler.h',
'include/cef_web_plugin.h',
'include/cef_web_urlrequest.h',
'include/cef_xml_reader.h',
'include/cef_zip_reader.h',
@ -87,6 +88,7 @@
'include/capi/cef_url_capi.h',
'include/capi/cef_v8_capi.h',
'include/capi/cef_v8context_handler_capi.h',
'include/capi/cef_web_plugin_capi.h',
'include/capi/cef_web_urlrequest_capi.h',
'include/capi/cef_xml_reader_capi.h',
'include/capi/cef_zip_reader_capi.h',
@ -188,6 +190,8 @@
'libcef_dll/ctocpp/v8handler_ctocpp.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/ctocpp/web_urlrequest_client_ctocpp.cc',
@ -296,6 +300,8 @@
'libcef_dll/cpptoc/v8handler_cpptoc.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/cpptoc/web_urlrequest_client_cpptoc.cc',

View File

@ -0,0 +1,110 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// This file was generated by the CEF translator tool and should not edited
// by hand. See the translator.README.txt file in the tools directory for
// more information.
//
#ifndef CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_
#define CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "include/capi/cef_base_capi.h"
///
// 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);
///
// 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
#endif // CEF_INCLUDE_CAPI_CEF_WEB_PLUGIN_CAPI_H_

View File

@ -0,0 +1,97 @@
// Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the name Chromium Embedded
// Framework nor the names of its contributors may be used to endorse
// or promote products derived from this software without specific prior
// written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// ---------------------------------------------------------------------------
//
// The contents of this file must follow a specific format in order to
// support the CEF translator tool. See the translator.README.txt file in the
// tools directory for more information.
//
#ifndef CEF_INCLUDE_CEF_WEB_PLUGIN_H_
#define CEF_INCLUDE_CEF_WEB_PLUGIN_H_
#include "include/cef_base.h"
class CefWebPluginInfo;
///
// 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<CefWebPluginInfo> 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<CefWebPluginInfo> CefGetWebPluginInfo(const CefString& name);
///
// 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_INCLUDE_CEF_WEB_PLUGIN_H_

View File

@ -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_web_plugin.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<webkit::WebPluginInfo> plugins;
webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
return plugins.size();
}
CefRefPtr<CefWebPluginInfo> 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<webkit::WebPluginInfo> plugins;
webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
if (index < 0 || index >= static_cast<int>(plugins.size()))
return NULL;
return new CefWebPluginInfoImpl(plugins[index]);
}
CefRefPtr<CefWebPluginInfo> 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<webkit::WebPluginInfo> plugins;
webkit::npapi::PluginList::Singleton()->GetPlugins(&plugins);
std::string nameStr = name;
StringToLowerASCII(&nameStr);
std::vector<webkit::WebPluginInfo>::const_iterator it = plugins.begin();
for (; it != plugins.end(); ++it) {
if (LowerCaseEqualsASCII(it->name, nameStr.c_str()))
return new CefWebPluginInfoImpl(*it);
}
return NULL;
}

View File

@ -0,0 +1,94 @@
// 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<CefWebPluginInfoCppToC, CefWebPluginInfo,
cef_web_plugin_info_t>(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<CefWebPluginInfoCppToC, CefWebPluginInfo,
cef_web_plugin_info_t>::DebugObjCt = 0;
#endif

View File

@ -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 CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_
#define CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_
#pragma once
#ifndef BUILDING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
#else // BUILDING_CEF_SHARED
#include "include/cef_web_plugin.h"
#include "include/capi/cef_web_plugin_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<CefWebPluginInfoCppToC, CefWebPluginInfo,
cef_web_plugin_info_t> {
public:
explicit CefWebPluginInfoCppToC(CefWebPluginInfo* cls);
virtual ~CefWebPluginInfoCppToC() {}
};
#endif // BUILDING_CEF_SHARED
#endif // CEF_LIBCEF_DLL_CPPTOC_WEB_PLUGIN_INFO_CPPTOC_H_

View File

@ -0,0 +1,83 @@
// 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<CefWebPluginInfoCToCpp, CefWebPluginInfo,
cef_web_plugin_info_t>::DebugObjCt = 0;
#endif

View File

@ -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 CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_
#define CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_
#pragma once
#ifndef USING_CEF_SHARED
#pragma message("Warning: "__FILE__" may be accessed wrapper-side only")
#else // USING_CEF_SHARED
#include "include/cef_web_plugin.h"
#include "include/capi/cef_web_plugin_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<CefWebPluginInfoCToCpp, CefWebPluginInfo,
cef_web_plugin_info_t> {
public:
explicit CefWebPluginInfoCToCpp(cef_web_plugin_info_t* str)
: CefCToCpp<CefWebPluginInfoCToCpp, CefWebPluginInfo,
cef_web_plugin_info_t>(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 // CEF_LIBCEF_DLL_CTOCPP_WEB_PLUGIN_INFO_CTOCPP_H_

View File

@ -24,6 +24,8 @@
#include "include/capi/cef_url_capi.h"
#include "include/cef_v8.h"
#include "include/capi/cef_v8_capi.h"
#include "include/cef_web_plugin.h"
#include "include/capi/cef_web_plugin_capi.h"
#include "libcef_dll/cpptoc/browser_cpptoc.h"
#include "libcef_dll/cpptoc/cookie_manager_cpptoc.h"
#include "libcef_dll/cpptoc/domdocument_cpptoc.h"
@ -41,6 +43,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"
@ -156,6 +159,7 @@ CEF_EXPORT void cef_shutdown() {
DCHECK_EQ(CefV8ExceptionCppToC::DebugObjCt, 0);
DCHECK_EQ(CefV8HandlerCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefV8ValueCppToC::DebugObjCt, 0);
DCHECK_EQ(CefWebPluginInfoCppToC::DebugObjCt, 0);
DCHECK_EQ(CefWebURLRequestClientCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefWebURLRequestCppToC::DebugObjCt, 0);
DCHECK_EQ(CefWriteHandlerCToCpp::DebugObjCt, 0);
@ -518,3 +522,41 @@ CEF_EXPORT int cef_register_extension(const cef_string_t* extension_name,
return _retval;
}
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<CefWebPluginInfo> _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<CefWebPluginInfo> _retval = CefGetWebPluginInfo(
CefString(name));
// Return type: refptr_same
return CefWebPluginInfoCppToC::Wrap(_retval);
}

View File

@ -24,6 +24,8 @@
#include "include/capi/cef_url_capi.h"
#include "include/cef_v8.h"
#include "include/capi/cef_v8_capi.h"
#include "include/cef_web_plugin.h"
#include "include/capi/cef_web_plugin_capi.h"
#include "include/cef_version.h"
#include "libcef_dll/cpptoc/app_cpptoc.h"
#include "libcef_dll/cpptoc/content_filter_cpptoc.h"
@ -73,6 +75,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"
@ -158,6 +161,7 @@ CEF_GLOBAL void CefShutdown() {
DCHECK_EQ(CefV8ExceptionCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefV8HandlerCppToC::DebugObjCt, 0);
DCHECK_EQ(CefV8ValueCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefWebPluginInfoCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefWebURLRequestCToCpp::DebugObjCt, 0);
DCHECK_EQ(CefWebURLRequestClientCppToC::DebugObjCt, 0);
DCHECK_EQ(CefWriteHandlerCppToC::DebugObjCt, 0);
@ -485,3 +489,41 @@ CEF_GLOBAL bool CefRegisterExtension(const CefString& extension_name,
return _retval?true:false;
}
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<CefWebPluginInfo> 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<CefWebPluginInfo> 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);
}

View File

@ -12,6 +12,7 @@
#include "include/cef_command_line.h"
#include "include/cef_frame.h"
#include "include/cef_runnable.h"
#include "include/cef_web_plugin.h"
#include "include/cef_web_urlrequest.h"
#include "cefclient/cefclient_switches.h"
#include "cefclient/client_handler.h"
@ -65,6 +66,46 @@ void UIT_InvokeScript(CefRefPtr<CefBrowser> browser) {
}
}
void UIT_RunPluginInfoTest(CefRefPtr<CefBrowser> browser) {
std::string html = "<html><head><title>Plugin Info Test</title></head><body>";
// Find the flash plugin first to test that get by name works.
std::string flash_name;
CefRefPtr<CefWebPluginInfo> info = CefGetWebPluginInfo("Shockwave Flash");
if (info.get()) {
flash_name = info->GetName();
html += "\n<b>Flash is installed!</b>"
"<br/>Name: " + flash_name +
"\n<br/>Description: " + info->GetDescription().ToString() +
"\n<br/>Version: " + info->GetVersion().ToString() +
"\n<br/>Path: " + info->GetPath().ToString();
}
if (!flash_name.empty()) {
html += "\n<br/><br/><b>Other installed plugins:</b>";
} else {
html += "\n<b>Installed plugins:</b>";
}
// Display all other plugins.
size_t count = CefGetWebPluginCount();
for (size_t i = 0; i < count; ++i) {
CefRefPtr<CefWebPluginInfo> info = CefGetWebPluginInfo(i);
ASSERT(info.get());
if (!flash_name.empty() && info->GetName() == flash_name)
continue;
html += "\n<br/><br/>Name: " + info->GetName().ToString() +
"\n<br/>Description: " + info->GetDescription().ToString() +
"\n<br/>Version: " + info->GetVersion().ToString() +
"\n<br/>Path: " + info->GetPath().ToString();
}
html += "</body></html>";
browser->GetMainFrame()->LoadString(html, "http://tests/plugin_info");
}
// Return the int representation of the specified string.
int GetIntValue(const CefString& str) {
if (str.empty())
@ -599,3 +640,13 @@ void RunDragDropTest(CefRefPtr<CefBrowser> browser) {
void RunModalDialogTest(CefRefPtr<CefBrowser> browser) {
browser->GetMainFrame()->LoadURL("http://tests/modalmain");
}
void RunPluginInfoTest(CefRefPtr<CefBrowser> browser) {
if (CefCurrentlyOn(TID_UI)) {
UIT_RunPluginInfoTest(browser);
} else {
// Execute on the UI thread.
CefPostTask(TID_UI,
NewCefRunnableFunction(&UIT_RunPluginInfoTest, browser));
}
}

View File

@ -51,6 +51,7 @@ void RunWebURLRequestTest(CefRefPtr<CefBrowser> browser);
void RunDOMAccessTest(CefRefPtr<CefBrowser> browser);
void RunDragDropTest(CefRefPtr<CefBrowser> browser);
void RunModalDialogTest(CefRefPtr<CefBrowser> browser);
void RunPluginInfoTest(CefRefPtr<CefBrowser> browser);
#if defined(OS_WIN)
void RunTransparentPopupTest(CefRefPtr<CefBrowser> browser);

View File

@ -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

View File

@ -206,6 +206,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())
@ -301,6 +309,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;
}

View File

@ -211,6 +211,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
@ -301,6 +302,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];
@ -522,6 +526,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 {

View File

@ -464,6 +464,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam,
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);

View File

@ -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