Chromium Code Reviews

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

Issue 112064: Linux: call xdg-open on downloaded files to open them. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix typos Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
« no previous file with comments | « chrome/browser/download/download_file.cc ('k') | chrome/browser/gtk/download_item_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/browser/download/download_shelf.h" 5 #include "chrome/browser/download/download_shelf.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "chrome/browser/dom_ui/downloads_ui.h" 9 #include "chrome/browser/dom_ui/downloads_ui.h"
10 #include "chrome/browser/download/download_item_model.h" 10 #include "chrome/browser/download/download_item_model.h"
11 #include "chrome/browser/download/download_manager.h" 11 #include "chrome/browser/download/download_manager.h"
12 #include "chrome/browser/metrics/user_metrics.h" 12 #include "chrome/browser/metrics/user_metrics.h"
13 #include "chrome/browser/tab_contents/tab_contents.h" 13 #include "chrome/browser/tab_contents/tab_contents.h"
14 #include "chrome/common/url_constants.h" 14 #include "chrome/common/url_constants.h"
15 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
16 16
17 #if defined(OS_WIN) 17 #if defined(OS_WIN) || defined(OS_LINUX)
18 // TODO(port): port this for mac. See two uses below.
18 #include "chrome/browser/download/download_util.h" 19 #include "chrome/browser/download/download_util.h"
19 #elif defined(OS_POSIX)
20 #include "chrome/common/temp_scaffolding_stubs.h"
21 #endif 20 #endif
22 21
23 // DownloadShelf --------------------------------------------------------------- 22 // DownloadShelf ---------------------------------------------------------------
24 23
25 void DownloadShelf::ShowAllDownloads() { 24 void DownloadShelf::ShowAllDownloads() {
26 Profile* profile = tab_contents_->profile(); 25 Profile* profile = tab_contents_->profile();
27 if (profile) 26 if (profile)
28 UserMetrics::RecordAction(L"ShowDownloads", profile); 27 UserMetrics::RecordAction(L"ShowDownloads", profile);
29 tab_contents_->OpenURL(GURL(chrome::kChromeUIDownloadsURL), GURL(), 28 tab_contents_->OpenURL(GURL(chrome::kChromeUIDownloadsURL), GURL(),
30 SINGLETON_TAB, PageTransition::AUTO_BOOKMARK); 29 SINGLETON_TAB, PageTransition::AUTO_BOOKMARK);
(...skipping 50 matching lines...)
81 } 80 }
82 return std::wstring(); 81 return std::wstring();
83 } 82 }
84 83
85 bool DownloadShelfContextMenu::IsItemCommandEnabled(int id) const { 84 bool DownloadShelfContextMenu::IsItemCommandEnabled(int id) const {
86 switch (id) { 85 switch (id) {
87 case SHOW_IN_FOLDER: 86 case SHOW_IN_FOLDER:
88 case OPEN_WHEN_COMPLETE: 87 case OPEN_WHEN_COMPLETE:
89 return download_->state() != DownloadItem::CANCELLED; 88 return download_->state() != DownloadItem::CANCELLED;
90 case ALWAYS_OPEN_TYPE: 89 case ALWAYS_OPEN_TYPE:
91 #if defined(OS_WIN) 90 #if defined(OS_WIN) || defined(OS_LINUX)
92 return download_util::CanOpenDownload(download_); 91 return download_util::CanOpenDownload(download_);
93 #elif defined(OS_LINUX) 92 #else
94 // Need to implement dangerous download stuff: http://crbug.com/11780
95 return false; 93 return false;
96 #endif 94 #endif
97 case CANCEL: 95 case CANCEL:
98 return download_->state() == DownloadItem::IN_PROGRESS; 96 return download_->state() == DownloadItem::IN_PROGRESS;
99 default: 97 default:
100 return id > 0 && id < MENU_LAST; 98 return id > 0 && id < MENU_LAST;
101 } 99 }
102 } 100 }
103 101
104 void DownloadShelfContextMenu::ExecuteItemCommand(int id) { 102 void DownloadShelfContextMenu::ExecuteItemCommand(int id) {
105 switch (id) { 103 switch (id) {
106 case SHOW_IN_FOLDER: 104 case SHOW_IN_FOLDER:
107 download_->manager()->ShowDownloadInShell(download_); 105 download_->manager()->ShowDownloadInShell(download_);
108 break; 106 break;
109 case OPEN_WHEN_COMPLETE: 107 case OPEN_WHEN_COMPLETE:
110 #if defined(OS_WIN) 108 #if defined(OS_WIN) || defined(OS_LINUX)
111 download_util::OpenDownload(download_); 109 download_util::OpenDownload(download_);
112 #else
113 // TODO(port): port download_util
114 NOTIMPLEMENTED();
115 #endif 110 #endif
116 break; 111 break;
117 case ALWAYS_OPEN_TYPE: { 112 case ALWAYS_OPEN_TYPE: {
118 const FilePath::StringType extension = 113 const FilePath::StringType extension =
119 file_util::GetFileExtensionFromPath(download_->full_path()); 114 file_util::GetFileExtensionFromPath(download_->full_path());
120 download_->manager()->OpenFilesOfExtension( 115 download_->manager()->OpenFilesOfExtension(
121 extension, !ItemIsChecked(ALWAYS_OPEN_TYPE)); 116 extension, !ItemIsChecked(ALWAYS_OPEN_TYPE));
122 break; 117 break;
123 } 118 }
124 case CANCEL: 119 case CANCEL:
125 model_->CancelTask(); 120 model_->CancelTask();
126 break; 121 break;
127 default: 122 default:
128 NOTREACHED(); 123 NOTREACHED();
129 } 124 }
130 } 125 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_file.cc ('k') | chrome/browser/gtk/download_item_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine