- Mac: Add CefDownloadManagerDelegate::ChooseDownloadPath implementation (issue #634).

- Persist downloaded files after CEF exits (issue #634).
- Shutdown the DownloadManager when CEF exits.
- Don't show an error message when downloading files with cefclient.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@682 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt
2012-06-11 17:35:23 +00:00
parent f79d18d510
commit a782ae94df
7 changed files with 104 additions and 21 deletions

View File

@@ -76,27 +76,8 @@ void CefDownloadManagerDelegate::ChooseDownloadPath(
const FilePath& suggested_path,
int32 download_id) {
FilePath result;
#if defined(OS_WIN) && !defined(USE_AURA)
std::wstring file_part = FilePath(suggested_path).BaseName().value();
wchar_t file_name[MAX_PATH];
base::wcslcpy(file_name, file_part.c_str(), arraysize(file_name));
OPENFILENAME save_as;
ZeroMemory(&save_as, sizeof(save_as));
save_as.lStructSize = sizeof(OPENFILENAME);
save_as.hwndOwner = web_contents->GetNativeView();
save_as.lpstrFile = file_name;
save_as.nMaxFile = arraysize(file_name);
std::wstring directory;
if (!suggested_path.empty())
directory = suggested_path.DirName().value();
save_as.lpstrInitialDir = directory.c_str();
save_as.Flags = OFN_OVERWRITEPROMPT | OFN_EXPLORER | OFN_ENABLESIZING |
OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
if (GetSaveFileName(&save_as))
result = FilePath(std::wstring(save_as.lpstrFile));
#if defined(OS_WIN) || defined(OS_MACOSX)
result = PlatformChooseDownloadPath(web_contents, suggested_path);
#else
NOTIMPLEMENTED();
#endif
@@ -108,6 +89,12 @@ void CefDownloadManagerDelegate::ChooseDownloadPath(
}
}
void CefDownloadManagerDelegate::AddItemToPersistentStore(
content::DownloadItem* item) {
static int next_id;
download_manager_->OnItemAddedToPersistentStore(item->GetId(), ++next_id);
}
void CefDownloadManagerDelegate::GenerateFilename(
int32 download_id,
const FilePath& generated_name) {