mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
- 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:
42
libcef/browser/download_manager_delegate_win.cc
Normal file
42
libcef/browser/download_manager_delegate_win.cc
Normal file
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
||||
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "libcef/browser/download_manager_delegate.h"
|
||||
|
||||
#include <commdlg.h>
|
||||
#include <windows.h>
|
||||
|
||||
#include "base/string_util.h"
|
||||
#include "content/public/browser/web_contents.h"
|
||||
|
||||
|
||||
FilePath CefDownloadManagerDelegate::PlatformChooseDownloadPath(
|
||||
content::WebContents* web_contents,
|
||||
const FilePath& suggested_path) {
|
||||
FilePath result;
|
||||
|
||||
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));
|
||||
|
||||
return result;
|
||||
}
|
Reference in New Issue
Block a user