aboutsummaryrefslogtreecommitdiffstats
path: root/embed/mozilla/EphyBrowser.cpp
diff options
context:
space:
mode:
authorChristian Persch <chpe@cvs.gnome.org>2004-05-02 04:47:00 +0800
committerChristian Persch <chpe@src.gnome.org>2004-05-02 04:47:00 +0800
commit7093f6ad148d62a9ddc77f8080cf9822d5d24f1f (patch)
tree672ab4fb4d9e9853b14903b6c9019e911773fd93 /embed/mozilla/EphyBrowser.cpp
parent8493f7c5d64b577b3f6b8de91e5bb6c82a8b96ae (diff)
downloadgsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.gz
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.bz2
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.lz
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.xz
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.tar.zst
gsoc2013-epiphany-7093f6ad148d62a9ddc77f8080cf9822d5d24f1f.zip
Clean up encoding handling.
2004-05-01 Christian Persch <chpe@cvs.gnome.org> * embed/ephy-embed.c: (ephy_embed_get_encoding), (ephy_embed_has_automatic_encoding): * embed/ephy-embed.h: * embed/ephy-encodings.c: * embed/ephy-encodings.h: * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: * embed/mozilla/MozRegisterComponents.cpp: * embed/mozilla/mozilla-embed.cpp: * src/ephy-encoding-dialog.c: (sync_embed_cb), (activate_choice): * src/ephy-encoding-menu.c: (update_encoding_menu_cb), (encoding_activate_cb): Clean up encoding handling.
Diffstat (limited to 'embed/mozilla/EphyBrowser.cpp')
-rw-r--r--embed/mozilla/EphyBrowser.cpp102
1 files changed, 25 insertions, 77 deletions
diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp
index 01e0d60ca..157dceba6 100644
--- a/embed/mozilla/EphyBrowser.cpp
+++ b/embed/mozilla/EphyBrowser.cpp
@@ -638,6 +638,8 @@ nsresult EphyBrowser::GetTargetDocumentUrl (nsCString &url)
nsresult EphyBrowser::ForceEncoding (const char *encoding)
{
+ NS_ENSURE_TRUE (mInitialized, NS_ERROR_FAILURE);
+
nsCOMPtr<nsIContentViewer> contentViewer;
GetContentViewer (getter_AddRefs(contentViewer));
NS_ENSURE_TRUE (contentViewer, NS_ERROR_FAILURE);
@@ -645,107 +647,53 @@ nsresult EphyBrowser::ForceEncoding (const char *encoding)
nsCOMPtr<nsIMarkupDocumentViewer> mdv = do_QueryInterface(contentViewer);
NS_ENSURE_TRUE (mdv, NS_ERROR_FAILURE);
- nsresult result;
- result = mdv->SetForceCharacterSet (nsDependentCString(encoding));
-
- return result;
+ return mdv->SetForceCharacterSet (nsDependentCString(encoding));
}
-nsresult EphyBrowser::PushTargetDocument (nsIDOMDocument *domDoc)
+nsresult EphyBrowser::GetEncoding (nsACString &encoding)
{
- mTargetDocument = domDoc;
-
- return NS_OK;
-}
-
-nsresult EphyBrowser::PopTargetDocument ()
-{
- mTargetDocument = nsnull;
-
- return NS_OK;
-}
-
-nsresult EphyBrowser::GetEncodingInfo (EphyEncodingInfo **infoptr)
-{
- nsresult result;
- EphyEncodingInfo *info;
+ NS_ENSURE_TRUE (mInitialized, NS_ERROR_FAILURE);
nsCOMPtr<nsIDOMDocument> domDoc;
GetTargetDocument (getter_AddRefs(domDoc));
NS_ENSURE_TRUE (domDoc, NS_ERROR_FAILURE);
- nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc, &result);
+ nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
NS_ENSURE_TRUE (doc, NS_ERROR_FAILURE);
- info = g_new0 (EphyEncodingInfo, 1);
- *infoptr = info;
-
- PRInt32 source;
- source = doc->GetDocumentCharacterSetSource ();
- info->encoding_source = (EphyEncodingSource) source;
-
- nsCOMPtr<nsIDocShell> ds;
- ds = do_GetInterface (mWebBrowser);
- NS_ENSURE_TRUE (ds, NS_ERROR_FAILURE);
-
- nsCOMPtr<nsIDocumentCharsetInfo> ci;
- result = ds->GetDocumentCharsetInfo (getter_AddRefs (ci));
- NS_ENSURE_TRUE (ci, NS_ERROR_FAILURE);
-
- nsCOMPtr<nsIAtom> atom;
- ci->GetForcedCharset (getter_AddRefs (atom));
- if (atom)
- {
- nsCAutoString atomstr;
- atom->ToUTF8String (atomstr);
- info->forced_encoding = g_strdup (atomstr.get());
- }
+ encoding = doc->GetDocumentCharacterSet ();
+ NS_ENSURE_TRUE (!encoding.IsEmpty(), NS_ERROR_FAILURE);
- ci->GetParentCharset (getter_AddRefs (atom));
- if (atom)
- {
- nsCAutoString atomstr;
- atom->ToUTF8String (atomstr);
- info->parent_encoding = g_strdup (atomstr.get());
- }
+ return NS_OK;
+}
- result = ci->GetParentCharsetSource (&source);
- NS_ENSURE_SUCCESS (result, NS_ERROR_FAILURE);
- info->parent_encoding_source = (EphyEncodingSource) source;
+nsresult EphyBrowser::GetForcedEncoding (nsACString &encoding)
+{
+ NS_ENSURE_TRUE (mInitialized, NS_ERROR_FAILURE);
nsCOMPtr<nsIContentViewer> contentViewer;
- ds->GetContentViewer (getter_AddRefs(contentViewer));
+ GetContentViewer (getter_AddRefs(contentViewer));
NS_ENSURE_TRUE (contentViewer, NS_ERROR_FAILURE);
nsCOMPtr<nsIMarkupDocumentViewer> mdv = do_QueryInterface(contentViewer);
NS_ENSURE_TRUE (mdv, NS_ERROR_FAILURE);
- const nsACString& charsetEnc = doc->GetDocumentCharacterSet ();
- NS_ENSURE_TRUE (!charsetEnc.IsEmpty(), NS_ERROR_FAILURE);
-
- info->encoding = g_strdup (PromiseFlatCString(charsetEnc).get());
-
- nsCAutoString enc;
-
- result = mdv->GetDefaultCharacterSet (enc);
+ nsresult result = mdv->GetForceCharacterSet (encoding);
NS_ENSURE_SUCCESS (result, NS_ERROR_FAILURE);
- info->default_encoding = g_strdup (enc.get());
- result = mdv->GetForceCharacterSet (enc);
- NS_ENSURE_SUCCESS (result, NS_ERROR_FAILURE);
- info->forced_encoding = g_strdup (enc.get());
+ return NS_OK;
+}
- result = mdv->GetHintCharacterSet (enc);
- NS_ENSURE_SUCCESS (result, NS_ERROR_FAILURE);
- info->hint_encoding = g_strdup (enc.get());
+nsresult EphyBrowser::PushTargetDocument (nsIDOMDocument *domDoc)
+{
+ mTargetDocument = domDoc;
- result = mdv->GetPrevDocCharacterSet (enc);
- NS_ENSURE_SUCCESS (result, NS_ERROR_FAILURE);
- info->prev_doc_encoding = g_strdup (enc.get());
+ return NS_OK;
+}
- mdv->GetHintCharacterSetSource (&source);
- NS_ENSURE_SUCCESS (result, NS_ERROR_FAILURE);
- info->hint_encoding_source = (EphyEncodingSource) source;
+nsresult EphyBrowser::PopTargetDocument ()
+{
+ mTargetDocument = nsnull;
return NS_OK;
}