Fixing bug 284364. Turn on plugins again if they were enabled before we started editing a document. r+sr=bzbarsky@mit.edu

This commit is contained in:
jst%mozilla.jstenback.com 2005-03-02 20:17:28 +00:00
parent d6b4a62ca7
commit 3a7c8a9086
2 changed files with 28 additions and 13 deletions

View File

@ -143,26 +143,33 @@ nsEditingSession::MakeWindowEditable(nsIDOMWindow *aWindow,
nsIDocShell *docShell = GetDocShellFromWindow(aWindow);
if (!docShell) return NS_ERROR_FAILURE;
nsresult rv = docShell->SetAllowPlugins(PR_FALSE);
if (NS_FAILED(rv)) return rv;
// register as a content listener, so that we can fend off URL
// loads from sidebar
nsresult rv;
nsCOMPtr<nsIURIContentListener> listener = do_GetInterface(docShell, &rv);
if (NS_FAILED(rv)) return rv;
NS_ENSURE_SUCCESS(rv, rv);
rv = listener->SetParentContentListener(this);
if (NS_FAILED(rv)) return rv;
NS_ENSURE_SUCCESS(rv, rv);
// Disable JavaScript in this document:
PRBool scriptsEnabled;
rv = docShell->GetAllowJavascript(&scriptsEnabled);
if (NS_FAILED(rv)) return rv;
mScriptsEnabled = scriptsEnabled;
if (scriptsEnabled) {
rv = docShell->SetAllowJavascript(PR_FALSE);
if (NS_FAILED(rv)) return rv;
}
PRBool tmp;
rv = docShell->GetAllowJavascript(&tmp);
NS_ENSURE_SUCCESS(rv, rv);
mScriptsEnabled = tmp;
rv = docShell->SetAllowJavascript(PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
// Disable plugins in this document:
rv = docShell->GetAllowPlugins(&tmp);
NS_ENSURE_SUCCESS(rv, rv);
mPluginsEnabled = tmp;
rv = docShell->SetAllowPlugins(PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
// Always remove existing editor
TearDownEditorOnWindow(aWindow);
@ -618,6 +625,10 @@ nsEditingSession::TearDownEditorOnWindow(nsIDOMWindow *aWindow)
docShell->SetAllowJavascript(PR_TRUE);
}
if (mPluginsEnabled) {
docShell->SetAllowPlugins(PR_TRUE);
}
nsCOMPtr<nsIDOMWindowUtils> utils(do_GetInterface(aWindow));
if (utils)
utils->SetImageAnimationMode(mImageAnimationMode);

View File

@ -141,6 +141,10 @@ protected:
// off, otherwise false.
PRPackedBool mScriptsEnabled;
// True if plugins were enabled before the editor turned plugins
// off, otherwise false.
PRPackedBool mPluginsEnabled;
PRPackedBool mProgressListenerRegistered;
// The image animation mode before it was turned off.