Bug 1129040 - Provide a way for content processes to query the chrome side blocklist service. r=billm
☠☠ backed out by 9a449959c891 ☠ ☠
authorJim Mathies <jmathies@mozilla.com>
Wed, 29 Apr 2015 06:33:09 -0500
changeset 241577 61b5398161f386ee27fe3d1493d02ef108407554
parent 241576 c0a9dd81198aeeea8e5d1099ef5a7d53b35060ae
child 241578 a8aa5f3c1c1460c04b43fef585fea80adf17db8e
push id28665
push userkwierso@gmail.com
push dateWed, 29 Apr 2015 23:43:43 +0000
treeherdermozilla-central@a86ed85747d8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbillm
bugs1129040
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1129040 - Provide a way for content processes to query the chrome side blocklist service. r=billm
dom/ipc/ContentParent.cpp
dom/ipc/ContentParent.h
dom/ipc/PContent.ipdl
dom/plugins/base/nsPluginHost.cpp
dom/plugins/base/nsPluginHost.h
dom/plugins/base/nsPluginTags.cpp
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -155,16 +155,19 @@
 #include "nsIWebBrowserChrome.h"
 #include "nsIDocShell.h"
 #include "mozilla/net/NeckoMessageUtils.h"
 #include "gfxPrefs.h"
 #include "prio.h"
 #include "private/pprio.h"
 #include "ContentProcessManager.h"
 #include "mozilla/psm/PSMContentListener.h"
+#include "nsPluginHost.h"
+#include "nsPluginTags.h"
+#include "nsIBlocklistService.h"
 
 #include "nsIBidiKeyboard.h"
 
 #if defined(ANDROID) || defined(LINUX)
 #include "nsSystemInfo.h"
 #endif
 
 #if defined(XP_LINUX)
@@ -1078,16 +1081,35 @@ ContentParent::RecvConnectPluginBridge(c
     // We don't need to get the run ID for the plugin, since we already got it
     // in the first call to SetupBridge in RecvLoadPlugin, so we pass in a dummy
     // pointer and just throw it away.
     uint32_t dummy = 0;
     return mozilla::plugins::SetupBridge(aPluginId, this, true, aRv, &dummy);
 }
 
 bool
+ContentParent::RecvGetBlocklistState(const uint32_t& aPluginId,
+                                     uint32_t* aState)
+{
+    *aState = nsIBlocklistService::STATE_BLOCKED;
+
+    nsRefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
+    if (!pluginHost) {
+        return false;
+    }
+    nsPluginTag* tag =  pluginHost->PluginWithId(aPluginId);
+
+    if (!tag) {
+        return false;
+    }
+
+    return NS_SUCCEEDED(tag->GetBlocklistState(aState));
+}
+
+bool
 ContentParent::RecvFindPlugins(const uint32_t& aPluginEpoch,
                                nsTArray<PluginTag>* aPlugins,
                                uint32_t* aNewPluginEpoch)
 {
     return mozilla::plugins::FindPluginsForContent(aPluginEpoch, aPlugins, aNewPluginEpoch);
 }
 
 /*static*/ TabParent*
--- a/dom/ipc/ContentParent.h
+++ b/dom/ipc/ContentParent.h
@@ -168,16 +168,17 @@ public:
     virtual bool RecvCreateGMPService() override;
     virtual bool RecvGetGMPPluginVersionForAPI(const nsCString& aAPI,
                                                nsTArray<nsCString>&& aTags,
                                                bool* aHasPlugin,
                                                nsCString* aVersion) override;
 
     virtual bool RecvLoadPlugin(const uint32_t& aPluginId, nsresult* aRv, uint32_t* aRunID) override;
     virtual bool RecvConnectPluginBridge(const uint32_t& aPluginId, nsresult* aRv) override;
