Bug 651622 - Remove WinCE code from browser/* r=dolske

This commit is contained in:
Ed Morley
2011-04-22 01:14:59 +02:00
parent 28cf5c6063
commit 1473544eb5
16 changed files with 8 additions and 344 deletions

View File

@@ -91,11 +91,7 @@
#define NS_TASKBAR_CONTRACTID "@mozilla.org/windows-taskbar;1"
#ifndef WINCE
NS_IMPL_ISUPPORTS2(nsWindowsShellService, nsIWindowsShellService, nsIShellService)
#else
NS_IMPL_ISUPPORTS1(nsWindowsShellService, nsIShellService)
#endif
static nsresult
OpenKeyForReading(HKEY aKeyRoot, const nsAString& aKeyName, HKEY* aKey)
@@ -115,33 +111,6 @@ OpenKeyForReading(HKEY aKeyRoot, const nsAString& aKeyName, HKEY* aKey)
return NS_OK;
}
#ifdef WINCE
static nsresult
OpenKeyForWriting(HKEY aStartKey, const nsAString& aKeyName, HKEY* aKey)
{
const nsString &flatName = PromiseFlatString(aKeyName);
DWORD dwDisp = 0;
DWORD res = ::RegCreateKeyExW(aStartKey, flatName.get(), 0, NULL,
0, KEY_READ | KEY_WRITE, NULL, aKey,
&dwDisp);
switch (res) {
case ERROR_SUCCESS:
break;
case ERROR_ACCESS_DENIED:
return NS_ERROR_FILE_ACCESS_DENIED;
case ERROR_FILE_NOT_FOUND:
res = ::RegCreateKeyExW(aStartKey, flatName.get(), 0, NULL,
0, KEY_READ | KEY_WRITE, NULL, aKey,
NULL);
if (res != ERROR_SUCCESS)
return NS_ERROR_FILE_ACCESS_DENIED;
}
return NS_OK;
}
#endif
///////////////////////////////////////////////////////////////////////////////
// Default Browser Registry Settings
//
@@ -217,23 +186,15 @@ typedef struct {
char* valueData;
} SETTING;
#ifndef WINCE
#define APP_REG_NAME L"Firefox"
#define CLS_HTML "FirefoxHTML"
#define CLS_URL "FirefoxURL"
#define CPL_DESKTOP L"Control Panel\\Desktop"
#define VAL_OPEN "\"%APPPATH%\" -requestPending -osint -url \"%1\""
#define VAL_FILE_ICON "%APPPATH%,1"
#else
#define CPL_DESKTOP L"ControlPanel\\Desktop"
#define VAL_OPEN "\"%APPPATH%\" -osint -url \"%1\""
#define VAL_FILE_ICON "%APPPATH%,-2"
#endif
#define DI "\\DefaultIcon"
#define SOP "\\shell\\open\\command"
#define MAKE_KEY_NAME1(PREFIX, MID) \
PREFIX MID
@@ -243,28 +204,11 @@ typedef struct {
// Handlers. see http://msdn2.microsoft.com/en-us/library/aa969357.aspx for
// more info.
static SETTING gSettings[] = {
#ifndef WINCE
// File Handler Class
{ MAKE_KEY_NAME1(CLS_HTML, SOP), "", VAL_OPEN },
// Protocol Handler Class - for Vista and above
{ MAKE_KEY_NAME1(CLS_URL, SOP), "", VAL_OPEN },
#else
{ MAKE_KEY_NAME1("FTP", DI), "", VAL_FILE_ICON },
{ MAKE_KEY_NAME1("FTP", SOP), "", VAL_OPEN },
// File handlers for Windows CE
{ MAKE_KEY_NAME1("bmpfile", DI), "", VAL_FILE_ICON },
{ MAKE_KEY_NAME1("bmpfile", SOP), "", VAL_OPEN },
{ MAKE_KEY_NAME1("giffile", DI), "", VAL_FILE_ICON },
{ MAKE_KEY_NAME1("giffile", SOP), "", VAL_OPEN },
{ MAKE_KEY_NAME1("jpegfile", DI), "", VAL_FILE_ICON },
{ MAKE_KEY_NAME1("jpegfile", SOP), "", VAL_OPEN },
{ MAKE_KEY_NAME1("pngfile", DI), "", VAL_FILE_ICON },
{ MAKE_KEY_NAME1("pngfile", SOP), "", VAL_OPEN },
{ MAKE_KEY_NAME1("htmlfile", DI), "", VAL_FILE_ICON },
{ MAKE_KEY_NAME1("htmlfile", SOP), "", VAL_OPEN },
#endif
// Protocol Handlers
{ MAKE_KEY_NAME1("HTTP", DI), "", VAL_FILE_ICON },
@@ -273,7 +217,6 @@ static SETTING gSettings[] = {
{ MAKE_KEY_NAME1("HTTPS", SOP), "", VAL_OPEN }
};
#if !defined(WINCE)
nsresult
GetHelperPath(nsAutoString& aPath)
{
@@ -313,12 +256,10 @@ LaunchHelper(nsAutoString& aPath)
CloseHandle(pi.hThread);
return NS_OK;
}
#endif // !defined(WINCE)
NS_IMETHODIMP
nsWindowsShellService::ShortcutMaintenance()
{
#if !defined(WINCE)
nsresult rv;
// Launch helper.exe so it can update the application user model ids on
@@ -388,13 +329,8 @@ nsWindowsShellService::ShortcutMaintenance()
appHelperPath.AppendLiteral(" /UpdateShortcutAppUserModelIds");
return LaunchHelper(appHelperPath);
#else
NS_NOTREACHED("ShortcutMaintenance not implemented on wince!");
return NS_OK;
#endif // !defined(WINCE)
}
#ifndef WINCE
PRBool
nsWindowsShellService::IsDefaultBrowserVista(PRBool* aIsDefaultBrowser)
{
@@ -418,7 +354,6 @@ nsWindowsShellService::IsDefaultBrowserVista(PRBool* aIsDefaultBrowser)
#endif
return PR_FALSE;
}
#endif
NS_IMETHODIMP
nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck,
@@ -439,12 +374,10 @@ nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck,
if (!::GetModuleFileNameW(0, exePath, MAX_BUF))
return NS_ERROR_FAILURE;
#ifndef WINCE
// Convert the path to a long path since GetModuleFileNameW returns the path
// that was used to launch Firefox which is not necessarily a long path.
if (!::GetLongPathNameW(exePath, exePath, MAX_BUF))
return NS_ERROR_FAILURE;
#endif
nsAutoString appLongPath(exePath);
@@ -478,12 +411,10 @@ nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck,
}
}
#ifndef WINCE
// Only check if Firefox is the default browser on Vista if the previous
// checks show that Firefox is the default browser.
if (*aIsDefaultBrowser)
IsDefaultBrowserVista(aIsDefaultBrowser);
#endif
return NS_OK;
}
@@ -491,7 +422,6 @@ nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck,
NS_IMETHODIMP
nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUsers)
{
#ifndef WINCE
nsAutoString appHelperPath;
if (NS_FAILED(GetHelperPath(appHelperPath)))
return NS_ERROR_FAILURE;
@@ -503,91 +433,8 @@ nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes, PRBool aForAllUs
}
return LaunchHelper(appHelperPath);
#else
SETTING* settings;
SETTING* end = gSettings + sizeof(gSettings)/sizeof(SETTING);
PRUnichar exePath[MAX_BUF];
if (!::GetModuleFileNameW(0, exePath, MAX_BUF))
return NS_ERROR_FAILURE;
nsAutoString appLongPath(exePath);
// The .png registry key isn't present by default so also add Content Type.
SetRegKey(NS_LITERAL_STRING(".png"), EmptyString(),
NS_LITERAL_STRING("pngfile"));
SetRegKey(NS_LITERAL_STRING(".png"), NS_LITERAL_STRING("Content Type"),
NS_LITERAL_STRING("image/png"));
// Set these keys to their default value for a clean install in case another
// app has changed these keys.
SetRegKey(NS_LITERAL_STRING(".htm"), EmptyString(),
NS_LITERAL_STRING("htmlfile"));
SetRegKey(NS_LITERAL_STRING(".html"), EmptyString(),
NS_LITERAL_STRING("htmlfile"));
SetRegKey(NS_LITERAL_STRING(".bmp"), EmptyString(),
NS_LITERAL_STRING("bmpfile"));
SetRegKey(NS_LITERAL_STRING(".gif"), EmptyString(),
NS_LITERAL_STRING("giffile"));
SetRegKey(NS_LITERAL_STRING(".jpe"), EmptyString(),
NS_LITERAL_STRING("jpegfile"));
SetRegKey(NS_LITERAL_STRING(".jpg"), EmptyString(),
NS_LITERAL_STRING("jpegfile"));
SetRegKey(NS_LITERAL_STRING(".jpeg"), EmptyString(),
NS_LITERAL_STRING("jpegfile"));
for (settings = gSettings; settings < end; ++settings) {
NS_ConvertUTF8toUTF16 dataLongPath(settings->valueData);
NS_ConvertUTF8toUTF16 key(settings->keyName);
NS_ConvertUTF8toUTF16 value(settings->valueName);
PRInt32 offset = dataLongPath.Find("%APPPATH%");
dataLongPath.Replace(offset, 9, appLongPath);
SetRegKey(key, value, dataLongPath);
}
// On Windows CE RegFlushKey can negatively impact performance if there are a
// lot of pending writes to the HKEY_CLASSES_ROOT registry hive but it is
// necessary to save the values in the case where the user performs a hard
// power off of the device.
::RegFlushKey(HKEY_CLASSES_ROOT);
#endif
return NS_OK;
}
#ifdef WINCE
void
nsWindowsShellService::SetRegKey(const nsString& aKeyName,
const nsString& aValueName,
const nsString& aValue)
{
PRUnichar buf[MAX_BUF];
DWORD len = sizeof buf;
HKEY theKey;
nsresult rv = OpenKeyForWriting(HKEY_CLASSES_ROOT, aKeyName, &theKey);
if (NS_FAILED(rv))
return;
// Get the current value.
DWORD res = ::RegQueryValueExW(theKey, PromiseFlatString(aValueName).get(),
NULL, NULL, (LPBYTE)buf, &len);
// Set the new value if it doesn't exist or it is different than the current
// value.
nsAutoString current(buf);
if (REG_FAILED(res) || !current.Equals(aValue)) {
const nsString &flatValue = PromiseFlatString(aValue);
::RegSetValueExW(theKey, PromiseFlatString(aValueName).get(),
0, REG_SZ, (const BYTE *)flatValue.get(),
(flatValue.Length() + 1) * sizeof(PRUnichar));
}
// Close the key we opened.
::RegCloseKey(theKey);
}
#endif
NS_IMETHODIMP
nsWindowsShellService::GetShouldCheckDefaultBrowser(PRBool* aResult)
{
@@ -768,7 +615,6 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_WRITE, NULL, &key, &dwDisp);
if (REG_SUCCEEDED(res)) {
#ifndef WINCE
PRUnichar tile[2], style[2];
switch (aPosition) {
case BACKGROUND_TILE:
@@ -795,25 +641,9 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
0, REG_SZ, (const BYTE *)style, size);
::SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, (PVOID)path.get(),
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
#else
DWORD tile = (aPosition == BACKGROUND_TILE);
::RegSetValueExW(key, L"Tile",
0, REG_DWORD, (const BYTE *)&tile, sizeof(DWORD));
// On WinCE SPI_SETDESKWALLPAPER isn't available, so set the registry
// entry ourselves and then broadcast UI change
PRInt32 size = (path.Length() + 1) * sizeof(PRUnichar);
::RegSetValueExW(key, L"Wallpaper",
0, REG_SZ, (const BYTE *)path.get(), size);
::SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, NULL, 0);
#endif
// Close the key we opened.
::RegCloseKey(key);
#ifdef WINCE
// Ensure that the writes are flushed in case of hard reboot
::RegFlushKey(HKEY_CURRENT_USER);
#endif
}
}
return rv;
@@ -939,9 +769,6 @@ nsWindowsShellService::SetDesktopBackgroundColor(PRUint32 aColor)
::SetSysColors(sizeof(aParameters) / sizeof(int), aParameters, colors);
// SetSysColors is persisting across sessions on Windows CE, so no need to
// write to registry
#ifndef WINCE
PRBool result = PR_FALSE;
DWORD dwDisp = 0;
HKEY key;
@@ -963,11 +790,9 @@ nsWindowsShellService::SetDesktopBackgroundColor(PRUint32 aColor)
// Close the key we opened.
::RegCloseKey(key);
#endif
return NS_OK;
}
#ifndef WINCE
NS_IMETHODIMP
nsWindowsShellService::GetUnreadMailCount(PRUint32* aCount)
{
@@ -1027,7 +852,6 @@ nsWindowsShellService::GetMailAccountKey(HKEY* aResult)
::RegCloseKey(mailKey);
return PR_FALSE;
}
#endif
NS_IMETHODIMP
nsWindowsShellService::OpenApplicationWithURI(nsILocalFile* aApplication,