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

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

Issue 149796: Bug fix for 10876, file extension handling refactoring (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 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
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/download_util.cc » ('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"
(...skipping 14 matching lines...) Expand all
25 25
26 DownloadShelfContextMenu::~DownloadShelfContextMenu() { 26 DownloadShelfContextMenu::~DownloadShelfContextMenu() {
27 } 27 }
28 28
29 bool DownloadShelfContextMenu::ItemIsChecked(int id) const { 29 bool DownloadShelfContextMenu::ItemIsChecked(int id) const {
30 switch (id) { 30 switch (id) {
31 case OPEN_WHEN_COMPLETE: { 31 case OPEN_WHEN_COMPLETE: {
32 return download_->open_when_complete(); 32 return download_->open_when_complete();
33 } 33 }
34 case ALWAYS_OPEN_TYPE: { 34 case ALWAYS_OPEN_TYPE: {
35 const FilePath::StringType extension = 35 return download_->manager()->ShouldOpenFileBasedOnExtension(
36 file_util::GetFileExtensionFromPath(download_->full_path()); 36 download_->full_path());
37 return download_->manager()->ShouldOpenFileExtension(extension);
38 } 37 }
39 case TOGGLE_PAUSE: { 38 case TOGGLE_PAUSE: {
40 return download_->is_paused(); 39 return download_->is_paused();
41 } 40 }
42 } 41 }
43 return false; 42 return false;
44 } 43 }
45 44
46 bool DownloadShelfContextMenu::ItemIsDefault(int id) const { 45 bool DownloadShelfContextMenu::ItemIsDefault(int id) const {
47 return id == OPEN_WHEN_COMPLETE; 46 return id == OPEN_WHEN_COMPLETE;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 88
90 void DownloadShelfContextMenu::ExecuteItemCommand(int id) { 89 void DownloadShelfContextMenu::ExecuteItemCommand(int id) {
91 switch (id) { 90 switch (id) {
92 case SHOW_IN_FOLDER: 91 case SHOW_IN_FOLDER:
93 download_->manager()->ShowDownloadInShell(download_); 92 download_->manager()->ShowDownloadInShell(download_);
94 break; 93 break;
95 case OPEN_WHEN_COMPLETE: 94 case OPEN_WHEN_COMPLETE:
96 download_util::OpenDownload(download_); 95 download_util::OpenDownload(download_);
97 break; 96 break;
98 case ALWAYS_OPEN_TYPE: { 97 case ALWAYS_OPEN_TYPE: {
99 const FilePath::StringType extension = 98 download_->manager()->OpenFilesBasedOnExtension(
100 file_util::GetFileExtensionFromPath(download_->full_path()); 99 download_->full_path(), !ItemIsChecked(ALWAYS_OPEN_TYPE));
101 download_->manager()->OpenFilesOfExtension(
102 extension, !ItemIsChecked(ALWAYS_OPEN_TYPE));
103 break; 100 break;
104 } 101 }
105 case CANCEL: 102 case CANCEL:
106 model_->CancelTask(); 103 model_->CancelTask();
107 break; 104 break;
108 case TOGGLE_PAUSE: 105 case TOGGLE_PAUSE:
109 // It is possible for the download to complete before the user clicks the 106 // It is possible for the download to complete before the user clicks the
110 // menu item, recheck if the download is in progress state before toggling 107 // menu item, recheck if the download is in progress state before toggling
111 // pause. 108 // pause.
112 if (download_->state() == DownloadItem::IN_PROGRESS) 109 if (download_->state() == DownloadItem::IN_PROGRESS)
113 download_->TogglePause(); 110 download_->TogglePause();
114 break; 111 break;
115 default: 112 default:
116 NOTREACHED(); 113 NOTREACHED();
117 } 114 }
118 } 115 }
OLDNEW
« no previous file with comments | « chrome/browser/download/download_manager.cc ('k') | chrome/browser/download/download_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698