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

This commit is contained in:
Blake Kaplan 2015-03-27 13:12:37 -07:00
Родитель a9a16182e7
Коммит 5c1748cefe
4 изменённых файлов: 34 добавлений и 5 удалений

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

@ -5704,12 +5704,18 @@ MOZ_ARG_DISABLE_BOOL(permissions,
MOZ_PERMISSIONS=1 MOZ_PERMISSIONS=1
) )
AC_SUBST(MOZ_PERMISSIONS)
if test -n "$MOZ_PERMISSIONS"; then
AC_DEFINE(MOZ_PERMISSIONS)
fi
dnl ======================================================== dnl ========================================================
dnl Child permissions, currently only used for b2g dnl Child permissions, currently only used for b2g
dnl ======================================================== dnl ========================================================
if test -n "$MOZ_B2G"; then if test -n "$MOZ_B2G"; then
if test -n "$MOZ_PERMISSIONS"; then if test -n "$MOZ_PERMISSIONS"; then
MOZ_CHILD_PERMISSIONS=1 MOZ_CHILD_PERMISSIONS=1
AC_DEFINE(MOZ_CHILD_PERMISSIONS)
else else
AC_MSG_ERROR([You need to enable MOZ_PERMISSIONS for MOZ_CHILD_PERMISSIONS]) AC_MSG_ERROR([You need to enable MOZ_PERMISSIONS for MOZ_CHILD_PERMISSIONS])
fi fi
@ -8429,7 +8435,6 @@ AC_SUBST(BIN_FLAGS)
AC_SUBST(MOZ_WIDGET_TOOLKIT) AC_SUBST(MOZ_WIDGET_TOOLKIT)
AC_SUBST(MOZ_UPDATE_XTERM) AC_SUBST(MOZ_UPDATE_XTERM)
AC_SUBST(MOZ_AUTH_EXTENSION) AC_SUBST(MOZ_AUTH_EXTENSION)
AC_SUBST(MOZ_PERMISSIONS)
AC_SUBST(MOZ_PREF_EXTENSIONS) AC_SUBST(MOZ_PREF_EXTENSIONS)
AC_SUBST(MOZ_DEBUG) AC_SUBST(MOZ_DEBUG)
AC_SUBST(MOZ_DEBUG_SYMBOLS) AC_SUBST(MOZ_DEBUG_SYMBOLS)

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

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* -*- 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 /* 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 * 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/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
@ -1692,12 +1693,18 @@ HTMLInputElement::GetValueInternal(nsAString& aValue) const
case VALUE_MODE_FILENAME: case VALUE_MODE_FILENAME:
if (nsContentUtils::IsCallerChrome()) { if (nsContentUtils::IsCallerChrome()) {
#ifndef MOZ_CHILD_PERMISSIONS
aValue.Assign(mFirstFilePath);
#else
// XXX We'd love to assert that this can't happen, but some mochitests
// use SpecialPowers to circumvent our more sane security model.
if (!mFiles.IsEmpty()) { if (!mFiles.IsEmpty()) {
return mFiles[0]->GetMozFullPath(aValue); return mFiles[0]->GetMozFullPath(aValue);
} }
else { else {
aValue.Truncate(); aValue.Truncate();
} }
#endif
} else { } else {
// Just return the leaf name // Just return the leaf name
if (mFiles.IsEmpty() || NS_FAILED(mFiles[0]->GetName(aValue))) { if (mFiles.IsEmpty() || NS_FAILED(mFiles[0]->GetName(aValue))) {
@ -2647,6 +2654,19 @@ HTMLInputElement::AfterSetFiles(bool aSetValueChanged)
formControlFrame->SetFormProperty(nsGkAtoms::value, readableValue); 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(); UpdateFileList();
if (aSetValueChanged) { if (aSetValueChanged) {

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

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

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

@ -148,10 +148,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk', 'qt'):
if CONFIG['MOZ_TOOLKIT_SEARCH']: if CONFIG['MOZ_TOOLKIT_SEARCH']:
DEFINES['MOZ_TOOLKIT_SEARCH'] = True DEFINES['MOZ_TOOLKIT_SEARCH'] = True
for var in ('MOZ_PERMISSIONS', 'MOZ_CHILD_PERMISSIONS'):
if CONFIG[var]:
DEFINES[var] = True
JAR_MANIFESTS += ['jar.mn'] JAR_MANIFESTS += ['jar.mn']
BROWSER_CHROME_MANIFESTS += ['tests/browser.ini'] BROWSER_CHROME_MANIFESTS += ['tests/browser.ini']