Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: chrome/browser/download/download_util.cc

Issue 9154: Rewrote the clipboard API to be more concurrent. Added a helper class to make... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 12 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Download utility implementation 5 // Download utility implementation
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "chrome/browser/download/download_util.h" 9 #include "chrome/browser/download/download_util.h"
10 10
11 #include "base/base_drag_source.h" 11 #include "base/base_drag_source.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/scoped_clipboard_writer.h"
13 #include "base/gfx/image_operations.h" 14 #include "base/gfx/image_operations.h"
14 #include "chrome/app/theme/theme_resources.h" 15 #include "chrome/app/theme/theme_resources.h"
15 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
16 #include "chrome/browser/download/download_manager.h" 17 #include "chrome/browser/download/download_manager.h"
17 #include "chrome/common/clipboard_service.h" 18 #include "chrome/common/clipboard_service.h"
18 #include "chrome/browser/drag_utils.h" 19 #include "chrome/browser/drag_utils.h"
19 #include "chrome/common/gfx/chrome_canvas.h" 20 #include "chrome/common/gfx/chrome_canvas.h"
20 #include "chrome/common/l10n_util.h" 21 #include "chrome/common/l10n_util.h"
21 #include "chrome/common/os_exchange_data.h" 22 #include "chrome/common/os_exchange_data.h"
22 #include "chrome/common/resource_bundle.h" 23 #include "chrome/common/resource_bundle.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 case ALWAYS_OPEN_TYPE: 97 case ALWAYS_OPEN_TYPE:
97 return CanOpenDownload(download_); 98 return CanOpenDownload(download_);
98 case CANCEL: 99 case CANCEL:
99 return download_->state() == DownloadItem::IN_PROGRESS; 100 return download_->state() == DownloadItem::IN_PROGRESS;
100 default: 101 default:
101 return id > 0 && id < MENU_LAST; 102 return id > 0 && id < MENU_LAST;
102 } 103 }
103 } 104 }
104 105
105 void BaseContextMenu::ExecuteCommand(int id) { 106 void BaseContextMenu::ExecuteCommand(int id) {
106 ClipboardService* clipboard = g_browser_process->clipboard_service(); 107 ScopedClipboardWriter scw(g_browser_process->clipboard_service());
107 DCHECK(clipboard);
108 switch (id) { 108 switch (id) {
109 case SHOW_IN_FOLDER: 109 case SHOW_IN_FOLDER:
110 download_->manager()->ShowDownloadInShell(download_); 110 download_->manager()->ShowDownloadInShell(download_);
111 break; 111 break;
112 case COPY_LINK: 112 case COPY_LINK:
113 clipboard->Clear(); 113 scw.WriteText(download_->url());
114 clipboard->WriteText(download_->url());
115 break; 114 break;
116 case COPY_PATH: 115 case COPY_PATH:
117 clipboard->Clear(); 116 scw.WriteText(download_->full_path());
118 clipboard->WriteText(download_->full_path());
119 break; 117 break;
120 case COPY_FILE: 118 case COPY_FILE:
121 // TODO(paulg): Move to OSExchangeData when implementing drag and drop? 119 // TODO(paulg): Move to OSExchangeData when implementing drag and drop?
122 clipboard->Clear(); 120 scw.WriteFile(download_->full_path());
123 clipboard->WriteFile(download_->full_path());
124 break; 121 break;
125 case OPEN_WHEN_COMPLETE: 122 case OPEN_WHEN_COMPLETE:
126 OpenDownload(download_); 123 OpenDownload(download_);
127 break; 124 break;
128 case ALWAYS_OPEN_TYPE: { 125 case ALWAYS_OPEN_TYPE: {
129 const std::wstring extension = 126 const std::wstring extension =
130 file_util::GetFileExtensionFromPath(download_->full_path()); 127 file_util::GetFileExtensionFromPath(download_->full_path());
131 download_->manager()->OpenFilesOfExtension( 128 download_->manager()->OpenFilesOfExtension(
132 extension, !IsItemChecked(ALWAYS_OPEN_TYPE)); 129 extension, !IsItemChecked(ALWAYS_OPEN_TYPE));
133 break; 130 break;
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 395
399 // Run the drag and drop loop 396 // Run the drag and drop loop
400 DWORD effects; 397 DWORD effects;
401 DoDragDrop(data.get(), drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK, 398 DoDragDrop(data.get(), drag_source.get(), DROPEFFECT_COPY | DROPEFFECT_LINK,
402 &effects); 399 &effects);
403 } 400 }
404 401
405 402
406 } // namespace download_util 403 } // namespace download_util
407 404
OLDNEW
« no previous file with comments | « chrome/browser/autocomplete/autocomplete_edit.cc ('k') | chrome/browser/render_view_context_menu_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698