mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 702037 - Merge Android History into mozilla-central. r=marco
This commit is contained in:
parent
c836049aca
commit
9a38269ada
@ -140,6 +140,7 @@ MOZ_UPDATE_PACKAGING = @MOZ_UPDATE_PACKAGING@
|
||||
MOZ_DISABLE_PARENTAL_CONTROLS = @MOZ_DISABLE_PARENTAL_CONTROLS@
|
||||
NS_ENABLE_TSF = @NS_ENABLE_TSF@
|
||||
MOZ_SPELLCHECK = @MOZ_SPELLCHECK@
|
||||
MOZ_ANDROID_HISTORY = @MOZ_ANDROID_HISTORY@
|
||||
MOZ_JAVA_COMPOSITOR = @MOZ_JAVA_COMPOSITOR@
|
||||
MOZ_PROFILELOCKING = @MOZ_PROFILELOCKING@
|
||||
MOZ_FEEDS = @MOZ_FEEDS@
|
||||
|
@ -4681,7 +4681,7 @@ NECKO_PROTOCOLS_DEFAULT="about data file ftp http res viewsource websocket wyciw
|
||||
USE_ARM_KUSER=
|
||||
BUILD_CTYPES=1
|
||||
MOZ_USE_NATIVE_POPUP_WINDOWS=
|
||||
|
||||
MOZ_ANDROID_HISTORY=
|
||||
|
||||
case "${target}" in
|
||||
*android*|*darwin*)
|
||||
@ -8464,6 +8464,7 @@ AC_SUBST(MOZ_D3DCOMPILER_CAB)
|
||||
AC_SUBST(MOZ_D3DX9_DLL)
|
||||
AC_SUBST(MOZ_D3DCOMPILER_DLL)
|
||||
|
||||
AC_SUBST(MOZ_ANDROID_HISTORY)
|
||||
AC_SUBST(ENABLE_STRIP)
|
||||
AC_SUBST(PKG_SKIP_STRIP)
|
||||
AC_SUBST(USE_ELF_DYNSTR_GC)
|
||||
|
@ -297,6 +297,12 @@ Database::~Database()
|
||||
nsresult
|
||||
Database::Init()
|
||||
{
|
||||
#ifdef MOZ_ANDROID_HISTORY
|
||||
// Currently places has deeply weaved it way throughout the gecko codebase.
|
||||
// Here we disable all database creation and loading of places.
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
nsCOMPtr<mozIStorageService> storage =
|
||||
|
@ -101,6 +101,14 @@ CPPSRCS = \
|
||||
|
||||
LOCAL_INCLUDES += -I$(srcdir)/../build
|
||||
|
||||
ifdef MOZ_ANDROID_HISTORY
|
||||
CPPSRCS += nsAndroidHistory.cpp
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(topsrcdir)/docshell/base \
|
||||
-I$(topsrcdir)/content/base/src \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
EXTRA_COMPONENTS = \
|
||||
toolkitplaces.manifest \
|
||||
nsLivemarkService.js \
|
||||
|
168
toolkit/components/places/nsAndroidHistory.cpp
Normal file
168
toolkit/components/places/nsAndroidHistory.cpp
Normal file
@ -0,0 +1,168 @@
|
||||
/* ***** 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 Android code.
|
||||
*
|
||||
* 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):
|
||||
* Kartikaya Gupta <kgupta@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 ***** */
|
||||
|
||||
#include "nsAndroidHistory.h"
|
||||
#include "AndroidBridge.h"
|
||||
#include "Link.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using mozilla::dom::Link;
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsAndroidHistory, IHistory)
|
||||
|
||||
nsAndroidHistory* nsAndroidHistory::sHistory = NULL;
|
||||
|
||||
/*static*/
|
||||
nsAndroidHistory*
|
||||
nsAndroidHistory::GetSingleton()
|
||||
{
|
||||
if (!sHistory) {
|
||||
sHistory = new nsAndroidHistory();
|
||||
NS_ENSURE_TRUE(sHistory, nsnull);
|
||||
}
|
||||
|
||||
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;
|
||||
nsString uriString = NS_ConvertUTF8toUTF16(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;
|
||||
nsString uriString = NS_ConvertUTF8toUTF16(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, PRUint32 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;
|
||||
nsString uriString = NS_ConvertUTF8toUTF16(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;
|
||||
}
|
72
toolkit/components/places/nsAndroidHistory.h
Normal file
72
toolkit/components/places/nsAndroidHistory.h
Normal file
@ -0,0 +1,72 @@
|
||||
/* -*- Mode: c++; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
|
||||
* ***** 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 Android code.
|
||||
*
|
||||
* 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):
|
||||
* Kartikaya Gupta <kgupta@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 ***** */
|
||||
|
||||
#ifndef NS_ANDROIDHISTORY_H
|
||||
#define NS_ANDROIDHISTORY_H
|
||||
|
||||
#include "IHistory.h"
|
||||
#include "nsDataHashtable.h"
|
||||
#include "nsTPriorityQueue.h"
|
||||
#include "nsThreadUtils.h"
|
||||
|
||||
#define NS_ANDROIDHISTORY_CID \
|
||||
{0xCCAA4880, 0x44DD, 0x40A7, {0xA1, 0x3F, 0x61, 0x56, 0xFC, 0x88, 0x2C, 0x0B}}
|
||||
|
||||
class nsAndroidHistory : public mozilla::IHistory, public nsIRunnable
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_IHISTORY
|
||||
NS_DECL_NSIRUNNABLE
|
||||
|
||||
/**
|
||||
* Obtains a pointer that has had AddRef called on it. Used by the service
|
||||
* manager only.
|
||||
*/
|
||||
static nsAndroidHistory* GetSingleton();
|
||||
|
||||
nsAndroidHistory();
|
||||
static void NotifyURIVisited(const nsString& str);
|
||||
|
||||
private:
|
||||
static nsAndroidHistory* sHistory;
|
||||
|
||||
nsDataHashtable<nsStringHashKey, nsTArray<mozilla::dom::Link *> *> mListeners;
|
||||
nsTPriorityQueue<nsString> mPendingURIs;
|
||||
};
|
||||
|
||||
#endif
|
@ -10,6 +10,10 @@
|
||||
#include "History.h"
|
||||
#include "nsDocShellCID.h"
|
||||
|
||||
#ifdef MOZ_ANDROID_HISTORY
|
||||
#include "nsAndroidHistory.h"
|
||||
#endif
|
||||
|
||||
using namespace mozilla::places;
|
||||
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsNavHistory,
|
||||
@ -20,9 +24,13 @@ NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsNavBookmarks,
|
||||
nsNavBookmarks::GetSingleton)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsFaviconService,
|
||||
nsFaviconService::GetSingleton)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(History, History::GetSingleton)
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsPlacesImportExportService,
|
||||
nsPlacesImportExportService::GetSingleton)
|
||||
#ifdef MOZ_ANDROID_HISTORY
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(nsAndroidHistory, nsAndroidHistory::GetSingleton)
|
||||
#else
|
||||
NS_GENERIC_FACTORY_SINGLETON_CONSTRUCTOR(History, History::GetSingleton)
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAnnoProtocolHandler)
|
||||
NS_DEFINE_NAMED_CID(NS_NAVHISTORYSERVICE_CID);
|
||||
@ -30,16 +38,25 @@ NS_DEFINE_NAMED_CID(NS_ANNOTATIONSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_ANNOPROTOCOLHANDLER_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_NAVBOOKMARKSSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_FAVICONSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_HISTORYSERVICE_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_PLACESIMPORTEXPORTSERVICE_CID);
|
||||
|
||||
#ifdef MOZ_ANDROID_HISTORY
|
||||
NS_DEFINE_NAMED_CID(NS_ANDROIDHISTORY_CID);
|
||||
#else
|
||||
NS_DEFINE_NAMED_CID(NS_HISTORYSERVICE_CID);
|
||||
#endif
|
||||
|
||||
const mozilla::Module::CIDEntry kPlacesCIDs[] = {
|
||||
{ &kNS_NAVHISTORYSERVICE_CID, false, NULL, nsNavHistoryConstructor },
|
||||
{ &kNS_ANNOTATIONSERVICE_CID, false, NULL, nsAnnotationServiceConstructor },
|
||||
{ &kNS_ANNOPROTOCOLHANDLER_CID, false, NULL, nsAnnoProtocolHandlerConstructor },
|
||||
{ &kNS_NAVBOOKMARKSSERVICE_CID, false, NULL, nsNavBookmarksConstructor },
|
||||
{ &kNS_FAVICONSERVICE_CID, false, NULL, nsFaviconServiceConstructor },
|
||||
#ifdef MOZ_ANDROID_HISTORY
|
||||
{ &kNS_ANDROIDHISTORY_CID, false, NULL, nsAndroidHistoryConstructor },
|
||||
#else
|
||||
{ &kNS_HISTORYSERVICE_CID, false, NULL, HistoryConstructor },
|
||||
#endif
|
||||
{ &kNS_PLACESIMPORTEXPORTSERVICE_CID, false, NULL, nsPlacesImportExportServiceConstructor },
|
||||
{ NULL }
|
||||
};
|
||||
@ -53,7 +70,11 @@ const mozilla::Module::ContractIDEntry kPlacesContracts[] = {
|
||||
{ NS_NAVBOOKMARKSSERVICE_CONTRACTID, &kNS_NAVBOOKMARKSSERVICE_CID },
|
||||
{ NS_FAVICONSERVICE_CONTRACTID, &kNS_FAVICONSERVICE_CID },
|
||||
{ "@mozilla.org/embeddor.implemented/bookmark-charset-resolver;1", &kNS_NAVHISTORYSERVICE_CID },
|
||||
#ifdef MOZ_ANDROID_HISTORY
|
||||
{ NS_IHISTORY_CONTRACTID, &kNS_ANDROIDHISTORY_CID },
|
||||
#else
|
||||
{ NS_IHISTORY_CONTRACTID, &kNS_HISTORYSERVICE_CID },
|
||||
#endif
|
||||
{ NS_PLACESIMPORTEXPORTSERVICE_CONTRACTID, &kNS_PLACESIMPORTEXPORTSERVICE_CID },
|
||||
{ NULL }
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user