зеркало из https://github.com/mozilla/pjs.git
Merge the latest green changeset on mozilla-central to mozilla-inbound
This commit is contained in:
Коммит
5168f24356
|
@ -46,6 +46,27 @@
|
|||
#
|
||||
topsrcdir=$1
|
||||
|
||||
abspath() {
|
||||
if uname -s | grep -q MINGW; then
|
||||
# We have no way to figure out whether we're in gmake or pymake right
|
||||
# now. gmake gives us Unix-style paths while pymake gives us Windows-style
|
||||
# paths, so attempt to handle both.
|
||||
regexes='^\([A-Za-z]:\|\\\\\|\/\) ^\/'
|
||||
else
|
||||
regexes='^\/'
|
||||
fi
|
||||
|
||||
for regex in $regexes; do
|
||||
if echo $1 | grep -q $regex; then
|
||||
echo $1
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
# If we're at this point, we have a relative path
|
||||
echo `pwd`/$1
|
||||
}
|
||||
|
||||
for _config in "$MOZCONFIG" \
|
||||
"$MOZ_MYCONFIG"
|
||||
do
|
||||
|
@ -66,7 +87,7 @@ for _config in "$MOZCONFIG" \
|
|||
"$HOME/.mozmyconfig.sh"
|
||||
do
|
||||
if test -f "$_config"; then
|
||||
echo "$_config";
|
||||
echo `abspath $_config`
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
|
|
@ -42,6 +42,8 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
NO_PROFILE_GUIDED_OPTIMIZE = 1
|
||||
|
||||
ifdef ENABLE_TESTS
|
||||
|
||||
ifdef _MSC_VER
|
||||
|
|
|
@ -215,6 +215,14 @@
|
|||
|
||||
#include "nsPluginError.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsContentErrors.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsITimedChannel.h"
|
||||
|
||||
static NS_DEFINE_CID(kDOMScriptObjectFactoryCID,
|
||||
NS_DOM_SCRIPT_OBJECT_FACTORY_CID);
|
||||
|
@ -225,15 +233,6 @@ static NS_DEFINE_CID(kAppShellCID, NS_APPSHELL_CID);
|
|||
#define DEBUG_PAGE_CACHE
|
||||
#endif
|
||||
|
||||
#include "nsContentErrors.h"
|
||||
#include "nsIChannelPolicy.h"
|
||||
#include "nsIContentSecurityPolicy.h"
|
||||
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
#include "nsDOMNavigationTiming.h"
|
||||
#include "nsITimedChannel.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
// Number of documents currently loading
|
||||
|
@ -922,7 +921,8 @@ NS_IMETHODIMP nsDocShell::GetInterface(const nsIID & aIID, void **aSink)
|
|||
*aSink = mScriptGlobal;
|
||||
}
|
||||
else if ((aIID.Equals(NS_GET_IID(nsPIDOMWindow)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIDOMWindow))) &&
|
||||
aIID.Equals(NS_GET_IID(nsIDOMWindow)) ||
|
||||
aIID.Equals(NS_GET_IID(nsIDOMWindowInternal))) &&
|
||||
NS_SUCCEEDED(EnsureScriptEnvironment())) {
|
||||
return mScriptGlobal->QueryInterface(aIID, aSink);
|
||||
}
|
||||
|
|
|
@ -262,6 +262,7 @@ using mozilla::TimeDuration;
|
|||
|
||||
nsIDOMStorageList *nsGlobalWindow::sGlobalStorageList = nsnull;
|
||||
nsGlobalWindow::WindowByIdTable *nsGlobalWindow::sWindowsById = nsnull;
|
||||
bool nsGlobalWindow::sWarnedAboutWindowInternal = false;
|
||||
|
||||
static nsIEntropyCollector *gEntropyCollector = nsnull;
|
||||
static PRInt32 gRefCnt = 0;
|
||||
|
@ -1348,6 +1349,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsGlobalWindow)
|
|||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIScriptGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMWindow)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMJSWindow)
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMWindowInternal))) {
|
||||
foundInterface = static_cast<nsIDOMWindowInternal*>(this);
|
||||
if (!sWarnedAboutWindowInternal) {
|
||||
sWarnedAboutWindowInternal = true;
|
||||
nsContentUtils::ReportToConsole(nsContentUtils::eDOM_PROPERTIES,
|
||||
"nsIDOMWindowInternalWarning",
|
||||
nsnull, 0, nsnull, EmptyString(), 0, 0,
|
||||
nsIScriptError::warningFlag,
|
||||
"Extensions", mWindowID);
|
||||
}
|
||||
} else
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScriptGlobalObject)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIScriptObjectPrincipal)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMEventTarget)
|
||||
|
@ -4926,8 +4938,7 @@ nsGlobalWindow::Focus()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIDOMWindow *caller =
|
||||
static_cast<nsIDOMWindow*>(nsContentUtils::GetWindowFromCaller());
|
||||
nsIDOMWindow *caller = nsContentUtils::GetWindowFromCaller();
|
||||
nsCOMPtr<nsIDOMWindow> opener;
|
||||
GetOpener(getter_AddRefs(opener));
|
||||
|
||||
|
|
|
@ -967,6 +967,7 @@ protected:
|
|||
static nsIDOMStorageList* sGlobalStorageList;
|
||||
|
||||
static WindowByIdTable* sWindowsById;
|
||||
static bool sWarnedAboutWindowInternal;
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -80,10 +80,10 @@ class nsIArray;
|
|||
class nsPIWindowRoot;
|
||||
|
||||
#define NS_PIDOMWINDOW_IID \
|
||||
{ 0x1bfacc26, 0xad77, 0x42bb, \
|
||||
{ 0xb9, 0xbb, 0xa0, 0x19, 0xc8, 0x27, 0x5c, 0x0e } }
|
||||
{ 0xeee816d2, 0x2f08, 0x4b34, \
|
||||
{ 0x97, 0x47, 0x5e, 0x5a, 0xcd, 0xc3, 0x56, 0xfa } }
|
||||
|
||||
class nsPIDOMWindow : public nsIDOMWindow
|
||||
class nsPIDOMWindow : public nsIDOMWindowInternal
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_PIDOMWINDOW_IID)
|
||||
|
|
|
@ -42,10 +42,6 @@
|
|||
interface nsIIDBRequest;
|
||||
interface nsIVariant;
|
||||
|
||||
%{C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* IDBCursor interface. See
|
||||
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBCursor for more
|
||||
|
|
|
@ -46,10 +46,6 @@ interface nsIIDBTransaction;
|
|||
interface nsIDOMDOMStringList;
|
||||
interface nsIDOMEventListener;
|
||||
|
||||
%{C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* IDBDatabase interface. See
|
||||
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBDatabase
|
||||
|
|
|
@ -44,10 +44,6 @@ interface nsIIDBKeyRange;
|
|||
interface nsIIDBRequest;
|
||||
interface nsIVariant;
|
||||
|
||||
%{C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* Interface that defines the indexedDB property on a window. See
|
||||
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBFactory
|
||||
|
|
|
@ -46,10 +46,6 @@ interface nsIIDBTransaction;
|
|||
interface nsIVariant;
|
||||
interface nsIDOMDOMStringList;
|
||||
|
||||
%{C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* nsIIDBObjectStore interface. See
|
||||
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-nsIIDBObjectStore
|
||||
|
|
|
@ -41,10 +41,6 @@
|
|||
|
||||
#include "domstubs.idl"
|
||||
|
||||
%{ C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
interface nsIAnimationFrameListener;
|
||||
interface nsIControllers;
|
||||
interface nsIDOMBlob;
|
||||
|
@ -448,3 +444,10 @@ interface nsIDOMWindowPerformance : nsISupports
|
|||
*/
|
||||
readonly attribute nsIDOMPerformance performance;
|
||||
};
|
||||
|
||||
/**
|
||||
* Empty interface for compatibility with older versions.
|
||||
* @deprecated Use nsIDOMWindow instead
|
||||
*/
|
||||
[scriptable, uuid(8614bdb7-5b07-4d00-a7ba-4d44697a343d)]
|
||||
interface nsIDOMWindowInternal : nsIDOMWindow {};
|
||||
|
|
|
@ -38,10 +38,6 @@
|
|||
|
||||
#include "nsIDOMEvent.idl"
|
||||
|
||||
%{ C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* The nsIDOMMessageEvent interface is used for server-sent events and for
|
||||
* cross-domain messaging.
|
||||
|
|
|
@ -40,10 +40,6 @@
|
|||
#include "nsIDOMEvent.idl"
|
||||
#include "nsIVariant.idl"
|
||||
|
||||
%{ C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
[scriptable, uuid(6250652d-7a6a-49a4-a2ee-9114e1e83427)]
|
||||
interface nsIDOMNotifyAudioAvailableEvent : nsIDOMEvent
|
||||
{
|
||||
|
|
|
@ -39,10 +39,6 @@
|
|||
|
||||
#include "nsIDOMDocument.idl"
|
||||
|
||||
%{C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* The nsIDOMHTMLDocument interface is the interface to a [X]HTML
|
||||
* document object.
|
||||
|
|
|
@ -42,10 +42,6 @@ interface nsIInputStream;
|
|||
interface nsIOutputStream;
|
||||
interface nsIScriptGlobalObject;
|
||||
|
||||
%{ C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
[ptr] native JSValPtr(jsval);
|
||||
[ptr] native JSContext(JSContext);
|
||||
|
||||
|
|
|
@ -108,6 +108,6 @@ IsSupportedWarning=Use of attributes' isSupported() is deprecated.
|
|||
IsEqualNodeWarning=Use of attributes' isEqualNode() is deprecated.
|
||||
TextContentWarning=Use of attributes' textContent attribute is deprecated. Use value instead.
|
||||
EnablePrivilegeWarning=Use of enablePrivilege is deprecated. Please use code that runs with the system principal (e.g. an extension) instead.
|
||||
|
||||
nsIJSONDecodeDeprecatedWarning=nsIJSON.decode is deprecated. Please use JSON.parse instead.
|
||||
nsIJSONEncodeDeprecatedWarning=nsIJSON.encode is deprecated. Please use JSON.stringify instead.
|
||||
nsIDOMWindowInternalWarning=Use of nsIDOMWindowInternal is deprecated. Use nsIDOMWindow instead.
|
||||
|
|
|
@ -64,6 +64,22 @@
|
|||
|
||||
using namespace mozilla;
|
||||
|
||||
class UpdateDictionnaryHolder {
|
||||
private:
|
||||
nsEditorSpellCheck* mSpellCheck;
|
||||
public:
|
||||
UpdateDictionnaryHolder(nsEditorSpellCheck* esc): mSpellCheck(esc) {
|
||||
if (mSpellCheck) {
|
||||
mSpellCheck->BeginUpdateDictionary();
|
||||
}
|
||||
}
|
||||
~UpdateDictionnaryHolder() {
|
||||
if (mSpellCheck) {
|
||||
mSpellCheck->EndUpdateDictionary();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsEditorSpellCheck)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsEditorSpellCheck)
|
||||
|
||||
|
@ -80,6 +96,8 @@ NS_IMPL_CYCLE_COLLECTION_2(nsEditorSpellCheck,
|
|||
nsEditorSpellCheck::nsEditorSpellCheck()
|
||||
: mSuggestedWordIndex(0)
|
||||
, mDictionaryIndex(0)
|
||||
, mUpdateDictionaryRunning(PR_FALSE)
|
||||
, mDictWasSetManually(PR_FALSE)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -360,31 +378,22 @@ nsEditorSpellCheck::GetDictionaryList(PRUnichar ***aDictionaryList, PRUint32 *aC
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::GetCurrentDictionary(PRUnichar **aDictionary)
|
||||
nsEditorSpellCheck::GetCurrentDictionary(nsAString& aDictionary)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
NS_ENSURE_TRUE(aDictionary, NS_ERROR_NULL_POINTER);
|
||||
|
||||
*aDictionary = 0;
|
||||
|
||||
nsAutoString dictStr;
|
||||
nsresult rv = mSpellChecker->GetCurrentDictionary(dictStr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
*aDictionary = ToNewUnicode(dictStr);
|
||||
|
||||
return rv;
|
||||
return mSpellChecker->GetCurrentDictionary(aDictionary);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::SetCurrentDictionary(const PRUnichar *aDictionary)
|
||||
nsEditorSpellCheck::SetCurrentDictionary(const nsAString& aDictionary)
|
||||
{
|
||||
NS_ENSURE_TRUE(mSpellChecker, NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
NS_ENSURE_TRUE(aDictionary, NS_ERROR_NULL_POINTER);
|
||||
|
||||
return mSpellChecker->SetCurrentDictionary(nsDependentString(aDictionary));
|
||||
if (!mUpdateDictionaryRunning) {
|
||||
mDictWasSetManually = PR_TRUE;
|
||||
}
|
||||
return mSpellChecker->SetCurrentDictionary(aDictionary);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -400,22 +409,19 @@ nsEditorSpellCheck::UninitSpellChecker()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Save the last used dictionary to the user's preferences.
|
||||
// Save the last set dictionary to the user's preferences.
|
||||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::SaveDefaultDictionary()
|
||||
{
|
||||
PRUnichar *dictName = nsnull;
|
||||
nsresult rv = GetCurrentDictionary(&dictName);
|
||||
|
||||
if (NS_SUCCEEDED(rv) && dictName && *dictName) {
|
||||
rv = Preferences::SetString("spellchecker.dictionary", dictName);
|
||||
if (!mDictWasSetManually) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (dictName) {
|
||||
nsMemory::Free(dictName);
|
||||
}
|
||||
nsAutoString dictName;
|
||||
nsresult rv = GetCurrentDictionary(dictName);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return rv;
|
||||
return Preferences::SetString("spellchecker.dictionary", dictName);
|
||||
}
|
||||
|
||||
|
||||
|
@ -438,8 +444,14 @@ nsEditorSpellCheck::DeleteSuggestedWordList()
|
|||
NS_IMETHODIMP
|
||||
nsEditorSpellCheck::UpdateCurrentDictionary(nsIEditor* aEditor)
|
||||
{
|
||||
if (mDictWasSetManually) { // user has set dictionary manually; we better not change it.
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
|
||||
UpdateDictionnaryHolder holder(this);
|
||||
|
||||
// Tell the spellchecker what dictionary to use:
|
||||
nsAutoString dictName;
|
||||
|
||||
|
@ -492,10 +504,10 @@ nsEditorSpellCheck::UpdateCurrentDictionary(nsIEditor* aEditor)
|
|||
}
|
||||
}
|
||||
|
||||
SetCurrentDictionary(NS_LITERAL_STRING("").get());
|
||||
SetCurrentDictionary(EmptyString());
|
||||
|
||||
if (NS_SUCCEEDED(rv) && !dictName.IsEmpty()) {
|
||||
rv = SetCurrentDictionary(dictName.get());
|
||||
rv = SetCurrentDictionary(dictName);
|
||||
if (NS_FAILED(rv)) {
|
||||
// required dictionary was not available. Try to get a dictionary
|
||||
// matching at least language part of dictName: If required dictionary is
|
||||
|
@ -505,7 +517,7 @@ nsEditorSpellCheck::UpdateCurrentDictionary(nsIEditor* aEditor)
|
|||
if (dashIdx != -1) {
|
||||
langCode.Assign(Substring(dictName, 0, dashIdx));
|
||||
// try to use langCode
|
||||
rv = SetCurrentDictionary(langCode.get());
|
||||
rv = SetCurrentDictionary(langCode);
|
||||
} else {
|
||||
langCode.Assign(dictName);
|
||||
}
|
||||
|
@ -520,7 +532,7 @@ nsEditorSpellCheck::UpdateCurrentDictionary(nsIEditor* aEditor)
|
|||
for (i = 0; i < count; i++) {
|
||||
nsAutoString dictStr(dictList.ElementAt(i));
|
||||
if (nsStyleUtil::DashMatchCompare(dictStr, langCode, comparator) &&
|
||||
NS_SUCCEEDED(SetCurrentDictionary(dictStr.get()))) {
|
||||
NS_SUCCEEDED(SetCurrentDictionary(dictStr))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -532,15 +544,15 @@ nsEditorSpellCheck::UpdateCurrentDictionary(nsIEditor* aEditor)
|
|||
// lang attribute, we try to get a dictionary. First try, en-US. If it does
|
||||
// not work, pick the first one.
|
||||
if (editorLang.IsEmpty()) {
|
||||
nsAutoString currentDictonary;
|
||||
rv = mSpellChecker->GetCurrentDictionary(currentDictonary);
|
||||
if (NS_FAILED(rv) || currentDictonary.IsEmpty()) {
|
||||
rv = SetCurrentDictionary(NS_LITERAL_STRING("en-US").get());
|
||||
nsAutoString currentDictionary;
|
||||
rv = GetCurrentDictionary(currentDictionary);
|
||||
if (NS_FAILED(rv) || currentDictionary.IsEmpty()) {
|
||||
rv = SetCurrentDictionary(NS_LITERAL_STRING("en-US"));
|
||||
if (NS_FAILED(rv)) {
|
||||
nsTArray<nsString> dictList;
|
||||
rv = mSpellChecker->GetDictionaryList(&dictList);
|
||||
if (NS_SUCCEEDED(rv) && dictList.Length() > 0) {
|
||||
SetCurrentDictionary(dictList[0].get());
|
||||
SetCurrentDictionary(dictList[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,13 @@ protected:
|
|||
nsresult DeleteSuggestedWordList();
|
||||
|
||||
nsCOMPtr<nsITextServicesFilter> mTxtSrvFilter;
|
||||
|
||||
PRPackedBool mUpdateDictionaryRunning;
|
||||
PRPackedBool mDictWasSetManually;
|
||||
|
||||
public:
|
||||
void BeginUpdateDictionary() { mUpdateDictionaryRunning = PR_TRUE ;}
|
||||
void EndUpdateDictionary() { mUpdateDictionaryRunning = PR_FALSE ;}
|
||||
};
|
||||
|
||||
#endif // nsEditorSpellCheck_h___
|
||||
|
|
|
@ -53,6 +53,7 @@ _TEST_FILES = \
|
|||
|
||||
_CHROME_TEST_FILES = \
|
||||
test_bug434998.xul \
|
||||
test_bug338427.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=338427
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 338427</title>
|
||||
<script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=338427">Mozilla Bug 338427</a>
|
||||
<p id="display"></p>
|
||||
<div id="content">
|
||||
<textarea id="editor" lang="testing-XX"></textarea>
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
/** Test for Bug 338427 **/
|
||||
function init() {
|
||||
var textarea = document.getElementById("editor");
|
||||
var editor = textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).editor;
|
||||
var spellchecker = editor.getInlineSpellChecker(true);
|
||||
spellchecker.enableRealTimeSpell = true;
|
||||
|
||||
var list = {}, count = {};
|
||||
spellchecker.spellChecker.GetDictionaryList(list, count);
|
||||
if (count.value === 0) {
|
||||
return; // no dictionary, no test possible
|
||||
}
|
||||
var lang = list.value[0];
|
||||
spellchecker.spellChecker.SetCurrentDictionary(lang);
|
||||
|
||||
textarea.addEventListener("focus", function() {
|
||||
var dictionary = "";
|
||||
try {
|
||||
dictionary = spellchecker.spellChecker.GetCurrentDictionary();
|
||||
} catch(e) {}
|
||||
is(dictionary, lang, "Unexpected spell check dictionary");
|
||||
SimpleTest.finish();
|
||||
}, false);
|
||||
textarea.focus();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addLoadEvent(init);
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -41,7 +41,7 @@
|
|||
interface nsIEditor;
|
||||
interface nsITextServicesFilter;
|
||||
|
||||
[scriptable, uuid(803ff0dd-07f2-4438-b3a6-ab9c2fe4e1dd)]
|
||||
[scriptable, uuid(3da0ce96-7d3a-48d0-80b7-2d90dab09747)]
|
||||
interface nsIEditorSpellCheck : nsISupports
|
||||
{
|
||||
|
||||
|
@ -143,12 +143,12 @@ interface nsIEditorSpellCheck : nsISupports
|
|||
/**
|
||||
* @see nsISpellChecker::GetCurrentDictionary
|
||||
*/
|
||||
wstring GetCurrentDictionary();
|
||||
AString GetCurrentDictionary();
|
||||
|
||||
/**
|
||||
* @see nsISpellChecker::SetCurrentDictionary
|
||||
*/
|
||||
void SetCurrentDictionary(in wstring dictionary);
|
||||
void SetCurrentDictionary(in AString dictionary);
|
||||
|
||||
/**
|
||||
* Call to save the currently selected dictionary as the default. The
|
||||
|
|
|
@ -48,10 +48,6 @@ interface nsIWebBrowserChrome;
|
|||
interface nsIDocShellTreeItem;
|
||||
interface nsIArray;
|
||||
|
||||
%{C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
[uuid(8624594a-28d7-4bc3-8d12-b1c2b9eefd90)]
|
||||
|
||||
interface nsPIWindowWatcher : nsISupports
|
||||
|
|
|
@ -1445,8 +1445,8 @@ mozInlineSpellChecker::ResumeCheck(mozInlineSpellStatus* aStatus)
|
|||
rv = GetSpellCheckSelection(getter_AddRefs(spellCheckSelection));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUnichar *currentDictionary = nsnull;
|
||||
rv = mSpellCheck->GetCurrentDictionary(¤tDictionary);
|
||||
nsAutoString currentDictionary;
|
||||
rv = mSpellCheck->GetCurrentDictionary(currentDictionary);
|
||||
if (NS_FAILED(rv)) {
|
||||
// no active dictionary
|
||||
PRInt32 count;
|
||||
|
@ -1760,31 +1760,22 @@ NS_IMETHODIMP mozInlineSpellChecker::UpdateCurrentDictionary()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PRUnichar *previousDictionary = nsnull;
|
||||
nsDependentString previousDictionaryStr;
|
||||
if (NS_SUCCEEDED(mSpellCheck->GetCurrentDictionary(&previousDictionary))) {
|
||||
previousDictionaryStr.Assign(previousDictionary);
|
||||
nsAutoString previousDictionary;
|
||||
if (NS_FAILED(mSpellCheck->GetCurrentDictionary(previousDictionary))) {
|
||||
previousDictionary.Truncate();
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIEditor> editor (do_QueryReferent(mEditor));
|
||||
nsresult rv = mSpellCheck->UpdateCurrentDictionary(editor);
|
||||
|
||||
PRUnichar *currentDictionary = nsnull;
|
||||
nsDependentString currentDictionaryStr;
|
||||
if (NS_SUCCEEDED(mSpellCheck->GetCurrentDictionary(¤tDictionary))) {
|
||||
currentDictionaryStr.Assign(currentDictionary);
|
||||
nsAutoString currentDictionary;
|
||||
if (NS_FAILED(mSpellCheck->GetCurrentDictionary(currentDictionary))) {
|
||||
currentDictionary.Truncate();
|
||||
}
|
||||
|
||||
if (!previousDictionary || !currentDictionary || !previousDictionaryStr.Equals(currentDictionaryStr)) {
|
||||
if (!previousDictionary.Equals(currentDictionary)) {
|
||||
rv = SpellCheckRange(nsnull);
|
||||
}
|
||||
|
||||
if (previousDictionary) {
|
||||
nsMemory::Free(previousDictionary);
|
||||
}
|
||||
if (currentDictionary) {
|
||||
nsMemory::Free(currentDictionary);
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -2610,25 +2610,6 @@ gfxFontGroup::FindFontForChar(PRUint32 aCh, PRUint32 aPrevCh,
|
|||
*aMatchType = gfxTextRange::kFontGroup;
|
||||
return font.forget();
|
||||
}
|
||||
// check other faces of the family
|
||||
// XXX optimization point: give the family a charmap that is the union
|
||||
// of the char maps of all its faces, so we can quickly test whether
|
||||
// it's worth doing this search
|
||||
gfxFontFamily *family = font->GetFontEntry()->Family();
|
||||
if (family) {
|
||||
FontSearch matchData(aCh, font);
|
||||
family->FindFontForChar(&matchData);
|
||||
gfxFontEntry *fe = matchData.mBestMatch;
|
||||
if (fe) {
|
||||
PRBool needsBold =
|
||||
font->GetStyle()->weight >= 600 && !fe->IsBold();
|
||||
selectedFont =
|
||||
fe->FindOrMakeFont(font->GetStyle(), needsBold);
|
||||
if (selectedFont) {
|
||||
return selectedFont.forget();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if character is in Private Use Area, don't do matching against pref or system fonts
|
||||
|
|
|
@ -550,6 +550,7 @@ var BrowserUI = {
|
|||
FullScreenVideo.init();
|
||||
NewTabPopup.init();
|
||||
CharsetMenu.init();
|
||||
WebappsUI.init();
|
||||
|
||||
// If some add-ons were disabled during during an application update, alert user
|
||||
let addonIDs = AddonManager.getStartupChanges("disabled");
|
||||
|
|
|
@ -1677,13 +1677,102 @@ var CharsetMenu = {
|
|||
|
||||
var WebappsUI = {
|
||||
_dialog: null,
|
||||
_manifest: null,
|
||||
_perms: [],
|
||||
|
||||
_openwebapps: null,
|
||||
_application: null,
|
||||
|
||||
init: function() {
|
||||
Cu.import("resource:///modules/openWebapps.jsm");
|
||||
messageManager.addMessageListener("OpenWebapps:Install", this);
|
||||
messageManager.addMessageListener("OpenWebapps:GetInstalledBy", this);
|
||||
messageManager.addMessageListener("OpenWebapps:AmInstalled", this);
|
||||
messageManager.addMessageListener("OpenWebapps:MgmtLaunch", this);
|
||||
messageManager.addMessageListener("OpenWebapps:MgmtList", this);
|
||||
messageManager.addMessageListener("OpenWebapps:MgmtUninstall", this);
|
||||
},
|
||||
|
||||
// converts a manifest to an application as expected by openwebapps.install()
|
||||
convertManifest: function(aData) {
|
||||
let app = {
|
||||
manifest : JSON.parse(aData.manifest),
|
||||
installData : aData.installData,
|
||||
storeURI : aData.storeURI,
|
||||
manifestURI : aData.manifestURIs,
|
||||
capabilities : [],
|
||||
callbackID : aData.callbackID
|
||||
}
|
||||
|
||||
let chrome = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry).QueryInterface(Ci.nsIToolkitChromeRegistry);
|
||||
let locale = chrome.getSelectedLocale("browser");
|
||||
|
||||
let localeRoot;
|
||||
if (app.manifest.locales)
|
||||
localeRoot = app.manifest.locales[locale];
|
||||
|
||||
if (!localeRoot)
|
||||
localeRoot = app.manifest;
|
||||
|
||||
let baseURI = Services.io.newURI(aData.manifestURI, null, null);
|
||||
app.title = localeRoot.name || app.manifest.name;
|
||||
|
||||
// choose the larger icon
|
||||
let max = 0;
|
||||
let icon;
|
||||
for (let size in app.manifest.icons) {
|
||||
let iSize = parseInt(size);
|
||||
if (iSize > max) {
|
||||
icon = baseURI.resolve(app.manifest.icons[size]);
|
||||
max = iSize;
|
||||
}
|
||||
}
|
||||
if (icon)
|
||||
app.iconURI = icon;
|
||||
|
||||
let root = baseURI.resolve("/").toString();
|
||||
app.appURI = app.manifest.launch_path ? baseURI.resolve(app.manifest.launch_path) : root.substring(0, root.length - 1);
|
||||
|
||||
return app;
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
let browser = aMessage.target;
|
||||
switch(aMessage.name) {
|
||||
case "OpenWebapps:Install":
|
||||
WebappsUI._openwebapps = browser;
|
||||
WebappsUI.show(WebappsUI.convertManifest(aMessage.json));
|
||||
break;
|
||||
case "OpenWebapps:GetInstalledBy":
|
||||
let apps = OpenWebapps.getInstalledBy(aMessage.json.storeURI);
|
||||
browser.messageManager.sendAsyncMessage("OpenWebapps:GetInstalledBy:Return",
|
||||
{ apps: apps, callbackID: aMessage.json.callbackID });
|
||||
break;
|
||||
case "OpenWebapps:AmInstalled":
|
||||
let app = OpenWebapps.amInstalled(aMessage.json.appURI);
|
||||
browser.messageManager.sendAsyncMessage("OpenWebapps:AmInstalled:Return",
|
||||
{ installed: app != null, app: app, callbackID: aMessage.json.callbackID });
|
||||
break;
|
||||
case "OpenWebapps:MgmtList":
|
||||
let list = OpenWebapps.mgmtList();
|
||||
browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtList:Return",
|
||||
{ ok: true, apps: list, callbackID: aMessage.json.callbackID });
|
||||
break;
|
||||
case "OpenWebapps:MgmtLaunch":
|
||||
let res = OpenWebapps.mgmtLaunch(aMessage.json.origin);
|
||||
browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtLaunch:Return",
|
||||
{ ok: res, callbackID: aMessage.json.callbackID });
|
||||
break;
|
||||
case "OpenWebapps:MgmtUninstall":
|
||||
let uninstalled = OpenWebapps.mgmtUninstall(aMessage.json.origin);
|
||||
browser.messageManager.sendAsyncMessage("OpenWebapps:MgmtUninstall:Return",
|
||||
{ ok: uninstalled, callbackID: aMessage.json.callbackID });
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
checkBox: function(aEvent) {
|
||||
let elem = aEvent.originalTarget;
|
||||
let perm = elem.getAttribute("perm");
|
||||
if (this._manifest.capabilities && this._manifest.capabilities.indexOf(perm) != -1) {
|
||||
if (this._application.capabilities && this._application.capabilities.indexOf(perm) != -1) {
|
||||
if (elem.checked) {
|
||||
elem.classList.remove("webapps-noperm");
|
||||
elem.classList.add("webapps-perm");
|
||||
|
@ -1694,8 +1783,10 @@ var WebappsUI = {
|
|||
}
|
||||
},
|
||||
|
||||
show: function show(aManifest) {
|
||||
if (!aManifest) {
|
||||
show: function show(aApplication) {
|
||||
if (!aApplication) {
|
||||
this._openwebapps = null;
|
||||
|
||||
// Try every way to get an icon
|
||||
let browser = Browser.selectedBrowser;
|
||||
let icon = browser.appIcon.href;
|
||||
|
@ -1704,24 +1795,32 @@ var WebappsUI = {
|
|||
if (!icon)
|
||||
icon = gFaviconService.getFaviconImageForPage(browser.currentURI).spec;
|
||||
|
||||
// Create a simple manifest
|
||||
aManifest = {
|
||||
uri: browser.currentURI.spec,
|
||||
name: browser.contentTitle,
|
||||
icon: icon,
|
||||
// Create a simple application object
|
||||
aApplication = {
|
||||
appURI: browser.currentURI.spec,
|
||||
storeURI: browser.currentURI.spec,
|
||||
title: browser.contentTitle,
|
||||
iconURI: icon,
|
||||
capabilities: [],
|
||||
};
|
||||
manifest: {
|
||||
name: browser.contentTitle,
|
||||
launch_path: browser.currentURI.spec,
|
||||
icons: {
|
||||
"64": icon
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._manifest = aManifest;
|
||||
this._application = aApplication;
|
||||
this._dialog = importDialog(window, "chrome://browser/content/webapps.xul", null);
|
||||
|
||||
if (aManifest.name)
|
||||
document.getElementById("webapps-title").value = aManifest.name;
|
||||
if (aManifest.icon)
|
||||
document.getElementById("webapps-icon").src = aManifest.icon;
|
||||
if (aApplication.title)
|
||||
document.getElementById("webapps-title").value = aApplication.title;
|
||||
if (aApplication.iconURI)
|
||||
document.getElementById("webapps-icon").src = aApplication.iconURI;
|
||||
|
||||
let uri = Services.io.newURI(aManifest.uri, null, null);
|
||||
let uri = Services.io.newURI(aApplication.appURI, null, null);
|
||||
|
||||
let perms = [["offline", "offline-app"], ["geoloc", "geo"], ["notifications", "desktop-notification"]];
|
||||
let self = this;
|
||||
|
@ -1729,7 +1828,7 @@ var WebappsUI = {
|
|||
let elem = document.getElementById("webapps-" + tuple[0] + "-checkbox");
|
||||
let currentPerm = Services.perms.testExactPermission(uri, tuple[1]);
|
||||
self._perms[tuple[1]] = (currentPerm == Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
if ((aManifest.capabilities && (aManifest.capabilities.indexOf(tuple[1]) != -1)) || (currentPerm == Ci.nsIPermissionManager.ALLOW_ACTION))
|
||||
if ((aApplication.capabilities && (aApplication.capabilities.indexOf(tuple[1]) != -1)) || (currentPerm == Ci.nsIPermissionManager.ALLOW_ACTION))
|
||||
elem.checked = true;
|
||||
else
|
||||
elem.checked = (currentPerm == Ci.nsIPermissionManager.ALLOW_ACTION);
|
||||
|
@ -1747,11 +1846,18 @@ var WebappsUI = {
|
|||
this._dialog.close();
|
||||
this._dialog = null;
|
||||
BrowserUI.popPopup(this);
|
||||
|
||||
if (this._openwebapps) {
|
||||
let browser = this._openwebapps;
|
||||
browser.messageManager.sendAsyncMessage("OpenWebapps:InstallAborted", { callbackID: this._application.callbackID });
|
||||
}
|
||||
|
||||
this._openwebapps = null;
|
||||
},
|
||||
|
||||
_updatePermission: function updatePermission(aId, aPerm) {
|
||||
try {
|
||||
let uri = Services.io.newURI(this._manifest.uri, null, null);
|
||||
let uri = Services.io.newURI(this._application.appURI, null, null);
|
||||
let currentState = document.getElementById(aId).checked;
|
||||
if (currentState != this._perms[aPerm])
|
||||
Services.perms.add(uri, aPerm, currentState ? Ci.nsIPermissionManager.ALLOW_ACTION : Ci.nsIPermissionManager.DENY_ACTION);
|
||||
|
@ -1765,12 +1871,19 @@ var WebappsUI = {
|
|||
if (!title)
|
||||
return;
|
||||
|
||||
this._application.title = title;
|
||||
|
||||
this._updatePermission("webapps-offline-checkbox", "offline-app");
|
||||
this._updatePermission("webapps-geoloc-checkbox", "geo");
|
||||
this._updatePermission("webapps-notifications-checkbox", "desktop-notification");
|
||||
|
||||
let browser = this._openwebapps;
|
||||
this._openwebapps = null;
|
||||
this.hide();
|
||||
this.install(this._manifest.uri, title, this._manifest.icon);
|
||||
this.install();
|
||||
|
||||
if (browser != null)
|
||||
browser.messageManager.sendAsyncMessage("OpenWebapps:InstallDone", { callbackID: this._application.callbackID });
|
||||
},
|
||||
|
||||
updateWebappsInstall: function updateWebappsInstall(aNode) {
|
||||
|
@ -1779,11 +1892,10 @@ var WebappsUI = {
|
|||
|
||||
let browser = Browser.selectedBrowser;
|
||||
|
||||
let webapp = Cc["@mozilla.org/webapps/support;1"].getService(Ci.nsIWebappsSupport);
|
||||
return !(webapp && webapp.isApplicationInstalled(browser.currentURI.spec));
|
||||
return !(OpenWebapps.amInstalled(browser.currentURI.spec));
|
||||
},
|
||||
|
||||
install: function(aURI, aTitle, aIcon) {
|
||||
install: function(aIconURI) {
|
||||
const kIconSize = 64;
|
||||
|
||||
let canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
|
||||
|
@ -1795,19 +1907,20 @@ var WebappsUI = {
|
|||
canvas.width = canvas.height = kIconSize; // clears the canvas
|
||||
let ctx = canvas.getContext("2d");
|
||||
ctx.drawImage(image, 0, 0, kIconSize, kIconSize);
|
||||
let data = canvas.toDataURL("image/png", "");
|
||||
self._application.iconData = canvas.toDataURL("image/png", "");
|
||||
canvas = null;
|
||||
try {
|
||||
let webapp = Cc["@mozilla.org/webapps/support;1"].getService(Ci.nsIWebappsSupport);
|
||||
webapp.installApplication(aTitle, aURI, aIcon, data);
|
||||
OpenWebapps.install(self._application);
|
||||
} catch(e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
image.onerror = function() {
|
||||
// can't load the icon (bad URI) : fallback to the default one from chrome
|
||||
self.install(aURI, aTitle, "chrome://browser/skin/images/favicon-default-30.png");
|
||||
self.install("chrome://browser/skin/images/favicon-default-30.png");
|
||||
}
|
||||
image.src = aIcon;
|
||||
|
||||
image.src = aIconURI || this._application.iconURI;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1523,3 +1523,174 @@ var SelectionHandler = {
|
|||
};
|
||||
|
||||
SelectionHandler.init();
|
||||
|
||||
// Implementation of https://developer.mozilla.org/en/OpenWebApps/The_JavaScript_API
|
||||
let OpenWebapps = {
|
||||
_callbacks: [],
|
||||
|
||||
/** from https://developer.mozilla.org/en/OpenWebApps/The_Manifest
|
||||
* only the name property is mandatory
|
||||
*/
|
||||
checkManifest: function(aManifest) {
|
||||
return ("name" in aManifest);
|
||||
},
|
||||
|
||||
getCallbackId: function(aCallback) {
|
||||
let id = "id" + Math.random();
|
||||
this._callbacks[id] = aCallback;
|
||||
return id;
|
||||
},
|
||||
|
||||
getCallback: function(aId) {
|
||||
return this._callbacks[aId];
|
||||
},
|
||||
|
||||
removeCallback: function(aId) {
|
||||
delete this._callbacks[aId];
|
||||
},
|
||||
|
||||
install: function(aStoreURI, aManifestURI, aInstallData, aSuccessCallback, aErrorCallback) {
|
||||
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
||||
xhr.open("GET", aManifestURI, true);
|
||||
|
||||
xhr.onload = function() {
|
||||
if (xhr.status == 200) {
|
||||
try {
|
||||
let manifest = JSON.parse(xhr.responseText);
|
||||
if (!OpenWebapps.checkManifest(manifest)) {
|
||||
if (aErrorCallback)
|
||||
aErrorCallback({ code: "invalidManifest", message: "Invalid manifest" });
|
||||
} else {
|
||||
sendAsyncMessage("OpenWebapps:Install", { storeURI: aStoreURI.href, manifestURI: aManifestURI, manifest: xhr.responseText,
|
||||
installData: aInstallData, callbackID: OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
|
||||
}
|
||||
} catch(e) {
|
||||
if (aErrorCallback)
|
||||
aErrorCallback({ code: "manifestParseError", message: "Unable to parse the manifest" });
|
||||
}
|
||||
}
|
||||
else if (aErrorCallback) {
|
||||
aErrorCallback({ code: "networkError", message: "Unable to retrieve manifest" });
|
||||
}
|
||||
}
|
||||
|
||||
xhr.onerror = function() {
|
||||
if (aErrorCallback)
|
||||
aErrorCallback({ code: "networkError", message: "Unable to retrieve manifest" });
|
||||
}
|
||||
|
||||
xhr.send(null);
|
||||
},
|
||||
|
||||
amInstalled: function(aAppURI, aSuccessCallback, aErrorCallback) {
|
||||
sendAsyncMessage("OpenWebapps:AmInstalled", { appURI: aAppURI, callbackID: OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
|
||||
},
|
||||
|
||||
getInstalledBy: function(aStoreURI, aSuccessCallback, aErrorCallback) {
|
||||
sendAsyncMessage("OpenWebapps:GetInstalledBy", { storeURI: aStoreURI.href, callbackID: OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
|
||||
},
|
||||
|
||||
mgmtLaunch: function(aOrigin, aSuccessCallback, aErrorCallback) {
|
||||
sendAsyncMessage("OpenWebapps:MgmtLaunch", { origin: aOrigin, callbackID: OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
|
||||
},
|
||||
|
||||
mgmtList: function(aSuccessCallback, aErrorCallback) {
|
||||
sendAsyncMessage("OpenWebapps:MgmtList", { callbackID: OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
|
||||
},
|
||||
|
||||
mgmtUninstall: function(aOrigin, aSuccessCallback, aErrorCallback) {
|
||||
sendAsyncMessage("OpenWebapps:MgmtUninstall", { origin: aOrigin, callbackID: OpenWebapps.getCallbackId({ success: aSuccessCallback, error: aErrorCallback }) });
|
||||
},
|
||||
|
||||
receiveMessage: function(aMessage) {
|
||||
let msg = aMessage.json;
|
||||
let callbacks = OpenWebapps.getCallback(msg.callbackID);
|
||||
switch(aMessage.name) {
|
||||
case "OpenWebapps:InstallAborted" :
|
||||
if (callbacks.error)
|
||||
callbacks.error({ code: "denied", message: "User denied installation" });
|
||||
break;
|
||||
case "OpenWebapps:InstallDone" :
|
||||
callbacks.success();
|
||||
break;
|
||||
case "OpenWebapps:GetInstalledBy:Return":
|
||||
callbacks.success(msg.apps);
|
||||
break;
|
||||
case "OpenWebapps:AmInstalled:Return":
|
||||
callbacks.success(msg.installed ? msg.app : null);
|
||||
break;
|
||||
case "OpenWebapps:MgmtLaunch:Return":
|
||||
if (msg.ok && callbacks.success)
|
||||
callbacks.success();
|
||||
else if (!msg.ok && callbacks.error)
|
||||
callbacks.error({ code: "noSuchApp", message: "Unable to launch application"});
|
||||
break;
|
||||
case "OpenWebapps:MgmtList:Return":
|
||||
if (msg.ok && callbacks.success)
|
||||
callbacks.success(msg.apps);
|
||||
else if (!msg.ok && callbacks.error)
|
||||
callbacks.error({ code: "noAppList", message: "Unable to get application list"});
|
||||
break;
|
||||
case "OpenWebapps:MgmtUninstall:Return":
|
||||
if (msg.ok && callbacks.success)
|
||||
callbacks.success();
|
||||
else if (!msg.ok && callbacks.error)
|
||||
callbacks.error({ code: "noSuchApp", message: "Unable to uninstall application"});
|
||||
break;
|
||||
}
|
||||
OpenWebapps.removeCallback(msg.callbackID);
|
||||
},
|
||||
|
||||
init: function() {
|
||||
addMessageListener("OpenWebapps:InstallDone", this);
|
||||
addMessageListener("OpenWebapps:InstallAborted", this);
|
||||
addMessageListener("OpenWebapps:GetInstalledBy:Return", this);
|
||||
addMessageListener("OpenWebapps:AmInstalled:Return", this);
|
||||
addMessageListener("OpenWebapps:MgmtLaunch:Return", this);
|
||||
addMessageListener("OpenWebapps:MgmtList:Return", this);
|
||||
addMessageListener("OpenWebapps:MgmtUninstall:Return", this);
|
||||
Services.obs.addObserver(this, "content-document-global-created", false);
|
||||
},
|
||||
|
||||
getInjected: function() {
|
||||
let xhr = Cc["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Ci.nsIXMLHttpRequest);
|
||||
xhr.open("GET", "chrome://browser/content/injected.js", false);
|
||||
xhr.overrideMimeType("text/plain");
|
||||
xhr.send(null);
|
||||
return xhr.responseText;
|
||||
},
|
||||
|
||||
observe: function(subject, topic, data) {
|
||||
let sandbox = new Components.utils.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance(Ci.nsIPrincipal));
|
||||
sandbox.window = subject.wrappedJSObject;
|
||||
|
||||
sandbox.importFunction(function(aStoreURI, aManifestURI, aInstallData, aSuccessCallback, aErrorCallback) {
|
||||
OpenWebapps.install(aStoreURI, aManifestURI, aInstallData, aSuccessCallback, aErrorCallback);
|
||||
}, "OpenWebapps_install");
|
||||
|
||||
sandbox.importFunction(function(aAppURI, aSuccessCallback, aErrorCallback) {
|
||||
OpenWebapps.amInstalled(aAppURI, aSuccessCallback, aErrorCallback);
|
||||
}, "OpenWebapps_amInstalled");
|
||||
|
||||
sandbox.importFunction(function(aStoreURI, aSuccessCallback, aErrorCallback) {
|
||||
OpenWebapps.getInstalledBy(aStoreURI, aSuccessCallback, aErrorCallback);
|
||||
}, "OpenWebapps_getInstalledBy");
|
||||
|
||||
sandbox.importFunction(function(aOrigin, aSuccessCallback, aErrorCallback) {
|
||||
OpenWebapps.mgmtLaunch(aOrigin, aSuccessCallback, aErrorCallback);
|
||||
}, "OpenWebappsMgmt_launch");
|
||||
|
||||
sandbox.importFunction(function(aSuccessCallback, aErrorCallback) {
|
||||
OpenWebapps.mgmtList(aSuccessCallback, aErrorCallback);
|
||||
}, "OpenWebappsMgmt_list");
|
||||
|
||||
sandbox.importFunction(function(aOrigin, aSuccessCallback, aErrorCallback) {
|
||||
OpenWebapps.mgmtUninstall(aOrigin, aSuccessCallback, aErrorCallback);
|
||||
}, "OpenWebappsMgmt_uninstall");
|
||||
|
||||
let toInject = OpenWebapps.getInjected();
|
||||
Cu.evalInSandbox(toInject, sandbox, "1.8", "chrome://browser/content/injected.js", 1);
|
||||
}
|
||||
};
|
||||
|
||||
OpenWebapps.init();
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
|
@ -12,10 +11,10 @@
|
|||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Webapp code.
|
||||
* The Original Code is Mozilla Mobile Browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2010
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
|
@ -35,26 +34,33 @@
|
|||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(adb91273-0cf1-4bbe-a37b-22e660192e2a)]
|
||||
interface nsIWebappsSupport : nsISupports
|
||||
{
|
||||
/**
|
||||
* This method installs a web app.
|
||||
*
|
||||
* @param title the user-friendly name of the application.
|
||||
* @param uri the uri of the web app.
|
||||
* @param iconData a base64 encoded representation of the application's icon.
|
||||
*/
|
||||
void installApplication(in wstring title, in wstring uri, in wstring iconUri, in wstring iconData);
|
||||
/* Expose API under window.navigator.apps */
|
||||
if (window && window.navigator) {
|
||||
window.navigator.mozApps = {
|
||||
install: function(aParam) {
|
||||
return OpenWebapps_install(window.location, aParam.url, aParam.install_data, aParam.onsuccess, aParam.onerror);
|
||||
},
|
||||
|
||||
amInstalled: function(aSuccessCallback, aErrorCallback) {
|
||||
return OpenWebapps_amInstalled(window.location, aSuccessCallback, aErrorCallback);
|
||||
},
|
||||
|
||||
getInstalledBy: function(aSuccessCallback, aErrorCallback) {
|
||||
return OpenWebapps_getInstalledBy(window.location, aSuccessCallback, aErrorCallback);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks is a web app is already installed
|
||||
*
|
||||
* @param uri the uri of the web app
|
||||
* @return true if the web app is installed, false if it's not installed
|
||||
*/
|
||||
boolean isApplicationInstalled(in wstring uri);
|
||||
};
|
||||
|
||||
window.navigator.mozApps.mgmt = {
|
||||
launch: function(aOrigin, aSuccessCallback, aErrorCallback) {
|
||||
return OpenWebappsMgmt_launch(aOrigin, aSuccessCallback, aErrorCallback);
|
||||
},
|
||||
|
||||
list: function(aSuccessCallback, aErrorCallback) {
|
||||
return OpenWebappsMgmt_list(aSuccessCallback, aErrorCallback);
|
||||
},
|
||||
|
||||
uninstall: function(aOrigin, aSuccessCallback, aErrorCallback) {
|
||||
return OpenWebappsMgmt_uninstall(aOrigin, aSuccessCallback, aErrorCallback);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -73,6 +73,7 @@ chrome.jar:
|
|||
content/fullscreen-video.js (content/fullscreen-video.js)
|
||||
content/fullscreen-video.xhtml (content/fullscreen-video.xhtml)
|
||||
content/netError.xhtml (content/netError.xhtml)
|
||||
content/injected.js (content/injected.js)
|
||||
|
||||
% override chrome://global/content/config.xul chrome://browser/content/config.xul
|
||||
% override chrome://global/content/netError.xhtml chrome://browser/content/netError.xhtml
|
||||
|
|
|
@ -49,7 +49,6 @@ XPIDL_MODULE = MobileComponents
|
|||
XPIDLSRCS = \
|
||||
SessionStore.idl \
|
||||
LoginManagerPrompter.idl \
|
||||
WebappsSupport.idl \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_PP_COMPONENTS = \
|
||||
|
@ -76,7 +75,6 @@ EXTRA_COMPONENTS = \
|
|||
LoginManager.js \
|
||||
LoginManagerPrompter.js \
|
||||
BlocklistPrompt.js \
|
||||
WebappsSupport.js \
|
||||
$(NULL)
|
||||
|
||||
ifdef MOZ_SAFE_BROWSING
|
||||
|
|
|
@ -120,7 +120,3 @@ category app-startup SafeBrowsing service,@mozilla.org/safebrowsing/application;
|
|||
component {88b3eb21-d072-4e3b-886d-f89d8c49fe59} UpdatePrompt.js
|
||||
contract @mozilla.org/updates/update-prompt;1 {88b3eb21-d072-4e3b-886d-f89d8c49fe59}
|
||||
#endif
|
||||
|
||||
# webapps
|
||||
component {cb1107c1-1e15-4f11-99c8-27b9ec221a2a} WebappsSupport.js
|
||||
contract @mozilla.org/webapps/support;1 {cb1107c1-1e15-4f11-99c8-27b9ec221a2a}
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Mobile Browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabrice Desré <fabrice@mozilla.com>
|
||||
* Mark Finkle <mfinkle@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* 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 ***** */
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
const DB_VERSION = 1;
|
||||
|
||||
function WebappsSupport() {
|
||||
this.init();
|
||||
}
|
||||
|
||||
WebappsSupport.prototype = {
|
||||
db: null,
|
||||
|
||||
init: function() {
|
||||
let file = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
|
||||
file.append("webapps.sqlite");
|
||||
this.db = Services.storage.openDatabase(file);
|
||||
let version = this.db.schemaVersion;
|
||||
|
||||
if (version == 0) {
|
||||
this.db.executeSimpleSQL("CREATE TABLE webapps (title TEXT, uri TEXT PRIMARY KEY, icon TEXT)");
|
||||
this.db.schemaVersion = DB_VERSION;
|
||||
}
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_installQuery", function() {
|
||||
return this.db.createAsyncStatement("INSERT INTO webapps (title, uri, icon) VALUES(:title, :uri, :icon)");
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "_findQuery", function() {
|
||||
return this.db.createStatement("SELECT uri FROM webapps where uri = :uri");
|
||||
});
|
||||
|
||||
Services.obs.addObserver(this, "quit-application-granted", false);
|
||||
},
|
||||
|
||||
// entry point
|
||||
installApplication: function(aTitle, aURI, aIconURI, aIconData) {
|
||||
let stmt = this._installQuery;
|
||||
stmt.params.title = aTitle;
|
||||
stmt.params.uri = aURI;
|
||||
stmt.params.icon = aIconData;
|
||||
stmt.executeAsync();
|
||||
},
|
||||
|
||||
isApplicationInstalled: function(aURI) {
|
||||
let stmt = this._findQuery;
|
||||
let found = false;
|
||||
try {
|
||||
stmt.params.uri = aURI;
|
||||
found = stmt.executeStep();
|
||||
} finally {
|
||||
stmt.reset();
|
||||
}
|
||||
return found;
|
||||
},
|
||||
|
||||
// nsIObserver
|
||||
observe: function(aSubject, aTopic, aData) {
|
||||
Services.obs.removeObserver(this, "quit-application-granted");
|
||||
|
||||
// Finalize the statements that we have used
|
||||
let stmts = [
|
||||
"_installQuery",
|
||||
"_findQuery"
|
||||
];
|
||||
for (let i = 0; i < stmts.length; i++) {
|
||||
// We do not want to create any query we haven't already created, so
|
||||
// see if it is a getter first.
|
||||
if (Object.getOwnPropertyDescriptor(this, stmts[i]).value !== undefined) {
|
||||
this[stmts[i]].finalize();
|
||||
}
|
||||
}
|
||||
|
||||
this.db.asyncClose();
|
||||
},
|
||||
|
||||
// QI
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebappsSupport]),
|
||||
|
||||
// XPCOMUtils factory
|
||||
classID: Components.ID("{cb1107c1-1e15-4f11-99c8-27b9ec221a2a}")
|
||||
};
|
||||
|
||||
const NSGetFactory = XPCOMUtils.generateNSGetFactory([WebappsSupport]);
|
||||
|
|
@ -612,7 +612,6 @@ bin/components/@DLL_PREFIX@nkgnomevfs@DLL_SUFFIX@
|
|||
#ifdef MOZ_UPDATER
|
||||
@BINPATH@/components/UpdatePrompt.js
|
||||
#endif
|
||||
@BINPATH@/components/WebappsSupport.js
|
||||
@BINPATH@/components/XPIDialogService.js
|
||||
@BINPATH@/components/browsercomps.xpt
|
||||
@BINPATH@/extensions/feedback@mobile.mozilla.org.xpi
|
||||
|
|
|
@ -46,6 +46,7 @@ EXTRA_JS_MODULES = \
|
|||
LocaleRepository.jsm \
|
||||
linuxTypes.jsm \
|
||||
video.jsm \
|
||||
openWebapps.jsm \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_PP_JS_MODULES = \
|
||||
|
|
|
@ -0,0 +1,209 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Mobile Browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla Foundation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Fabrice Desré <fabrice@mozilla.com>
|
||||
* Mark Finkle <mfinkle@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* 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 ***** */
|
||||
|
||||
const Cu = Components.utils;
|
||||
const Cc = Components.classes;
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
let EXPORTED_SYMBOLS = ["OpenWebapps"];
|
||||
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
|
||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||
return NetUtil;
|
||||
});
|
||||
|
||||
let OpenWebapps = {
|
||||
appsDir: null,
|
||||
appsFile: null,
|
||||
webapps: { },
|
||||
|
||||
init: function() {
|
||||
let file = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties).get("ProfD", Ci.nsIFile);
|
||||
file.append("webapps");
|
||||
if (!file.exists() || !file.isDirectory()) {
|
||||
file.create(Ci.nsIFile.DIRECTORY_TYPE, 0700);
|
||||
}
|
||||
this.appsDir = file;
|
||||
this.appsFile = file.clone();
|
||||
this.appsFile.append("webapps.json");
|
||||
if (!this.appsFile.exists())
|
||||
return;
|
||||
|
||||
try {
|
||||
let channel = NetUtil.newChannel(this.appsFile);
|
||||
channel.contentType = "application/json";
|
||||
let self = this;
|
||||
NetUtil.asyncFetch(channel, function(aStream, aResult) {
|
||||
if (!Components.isSuccessCode(aResult)) {
|
||||
Cu.reportError("OpenWebappsSupport: Could not read from webapps.json file");
|
||||
return;
|
||||
}
|
||||
|
||||
// Read webapps json file into a string
|
||||
let data = null;
|
||||
try {
|
||||
data = JSON.parse(NetUtil.readInputStreamToString(aStream, aStream.available()) || "");
|
||||
self.webapps = data;
|
||||
aStream.close();
|
||||
} catch (ex) {
|
||||
Cu.reportError("OpenWebsappsStore: Could not parse JSON: " + ex);
|
||||
}
|
||||
});
|
||||
} catch (ex) {
|
||||
Cu.reportError("OpenWebappsSupport: Could not read from webapps.json file: " + ex);
|
||||
}
|
||||
},
|
||||
|
||||
_writeFile: function ss_writeFile(aFile, aData) {
|
||||
// Initialize the file output stream.
|
||||
let ostream = Cc["@mozilla.org/network/safe-file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
|
||||
ostream.init(aFile, 0x02 | 0x08 | 0x20, 0600, ostream.DEFER_OPEN);
|
||||
|
||||
// Obtain a converter to convert our data to a UTF-8 encoded input stream.
|
||||
let converter = Cc["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Ci.nsIScriptableUnicodeConverter);
|
||||
converter.charset = "UTF-8";
|
||||
|
||||
// Asynchronously copy the data to the file.
|
||||
let istream = converter.convertToInputStream(aData);
|
||||
NetUtil.asyncCopy(istream, ostream, function(rc) {
|
||||
// nothing to do
|
||||
});
|
||||
},
|
||||
|
||||
install: function(aApplication) {
|
||||
// Don't install twice an application
|
||||
if (this.amInstalled(aApplication.appURI))
|
||||
return;
|
||||
|
||||
let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
|
||||
let id = uuidGenerator.generateUUID().toString();
|
||||
let dir = this.appsDir.clone();
|
||||
dir.append(id);
|
||||
dir.create(Ci.nsIFile.DIRECTORY_TYPE, 0700);
|
||||
|
||||
let manFile = dir.clone();
|
||||
manFile.append("manifest.json");
|
||||
this._writeFile(manFile, JSON.stringify(aApplication.manifest));
|
||||
|
||||
this.webapps[id] = {
|
||||
title: aApplication.title,
|
||||
storeURI: aApplication.storeURI,
|
||||
appURI: aApplication.appURI,
|
||||
iconData: aApplication.iconData,
|
||||
installData: aApplication.installData,
|
||||
installTime: (new Date()).getTime(),
|
||||
manifest: aApplication.manifest
|
||||
};
|
||||
this._writeFile(this.appsFile, JSON.stringify(this.webapps));
|
||||
},
|
||||
|
||||
amInstalled: function(aURI) {
|
||||
for (let id in this.webapps) {
|
||||
let app = this.webapps[id];
|
||||
if (app.appURI == aURI) {
|
||||
return { origin: app.appURI,
|
||||
install_origin: app.storeURI,
|
||||
install_data: app.installData,
|
||||
install_time: app.installTime,
|
||||
manifest: app.manifest };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
getInstalledBy: function(aStoreURI) {
|
||||
let res = [];
|
||||
for (let id in this.webapps) {
|
||||
let app = this.webapps[id];
|
||||
if (app.storeURI == aStoreURI)
|
||||
res.push({ origin: app.appURI,
|
||||
install_origin: app.storeURI,
|
||||
install_data: app.installData,
|
||||
install_time: app.installTime,
|
||||
manifest: app.manifest });
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
mgmtList: function() {
|
||||
let res = {};
|
||||
for (let id in this.webapps) {
|
||||
let app = this.webapps[id];
|
||||
res[app.appURI] = { origin: app.appURI,
|
||||
install_origin: app.storeURI,
|
||||
install_data: app.installData,
|
||||
install_time: app.installTime,
|
||||
manifest: app.manifest };
|
||||
}
|
||||
return res;
|
||||
},
|
||||
|
||||
mgmtLaunch: function(aOrigin) {
|
||||
for (let id in this.webapps) {
|
||||
let app = this.webapps[id];
|
||||
if (app.appURI == aOrigin) {
|
||||
let browserWin = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
browserWin.browserDOMWindow.openURI(Services.io.newURI(aOrigin, null, null), null, browserWin.OPEN_APPTAB, Ci.nsIBrowserDOMWindow.OPEN_NEW);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
mgmtUninstall: function(aOrigin) {
|
||||
for (let id in this.webapps) {
|
||||
let app = this.webapps[id];
|
||||
if (app.appURI == aOrigin) {
|
||||
delete this.webapps[id];
|
||||
this._writeFile(this.appsFile, JSON.stringify(this.webapps));
|
||||
let dir = this.appsFile.clone();
|
||||
dir.append(id);
|
||||
try {
|
||||
dir.remove(true);
|
||||
} catch (e) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
OpenWebapps.init();
|
|
@ -77,10 +77,6 @@ interface nsIDataType : nsISupports
|
|||
const PRUint16 VTYPE_EMPTY = 255;
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#include "jspubtd.h"
|
||||
%}
|
||||
|
||||
/**
|
||||
* XPConnect has magic to transparently convert between nsIVariant and JS types.
|
||||
* We mark the interface [scriptable] so that JS can use methods
|
||||
|
|
|
@ -859,6 +859,8 @@ class Method(object):
|
|||
def needsJSTypes(self):
|
||||
if self.implicit_jscontext:
|
||||
return True
|
||||
if self.type == "jsval":
|
||||
return True
|
||||
for p in self.params:
|
||||
t = p.realtype
|
||||
if isinstance(t, Native) and t.specialtype == "jsval":
|
||||
|
|
|
@ -89,7 +89,6 @@
|
|||
#include "nsWebShellWindow.h" // get rid of this one, too...
|
||||
|
||||
#include "prenv.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
@ -201,7 +200,15 @@ NS_IMETHODIMP nsXULWindow::GetInterface(const nsIID& aIID, void** aSink)
|
|||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMWindow))) {
|
||||
return GetWindowDOMWindow(reinterpret_cast<nsIDOMWindow**>(aSink));
|
||||
}
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIDOMWindowInternal))) {
|
||||
nsIDOMWindow* domWindow = nsnull;
|
||||
rv = GetWindowDOMWindow(&domWindow);
|
||||
nsIDOMWindowInternal* domWindowInternal =
|
||||
static_cast<nsIDOMWindowInternal*>(domWindow);
|
||||
*aSink = domWindowInternal;
|
||||
return rv;
|
||||
}
|
||||
if (aIID.Equals(NS_GET_IID(nsIWebBrowserChrome)) &&
|
||||
NS_SUCCEEDED(EnsureContentTreeOwner()) &&
|
||||
NS_SUCCEEDED(mContentTreeOwner->QueryInterface(aIID, aSink)))
|
||||
|
|
Загрузка…
Ссылка в новой задаче