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

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

Issue 1165893004: [Downloads] Prevent dangerous files from being opened automatically. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « no previous file | chrome/browser/download/download_extensions.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_commands.h" 5 #include "chrome/browser/download/download_commands.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "chrome/browser/browser_process.h" 8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/download/download_crx_util.h" 9 #include "chrome/browser/download/download_crx_util.h"
10 #include "chrome/browser/download/download_extensions.h"
10 #include "chrome/browser/download/download_item_model.h" 11 #include "chrome/browser/download/download_item_model.h"
11 #include "chrome/browser/download/download_prefs.h" 12 #include "chrome/browser/download/download_prefs.h"
12 #include "chrome/browser/profiles/profile_manager.h" 13 #include "chrome/browser/profiles/profile_manager.h"
13 #include "chrome/browser/safe_browsing/download_protection_service.h" 14 #include "chrome/browser/safe_browsing/download_protection_service.h"
14 #include "chrome/browser/safe_browsing/safe_browsing_service.h" 15 #include "chrome/browser/safe_browsing/safe_browsing_service.h"
15 #include "chrome/browser/ui/browser_finder.h" 16 #include "chrome/browser/ui/browser_finder.h"
16 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 17 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
17 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
18 #include "chrome/grit/generated_resources.h" 19 #include "chrome/grit/generated_resources.h"
19 #include "components/google/core/browser/google_util.h" 20 #include "components/google/core/browser/google_util.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 return download_item_->CanShowInFolder(); 82 return download_item_->CanShowInFolder();
82 case OPEN_WHEN_COMPLETE: 83 case OPEN_WHEN_COMPLETE:
83 case PLATFORM_OPEN: 84 case PLATFORM_OPEN:
84 return download_item_->CanOpenDownload() && 85 return download_item_->CanOpenDownload() &&
85 !download_crx_util::IsExtensionDownload(*download_item_); 86 !download_crx_util::IsExtensionDownload(*download_item_);
86 case ALWAYS_OPEN_TYPE: 87 case ALWAYS_OPEN_TYPE:
87 // For temporary downloads, the target filename might be a temporary 88 // For temporary downloads, the target filename might be a temporary
88 // filename. Don't base an "Always open" decision based on it. Also 89 // filename. Don't base an "Always open" decision based on it. Also
89 // exclude extensions. 90 // exclude extensions.
90 return download_item_->CanOpenDownload() && 91 return download_item_->CanOpenDownload() &&
92 download_util::IsAllowedToOpenAutomatically(
93 download_item_->GetTargetFilePath()) &&
91 !download_crx_util::IsExtensionDownload(*download_item_); 94 !download_crx_util::IsExtensionDownload(*download_item_);
92 case CANCEL: 95 case CANCEL:
93 return !download_item_->IsDone(); 96 return !download_item_->IsDone();
94 case PAUSE: 97 case PAUSE:
95 return !download_item_->IsDone() && !download_item_->IsPaused() && 98 return !download_item_->IsDone() && !download_item_->IsPaused() &&
96 download_item_->GetState() == content::DownloadItem::IN_PROGRESS; 99 download_item_->GetState() == content::DownloadItem::IN_PROGRESS;
97 case RESUME: 100 case RESUME:
98 return download_item_->CanResume() && 101 return download_item_->CanResume() &&
99 (download_item_->IsPaused() || 102 (download_item_->IsPaused() ||
100 download_item_->GetState() != content::DownloadItem::IN_PROGRESS); 103 download_item_->GetState() != content::DownloadItem::IN_PROGRESS);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 is_adobe_pdf_reader_up_to_date = 242 is_adobe_pdf_reader_up_to_date =
240 DownloadTargetDeterminer::IsAdobeReaderUpToDate(); 243 DownloadTargetDeterminer::IsAdobeReaderUpToDate();
241 } 244 }
242 return IsDownloadPdf() && 245 return IsDownloadPdf() &&
243 (IsAdobeReaderDefaultPDFViewer() ? is_adobe_pdf_reader_up_to_date 246 (IsAdobeReaderDefaultPDFViewer() ? is_adobe_pdf_reader_up_to_date
244 : true); 247 : true);
245 #elif defined(OS_MACOSX) || defined(OS_LINUX) 248 #elif defined(OS_MACOSX) || defined(OS_LINUX)
246 return IsDownloadPdf(); 249 return IsDownloadPdf();
247 #endif 250 #endif
248 } 251 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_extensions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698