mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-29 07:42:04 +00:00
Improve wording of the postdata dialog. Bug 112848, patch by Magnus Melin
<mkmelin+mozilla@iki.fi>, r=darin, sr=bzbarsky
This commit is contained in:
parent
d999075330
commit
725237b351
@ -42,8 +42,9 @@ connectionFailure=Firefox can't establish a connection to the server at %S.
|
||||
netInterrupt=The connection to %S was interrupted while the page was loading.
|
||||
netTimeout=The server at %S is taking too long to respond.
|
||||
redirectLoop=Firefox has detected that the server is redirecting the request for this address in a way that will never complete.
|
||||
repost=The page you are trying to view contains POSTDATA that has expired from cache. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel.
|
||||
repostConfirm=The page you are trying to view contains POSTDATA. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel.
|
||||
## LOCALIZATION NOTE (confirmRepost): In this item, don't translate "%S"
|
||||
confirmRepost=To display this page, the information previously sent by %S must be resent. This will repeat any action (such as a search or order submission) that had been performed earlier.
|
||||
resendButton.label=Resend
|
||||
unknownSocketType=Firefox doesn't know how to communicate with the server.
|
||||
netReset=The connection to the server was reset while the page was loading.
|
||||
netOffline=Firefox is currently in offline mode and can't browse the Web.
|
||||
|
@ -99,6 +99,7 @@
|
||||
#include "nsIAppShell.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
#include "nsDOMJSUtils.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
||||
// we want to explore making the document own the load group
|
||||
// so we can associate the document URI with the load group.
|
||||
@ -221,6 +222,9 @@ static PRLogModuleInfo* gDocShellLog;
|
||||
static PRLogModuleInfo* gDocShellLeakLog;
|
||||
#endif
|
||||
|
||||
const char kBrandBundleURL[] = "chrome://branding/locale/brand.properties";
|
||||
const char kAppstringsBundleURL[] = "chrome://global/locale/appstrings.properties";
|
||||
|
||||
static void
|
||||
FavorPerformanceHint(PRBool perfOverStarvation, PRUint32 starvationDelay)
|
||||
{
|
||||
@ -7709,27 +7713,13 @@ nsDocShell::LoadHistoryEntry(nsISHEntry * aEntry, PRUint32 aLoadType)
|
||||
* repost the data to the server.
|
||||
*/
|
||||
if ((aLoadType & LOAD_CMD_RELOAD) && postData) {
|
||||
|
||||
nsCOMPtr<nsIPrompt> prompter;
|
||||
PRBool repost;
|
||||
nsCOMPtr<nsIStringBundle> stringBundle;
|
||||
GetPromptAndStringBundle(getter_AddRefs(prompter),
|
||||
getter_AddRefs(stringBundle));
|
||||
|
||||
if (stringBundle && prompter) {
|
||||
nsXPIDLString messageStr;
|
||||
nsresult rv = stringBundle->GetStringFromName(NS_LITERAL_STRING("repostConfirm").get(),
|
||||
getter_Copies(messageStr));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && messageStr) {
|
||||
prompter->Confirm(nsnull, messageStr, &repost);
|
||||
/* If the user pressed cancel in the dialog, return. We're
|
||||
* done here.
|
||||
*/
|
||||
if (!repost)
|
||||
return NS_BINDING_ABORTED;
|
||||
}
|
||||
}
|
||||
rv = ConfirmRepost(&repost);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
// If the user pressed cancel in the dialog, return. We're done here.
|
||||
if (!repost)
|
||||
return NS_BINDING_ABORTED;
|
||||
}
|
||||
|
||||
rv = InternalLoad(uri,
|
||||
@ -8207,7 +8197,56 @@ nsDocShell::GetLoadType(PRUint32 * aLoadType)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
#define DIALOG_STRING_URI "chrome://global/locale/appstrings.properties"
|
||||
nsresult
|
||||
nsDocShell::ConfirmRepost(PRBool * aRepost)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPrompt> prompter;
|
||||
CallGetInterface(this, NS_STATIC_CAST(nsIPrompt**, getter_AddRefs(prompter)));
|
||||
|
||||
nsCOMPtr<nsIStringBundleService>
|
||||
stringBundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> appBundle;
|
||||
rv = stringBundleService->CreateBundle(kAppstringsBundleURL,
|
||||
getter_AddRefs(appBundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
rv = stringBundleService->CreateBundle(kBrandBundleURL, getter_AddRefs(brandBundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ASSERTION(prompter && brandBundle && appBundle,
|
||||
"Unable to set up repost prompter.");
|
||||
|
||||
nsXPIDLString brandName;
|
||||
rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandName));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
const PRUnichar *formatStrings[] = { brandName.get() };
|
||||
|
||||
nsXPIDLString msgString, button0Title;
|
||||
rv = appBundle->FormatStringFromName(NS_LITERAL_STRING("confirmRepost").get(),
|
||||
formatStrings, NS_ARRAY_LENGTH(formatStrings),
|
||||
getter_Copies(msgString));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = appBundle->GetStringFromName(NS_LITERAL_STRING("resendButton.label").get(),
|
||||
getter_Copies(button0Title));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
PRInt32 buttonPressed;
|
||||
rv = prompter->
|
||||
ConfirmEx(nsnull, msgString.get(),
|
||||
(nsIPrompt::BUTTON_POS_0 * nsIPrompt::BUTTON_TITLE_IS_STRING) +
|
||||
(nsIPrompt::BUTTON_POS_1 * nsIPrompt::BUTTON_TITLE_CANCEL),
|
||||
button0Title.get(), nsnull, nsnull, nsnull, nsnull, &buttonPressed);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
*aRepost = (buttonPressed == 0);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetPromptAndStringBundle(nsIPrompt ** aPrompt,
|
||||
@ -8221,7 +8260,7 @@ nsDocShell::GetPromptAndStringBundle(nsIPrompt ** aPrompt,
|
||||
NS_ENSURE_TRUE(stringBundleService, NS_ERROR_FAILURE);
|
||||
|
||||
NS_ENSURE_SUCCESS(stringBundleService->
|
||||
CreateBundle(DIALOG_STRING_URI,
|
||||
CreateBundle(kAppstringsBundleURL,
|
||||
aStringBundle),
|
||||
NS_ERROR_FAILURE);
|
||||
|
||||
|
@ -360,6 +360,7 @@ protected:
|
||||
nsIChannel * aChannel);
|
||||
|
||||
// Helper Routines
|
||||
nsresult ConfirmRepost(PRBool * aRepost);
|
||||
NS_IMETHOD GetPromptAndStringBundle(nsIPrompt ** aPrompt,
|
||||
nsIStringBundle ** aStringBundle);
|
||||
NS_IMETHOD GetChildOffset(nsIDOMNode * aChild, nsIDOMNode * aParent,
|
||||
|
@ -1167,103 +1167,90 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress,
|
||||
if (httpChannel)
|
||||
httpChannel->GetRequestMethod(method);
|
||||
if (method.Equals("POST") && !NS_IsOffline()) {
|
||||
nsCOMPtr<nsIPrompt> prompter;
|
||||
PRBool repost;
|
||||
nsCOMPtr<nsIStringBundle> stringBundle;
|
||||
GetPromptAndStringBundle(getter_AddRefs(prompter),
|
||||
getter_AddRefs(stringBundle));
|
||||
|
||||
if (stringBundle && prompter) {
|
||||
nsXPIDLString messageStr;
|
||||
nsresult rv = stringBundle->GetStringFromName(NS_LITERAL_STRING("repost").get(),
|
||||
getter_Copies(messageStr));
|
||||
|
||||
if (NS_SUCCEEDED(rv) && messageStr) {
|
||||
prompter->Confirm(nsnull, messageStr, &repost);
|
||||
/* If the user pressed cancel in the dialog, return. Don't
|
||||
* try to load the page with out the post data.
|
||||
*/
|
||||
if (!repost)
|
||||
return NS_OK;
|
||||
rv = ConfirmRepost(&repost);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// If the user pressed cancel in the dialog, return. Don't try to load
|
||||
// the page without the post data.
|
||||
if (!repost)
|
||||
return NS_OK;
|
||||
|
||||
// The user wants to repost the data to the server.
|
||||
// If the page was loaded due to a back/forward/go
|
||||
// operation, update the session history index.
|
||||
// This is similar to the updating done in
|
||||
// nsDocShell::OnNewURI() for regular pages
|
||||
nsCOMPtr<nsISHistory> rootSH=mSessionHistory;
|
||||
if (!mSessionHistory) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||
//Get the root docshell
|
||||
GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||
if (root) {
|
||||
// QI root to nsIWebNavigation
|
||||
nsCOMPtr<nsIWebNavigation> rootAsWebnav(do_QueryInterface(root));
|
||||
if (rootAsWebnav) {
|
||||
// Get the handle to SH from the root docshell
|
||||
rootAsWebnav->GetSessionHistory(getter_AddRefs(rootSH));
|
||||
}
|
||||
}
|
||||
} // mSessionHistory
|
||||
// The user wants to repost the data to the server.
|
||||
// If the page was loaded due to a back/forward/go
|
||||
// operation, update the session history index.
|
||||
// This is similar to the updating done in
|
||||
// nsDocShell::OnNewURI() for regular pages
|
||||
nsCOMPtr<nsISHistory> rootSH=mSessionHistory;
|
||||
if (!mSessionHistory) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> root;
|
||||
//Get the root docshell
|
||||
GetSameTypeRootTreeItem(getter_AddRefs(root));
|
||||
if (root) {
|
||||
// QI root to nsIWebNavigation
|
||||
nsCOMPtr<nsIWebNavigation> rootAsWebnav(do_QueryInterface(root));
|
||||
if (rootAsWebnav) {
|
||||
// Get the handle to SH from the root docshell
|
||||
rootAsWebnav->GetSessionHistory(getter_AddRefs(rootSH));
|
||||
}
|
||||
}
|
||||
} // mSessionHistory
|
||||
|
||||
if (rootSH && (mLoadType & LOAD_CMD_HISTORY)) {
|
||||
nsCOMPtr<nsISHistoryInternal> shInternal(do_QueryInterface(rootSH));
|
||||
if (shInternal) {
|
||||
rootSH->GetIndex(&mPreviousTransIndex);
|
||||
shInternal->UpdateIndex();
|
||||
rootSH->GetIndex(&mLoadedTransIndex);
|
||||
if (rootSH && (mLoadType & LOAD_CMD_HISTORY)) {
|
||||
nsCOMPtr<nsISHistoryInternal> shInternal(do_QueryInterface(rootSH));
|
||||
if (shInternal) {
|
||||
rootSH->GetIndex(&mPreviousTransIndex);
|
||||
shInternal->UpdateIndex();
|
||||
rootSH->GetIndex(&mLoadedTransIndex);
|
||||
#ifdef DEBUG_PAGE_CACHE
|
||||
printf("Previous index: %d, Loaded index: %d\n\n",
|
||||
mPreviousTransIndex, mLoadedTransIndex);
|
||||
printf("Previous index: %d, Loaded index: %d\n\n",
|
||||
mPreviousTransIndex, mLoadedTransIndex);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
// Make it look like we really did honestly finish loading the
|
||||
// history page we were loading, since the "reload" load we're
|
||||
// about to kick off will reload our current history entry. This
|
||||
// is a bit of a hack, and if the force-load fails I think we'll
|
||||
// end up being confused about what page we're on... but we would
|
||||
// anyway, since we've updated the session history index above.
|
||||
SetHistoryEntry(&mOSHE, loadingSHE);
|
||||
|
||||
/* The user does want to repost the data to the server.
|
||||
* Initiate a new load again.
|
||||
*/
|
||||
/* Get the postdata if any from the channel */
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
if (channel) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
|
||||
if(httpChannel) {
|
||||
httpChannel->GetReferrer(getter_AddRefs(referrer));
|
||||
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(channel));
|
||||
if (uploadChannel) {
|
||||
uploadChannel->GetUploadStream(getter_AddRefs(inputStream));
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsISeekableStream> postDataSeekable(do_QueryInterface(inputStream));
|
||||
if (postDataSeekable)
|
||||
{
|
||||
postDataSeekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
}
|
||||
InternalLoad(url, // URI
|
||||
referrer, // Referring URI
|
||||
nsnull, // Owner
|
||||
INTERNAL_LOAD_FLAGS_INHERIT_OWNER, // Inherit owner
|
||||
nsnull, // No window target
|
||||
nsnull, // No type hint
|
||||
inputStream, // Post data stream
|
||||
nsnull, // No headers stream
|
||||
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE,// Load type
|
||||
nsnull, // No SHEntry
|
||||
PR_TRUE, // first party site
|
||||
nsnull, // No nsIDocShell
|
||||
nsnull); // No nsIRequest
|
||||
}
|
||||
}
|
||||
|
||||
// Make it look like we really did honestly finish loading the
|
||||
// history page we were loading, since the "reload" load we're
|
||||
// about to kick off will reload our current history entry. This
|
||||
// is a bit of a hack, and if the force-load fails I think we'll
|
||||
// end up being confused about what page we're on... but we would
|
||||
// anyway, since we've updated the session history index above.
|
||||
SetHistoryEntry(&mOSHE, loadingSHE);
|
||||
|
||||
// The user does want to repost the data to the server.
|
||||
// Initiate a new load again.
|
||||
|
||||
// Get the postdata if any from the channel.
|
||||
nsCOMPtr<nsIInputStream> inputStream;
|
||||
nsCOMPtr<nsIURI> referrer;
|
||||
if (channel) {
|
||||
nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(channel));
|
||||
|
||||
if(httpChannel) {
|
||||
httpChannel->GetReferrer(getter_AddRefs(referrer));
|
||||
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(channel));
|
||||
if (uploadChannel) {
|
||||
uploadChannel->GetUploadStream(getter_AddRefs(inputStream));
|
||||
}
|
||||
}
|
||||
}
|
||||
nsCOMPtr<nsISeekableStream> postDataSeekable(do_QueryInterface(inputStream));
|
||||
if (postDataSeekable)
|
||||
{
|
||||
postDataSeekable->Seek(nsISeekableStream::NS_SEEK_SET, 0);
|
||||
}
|
||||
InternalLoad(url, // URI
|
||||
referrer, // Referring URI
|
||||
nsnull, // Owner
|
||||
INTERNAL_LOAD_FLAGS_INHERIT_OWNER, // Inherit owner
|
||||
nsnull, // No window target
|
||||
nsnull, // No type hint
|
||||
inputStream, // Post data stream
|
||||
nsnull, // No headers stream
|
||||
LOAD_RELOAD_BYPASS_PROXY_AND_CACHE,// Load type
|
||||
nsnull, // No SHEntry
|
||||
PR_TRUE, // first party site
|
||||
nsnull, // No nsIDocShell
|
||||
nsnull); // No nsIRequest
|
||||
}
|
||||
else {
|
||||
DisplayLoadError(aStatus, url, nsnull, channel);
|
||||
|
@ -42,8 +42,9 @@ connectionFailure=The connection was refused when attempting to contact %S.
|
||||
netInterrupt=The connection to %S has terminated unexpectedly. Some data may have been transferred.
|
||||
netTimeout=The operation timed out when attempting to contact %S.
|
||||
redirectLoop=Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked.
|
||||
repost=The page you are trying to view contains POSTDATA that has expired from cache. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel.
|
||||
repostConfirm=The page you are trying to view contains POSTDATA. If you resend the data, any action the form carried out (such as a search or online purchase) will be repeated. To resend the data, click OK. Otherwise, click Cancel.
|
||||
## LOCALIZATION NOTE (confirmRepost): In this item, don't translate "%S"
|
||||
confirmRepost=To display this page, the information previously sent by %S must be resent. This will repeat any action (such as a search or order submission) that had been performed earlier.
|
||||
resendButton.label=Resend
|
||||
unknownSocketType=This document cannot be displayed unless you install the Personal Security Manager (PSM). Download and install PSM and try again, or contact your system administrator.
|
||||
netReset=The document contains no data.
|
||||
netOffline=This document cannot be displayed while offline. To go online, uncheck Work Offline from the File menu.
|
||||
|
Loading…
Reference in New Issue
Block a user