+    virtual bool RecvGetBlocklistState(const uint32_t& aPluginId, uint32_t* aIsBlocklisted) override;
     virtual bool RecvFindPlugins(const uint32_t& aPluginEpoch,
                                  nsTArray<PluginTag>* aPlugins,
                                  uint32_t* aNewPluginEpoch) override;
 
     NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(ContentParent, nsIObserver)
 
     NS_DECL_CYCLE_COLLECTING_ISUPPORTS
     NS_DECL_NSIOBSERVER
--- a/dom/ipc/PContent.ipdl
+++ b/dom/ipc/PContent.ipdl
@@ -695,16 +695,21 @@ parent:
      * This call is used by asynchronous plugin instantiation to notify the
      * content parent that it is now safe to initiate the plugin bridge for
      * the specified plugin id. When this call returns, the requested bridge
      * connection has been made.
      */
     sync ConnectPluginBridge(uint32_t aPluginId) returns (nsresult rv);
 
     /**
+     * Return the current blocklist state for a particular plugin.
+     */
+    sync GetBlocklistState(uint32_t aPluginId) returns (uint32_t aState);
+
+    /**
      * This call returns the set of plugins loaded in the chrome
      * process. However, in many cases this set will not have changed since the
      * last FindPlugins message. Consequently, the chrome process increments an
      * epoch number every time the set of plugins changes. The content process
      * sends up the last epoch it observed. If the epochs are the same, the
      * chrome process returns no plugins. Otherwise it returns a complete list.
      *
      * |pluginEpoch| is the epoch last observed by the content
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -105,16 +105,18 @@
 #include <android/log.h>
 #define LOG(args...)  __android_log_print(ANDROID_LOG_INFO, "GeckoPlugins" , ## args)
 #endif
 
 #if MOZ_CRASHREPORTER
 #include "nsExceptionHandler.h"
 #endif
 
+#include "npapi.h"
+
 using namespace mozilla;
 using mozilla::TimeStamp;
 using mozilla::plugins::PluginTag;
 using mozilla::plugins::PluginAsyncSurrogate;
 
 // Null out a strong ref to a linked list iteratively to avoid
 // exhausting the stack (bug 486349).
 #define NS_ITERATIVE_UNREF_LIST(type_, list_, mNext_)                \
@@ -1049,17 +1051,16 @@ nsPluginHost::GetBlocklistStateForType(c
                                        uint32_t aExcludeFlags,
                                        uint32_t *aState)
 {
   nsCOMPtr<nsIPluginTag> tag;
   nsresult rv = GetPluginTagForType(aMimeType,
                                     aExcludeFlags,
                                     getter_AddRefs(tag));
   NS_ENSURE_SUCCESS(rv, rv);
-
   return tag->GetBlocklistState(aState);
 }
 
 NS_IMETHODIMP
 nsPluginHost::GetPermissionStringForType(const nsACString &aMimeType,
                                          uint32_t aExcludeFlags,
                                          nsACString &aPermissionString)
 {
--- a/dom/plugins/base/nsPluginHost.h
+++ b/dom/plugins/base/nsPluginHost.h
@@ -6,17 +6,16 @@
 #ifndef nsPluginHost_h_
 #define nsPluginHost_h_
 
 #include "nsIPluginHost.h"
 #include "nsIObserver.h"
 #include "nsCOMPtr.h"
 #include "prlink.h"
 #include "prclist.h"
-#include "npapi.h"
 #include "nsIPluginTag.h"
 #include "nsPluginsDir.h"
 #include "nsPluginDirServiceProvider.h"
 #include "nsAutoPtr.h"
 #include "nsWeakPtr.h"
 #include "nsIPrompt.h"
 #include "nsWeakReference.h"
 #include "MainThreadUtils.h"
@@ -25,16 +24,17 @@
 #include "nsITimer.h"
 #include "nsPluginTags.h"
 #include "nsPluginPlayPreviewInfo.h"
 #include "nsIEffectiveTLDService.h"
 #include "nsIIDNService.h"
 #include "nsCRT.h"
 
 #ifdef XP_WIN
+#include <minwindef.h>
 #include "nsIWindowsRegKey.h"
 #endif
 
 namespace mozilla {
 namespace plugins {
 class PluginAsyncSurrogate;
 class PluginTag;
 } // namespace mozilla
@@ -47,16 +47,20 @@ class nsPluginNativeWindow;
 class nsObjectLoadingContent;
 class nsPluginInstanceOwner;
 class nsPluginUnloadRunnable;
 class nsNPAPIPluginInstance;
 class nsNPAPIPluginStreamListener;
 class nsIPluginInstanceOwner;
 class nsIInputStream;
 class nsIStreamListener;
+#ifndef npapi_h_
+struct _NPP;
+typedef _NPP* NPP;
+#endif
 
 class nsInvalidPluginTag : public nsISupports
 {
   virtual ~nsInvalidPluginTag();
 public:
   explicit nsInvalidPluginTag(const char* aFullPath, int64_t aLastModifiedTime = 0);
 
   NS_DECL_ISUPPORTS
--- a/dom/plugins/base/nsPluginTags.cpp
+++ b/dom/plugins/base/nsPluginTags.cpp
@@ -15,16 +15,17 @@
 #include "nsIPlatformCharset.h"
 #include "nsPluginLogging.h"
 #include "nsNPAPIPlugin.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/unused.h"
 #include <cctype>
 #include "mozilla/dom/EncodingUtils.h"
+#include "mozilla/dom/ContentChild.h"
 
 using mozilla::dom::EncodingUtils;
 using namespace mozilla;
 
 // These legacy flags are used in the plugin registry. The states are now
 // stored in prefs, but we still need to be able to import them.
 #define NS_PLUGIN_FLAG_ENABLED      0x0001    // is this plugin enabled?
 // no longer used                   0x0002    // reuse only if regenerating pluginreg.dat
@@ -640,37 +641,43 @@ void nsPluginTag::ImportFlagsToPrefs(uin
 NS_IMETHODIMP
 nsPluginTag::GetBlocklistState(uint32_t *aResult)
 {
   if (mCachedBlocklistStateValid) {
     *aResult = mCachedBlocklistState;
     return NS_OK;
   }
 
-  nsCOMPtr<nsIBlocklistService> blocklist =
-    do_GetService("@mozilla.org/extensions/blocklist;1");
+  if (XRE_GetProcessType() != GeckoProcessType_Default) {
+    *aResult = nsIBlocklistService::STATE_BLOCKED;
+    dom::ContentChild* cp = dom::ContentChild::GetSingleton();
+    if (!cp->SendGetBlocklistState(mId, aResult)) {
+      return NS_OK;
+    }
+  } else {
+    nsCOMPtr<nsIBlocklistService> blocklist =
+      do_GetService("@mozilla.org/extensions/blocklist;1");
 
-  if (!blocklist) {
-    *aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
-    return NS_OK;
+    if (!blocklist) {
+      *aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
+      return NS_OK;
+    }
+
+    // The EmptyString()s are so we use the currently running application
+    // and toolkit versions
+    if (NS_FAILED(blocklist->GetPluginBlocklistState(this, EmptyString(),
+                                                     EmptyString(), aResult))) {
+      *aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
+      return NS_OK;
+    }
   }
 
-  // The EmptyString()s are so we use the currently running application
-  // and toolkit versions
-  uint32_t state;
-  if (NS_FAILED(blocklist->GetPluginBlocklistState(this, EmptyString(),
-                                                   EmptyString(), &state))) {
-    *aResult = nsIBlocklistService::STATE_NOT_BLOCKED;
-    return NS_OK;
-  }
-
-  MOZ_ASSERT(state <= UINT16_MAX);
-  mCachedBlocklistState = (uint16_t) state;
+  MOZ_ASSERT(*aResult <= UINT16_MAX);
+  mCachedBlocklistState = (uint16_t) *aResult;
   mCachedBlocklistStateValid = true;
-  *aResult = state;
   return NS_OK;
 }
 
 bool
 nsPluginTag::HasMimeType(const nsACString & aMimeType) const
 {
   return mMimeTypes.Contains(aMimeType,
                              nsCaseInsensitiveCStringArrayComparator());