mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
8c296bbcd4
This patch was generated by a script. Here's the source of the script for future reference: function convert() { echo "Converting $1 to $2..." find . ! -wholename "*nsprpub*" \ ! -wholename "*security/nss*" \ ! -wholename "*/.hg*" \ ! -wholename "obj-ff-dbg*" \ ! -name nsXPCOMCID.h \ ! -name prtypes.h \ -type f \ \( -iname "*.cpp" \ -o -iname "*.h" \ -o -iname "*.c" \ -o -iname "*.cc" \ -o -iname "*.idl" \ -o -iname "*.ipdl" \ -o -iname "*.ipdlh" \ -o -iname "*.mm" \) | \ xargs -n 1 sed -i -e "s/\b$1\b/$2/g" } convert PRInt8 int8_t convert PRUint8 uint8_t convert PRInt16 int16_t convert PRUint16 uint16_t convert PRInt32 int32_t convert PRUint32 uint32_t convert PRInt64 int64_t convert PRUint64 uint64_t convert PRIntn int convert PRUintn unsigned convert PRSize size_t convert PROffset32 int32_t convert PROffset64 int64_t convert PRPtrdiff ptrdiff_t convert PRFloat64 double
137 lines
3.0 KiB
C++
137 lines
3.0 KiB
C++
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "nsAndroidHistory.h"
|
|
#include "AndroidBridge.h"
|
|
#include "Link.h"
|
|
|
|
using namespace mozilla;
|
|
using mozilla::dom::Link;
|
|
|
|
NS_IMPL_ISUPPORTS2(nsAndroidHistory, IHistory, nsIRunnable)
|
|
|
|
nsAndroidHistory* nsAndroidHistory::sHistory = NULL;
|
|
|
|
/*static*/
|
|
nsAndroidHistory*
|
|
nsAndroidHistory::GetSingleton()
|
|
{
|
|
if (!sHistory) {
|
|
sHistory = new nsAndroidHistory();
|
|
NS_ENSURE_TRUE(sHistory, nullptr);
|
|
}
|
|
|
|
NS_ADDREF(sHistory);
|
|
return sHistory;
|
|
}
|
|
|
|
nsAndroidHistory::nsAndroidHistory()
|
|
{
|
|
mListeners.Init();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsAndroidHistory::RegisterVisitedCallback(nsIURI *aURI, Link *aContent)
|
|
{
|
|
if (!aContent || !aURI)
|
|
return NS_OK;
|
|
|
|
nsCAutoString uri;
|
|
nsresult rv = aURI->GetSpec(uri);
|
|
if (NS_FAILED(rv)) return rv;
|
|
NS_ConvertUTF8toUTF16 uriString(uri);
|
|
|
|
nsTArray<Link*>* list = mListeners.Get(uriString);
|
|
if (! list) {
|
|
list = new nsTArray<Link*>();
|
|
mListeners.Put(uriString, list);
|
|
}
|
|
list->AppendElement(aContent);
|
|
|
|
AndroidBridge *bridge = AndroidBridge::Bridge();
|
|
if (bridge) {
|
|
bridge->CheckURIVisited(uriString);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsAndroidHistory::UnregisterVisitedCallback(nsIURI *aURI, Link *aContent)
|
|
{
|
|
if (!aContent || !aURI)
|
|
return NS_OK;
|
|
|
|
nsCAutoString uri;
|
|
nsresult rv = aURI->GetSpec(uri);
|
|
if (NS_FAILED(rv)) return rv;
|
|
NS_ConvertUTF8toUTF16 uriString(uri);
|
|
|
|
nsTArray<Link*>* list = mListeners.Get(uriString);
|
|
if (! list)
|
|
return NS_OK;
|
|
|
|
list->RemoveElement(aContent);
|
|
if (list->IsEmpty()) {
|
|
mListeners.Remove(uriString);
|
|
delete list;
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsAndroidHistory::VisitURI(nsIURI *aURI, nsIURI *aLastVisitedURI, uint32_t aFlags)
|
|
{
|
|
if (!aURI)
|
|
return NS_OK;
|
|
|
|
if (!(aFlags & VisitFlags::TOP_LEVEL))
|
|
return NS_OK;
|
|
|
|
AndroidBridge *bridge = AndroidBridge::Bridge();
|
|
if (bridge) {
|
|
nsCAutoString uri;
|
|
nsresult rv = aURI->GetSpec(uri);
|
|
if (NS_FAILED(rv)) return rv;
|
|
NS_ConvertUTF8toUTF16 uriString(uri);
|
|
bridge->MarkURIVisited(uriString);
|
|
}
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsAndroidHistory::SetURITitle(nsIURI *aURI, const nsAString& aTitle)
|
|
{
|
|
// we don't do anything with this right now
|
|
return NS_OK;
|
|
}
|
|
|
|
void /*static*/
|
|
nsAndroidHistory::NotifyURIVisited(const nsString& aUriString)
|
|
{
|
|
if (! sHistory)
|
|
return;
|
|
sHistory->mPendingURIs.Push(aUriString);
|
|
NS_DispatchToMainThread(sHistory);
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsAndroidHistory::Run()
|
|
{
|
|
while (! mPendingURIs.IsEmpty()) {
|
|
nsString uriString = mPendingURIs.Pop();
|
|
nsTArray<Link*>* list = sHistory->mListeners.Get(uriString);
|
|
if (list) {
|
|
for (unsigned int i = 0; i < list->Length(); i++) {
|
|
list->ElementAt(i)->SetLinkState(eLinkState_Visited);
|
|
}
|
|
// as per the IHistory interface contract, remove the
|
|
// Link pointers once they have been notified
|
|
mListeners.Remove(uriString);
|
|
delete list;
|
|
}
|
|
}
|
|
return NS_OK;
|
|
}
|