This source file includes following definitions.
- process_id_
- OverrideThreadForMessage
- OnMessageReceived
- OnGetFileInfo
#include "content/browser/renderer_host/file_utilities_message_filter.h"
#include "base/file_util.h"
#include "content/browser/child_process_security_policy_impl.h"
#include "content/common/file_utilities_messages.h"
namespace content {
FileUtilitiesMessageFilter::FileUtilitiesMessageFilter(int process_id)
: BrowserMessageFilter(FileUtilitiesMsgStart),
process_id_(process_id) {
}
FileUtilitiesMessageFilter::~FileUtilitiesMessageFilter() {
}
void FileUtilitiesMessageFilter::OverrideThreadForMessage(
const IPC::Message& message,
BrowserThread::ID* thread) {
if (IPC_MESSAGE_CLASS(message) == FileUtilitiesMsgStart)
*thread = BrowserThread::FILE;
}
bool FileUtilitiesMessageFilter::OnMessageReceived(const IPC::Message& message,
bool* message_was_ok) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_EX(FileUtilitiesMessageFilter, message, *message_was_ok)
IPC_MESSAGE_HANDLER(FileUtilitiesMsg_GetFileInfo, OnGetFileInfo)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
void FileUtilitiesMessageFilter::OnGetFileInfo(
const base::FilePath& path,
base::File::Info* result,
base::File::Error* status) {
*result = base::File::Info();
*status = base::File::FILE_OK;
if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanReadFile(
process_id_, path)) {
return;
}
if (!base::GetFileInfo(path, result))
*status = base::File::FILE_ERROR_FAILED;
}
}