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

Side by Side Diff: chrome/browser/file_select_helper.cc

Issue 1613483003: [SafeBrowsing] Alternate extensions should also be subject to block list. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix comment in histograms.xml Created 4 years, 10 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/safe_browsing/unverified_download_field_trial.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/file_select_helper.h" 5 #include "chrome/browser/file_select_helper.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
450 base::Bind(&FileSelectHelper::GetSanitizedFilenameOnUIThread, this, 450 base::Bind(&FileSelectHelper::GetSanitizedFilenameOnUIThread, this,
451 base::Passed(&params))); 451 base::Passed(&params)));
452 } 452 }
453 453
454 void FileSelectHelper::GetSanitizedFilenameOnUIThread( 454 void FileSelectHelper::GetSanitizedFilenameOnUIThread(
455 scoped_ptr<FileChooserParams> params) { 455 scoped_ptr<FileChooserParams> params) {
456 base::FilePath default_file_path = profile_->last_selected_directory().Append( 456 base::FilePath default_file_path = profile_->last_selected_directory().Append(
457 GetSanitizedFileName(params->default_file_name)); 457 GetSanitizedFileName(params->default_file_name));
458 458
459 #if defined(FULL_SAFE_BROWSING) 459 #if defined(FULL_SAFE_BROWSING)
460 std::vector<base::FilePath::StringType> alternate_extensions;
461 if (select_file_types_) {
462 for (const auto& extensions : select_file_types_->extensions) {
463 alternate_extensions.insert(alternate_extensions.end(),
464 extensions.begin(), extensions.end());
465 }
466 }
467
460 // Note that FileChooserParams::requestor is not considered a trusted field 468 // Note that FileChooserParams::requestor is not considered a trusted field
461 // since it's provided by the renderer and not validated browserside. 469 // since it's provided by the renderer and not validated browserside.
462 if (params->mode == FileChooserParams::Save && 470 if (params->mode == FileChooserParams::Save &&
463 !params->default_file_name.empty()) { 471 (!params->default_file_name.empty() || !alternate_extensions.empty())) {
464 GURL requestor = params->requestor; 472 GURL requestor = params->requestor;
465 safe_browsing::CheckUnverifiedDownloadPolicy( 473 safe_browsing::CheckUnverifiedDownloadPolicy(
466 requestor, default_file_path, 474 requestor, default_file_path, alternate_extensions,
467 base::Bind(&FileSelectHelper::ApplyUnverifiedDownloadPolicy, this, 475 base::Bind(&FileSelectHelper::ApplyUnverifiedDownloadPolicy, this,
468 default_file_path, base::Passed(&params))); 476 default_file_path, base::Passed(&params)));
469 return; 477 return;
470 } 478 }
471 #endif 479 #endif
472 480
473 RunFileChooserOnUIThread(default_file_path, std::move(params)); 481 RunFileChooserOnUIThread(default_file_path, std::move(params));
474 } 482 }
475 483
476 #if defined(FULL_SAFE_BROWSING) 484 #if defined(FULL_SAFE_BROWSING)
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
627 635
628 // static 636 // static
629 base::FilePath FileSelectHelper::GetSanitizedFileName( 637 base::FilePath FileSelectHelper::GetSanitizedFileName(
630 const base::FilePath& suggested_filename) { 638 const base::FilePath& suggested_filename) {
631 if (suggested_filename.empty()) 639 if (suggested_filename.empty())
632 return base::FilePath(); 640 return base::FilePath();
633 return net::GenerateFileName( 641 return net::GenerateFileName(
634 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(), 642 GURL(), std::string(), std::string(), suggested_filename.AsUTF8Unsafe(),
635 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME)); 643 std::string(), l10n_util::GetStringUTF8(IDS_DEFAULT_DOWNLOAD_FILENAME));
636 } 644 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/unverified_download_field_trial.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698