summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/chrome_plugin_lib.cc25
-rw-r--r--chrome/common/chrome_plugin_lib.h25
-rw-r--r--chrome/common/chrome_plugin_unittest.cc7
-rw-r--r--chrome/common/ipc_message_utils.h19
-rw-r--r--chrome/common/render_messages_internal.h12
5 files changed, 57 insertions, 31 deletions
diff --git a/chrome/common/chrome_plugin_lib.cc b/chrome/common/chrome_plugin_lib.cc
index 642c623..d9848c9 100644
--- a/chrome/common/chrome_plugin_lib.cc
+++ b/chrome/common/chrome_plugin_lib.cc
@@ -25,7 +25,7 @@ const TCHAR ChromePluginLib::kRegistryChromePlugins[] =
static const TCHAR kRegistryLoadOnStartup[] = _T("LoadOnStartup");
static const TCHAR kRegistryPath[] = _T("Path");
-typedef base::hash_map<std::wstring, scoped_refptr<ChromePluginLib> >
+typedef base::hash_map<FilePath, scoped_refptr<ChromePluginLib> >
PluginMap;
// A map of all the instantiated plugins.
@@ -43,7 +43,7 @@ static bool IsSingleProcessMode() {
}
// static
-ChromePluginLib* ChromePluginLib::Create(const std::wstring& filename,
+ChromePluginLib* ChromePluginLib::Create(const FilePath& filename,
const CPBrowserFuncs* bfuncs) {
// Keep a map of loaded plugins to ensure we only load each library once.
if (!g_loaded_libs) {
@@ -53,8 +53,13 @@ ChromePluginLib* ChromePluginLib::Create(const std::wstring& filename,
}
DCHECK(IsPluginThread());
- // Lower case to match how PluginList::LoadPlugin stores the path.
- std::wstring filename_lc = StringToLowerASCII(filename);
+#if defined(OS_WIN)
+ // Lower case to match how PluginLib::CreatePluginLib stores the path. See
+ // there for the rationale behind this.
+ FilePath filename_lc(StringToLowerASCII(filename.value()));
+#else
+ FilePath filename_lc = filename;
+#endif // OS_WIN
PluginMap::const_iterator iter = g_loaded_libs->find(filename_lc);
if (iter != g_loaded_libs->end())
@@ -69,7 +74,7 @@ ChromePluginLib* ChromePluginLib::Create(const std::wstring& filename,
}
// static
-ChromePluginLib* ChromePluginLib::Find(const std::wstring& filename) {
+ChromePluginLib* ChromePluginLib::Find(const FilePath& filename) {
if (g_loaded_libs) {
PluginMap::const_iterator iter = g_loaded_libs->find(filename);
if (iter != g_loaded_libs->end())
@@ -79,7 +84,7 @@ ChromePluginLib* ChromePluginLib::Find(const std::wstring& filename) {
}
// static
-void ChromePluginLib::Destroy(const std::wstring& filename) {
+void ChromePluginLib::Destroy(const FilePath& filename) {
DCHECK(g_loaded_libs);
PluginMap::iterator iter = g_loaded_libs->find(filename);
if (iter != g_loaded_libs->end()) {
@@ -104,7 +109,7 @@ void ChromePluginLib::RegisterPluginsWithNPAPI() {
if (IsSingleProcessMode())
return;
- std::wstring path;
+ FilePath path;
if (!PathService::Get(chrome::FILE_GEARS_PLUGIN, &path))
return;
// Note: we can only access the NPAPI list because the PluginService has done
@@ -127,7 +132,7 @@ void ChromePluginLib::LoadChromePlugins(const CPBrowserFuncs* bfuncs) {
if (IsSingleProcessMode())
return;
- std::wstring path;
+ FilePath path;
if (!PathService::Get(chrome::FILE_GEARS_PLUGIN, &path))
return;
@@ -177,7 +182,7 @@ const CPPluginFuncs& ChromePluginLib::functions() const {
return plugin_funcs_;
}
-ChromePluginLib::ChromePluginLib(const std::wstring& filename)
+ChromePluginLib::ChromePluginLib(const FilePath& filename)
: filename_(filename),
module_(0),
initialized_(false),
@@ -229,7 +234,7 @@ int ChromePluginLib::CP_Test(void* param) {
bool ChromePluginLib::Load() {
DCHECK(module_ == 0);
- module_ = LoadLibrary(filename_.c_str());
+ module_ = LoadLibrary(filename_.value().c_str());
if (module_ == 0)
return false;
diff --git a/chrome/common/chrome_plugin_lib.h b/chrome/common/chrome_plugin_lib.h
index f58b9c8..eb2e95f 100644
--- a/chrome/common/chrome_plugin_lib.h
+++ b/chrome/common/chrome_plugin_lib.h
@@ -8,6 +8,7 @@
#include <string>
#include "base/basictypes.h"
+#include "base/file_path.h"
#include "base/ref_counted.h"
#include "base/scoped_ptr.h"
#include "chrome/common/chrome_plugin_api.h"
@@ -20,10 +21,10 @@ class MessageLoop;
// issues a NOTIFY_CHROME_PLUGIN_UNLOADED notification.
class ChromePluginLib : public base::RefCounted<ChromePluginLib> {
public:
- static ChromePluginLib* Create(const std::wstring& filename,
+ static ChromePluginLib* Create(const FilePath& filename,
const CPBrowserFuncs* bfuncs);
- static ChromePluginLib* Find(const std::wstring& filename);
- static void Destroy(const std::wstring& filename);
+ static ChromePluginLib* Find(const FilePath& filename);
+ static void Destroy(const FilePath& filename);
static bool IsPluginThread();
static MessageLoop* GetPluginThreadLoop();
@@ -49,7 +50,7 @@ class ChromePluginLib : public base::RefCounted<ChromePluginLib> {
CPID cpid() { return reinterpret_cast<CPID>(this); }
- const std::wstring& filename() { return filename_; }
+ const FilePath& filename() { return filename_; }
// Plugin API functions
@@ -62,7 +63,7 @@ class ChromePluginLib : public base::RefCounted<ChromePluginLib> {
private:
friend class base::RefCounted<ChromePluginLib>;
- ChromePluginLib(const std::wstring& filename);
+ ChromePluginLib(const FilePath& filename);
~ChromePluginLib();
// Method to initialize a Plugin.
@@ -79,20 +80,20 @@ class ChromePluginLib : public base::RefCounted<ChromePluginLib> {
// Unloading the plugin DLL.
void Unload();
- std::wstring filename_; // the path to the DLL
- HMODULE module_; // the opened DLL handle
- bool initialized_; // is the plugin initialized
+ FilePath filename_; // the path to the DLL
+ HMODULE module_; // the opened DLL handle
+ bool initialized_; // is the plugin initialized
// DLL exports, looked up by name.
- CP_VersionNegotiateFunc CP_VersionNegotiate_;
- CP_InitializeFunc CP_Initialize_;
+ CP_VersionNegotiateFunc CP_VersionNegotiate_;
+ CP_InitializeFunc CP_Initialize_;
// Additional function pointers provided by the plugin.
- CPPluginFuncs plugin_funcs_;
+ CPPluginFuncs plugin_funcs_;
// Used for unit tests.
typedef int (STDCALL *CP_TestFunc)(void*);
- CP_TestFunc CP_Test_;
+ CP_TestFunc CP_Test_;
DISALLOW_COPY_AND_ASSIGN(ChromePluginLib);
};
diff --git a/chrome/common/chrome_plugin_unittest.cc b/chrome/common/chrome_plugin_unittest.cc
index 1465f1a..09ae2f4 100644
--- a/chrome/common/chrome_plugin_unittest.cc
+++ b/chrome/common/chrome_plugin_unittest.cc
@@ -17,7 +17,8 @@
namespace {
const wchar_t kDocRoot[] = L"chrome/test/data";
-const wchar_t kPluginFilename[] = L"test_chrome_plugin.dll";
+const FilePath::CharType kPluginFilename[] =
+ FILE_PATH_LITERAL("test_chrome_plugin.dll");
class ChromePluginTest : public testing::Test, public URLRequest::Delegate {
public:
@@ -117,9 +118,9 @@ static void STDCALL CPT_InvokeLater(TestFuncParams::CallbackFunc callback,
}
void ChromePluginTest::LoadPlugin() {
- std::wstring path;
+ FilePath path;
PathService::Get(base::DIR_EXE, &path);
- file_util::AppendToPath(&path, kPluginFilename);
+ path = path.Append(kPluginFilename);
plugin_ = ChromePluginLib::Create(path, GetCPBrowserFuncsForBrowser());
// Exchange test APIs with the plugin.
diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h
index 476d7f9..39bb231 100644
--- a/chrome/common/ipc_message_utils.h
+++ b/chrome/common/ipc_message_utils.h
@@ -9,6 +9,7 @@
#include <vector>
#include <map>
+#include "base/file_path.h"
#include "base/string_util.h"
#include "base/tuple.h"
#include "chrome/common/ipc_sync_message.h"
@@ -604,6 +605,24 @@ struct ParamTraits<POINT> {
#endif // defined(OS_WIN)
template <>
+struct ParamTraits<FilePath> {
+ typedef FilePath param_type;
+ static void Write(Message* m, const param_type& p) {
+ ParamTraits<FilePath::StringType>::Write(m, p.value());
+ }
+ static bool Read(const Message* m, void** iter, param_type* r) {
+ FilePath::StringType value;
+ if (!ParamTraits<FilePath::StringType>::Read(m, iter, &value))
+ return false;
+ *r = FilePath(value);
+ return true;
+ }
+ static void Log(const param_type& p, std::wstring* l) {
+ ParamTraits<FilePath::StringType>::Log(p.value(), l);
+ }
+};
+
+template <>
struct ParamTraits<gfx::Point> {
typedef gfx::Point param_type;
static void Write(Message* m, const param_type& p);
diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h
index 64a76b2..e2b7c26 100644
--- a/chrome/common/render_messages_internal.h
+++ b/chrome/common/render_messages_internal.h
@@ -55,7 +55,7 @@ IPC_BEGIN_MESSAGES(View, 1)
// Allows a chrome plugin loaded in the browser process to send arbitrary
// data to an instance of the same plugin loaded in a renderer process.
IPC_MESSAGE_CONTROL2(ViewMsg_PluginMessage,
- std::wstring /* dll_path of plugin */,
+ FilePath /* plugin_path of plugin */,
std::vector<uint8> /* opaque data */)
#if defined(OS_WIN)
@@ -703,7 +703,7 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)
GURL /* url */,
std::string /* mime_type */,
std::string /* clsid */,
- std::wstring /* filename */,
+ FilePath /* filename */,
std::string /* actual mime type for url */)
// Retrieve the data directory associated with the renderer's profile.
@@ -713,13 +713,13 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)
// Allows a chrome plugin loaded in a renderer process to send arbitrary
// data to an instance of the same plugin loaded in the browser process.
IPC_MESSAGE_CONTROL2(ViewHostMsg_PluginMessage,
- std::wstring /* dll_path of plugin */,
+ FilePath /* plugin_path of plugin */,
std::vector<uint8> /* opaque data */)
// Allows a chrome plugin loaded in a renderer process to send arbitrary
// data to an instance of the same plugin loaded in the browser process.
IPC_SYNC_MESSAGE_CONTROL2_1(ViewHostMsg_PluginSyncMessage,
- std::wstring /* dll_path of plugin */,
+ FilePath /* plugin_path of plugin */,
std::vector<uint8> /* opaque data */,
std::vector<uint8> /* opaque data */)
@@ -811,7 +811,7 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)
std::string /* clsid */,
std::wstring /* locale */,
std::wstring /* channel_name */,
- std::wstring /* plugin_path */)
+ FilePath /* plugin_path */)
// Clipboard IPC messages
@@ -991,7 +991,7 @@ IPC_BEGIN_MESSAGES(ViewHost, 2)
// Sent by the renderer process to indicate that a plugin instance has
// crashed.
IPC_MESSAGE_ROUTED1(ViewHostMsg_CrashedPlugin,
- std::wstring /* plugin_path */)
+ FilePath /* plugin_path */)
// Dsiplays a JavaScript out-of-memory message in the infobar.
IPC_MESSAGE_ROUTED0(ViewHostMsg_JSOutOfMemory)