Un-fold browsercomps.* from libxul

This resolves #16.
This commit is contained in:
wolfbeast 2018-02-11 13:01:08 +01:00 committed by Roy Tam
commit d07bf4bba2
13 changed files with 55 additions and 43 deletions

View file

@ -14,7 +14,7 @@
#include "nsDirectoryServiceDefs.h"
#include "nsIPrefService.h"
#include "prenv.h"
#include "nsString.h"
#include "nsStringAPI.h"
#include "nsIGConfService.h"
#include "nsIGIOService.h"
#include "nsIGSettingsService.h"
@ -70,16 +70,16 @@ static const MimeTypeAssociation appTypes[] = {
// GConf registry key constants
#define DG_BACKGROUND "/desktop/gnome/background"
#define kDesktopImageKey DG_BACKGROUND "/picture_filename"
#define kDesktopOptionsKey DG_BACKGROUND "/picture_options"
#define kDesktopDrawBGKey DG_BACKGROUND "/draw_background"
#define kDesktopColorKey DG_BACKGROUND "/primary_color"
static const char kDesktopImageKey[] = DG_BACKGROUND "/picture_filename";
static const char kDesktopOptionsKey[] = DG_BACKGROUND "/picture_options";
static const char kDesktopDrawBGKey[] = DG_BACKGROUND "/draw_background";
static const char kDesktopColorKey[] = DG_BACKGROUND "/primary_color";
#define kDesktopBGSchema "org.gnome.desktop.background"
#define kDesktopImageGSKey "picture-uri"
#define kDesktopOptionGSKey "picture-options"
#define kDesktopDrawBGGSKey "draw-background"
#define kDesktopColorGSKey "primary-color"
static const char kDesktopBGSchema[] = "org.gnome.desktop.background";
static const char kDesktopImageGSKey[] = "picture-uri";
static const char kDesktopOptionGSKey[] = "picture-options";
static const char kDesktopDrawBGGSKey[] = "draw-background";
static const char kDesktopColorGSKey[] = "primary-color";
nsresult
nsGNOMEShellService::Init()
@ -508,8 +508,7 @@ static void
ColorToCString(uint32_t aColor, nsCString& aResult)
{
// The #rrrrggggbbbb format is used to match gdk_color_to_string()
aResult.SetLength(13);
char *buf = aResult.BeginWriting();
char *buf = aResult.BeginWriting(13);
if (!buf)
return;

View file

@ -7,7 +7,7 @@
#define nsgnomeshellservice_h____
#include "nsIGNOMEShellService.h"
#include "nsString.h"
#include "nsStringAPI.h"
#include "mozilla/Attributes.h"
class nsGNOMEShellService final : public nsIGNOMEShellService

View file

@ -20,7 +20,7 @@
#include "nsIProperties.h"
#include "nsServiceManagerUtils.h"
#include "nsShellService.h"
#include "nsString.h"
#include "nsStringAPI.h"
#include "nsIDocShell.h"
#include "nsILoadContext.h"

View file

@ -12,7 +12,6 @@
#include "nsIDOMElement.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsIImageLoadingContent.h"
#include "nsIOutputStream.h"
#include "nsIPrefService.h"
#include "nsIPrefLocalizedString.h"
#include "nsIServiceManager.h"
@ -466,7 +465,7 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
return NS_OK;
}
res = ::RegOpenKeyExW(HKEY_CLASSES_ROOT, keyName.get(),
res = ::RegOpenKeyExW(HKEY_CLASSES_ROOT, PromiseFlatString(keyName).get(),
0, KEY_SET_VALUE, &theKey);
if (REG_FAILED(res)) {
// If updating the open command fails try to update it using the helper
@ -475,9 +474,10 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
return NS_OK;
}
const nsString &flatValue = PromiseFlatString(valueData);
res = ::RegSetValueExW(theKey, L"", 0, REG_SZ,
(const BYTE *) valueData.get(),
(valueData.Length() + 1) * sizeof(char16_t));
(const BYTE *) flatValue.get(),
(flatValue.Length() + 1) * sizeof(char16_t));
// Close the key that was created.
::RegCloseKey(theKey);
if (REG_FAILED(res)) {
@ -529,8 +529,9 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
if (REG_FAILED(res) || char16_t('\0') != *currValue) {
// Key wasn't set or was set to something other than our registry entry.
// Delete the key along with all of its childrean and then recreate it.
::SHDeleteKeyW(HKEY_CURRENT_USER, keyName.get());
res = ::RegCreateKeyExW(HKEY_CURRENT_USER, keyName.get(), 0, nullptr,
const nsString &flatName = PromiseFlatString(keyName);
::SHDeleteKeyW(HKEY_CURRENT_USER, flatName.get());
res = ::RegCreateKeyExW(HKEY_CURRENT_USER, flatName.get(), 0, nullptr,
REG_OPTION_NON_VOLATILE, KEY_SET_VALUE,
nullptr, &theKey, nullptr);
if (REG_FAILED(res)) {
@ -582,9 +583,10 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
NS_ConvertUTF8toUTF16 valueData(VAL_OPEN);
valueData.Replace(offset, 9, appLongPath);
const nsString &flatValue = PromiseFlatString(valueData);
res = ::RegSetValueExW(theKey, L"", 0, REG_SZ,
(const BYTE *) valueData.get(),
(valueData.Length() + 1) * sizeof(char16_t));
(const BYTE *) flatValue.get(),
(flatValue.Length() + 1) * sizeof(char16_t));
// Close the key that was created.
::RegCloseKey(theKey);
// If updating the FTP protocol handlers shell open command fails try to

View file

@ -7,7 +7,7 @@
#define nswindowsshellservice_h____
#include "nscore.h"
#include "nsString.h"
#include "nsStringAPI.h"
#include "nsIWindowsShellService.h"
#include "nsITimer.h"