forked from mirrors/gecko-dev
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.
find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
if [ -n "$interfaces" ]; then
if [[ "$interfaces" == *$'\n'* ]]; then
regexp="\("
for i in $interfaces; do regexp="$regexp$i\|"; done
regexp="${regexp%%\\\|}\)"
else
regexp="$interfaces"
fi
interface=$(basename "$path")
rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
if [ $hits -eq 0 ]; then
echo "Removing ${interface} from ${path2}"
grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
mv -f "$path2".tmp "$path2"
fi
done
fi
done
Differential Revision: https://phabricator.services.mozilla.com/D55443
--HG--
extra : moz-landing-system : lando
117 lines
3.4 KiB
C++
117 lines
3.4 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 "nsIEHistoryEnumerator.h"
|
|
|
|
#include <urlhist.h>
|
|
#include <shlguid.h>
|
|
|
|
#include "nsArrayEnumerator.h"
|
|
#include "nsComponentManagerUtils.h"
|
|
#include "nsCOMArray.h"
|
|
#include "nsIURI.h"
|
|
#include "nsNetUtil.h"
|
|
#include "nsString.h"
|
|
#include "nsWindowsMigrationUtils.h"
|
|
#include "prtime.h"
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
//// nsIEHistoryEnumerator
|
|
|
|
nsIEHistoryEnumerator::nsIEHistoryEnumerator() { ::CoInitialize(nullptr); }
|
|
|
|
nsIEHistoryEnumerator::~nsIEHistoryEnumerator() { ::CoUninitialize(); }
|
|
|
|
void nsIEHistoryEnumerator::EnsureInitialized() {
|
|
if (mURLEnumerator) return;
|
|
|
|
HRESULT hr =
|
|
::CoCreateInstance(CLSID_CUrlHistory, nullptr, CLSCTX_INPROC_SERVER,
|
|
IID_IUrlHistoryStg2, getter_AddRefs(mIEHistory));
|
|
if (FAILED(hr)) return;
|
|
|
|
hr = mIEHistory->EnumUrls(getter_AddRefs(mURLEnumerator));
|
|
if (FAILED(hr)) return;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsIEHistoryEnumerator::HasMoreElements(bool* _retval) {
|
|
*_retval = false;
|
|
|
|
EnsureInitialized();
|
|
MOZ_ASSERT(mURLEnumerator,
|
|
"Should have instanced an IE History URLEnumerator");
|
|
if (!mURLEnumerator) return NS_OK;
|
|
|
|
STATURL statURL;
|
|
ULONG fetched;
|
|
|
|
// First argument is not implemented, so doesn't matter what we pass.
|
|
HRESULT hr = mURLEnumerator->Next(1, &statURL, &fetched);
|
|
if (FAILED(hr) || fetched != 1UL) {
|
|
// Reached the last entry.
|
|
return NS_OK;
|
|
}
|
|
|
|
nsCOMPtr<nsIURI> uri;
|
|
if (statURL.pwcsUrl) {
|
|
nsDependentString url(statURL.pwcsUrl);
|
|
nsresult rv = NS_NewURI(getter_AddRefs(uri), url);
|
|
::CoTaskMemFree(statURL.pwcsUrl);
|
|
if (NS_FAILED(rv)) {
|
|
// Got a corrupt or invalid URI, continue to the next entry.
|
|
return HasMoreElements(_retval);
|
|
}
|
|
}
|
|
|
|
nsDependentString title(statURL.pwcsTitle ? statURL.pwcsTitle : L"");
|
|
|
|
bool lastVisitTimeIsValid;
|
|
PRTime lastVisited = WinMigrationFileTimeToPRTime(&(statURL.ftLastVisited),
|
|
&lastVisitTimeIsValid);
|
|
|
|
mCachedNextEntry = do_CreateInstance("@mozilla.org/hash-property-bag;1");
|
|
MOZ_ASSERT(mCachedNextEntry, "Should have instanced a new property bag");
|
|
if (mCachedNextEntry) {
|
|
mCachedNextEntry->SetPropertyAsInterface(NS_LITERAL_STRING("uri"), uri);
|
|
mCachedNextEntry->SetPropertyAsAString(NS_LITERAL_STRING("title"), title);
|
|
if (lastVisitTimeIsValid) {
|
|
mCachedNextEntry->SetPropertyAsInt64(NS_LITERAL_STRING("time"),
|
|
lastVisited);
|
|
}
|
|
|
|
*_retval = true;
|
|
}
|
|
|
|
if (statURL.pwcsTitle) ::CoTaskMemFree(statURL.pwcsTitle);
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
nsIEHistoryEnumerator::GetNext(nsISupports** _retval) {
|
|
*_retval = nullptr;
|
|
|
|
EnsureInitialized();
|
|
MOZ_ASSERT(mURLEnumerator,
|
|
"Should have instanced an IE History URLEnumerator");
|
|
if (!mURLEnumerator) return NS_OK;
|
|
|
|
if (!mCachedNextEntry) {
|
|
bool hasMore = false;
|
|
nsresult rv = this->HasMoreElements(&hasMore);
|
|
if (NS_FAILED(rv)) {
|
|
return rv;
|
|
}
|
|
if (!hasMore) {
|
|
return NS_ERROR_FAILURE;
|
|
}
|
|
}
|
|
|
|
NS_ADDREF(*_retval = mCachedNextEntry);
|
|
// Release the cached entry, so it can't be returned twice.
|
|
mCachedNextEntry = nullptr;
|
|
|
|
return NS_OK;
|
|
}
|