diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 03:36:36 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-04 03:36:36 +0000 |
commit | 3a2a5d201631f31800a889164cb84b3c6784b8c2 (patch) | |
tree | 52f45c58258845ad6b0a9a9591e15b3cc225337c /chrome | |
parent | 0bb1a6204af17f50ad0577f811a2c044b2bf62ff (diff) | |
download | chromium_src-3a2a5d201631f31800a889164cb84b3c6784b8c2.zip chromium_src-3a2a5d201631f31800a889164cb84b3c6784b8c2.tar.gz chromium_src-3a2a5d201631f31800a889164cb84b3c6784b8c2.tar.bz2 |
Update clipboard classes to use string16 and FilePath instead of wstring.
Update callers as well.
This patch builds on a patch by mark.a.lindner@gmail.com which can be found at http://codereview.chromium.org/28294
Review URL: http://codereview.chromium.org/27370
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10860 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
9 files changed, 22 insertions, 31 deletions
diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index fd80886..4933945 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -113,14 +113,14 @@ void BaseContextMenu::ExecuteCommand(int id) { download_->manager()->ShowDownloadInShell(download_); break; case COPY_LINK: - scw.WriteText(UTF8ToWide(download_->url().spec())); + scw.WriteText(UTF8ToUTF16(download_->url().spec())); break; case COPY_PATH: - scw.WriteText(download_->full_path().ToWStringHack()); + scw.WriteText(WideToUTF16(download_->full_path().ToWStringHack())); break; case COPY_FILE: // TODO(paulg): Move to OSExchangeData when implementing drag and drop? - scw.WriteFile(download_->full_path().ToWStringHack()); + scw.WriteFile(download_->full_path()); break; case OPEN_WHEN_COMPLETE: OpenDownload(download_); diff --git a/chrome/browser/renderer_host/browser_render_process_host.h b/chrome/browser/renderer_host/browser_render_process_host.h index dad06b5..03dfc43 100644 --- a/chrome/browser/renderer_host/browser_render_process_host.h +++ b/chrome/browser/renderer_host/browser_render_process_host.h @@ -13,6 +13,7 @@ #include "base/ref_counted.h" #include "base/scoped_ptr.h" #include "base/shared_memory.h" +#include "base/string16.h" #include "base/timer.h" #include "chrome/common/transport_dib.h" #include "chrome/browser/renderer_host/audio_renderer_host.h" @@ -99,9 +100,9 @@ class BrowserRenderProcessHost : public RenderProcessHost, void OnClipboardWriteBookmark(const std::wstring& title, const GURL& url); void OnClipboardWriteBitmap(base::SharedMemoryHandle bitmap, gfx::Size size); void OnClipboardIsFormatAvailable(unsigned int format, bool* result); - void OnClipboardReadText(std::wstring* result); + void OnClipboardReadText(string16* result); void OnClipboardReadAsciiText(std::string* result); - void OnClipboardReadHTML(std::wstring* markup, GURL* src_url); + void OnClipboardReadHTML(string16* markup, GURL* src_url); void OnUpdatedCacheStats(const CacheManager::UsageStats& stats); diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index edec4d7..1f78df1 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -551,7 +551,7 @@ void ResourceMessageFilter::OnClipboardIsFormatAvailable(unsigned int format, #endif } -void ResourceMessageFilter::OnClipboardReadText(std::wstring* result) { +void ResourceMessageFilter::OnClipboardReadText(string16* result) { GetClipboardService()->ReadText(result); } @@ -559,7 +559,7 @@ void ResourceMessageFilter::OnClipboardReadAsciiText(std::string* result) { GetClipboardService()->ReadAsciiText(result); } -void ResourceMessageFilter::OnClipboardReadHTML(std::wstring* markup, +void ResourceMessageFilter::OnClipboardReadHTML(string16* markup, GURL* src_url) { std::string src_url_str; GetClipboardService()->ReadHTML(markup, &src_url_str); diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index b131488..679a0ac 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -14,6 +14,7 @@ #include "base/gfx/native_widget_types.h" #include "base/ref_counted.h" #include "base/shared_memory.h" +#include "base/string16.h" #include "build/build_config.h" #include "chrome/browser/net/resolve_proxy_msg_helper.h" #include "chrome/browser/renderer_host/resource_dispatcher_host.h" @@ -156,9 +157,9 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // Clipboard messages void OnClipboardWriteObjects(const Clipboard::ObjectMap& objects); void OnClipboardIsFormatAvailable(unsigned int format, bool* result); - void OnClipboardReadText(std::wstring* result); + void OnClipboardReadText(string16* result); void OnClipboardReadAsciiText(std::string* result); - void OnClipboardReadHTML(std::wstring* markup, GURL* src_url); + void OnClipboardReadHTML(string16* markup, GURL* src_url); #if defined(OS_WIN)|| defined(OS_LINUX) void OnGetWindowRect(gfx::NativeViewId window, gfx::Rect *rect); void OnGetRootWindowRect(gfx::NativeViewId window, gfx::Rect *rect); diff --git a/chrome/browser/tab_contents/render_view_context_menu_controller.cc b/chrome/browser/tab_contents/render_view_context_menu_controller.cc index 714f24c..4afcc86 100644 --- a/chrome/browser/tab_contents/render_view_context_menu_controller.cc +++ b/chrome/browser/tab_contents/render_view_context_menu_controller.cc @@ -67,7 +67,7 @@ void RenderViewContextMenuController::Inspect(int x, int y) { } void RenderViewContextMenuController::WriteTextToClipboard( - const std::wstring& text) { + const string16& text) { ClipboardService* clipboard = g_browser_process->clipboard_service(); if (!clipboard) @@ -79,9 +79,9 @@ void RenderViewContextMenuController::WriteTextToClipboard( void RenderViewContextMenuController::WriteURLToClipboard(const GURL& url) { if (url.SchemeIs(chrome::kMailToScheme)) - WriteTextToClipboard(UTF8ToWide(url.path())); + WriteTextToClipboard(UTF8ToUTF16(url.path())); else - WriteTextToClipboard(UTF8ToWide(url.spec())); + WriteTextToClipboard(UTF8ToUTF16(url.spec())); } /////////////////////////////////////////////////////////////////////////////// diff --git a/chrome/browser/tab_contents/render_view_context_menu_controller.h b/chrome/browser/tab_contents/render_view_context_menu_controller.h index 9d18ff6..0c72dcc 100644 --- a/chrome/browser/tab_contents/render_view_context_menu_controller.h +++ b/chrome/browser/tab_contents/render_view_context_menu_controller.h @@ -7,6 +7,7 @@ #include "build/build_config.h" +#include "base/string16.h" #include "chrome/common/pref_member.h" #include "chrome/common/page_transition_types.h" #include "webkit/glue/context_menu.h" @@ -49,7 +50,7 @@ class RenderViewContextMenuController : public Menu::Delegate { void Inspect(int x, int y); // Writes the specified text/url to the system clipboard - void WriteTextToClipboard(const std::wstring& text); + void WriteTextToClipboard(const string16& text); void WriteURLToClipboard(const GURL& url); bool IsDevCommandEnabled(int id) const; diff --git a/chrome/common/ipc_message_utils.h b/chrome/common/ipc_message_utils.h index 61243f5..e877221 100644 --- a/chrome/common/ipc_message_utils.h +++ b/chrome/common/ipc_message_utils.h @@ -512,32 +512,22 @@ struct ParamTraits<std::wstring> { } }; - // If WCHAR_T_IS_UTF16 is defined, then string16 is a std::wstring so we don't // need this trait. #if !defined(WCHAR_T_IS_UTF16) - template <> struct ParamTraits<string16> { typedef string16 param_type; static void Write(Message* m, const param_type& p) { - m->WriteData(reinterpret_cast<const char*>(p.data()), - static_cast<int>(p.size() * sizeof(char16))); + m->WriteString16(p); } static bool Read(const Message* m, void** iter, param_type* r) { - const char *data; - int data_size = 0; - if (!m->ReadData(iter, &data, &data_size)) - return false; - r->assign(reinterpret_cast<const char16*>(data), - data_size / sizeof(char16)); - return true; + return m->ReadString16(iter, r); } static void Log(const param_type& p, std::wstring* l) { l->append(UTF16ToWide(p)); } }; - #endif template <> @@ -704,7 +694,6 @@ struct ParamTraits<gfx::Size> { }; #if defined(OS_POSIX) - template<> struct ParamTraits<base::FileDescriptor> { typedef base::FileDescriptor param_type; @@ -723,7 +712,6 @@ struct ParamTraits<base::FileDescriptor> { } } }; - #endif // defined(OS_POSIX) template<> diff --git a/chrome/common/render_messages_internal.h b/chrome/common/render_messages_internal.h index af42627..963afae 100644 --- a/chrome/common/render_messages_internal.h +++ b/chrome/common/render_messages_internal.h @@ -840,11 +840,11 @@ IPC_BEGIN_MESSAGES(ViewHost) int /* format */, bool /* result */) IPC_SYNC_MESSAGE_CONTROL0_1(ViewHostMsg_ClipboardReadText, - std::wstring /* result */) + string16 /* result */) IPC_SYNC_MESSAGE_CONTROL0_1(ViewHostMsg_ClipboardReadAsciiText, std::string /* result */) IPC_SYNC_MESSAGE_CONTROL0_2(ViewHostMsg_ClipboardReadHTML, - std::wstring /* markup */, + string16 /* markup */, GURL /* url */) #if defined(OS_WIN) diff --git a/chrome/renderer/renderer_glue.cc b/chrome/renderer/renderer_glue.cc index 97a26ff..9508c50 100644 --- a/chrome/renderer/renderer_glue.cc +++ b/chrome/renderer/renderer_glue.cc @@ -211,7 +211,7 @@ bool ClipboardIsFormatAvailable(unsigned int format) { return result; } -void ClipboardReadText(std::wstring* result) { +void ClipboardReadText(string16* result) { RenderThread::current()->Send(new ViewHostMsg_ClipboardReadText(result)); } @@ -219,7 +219,7 @@ void ClipboardReadAsciiText(std::string* result) { RenderThread::current()->Send(new ViewHostMsg_ClipboardReadAsciiText(result)); } -void ClipboardReadHTML(std::wstring* markup, GURL* url) { +void ClipboardReadHTML(string16* markup, GURL* url) { RenderThread::current()->Send(new ViewHostMsg_ClipboardReadHTML(markup, url)); } |