mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
Break cef.h into multiple headers (issue #142).
- Move wrapper classes from cef_wrapper.h to wrapper/ directory. - Move C API functions/classes from cef_capi.h to capi/ directory. - Move global function implementations from cef_context.cc to *_impl.cc files. - Output auto-generated file paths in cef_paths.gypi. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@442 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
80
libcef/nplugin_impl.cc
Normal file
80
libcef/nplugin_impl.cc
Normal file
@ -0,0 +1,80 @@
|
||||
// Copyright (c) 2011 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_nplugin.h"
|
||||
#include "cef_context.h"
|
||||
#include "cef_thread.h"
|
||||
|
||||
#include "base/string_split.h"
|
||||
#include "base/utf_string_conversions.h"
|
||||
#include "webkit/plugins/npapi/plugin_list.h"
|
||||
|
||||
namespace {
|
||||
|
||||
void UIT_RegisterPlugin(CefPluginInfo* plugin_info)
|
||||
{
|
||||
REQUIRE_UIT();
|
||||
|
||||
webkit::WebPluginInfo info;
|
||||
|
||||
info.path = FilePath(CefString(&plugin_info->unique_name));
|
||||
info.name = CefString(&plugin_info->display_name);
|
||||
info.version = CefString(&plugin_info->version);
|
||||
info.desc = CefString(&plugin_info->description);
|
||||
|
||||
typedef std::vector<std::string> VectorType;
|
||||
VectorType mime_types, file_extensions, descriptions, file_extensions_parts;
|
||||
base::SplitString(CefString(&plugin_info->mime_types), '|', &mime_types);
|
||||
base::SplitString(CefString(&plugin_info->file_extensions), '|',
|
||||
&file_extensions);
|
||||
base::SplitString(CefString(&plugin_info->type_descriptions), '|',
|
||||
&descriptions);
|
||||
|
||||
for (size_t i = 0; i < mime_types.size(); ++i) {
|
||||
webkit::WebPluginMimeType mimeType;
|
||||
|
||||
mimeType.mime_type = mime_types[i];
|
||||
|
||||
if (file_extensions.size() > i) {
|
||||
base::SplitString(file_extensions[i], ',', &file_extensions_parts);
|
||||
VectorType::const_iterator it = file_extensions_parts.begin();
|
||||
for(; it != file_extensions_parts.end(); ++it)
|
||||
mimeType.file_extensions.push_back(*(it));
|
||||
file_extensions_parts.clear();
|
||||
}
|
||||
|
||||
if (descriptions.size() > i)
|
||||
mimeType.description = UTF8ToUTF16(descriptions[i]);
|
||||
|
||||
info.mime_types.push_back(mimeType);
|
||||
}
|
||||
|
||||
webkit::npapi::PluginEntryPoints entry_points;
|
||||
#if !defined(OS_POSIX) || defined(OS_MACOSX)
|
||||
entry_points.np_getentrypoints = plugin_info->np_getentrypoints;
|
||||
#endif
|
||||
entry_points.np_initialize = plugin_info->np_initialize;
|
||||
entry_points.np_shutdown = plugin_info->np_shutdown;
|
||||
|
||||
webkit::npapi::PluginList::Singleton()->RegisterInternalPlugin(
|
||||
info, entry_points, true);
|
||||
|
||||
delete plugin_info;
|
||||
}
|
||||
|
||||
} // anonymous
|
||||
|
||||
bool CefRegisterPlugin(const CefPluginInfo& plugin_info)
|
||||
{
|
||||
// Verify that the context is in a valid state.
|
||||
if (!CONTEXT_STATE_VALID()) {
|
||||
NOTREACHED() << "context not valid";
|
||||
return false;
|
||||
}
|
||||
|
||||
CefThread::PostTask(CefThread::UI, FROM_HERE,
|
||||
NewRunnableFunction(UIT_RegisterPlugin, new CefPluginInfo(plugin_info)));
|
||||
|
||||
return true;
|
||||
}
|
Reference in New Issue
Block a user