Bug 551181 - Tell the chrome process when we visit a page. r=cjones/sdwilsh
authorDoug Turner <dougt@dougt.org>
Tue, 29 Jun 2010 16:39:35 -0700
changeset 46936 71114e4522c7f938ecd669d5f9de020e0e48b659
parent 46935 e6d93fff753b1bab26cbd64f13dd331168e4f412
child 46937 ca18a037097f278bc8cd5dd0a4f36a78fa2b26db
push idunknown
push userunknown
push dateunknown
reviewerscjones, sdwilsh
bugs551181
milestone2.0b2pre
Bug 551181 - Tell the chrome process when we visit a page. r=cjones/sdwilsh
dom/ipc/ContentProcessParent.cpp
dom/ipc/ContentProcessParent.h
dom/ipc/PContentProcess.ipdl
toolkit/components/places/src/History.cpp
toolkit/components/places/src/Makefile.in
--- a/dom/ipc/ContentProcessParent.cpp
+++ b/dom/ipc/ContentProcessParent.cpp
@@ -41,17 +41,17 @@
 
 #include "TabParent.h"
 #include "mozilla/ipc/TestShellParent.h"
 #include "mozilla/net/NeckoParent.h"
 #include "nsIPrefBranch.h"
 #include "nsIPrefBranch2.h"
 #include "nsIPrefLocalizedString.h"
 #include "nsIObserverService.h"
-
+#include "nsContentUtils.h"
 #include "nsAutoPtr.h"
 #include "nsCOMPtr.h"
 #include "nsServiceManagerUtils.h"
 #include "nsThreadUtils.h"
 #include "nsChromeRegistryChrome.h"
 
 using namespace mozilla::ipc;
 using namespace mozilla::net;
@@ -392,16 +392,29 @@ ContentProcessParent::RequestRunToComple
         printf("Running to completion...\n");
 #endif
         mRunToCompletionDepth = 1;
         mShouldCallUnblockChild = true;
     }
     return !!mRunToCompletionDepth;
 }
 
