| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 21 BaseDownloadItemModel* download_model) | 21 BaseDownloadItemModel* download_model) |
| 22 : download_(download_model->download()), | 22 : download_(download_model->download()), |
| 23 model_(download_model) { | 23 model_(download_model) { |
| 24 } | 24 } |
| 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 case ALWAYS_OPEN_TYPE: { | 34 case ALWAYS_OPEN_TYPE: { |
| 34 const FilePath::StringType extension = | 35 const FilePath::StringType extension = |
| 35 file_util::GetFileExtensionFromPath(download_->full_path()); | 36 file_util::GetFileExtensionFromPath(download_->full_path()); |
| 36 return download_->manager()->ShouldOpenFileExtension(extension); | 37 return download_->manager()->ShouldOpenFileExtension(extension); |
| 37 } | 38 } |
| 39 case TOGGLE_PAUSE: { |
| 40 return download_->is_paused(); |
| 41 } |
| 38 } | 42 } |
| 39 return false; | 43 return false; |
| 40 } | 44 } |
| 41 | 45 |
| 42 bool DownloadShelfContextMenu::ItemIsDefault(int id) const { | 46 bool DownloadShelfContextMenu::ItemIsDefault(int id) const { |
| 43 return id == OPEN_WHEN_COMPLETE; | 47 return id == OPEN_WHEN_COMPLETE; |
| 44 } | 48 } |
| 45 | 49 |
| 46 std::wstring DownloadShelfContextMenu::GetItemLabel(int id) const { | 50 std::wstring DownloadShelfContextMenu::GetItemLabel(int id) const { |
| 47 switch (id) { | 51 switch (id) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // It is possible for the download to complete before the user clicks the | 117 // It is possible for the download to complete before the user clicks the |
| 114 // menu item, recheck if the download is in progress state before toggling | 118 // menu item, recheck if the download is in progress state before toggling |
| 115 // pause. | 119 // pause. |
| 116 if (download_->state() == DownloadItem::IN_PROGRESS) | 120 if (download_->state() == DownloadItem::IN_PROGRESS) |
| 117 download_->TogglePause(); | 121 download_->TogglePause(); |
| 118 break; | 122 break; |
| 119 default: | 123 default: |
| 120 NOTREACHED(); | 124 NOTREACHED(); |
| 121 } | 125 } |
| 122 } | 126 } |
| OLD | NEW |