Bug 1254865 - Send disableglobalhistory state down to TabChild after construction asynchronously. r=smaug
authorMike Conley <mconley@mozilla.com>
Wed, 23 Mar 2016 14:39:28 -0400
changeset 290719 ae25970e4fc50be6e55daae6b28f8330b35a35e6
parent 290703 073bbd96f75766ec2843bb905da2f7d1f0eaa0d2
child 290720 f7affb27ef92a63b22e23b4f8703917a0e744cd2
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1254865
milestone48.0a1
Bug 1254865 - Send disableglobalhistory state down to TabChild after construction asynchronously. r=smaug disableglobalhistory is an attribute that we support on <xul:browser> that can be used to signal to the underlying DocShell whether or not it should record visits in global history. This patch adds support for this attribute by detecting it at the time that the TabParent is bound to the browser, and then sending the presence of the attribute to the TabChild, which then sets the state in its DocShell. MozReview-Commit-ID: 9miKtdotTho
dom/base/nsGkAtomList.h
dom/ipc/ContentParent.cpp
dom/ipc/PBrowser.ipdl
dom/ipc/TabChild.cpp
dom/ipc/TabChild.h
dom/ipc/TabParent.cpp
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -301,16 +301,17 @@ GK_ATOM(dialog, "dialog")
 GK_ATOM(difference, "difference")
 GK_ATOM(digit, "digit")
 GK_ATOM(dir, "dir")
 GK_ATOM(dirAutoSetBy, "dirAutoSetBy")
 GK_ATOM(directionality, "directionality")
 GK_ATOM(directory, "directory")
 GK_ATOM(disableOutputEscaping, "disable-output-escaping")
 GK_ATOM(disabled, "disabled")
+GK_ATOM(disableglobalhistory, "disableglobalhistory")
 GK_ATOM(disablehistory, "disablehistory")
 GK_ATOM(display, "display")
 GK_ATOM(displayMode, "display-mode")
 GK_ATOM(distinct, "distinct")
 GK_ATOM(div, "div")
 GK_ATOM(dl, "dl")
 GK_ATOM(doctypePublic, "doctype-public")
 GK_ATOM(doctypeSystem, "doctype-system")
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -1185,28 +1185,30 @@ ContentParent::CreateBrowserOrApp(const 
       }
 
       if (tabId == 0) {
         return nullptr;
       }
       RefPtr<TabParent> tp(new TabParent(constructorSender, tabId,
                                          aContext, chromeFlags));
       tp->SetInitedByParent();
-      tp->SetOwnerElement(aFrameElement);
 
       PBrowserParent* browser =
       constructorSender->SendPBrowserConstructor(
         // DeallocPBrowserParent() releases this ref.
         tp.forget().take(), tabId,
         aContext.AsIPCTabContext(),
         chromeFlags,
         constructorSender->ChildID(),
         constructorSender->IsForApp(),
         constructorSender->IsForBrowser());
-      return TabParent::GetFrom(browser);
+
+      RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
+      constructedTabParent->SetOwnerElement(aFrameElement);
+      return constructedTabParent;
     }
     return nullptr;
   }
 
   // If we got here, we have an app and we're not a browser element.  ownApp
   // shouldn't be null, because we otherwise would have gone into the
   // !HasOwnApp() branch above.
   RefPtr<nsIContentParent> parent;
