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

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

Issue 16533: Convert download manager to FilePath. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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 | « chrome/browser/download/save_file.cc ('k') | chrome/browser/history/download_database.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) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/save_package.h" 5 #include "chrome/browser/download/save_package.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return false; 170 return false;
171 } 171 }
172 172
173 file_manager_ = rdh->save_file_manager(); 173 file_manager_ = rdh->save_file_manager();
174 if (!file_manager_) { 174 if (!file_manager_) {
175 NOTREACHED(); 175 NOTREACHED();
176 return false; 176 return false;
177 } 177 }
178 178
179 // Create the fake DownloadItem and display the view. 179 // Create the fake DownloadItem and display the view.
180 download_ = new DownloadItem(1, saved_main_file_path_, 0, page_url_, 180 download_ = new DownloadItem(1,
181 std::wstring(), Time::Now(), 0, -1, -1, false); 181 FilePath::FromWStringHack(saved_main_file_path_), 0, page_url_,
182 FilePath(), Time::Now(), 0, -1, -1, false);
182 download_->set_manager(web_contents_->profile()->GetDownloadManager()); 183 download_->set_manager(web_contents_->profile()->GetDownloadManager());
183 DownloadShelfView* shelf = web_contents_->GetDownloadShelfView(); 184 DownloadShelfView* shelf = web_contents_->GetDownloadShelfView();
184 shelf->AddDownloadView(new DownloadItemView( 185 shelf->AddDownloadView(new DownloadItemView(
185 download_, shelf, new SavePageModel(this, download_))); 186 download_, shelf, new SavePageModel(this, download_)));
186 web_contents_->SetDownloadShelfVisible(true); 187 web_contents_->SetDownloadShelfVisible(true);
187 188
188 // Check save type and process the save page job. 189 // Check save type and process the save page job.
189 if (save_type_ == SAVE_AS_COMPLETE_HTML) { 190 if (save_type_ == SAVE_AS_COMPLETE_HTML) {
190 // Get directory 191 // Get directory
191 DCHECK(!saved_main_directory_path_.empty()); 192 DCHECK(!saved_main_directory_path_.empty());
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 if (!win_util::SaveFileAs(container_hwnd, suggest_name, 945 if (!win_util::SaveFileAs(container_hwnd, suggest_name,
945 &param->saved_main_file_path)) 946 &param->saved_main_file_path))
946 return false; 947 return false;
947 // Set save-as type to only-HTML if the contents of current tab can not be 948 // Set save-as type to only-HTML if the contents of current tab can not be
948 // saved as complete-HTML. 949 // saved as complete-HTML.
949 index = 1; 950 index = 1;
950 } 951 }
951 952
952 DCHECK(download_manager); 953 DCHECK(download_manager);
953 // Ensure the filename is safe. 954 // Ensure the filename is safe.
954 download_manager->GenerateSafeFilename(param->current_tab_mime_type, 955 FilePath path;
955 &param->saved_main_file_path); 956 download_manager->GenerateSafeFilename(param->current_tab_mime_type, &path);
957 param->saved_main_file_path = path.ToWStringHack();
956 958
957 // The option index is not zero-based. 959 // The option index is not zero-based.
958 DCHECK(index > 0 && index < 3); 960 DCHECK(index > 0 && index < 3);
959 param->dir = file_util::GetDirectoryFromPath(param->saved_main_file_path); 961 param->dir = file_util::GetDirectoryFromPath(param->saved_main_file_path);
960 962
961 StringPrefMember save_file_path; 963 StringPrefMember save_file_path;
962 save_file_path.Init(prefs::kSaveFileDefaultDirectory, param->prefs, NULL); 964 save_file_path.Init(prefs::kSaveFileDefaultDirectory, param->prefs, NULL);
963 // If user change the default saving directory, we will remember it just 965 // If user change the default saving directory, we will remember it just
964 // like IE and FireFox. 966 // like IE and FireFox.
965 if (save_file_path.GetValue() != param->dir) 967 if (save_file_path.GetValue() != param->dir)
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1071 1073
1072 if (available_length > dir_path_length) { 1074 if (available_length > dir_path_length) {
1073 *pure_file_name = 1075 *pure_file_name =
1074 pure_file_name->substr(0, available_length - dir_path_length); 1076 pure_file_name->substr(0, available_length - dir_path_length);
1075 return true; 1077 return true;
1076 } else { 1078 } else {
1077 pure_file_name->clear(); 1079 pure_file_name->clear();
1078 return false; 1080 return false;
1079 } 1081 }
1080 } 1082 }
OLDNEW
« no previous file with comments | « chrome/browser/download/save_file.cc ('k') | chrome/browser/history/download_database.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698