mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-29 10:37:33 +09:00
[PALEMOON] Wholesale steal Basilisk's shell component
This commit is contained in:
parent
b76b957009
commit
3a4bc108d7
17 changed files with 553 additions and 424 deletions
|
|
@ -1,11 +0,0 @@
|
||||||
#
|
|
||||||
# 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 $(topsrcdir)/config/rules.mk
|
|
||||||
|
|
||||||
CXXFLAGS += $(TK_CFLAGS)
|
|
||||||
|
|
||||||
clobber::
|
|
||||||
rm -f $(DIST)/lib/$(LIBRARY_NAME).lib
|
|
||||||
114
application/palemoon/components/shell/ShellService.jsm
Normal file
114
application/palemoon/components/shell/ShellService.jsm
Normal file
|
|
@ -0,0 +1,114 @@
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
this.EXPORTED_SYMBOLS = ["ShellService"];
|
||||||
|
|
||||||
|
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
|
||||||
|
|
||||||
|
Cu.import("resource://gre/modules/AppConstants.jsm");
|
||||||
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
XPCOMUtils.defineLazyModuleGetter(this, "WindowsRegistry",
|
||||||
|
"resource://gre/modules/WindowsRegistry.jsm");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Internal functionality to save and restore the docShell.allow* properties.
|
||||||
|
*/
|
||||||
|
let ShellServiceInternal = {
|
||||||
|
/**
|
||||||
|
* Used to determine whether or not to offer "Set as desktop background"
|
||||||
|
* functionality. Even if shell service is available it is not
|
||||||
|
* guaranteed that it is able to set the background for every desktop
|
||||||
|
* which is especially true for Linux with its many different desktop
|
||||||
|
* environments.
|
||||||
|
*/
|
||||||
|
get canSetDesktopBackground() {
|
||||||
|
if (AppConstants.platform == "win" ||
|
||||||
|
AppConstants.platform == "macosx") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AppConstants.platform == "linux") {
|
||||||
|
if (this.shellService) {
|
||||||
|
let linuxShellService = this.shellService
|
||||||
|
.QueryInterface(Ci.nsIGNOMEShellService);
|
||||||
|
return linuxShellService.canSetDesktopBackground;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to determine whether or not to show a "Set Default Browser"
|
||||||
|
* query dialog. This attribute is true if the application is starting
|
||||||
|
* up and "browser.shell.checkDefaultBrowser" is true, otherwise it
|
||||||
|
* is false.
|
||||||
|
*/
|
||||||
|
_checkedThisSession: false,
|
||||||
|
get shouldCheckDefaultBrowser() {
|
||||||
|
// If we've already checked, the browser has been started and this is a
|
||||||
|
// new window open, and we don't want to check again.
|
||||||
|
if (this._checkedThisSession) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Services.prefs.getBoolPref("browser.shell.checkDefaultBrowser")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AppConstants.platform == "win") {
|
||||||
|
let optOutValue = WindowsRegistry.readRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||||
|
"Software\\Mozilla\\PaleMoon",
|
||||||
|
"DefaultBrowserOptOut");
|
||||||
|
WindowsRegistry.removeRegKey(Ci.nsIWindowsRegKey.ROOT_KEY_CURRENT_USER,
|
||||||
|
"Software\\Mozilla\\PaleMoon",
|
||||||
|
"DefaultBrowserOptOut");
|
||||||
|
if (optOutValue == "True") {
|
||||||
|
Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
|
set shouldCheckDefaultBrowser(shouldCheck) {
|
||||||
|
Services.prefs.setBoolPref("browser.shell.checkDefaultBrowser", !!shouldCheck);
|
||||||
|
},
|
||||||
|
|
||||||
|
isDefaultBrowser(startupCheck, forAllTypes) {
|
||||||
|
// If this is the first browser window, maintain internal state that we've
|
||||||
|
// checked this session (so that subsequent window opens don't show the
|
||||||
|
// default browser dialog).
|
||||||
|
if (startupCheck) {
|
||||||
|
this._checkedThisSession = true;
|
||||||
|
}
|
||||||
|
if (this.shellService) {
|
||||||
|
return this.shellService.isDefaultBrowser(startupCheck, forAllTypes);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyServiceGetter(ShellServiceInternal, "shellService",
|
||||||
|
"@mozilla.org/browser/shell-service;1", Ci.nsIShellService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The external API exported by this module.
|
||||||
|
*/
|
||||||
|
this.ShellService = new Proxy(ShellServiceInternal, {
|
||||||
|
get(target, name) {
|
||||||
|
if (name in target) {
|
||||||
|
return target[name];
|
||||||
|
}
|
||||||
|
if (target.shellService) {
|
||||||
|
return target.shellService[name];
|
||||||
|
}
|
||||||
|
Services.console.logStringMessage(`${name} not found in ShellService: ${target.shellService}`);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
@ -1,16 +1,14 @@
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
/* 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
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
Components.utils.import("resource://gre/modules/AppConstants.jsm");
|
||||||
|
|
||||||
var Ci = Components.interfaces;
|
var Ci = Components.interfaces;
|
||||||
|
|
||||||
var gSetBackground = {
|
var gSetBackground = {
|
||||||
#ifndef XP_MACOSX
|
_position : AppConstants.platform == "macosx" ? "STRETCH" : "",
|
||||||
_position : "",
|
_backgroundColor : AppConstants.platform != "macosx" ? 0 : undefined,
|
||||||
_backgroundColor : 0,
|
|
||||||
#else
|
|
||||||
_position : "STRETCH",
|
|
||||||
#endif
|
|
||||||
_screenWidth : 0,
|
_screenWidth : 0,
|
||||||
_screenHeight : 0,
|
_screenHeight : 0,
|
||||||
_image : null,
|
_image : null,
|
||||||
|
|
@ -27,23 +25,23 @@ var gSetBackground = {
|
||||||
this._canvas = document.getElementById("screen");
|
this._canvas = document.getElementById("screen");
|
||||||
this._screenWidth = screen.width;
|
this._screenWidth = screen.width;
|
||||||
this._screenHeight = screen.height;
|
this._screenHeight = screen.height;
|
||||||
#ifdef XP_MACOSX
|
if (AppConstants.platform == "macosx") {
|
||||||
document.documentElement.getButton("accept").hidden = true;
|
document.documentElement.getButton("accept").hidden = true;
|
||||||
#endif
|
}
|
||||||
if (this._screenWidth / this._screenHeight >= 1.6)
|
if (this._screenWidth / this._screenHeight >= 1.6)
|
||||||
document.getElementById("monitor").setAttribute("aspectratio", "16:10");
|
document.getElementById("monitor").setAttribute("aspectratio", "16:10");
|
||||||
|
|
||||||
#ifdef XP_WIN
|
if (AppConstants.platform == "win") {
|
||||||
// hide fill + fit options if <win7 since don't work
|
// Hide fill + fit options if < Win7 since they don't work.
|
||||||
var version = Components.classes["@mozilla.org/system-info;1"]
|
var version = Components.classes["@mozilla.org/system-info;1"]
|
||||||
.getService(Ci.nsIPropertyBag2)
|
.getService(Ci.nsIPropertyBag2)
|
||||||
.getProperty("version");
|
.getProperty("version");
|
||||||
var isWindows7OrHigher = (parseFloat(version) >= 6.1);
|
var isWindows7OrHigher = (parseFloat(version) >= 6.1);
|
||||||
if (!isWindows7OrHigher) {
|
if (!isWindows7OrHigher) {
|
||||||
document.getElementById("fillPosition").hidden = true;
|
document.getElementById("fillPosition").hidden = true;
|
||||||
document.getElementById("fitPosition").hidden = true;
|
document.getElementById("fitPosition").hidden = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
// make sure that the correct dimensions will be used
|
// make sure that the correct dimensions will be used
|
||||||
setTimeout(function(self) {
|
setTimeout(function(self) {
|
||||||
|
|
@ -62,24 +60,106 @@ var gSetBackground = {
|
||||||
var ctx = this._canvas.getContext("2d");
|
var ctx = this._canvas.getContext("2d");
|
||||||
ctx.scale(this._canvas.clientWidth / this._screenWidth, this._canvas.clientHeight / this._screenHeight);
|
ctx.scale(this._canvas.clientWidth / this._screenWidth, this._canvas.clientHeight / this._screenHeight);
|
||||||
|
|
||||||
#ifndef XP_MACOSX
|
if (AppConstants.platform != "macosx") {
|
||||||
this._initColor();
|
this._initColor();
|
||||||
#else
|
} else {
|
||||||
// Make sure to reset the button state in case the user has already
|
// Make sure to reset the button state in case the user has already
|
||||||
// set an image as their desktop background.
|
// set an image as their desktop background.
|
||||||
var setDesktopBackground = document.getElementById("setDesktopBackground");
|
var setDesktopBackground = document.getElementById("setDesktopBackground");
|
||||||
setDesktopBackground.hidden = false;
|
setDesktopBackground.hidden = false;
|
||||||
var bundle = document.getElementById("backgroundBundle");
|
var bundle = document.getElementById("backgroundBundle");
|
||||||
setDesktopBackground.label = bundle.getString("DesktopBackgroundSet");
|
setDesktopBackground.label = bundle.getString("DesktopBackgroundSet");
|
||||||
setDesktopBackground.disabled = false;
|
setDesktopBackground.disabled = false;
|
||||||
|
|
||||||
document.getElementById("showDesktopPreferences").hidden = true;
|
document.getElementById("showDesktopPreferences").hidden = true;
|
||||||
#endif
|
}
|
||||||
this.updatePosition();
|
this.updatePosition();
|
||||||
},
|
},
|
||||||
|
|
||||||
#ifndef XP_MACOSX
|
setDesktopBackground: function ()
|
||||||
_initColor: function ()
|
{
|
||||||
|
if (AppConstants.platform != "macosx") {
|
||||||
|
document.persist("menuPosition", "value");
|
||||||
|
this._shell.desktopBackgroundColor = this._hexStringToLong(this._backgroundColor);
|
||||||
|
} else {
|
||||||
|
Components.classes["@mozilla.org/observer-service;1"]
|
||||||
|
.getService(Ci.nsIObserverService)
|
||||||
|
.addObserver(this, "shell:desktop-background-changed", false);
|
||||||
|
|
||||||
|
var bundle = document.getElementById("backgroundBundle");
|
||||||
|
var setDesktopBackground = document.getElementById("setDesktopBackground");
|
||||||
|
setDesktopBackground.disabled = true;
|
||||||
|
setDesktopBackground.label = bundle.getString("DesktopBackgroundDownloading");
|
||||||
|
}
|
||||||
|
this._shell.setDesktopBackground(this._image,
|
||||||
|
Ci.nsIShellService["BACKGROUND_" + this._position]);
|
||||||
|
},
|
||||||
|
|
||||||
|
updatePosition: function ()
|
||||||
|
{
|
||||||
|
var ctx = this._canvas.getContext("2d");
|
||||||
|
ctx.clearRect(0, 0, this._screenWidth, this._screenHeight);
|
||||||
|
|
||||||
|
if (AppConstants.platform != "macosx") {
|
||||||
|
this._position = document.getElementById("menuPosition").value;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (this._position) {
|
||||||
|
case "TILE":
|
||||||
|
ctx.save();
|
||||||
|
ctx.fillStyle = ctx.createPattern(this._image, "repeat");
|
||||||
|
ctx.fillRect(0, 0, this._screenWidth, this._screenHeight);
|
||||||
|
ctx.restore();
|
||||||
|
break;
|
||||||
|
case "STRETCH":
|
||||||
|
ctx.drawImage(this._image, 0, 0, this._screenWidth, this._screenHeight);
|
||||||
|
break;
|
||||||
|
case "CENTER": {
|
||||||
|
let x = (this._screenWidth - this._image.naturalWidth) / 2;
|
||||||
|
let y = (this._screenHeight - this._image.naturalHeight) / 2;
|
||||||
|
ctx.drawImage(this._image, x, y);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "FILL": {
|
||||||
|
// Try maxing width first, overflow height.
|
||||||
|
let widthRatio = this._screenWidth / this._image.naturalWidth;
|
||||||
|
let width = this._image.naturalWidth * widthRatio;
|
||||||
|
let height = this._image.naturalHeight * widthRatio;
|
||||||
|
if (height < this._screenHeight) {
|
||||||
|
// Height less than screen, max height and overflow width.
|
||||||
|
let heightRatio = this._screenHeight / this._image.naturalHeight;
|
||||||
|
width = this._image.naturalWidth * heightRatio;
|
||||||
|
height = this._image.naturalHeight * heightRatio;
|
||||||
|
}
|
||||||
|
let x = (this._screenWidth - width) / 2;
|
||||||
|
let y = (this._screenHeight - height) / 2;
|
||||||
|
ctx.drawImage(this._image, x, y, width, height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "FIT": {
|
||||||
|
// Try maxing width first, top and bottom borders.
|
||||||
|
let widthRatio = this._screenWidth / this._image.naturalWidth;
|
||||||
|
let width = this._image.naturalWidth * widthRatio;
|
||||||
|
let height = this._image.naturalHeight * widthRatio;
|
||||||
|
let x = 0;
|
||||||
|
let y = (this._screenHeight - height) / 2;
|
||||||
|
if (height > this._screenHeight) {
|
||||||
|
// Height overflow, maximise height, side borders.
|
||||||
|
let heightRatio = this._screenHeight / this._image.naturalHeight;
|
||||||
|
width = this._image.naturalWidth * heightRatio;
|
||||||
|
height = this._image.naturalHeight * heightRatio;
|
||||||
|
x = (this._screenWidth - width) / 2;
|
||||||
|
y = 0;
|
||||||
|
}
|
||||||
|
ctx.drawImage(this._image, x, y, width, height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (AppConstants.platform != "macosx") {
|
||||||
|
gSetBackground["_initColor"] = function ()
|
||||||
{
|
{
|
||||||
var color = this._shell.desktopBackgroundColor;
|
var color = this._shell.desktopBackgroundColor;
|
||||||
|
|
||||||
|
|
@ -93,29 +173,29 @@ var gSetBackground = {
|
||||||
|
|
||||||
var colorpicker = document.getElementById("desktopColor");
|
var colorpicker = document.getElementById("desktopColor");
|
||||||
colorpicker.color = this._backgroundColor;
|
colorpicker.color = this._backgroundColor;
|
||||||
},
|
};
|
||||||
|
|
||||||
updateColor: function (aColor)
|
gSetBackground["updateColor"] = function (aColor)
|
||||||
{
|
{
|
||||||
this._backgroundColor = aColor;
|
this._backgroundColor = aColor;
|
||||||
this._canvas.style.backgroundColor = aColor;
|
this._canvas.style.backgroundColor = aColor;
|
||||||
},
|
};
|
||||||
|
|
||||||
// Converts a color string in the format "#RRGGBB" to an integer.
|
// Converts a color string in the format "#RRGGBB" to an integer.
|
||||||
_hexStringToLong: function (aString)
|
gSetBackground["_hexStringToLong"] = function (aString)
|
||||||
{
|
{
|
||||||
return parseInt(aString.substring(1,3), 16) << 16 |
|
return parseInt(aString.substring(1, 3), 16) << 16 |
|
||||||
parseInt(aString.substring(3,5), 16) << 8 |
|
parseInt(aString.substring(3, 5), 16) << 8 |
|
||||||
parseInt(aString.substring(5,7), 16);
|
parseInt(aString.substring(5, 7), 16);
|
||||||
},
|
};
|
||||||
|
|
||||||
_rgbToHex: function (aR, aG, aB)
|
gSetBackground["_rgbToHex"] = function (aR, aG, aB)
|
||||||
{
|
{
|
||||||
return "#" + [aR, aG, aB].map(function(aInt) aInt.toString(16).replace(/^(.)$/, "0$1"))
|
return "#" + [aR, aG, aB].map(aInt => aInt.toString(16).replace(/^(.)$/, "0$1"))
|
||||||
.join("").toUpperCase();
|
.join("").toUpperCase();
|
||||||
},
|
};
|
||||||
#else
|
} else {
|
||||||
observe: function (aSubject, aTopic, aData)
|
gSetBackground["observe"] = function (aSubject, aTopic, aData)
|
||||||
{
|
{
|
||||||
if (aTopic == "shell:desktop-background-changed") {
|
if (aTopic == "shell:desktop-background-changed") {
|
||||||
document.getElementById("setDesktopBackground").hidden = true;
|
document.getElementById("setDesktopBackground").hidden = true;
|
||||||
|
|
@ -125,89 +205,10 @@ var gSetBackground = {
|
||||||
.getService(Ci.nsIObserverService)
|
.getService(Ci.nsIObserverService)
|
||||||
.removeObserver(this, "shell:desktop-background-changed");
|
.removeObserver(this, "shell:desktop-background-changed");
|
||||||
}
|
}
|
||||||
},
|
};
|
||||||
|
|
||||||
showDesktopPrefs: function()
|
gSetBackground["showDesktopPrefs"] = function()
|
||||||
{
|
{
|
||||||
this._shell.openApplication(Ci.nsIMacShellService.APPLICATION_DESKTOP);
|
this._shell.openApplication(Ci.nsIMacShellService.APPLICATION_DESKTOP);
|
||||||
},
|
};
|
||||||
#endif
|
}
|
||||||
|
|
||||||
setDesktopBackground: function ()
|
|
||||||
{
|
|
||||||
#ifndef XP_MACOSX
|
|
||||||
document.persist("menuPosition", "value");
|
|
||||||
this._shell.desktopBackgroundColor = this._hexStringToLong(this._backgroundColor);
|
|
||||||
#else
|
|
||||||
Components.classes["@mozilla.org/observer-service;1"]
|
|
||||||
.getService(Ci.nsIObserverService)
|
|
||||||
.addObserver(this, "shell:desktop-background-changed", false);
|
|
||||||
|
|
||||||
var bundle = document.getElementById("backgroundBundle");
|
|
||||||
var setDesktopBackground = document.getElementById("setDesktopBackground");
|
|
||||||
setDesktopBackground.disabled = true;
|
|
||||||
setDesktopBackground.label = bundle.getString("DesktopBackgroundDownloading");
|
|
||||||
#endif
|
|
||||||
this._shell.setDesktopBackground(this._image,
|
|
||||||
Ci.nsIShellService["BACKGROUND_" + this._position]);
|
|
||||||
},
|
|
||||||
|
|
||||||
updatePosition: function ()
|
|
||||||
{
|
|
||||||
var ctx = this._canvas.getContext("2d");
|
|
||||||
ctx.clearRect(0, 0, this._screenWidth, this._screenHeight);
|
|
||||||
|
|
||||||
#ifndef XP_MACOSX
|
|
||||||
this._position = document.getElementById("menuPosition").value;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
switch (this._position) {
|
|
||||||
case "TILE":
|
|
||||||
ctx.save();
|
|
||||||
ctx.fillStyle = ctx.createPattern(this._image, "repeat");
|
|
||||||
ctx.fillRect(0, 0, this._screenWidth, this._screenHeight);
|
|
||||||
ctx.restore();
|
|
||||||
break;
|
|
||||||
case "STRETCH":
|
|
||||||
ctx.drawImage(this._image, 0, 0, this._screenWidth, this._screenHeight);
|
|
||||||
break;
|
|
||||||
case "CENTER":
|
|
||||||
var x = (this._screenWidth - this._image.naturalWidth) / 2;
|
|
||||||
var y = (this._screenHeight - this._image.naturalHeight) / 2;
|
|
||||||
ctx.drawImage(this._image, x, y);
|
|
||||||
break;
|
|
||||||
case "FILL":
|
|
||||||
//Try maxing width first, overflow height
|
|
||||||
var widthRatio = this._screenWidth / this._image.naturalWidth;
|
|
||||||
var width = this._image.naturalWidth * widthRatio;
|
|
||||||
var height = this._image.naturalHeight * widthRatio;
|
|
||||||
if (height < this._screenHeight) {
|
|
||||||
//height less than screen, max height and overflow width
|
|
||||||
var heightRatio = this._screenHeight / this._image.naturalHeight;
|
|
||||||
width = this._image.naturalWidth * heightRatio;
|
|
||||||
height = this._image.naturalHeight * heightRatio;
|
|
||||||
}
|
|
||||||
var x = (this._screenWidth - width) / 2;
|
|
||||||
var y = (this._screenHeight - height) / 2;
|
|
||||||
ctx.drawImage(this._image, x, y, width, height);
|
|
||||||
break;
|
|
||||||
case "FIT":
|
|
||||||
//Try maxing width first, top and bottom borders
|
|
||||||
var widthRatio = this._screenWidth / this._image.naturalWidth;
|
|
||||||
var width = this._image.naturalWidth * widthRatio;
|
|
||||||
var height = this._image.naturalHeight * widthRatio;
|
|
||||||
var x = 0;
|
|
||||||
var y = (this._screenHeight - height) / 2;
|
|
||||||
if (height > this._screenHeight) {
|
|
||||||
//height overflow, maximise height, side borders
|
|
||||||
var heightRatio = this._screenHeight / this._image.naturalHeight;
|
|
||||||
width = this._image.naturalWidth * heightRatio;
|
|
||||||
height = this._image.naturalHeight * heightRatio;
|
|
||||||
x = (this._screenWidth - width) / 2;
|
|
||||||
y = 0;
|
|
||||||
}
|
|
||||||
ctx.drawImage(this._image, x, y, width, height);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@
|
||||||
|
|
||||||
browser.jar:
|
browser.jar:
|
||||||
* content/browser/setDesktopBackground.xul (content/setDesktopBackground.xul)
|
* content/browser/setDesktopBackground.xul (content/setDesktopBackground.xul)
|
||||||
* content/browser/setDesktopBackground.js (content/setDesktopBackground.js)
|
content/browser/setDesktopBackground.js (content/setDesktopBackground.js)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||||
# vim: set filetype=python:
|
# vim: set filetype=python:
|
||||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
# 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
|
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
|
@ -18,6 +18,10 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||||
XPIDL_SOURCES += [
|
XPIDL_SOURCES += [
|
||||||
'nsIMacShellService.idl',
|
'nsIMacShellService.idl',
|
||||||
]
|
]
|
||||||
|
elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
|
||||||
|
XPIDL_SOURCES += [
|
||||||
|
'nsIGNOMEShellService.idl',
|
||||||
|
]
|
||||||
|
|
||||||
XPIDL_MODULE = 'shellservice'
|
XPIDL_MODULE = 'shellservice'
|
||||||
|
|
||||||
|
|
@ -29,7 +33,7 @@ elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||||
SOURCES += [
|
SOURCES += [
|
||||||
'nsMacShellService.cpp',
|
'nsMacShellService.cpp',
|
||||||
]
|
]
|
||||||
elif CONFIG['MOZ_WIDGET_GTK']:
|
elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
|
||||||
SOURCES += [
|
SOURCES += [
|
||||||
'nsGNOMEShellService.cpp',
|
'nsGNOMEShellService.cpp',
|
||||||
]
|
]
|
||||||
|
|
@ -42,6 +46,10 @@ EXTRA_COMPONENTS += [
|
||||||
'nsSetDefaultBrowser.manifest',
|
'nsSetDefaultBrowser.manifest',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
EXTRA_JS_MODULES += [
|
||||||
|
'ShellService.jsm',
|
||||||
|
]
|
||||||
|
|
||||||
for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'):
|
for var in ('MOZ_APP_NAME', 'MOZ_APP_VERSION'):
|
||||||
DEFINES[var] = '"%s"' % CONFIG[var]
|
DEFINES[var] = '"%s"' % CONFIG[var]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,12 +21,13 @@
|
||||||
#include "nsIStringBundle.h"
|
#include "nsIStringBundle.h"
|
||||||
#include "nsIOutputStream.h"
|
#include "nsIOutputStream.h"
|
||||||
#include "nsIProcess.h"
|
#include "nsIProcess.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsServiceManagerUtils.h"
|
||||||
|
#include "nsComponentManagerUtils.h"
|
||||||
#include "nsIDOMHTMLImageElement.h"
|
#include "nsIDOMHTMLImageElement.h"
|
||||||
#include "nsIImageLoadingContent.h"
|
#include "nsIImageLoadingContent.h"
|
||||||
#include "imgIRequest.h"
|
#include "imgIRequest.h"
|
||||||
#include "imgIContainer.h"
|
#include "imgIContainer.h"
|
||||||
#include "prprf.h"
|
#include "mozilla/Sprintf.h"
|
||||||
#if defined(MOZ_WIDGET_GTK)
|
#if defined(MOZ_WIDGET_GTK)
|
||||||
#include "nsIImageToPixbuf.h"
|
#include "nsIImageToPixbuf.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -116,7 +117,7 @@ nsGNOMEShellService::Init()
|
||||||
return appPath->GetNativePath(mAppPath);
|
return appPath->GetNativePath(mAppPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMPL_ISUPPORTS(nsGNOMEShellService, nsIShellService)
|
NS_IMPL_ISUPPORTS(nsGNOMEShellService, nsIGNOMEShellService, nsIShellService)
|
||||||
|
|
||||||
bool
|
bool
|
||||||
nsGNOMEShellService::GetAppPathFromLauncher()
|
nsGNOMEShellService::GetAppPathFromLauncher()
|
||||||
|
|
@ -152,7 +153,8 @@ nsGNOMEShellService::KeyMatchesAppName(const char *aKeyValue) const
|
||||||
|
|
||||||
gchar *commandPath;
|
gchar *commandPath;
|
||||||
if (mUseLocaleFilenames) {
|
if (mUseLocaleFilenames) {
|
||||||
gchar *nativePath = g_filename_from_utf8(aKeyValue, -1, nullptr, nullptr, nullptr);
|
gchar *nativePath = g_filename_from_utf8(aKeyValue, -1,
|
||||||
|
nullptr, nullptr, nullptr);
|
||||||
if (!nativePath) {
|
if (!nativePath) {
|
||||||
NS_ERROR("Error converting path to filesystem encoding");
|
NS_ERROR("Error converting path to filesystem encoding");
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -199,8 +201,6 @@ nsGNOMEShellService::IsDefaultBrowser(bool aStartupCheck,
|
||||||
bool* aIsDefaultBrowser)
|
bool* aIsDefaultBrowser)
|
||||||
{
|
{
|
||||||
*aIsDefaultBrowser = false;
|
*aIsDefaultBrowser = false;
|
||||||
if (aStartupCheck)
|
|
||||||
mCheckedThisSession = true;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
nsCOMPtr<nsIGConfService> gconf = do_GetService(NS_GCONFSERVICE_CONTRACTID);
|
||||||
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
nsCOMPtr<nsIGIOService> giovfs = do_GetService(NS_GIOSERVICE_CONTRACTID);
|
||||||
|
|
@ -284,7 +284,7 @@ nsGNOMEShellService::SetDefaultBrowser(bool aClaimAllTypes,
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
nsString brandShortName;
|
nsString brandShortName;
|
||||||
brandBundle->GetStringFromName(MOZ_UTF16("brandShortName"),
|
brandBundle->GetStringFromName(u"brandShortName",
|
||||||
getter_Copies(brandShortName));
|
getter_Copies(brandShortName));
|
||||||
|
|
||||||
// use brandShortName as the application id.
|
// use brandShortName as the application id.
|
||||||
|
|
@ -312,41 +312,14 @@ nsGNOMEShellService::SetDefaultBrowser(bool aClaimAllTypes,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||||
}
|
if (prefs) {
|
||||||
|
(void) prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, true);
|
||||||
NS_IMETHODIMP
|
// Reset the number of times the dialog should be shown
|
||||||
nsGNOMEShellService::GetShouldCheckDefaultBrowser(bool* aResult)
|
// before it is silenced.
|
||||||
{
|
(void) prefs->SetIntPref(PREF_DEFAULTBROWSERCHECKCOUNT, 0);
|
||||||
// If we've already checked, the browser has been started and this is a
|
|
||||||
// new window open, and we don't want to check again.
|
|
||||||
if (mCheckedThisSession) {
|
|
||||||
*aResult = false;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
||||||
if (pserve)
|
|
||||||
pserve->GetBranch("", getter_AddRefs(prefs));
|
|
||||||
|
|
||||||
if (prefs)
|
|
||||||
prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsGNOMEShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
||||||
if (pserve)
|
|
||||||
pserve->GetBranch("", getter_AddRefs(prefs));
|
|
||||||
|
|
||||||
if (prefs)
|
|
||||||
prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -407,15 +380,15 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||||
// Set desktop wallpaper filling style
|
// Set desktop wallpaper filling style
|
||||||
nsAutoCString options;
|
nsAutoCString options;
|
||||||
if (aPosition == BACKGROUND_TILE)
|
if (aPosition == BACKGROUND_TILE)
|
||||||
options.Assign("wallpaper");
|
options.AssignLiteral("wallpaper");
|
||||||
else if (aPosition == BACKGROUND_STRETCH)
|
else if (aPosition == BACKGROUND_STRETCH)
|
||||||
options.Assign("stretched");
|
options.AssignLiteral("stretched");
|
||||||
else if (aPosition == BACKGROUND_FILL)
|
else if (aPosition == BACKGROUND_FILL)
|
||||||
options.Assign("zoom");
|
options.AssignLiteral("zoom");
|
||||||
else if (aPosition == BACKGROUND_FIT)
|
else if (aPosition == BACKGROUND_FIT)
|
||||||
options.Assign("scaled");
|
options.AssignLiteral("scaled");
|
||||||
else
|
else
|
||||||
options.Assign("centered");
|
options.AssignLiteral("centered");
|
||||||
|
|
||||||
// Write the background file to the home directory.
|
// Write the background file to the home directory.
|
||||||
nsAutoCString filePath(PR_GetEnv("HOME"));
|
nsAutoCString filePath(PR_GetEnv("HOME"));
|
||||||
|
|
@ -429,7 +402,7 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||||
rv = bundleService->CreateBundle(BRAND_PROPERTIES,
|
rv = bundleService->CreateBundle(BRAND_PROPERTIES,
|
||||||
getter_AddRefs(brandBundle));
|
getter_AddRefs(brandBundle));
|
||||||
if (NS_SUCCEEDED(rv) && brandBundle) {
|
if (NS_SUCCEEDED(rv) && brandBundle) {
|
||||||
rv = brandBundle->GetStringFromName(MOZ_UTF16("brandShortName"),
|
rv = brandBundle->GetStringFromName(u"brandShortName",
|
||||||
getter_Copies(brandName));
|
getter_Copies(brandName));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
}
|
}
|
||||||
|
|
@ -438,7 +411,7 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||||
// build the file name
|
// build the file name
|
||||||
filePath.Append('/');
|
filePath.Append('/');
|
||||||
filePath.Append(NS_ConvertUTF16toUTF8(brandName));
|
filePath.Append(NS_ConvertUTF16toUTF8(brandName));
|
||||||
filePath.Append("_wallpaper.png");
|
filePath.AppendLiteral("_wallpaper.png");
|
||||||
|
|
||||||
// write the image to a file in the home dir
|
// write the image to a file in the home dir
|
||||||
rv = WriteImage(filePath, container);
|
rv = WriteImage(filePath, container);
|
||||||
|
|
@ -478,7 +451,7 @@ nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||||
|
|
||||||
// Set the image to an empty string first to force a refresh
|
// Set the image to an empty string first to force a refresh
|
||||||
// (since we could be writing a new image on top of an existing
|
// (since we could be writing a new image on top of an existing
|
||||||
// Firefox_wallpaper.png and nautilus doesn't monitor the file for changes)
|
// PaleMoon_wallpaper.png and nautilus doesn't monitor the file for changes)
|
||||||
gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey),
|
gconf->SetString(NS_LITERAL_CSTRING(kDesktopImageKey),
|
||||||
EmptyCString());
|
EmptyCString());
|
||||||
|
|
||||||
|
|
@ -543,7 +516,7 @@ ColorToCString(uint32_t aColor, nsCString& aResult)
|
||||||
uint16_t green = COLOR_8_TO_16_BIT((aColor >> 8) & 0xff);
|
uint16_t green = COLOR_8_TO_16_BIT((aColor >> 8) & 0xff);
|
||||||
uint16_t blue = COLOR_8_TO_16_BIT(aColor & 0xff);
|
uint16_t blue = COLOR_8_TO_16_BIT(aColor & 0xff);
|
||||||
|
|
||||||
PR_snprintf(buf, 14, "#%04x%04x%04x", red, green, blue);
|
snprintf(buf, 14, "#%04x%04x%04x", red, green, blue);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
@ -580,9 +553,9 @@ nsGNOMEShellService::OpenApplication(int32_t aApplication)
|
||||||
{
|
{
|
||||||
nsAutoCString scheme;
|
nsAutoCString scheme;
|
||||||
if (aApplication == APPLICATION_MAIL)
|
if (aApplication == APPLICATION_MAIL)
|
||||||
scheme.Assign("mailto");
|
scheme.AssignLiteral("mailto");
|
||||||
else if (aApplication == APPLICATION_NEWS)
|
else if (aApplication == APPLICATION_NEWS)
|
||||||
scheme.Assign("news");
|
scheme.AssignLiteral("news");
|
||||||
else
|
else
|
||||||
return NS_ERROR_NOT_AVAILABLE;
|
return NS_ERROR_NOT_AVAILABLE;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,28 +6,28 @@
|
||||||
#ifndef nsgnomeshellservice_h____
|
#ifndef nsgnomeshellservice_h____
|
||||||
#define nsgnomeshellservice_h____
|
#define nsgnomeshellservice_h____
|
||||||
|
|
||||||
#include "nsIShellService.h"
|
#include "nsIGNOMEShellService.h"
|
||||||
#include "nsStringAPI.h"
|
#include "nsStringAPI.h"
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
|
||||||
class nsGNOMEShellService final : public nsIShellService
|
class nsGNOMEShellService final : public nsIGNOMEShellService
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsGNOMEShellService() : mCheckedThisSession(false), mAppIsInPath(false) { }
|
nsGNOMEShellService() : mAppIsInPath(false) { }
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSISHELLSERVICE
|
NS_DECL_NSISHELLSERVICE
|
||||||
|
NS_DECL_NSIGNOMESHELLSERVICE
|
||||||
|
|
||||||
nsresult Init() NS_HIDDEN;
|
nsresult Init();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
~nsGNOMEShellService() {}
|
~nsGNOMEShellService() {}
|
||||||
|
|
||||||
NS_HIDDEN_(bool) KeyMatchesAppName(const char *aKeyValue) const;
|
bool KeyMatchesAppName(const char *aKeyValue) const;
|
||||||
NS_HIDDEN_(bool) CheckHandlerMatchesAppName(const nsACString& handler) const;
|
bool CheckHandlerMatchesAppName(const nsACString& handler) const;
|
||||||
|
|
||||||
NS_HIDDEN_(bool) GetAppPathFromLauncher();
|
bool GetAppPathFromLauncher();
|
||||||
bool mCheckedThisSession;
|
|
||||||
bool mUseLocaleFilenames;
|
bool mUseLocaleFilenames;
|
||||||
nsCString mAppPath;
|
nsCString mAppPath;
|
||||||
bool mAppIsInPath;
|
bool mAppIsInPath;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* 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 "nsIShellService.idl"
|
||||||
|
|
||||||
|
[scriptable, uuid(2ce5c803-edcd-443d-98eb-ceba86d02d13)]
|
||||||
|
interface nsIGNOMEShellService : nsIShellService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Used to determine whether or not to offer "Set as desktop background"
|
||||||
|
* functionality. Even if shell service is available it is not
|
||||||
|
* guaranteed that it is able to set the background for every desktop
|
||||||
|
* which is especially true for Linux with its many different desktop
|
||||||
|
* environments.
|
||||||
|
*/
|
||||||
|
readonly attribute boolean canSetDesktopBackground;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "nsIShellService.idl"
|
#include "nsIShellService.idl"
|
||||||
|
|
||||||
[scriptable, uuid(7f8ca08e-1df4-4735-86e9-50dedb48e5e8)]
|
[scriptable, uuid(387fdc80-0077-4b60-a0d9-d9e80a83ba64)]
|
||||||
interface nsIMacShellService : nsIShellService
|
interface nsIMacShellService : nsIShellService
|
||||||
{
|
{
|
||||||
const long APPLICATION_KEYCHAIN_ACCESS = 2;
|
const long APPLICATION_KEYCHAIN_ACCESS = 2;
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
interface nsIDOMElement;
|
interface nsIDOMElement;
|
||||||
interface nsIFile;
|
interface nsIFile;
|
||||||
|
|
||||||
[scriptable, uuid(99d2e9f1-3c86-40f7-81fd-3060c18489f0)]
|
[scriptable, uuid(2d1a95e4-5bd8-4eeb-b0a8-c1455fd2a357)]
|
||||||
interface nsIShellService : nsISupports
|
interface nsIShellService : nsISupports
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
@ -38,23 +38,6 @@ interface nsIShellService : nsISupports
|
||||||
*/
|
*/
|
||||||
void setDefaultBrowser(in boolean aClaimAllTypes, in boolean aForAllUsers);
|
void setDefaultBrowser(in boolean aClaimAllTypes, in boolean aForAllUsers);
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to determine whether or not to show a "Set Default Browser"
|
|
||||||
* query dialog. This attribute is true if the application is starting
|
|
||||||
* up and "browser.shell.checkDefaultBrowser" is true, otherwise it
|
|
||||||
* is false.
|
|
||||||
*/
|
|
||||||
attribute boolean shouldCheckDefaultBrowser;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Used to determine whether or not to offer "Set as desktop background"
|
|
||||||
* functionality. Even if shell service is available it is not
|
|
||||||
* guaranteed that it is able to set the background for every desktop
|
|
||||||
* which is especially true for Linux with its many different desktop
|
|
||||||
* environments.
|
|
||||||
*/
|
|
||||||
readonly attribute boolean canSetDesktopBackground;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flags for positioning/sizing of the Desktop Background image.
|
* Flags for positioning/sizing of the Desktop Background image.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "nsIShellService.idl"
|
#include "nsIShellService.idl"
|
||||||
|
|
||||||
[scriptable, uuid(89b0a761-d9a0-4c39-ab83-d81566459a31)]
|
[scriptable, uuid(f8a26b94-49e5-4441-8fbc-315e0b4f22ef)]
|
||||||
interface nsIWindowsShellService : nsIShellService
|
interface nsIWindowsShellService : nsIShellService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,13 @@
|
||||||
#include "nsIURL.h"
|
#include "nsIURL.h"
|
||||||
#include "nsIWebBrowserPersist.h"
|
#include "nsIWebBrowserPersist.h"
|
||||||
#include "nsMacShellService.h"
|
#include "nsMacShellService.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsIProperties.h"
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "nsShellService.h"
|
#include "nsShellService.h"
|
||||||
#include "nsStringAPI.h"
|
#include "nsStringAPI.h"
|
||||||
#include "nsIDocShell.h"
|
#include "nsIDocShell.h"
|
||||||
#include "nsILoadContext.h"
|
#include "nsILoadContext.h"
|
||||||
|
|
||||||
|
|
||||||
#include <CoreFoundation/CoreFoundation.h>
|
#include <CoreFoundation/CoreFoundation.h>
|
||||||
#include <ApplicationServices/ApplicationServices.h>
|
#include <ApplicationServices/ApplicationServices.h>
|
||||||
|
|
||||||
|
|
@ -49,19 +49,14 @@ nsMacShellService::IsDefaultBrowser(bool aStartupCheck,
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the default http handler's bundle ID (or nullptr if it has not been explicitly set)
|
// Get the default http handler's bundle ID (or nullptr if it has not been
|
||||||
|
// explicitly set)
|
||||||
CFStringRef defaultBrowserID = ::LSCopyDefaultHandlerForURLScheme(CFSTR("http"));
|
CFStringRef defaultBrowserID = ::LSCopyDefaultHandlerForURLScheme(CFSTR("http"));
|
||||||
if (defaultBrowserID) {
|
if (defaultBrowserID) {
|
||||||
*aIsDefaultBrowser = ::CFStringCompare(firefoxID, defaultBrowserID, 0) == kCFCompareEqualTo;
|
*aIsDefaultBrowser = ::CFStringCompare(firefoxID, defaultBrowserID, 0) == kCFCompareEqualTo;
|
||||||
::CFRelease(defaultBrowserID);
|
::CFRelease(defaultBrowserID);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this is the first browser window, maintain internal state that we've
|
|
||||||
// checked this session (so that subsequent window opens don't show the
|
|
||||||
// default browser dialog).
|
|
||||||
if (aStartupCheck)
|
|
||||||
mCheckedThisSession = true;
|
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,46 +86,14 @@ nsMacShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NS_OK;
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||||
}
|
if (prefs) {
|
||||||
|
(void) prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, true);
|
||||||
NS_IMETHODIMP
|
// Reset the number of times the dialog should be shown
|
||||||
nsMacShellService::GetShouldCheckDefaultBrowser(bool* aResult)
|
// before it is silenced.
|
||||||
{
|
(void) prefs->SetIntPref(PREF_DEFAULTBROWSERCHECKCOUNT, 0);
|
||||||
// If we've already checked, the browser has been started and this is a
|
|
||||||
// new window open, and we don't want to check again.
|
|
||||||
if (mCheckedThisSession) {
|
|
||||||
*aResult = false;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
||||||
if (pserve)
|
|
||||||
pserve->GetBranch("", getter_AddRefs(prefs));
|
|
||||||
|
|
||||||
prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMacShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
|
||||||
if (pserve)
|
|
||||||
pserve->GetBranch("", getter_AddRefs(prefs));
|
|
||||||
|
|
||||||
prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsMacShellService::GetCanSetDesktopBackground(bool* aResult)
|
|
||||||
{
|
|
||||||
*aResult = true;
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -202,8 +165,10 @@ nsMacShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||||
loadContext = do_QueryInterface(docShell);
|
loadContext = do_QueryInterface(docShell);
|
||||||
}
|
}
|
||||||
|
|
||||||
return wbp->SaveURI(imageURI, nullptr, docURI, content->OwnerDoc()->GetReferrerPolicy(),
|
return wbp->SaveURI(imageURI, nullptr,
|
||||||
nullptr, nullptr, mBackgroundFile, loadContext);
|
docURI, content->OwnerDoc()->GetReferrerPolicy(),
|
||||||
|
nullptr, nullptr,
|
||||||
|
mBackgroundFile, loadContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
@ -269,7 +234,8 @@ nsMacShellService::OnStateChange(nsIWebProgress* aWebProgress,
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
|
|
||||||
// Convert the path into a FSRef
|
// Convert the path into a FSRef
|
||||||
status = ::FSPathMakeRef((const UInt8*)nativePath.get(), &pictureRef, nullptr);
|
status = ::FSPathMakeRef((const UInt8*)nativePath.get(), &pictureRef,
|
||||||
|
nullptr);
|
||||||
if (status == noErr) {
|
if (status == noErr) {
|
||||||
err = ::FSNewAlias(nil, &pictureRef, &aliasHandle);
|
err = ::FSNewAlias(nil, &pictureRef, &aliasHandle);
|
||||||
if (err == noErr && aliasHandle == nil)
|
if (err == noErr && aliasHandle == nil)
|
||||||
|
|
@ -336,8 +302,8 @@ nsMacShellService::OpenApplication(int32_t aApplication)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case nsIMacShellService::APPLICATION_KEYCHAIN_ACCESS:
|
case nsIMacShellService::APPLICATION_KEYCHAIN_ACCESS:
|
||||||
err = ::LSGetApplicationForInfo('APPL', 'kcmr', nullptr, kLSRolesAll, nullptr,
|
err = ::LSGetApplicationForInfo('APPL', 'kcmr', nullptr, kLSRolesAll,
|
||||||
&appURL);
|
nullptr, &appURL);
|
||||||
break;
|
break;
|
||||||
case nsIMacShellService::APPLICATION_NETWORK:
|
case nsIMacShellService::APPLICATION_NETWORK:
|
||||||
{
|
{
|
||||||
|
|
@ -350,7 +316,6 @@ nsMacShellService::OpenApplication(int32_t aApplication)
|
||||||
return NS_ERROR_FILE_NOT_FOUND;
|
return NS_ERROR_FILE_NOT_FOUND;
|
||||||
return lf->Launch();
|
return lf->Launch();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case nsIMacShellService::APPLICATION_DESKTOP:
|
case nsIMacShellService::APPLICATION_DESKTOP:
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIFile> lf;
|
nsCOMPtr<nsIFile> lf;
|
||||||
|
|
@ -362,7 +327,6 @@ nsMacShellService::OpenApplication(int32_t aApplication)
|
||||||
return NS_ERROR_FILE_NOT_FOUND;
|
return NS_ERROR_FILE_NOT_FOUND;
|
||||||
return lf->Launch();
|
return lf->Launch();
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (appURL && err == noErr) {
|
if (appURL && err == noErr) {
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ class nsMacShellService : public nsIMacShellService,
|
||||||
public nsIWebProgressListener
|
public nsIWebProgressListener
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
nsMacShellService() : mCheckedThisSession(false) {};
|
nsMacShellService() {};
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSISHELLSERVICE
|
NS_DECL_NSISHELLSERVICE
|
||||||
|
|
@ -27,8 +27,6 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
nsCOMPtr<nsIFile> mBackgroundFile;
|
nsCOMPtr<nsIFile> mBackgroundFile;
|
||||||
|
|
||||||
bool mCheckedThisSession;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsmacshellservice_h____
|
#endif // nsmacshellservice_h____
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* -setDefaultBrowser commandline handler
|
* --setDefaultBrowser commandline handler
|
||||||
* Makes the current executable the "default browser".
|
* Makes the current executable the "default browser".
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
|
Components.utils.import("resource:///modules/ShellService.jsm");
|
||||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
function nsSetDefaultBrowser() {}
|
function nsSetDefaultBrowser() {}
|
||||||
|
|
@ -16,13 +17,11 @@ function nsSetDefaultBrowser() {}
|
||||||
nsSetDefaultBrowser.prototype = {
|
nsSetDefaultBrowser.prototype = {
|
||||||
handle: function nsSetDefault_handle(aCmdline) {
|
handle: function nsSetDefault_handle(aCmdline) {
|
||||||
if (aCmdline.handleFlag("setDefaultBrowser", false)) {
|
if (aCmdline.handleFlag("setDefaultBrowser", false)) {
|
||||||
var shell = Cc["@mozilla.org/browser/shell-service;1"].
|
ShellService.setDefaultBrowser(true, true);
|
||||||
getService(Ci.nsIShellService);
|
|
||||||
shell.setDefaultBrowser(true, true);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
helpInfo: " -setDefaultBrowser Set this app as the default browser.\n",
|
helpInfo: " --setDefaultBrowser Set this app as the default browser.\n",
|
||||||
|
|
||||||
classID: Components.ID("{F57899D0-4E2C-4ac6-9E29-50C736103B0C}"),
|
classID: Components.ID("{F57899D0-4E2C-4ac6-9E29-50C736103B0C}"),
|
||||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsICommandLineHandler]),
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#define PREF_CHECKDEFAULTBROWSER "browser.shell.checkDefaultBrowser"
|
#define PREF_CHECKDEFAULTBROWSER "browser.shell.checkDefaultBrowser"
|
||||||
|
#define PREF_SKIPDEFAULTBROWSERCHECK "browser.shell.skipDefaultBrowserCheck"
|
||||||
|
#define PREF_DEFAULTBROWSERCHECKCOUNT "browser.shell.defaultBrowserCheckCount"
|
||||||
|
|
||||||
#define SHELLSERVICE_PROPERTIES "chrome://browser/locale/shellservice.properties"
|
#define SHELLSERVICE_PROPERTIES "chrome://browser/locale/shellservice.properties"
|
||||||
#define BRAND_PROPERTIES "chrome://branding/locale/brand.properties"
|
#define BRAND_PROPERTIES "chrome://branding/locale/brand.properties"
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#include "nsWindowsShellService.h"
|
||||||
|
|
||||||
#include "imgIContainer.h"
|
#include "imgIContainer.h"
|
||||||
#include "imgIRequest.h"
|
#include "imgIRequest.h"
|
||||||
#include "mozilla/gfx/2D.h"
|
#include "mozilla/gfx/2D.h"
|
||||||
|
|
@ -15,8 +17,8 @@
|
||||||
#include "nsIServiceManager.h"
|
#include "nsIServiceManager.h"
|
||||||
#include "nsIStringBundle.h"
|
#include "nsIStringBundle.h"
|
||||||
#include "nsNetUtil.h"
|
#include "nsNetUtil.h"
|
||||||
|
#include "nsServiceManagerUtils.h"
|
||||||
#include "nsShellService.h"
|
#include "nsShellService.h"
|
||||||
#include "nsWindowsShellService.h"
|
|
||||||
#include "nsIProcess.h"
|
#include "nsIProcess.h"
|
||||||
#include "nsICategoryManager.h"
|
#include "nsICategoryManager.h"
|
||||||
#include "nsBrowserCompsCID.h"
|
#include "nsBrowserCompsCID.h"
|
||||||
|
|
@ -27,6 +29,7 @@
|
||||||
#include "nsUnicharUtils.h"
|
#include "nsUnicharUtils.h"
|
||||||
#include "nsIWinTaskbar.h"
|
#include "nsIWinTaskbar.h"
|
||||||
#include "nsISupportsPrimitives.h"
|
#include "nsISupportsPrimitives.h"
|
||||||
|
#include "nsIURLFormatter.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsXULAppAPI.h"
|
#include "nsXULAppAPI.h"
|
||||||
#include "mozilla/WindowsVersion.h"
|
#include "mozilla/WindowsVersion.h"
|
||||||
|
|
@ -47,6 +50,9 @@
|
||||||
#include <mbstring.h>
|
#include <mbstring.h>
|
||||||
#include <shlwapi.h>
|
#include <shlwapi.h>
|
||||||
|
|
||||||
|
#include <lm.h>
|
||||||
|
#undef ACCESS_READ
|
||||||
|
|
||||||
#ifndef MAX_BUF
|
#ifndef MAX_BUF
|
||||||
#define MAX_BUF 4096
|
#define MAX_BUF 4096
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -129,7 +135,7 @@ OpenKeyForReading(HKEY aKeyRoot, const nsAString& aKeyName, HKEY* aKey)
|
||||||
// The following keys are set to make PaleMoon appear in the Start Menu as the
|
// The following keys are set to make PaleMoon appear in the Start Menu as the
|
||||||
// browser:
|
// browser:
|
||||||
//
|
//
|
||||||
// HKCU\SOFTWARE\Clients\StartMenuInternet\FIREFOX.EXE\
|
// HKCU\SOFTWARE\Clients\StartMenuInternet\PaleMoon.EXE\
|
||||||
// (default) REG_SZ <appname>
|
// (default) REG_SZ <appname>
|
||||||
// DefaultIcon (default) REG_SZ <apppath>,0
|
// DefaultIcon (default) REG_SZ <apppath>,0
|
||||||
// InstallInfo HideIconsCommand REG_SZ <uninstpath> /HideShortcuts
|
// InstallInfo HideIconsCommand REG_SZ <uninstpath> /HideShortcuts
|
||||||
|
|
@ -278,20 +284,15 @@ nsWindowsShellService::ShortcutMaintenance()
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
NS_NAMED_LITERAL_CSTRING(prefName, "browser.taskbar.lastgroupid");
|
NS_NAMED_LITERAL_CSTRING(prefName, "browser.taskbar.lastgroupid");
|
||||||
nsCOMPtr<nsIPrefService> prefs =
|
nsCOMPtr<nsIPrefBranch> prefs =
|
||||||
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
do_GetService(NS_PREFSERVICE_CONTRACTID);
|
||||||
if (!prefs)
|
if (!prefs)
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefBranch;
|
|
||||||
prefs->GetBranch(nullptr, getter_AddRefs(prefBranch));
|
|
||||||
if (!prefBranch)
|
|
||||||
return NS_ERROR_UNEXPECTED;
|
|
||||||
|
|
||||||
nsCOMPtr<nsISupportsString> prefString;
|
nsCOMPtr<nsISupportsString> prefString;
|
||||||
rv = prefBranch->GetComplexValue(prefName.get(),
|
rv = prefs->GetComplexValue(prefName.get(),
|
||||||
NS_GET_IID(nsISupportsString),
|
NS_GET_IID(nsISupportsString),
|
||||||
getter_AddRefs(prefString));
|
getter_AddRefs(prefString));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
nsAutoString version;
|
nsAutoString version;
|
||||||
prefString->GetData(version);
|
prefString->GetData(version);
|
||||||
|
|
@ -307,9 +308,9 @@ nsWindowsShellService::ShortcutMaintenance()
|
||||||
return rv;
|
return rv;
|
||||||
|
|
||||||
prefString->SetData(appId);
|
prefString->SetData(appId);
|
||||||
rv = prefBranch->SetComplexValue(prefName.get(),
|
rv = prefs->SetComplexValue(prefName.get(),
|
||||||
NS_GET_IID(nsISupportsString),
|
NS_GET_IID(nsISupportsString),
|
||||||
prefString);
|
prefString);
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
NS_WARNING("Couldn't set last user model id!");
|
NS_WARNING("Couldn't set last user model id!");
|
||||||
return NS_ERROR_UNEXPECTED;
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
|
@ -325,38 +326,47 @@ nsWindowsShellService::ShortcutMaintenance()
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
IsAARDefaultHTTP(IApplicationAssociationRegistration* pAAR,
|
IsAARDefault(const RefPtr<IApplicationAssociationRegistration>& pAAR,
|
||||||
bool* aIsDefaultBrowser)
|
LPCWSTR aClassName)
|
||||||
{
|
{
|
||||||
// Make sure the Prog ID matches what we have
|
// Make sure the Prog ID matches what we have
|
||||||
LPWSTR registeredApp;
|
LPWSTR registeredApp;
|
||||||
HRESULT hr = pAAR->QueryCurrentDefault(L"http", AT_URLPROTOCOL, AL_EFFECTIVE,
|
bool isProtocol = *aClassName != L'.';
|
||||||
|
ASSOCIATIONTYPE queryType = isProtocol ? AT_URLPROTOCOL : AT_FILEEXTENSION;
|
||||||
|
HRESULT hr = pAAR->QueryCurrentDefault(aClassName, queryType, AL_EFFECTIVE,
|
||||||
®isteredApp);
|
®isteredApp);
|
||||||
if (SUCCEEDED(hr)) {
|
if (FAILED(hr)) {
|
||||||
LPCWSTR firefoxHTTPProgID = L"PaleMoonURL";
|
return false;
|
||||||
*aIsDefaultBrowser = !wcsicmp(registeredApp, firefoxHTTPProgID);
|
|
||||||
CoTaskMemFree(registeredApp);
|
|
||||||
} else {
|
|
||||||
*aIsDefaultBrowser = false;
|
|
||||||
}
|
}
|
||||||
return SUCCEEDED(hr);
|
|
||||||
|
LPCWSTR progID = isProtocol ? L"PaleMoonURL" : L"PaleMoonHTML";
|
||||||
|
bool isDefault = !wcsicmp(registeredApp, progID);
|
||||||
|
CoTaskMemFree(registeredApp);
|
||||||
|
|
||||||
|
return isDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
IsAARDefaultHTML(IApplicationAssociationRegistration* pAAR,
|
IsDefaultBrowserWin8(bool aCheckAllTypes, bool* aIsDefaultBrowser)
|
||||||
bool* aIsDefaultBrowser)
|
|
||||||
{
|
{
|
||||||
LPWSTR registeredApp;
|
RefPtr<IApplicationAssociationRegistration> pAAR;
|
||||||
HRESULT hr = pAAR->QueryCurrentDefault(L".html", AT_FILEEXTENSION, AL_EFFECTIVE,
|
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
|
||||||
®isteredApp);
|
nullptr,
|
||||||
if (SUCCEEDED(hr)) {
|
CLSCTX_INPROC,
|
||||||
LPCWSTR firefoxHTMLProgID = L"PaleMoonHTML";
|
IID_IApplicationAssociationRegistration,
|
||||||
*aIsDefaultBrowser = !wcsicmp(registeredApp, firefoxHTMLProgID);
|
getter_AddRefs(pAAR));
|
||||||
CoTaskMemFree(registeredApp);
|
if (FAILED(hr)) {
|
||||||
} else {
|
return;
|
||||||
*aIsDefaultBrowser = false;
|
}
|
||||||
|
|
||||||
|
bool res = IsAARDefault(pAAR, L"http");
|
||||||
|
if (*aIsDefaultBrowser) {
|
||||||
|
*aIsDefaultBrowser = res;
|
||||||
|
}
|
||||||
|
res = IsAARDefault(pAAR, L".html");
|
||||||
|
if (*aIsDefaultBrowser && aCheckAllTypes) {
|
||||||
|
*aIsDefaultBrowser = res;
|
||||||
}
|
}
|
||||||
return SUCCEEDED(hr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -369,37 +379,27 @@ bool
|
||||||
nsWindowsShellService::IsDefaultBrowserVista(bool aCheckAllTypes,
|
nsWindowsShellService::IsDefaultBrowserVista(bool aCheckAllTypes,
|
||||||
bool* aIsDefaultBrowser)
|
bool* aIsDefaultBrowser)
|
||||||
{
|
{
|
||||||
IApplicationAssociationRegistration* pAAR;
|
RefPtr<IApplicationAssociationRegistration> pAAR;
|
||||||
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
|
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistration,
|
||||||
nullptr,
|
nullptr,
|
||||||
CLSCTX_INPROC,
|
CLSCTX_INPROC,
|
||||||
IID_IApplicationAssociationRegistration,
|
IID_IApplicationAssociationRegistration,
|
||||||
(void**)&pAAR);
|
getter_AddRefs(pAAR));
|
||||||
|
if (FAILED(hr)) {
|
||||||
if (SUCCEEDED(hr)) {
|
return false;
|
||||||
if (aCheckAllTypes) {
|
|
||||||
BOOL res;
|
|
||||||
hr = pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE,
|
|
||||||
APP_REG_NAME,
|
|
||||||
&res);
|
|
||||||
*aIsDefaultBrowser = res;
|
|
||||||
|
|
||||||
// If we have all defaults, let's make sure that our ProgID
|
|
||||||
// is explicitly returned as well. Needed only for Windows 8.
|
|
||||||
if (*aIsDefaultBrowser && IsWin8OrLater()) {
|
|
||||||
IsAARDefaultHTTP(pAAR, aIsDefaultBrowser);
|
|
||||||
if (*aIsDefaultBrowser) {
|
|
||||||
IsAARDefaultHTML(pAAR, aIsDefaultBrowser);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
IsAARDefaultHTTP(pAAR, aIsDefaultBrowser);
|
|
||||||
}
|
|
||||||
|
|
||||||
pAAR->Release();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
|
if (aCheckAllTypes) {
|
||||||
|
BOOL res;
|
||||||
|
hr = pAAR->QueryAppIsDefaultAll(AL_EFFECTIVE,
|
||||||
|
APP_REG_NAME,
|
||||||
|
&res);
|
||||||
|
*aIsDefaultBrowser = res;
|
||||||
|
} else if (!IsWin8OrLater()) {
|
||||||
|
*aIsDefaultBrowser = IsAARDefault(pAAR, L"http");
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
|
|
@ -407,12 +407,6 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
|
||||||
bool aForAllTypes,
|
bool aForAllTypes,
|
||||||
bool* aIsDefaultBrowser)
|
bool* aIsDefaultBrowser)
|
||||||
{
|
{
|
||||||
// If this is the first browser window, maintain internal state that we've
|
|
||||||
// checked this session (so that subsequent window opens don't show the
|
|
||||||
// default browser dialog).
|
|
||||||
if (aStartupCheck)
|
|
||||||
mCheckedThisSession = true;
|
|
||||||
|
|
||||||
// Assume we're the default unless one of the several checks below tell us
|
// Assume we're the default unless one of the several checks below tell us
|
||||||
// otherwise.
|
// otherwise.
|
||||||
*aIsDefaultBrowser = true;
|
*aIsDefaultBrowser = true;
|
||||||
|
|
@ -499,6 +493,9 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
|
||||||
// previous checks show that PaleMoon is the default browser.
|
// previous checks show that PaleMoon is the default browser.
|
||||||
if (*aIsDefaultBrowser) {
|
if (*aIsDefaultBrowser) {
|
||||||
IsDefaultBrowserVista(aForAllTypes, aIsDefaultBrowser);
|
IsDefaultBrowserVista(aForAllTypes, aIsDefaultBrowser);
|
||||||
|
if (IsWin8OrLater()) {
|
||||||
|
IsDefaultBrowserWin8(aForAllTypes, aIsDefaultBrowser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// To handle the case where DDE isn't disabled due for a user because there
|
// To handle the case where DDE isn't disabled due for a user because there
|
||||||
|
|
@ -603,13 +600,6 @@ nsWindowsShellService::IsDefaultBrowser(bool aStartupCheck,
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsWindowsShellService::GetCanSetDesktopBackground(bool* aResult)
|
|
||||||
{
|
|
||||||
*aResult = true;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
DynSHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
|
DynSHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
|
||||||
{
|
{
|
||||||
|
|
@ -628,13 +618,33 @@ DynSHOpenWithDialog(HWND hwndParent, const OPENASINFO *poainfo)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult rv =
|
nsresult rv;
|
||||||
SUCCEEDED(SHOpenWithDialogFn(hwndParent, poainfo)) ? NS_OK :
|
HRESULT hr = SHOpenWithDialogFn(hwndParent, poainfo);
|
||||||
NS_ERROR_FAILURE;
|
if (SUCCEEDED(hr) || (hr == HRESULT_FROM_WIN32(ERROR_CANCELLED))) {
|
||||||
|
rv = NS_OK;
|
||||||
|
} else {
|
||||||
|
rv = NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
FreeLibrary(shellDLL);
|
FreeLibrary(shellDLL);
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsWindowsShellService::LaunchControlPanelDefaultsSelectionUI()
|
||||||
|
{
|
||||||
|
IApplicationAssociationRegistrationUI* pAARUI;
|
||||||
|
HRESULT hr = CoCreateInstance(CLSID_ApplicationAssociationRegistrationUI,
|
||||||
|
NULL,
|
||||||
|
CLSCTX_INPROC,
|
||||||
|
IID_IApplicationAssociationRegistrationUI,
|
||||||
|
(void**)&pAARUI);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
hr = pAARUI->LaunchAdvancedAssociationUI(APP_REG_NAME);
|
||||||
|
pAARUI->Release();
|
||||||
|
}
|
||||||
|
return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsWindowsShellService::LaunchControlPanelDefaultPrograms()
|
nsWindowsShellService::LaunchControlPanelDefaultPrograms()
|
||||||
{
|
{
|
||||||
|
|
@ -651,7 +661,8 @@ nsWindowsShellService::LaunchControlPanelDefaultPrograms()
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
WCHAR params[] = L"control.exe /name Microsoft.DefaultPrograms /page pageDefaultProgram";
|
WCHAR params[] = L"control.exe /name Microsoft.DefaultPrograms /page "
|
||||||
|
"pageDefaultProgram\\pageAdvancedSettings?pszAppName=" APP_REG_NAME;
|
||||||
STARTUPINFOW si = {sizeof(si), 0};
|
STARTUPINFOW si = {sizeof(si), 0};
|
||||||
si.dwFlags = STARTF_USESHOWWINDOW;
|
si.dwFlags = STARTF_USESHOWWINDOW;
|
||||||
si.wShowWindow = SW_SHOWDEFAULT;
|
si.wShowWindow = SW_SHOWDEFAULT;
|
||||||
|
|
@ -666,9 +677,62 @@ nsWindowsShellService::LaunchControlPanelDefaultPrograms()
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
IsWindowsLogonConnected()
|
||||||
|
{
|
||||||
|
WCHAR userName[UNLEN + 1];
|
||||||
|
DWORD size = ArrayLength(userName);
|
||||||
|
if (!GetUserNameW(userName, &size)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LPUSER_INFO_24 info;
|
||||||
|
if (NetUserGetInfo(nullptr, userName, 24, (LPBYTE *)&info)
|
||||||
|
!= NERR_Success) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool connected = info->usri24_internet_identity;
|
||||||
|
NetApiBufferFree(info);
|
||||||
|
|
||||||
|
return connected;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
SettingsAppBelievesConnected()
|
||||||
|
{
|
||||||
|
nsresult rv;
|
||||||
|
nsCOMPtr<nsIWindowsRegKey> regKey =
|
||||||
|
do_CreateInstance("@mozilla.org/windows-registry-key;1", &rv);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CURRENT_USER,
|
||||||
|
NS_LITERAL_STRING("SOFTWARE\\Microsoft\\Windows\\Shell\\Associations"),
|
||||||
|
nsIWindowsRegKey::ACCESS_READ);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t value;
|
||||||
|
rv = regKey->ReadIntValue(NS_LITERAL_STRING("IsConnectedAtLogon"), &value);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !!value;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsWindowsShellService::LaunchModernSettingsDialogDefaultApps()
|
nsWindowsShellService::LaunchModernSettingsDialogDefaultApps()
|
||||||
{
|
{
|
||||||
|
if (!IsWindowsBuildOrLater(14965) &&
|
||||||
|
!IsWindowsLogonConnected() && SettingsAppBelievesConnected()) {
|
||||||
|
// Use the classic Control Panel to work around a bug of older
|
||||||
|
// builds of Windows 10.
|
||||||
|
return LaunchControlPanelDefaultPrograms();
|
||||||
|
}
|
||||||
|
|
||||||
IApplicationActivationManager* pActivator;
|
IApplicationActivationManager* pActivator;
|
||||||
HRESULT hr = CoCreateInstance(CLSID_ApplicationActivationManager,
|
HRESULT hr = CoCreateInstance(CLSID_ApplicationActivationManager,
|
||||||
nullptr,
|
nullptr,
|
||||||
|
|
@ -682,12 +746,51 @@ nsWindowsShellService::LaunchModernSettingsDialogDefaultApps()
|
||||||
L"windows.immersivecontrolpanel_cw5n1h2txyewy"
|
L"windows.immersivecontrolpanel_cw5n1h2txyewy"
|
||||||
L"!microsoft.windows.immersivecontrolpanel",
|
L"!microsoft.windows.immersivecontrolpanel",
|
||||||
L"page=SettingsPageAppsDefaults", AO_NONE, &pid);
|
L"page=SettingsPageAppsDefaults", AO_NONE, &pid);
|
||||||
|
if (SUCCEEDED(hr)) {
|
||||||
|
// Do not check error because we could at least open
|
||||||
|
// the "Default apps" setting.
|
||||||
|
pActivator->ActivateApplication(
|
||||||
|
L"windows.immersivecontrolpanel_cw5n1h2txyewy"
|
||||||
|
L"!microsoft.windows.immersivecontrolpanel",
|
||||||
|
L"page=SettingsPageAppsDefaults"
|
||||||
|
L"&target=SystemSettings_DefaultApps_Browser", AO_NONE, &pid);
|
||||||
|
}
|
||||||
pActivator->Release();
|
pActivator->Release();
|
||||||
return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
|
return SUCCEEDED(hr) ? NS_OK : NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
nsWindowsShellService::InvokeHTTPOpenAsVerb()
|
||||||
|
{
|
||||||
|
nsCOMPtr<nsIURLFormatter> formatter(
|
||||||
|
do_GetService("@mozilla.org/toolkit/URLFormatterService;1"));
|
||||||
|
if (!formatter) {
|
||||||
|
return NS_ERROR_UNEXPECTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsString urlStr;
|
||||||
|
nsresult rv = formatter->FormatURLPref(
|
||||||
|
NS_LITERAL_STRING("app.support.baseURL"), urlStr);
|
||||||
|
if (NS_FAILED(rv)) {
|
||||||
|
return rv;
|
||||||
|
}
|
||||||
|
if (!StringBeginsWith(urlStr, NS_LITERAL_STRING("https://"))) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
urlStr.AppendLiteral("win10-default-browser");
|
||||||
|
|
||||||
|
SHELLEXECUTEINFOW seinfo = { sizeof(SHELLEXECUTEINFOW) };
|
||||||
|
seinfo.lpVerb = L"openas";
|
||||||
|
seinfo.lpFile = urlStr.get();
|
||||||
|
seinfo.nShow = SW_SHOWNORMAL;
|
||||||
|
if (!ShellExecuteExW(&seinfo)) {
|
||||||
|
return NS_ERROR_FAILURE;
|
||||||
|
}
|
||||||
|
return NS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsWindowsShellService::LaunchHTTPHandlerPane()
|
nsWindowsShellService::LaunchHTTPHandlerPane()
|
||||||
{
|
{
|
||||||
|
|
@ -716,16 +819,23 @@ nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers)
|
||||||
nsresult rv = LaunchHelper(appHelperPath);
|
nsresult rv = LaunchHelper(appHelperPath);
|
||||||
if (NS_SUCCEEDED(rv) && IsWin8OrLater()) {
|
if (NS_SUCCEEDED(rv) && IsWin8OrLater()) {
|
||||||
if (aClaimAllTypes) {
|
if (aClaimAllTypes) {
|
||||||
rv = LaunchControlPanelDefaultPrograms();
|
if (IsWin10OrLater()) {
|
||||||
|
rv = LaunchModernSettingsDialogDefaultApps();
|
||||||
|
} else {
|
||||||
|
rv = LaunchControlPanelDefaultsSelectionUI();
|
||||||
|
}
|
||||||
// The above call should never really fail, but just in case
|
// The above call should never really fail, but just in case
|
||||||
// fall back to showing the HTTP association screen only.
|
// fall back to showing the HTTP association screen only.
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
rv = LaunchHTTPHandlerPane();
|
if (IsWin10OrLater()) {
|
||||||
|
rv = InvokeHTTPOpenAsVerb();
|
||||||
|
} else {
|
||||||
|
rv = LaunchHTTPHandlerPane();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Windows 10 blocks attempts to load the HTTP Handler
|
// Windows 10 blocks attempts to load the
|
||||||
// association dialog, so the modern Settings dialog
|
// HTTP Handler association dialog.
|
||||||
// is opened with the Default Apps view loaded.
|
|
||||||
if (IsWin10OrLater()) {
|
if (IsWin10OrLater()) {
|
||||||
rv = LaunchModernSettingsDialogDefaultApps();
|
rv = LaunchModernSettingsDialogDefaultApps();
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -735,50 +845,20 @@ nsWindowsShellService::SetDefaultBrowser(bool aClaimAllTypes, bool aForAllUsers)
|
||||||
// The above call should never really fail, but just in case
|
// The above call should never really fail, but just in case
|
||||||
// fall back to showing control panel for all defaults
|
// fall back to showing control panel for all defaults
|
||||||
if (NS_FAILED(rv)) {
|
if (NS_FAILED(rv)) {
|
||||||
rv = LaunchControlPanelDefaultPrograms();
|
rv = LaunchControlPanelDefaultsSelectionUI();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID));
|
||||||
}
|
if (prefs) {
|
||||||
|
(void) prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, true);
|
||||||
NS_IMETHODIMP
|
// Reset the number of times the dialog should be shown
|
||||||
nsWindowsShellService::GetShouldCheckDefaultBrowser(bool* aResult)
|
// before it is silenced.
|
||||||
{
|
(void) prefs->SetIntPref(PREF_DEFAULTBROWSERCHECKCOUNT, 0);
|
||||||
NS_ENSURE_ARG_POINTER(aResult);
|
|
||||||
|
|
||||||
// If we've already checked, the browser has been started and this is a
|
|
||||||
// new window open, and we don't want to check again.
|
|
||||||
if (mCheckedThisSession) {
|
|
||||||
*aResult = false;
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
return rv;
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = pserve->GetBranch("", getter_AddRefs(prefs));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
return prefs->GetBoolPref(PREF_CHECKDEFAULTBROWSER, aResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsWindowsShellService::SetShouldCheckDefaultBrowser(bool aShouldCheck)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIPrefBranch> prefs;
|
|
||||||
nsresult rv;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIPrefService> pserve(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = pserve->GetBranch("", getter_AddRefs(prefs));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
return prefs->SetBoolPref(PREF_CHECKDEFAULTBROWSER, aShouldCheck);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static nsresult
|
static nsresult
|
||||||
|
|
@ -912,7 +992,7 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||||
// e.g. "Desktop Background.bmp"
|
// e.g. "Desktop Background.bmp"
|
||||||
nsString fileLeafName;
|
nsString fileLeafName;
|
||||||
rv = shellBundle->GetStringFromName
|
rv = shellBundle->GetStringFromName
|
||||||
(MOZ_UTF16("desktopBackgroundLeafNameWin"),
|
(u"desktopBackgroundLeafNameWin",
|
||||||
getter_Copies(fileLeafName));
|
getter_Copies(fileLeafName));
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
|
@ -948,24 +1028,24 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||||
nsAutoString style;
|
nsAutoString style;
|
||||||
switch (aPosition) {
|
switch (aPosition) {
|
||||||
case BACKGROUND_TILE:
|
case BACKGROUND_TILE:
|
||||||
style.AssignLiteral("0");
|
style.Assign('0');
|
||||||
tile.AssignLiteral("1");
|
tile.Assign('1');
|
||||||
break;
|
break;
|
||||||
case BACKGROUND_CENTER:
|
case BACKGROUND_CENTER:
|
||||||
style.AssignLiteral("0");
|
style.Assign('0');
|
||||||
tile.AssignLiteral("0");
|
tile.Assign('0');
|
||||||
break;
|
break;
|
||||||
case BACKGROUND_STRETCH:
|
case BACKGROUND_STRETCH:
|
||||||
style.AssignLiteral("2");
|
style.Assign('2');
|
||||||
tile.AssignLiteral("0");
|
tile.Assign('0');
|
||||||
break;
|
break;
|
||||||
case BACKGROUND_FILL:
|
case BACKGROUND_FILL:
|
||||||
style.AssignLiteral("10");
|
style.AssignLiteral("10");
|
||||||
tile.AssignLiteral("0");
|
tile.Assign('0');
|
||||||
break;
|
break;
|
||||||
case BACKGROUND_FIT:
|
case BACKGROUND_FIT:
|
||||||
style.AssignLiteral("6");
|
style.Assign('6');
|
||||||
tile.AssignLiteral("0");
|
tile.Assign('0');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1023,7 +1103,7 @@ nsWindowsShellService::OpenApplication(int32_t aApplication)
|
||||||
::RegCloseKey(theKey);
|
::RegCloseKey(theKey);
|
||||||
|
|
||||||
// Find the "open" command
|
// Find the "open" command
|
||||||
application.AppendLiteral("\\");
|
application.Append('\\');
|
||||||
application.Append(buf);
|
application.Append(buf);
|
||||||
application.AppendLiteral("\\shell\\open\\command");
|
application.AppendLiteral("\\shell\\open\\command");
|
||||||
|
|
||||||
|
|
@ -1122,8 +1202,7 @@ nsWindowsShellService::SetDesktopBackgroundColor(uint32_t aColor)
|
||||||
return regKey->Close();
|
return regKey->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
nsWindowsShellService::nsWindowsShellService() :
|
nsWindowsShellService::nsWindowsShellService()
|
||||||
mCheckedThisSession(false)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,10 @@
|
||||||
|
|
||||||
class nsWindowsShellService : public nsIWindowsShellService
|
class nsWindowsShellService : public nsIWindowsShellService
|
||||||
{
|
{
|
||||||
|
virtual ~nsWindowsShellService();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
nsWindowsShellService();
|
nsWindowsShellService();
|
||||||
virtual ~nsWindowsShellService();
|
|
||||||
|
|
||||||
NS_DECL_ISUPPORTS
|
NS_DECL_ISUPPORTS
|
||||||
NS_DECL_NSISHELLSERVICE
|
NS_DECL_NSISHELLSERVICE
|
||||||
|
|
@ -26,12 +27,11 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool IsDefaultBrowserVista(bool aCheckAllTypes, bool* aIsDefaultBrowser);
|
bool IsDefaultBrowserVista(bool aCheckAllTypes, bool* aIsDefaultBrowser);
|
||||||
|
nsresult LaunchControlPanelDefaultsSelectionUI();
|
||||||
nsresult LaunchControlPanelDefaultPrograms();
|
nsresult LaunchControlPanelDefaultPrograms();
|
||||||
nsresult LaunchModernSettingsDialogDefaultApps();
|
nsresult LaunchModernSettingsDialogDefaultApps();
|
||||||
|
nsresult InvokeHTTPOpenAsVerb();
|
||||||
nsresult LaunchHTTPHandlerPane();
|
nsresult LaunchHTTPHandlerPane();
|
||||||
|
|
||||||
private:
|
|
||||||
bool mCheckedThisSession;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nswindowsshellservice_h____
|
#endif // nswindowsshellservice_h____
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue