Bug 470455 - test_database_sync_embed_visits.js leaks, r=sdwilsh
[wine-gecko.git] / intl / chardet / src / nsObserverBase.cpp
blobb052eafec9e33f7f5c7677cde9cc978941e554f2
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
13 * License.
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1999
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
38 //#define DONT_INFORM_WEBSHELL
40 #include "nsIServiceManager.h"
41 #include "nsIWebShellServices.h"
42 #include "nsObserverBase.h"
43 #include "nsString.h"
44 #include "nsIHttpChannel.h"
48 //-------------------------------------------------------------------------
49 NS_IMETHODIMP nsObserverBase::NotifyWebShell(nsISupports* aWebShell,
50 nsISupports* aChannel,
51 const char* charset,
52 PRInt32 source)
55 nsresult rv = NS_OK;
56 nsresult res = NS_OK;
58 nsCOMPtr<nsIHttpChannel> httpChannel(do_QueryInterface(aChannel,&res));
59 if (NS_SUCCEEDED(res)) {
60 nsCAutoString method;
61 httpChannel->GetRequestMethod(method);
62 if (method.EqualsLiteral("POST")) { // XXX What about PUT, etc?
63 return NS_OK;
67 nsCOMPtr<nsIWebShellServices> wss;
68 wss = do_QueryInterface(aWebShell,&res);
69 if (NS_SUCCEEDED(res)) {
71 #ifndef DONT_INFORM_WEBSHELL
72 // ask the webshellservice to load the URL
73 if (NS_FAILED( res = wss->SetRendering(PR_FALSE) ))
74 rv = res;
76 // XXX nisheeth, uncomment the following two line to see the reent problem
78 else if (NS_FAILED(res = wss->StopDocumentLoad())){
79 rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
81 else if (NS_FAILED(res = wss->ReloadDocument(charset, source))) {
82 rv = wss->SetRendering(PR_TRUE); // turn on the rendering so at least we will see something.
84 else {
85 rv = NS_ERROR_HTMLPARSER_STOPPARSING; // We're reloading a new document...stop loading the current.
87 #endif
90 //if our reload request is not accepted, we should tell parser to go on
91 if (rv != NS_ERROR_HTMLPARSER_STOPPARSING)
92 rv = NS_ERROR_HTMLPARSER_CONTINUE;
94 return rv;