From 3ee3ffd1d79a0c1544f3bfd70c7de7606df9482f Mon Sep 17 00:00:00 2001 From: "estade@chromium.org" Date: Wed, 5 Nov 2008 01:34:30 +0000 Subject: Rewrote the clipboard API to be more concurrent. Added a helper class to make it more foolproof. Updated all clients and unittests. Mac port by jeremy@chromium.org Review URL: http://codereview.chromium.org/9154 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4719 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/download/download_util.cc | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'chrome/browser/download') diff --git a/chrome/browser/download/download_util.cc b/chrome/browser/download/download_util.cc index f9040b3..262c507 100644 --- a/chrome/browser/download/download_util.cc +++ b/chrome/browser/download/download_util.cc @@ -10,6 +10,7 @@ #include "base/base_drag_source.h" #include "base/file_util.h" +#include "base/scoped_clipboard_writer.h" #include "base/gfx/image_operations.h" #include "base/string_util.h" #include "chrome/app/locales/locale_settings.h" @@ -105,24 +106,20 @@ bool BaseContextMenu::IsCommandEnabled(int id) const { } void BaseContextMenu::ExecuteCommand(int id) { - ClipboardService* clipboard = g_browser_process->clipboard_service(); - DCHECK(clipboard); + ScopedClipboardWriter scw(g_browser_process->clipboard_service()); switch (id) { case SHOW_IN_FOLDER: download_->manager()->ShowDownloadInShell(download_); break; case COPY_LINK: - clipboard->Clear(); - clipboard->WriteText(download_->url()); + scw.WriteText(download_->url()); break; case COPY_PATH: - clipboard->Clear(); - clipboard->WriteText(download_->full_path()); + scw.WriteText(download_->full_path()); break; case COPY_FILE: // TODO(paulg): Move to OSExchangeData when implementing drag and drop? - clipboard->Clear(); - clipboard->WriteFile(download_->full_path()); + scw.WriteFile(download_->full_path()); break; case OPEN_WHEN_COMPLETE: OpenDownload(download_); -- cgit v1.1