Bug 1086684 - Stash the full path for file inputs to avoid doing IPC at inopportune times. r=ehsan

This commit is contained in:
Blake Kaplan 2015-03-20 12:04:58 -07:00
Родитель e26a687773
Коммит fc6395db41
3 изменённых файлов: 28 добавлений и 6 удалений

Просмотреть файл

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 sw=2 sts=2 et tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -1691,12 +1692,11 @@ HTMLInputElement::GetValueInternal(nsAString& aValue) const
case VALUE_MODE_FILENAME:
if (nsContentUtils::IsCallerChrome()) {
if (!mFiles.IsEmpty()) {
return mFiles[0]->GetMozFullPath(aValue);
}
else {
aValue.Truncate();
}
#ifndef MOZ_CHILD_PERMISSIONS
aValue.Assign(mFirstFilePath);
#else
MOZ_ASSERT_UNREACHABLE("This doesn't happen with a sane security model");
#endif
} else {
// Just return the leaf name
if (mFiles.IsEmpty() || NS_FAILED(mFiles[0]->GetName(aValue))) {
@ -2646,6 +2646,19 @@ HTMLInputElement::AfterSetFiles(bool aSetValueChanged)
formControlFrame->SetFormProperty(nsGkAtoms::value, readableValue);
}
#ifndef MOZ_CHILD_PERMISSIONS
// Grab the full path here for any chrome callers who access our .value via a
// CPOW. This path won't be called from a CPOW meaning the potential sync IPC
// call under GetMozFullPath won't be rejected for not being urgent.
// XXX Protected by the ifndef because the blob code doesn't allow us to send
// this message in b2g.
if (mFiles.IsEmpty()) {
mFirstFilePath.Truncate();
} else {
mFiles[0]->GetMozFullPath(mFirstFilePath);
}
#endif
UpdateFileList();
if (aSetValueChanged) {

Просмотреть файл

@ -1254,6 +1254,7 @@ protected:
*/
nsTextEditorState* mState;
} mInputData;
/**
* The value of the input if it is a file input. This is the list of filenames
* used when uploading a file. It is vital that this is kept separate from
@ -1266,6 +1267,11 @@ protected:
*/
nsTArray<nsRefPtr<File>> mFiles;
/**
* Hack for bug 1086684: Stash the .value when we're a file picker.
*/
nsString mFirstFilePath;
nsRefPtr<FileList> mFileList;
nsRefPtr<DirPickerFileListBuilderTask> mDirPickerFileListBuilderTask;

Просмотреть файл

@ -244,4 +244,7 @@ LOCAL_INCLUDES += [
'/netwerk/base',
]
if CONFIG['MOZ_CHILD_PERMISSIONS']:
DEFINES['MOZ_CHILD_PERMISSIONS'] = True
FINAL_LIBRARY = 'xul'