@@ -1294,27 +1296,31 @@ ContentParent::CreateBrowserOrApp(const 
   if (!parent || (tabId == 0)) {
     return nullptr;
   }
 
   uint32_t chromeFlags = 0;
 
   RefPtr<TabParent> tp = new TabParent(parent, tabId, aContext, chromeFlags);
   tp->SetInitedByParent();
-  tp->SetOwnerElement(aFrameElement);
   PBrowserParent* browser = parent->SendPBrowserConstructor(
     // DeallocPBrowserParent() releases this ref.
     RefPtr<TabParent>(tp).forget().take(),
     tabId,
     aContext.AsIPCTabContext(),
     chromeFlags,
     parent->ChildID(),
     parent->IsForApp(),
     parent->IsForBrowser());
 
+  if (browser) {
+    RefPtr<TabParent> constructedTabParent = TabParent::GetFrom(browser);
+    constructedTabParent->SetOwnerElement(aFrameElement);
+  }
+
   if (isInContentProcess) {
     // Just return directly without the following check in content process.
     return TabParent::GetFrom(browser);
   }
 
   if (!browser) {
     // We failed to actually start the PBrowser.  This can happen if the
     // other process has already died.
--- a/dom/ipc/PBrowser.ipdl
+++ b/dom/ipc/PBrowser.ipdl
@@ -720,16 +720,23 @@ child:
 
     /**
      * Propagate a refresh to the child process
      */
     async AudioChannelChangeNotification(uint32_t aAudioChannel,
                                          float aVolume,
                                          bool aMuted);
 
+    /**
+     * Tells the root child docShell whether or not to use
+     * global history. This is sent right after the PBrowser
+     * is bound to a frameloader element.
+     */
+    async SetUseGlobalHistory(bool aUse);
+
 /*
  * FIXME: write protocol!
 
 state LIVE:
     send LoadURL goto LIVE;
 //etc.
     send Destroy goto DYING;
 
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -2346,16 +2346,30 @@ TabChild::RecvAudioChannelChangeNotifica
                                   static_cast<AudioChannel>(aAudioChannel),
                                   aMuted);
   }
 
   return true;
 }
 
 bool
+TabChild::RecvSetUseGlobalHistory(const bool& aUse)
+{
+  nsCOMPtr<nsIDocShell> docShell = do_GetInterface(WebNavigation());
+  MOZ_ASSERT(docShell);
+
+  nsresult rv = docShell->SetUseGlobalHistory(aUse);
+  if (NS_FAILED(rv)) {
+    NS_WARNING("Failed to set UseGlobalHistory on TabChild docShell");
+  }
+
+  return true;
+}
+
+bool
 TabChild::RecvDestroy()
 {
   MOZ_ASSERT(mDestroyed == false);
   mDestroyed = true;
 
   nsTArray<PContentPermissionRequestChild*> childArray =
       nsContentPermissionUtils::GetContentPermissionRequestChildById(GetTabId());
 
--- a/dom/ipc/TabChild.h
+++ b/dom/ipc/TabChild.h
@@ -568,16 +568,18 @@ public:
   virtual bool RecvHandleAccessKey(nsTArray<uint32_t>&& aCharCodes,
                                    const bool& aIsTrusted,
                                    const int32_t& aModifierMask) override;
 
   virtual bool RecvAudioChannelChangeNotification(const uint32_t& aAudioChannel,
                                                   const float& aVolume,
                                                   const bool& aMuted) override;
 
+  virtual bool RecvSetUseGlobalHistory(const bool& aUse) override;
+
   /**
    * Native widget remoting protocol for use with windowed plugins with e10s.
    */
   PPluginWidgetChild* AllocPPluginWidgetChild() override;
 
   bool DeallocPPluginWidgetChild(PPluginWidgetChild* aActor) override;
 
   nsresult CreatePluginWidget(nsIWidget* aParent, nsIWidget** aOut);
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -367,16 +367,22 @@ TabParent::SetOwnerElement(Element* aEle
 
   // Update to the new content, and register to listen for events from it.
   mFrameElement = aElement;
 
   if (newTopLevelWin && !isSameTopLevelWin) {
     newTopLevelWin->AddBrowser(this);
   }
 
+  if (mFrameElement) {
+    bool useGlobalHistory =
+      !mFrameElement->HasAttr(kNameSpaceID_None, nsGkAtoms::disableglobalhistory);
+    Unused << SendSetUseGlobalHistory(useGlobalHistory);
+  }
+
   AddWindowListeners();
   TryCacheDPIAndScale();
 }
 
 void
 TabParent::AddWindowListeners()
 {
   if (mFrameElement && mFrameElement->OwnerDoc()) {