mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-21 14:40:49 +01:00
alloy: Fix crash when downloading a modified PDF form (see issue #3169)
Create a CefFileSystemDelegate based on the ShellFileSystemDelegate placeholder implementation. An actual implementation will still be required to properly support this download functionality.
This commit is contained in:
parent
f1f3fc871c
commit
674fc0124f
2
BUILD.gn
2
BUILD.gn
@ -489,6 +489,8 @@ static_library("libcef_static") {
|
|||||||
"libcef/browser/download_manager_delegate.h",
|
"libcef/browser/download_manager_delegate.h",
|
||||||
"libcef/browser/extension_impl.cc",
|
"libcef/browser/extension_impl.cc",
|
||||||
"libcef/browser/extension_impl.h",
|
"libcef/browser/extension_impl.h",
|
||||||
|
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.cc",
|
||||||
|
"libcef/browser/extensions/api/file_system/cef_file_system_delegate.h",
|
||||||
"libcef/browser/extensions/api/storage/sync_value_store_cache.cc",
|
"libcef/browser/extensions/api/storage/sync_value_store_cache.cc",
|
||||||
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
|
"libcef/browser/extensions/api/storage/sync_value_store_cache.h",
|
||||||
"libcef/browser/extensions/api/tabs/tabs_api.cc",
|
"libcef/browser/extensions/api/tabs/tabs_api.cc",
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
// Copyright 2017 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/extensions/api/file_system/cef_file_system_delegate.h"
|
||||||
|
|
||||||
|
#include "apps/saved_files_service.h"
|
||||||
|
#include "base/callback.h"
|
||||||
|
#include "base/callback_forward.h"
|
||||||
|
#include "base/files/file_path.h"
|
||||||
|
#include "extensions/common/api/file_system.h"
|
||||||
|
#include "extensions/common/extension.h"
|
||||||
|
|
||||||
|
namespace extensions {
|
||||||
|
namespace cef {
|
||||||
|
|
||||||
|
CefFileSystemDelegate::CefFileSystemDelegate() = default;
|
||||||
|
|
||||||
|
CefFileSystemDelegate::~CefFileSystemDelegate() = default;
|
||||||
|
|
||||||
|
base::FilePath CefFileSystemDelegate::GetDefaultDirectory() {
|
||||||
|
return base::FilePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
base::FilePath CefFileSystemDelegate::GetManagedSaveAsDirectory(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
const Extension& extension) {
|
||||||
|
return base::FilePath();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CefFileSystemDelegate::ShowSelectFileDialog(
|
||||||
|
scoped_refptr<ExtensionFunction> extension_function,
|
||||||
|
ui::SelectFileDialog::Type type,
|
||||||
|
const base::FilePath& default_path,
|
||||||
|
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
||||||
|
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
|
||||||
|
base::OnceClosure file_selection_canceled_callback) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
|
||||||
|
// Run the cancel callback by default.
|
||||||
|
std::move(file_selection_canceled_callback).Run();
|
||||||
|
|
||||||
|
// Return true since this isn't a disallowed call, just not implemented.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CefFileSystemDelegate::ConfirmSensitiveDirectoryAccess(
|
||||||
|
bool has_write_permission,
|
||||||
|
const std::u16string& app_name,
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
base::OnceClosure on_accept,
|
||||||
|
base::OnceClosure on_cancel) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
|
||||||
|
// Run the cancel callback by default.
|
||||||
|
std::move(on_cancel).Run();
|
||||||
|
}
|
||||||
|
|
||||||
|
int CefFileSystemDelegate::GetDescriptionIdForAcceptType(
|
||||||
|
const std::string& accept_type) {
|
||||||
|
NOTIMPLEMENTED();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
SavedFilesServiceInterface* CefFileSystemDelegate::GetSavedFilesService(
|
||||||
|
content::BrowserContext* browser_context) {
|
||||||
|
return apps::SavedFilesService::Get(browser_context);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace cef
|
||||||
|
} // namespace extensions
|
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright (c) 2012 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.
|
||||||
|
|
||||||
|
#ifndef CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
||||||
|
#define CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
#include "base/callback.h"
|
||||||
|
#include "base/compiler_specific.h"
|
||||||
|
#include "base/memory/ref_counted.h"
|
||||||
|
#include "extensions/browser/api/execute_code_function.h"
|
||||||
|
#include "extensions/browser/api/file_system/file_system_delegate.h"
|
||||||
|
#include "extensions/browser/extension_function.h"
|
||||||
|
|
||||||
|
namespace content {
|
||||||
|
class WebContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace extensions {
|
||||||
|
namespace cef {
|
||||||
|
|
||||||
|
class CefFileSystemDelegate : public FileSystemDelegate {
|
||||||
|
public:
|
||||||
|
CefFileSystemDelegate();
|
||||||
|
|
||||||
|
CefFileSystemDelegate(const CefFileSystemDelegate&) = delete;
|
||||||
|
CefFileSystemDelegate& operator=(const CefFileSystemDelegate&) = delete;
|
||||||
|
|
||||||
|
~CefFileSystemDelegate() override;
|
||||||
|
|
||||||
|
// FileSystemDelegate
|
||||||
|
base::FilePath GetDefaultDirectory() override;
|
||||||
|
base::FilePath GetManagedSaveAsDirectory(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
const Extension& extension) override;
|
||||||
|
bool ShowSelectFileDialog(
|
||||||
|
scoped_refptr<ExtensionFunction> extension_function,
|
||||||
|
ui::SelectFileDialog::Type type,
|
||||||
|
const base::FilePath& default_path,
|
||||||
|
const ui::SelectFileDialog::FileTypeInfo* file_types,
|
||||||
|
FileSystemDelegate::FilesSelectedCallback files_selected_callback,
|
||||||
|
base::OnceClosure file_selection_canceled_callback) override;
|
||||||
|
void ConfirmSensitiveDirectoryAccess(bool has_write_permission,
|
||||||
|
const std::u16string& app_name,
|
||||||
|
content::WebContents* web_contents,
|
||||||
|
base::OnceClosure on_accept,
|
||||||
|
base::OnceClosure on_cancel) override;
|
||||||
|
int GetDescriptionIdForAcceptType(const std::string& accept_type) override;
|
||||||
|
SavedFilesServiceInterface* GetSavedFilesService(
|
||||||
|
content::BrowserContext* browser_context) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace cef
|
||||||
|
} // namespace extensions
|
||||||
|
|
||||||
|
#endif // CEF_LIBCEF_BROWSER_EXTENSIONS_API_FILE_SYSTEM_FILE_SYSTEM_DELEGATE_H_
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "include/internal/cef_types_wrappers.h"
|
#include "include/internal/cef_types_wrappers.h"
|
||||||
#include "libcef/browser/browser_context.h"
|
#include "libcef/browser/browser_context.h"
|
||||||
|
#include "libcef/browser/extensions/api/file_system/cef_file_system_delegate.h"
|
||||||
#include "libcef/browser/extensions/api/storage/sync_value_store_cache.h"
|
#include "libcef/browser/extensions/api/storage/sync_value_store_cache.h"
|
||||||
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
#include "libcef/browser/extensions/extension_web_contents_observer.h"
|
||||||
#include "libcef/browser/extensions/mime_handler_view_guest_delegate.h"
|
#include "libcef/browser/extensions/mime_handler_view_guest_delegate.h"
|
||||||
@ -74,4 +75,10 @@ void CefExtensionsAPIClient::AddAdditionalValueStoreCaches(
|
|||||||
(*caches)[settings_namespace::SYNC] = new cef::SyncValueStoreCache(factory);
|
(*caches)[settings_namespace::SYNC] = new cef::SyncValueStoreCache(factory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileSystemDelegate* CefExtensionsAPIClient::GetFileSystemDelegate() {
|
||||||
|
if (!file_system_delegate_)
|
||||||
|
file_system_delegate_ = std::make_unique<cef::CefFileSystemDelegate>();
|
||||||
|
return file_system_delegate_.get();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace extensions
|
} // namespace extensions
|
||||||
|
@ -25,6 +25,7 @@ class CefExtensionsAPIClient : public ExtensionsAPIClient {
|
|||||||
MimeHandlerViewGuest* guest) const override;
|
MimeHandlerViewGuest* guest) const override;
|
||||||
void AttachWebContentsHelpers(
|
void AttachWebContentsHelpers(
|
||||||
content::WebContents* web_contents) const override;
|
content::WebContents* web_contents) const override;
|
||||||
|
FileSystemDelegate* GetFileSystemDelegate() override;
|
||||||
|
|
||||||
// Storage API support.
|
// Storage API support.
|
||||||
|
|
||||||
@ -37,6 +38,9 @@ class CefExtensionsAPIClient : public ExtensionsAPIClient {
|
|||||||
observers,
|
observers,
|
||||||
std::map<settings_namespace::Namespace, ValueStoreCache*>* caches)
|
std::map<settings_namespace::Namespace, ValueStoreCache*>* caches)
|
||||||
override;
|
override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unique_ptr<FileSystemDelegate> file_system_delegate_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace extensions
|
} // namespace extensions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user