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

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

Issue 150079: Enable opening downloads from the Mac download shelf (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 5 months 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
« no previous file with comments | « app/gfx/canvas.cc ('k') | chrome/chrome.gyp » ('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/browser.h" 9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/dom_ui/downloads_ui.h" 10 #include "chrome/browser/dom_ui/downloads_ui.h"
11 #include "chrome/browser/download/download_item_model.h" 11 #include "chrome/browser/download/download_item_model.h"
12 #include "chrome/browser/download/download_manager.h" 12 #include "chrome/browser/download/download_manager.h"
13 #include "chrome/browser/download/download_util.h"
13 #include "chrome/browser/metrics/user_metrics.h" 14 #include "chrome/browser/metrics/user_metrics.h"
14 #include "chrome/common/url_constants.h" 15 #include "chrome/common/url_constants.h"
15 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
16 17
17 #if defined(OS_WIN) || defined(OS_LINUX)
18 // TODO(port): port this for mac. See two uses below.
19 #include "chrome/browser/download/download_util.h"
20 #endif
21 18
22 // DownloadShelf --------------------------------------------------------------- 19 // DownloadShelf ---------------------------------------------------------------
23 20
24 void DownloadShelf::ShowAllDownloads() { 21 void DownloadShelf::ShowAllDownloads() {
25 Profile* profile = browser_->profile(); 22 Profile* profile = browser_->profile();
26 if (profile) 23 if (profile)
27 UserMetrics::RecordAction(L"ShowDownloads", profile); 24 UserMetrics::RecordAction(L"ShowDownloads", profile);
28 browser_->OpenURL(GURL(chrome::kChromeUIDownloadsURL), GURL(), 25 browser_->OpenURL(GURL(chrome::kChromeUIDownloadsURL), GURL(),
29 NEW_FOREGROUND_TAB, PageTransition::AUTO_BOOKMARK); 26 NEW_FOREGROUND_TAB, PageTransition::AUTO_BOOKMARK);
30 } 27 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 } 71 }
75 return std::wstring(); 72 return std::wstring();
76 } 73 }
77 74
78 bool DownloadShelfContextMenu::IsItemCommandEnabled(int id) const { 75 bool DownloadShelfContextMenu::IsItemCommandEnabled(int id) const {
79 switch (id) { 76 switch (id) {
80 case SHOW_IN_FOLDER: 77 case SHOW_IN_FOLDER:
81 case OPEN_WHEN_COMPLETE: 78 case OPEN_WHEN_COMPLETE:
82 return download_->state() != DownloadItem::CANCELLED; 79 return download_->state() != DownloadItem::CANCELLED;
83 case ALWAYS_OPEN_TYPE: 80 case ALWAYS_OPEN_TYPE:
84 #if defined(OS_WIN) || defined(OS_LINUX)
85 return download_util::CanOpenDownload(download_); 81 return download_util::CanOpenDownload(download_);
86 #else
87 return false;
88 #endif
89 case CANCEL: 82 case CANCEL:
90 return download_->state() == DownloadItem::IN_PROGRESS; 83 return download_->state() == DownloadItem::IN_PROGRESS;
91 default: 84 default:
92 return id > 0 && id < MENU_LAST; 85 return id > 0 && id < MENU_LAST;
93 } 86 }
94 } 87 }
95 88
96 void DownloadShelfContextMenu::ExecuteItemCommand(int id) { 89 void DownloadShelfContextMenu::ExecuteItemCommand(int id) {
97 switch (id) { 90 switch (id) {
98 case SHOW_IN_FOLDER: 91 case SHOW_IN_FOLDER:
99 download_->manager()->ShowDownloadInShell(download_); 92 download_->manager()->ShowDownloadInShell(download_);
100 break; 93 break;
101 case OPEN_WHEN_COMPLETE: 94 case OPEN_WHEN_COMPLETE:
102 #if defined(OS_WIN) || defined(OS_LINUX)
103 download_util::OpenDownload(download_); 95 download_util::OpenDownload(download_);
104 #endif
105 break; 96 break;
106 case ALWAYS_OPEN_TYPE: { 97 case ALWAYS_OPEN_TYPE: {
107 const FilePath::StringType extension = 98 const FilePath::StringType extension =
108 file_util::GetFileExtensionFromPath(download_->full_path()); 99 file_util::GetFileExtensionFromPath(download_->full_path());
109 download_->manager()->OpenFilesOfExtension( 100 download_->manager()->OpenFilesOfExtension(
110 extension, !ItemIsChecked(ALWAYS_OPEN_TYPE)); 101 extension, !ItemIsChecked(ALWAYS_OPEN_TYPE));
111 break; 102 break;
112 } 103 }
113 case CANCEL: 104 case CANCEL:
114 model_->CancelTask(); 105 model_->CancelTask();
115 break; 106 break;
116 default: 107 default:
117 NOTREACHED(); 108 NOTREACHED();
118 } 109 }
119 } 110 }
OLDNEW
« no previous file with comments | « app/gfx/canvas.cc ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698