+
+bool
+ContentProcessParent::RecvVisitURI(const IPC::URI& uri,
+                                   const IPC::URI& referrer,
+                                   const PRUint32& flags)
+{
+    nsCOMPtr<nsIURI> ourURI = uri;
+    nsCOMPtr<nsIURI> ourReferrer = referrer;
+    IHistory *history = nsContentUtils::GetHistory(); 
+    history->VisitURI(ourURI, ourReferrer, flags);
+    return true;
+}
+
 /* void onDispatchedEvent (in nsIThreadInternal thread); */
 NS_IMETHODIMP
 ContentProcessParent::OnDispatchedEvent(nsIThreadInternal *thread)
 {
     if (mOldObserver)
         return mOldObserver->OnDispatchedEvent(thread);
 
     return NS_OK;
--- a/dom/ipc/ContentProcessParent.h
+++ b/dom/ipc/ContentProcessParent.h
@@ -42,16 +42,17 @@
 #include "base/waitable_event_watcher.h"
 
 #include "mozilla/dom/PContentProcessParent.h"
 #include "mozilla/ipc/GeckoChildProcessHost.h"
 
 #include "nsIObserver.h"
 #include "nsIThreadInternal.h"
 #include "mozilla/Monitor.h"
+#include "nsNetUtil.h"
 #include "nsIPrefService.h"
 
 namespace mozilla {
 
 namespace ipc {
 class TestShellParent;
 }
 
@@ -133,16 +134,20 @@ private:
     virtual bool RecvPrefIsLocked(const nsCString& prefName,
             PRBool* retValue, nsresult* rv);
 
     virtual bool RecvGetChildList(const nsCString& domain,
             nsTArray<nsCString>* list, nsresult* rv);
 
     void EnsurePrefService();
 
+    virtual bool RecvVisitURI(const IPC::URI& uri,
+                              const IPC::URI& referrer,
+                              const PRUint32& flags);
+
     mozilla::Monitor mMonitor;
 
     GeckoChildProcessHost* mSubprocess;
 
     int mRunToCompletionDepth;
     bool mShouldCallUnblockChild;
     nsCOMPtr<nsIThreadObserver> mOldObserver;
 
--- a/dom/ipc/PContentProcess.ipdl
+++ b/dom/ipc/PContentProcess.ipdl
@@ -37,17 +37,19 @@
  * ***** END LICENSE BLOCK ***** */
 
 include protocol PIFrameEmbedding;
 include protocol PTestShell;
 include protocol PNecko;
 
 include "mozilla/TabTypes.h";
 include "mozilla/chrome/RegistryMessageUtils.h";
+include "mozilla/net/NeckoMessageUtils.h";
 
+using IPC::URI;
 using ChromePackage;
 using ResourceMapping;
 using OverrideMapping;
 
 namespace mozilla {
 namespace dom {
 
 rpc protocol PContentProcess
@@ -66,16 +68,18 @@ child:
 
     async SetOffline(PRBool offline);
 
     NotifyRemotePrefObserver(nsCString aDomain);
 
 parent:
     PNecko();
 
+    async VisitURI(URI uri, URI referrer, PRUint32 flags);
+
     // prefs-related messages ...
     sync GetPrefType(nsCString prefName) returns (PRInt32 retValue, nsresult rv);
     sync GetBoolPref(nsCString prefName) returns (PRBool retValue, nsresult rv);
     sync GetIntPref(nsCString prefName)  returns (PRInt32 retValue, nsresult rv);
     sync GetCharPref(nsCString prefName) returns (nsCString retValue, nsresult rv);
     sync GetPrefLocalizedString(nsCString prefName) returns (nsString retValue, nsresult rv);
     sync PrefHasUserValue(nsCString prefName) returns (PRBool retValue, nsresult rv);
     sync PrefIsLocked(nsCString prefName) returns (PRBool retValue, nsresult rv);
--- a/toolkit/components/places/src/History.cpp
+++ b/toolkit/components/places/src/History.cpp
@@ -32,16 +32,21 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+#ifdef MOZ_IPC
+#include "mozilla/dom/ContentProcessChild.h"
+#include "nsXULAppAPI.h"
+#endif
+
 #include "History.h"
 #include "nsNavHistory.h"
 #include "nsNavBookmarks.h"
 #include "Helpers.h"
 
 #include "mozilla/storage.h"
 #include "mozilla/dom/Link.h"
 #include "nsDocShellCID.h"
@@ -979,16 +984,26 @@ History::StartNextTask()
 
 NS_IMETHODIMP
 History::VisitURI(nsIURI* aURI,
                   nsIURI* aLastVisitedURI,
                   PRUint32 aFlags)
 {
   NS_PRECONDITION(aURI, "URI should not be NULL.");
 
+#ifdef MOZ_IPC
+  if (XRE_GetProcessType() == GeckoProcessType_Content) {
+    mozilla::dom::ContentProcessChild * cpc = 
+      mozilla::dom::ContentProcessChild::GetSingleton();
+    NS_ASSERTION(cpc, "Content Protocol is NULL!");
+    (void) cpc->SendVisitURI(IPC::URI(aURI), IPC::URI(aLastVisitedURI), aFlags);
+    return NS_OK;
+  } 
+#endif /* MOZ_IPC */
+
   nsNavHistory* history = nsNavHistory::GetHistoryService();
   NS_ENSURE_TRUE(history, NS_ERROR_OUT_OF_MEMORY);
 
   // Silently return if URI is something we shouldn't add to DB.
   PRBool canAdd;
   nsresult rv = history->CanAddURI(aURI, &canAdd);
   NS_ENSURE_SUCCESS(rv, rv);
   if (!canAdd) {
--- a/toolkit/components/places/src/Makefile.in
+++ b/toolkit/components/places/src/Makefile.in
@@ -93,9 +93,11 @@ EXTRA_JS_MODULES = \
   PlacesDBUtils.jsm \
   utils.js \
   $(NULL)
 
 EXTRA_PP_JS_MODULES = \
   PlacesUtils.jsm \
   $(NULL)
 
+include $(topsrcdir)/config/config.mk
+include $(topsrcdir)/ipc/chromium/chromium-config.mk
 include $(topsrcdir)/config/rules.mk