From 134cb296e99e2c3375c8da8a2ece4114cbbe9111 Mon Sep 17 00:00:00 2001 From: "evanm@google.com" Date: Mon, 17 Nov 2008 23:34:21 +0000 Subject: Lazy-initialize Clipboard, since we can't use it until we have an X connection. Review URL: http://codereview.chromium.org/11429 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@5583 0039d316-1c4b-4281-b951-d872f2087c98 --- webkit/glue/simple_clipboard_impl.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'webkit/glue/simple_clipboard_impl.cc') diff --git a/webkit/glue/simple_clipboard_impl.cc b/webkit/glue/simple_clipboard_impl.cc index b60a36808..bc8c7c5 100644 --- a/webkit/glue/simple_clipboard_impl.cc +++ b/webkit/glue/simple_clipboard_impl.cc @@ -7,8 +7,9 @@ #include #include "base/clipboard.h" -#include "webkit/glue/scoped_clipboard_writer_glue.h" +#include "base/lazy_instance.h" #include "googleurl/src/gurl.h" +#include "webkit/glue/scoped_clipboard_writer_glue.h" #include "SkBitmap.h" @@ -28,27 +29,27 @@ ScopedClipboardWriterGlue::~ScopedClipboardWriterGlue() { namespace webkit_glue { -Clipboard clipboard; +base::LazyInstance clipboard(base::LINKER_INITIALIZED); Clipboard* ClipboardGetClipboard() { - return &clipboard; + return clipboard.Pointer(); } bool ClipboardIsFormatAvailable(Clipboard::FormatType format) { - return clipboard.IsFormatAvailable(format); + return ClipboardGetClipboard()->IsFormatAvailable(format); } void ClipboardReadText(std::wstring* result) { - clipboard.ReadText(result); + ClipboardGetClipboard()->ReadText(result); } void ClipboardReadAsciiText(std::string* result) { - clipboard.ReadAsciiText(result); + ClipboardGetClipboard()->ReadAsciiText(result); } void ClipboardReadHTML(std::wstring* markup, GURL* url) { std::string url_str; - clipboard.ReadHTML(markup, url ? &url_str : NULL); + ClipboardGetClipboard()->ReadHTML(markup, url ? &url_str : NULL); if (url) *url = GURL(url_str); } -- cgit v1.1