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

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

Issue 10382113: Add SafeBrowsing support for checking downloaded zip files that contain executables. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix FilePath printf format on Windows Created 8 years, 7 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 | « no previous file | chrome/browser/safe_browsing/download_protection_service.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 (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/download/chrome_download_manager_delegate.h" 5 #include "chrome/browser/download/chrome_download_manager_delegate.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
593 // is going to save there and not to another directory of his choice. 593 // is going to save there and not to another directory of his choice.
594 file_util::CreateDirectory(default_path); 594 file_util::CreateDirectory(default_path);
595 595
596 // Check writability of the suggested path. If we can't write to it, default 596 // Check writability of the suggested path. If we can't write to it, default
597 // to the user's "My Documents" directory. We'll prompt them in this case. 597 // to the user's "My Documents" directory. We'll prompt them in this case.
598 FilePath dir = state.suggested_path.DirName(); 598 FilePath dir = state.suggested_path.DirName();
599 FilePath filename = state.suggested_path.BaseName(); 599 FilePath filename = state.suggested_path.BaseName();
600 if (!file_util::PathIsWritable(dir)) { 600 if (!file_util::PathIsWritable(dir)) {
601 VLOG(1) << "Unable to write to directory \"" << dir.value() << "\""; 601 VLOG(1) << "Unable to write to directory \"" << dir.value() << "\"";
602 state.prompt_user_for_save_location = true; 602 state.prompt_user_for_save_location = true;
603 PathService::Get(chrome::DIR_USER_DOCUMENTS, &state.suggested_path); 603 PathService::Get(chrome::DIR_USER_DOCUMENTS, &dir);
604 state.suggested_path = state.suggested_path.Append(filename); 604 state.suggested_path = dir.Append(filename);
605 } 605 }
606 606
607 // If the download is possibly dangerous, we'll use a temporary name for it. 607 // If the download is possibly dangerous, we'll use a temporary name for it.
608 if (state.danger != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) { 608 if (state.danger != content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS) {
609 state.target_name = FilePath(state.suggested_path).BaseName(); 609 state.target_name = FilePath(state.suggested_path).BaseName();
610 // Create a temporary file to hold the file until the user approves its 610 // Create a temporary file to hold the file until the user approves its
611 // download. 611 // download.
612 FilePath::StringType file_name; 612 FilePath::StringType file_name;
613 FilePath path; 613 FilePath path;
614 #if defined(OS_WIN) 614 #if defined(OS_WIN)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 int32 download_id, int64 db_handle) { 719 int32 download_id, int64 db_handle) {
720 // It's not immediately obvious, but HistoryBackend::CreateDownload() can 720 // It's not immediately obvious, but HistoryBackend::CreateDownload() can
721 // call this function with an invalid |db_handle|. For instance, this can 721 // call this function with an invalid |db_handle|. For instance, this can
722 // happen when the history database is offline. We cannot have multiple 722 // happen when the history database is offline. We cannot have multiple
723 // DownloadItems with the same invalid db_handle, so we need to assign a 723 // DownloadItems with the same invalid db_handle, so we need to assign a
724 // unique |db_handle| here. 724 // unique |db_handle| here.
725 if (db_handle == DownloadItem::kUninitializedHandle) 725 if (db_handle == DownloadItem::kUninitializedHandle)
726 db_handle = download_history_->GetNextFakeDbHandle(); 726 db_handle = download_history_->GetNextFakeDbHandle();
727 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle); 727 download_manager_->OnItemAddedToPersistentStore(download_id, db_handle);
728 } 728 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/download_protection_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698