diff options
author | Jean-François Rameau <jframeau@cvs.gnome.org> | 2006-10-23 01:08:06 +0800 |
---|---|---|
committer | Jean-François Rameau <jframeau@src.gnome.org> | 2006-10-23 01:08:06 +0800 |
commit | f2d423a34e23b3d785fab96c9c14925bdbe16591 (patch) | |
tree | 9bea04c2dc966a64887bd56796bc08c6051038f1 | |
parent | 461daa07586775c39d72c22287e0ab1fd1f9cf34 (diff) | |
download | gsoc2013-epiphany-f2d423a34e23b3d785fab96c9c14925bdbe16591.tar.gz gsoc2013-epiphany-f2d423a34e23b3d785fab96c9c14925bdbe16591.tar.zst gsoc2013-epiphany-f2d423a34e23b3d785fab96c9c14925bdbe16591.zip |
Get keyword search back by passing ALLOW_THIRD_PARTY_FIXUP flag to gecko.
2006-10-22 Jean-François Rameau <jframeau@cvs.gnome.org>
* embed/ephy-embed.h:
* embed/ephy-embed.c:
* embed/mozilla/EphyBrowser.cpp:
* embed/mozilla/EphyBrowser.h:
* embed/mozilla/mozilla-embed.cpp:
* src/ephy-link.h:
* src/ephy-location-action.c: (action_activated_cb):
* src/ephy-shell.c: (ephy_shell_new_tab_full):
* src/ephy-shell.h:
* src/ephy-window.c: (ephy_window_open_link):
Get keyword search back by passing ALLOW_THIRD_PARTY_FIXUP flag to gecko.
Add a new load method to EphyEmbed to custom load behaviour and pass (optional) referrer.
Fix bug #350053.
-rw-r--r-- | ChangeLog | 17 | ||||
-rw-r--r-- | embed/ephy-embed.c | 19 | ||||
-rw-r--r-- | embed/ephy-embed.h | 14 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.cpp | 52 | ||||
-rw-r--r-- | embed/mozilla/EphyBrowser.h | 6 | ||||
-rw-r--r-- | embed/mozilla/mozilla-embed.cpp | 37 | ||||
-rw-r--r-- | src/ephy-link.h | 3 | ||||
-rw-r--r-- | src/ephy-location-action.c | 4 | ||||
-rw-r--r-- | src/ephy-shell.c | 18 | ||||
-rw-r--r-- | src/ephy-shell.h | 4 | ||||
-rw-r--r-- | src/ephy-window.c | 20 |
11 files changed, 188 insertions, 6 deletions
@@ -1,3 +1,20 @@ +2006-10-22 Jean-François Rameau <jframeau@cvs.gnome.org> + + * embed/ephy-embed.h: + * embed/ephy-embed.c: + * embed/mozilla/EphyBrowser.cpp: + * embed/mozilla/EphyBrowser.h: + * embed/mozilla/mozilla-embed.cpp: + * src/ephy-link.h: + * src/ephy-location-action.c: (action_activated_cb): + * src/ephy-shell.c: (ephy_shell_new_tab_full): + * src/ephy-shell.h: + * src/ephy-window.c: (ephy_window_open_link): + + Get keyword search back by passing ALLOW_THIRD_PARTY_FIXUP flag to gecko. + Add a new load method to EphyEmbed to custom load behaviour and pass (optional) referrer. + Fix bug #350053. + 2006-10-18 Wouter Bolsterlee <wbolster@gnome.org> * src/ephy-dbus.c: (ephy_dbus_shutdown): diff --git a/embed/ephy-embed.c b/embed/ephy-embed.c index 139cfba8f..3e743c40c 100644 --- a/embed/ephy-embed.c +++ b/embed/ephy-embed.c @@ -423,6 +423,25 @@ ephy_embed_load_url (EphyEmbed *embed, } /** + * ephy_embed_load: + * @embed: an #EphyEmbed + * @url: an URL + * @flags: flags modifying load behaviour + * @previous_embed: the referrer embed or %NULL + * + * Loads a new web page in @embed. + **/ +void +ephy_embed_load (EphyEmbed *embed, + const char *url, + EphyEmbedLoadFlags flags, + EphyEmbed *referring_embed) +{ + EphyEmbedIface *iface = EPHY_EMBED_GET_IFACE (embed); + iface->load (embed, url, flags, referring_embed); +} + +/** * ephy_embed_stop_load: * @embed: an #EphyEmbed * diff --git a/embed/ephy-embed.h b/embed/ephy-embed.h index 1cf0a16a6..90743ded7 100644 --- a/embed/ephy-embed.h +++ b/embed/ephy-embed.h @@ -63,6 +63,12 @@ typedef enum EPHY_EMBED_CHROME_BOOKMARKSBAR = 1 << 3 } EphyEmbedChrome; +typedef enum +{ + EPHY_EMBED_LOAD_FLAGS_NONE = 1 << 0, + EPHY_EMBED_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP = 1 << 1, +} EphyEmbedLoadFlags; + #define EPHY_EMBED_CHROME_ALL (EPHY_EMBED_CHROME_MENUBAR | \ EPHY_EMBED_CHROME_TOOLBAR | \ EPHY_EMBED_CHROME_STATUSBAR | \ @@ -157,6 +163,10 @@ struct _EphyEmbedIface /* Methods */ void (* load_url) (EphyEmbed *embed, const char *url); + void (* load) (EphyEmbed *embed, + const char *url, + EphyEmbedLoadFlags flags, + EphyEmbed *referring_embed); void (* stop_load) (EphyEmbed *embed); void (* reload) (EphyEmbed *embed, gboolean force); @@ -232,6 +242,10 @@ GType ephy_embed_get_type (void); /* Base */ void ephy_embed_load_url (EphyEmbed *embed, const char *url); +void ephy_embed_load (EphyEmbed *embed, + const char *url, + EphyEmbedLoadFlags flags, + EphyEmbed *referring_embed); void ephy_embed_stop_load (EphyEmbed *embed); diff --git a/embed/mozilla/EphyBrowser.cpp b/embed/mozilla/EphyBrowser.cpp index 8e2e946a0..aba1645eb 100644 --- a/embed/mozilla/EphyBrowser.cpp +++ b/embed/mozilla/EphyBrowser.cpp @@ -1524,3 +1524,55 @@ EphyBrowser::Close () return domWin->Close(); } + +nsresult +EphyBrowser::GetPIDOMWindow(nsPIDOMWindow **aPIWin) +{ + *aPIWin = nsnull; + + // get the private DOM window + nsCOMPtr<nsPIDOMWindow> domWindowPrivate = do_QueryInterface(mDOMWindow); + + // and the root window for that DOM window + *aPIWin = domWindowPrivate->GetPrivateRoot(); + + if (*aPIWin) + { + NS_ADDREF(*aPIWin); + return NS_OK; + } + + return NS_ERROR_FAILURE; + +} + +nsresult +EphyBrowser::LoadURI(const char *aURI, + PRUint32 aLoadFlags, + nsIURI *aReferrer) +{ + nsString uURI; + nsresult rv = NS_OK; + + NS_CStringToUTF16 (nsCString (aURI), NS_CSTRING_ENCODING_UTF8, uURI); + + if (uURI.Length() == 0) return NS_OK; + + nsCOMPtr<nsIWebNavigation> contentNav = do_QueryInterface (mWebBrowser); + NS_ENSURE_TRUE (contentNav, NS_ERROR_FAILURE); + + nsCOMPtr<nsPIDOMWindow> piWin; + rv = GetPIDOMWindow(getter_AddRefs(piWin)); + NS_ENSURE_SUCCESS (rv, rv); + + nsAutoPopupStatePusher popupStatePusher(piWin, openAllowed); + + rv = contentNav->LoadURI(uURI.get(), // URI string + aLoadFlags, // Load flags + aReferrer, // Referring URI + nsnull, // Post data + nsnull); // extra headers + + return rv; +} + diff --git a/embed/mozilla/EphyBrowser.h b/embed/mozilla/EphyBrowser.h index c1464893f..9b41cd0d9 100644 --- a/embed/mozilla/EphyBrowser.h +++ b/embed/mozilla/EphyBrowser.h @@ -36,6 +36,7 @@ #include <nsIWebBrowserFocus.h> #include <nsIWebBrowser.h> #include <nsIWebNavigation.h> +#include <nsPIDOMWindow.h> #ifdef ALLOW_PRIVATE_API #include <nsIContentViewer.h> @@ -172,6 +173,7 @@ public: nsresult GetDocumentURI (nsIURI **aURI); nsresult GetTargetDocumentURI (nsIURI **aURI); nsresult GetDOMWindow (nsIDOMWindow **window); + nsresult GetPIDOMWindow(nsPIDOMWindow **aPIWin); nsresult GetHasModifiedForms (PRBool *modified); @@ -183,6 +185,10 @@ public: nsresult Close (); + nsresult LoadURI(const char *aURI, + PRUint32 aLoadFlags = nsIWebNavigation::LOAD_FLAGS_NONE, + nsIURI *aURI = nsnull); + EphyEmbedDocumentType GetDocumentType (); nsCOMPtr<nsIWebBrowser> mWebBrowser; diff --git a/embed/mozilla/mozilla-embed.cpp b/embed/mozilla/mozilla-embed.cpp index db8d09e68..45213598e 100644 --- a/embed/mozilla/mozilla-embed.cpp +++ b/embed/mozilla/mozilla-embed.cpp @@ -324,6 +324,42 @@ impl_load_url (EphyEmbed *embed, gtk_moz_embed_load_url (GTK_MOZ_EMBED(embed), url); } +static char * impl_get_location (EphyEmbed *embed, gboolean toplevel); + +static void +impl_load (EphyEmbed *embed, + const char *url, + EphyEmbedLoadFlags flags, + EphyEmbed *preview_embed) +{ + EphyBrowser *browser; + + browser = MOZILLA_EMBED(embed)->priv->browser; + g_return_if_fail (browser != NULL); + + nsCOMPtr<nsIURI> uri; + if (preview_embed != NULL) + { + EphyBrowser *pbrowser; + nsresult rv; + + pbrowser = MOZILLA_EMBED(preview_embed)->priv->browser; + if (pbrowser != NULL) + { + pbrowser->GetDocumentURI (getter_AddRefs (uri)); + } + } + + if (flags & EPHY_EMBED_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP) + { + browser->LoadURI (url, nsIWebNavigation::LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP, uri); + } + else + { + browser->LoadURI (url, nsIWebNavigation::LOAD_FLAGS_NONE, uri); + } +} + static void impl_stop_load (EphyEmbed *embed) { @@ -1114,6 +1150,7 @@ static void ephy_embed_iface_init (EphyEmbedIface *iface) { iface->load_url = impl_load_url; + iface->load = impl_load; iface->stop_load = impl_stop_load; iface->can_go_back = impl_can_go_back; iface->can_go_forward =impl_can_go_forward; diff --git a/src/ephy-link.h b/src/ephy-link.h index c7ff4971d..48dbc9f3a 100644 --- a/src/ephy-link.h +++ b/src/ephy-link.h @@ -41,7 +41,8 @@ typedef enum {
EPHY_LINK_NEW_WINDOW = 1 << 0,
EPHY_LINK_NEW_TAB = 1 << 1,
- EPHY_LINK_JUMP_TO = 1 << 2
+ EPHY_LINK_JUMP_TO = 1 << 2,
+ EPHY_LINK_ALLOW_FIXUP = 1 << 3
} EphyLinkFlags;
struct _EphyLinkIface
diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index 6114d52e7..df230479c 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -139,7 +139,7 @@ action_activated_cb (GtkEntryCompletion *completion, if (url == NULL) return; ephy_link_open (EPHY_LINK (action), url, NULL, - ephy_link_flags_from_current_event ()); + ephy_link_flags_from_current_event () | EPHY_LINK_ALLOW_FIXUP); g_free (url); } @@ -162,7 +162,7 @@ entry_activate_cb (GtkEntry *entry, g_return_if_fail (address != NULL); ephy_link_open (EPHY_LINK (action), address, NULL, - ephy_link_flags_from_current_event ()); + ephy_link_flags_from_current_event () | EPHY_LINK_ALLOW_FIXUP); g_free (address); } diff --git a/src/ephy-shell.c b/src/ephy-shell.c index 58b387872..30ee3135f 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -530,8 +530,24 @@ ephy_shell_new_tab_full (EphyShell *shell, } else if (flags & EPHY_NEW_TAB_OPEN_PAGE) { + EphyEmbedLoadFlags load_flags = 0; + g_assert (url != NULL); - ephy_embed_load_url (embed, url); + + if (flags & EPHY_NEW_TAB_ALLOW_FIXUP) + { + load_flags = EPHY_EMBED_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP; + } + else + { + load_flags = EPHY_EMBED_LOAD_FLAGS_NONE; + } + /* FIXME */ + /* We need to audit every caller to see if this + won't make us send referer for undesirable loads. + Passing NULL referrer atm */ + ephy_embed_load (embed, url, load_flags, NULL); + is_empty = url_is_empty (url); } diff --git a/src/ephy-shell.h b/src/ephy-shell.h index 0d8de4132..e1eca3ba2 100644 --- a/src/ephy-shell.h +++ b/src/ephy-shell.h @@ -62,6 +62,10 @@ typedef enum EPHY_NEW_TAB_JUMP = 1 << 9, EPHY_NEW_TAB_IN_NEW_WINDOW = 1 << 10, EPHY_NEW_TAB_IN_EXISTING_WINDOW = 1 << 11, + + /* The way to load */ + EPHY_NEW_TAB_ALLOW_FIXUP = 1 << 12, + } EphyNewTabFlags; struct _EphyShell diff --git a/src/ephy-window.c b/src/ephy-window.c index 04539f2b9..000c0fbab 100644 --- a/src/ephy-window.c +++ b/src/ephy-window.c @@ -2970,7 +2970,9 @@ ephy_window_open_link (EphyLink *link, tab = ephy_window_get_active_tab (window); } - if (flags != 0) + if (flags & (EPHY_LINK_JUMP_TO | + EPHY_LINK_NEW_TAB | + EPHY_LINK_NEW_WINDOW)) { EphyNewTabFlags ntflags = EPHY_NEW_TAB_OPEN_PAGE; @@ -2987,6 +2989,10 @@ ephy_window_open_link (EphyLink *link, { ntflags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW; } + if (flags & EPHY_LINK_ALLOW_FIXUP) + { + ntflags |= EPHY_NEW_TAB_ALLOW_FIXUP; + } new_tab = ephy_shell_new_tab (ephy_shell, @@ -2999,7 +3005,17 @@ ephy_window_open_link (EphyLink *link, embed = ephy_tab_get_embed (tab); - ephy_embed_load_url (embed, address); + if (flags & EPHY_LINK_ALLOW_FIXUP) + { + ephy_embed_load (embed, + address, + EPHY_EMBED_LOAD_FLAGS_ALLOW_THIRD_PARTY_FIXUP, + NULL); + } + else + { + ephy_embed_load_url (embed, address); + } if (address == NULL || address[0] == '\0' || strcmp (address, "about:blank") == 0) { |