Bug 813828 - Allow chrome code to launch Web Activities [r=mounir]

This commit is contained in:
Fabrice Desré 2012-11-21 15:36:49 -08:00
parent 2b7994071a
commit e29652bb1f

View File

@ -7,6 +7,7 @@
#include "nsContentUtils.h"
#include "nsIDOMActivityOptions.h"
#include "nsEventStateManager.h"
#include "nsIConsoleService.h"
using namespace mozilla::dom;
@ -52,11 +53,23 @@ Activity::Initialize(nsISupports* aOwner,
Init(window);
if (!nsEventStateManager::IsHandlingUserInput()) {
nsCOMPtr<nsIDocument> document = do_QueryInterface(window->GetExtantDocument());
if (!nsEventStateManager::IsHandlingUserInput() &&
!nsContentUtils::IsChromeDoc(document)) {
nsCOMPtr<nsIDOMRequestService> rs =
do_GetService("@mozilla.org/dom/dom-request-service;1");
rs->FireErrorAsync(static_cast<DOMRequest*>(this),
NS_LITERAL_STRING("NotUserInput"));
nsCOMPtr<nsIConsoleService> console(
do_GetService("@mozilla.org/consoleservice;1"));
NS_ENSURE_TRUE(console, NS_OK);
nsString message =
NS_LITERAL_STRING("Can start activity from non user input or chrome code");
console->LogStringMessage(message.get());
return NS_OK;
}