зеркало из https://github.com/mozilla/pjs.git
236744 - replace winhooks with a XP shell service to better allow for system integration on various platforms
This commit is contained in:
Родитель
3267b1f993
Коммит
a8976361c8
|
@ -124,6 +124,9 @@ endif
|
|||
ifdef BUILD_STATIC_LIBS
|
||||
RCFLAGS += -DMOZ_STATIC_BUILD
|
||||
endif
|
||||
ifdef DEBUG
|
||||
RCFLAGS += -DDEBUG
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OS_ARCH),OS2)
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 22 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 22 KiB |
|
@ -64,6 +64,10 @@ pref("general.autoScroll", false);
|
|||
pref("general.autoScroll", true);
|
||||
#endif
|
||||
|
||||
// Whether or not the application should check at startup each time if it
|
||||
// is the default browser.
|
||||
pref("browser.shell.checkDefaultBrowser", true);
|
||||
|
||||
// 0 = blank, 1 = home (browser.startup.homepage), 2 = last
|
||||
// XXXBlake Remove this stupid pref
|
||||
pref("browser.startup.page", 1);
|
||||
|
|
|
@ -41,29 +41,8 @@
|
|||
|
||||
1 24 "firefox.exe.manifest"
|
||||
|
||||
// Program icon.
|
||||
IDI_APPLICATION ICON
|
||||
"mozilla.ico"
|
||||
|
||||
// Splash screen dialog.
|
||||
IDD_SPLASH DIALOGEX
|
||||
DISCARDABLE
|
||||
0,0,0,0
|
||||
STYLE DS_SETFOREGROUND | DS_CENTER | WS_POPUP
|
||||
EXSTYLE WS_EX_TOOLWINDOW
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL
|
||||
IDB_SPLASH,
|
||||
IDB_SPLASH,
|
||||
"Static",
|
||||
SS_BITMAP,
|
||||
0,0,0,0
|
||||
END
|
||||
|
||||
// Splash screen bitmap.
|
||||
// IDB_SPLASH BITMAP
|
||||
// "splash.bmp"
|
||||
IDI_DOCUMENT ICON "document.ico"
|
||||
IDI_APPLICATION ICON "firefox.ico"
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
<stringbundleset id="stringbundleset">
|
||||
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
|
||||
<stringbundle id="bundle_shell" src="chrome://browser/locale/shellservice.properties"/>
|
||||
<stringbundle id="bundle_browser" src="chrome://browser/locale/browser.properties"/>
|
||||
<stringbundle id="bundle_browser_region" src="chrome://browser-region/locale/region.properties"/>
|
||||
<stringbundle id="findBundle" src="chrome://global/locale/finddialog.properties"/>
|
||||
|
|
|
@ -512,16 +512,31 @@ function delayedStartup()
|
|||
|
||||
clearObsoletePrefs();
|
||||
|
||||
#ifdef XP_WIN
|
||||
// Perform default browser checking (after window opens).
|
||||
try {
|
||||
var dialogShown = Components.classes["@mozilla.org/winhooks;1"]
|
||||
.getService(Components.interfaces.nsIWindowsHooks)
|
||||
.checkSettings(window);
|
||||
} catch(e) {
|
||||
}
|
||||
#endif
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
var shouldCheck = shell.shouldCheckDefaultBrowser;
|
||||
if (shouldCheck && !shell.isDefaultBrowser(true)) {
|
||||
var brandBundle = document.getElementById("bundle_brand");
|
||||
var shellBundle = document.getElementById("bundle_shell");
|
||||
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
var promptTitle = shellBundle.getString("setDefaultBrowserTitle");
|
||||
var promptMessage = shellBundle.getFormattedString("setDefaultBrowserMessage",
|
||||
[brandShortName]);
|
||||
var checkboxLabel = shellBundle.getString("setDefaultBrowserDontAsk");
|
||||
const IPS = Components.interfaces.nsIPromptService;
|
||||
var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(IPS);
|
||||
var checkEveryTime = { value: shouldCheck };
|
||||
var rv = ps.confirmEx(window, promptTitle, promptMessage,
|
||||
(IPS.BUTTON_TITLE_YES * IPS.BUTTON_POS_0) +
|
||||
(IPS.BUTTON_TITLE_NO * IPS.BUTTON_POS_1),
|
||||
null, null, null, checkboxLabel, checkEveryTime);
|
||||
if (rv == 0)
|
||||
shell.setDefaultBrowser(true);
|
||||
shell.shouldCheckDefaultBrowser = checkEveryTime.value;
|
||||
}
|
||||
}
|
||||
|
||||
function Shutdown()
|
||||
|
@ -4327,20 +4342,23 @@ var MailIntegration = {
|
|||
|
||||
readMail: function ()
|
||||
{
|
||||
var whs = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
|
||||
whs.openDefaultClient("Mail");
|
||||
const ss = Components.interfaces.nsIShellService;
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"].getService(ss);
|
||||
shell.openPreferredApplication(ss.APPLICATION_MAIL);
|
||||
},
|
||||
|
||||
readNews: function ()
|
||||
{
|
||||
var whs = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
|
||||
whs.openDefaultClient("News");
|
||||
const ss = Components.interfaces.nsIShellService;
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"].getService(Components.interfaces.nsIShellService);
|
||||
shell.openPreferredApplication(ss.APPLICATION_NEWS);
|
||||
},
|
||||
|
||||
updateUnreadCount: function ()
|
||||
{
|
||||
var whs = Components.classes["@mozilla.org/winhooks;1"].getService(Components.interfaces.nsIWindowsHooks);
|
||||
var unreadCount = whs.unreadMailCount;
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIWindowsShellService);
|
||||
var unreadCount = shell.unreadMailCount;
|
||||
var message = gNavigatorBundle.getFormattedString("mailUnreadTooltip", [unreadCount]);
|
||||
var element = document.getElementById("mail-button");
|
||||
element.setAttribute("tooltiptext", message);
|
||||
|
|
|
@ -54,8 +54,8 @@
|
|||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
const xulNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
const winHooks = Components.interfaces.nsIWindowsHooks;
|
||||
var gMode = winHooks.WALLPAPER_STRETCH;
|
||||
const ISS = Components.interfaces.nsIShellService;
|
||||
var gMode = ISS.BACKGROUND_STRETCH;
|
||||
var gMonitor;
|
||||
var gWidth, gHeight;
|
||||
|
||||
|
@ -77,10 +77,10 @@
|
|||
}
|
||||
|
||||
function onLoad() {
|
||||
var winhooks = Components.classes["@mozilla.org/winhooks;1"].
|
||||
getService(Components.interfaces.nsIWindowsHooks);
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIWindowsShellService);
|
||||
gMonitor = document.getElementById("monitor");
|
||||
var color = winhooks.getDesktopColor();
|
||||
var color = shell.desktopBackgroundColor;
|
||||
const rMask = 4294901760;
|
||||
const gMask = 65280;
|
||||
const bMask = 255;
|
||||
|
@ -124,15 +124,15 @@
|
|||
|
||||
function onAccept() {
|
||||
var pos = parseInt(document.getElementById("menuPosition").value);
|
||||
var winhooks = Components.classes["@mozilla.org/winhooks;1"].
|
||||
getService(Components.interfaces.nsIWindowsHooks);
|
||||
winhooks.setImageAsWallpaper(window.arguments[0], false, pos);
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIWindowsShellService);
|
||||
shell.setDesktopBackground(window.arguments[0], pos);
|
||||
|
||||
var colorpicker = document.getElementById("desktopColor");
|
||||
var r = HexToR(colorpicker.color);
|
||||
var g = HexToG(colorpicker.color);
|
||||
var b = HexToB(colorpicker.color);
|
||||
winhooks.setDesktopColor((r << 16) | (g << 8) | b);
|
||||
shell.desktopBackgroundColor = (r << 16) | (g << 8) | b;
|
||||
}
|
||||
|
||||
function updatePreviewColor(color) {
|
||||
|
@ -141,9 +141,9 @@
|
|||
|
||||
function onPositionChange(val) {
|
||||
gMode = parseInt(val);
|
||||
if (gMode == winHooks.WALLPAPER_TILE)
|
||||
if (gMode == ISS.WALLPAPER_TILE)
|
||||
tileImage();
|
||||
else if (gMode == winHooks.WALLPAPER_STRETCH)
|
||||
else if (gMode == ISS.WALLPAPER_STRETCH)
|
||||
stretchImage();
|
||||
else
|
||||
centerImage();
|
||||
|
|
|
@ -1,61 +0,0 @@
|
|||
nv_done=Done
|
||||
nv_timeout=Timed Out
|
||||
nv_stopped=Stopped
|
||||
openFile=Open File
|
||||
defaultStatus=
|
||||
|
||||
droponhomebutton=Drop a link or file to make it your home page
|
||||
droponhometitle=Set Home Page
|
||||
droponhomemsg=Do you want this document to be your new home page?
|
||||
|
||||
jserror=An error has occurred on this page. Double click here for details.
|
||||
|
||||
linkTargetLabel=Link will open in:
|
||||
linkHREFLabel=Location:
|
||||
|
||||
#SessionHistory.js
|
||||
nothingAvailable=(Nothing Available)
|
||||
|
||||
# Localization Note: Use 'true' or 'false' to control the pref:theme to
|
||||
# show the English description or not
|
||||
# for example, in Japanese build, instead of showing English description
|
||||
# set the following value to false so it won't show up.
|
||||
showskinsdescription=true
|
||||
|
||||
# context menu strings
|
||||
|
||||
searchText=Search Web for "%S"
|
||||
|
||||
blockImages=Block Images from %S
|
||||
|
||||
SavePageTitle=Save Web Page
|
||||
SaveImageTitle=Save Picture
|
||||
SaveLinkTitle=Save As
|
||||
DefaultSaveFileName=index
|
||||
WebPageCompleteFilter=Web Page, complete
|
||||
WebPageHTMLOnlyFilter=Web Page, HTML only
|
||||
|
||||
# LOCALIZATION NOTE (filesFolder):
|
||||
# This is the name of the folder that is created parallel to a HTML file
|
||||
# when it is saved "With Images". The %S section is replaced with the
|
||||
# leaf name of the file being saved (minus extension).
|
||||
filesFolder=%S_files
|
||||
|
||||
saveLinkErrorMsg=The link could not be saved. The web page might have been removed or had its name changed.
|
||||
saveLinkErrorTitle=Save Link
|
||||
addEngines=Add engines...
|
||||
|
||||
# Default name for the Web Panels sidebar
|
||||
webPanels=Web Panels
|
||||
|
||||
# setWallpaper confirmation dialog
|
||||
wallpaperConfirmTitle = Set Wallpaper
|
||||
wallpaperConfirmMsg = Do you want to set this image as your desktop wallpaper?
|
||||
|
||||
tabs.closeWarningTitle=Confirm close
|
||||
tabs.closeWarning=This Browser window has %S tabs open. Do you want to close it and all its tabs?
|
||||
tabs.closeButton=Close all tabs
|
||||
tabs.closeWarningPromptMe=Warn me when closing multiple tabs
|
||||
|
||||
mailUnreadTooltip=Read Mail and News (%S new messages)
|
||||
mailUnreadMenuitem=Read Mail (%S new)
|
|
@ -42,12 +42,7 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = bookmarks help migration history prefwindow security sidebar cookieviewer
|
||||
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
DIRS += winhooks
|
||||
endif
|
||||
DIRS = bookmarks help migration history prefwindow security shell sidebar cookieviewer
|
||||
|
||||
DIRS += build
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ REQUIRES = \
|
|||
txmgr \
|
||||
bookmarks \
|
||||
migration \
|
||||
winhooks \
|
||||
shellservice \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = nsBrowserCompsCID.h
|
||||
|
@ -59,12 +59,12 @@ SHARED_LIBRARY_LIBS = \
|
|||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
SHARED_LIBRARY_LIBS += \
|
||||
$(DIST)/lib/$(LIB_PREFIX)winhooks_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)migration_s.$(LIB_SUFFIX) \
|
||||
$(DIST)/lib/$(LIB_PREFIX)shellservice_s.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES += \
|
||||
-I$(srcdir)/../winhooks \
|
||||
-I$(srcdir)/../shell/src \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
|
|
|
@ -73,3 +73,9 @@
|
|||
#define NS_PHOENIXPROFILEMIGRATOR_CID \
|
||||
{ 0x78481e4a, 0x50e4, 0x4489, { 0xb6, 0x8a, 0xef, 0x82, 0x67, 0xe, 0xd6, 0x3f } }
|
||||
|
||||
#define NS_SHELLSERVICE_CID \
|
||||
{ 0x63c7b9f4, 0xcc8, 0x43f8, { 0xb6, 0x66, 0xa, 0x66, 0x16, 0x55, 0xcb, 0x73 } }
|
||||
|
||||
#define NS_SHELLSERVICE_CONTRACTID \
|
||||
"@mozilla.org/browser/shell-service;1"
|
||||
|
||||
|
|
|
@ -41,7 +41,11 @@
|
|||
#include "nsBrowserCompsCID.h"
|
||||
#include "nsBookmarksService.h"
|
||||
#ifdef XP_WIN
|
||||
#include "nsWindowsHooks.h"
|
||||
#include "nsWindowsShellService.h"
|
||||
#elif defined(XP_MACOSX)
|
||||
#include "nsMacShellService.h"
|
||||
#else
|
||||
#include "nsGNOMEShellService.h"
|
||||
#endif
|
||||
#include "nsProfileMigrator.h"
|
||||
#include "nsDogbertProfileMigrator.h"
|
||||
|
@ -62,7 +66,11 @@
|
|||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsBookmarksService, Init)
|
||||
#ifdef XP_WIN
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowsHooks)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsWindowsShellService)
|
||||
#elif defined(XP_MACOSX)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMacShellService)
|
||||
#else
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsGNOMEShellService)
|
||||
#endif
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDogbertProfileMigrator)
|
||||
|
@ -83,11 +91,24 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsICabProfileMigrator)
|
|||
|
||||
static const nsModuleComponentInfo components[] =
|
||||
{
|
||||
#ifdef XP_WIN
|
||||
{ NS_IWINDOWSHOOKS_CLASSNAME,
|
||||
NS_IWINDOWSHOOKS_CID,
|
||||
NS_IWINDOWSHOOKS_CONTRACTID,
|
||||
nsWindowsHooksConstructor },
|
||||
#if defined(XP_WIN)
|
||||
{ "Browser Shell Shervice",
|
||||
NS_SHELLSERVICE_CID,
|
||||
NS_SHELLSERVICE_CONTRACTID,
|
||||
nsWindowsShellServiceConstructor },
|
||||
|
||||
#elif defined (XP_MACOSX)
|
||||
{ "Browser Shell Shervice",
|
||||
NS_SHELLSERVICE_CID,
|
||||
NS_SHELLSERVICE_CONTRACTID,
|
||||
nsMacShellServiceConstructor },
|
||||
|
||||
#else
|
||||
{ "Browser Shell Shervice",
|
||||
NS_SHELLSERVICE_CID,
|
||||
NS_SHELLSERVICE_CONTRACTID,
|
||||
nsGNOMEShellServiceConstructor },
|
||||
|
||||
#endif
|
||||
{ "Bookmarks",
|
||||
NS_BOOKMARKS_SERVICE_CID,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
|
@ -11,11 +11,10 @@
|
|||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla.org Code.
|
||||
# The Original Code is the Firefox Options Dialog
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Doron Rosenberg.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# The Initial Developer of the Original Code is mozilla.org.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2004
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
|
@ -28,15 +27,13 @@
|
|||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# and other provisions required by the LGPL or the GPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
# ***** END LICENSE BLOCK ***** -->
|
||||
|
||||
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
*/
|
||||
var _elementIDs = ["browserStartupHomepage", "checkForDefault"];
|
||||
|
||||
const nsIPrefService = Components.interfaces.nsIPrefService;
|
||||
const nsIPrefLocalizedString = Components.interfaces.nsIPrefLocalizedString;
|
||||
|
@ -83,8 +80,10 @@ function setHomePageToDefaultPage()
|
|||
homePageField.value = url;
|
||||
}
|
||||
|
||||
function onOK() {
|
||||
if (!('homepage' in parent)) return;
|
||||
function onOK()
|
||||
{
|
||||
if (!('homepage' in parent))
|
||||
return;
|
||||
|
||||
// Replace pipes with commas to look nicer.
|
||||
parent.homepage = parent.homepage.replace(/\|/g,', ');
|
||||
|
@ -99,6 +98,11 @@ function onOK() {
|
|||
if (homeButton)
|
||||
homeButton.setAttribute("tooltiptext", parent.homepage);
|
||||
}
|
||||
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
if ("shouldBeDefaultBrowser" in parent && parent.shouldBeDefautBrowser)
|
||||
shell.setDefaultBrowser(true);
|
||||
}
|
||||
|
||||
function Startup()
|
||||
|
@ -199,3 +203,36 @@ function saveFontPrefs()
|
|||
pref.SetBoolPref(prefs[i], prefvalue)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef XP_WIN
|
||||
function checkNow()
|
||||
{
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
|
||||
var brandBundle = document.getElementById("bundle_brand");
|
||||
var shellBundle = document.getElementById("bundle_shell");
|
||||
var brandShortName = brandBundle.getString("brandShortName");
|
||||
var promptTitle = shellBundle.getString("setDefaultBrowserTitle");
|
||||
var promptMessage;
|
||||
const IPS = Components.interfaces.nsIPromptService;
|
||||
var psvc = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
|
||||
.getService(IPS);
|
||||
// if (!shell.isDefaultBrowser(false)) {
|
||||
promptMessage = shellBundle.getFormattedString("setDefaultBrowserMessage",
|
||||
[brandShortName]);
|
||||
var rv = psvc.confirmEx(window, promptTitle, promptMessage,
|
||||
(IPS.BUTTON_TITLE_YES * IPS.BUTTON_POS_0) +
|
||||
(IPS.BUTTON_TITLE_NO * IPS.BUTTON_POS_1),
|
||||
null, null, null, null, { });
|
||||
if (rv == 0)
|
||||
shell.setDefaultBrowser(true);
|
||||
/*
|
||||
}
|
||||
else {
|
||||
promptMessage = shellBundle.getFormattedString("alreadyDefaultBrowser",
|
||||
[brandShortName]);
|
||||
psvc.alert(window, promptTitle, promptMessage);
|
||||
}*/
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -53,81 +53,9 @@
|
|||
|
||||
<stringbundle id="bundle_prefutilities" src="chrome://browser/locale/pref/prefutilities.properties"/>
|
||||
<stringbundle id="bundle_brand" src="chrome://global/locale/brand.properties"/>
|
||||
<stringbundle id="bundle_shell" src="chrome://browser/locale/shellservice.properties"/>
|
||||
<script type="application/x-javascript" src="chrome://browser/content/pref/pref-navigator.js"/>
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
var _elementIDs = ["browserStartupHomepage"];
|
||||
|
||||
#ifdef XP_WIN
|
||||
// "Install" the SetFields function. This will be
|
||||
// called whenever the Navigator pane is shown.
|
||||
window.SetFields = function( pageData ) {
|
||||
// Determine if we have been selected as the default browser
|
||||
// already, and enable/disable the "Set As Default" button
|
||||
// accordingly.
|
||||
|
||||
// We store our state info in the same place as the code in
|
||||
// pref-winhooks.js uses so that this panel and the
|
||||
// Advanced/System panel are kept in synch.
|
||||
if (!("winHooks" in parent)) {
|
||||
// Neither the Advanced/System panel nor this panel has
|
||||
// appeared. Initialize the state information.
|
||||
parent.winHooks = new Object;
|
||||
|
||||
// Get winhooks service.
|
||||
parent.winHooks.winhooks = Components.classes[ "@mozilla.org/winhooks;1" ]
|
||||
.getService( Components.interfaces.nsIWindowsHooks );
|
||||
|
||||
// Extract current settings (these are what the user has checked on
|
||||
// the Advanced/System panel).
|
||||
parent.winHooks.prefs = parent.winHooks.winhooks.settings;
|
||||
}
|
||||
|
||||
// Start by checking http/https/ftp and html/xhtml/xml.
|
||||
var prefs = parent.winHooks.prefs;
|
||||
if (prefs.isHandlingHTTP &&
|
||||
prefs.isHandlingHTTPS &&
|
||||
prefs.isHandlingHTML &&
|
||||
prefs.isHandlingXHTML) {
|
||||
// The user *wants* us to be the default, apparently.
|
||||
// We test the registry settings using a scratch copy of the
|
||||
// settings because we don't care about some of them, but we
|
||||
// don't want to mess up the user's choices from the
|
||||
// Advanced/System panel.
|
||||
var testSettings = parent.winHooks.winhooks.settings;
|
||||
// Test that these are set.
|
||||
testSettings.isHandlingHTTP = true;
|
||||
testSettings.isHandlingHTTPS = true;
|
||||
testSettings.isHandlingHTML = true;
|
||||
testSettings.isHandlingXHTML = true;
|
||||
}
|
||||
// Return true to tell caller to process the standard pref fields.
|
||||
return true;
|
||||
}
|
||||
// "Install" the makeDefault function;
|
||||
window.makeDefault = function() {
|
||||
// Extract current settings (these are what the
|
||||
// user has checked on the Advanced/System panel).
|
||||
var settings = parent.winHooks.prefs;
|
||||
|
||||
// Turn on all "default browser" settings.
|
||||
settings.isHandlingHTTP = true;
|
||||
settings.isHandlingHTTPS = true;
|
||||
settings.isHandlingHTML = true;
|
||||
settings.isHandlingXHTML = true;
|
||||
|
||||
// Register callback that will be called when and if the
|
||||
// user presses the OK button.
|
||||
parent.hPrefWindow.registerOKCallbackFunc( function () {
|
||||
// Apply the settings.
|
||||
parent.winHooks.winhooks.settings = parent.winHooks.prefs;
|
||||
} );
|
||||
}
|
||||
#endif
|
||||
]]>
|
||||
</script>
|
||||
|
||||
<!-- homepage specification -->
|
||||
<groupbox>
|
||||
<caption label="&header2.label;"/>
|
||||
|
@ -170,10 +98,11 @@
|
|||
<groupbox orient="horizontal">
|
||||
<caption label="&defaultBrowserGroup.label;"/>
|
||||
<hbox align="center" flex="1">
|
||||
<description>&makeDefaultText;</description>
|
||||
<spacer flex="1"/>
|
||||
<button label="&defaultBrowserButton.label;"
|
||||
oncommand="makeDefault()"/>
|
||||
<checkbox id="checkForDefault" prefstring="browser.shell.checkDefaultBrowser"
|
||||
label="&checkForDefault.label;" accesskey="&checkForDefault.accesskey;"
|
||||
flex="1"/>
|
||||
<button label="&checkNow.label;" accesskey="&checkNow.accesskey;"
|
||||
oncommand="checkNow()"/>
|
||||
</hbox>
|
||||
</groupbox>
|
||||
#endif
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<!ENTITY lHeader "General">
|
||||
|
||||
<!ENTITY header2.label "Home Page">
|
||||
<!ENTITY location.label "Location(s):">
|
||||
<!ENTITY location.accesskey "a">
|
||||
<!ENTITY useCurrent.label "Use Current Page">
|
||||
<!ENTITY useCurrent.accesskey "C">
|
||||
<!ENTITY useCurrentMultiple.label "Use Current Pages">
|
||||
<!ENTITY useBookmark.label "Use Bookmark...">
|
||||
<!ENTITY useBookmark.accesskey "U">
|
||||
<!ENTITY useBlank.label "Use Blank Page">
|
||||
<!ENTITY useBlank.accesskey "B">
|
||||
|
||||
<!ENTITY defaultBrowserGroup.label "Default Browser">
|
||||
<!ENTITY defaultBrowserButton.label "Set Default Browser">
|
||||
<!ENTITY makeDefaultText "Set &brandShortName; as your default browser.">
|
||||
|
||||
<!-- XXXben oh please, can we do better than this text-wise? -->
|
||||
<!ENTITY showConnections.label "Connection Settings...">
|
||||
<!ENTITY showConnections.accesskey "o">
|
||||
|
||||
<!ENTITY proxiesInfo.label "Set up Proxies for accessing the internet.">
|
||||
<!ENTITY connectionsInfo.caption "Connection">
|
||||
|
||||
<!-- XXXben can we do better than this text-wise? -->
|
||||
<!ENTITY fonts.label "Fonts & Colors">
|
||||
<!ENTITY fontsInfo.caption "Fonts & Colors Settings">
|
||||
<!ENTITY fontsInfo.label "Select default Fonts and Colors used when displaying pages.">
|
||||
|
||||
<!ENTITY showFontsAndColors.label "Fonts & Colors...">
|
||||
<!ENTITY showFontsAndColors.accesskey "f">
|
|
@ -0,0 +1,47 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is the Mozilla Browser code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2002
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Brian Ryner <bryner@brianryner.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = public src
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,4 @@
|
|||
toolkit.jar:
|
||||
content/global/dummyWindow.xul (content/dummyWindow.xul)
|
||||
en-US.jar:
|
||||
locale/en-US/browser/shellservice.properties (locale/shellservice.properties)
|
|
@ -0,0 +1,38 @@
|
|||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = shellservice
|
||||
XPIDL_MODULE = shellservice
|
||||
|
||||
XPIDLSRCS = nsIShellService.idl
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
XPIDLSRCS += nsIWindowsShellService.idl
|
||||
endif
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,104 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMElement;
|
||||
|
||||
[scriptable, uuid(7d8a7a34-f492-43c0-9657-ec7dbbeba236)]
|
||||
interface nsIShellService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Determines whether or not Firefox is the "Default Browser."
|
||||
* This is simply whether or not Firefox is registered to handle
|
||||
* http links.
|
||||
*
|
||||
* @param aStartupCheck true if this is the check being performed
|
||||
* by the first browser window at startup,
|
||||
* false otherwise.
|
||||
*/
|
||||
boolean isDefaultBrowser(in boolean aStartupCheck);
|
||||
|
||||
/**
|
||||
* Registers Firefox as the "Default Browser."
|
||||
*
|
||||
* @param aClaimAllTypes Register Firefox as the handler for
|
||||
* additional protocols (ftp, chrome etc)
|
||||
* and web documents (.html, .xhtml etc).
|
||||
*/
|
||||
void setDefaultBrowser(in boolean aClaimAllTypes);
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Flags for positioning/sizing of the Desktop Background image.
|
||||
*/
|
||||
const long BACKGROUND_TILE = 0x00;
|
||||
const long BACKGROUND_STRETCH = 0x01;
|
||||
const long BACKGROUND_CENTER = 0x02;
|
||||
|
||||
/**
|
||||
* Sets the desktop background image using either the HTML <IMG>
|
||||
* element supplied or the background image of the element supplied.
|
||||
*
|
||||
* @param aImageElement Either a HTML <IMG> element or an element with
|
||||
* a background image from which to source the
|
||||
* background image.
|
||||
* @param aPosition How to place the image on the desktop
|
||||
*/
|
||||
void setDesktopBackground(in nsIDOMElement aElement, in long aPosition);
|
||||
|
||||
/**
|
||||
* Constants identifying preferred applications that can be opened with
|
||||
* openPreferredApplication.
|
||||
*/
|
||||
const long APPLICATION_MAIL = 0;
|
||||
const long APPLICATION_NEWS = 1;
|
||||
|
||||
/**
|
||||
* Opens the preferred application specified.
|
||||
*/
|
||||
void openPreferredApplication(in long aApplication);
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@mozilla.org> (Original Author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIShellService.idl"
|
||||
|
||||
[scriptable, uuid(45a378fd-65b7-4be8-99b3-ebbf5513fe07)]
|
||||
interface nsIWindowsShellService : nsIShellService
|
||||
{
|
||||
/**
|
||||
* Restores system settings to what they were before Firefox
|
||||
* modified them.
|
||||
*/
|
||||
void restoreFileSettings();
|
||||
|
||||
/**
|
||||
* The desktop background color, visible when no background image is
|
||||
* used, or if the background image is centered and does not fill the
|
||||
* entire screen. A rgb value, where (r << 24 | g << 16 | b)
|
||||
*/
|
||||
attribute unsigned long desktopBackgroundColor;
|
||||
|
||||
/**
|
||||
* The number of unread mail messages for the current user.
|
||||
*
|
||||
* @return The number of unread (new) mail messages for the current user.
|
||||
*/
|
||||
readonly attribute unsigned long unreadMailCount;
|
||||
};
|
||||
|
|
@ -0,0 +1,70 @@
|
|||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
#
|
||||
|
||||
DEPTH = ../../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
MODULE = shellservice
|
||||
LIBRARY_NAME = shellservice_s
|
||||
|
||||
REQUIRES = \
|
||||
xpcom \
|
||||
string \
|
||||
dom \
|
||||
windowwatcher \
|
||||
intl \
|
||||
appshell \
|
||||
necko \
|
||||
layout \
|
||||
content \
|
||||
widget \
|
||||
imglib2 \
|
||||
gfx \
|
||||
locale \
|
||||
pref \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(OS_ARCH),WINNT)
|
||||
CPPSRCS = nsWindowsShellService.cpp
|
||||
else
|
||||
ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
|
||||
CPPSRCS = nsMacShellService.cpp
|
||||
else
|
||||
CPPSRCS = nsGNOMEShellService.cpp
|
||||
endif
|
||||
endif
|
||||
|
||||
FORCE_STATIC_LIB = 1
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
JS_SET_BROWSER_COMPONENT = nsSetDefaultBrowser.js
|
||||
|
||||
libs::
|
||||
$(INSTALL) $(srcdir)/$(JS_SET_BROWSER_COMPONENT) $(DIST)/bin/components
|
||||
|
||||
clobber::
|
||||
rm -f $(DIST)/lib/$(LIBRARY_NAME).lib
|
||||
rm -f $(DIST)/bin/components/$(JS_SET_BROWSER_COMPONENT)
|
|
@ -0,0 +1,102 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsGNOMEShellService.h"
|
||||
#include "nsShellService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsGNOMEShellService, nsIShellService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefaultBrowser)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::SetDefaultBrowser(PRBool aClaimAllTypes)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::GetShouldCheckDefaultBrowser(PRBool* 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 = PR_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
|
||||
nsGNOMEShellService::SetShouldCheckDefaultBrowser(PRBool 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
|
||||
nsGNOMEShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||
PRInt32 aPosition)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGNOMEShellService::OpenPreferredApplication(PRInt32 aApplication)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsgnomeshellservice_h____
|
||||
#define nsgnomeshellservice_h____
|
||||
|
||||
#include "nsIShellService.h"
|
||||
|
||||
class nsGNOMEShellService : public nsIShellService
|
||||
{
|
||||
public:
|
||||
nsGNOMEShellService() : mCheckedThisSession(PR_FALSE) {};
|
||||
virtual ~nsGNOMEShellService() {};
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISHELLSERVICE
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
PRBool mCheckedThisSession;
|
||||
};
|
||||
|
||||
#endif // nsgnomeshellservice_h____
|
|
@ -0,0 +1,102 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsMacShellService.h"
|
||||
#include "nsShellService.h"
|
||||
|
||||
NS_IMPL_ISUPPORTS1(nsMacShellService, nsIShellService)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefaultBrowser)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::SetDefaultBrowser(PRBool aClaimAllTypes)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::GetShouldCheckDefaultBrowser(PRBool* 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 = PR_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(PRBool 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::SetDesktopBackground(nsIDOMElement* aElement,
|
||||
PRInt32 aPosition)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::OpenPreferredApplication(PRInt32 aApplication)
|
||||
{
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@mozilla.org>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsmacshellservice_h____
|
||||
#define nsmacshellservice_h____
|
||||
|
||||
#include "nsIShellService.h"
|
||||
|
||||
class nsMacShellService : public nsIShellService
|
||||
{
|
||||
public:
|
||||
nsMacShellService() : mCheckedThisSession(PR_FALSE) {};
|
||||
virtual ~nsMacShellService() {};
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISHELLSERVICE
|
||||
|
||||
protected:
|
||||
|
||||
private:
|
||||
PRBool mCheckedThisSession;
|
||||
};
|
||||
|
||||
#endif // nsmacshellservice_h____
|
|
@ -0,0 +1,168 @@
|
|||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla Default Browser.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Bill Law <law@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/* This file implements the nsICmdLineHandler interface. See nsICmdLineHandler.idl
|
||||
* at http://lxr.mozilla.org/seamonkey/source/xpfe/appshell/public/nsICmdLineHandler.idl.
|
||||
*
|
||||
* This component handles the startup command line argument of the form:
|
||||
* -setDefaultBrowser
|
||||
* by making the current executable the "default browser." It accomplishes
|
||||
* that via use of the nsIWindowsHooks interface (see implementation below).
|
||||
*
|
||||
* The module is registered under the contractid
|
||||
* "@mozilla.org/commandlinehandler/general-startup;1?type=setDefaultBrowser"
|
||||
*
|
||||
* The implementation consists of a JavaScript "class" named nsKillAll,
|
||||
* comprised of:
|
||||
* - a JS constructor function
|
||||
* - a prototype providing all the interface methods and implementation stuff
|
||||
*
|
||||
* In addition, this file implements an nsIModule object that registers the
|
||||
* nsSetDefaultBrowser component.
|
||||
*/
|
||||
|
||||
/* ctor
|
||||
*/
|
||||
function nsSetDefaultBrowser() {
|
||||
}
|
||||
|
||||
nsSetDefaultBrowser.prototype = {
|
||||
|
||||
// nsICmdLineHandler interface
|
||||
get commandLineArgument() { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
get prefNameForStartup() { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
|
||||
get chromeUrlForTask() {
|
||||
// First, get winhooks service.
|
||||
var shell = Components.classes["@mozilla.org/browser/shell-service;1"]
|
||||
.getService(Components.interfaces.nsIShellService);
|
||||
shell.isDefaultBrowser = true;
|
||||
|
||||
// Now, get the cmd line service.
|
||||
var cmdLineService = Components.classes[ "@mozilla.org/appshell/commandLineService;1" ]
|
||||
.getService( Components.interfaces.nsICmdLineService );
|
||||
|
||||
// See if "-setDefaultBrowser" was specified. The value will be "1" if
|
||||
// -setDefaultBrowser is in the service's list of cmd line arguments, and
|
||||
// null otherwise. -setDefaultBrowser will only be in the service's
|
||||
// arg list if the application was not already running. That's because
|
||||
// if it was already running, then the service reflects the arguments
|
||||
// that were specified when *that* process was started, *not* the ones
|
||||
// passed via IPC from the second instance.
|
||||
var option = cmdLineService.getCmdLineValue( "-setDefaultBrowser" );
|
||||
if (!option) {
|
||||
// Already running, so we don't have to worry about opening
|
||||
// another window, etc.
|
||||
throw Components.results.NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
// Return URL for dummy window that will auto-close. We do this rather
|
||||
// than throw NS_ERROR_NOT_AVAILABLE, which *should* work, because it
|
||||
// seems that if we don't open a window, we get a crash when trying to
|
||||
// release this (or some other) JS component during XPCOM shutdown.
|
||||
return "chrome://global/content/dummyWindow.xul";
|
||||
},
|
||||
|
||||
get helpText() { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
get handlesArgs() { return false; },
|
||||
get defaultArgs() { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
get openWindowWithArgs() { throw Components.results.NS_ERROR_NOT_IMPLEMENTED; },
|
||||
|
||||
// nsISupports interface
|
||||
|
||||
// This "class" supports nsICmdLineHandler and nsISupports.
|
||||
QueryInterface: function (iid) {
|
||||
if (!iid.equals(Components.interfaces.nsICmdLineHandler) &&
|
||||
!iid.equals(Components.interfaces.nsISupports)) {
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
// This Component's module implementation. All the code below is used to get this
|
||||
// component registered and accessible via XPCOM.
|
||||
module: {
|
||||
// registerSelf: Register this component.
|
||||
registerSelf: function (compMgr, fileSpec, location, type) {
|
||||
var compReg = compMgr.QueryInterface( Components.interfaces.nsIComponentRegistrar );
|
||||
compReg.registerFactoryLocation( this.cid,
|
||||
"Default Browser Component",
|
||||
this.contractId,
|
||||
fileSpec,
|
||||
location,
|
||||
type );
|
||||
},
|
||||
|
||||
// getClassObject: Return this component's factory object.
|
||||
getClassObject: function (compMgr, cid, iid) {
|
||||
if (!cid.equals(this.cid))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsIFactory))
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return this.factory;
|
||||
},
|
||||
|
||||
/* CID for this class */
|
||||
cid: Components.ID("{C66E05DC-509C-4972-A1F2-EE5AC34B9800}"),
|
||||
|
||||
/* Contract ID for this class */
|
||||
contractId: "@mozilla.org/commandlinehandler/general-startup;1?type=setDefaultBrowser",
|
||||
|
||||
/* factory object */
|
||||
factory: {
|
||||
// createInstance: Return a new nsSetDefaultBrowser object.
|
||||
createInstance: function (outer, iid) {
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return (new nsSetDefaultBrowser()).QueryInterface(iid);
|
||||
}
|
||||
},
|
||||
|
||||
// canUnload: n/a (returns true)
|
||||
canUnload: function(compMgr) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NSGetModule: Return the nsIModule object.
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return nsSetDefaultBrowser.prototype.module;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define PREF_CHECKDEFAULTBROWSER "browser.shell.checkDefaultBrowser"
|
||||
|
||||
#define SHELLSERVICE_PROPERTIES "chrome://browser/locale/shellservice.properties"
|
||||
#define BRAND_PROPERTIES "chrome://global/locale/brand.properties"
|
||||
|
|
@ -0,0 +1,796 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@mozilla.org> (Clients, Mail, New Default Browser)
|
||||
* Joe Hewitt <hewitt@netscape.com> (Set Background)
|
||||
* Blake Ross <blake@blakeross.com> (Desktop Color)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "gfxIImageFrame.h"
|
||||
#include "imgIContainer.h"
|
||||
#include "imgIRequest.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLImageElement.h"
|
||||
#include "nsIFrame.h"
|
||||
#include "nsIImageLoadingContent.h"
|
||||
#include "nsIOutputStream.h"
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPresShell.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsShellService.h"
|
||||
#include "nsWindowsShellService.h"
|
||||
|
||||
#define MOZ_HWND_BROADCAST_MSG_TIMEOUT 5000
|
||||
#define MOZ_BACKUP_REGISTRY "SOFTWARE\\Mozilla\\Desktop"
|
||||
|
||||
#ifndef MAX_BUF
|
||||
#define MAX_BUF 4096
|
||||
#endif
|
||||
|
||||
#define REG_SUCCEEDED(val) \
|
||||
(val == ERROR_SUCCESS)
|
||||
|
||||
#define REG_FAILED(val) \
|
||||
(val != ERROR_SUCCESS)
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsWindowsShellService, nsIWindowsShellService, nsIShellService)
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Default Browser Registry Settings
|
||||
//
|
||||
// - File Extension Mappings
|
||||
// -----------------------
|
||||
// The following file extensions:
|
||||
// .htm .html .shtml .xht .xhtml
|
||||
// are mapped like so:
|
||||
//
|
||||
// HKLM\SOFTWARE\Classes\.<ext>\ (default) REG_SZ FirefoxHTML
|
||||
//
|
||||
// as aliases to the class:
|
||||
//
|
||||
// HKLM\SOFTWARE\Classes\FirefoxHTML\
|
||||
// DefaultIcon (default) REG_SZ <appname>,1
|
||||
// shell\open\command (default) REG_SZ <appname> -url "%1"
|
||||
//
|
||||
// - Protocol Mappings
|
||||
// -----------------
|
||||
// The following protocols:
|
||||
// HTTP, HTTPS, FTP, GOPHER, CHROME
|
||||
// are mapped like so:
|
||||
//
|
||||
// HKLM\SOFTWARE\Classes\<protocol>\
|
||||
// DefaultIcon (default) REG_SZ <appname>,1
|
||||
// shell\open\command (default) REG_SZ <appname> -url "%1"
|
||||
// shell\open\ddeexec (default) REG_SZ "%1",,-1,0,,,,
|
||||
// \application (default) REG_SZ Firefox
|
||||
// \topic (default) REG_SZ WWW_OpenURL
|
||||
//
|
||||
//
|
||||
// - Windows XP Start Menu Browser
|
||||
// -----------------------------
|
||||
// The following keys are set to make Firefox appear in the Windows XP
|
||||
// Start Menu as the browser:
|
||||
//
|
||||
// HKLM\SOFTWARE\Clients\StartMenuInternet
|
||||
// firefox.exe\DefaultIcon (default) REG_SZ <appname>,0
|
||||
// firefox.exe\shell\open\command (default) REG_SZ <appname>
|
||||
// firefox.exe\shell\properties (default) REG_SZ Firefox &Options
|
||||
// firefox.exe\shell\properties\command(default) REG_SZ <appname> -chrome "chrome://browser/content/pref.xul"
|
||||
//
|
||||
// - Uninstall Information
|
||||
// ---------------------
|
||||
// Every key that is set has the previous value stored in:
|
||||
//
|
||||
// HKLM\SOFTWARE\Mozilla\Desktop\ <keyname> REG_SZ oldval
|
||||
//
|
||||
// If there is no previous value, an empty value is set to indicate that the
|
||||
// key should be removed completely.
|
||||
//
|
||||
|
||||
typedef enum { NO_SUBSTITUTION = 0x00,
|
||||
PATH_SUBSTITUTION = 0x01,
|
||||
EXE_SUBSTITUTION = 0x02,
|
||||
NON_ESSENTIAL = 0x04,} SettingFlags;
|
||||
typedef struct {
|
||||
char* keyName;
|
||||
char* valueName;
|
||||
char* valueData;
|
||||
|
||||
PRInt32 flags;
|
||||
} SETTING;
|
||||
|
||||
#define SMI "SOFTWARE\\Clients\\StartMenuInternet\\"
|
||||
#define CLS "SOFTWARE\\Classes\\"
|
||||
#define DI "\\DefaultIcon"
|
||||
#define SOP "\\shell\\open\\command"
|
||||
#define EXE "firefox.exe"
|
||||
|
||||
#define CLS_HTML "FirefoxHTML"
|
||||
#define VAL_ICON "%APPPATH%,1"
|
||||
#define VAL_OPEN "%APPPATH% -url \"%1\""
|
||||
|
||||
#define MAKE_KEY_NAME1(PREFIX, MID) \
|
||||
PREFIX MID
|
||||
|
||||
#define MAKE_KEY_NAME2(PREFIX, MID, SUFFIX) \
|
||||
PREFIX MID SUFFIX
|
||||
|
||||
static SETTING gSettings[] = {
|
||||
// File Extension Aliases
|
||||
{ MAKE_KEY_NAME1(CLS, ".htm"), "", CLS_HTML, NO_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME1(CLS, ".html"), "", CLS_HTML, NO_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME1(CLS, ".shtml"), "", CLS_HTML, NO_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME1(CLS, ".xht"), "", CLS_HTML, NO_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME1(CLS, ".xhtml"), "", CLS_HTML, NO_SUBSTITUTION | NON_ESSENTIAL },
|
||||
|
||||
// File Extension Class
|
||||
{ MAKE_KEY_NAME2(CLS, CLS_HTML, DI), "", VAL_ICON, PATH_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME2(CLS, CLS_HTML, SOP), "", VAL_OPEN, PATH_SUBSTITUTION | NON_ESSENTIAL },
|
||||
|
||||
// Protocol Handlers
|
||||
{ MAKE_KEY_NAME2(CLS, "HTTP", DI), "", VAL_ICON, PATH_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(CLS, "HTTP", SOP), "", VAL_OPEN, PATH_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(CLS, "HTTPS", DI), "", VAL_ICON, PATH_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(CLS, "HTTPS", SOP), "", VAL_OPEN, PATH_SUBSTITUTION },
|
||||
{ MAKE_KEY_NAME2(CLS, "FTP", DI), "", VAL_ICON, PATH_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME2(CLS, "FTP", SOP), "", VAL_OPEN, PATH_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME2(CLS, "GOPHER", DI), "", VAL_ICON, PATH_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME2(CLS, "GOPHER", SOP), "", VAL_OPEN, PATH_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME2(CLS, "CHROME", DI), "", VAL_ICON, PATH_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME2(CLS, "CHROME", SOP), "", VAL_OPEN, PATH_SUBSTITUTION | NON_ESSENTIAL },
|
||||
|
||||
// Windows XP Start Menu
|
||||
{ MAKE_KEY_NAME2(SMI, "%APPEXE%", DI),
|
||||
"",
|
||||
"%APPPATH%,0",
|
||||
PATH_SUBSTITUTION | EXE_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME2(SMI, "%APPEXE%", SOP),
|
||||
"",
|
||||
"%APPPATH%",
|
||||
PATH_SUBSTITUTION | EXE_SUBSTITUTION | NON_ESSENTIAL },
|
||||
{ MAKE_KEY_NAME1(SMI, "%APPEXE%\\shell\\properties\\command"),
|
||||
"",
|
||||
"%APPPATH% -chrome \"chrome://browser/content/pref/pref.xul\"",
|
||||
PATH_SUBSTITUTION | EXE_SUBSTITUTION | NON_ESSENTIAL }
|
||||
|
||||
// The value of the menu must be set by hand, since it contains a localized
|
||||
// string.
|
||||
// firefox.exe\shell\properties (default) REG_SZ Firefox &Options
|
||||
};
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::IsDefaultBrowser(PRBool aStartupCheck, PRBool* aIsDefaultBrowser)
|
||||
{
|
||||
SETTING* settings;
|
||||
SETTING* end = gSettings + sizeof(gSettings)/sizeof(SETTING);
|
||||
|
||||
*aIsDefaultBrowser = PR_TRUE;
|
||||
|
||||
nsCAutoString appPath;
|
||||
char buf[MAX_BUF];
|
||||
::GetModuleFileName(NULL, buf, sizeof(buf));
|
||||
::GetShortPathName(buf, buf, sizeof(buf));
|
||||
ToUpperCase(appPath = buf);
|
||||
|
||||
PRInt32 n = appPath.RFind("\\");
|
||||
nsCAutoString exeName;
|
||||
if (n != kNotFound)
|
||||
exeName = Substring(appPath, n + 1, appPath.Length() - (n - 1));
|
||||
else
|
||||
exeName = appPath;
|
||||
|
||||
char currValue[MAX_BUF];
|
||||
for (settings = gSettings; settings < end; ++settings) {
|
||||
if (settings->flags & NON_ESSENTIAL)
|
||||
continue; // This is not a registry key that determines whether
|
||||
// or not we consider Firefox the "Default Browser."
|
||||
|
||||
nsCAutoString data(settings->valueData);
|
||||
nsCAutoString key(settings->keyName);
|
||||
if (settings->flags & PATH_SUBSTITUTION) {
|
||||
PRInt32 offset = data.Find("%APPPATH%");
|
||||
data.Replace(offset, 9, appPath);
|
||||
}
|
||||
if (settings->flags & EXE_SUBSTITUTION) {
|
||||
PRInt32 offset = key.Find("%APPEXE%");
|
||||
key.Replace(offset, 8, exeName);
|
||||
}
|
||||
|
||||
::ZeroMemory(currValue, sizeof(currValue));
|
||||
HKEY theKey;
|
||||
DWORD result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||
key.get(), 0, KEY_READ, &theKey);
|
||||
if (REG_SUCCEEDED(result)) {
|
||||
DWORD len = sizeof currValue;
|
||||
DWORD result = ::RegQueryValueEx(theKey, settings->valueName, NULL, NULL, (LPBYTE)currValue, &len);
|
||||
if (REG_FAILED(result) || strcmp(data.get(), currValue) != 0) {
|
||||
// Key wasn't set, or was set to something else (something else became the default browser)
|
||||
*aIsDefaultBrowser = PR_FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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 = PR_TRUE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::SetDefaultBrowser(PRBool aClaimAllTypes)
|
||||
{
|
||||
// Locate the Backup key
|
||||
HKEY backupKey;
|
||||
DWORD result = ::RegOpenKey(HKEY_LOCAL_MACHINE, MOZ_BACKUP_REGISTRY, &backupKey);
|
||||
if (result == ERROR_FILE_NOT_FOUND)
|
||||
result = ::RegCreateKey(HKEY_LOCAL_MACHINE, MOZ_BACKUP_REGISTRY, &backupKey);
|
||||
|
||||
SETTING* settings;
|
||||
SETTING* end = gSettings + sizeof(gSettings)/sizeof(SETTING);
|
||||
|
||||
nsCAutoString appPath;
|
||||
char buf[MAX_BUF];
|
||||
::GetModuleFileName(NULL, buf, sizeof(buf));
|
||||
::GetShortPathName(buf, buf, sizeof(buf));
|
||||
ToUpperCase(appPath = buf);
|
||||
|
||||
PRInt32 n = appPath.RFind("\\");
|
||||
nsCAutoString exeName;
|
||||
if (n != kNotFound)
|
||||
exeName = Substring(appPath, n + 1, appPath.Length() - (n - 1));
|
||||
else
|
||||
exeName = appPath;
|
||||
|
||||
for (settings = gSettings; settings < end; ++settings) {
|
||||
nsCAutoString data(settings->valueData);
|
||||
nsCAutoString key(settings->keyName);
|
||||
if (settings->flags & PATH_SUBSTITUTION) {
|
||||
PRInt32 offset = data.Find("%APPPATH%");
|
||||
data.Replace(offset, 9, appPath);
|
||||
}
|
||||
if (settings->flags & EXE_SUBSTITUTION) {
|
||||
PRInt32 offset = key.Find("%APPEXE%");
|
||||
key.Replace(offset, 8, exeName);
|
||||
}
|
||||
|
||||
PRBool replaceExisting = aClaimAllTypes ? PR_TRUE : !(settings->flags & NON_ESSENTIAL);
|
||||
SetRegKey(key.get(), settings->valueName, data.get(),
|
||||
PR_TRUE, backupKey, replaceExisting);
|
||||
}
|
||||
|
||||
// Select the Default Browser for the Windows XP Start Menu
|
||||
SetRegKey(NS_LITERAL_CSTRING(SMI).get(), "", exeName.get(), PR_TRUE, backupKey, aClaimAllTypes);
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService("@mozilla.org/intl/stringbundle;1"));
|
||||
nsCOMPtr<nsIStringBundle> bundle, brandBundle;
|
||||
bundleService->CreateBundle(SHELLSERVICE_PROPERTIES, getter_AddRefs(bundle));
|
||||
bundleService->CreateBundle(BRAND_PROPERTIES, getter_AddRefs(brandBundle));
|
||||
|
||||
// Set the Start Menu item subtitle
|
||||
nsXPIDLString brandFullName;
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandFullName").get(),
|
||||
getter_Copies(brandFullName));
|
||||
nsCAutoString key1(NS_LITERAL_CSTRING(SMI));
|
||||
key1.Append(exeName);
|
||||
key1.Append("\\");
|
||||
SetRegKey(key1.get(), "", NS_ConvertUCS2toUTF8(brandFullName).get(), PR_TRUE, backupKey, aClaimAllTypes);
|
||||
|
||||
// Set the Options menu item title
|
||||
nsXPIDLString brandShortName;
|
||||
brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandShortName));
|
||||
const PRUnichar* brandNameStrings[] = { brandShortName.get() };
|
||||
nsXPIDLString optionsTitle;
|
||||
bundle->FormatStringFromName(NS_LITERAL_STRING("optionsLabel").get(),
|
||||
brandNameStrings, 1, getter_Copies(optionsTitle));
|
||||
|
||||
|
||||
nsCAutoString key2(NS_LITERAL_CSTRING(SMI "%APPEXE%\\shell\\properties"));
|
||||
PRInt32 offset = key2.Find("%APPEXE%");
|
||||
key2.Replace(offset, 8, exeName);
|
||||
SetRegKey(key2.get(), "", NS_ConvertUCS2toUTF8(optionsTitle).get(), PR_TRUE, backupKey, aClaimAllTypes);
|
||||
|
||||
// Refresh the Shell
|
||||
::SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, NULL,
|
||||
(LPARAM)"SOFTWARE\\Clients\\StartMenuInternet",
|
||||
SMTO_NORMAL|SMTO_ABORTIFHUNG,
|
||||
MOZ_HWND_BROADCAST_MSG_TIMEOUT, NULL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::RestoreFileSettings()
|
||||
{
|
||||
// Locate the Backup key
|
||||
HKEY backupKey;
|
||||
DWORD result = ::RegOpenKey(HKEY_LOCAL_MACHINE, MOZ_BACKUP_REGISTRY, &backupKey);
|
||||
if (result == ERROR_FILE_NOT_FOUND)
|
||||
result = ::RegCreateKey(HKEY_LOCAL_MACHINE, MOZ_BACKUP_REGISTRY, &backupKey);
|
||||
|
||||
DWORD i = 0;
|
||||
do {
|
||||
char origKeyName[MAX_BUF];
|
||||
DWORD len = sizeof origKeyName;
|
||||
result = ::RegEnumValue(backupKey, i++, origKeyName, &len, 0, 0, 0, 0);
|
||||
if (REG_SUCCEEDED(result)) {
|
||||
char origValue[MAX_BUF];
|
||||
DWORD len = sizeof origValue;
|
||||
result = ::RegQueryValueEx(backupKey, origKeyName, NULL, NULL, (LPBYTE)origValue, &len);
|
||||
if (REG_SUCCEEDED(result)) {
|
||||
HKEY origKey;
|
||||
result = ::RegOpenKeyEx(NULL, origKeyName, 0, KEY_READ, &origKey);
|
||||
if (REG_SUCCEEDED(result))
|
||||
result = ::RegSetValueEx(origKey, "", 0, REG_SZ, (LPBYTE)origValue, len);
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
|
||||
// Refresh the Shell
|
||||
::SendMessageTimeout(HWND_BROADCAST, WM_SETTINGCHANGE, NULL,
|
||||
(LPARAM)"SOFTWARE\\Clients\\StartMenuInternet",
|
||||
SMTO_NORMAL|SMTO_ABORTIFHUNG,
|
||||
MOZ_HWND_BROADCAST_MSG_TIMEOUT, NULL);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsWindowsShellService::SetRegKey(const char* aKeyName, const char* aValueName,
|
||||
const char* aValue, PRBool aBackup,
|
||||
HKEY aBackupKey, PRBool aReplaceExisting)
|
||||
{
|
||||
char buf[MAX_BUF];
|
||||
DWORD len = sizeof buf;
|
||||
|
||||
HKEY theKey;
|
||||
DWORD result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, aKeyName, 0, KEY_READ | KEY_WRITE, &theKey);
|
||||
if (result == ERROR_FILE_NOT_FOUND)
|
||||
result = ::RegCreateKey(HKEY_LOCAL_MACHINE, aKeyName, &theKey);
|
||||
if (REG_FAILED(result))
|
||||
return;
|
||||
|
||||
// If we're not allowed to replace an existing key, and one exists (i.e. the
|
||||
// result isn't ERROR_FILE_NOT_FOUND, then just return now.
|
||||
if (!aReplaceExisting)
|
||||
return;
|
||||
|
||||
// Get the old value
|
||||
result = ::RegQueryValueEx(theKey, aValueName, NULL, NULL, (LPBYTE)buf, &len);
|
||||
|
||||
// Back up the old value
|
||||
if (aBackup && REG_SUCCEEDED(result))
|
||||
::RegSetValueEx(aBackupKey, aKeyName, 0, REG_SZ, (LPBYTE)buf, len);
|
||||
|
||||
// Set the new value
|
||||
if (REG_FAILED(result) || strcmp(buf, aValue) != 0)
|
||||
::RegSetValueEx(theKey, aValueName, 0, REG_SZ,
|
||||
(LPBYTE)aValue, nsDependentCString(aValue).Length());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::GetShouldCheckDefaultBrowser(PRBool* 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 = PR_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
|
||||
nsWindowsShellService::SetShouldCheckDefaultBrowser(PRBool 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;
|
||||
}
|
||||
|
||||
nsresult
|
||||
WriteBitmap(nsString& aPath, gfxIImageFrame* aImage)
|
||||
{
|
||||
PRInt32 width, height;
|
||||
aImage->GetWidth(&width);
|
||||
aImage->GetHeight(&height);
|
||||
|
||||
PRUint8* bits;
|
||||
PRUint32 length;
|
||||
aImage->GetImageData(&bits, &length);
|
||||
if (!bits) return NS_ERROR_FAILURE;
|
||||
|
||||
PRUint32 bpr;
|
||||
aImage->GetImageBytesPerRow(&bpr);
|
||||
PRInt32 bitCount = bpr/width;
|
||||
|
||||
// initialize these bitmap structs which we will later
|
||||
// serialize directly to the head of the bitmap file
|
||||
LPBITMAPINFOHEADER bmi = (LPBITMAPINFOHEADER)new BITMAPINFO;
|
||||
bmi->biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmi->biWidth = width;
|
||||
bmi->biHeight = height;
|
||||
bmi->biPlanes = 1;
|
||||
bmi->biBitCount = (WORD)bitCount*8;
|
||||
bmi->biCompression = BI_RGB;
|
||||
bmi->biSizeImage = 0; // don't need to set this if bmp is uncompressed
|
||||
bmi->biXPelsPerMeter = 0;
|
||||
bmi->biYPelsPerMeter = 0;
|
||||
bmi->biClrUsed = 0;
|
||||
bmi->biClrImportant = 0;
|
||||
|
||||
BITMAPFILEHEADER bf;
|
||||
bf.bfType = 0x4D42; // 'BM'
|
||||
bf.bfReserved1 = 0;
|
||||
bf.bfReserved2 = 0;
|
||||
bf.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
|
||||
bf.bfSize = bf.bfOffBits + bmi->biSizeImage;
|
||||
|
||||
// get a file output stream
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsILocalFile> path;
|
||||
rv = NS_NewLocalFile(aPath, PR_TRUE, getter_AddRefs(path));
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIOutputStream> stream;
|
||||
NS_NewLocalFileOutputStream(getter_AddRefs(stream), path);
|
||||
|
||||
// write the bitmap headers and rgb pixel data to the file
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (stream) {
|
||||
PRUint32 written;
|
||||
stream->Write((const char*)&bf, sizeof(BITMAPFILEHEADER), &written);
|
||||
if (written == sizeof(BITMAPFILEHEADER)) {
|
||||
stream->Write((const char*)bmi, sizeof(BITMAPINFOHEADER), &written);
|
||||
if (written == sizeof(BITMAPINFOHEADER)) {
|
||||
stream->Write((const char*)bits, length, &written);
|
||||
if (written == length)
|
||||
rv = NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
stream->Close();
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
|
||||
PRInt32 aPosition)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<gfxIImageFrame> gfxFrame;
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLImageElement> imgElement(do_QueryInterface(aElement));
|
||||
if (!imgElement) {
|
||||
// XXX write background loading stuff!
|
||||
}
|
||||
else {
|
||||
nsCOMPtr<nsIImageLoadingContent> imageContent = do_QueryInterface(aElement, &rv);
|
||||
if (!imageContent) return rv;
|
||||
|
||||
// get the image container
|
||||
nsCOMPtr<imgIRequest> request;
|
||||
rv = imageContent->GetRequest(nsIImageLoadingContent::CURRENT_REQUEST,
|
||||
getter_AddRefs(request));
|
||||
if (!request) return rv;
|
||||
nsCOMPtr<imgIContainer> container;
|
||||
rv = request->GetImage(getter_AddRefs(container));
|
||||
if (!request) return rv;
|
||||
|
||||
// get the current frame, which holds the image data
|
||||
container->GetCurrentFrame(getter_AddRefs(gfxFrame));
|
||||
}
|
||||
|
||||
if (!gfxFrame)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get the windows directory ('c:\windows' usually)
|
||||
char winDir[256];
|
||||
::GetWindowsDirectory(winDir, sizeof(winDir));
|
||||
nsAutoString winPath;
|
||||
winPath.AssignWithConversion(winDir);
|
||||
|
||||
// get the product brand name from localized strings
|
||||
nsXPIDLString brandName;
|
||||
nsCID bundleCID = NS_STRINGBUNDLESERVICE_CID;
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(bundleCID));
|
||||
if (bundleService) {
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
rv = bundleService->CreateBundle("chrome://global/locale/brand.properties",
|
||||
getter_AddRefs(brandBundle));
|
||||
if (NS_SUCCEEDED(rv) && brandBundle) {
|
||||
if (NS_FAILED(rv = brandBundle->GetStringFromName(NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandName))))
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// build the file name
|
||||
winPath.Append(NS_LITERAL_STRING("\\").get());
|
||||
winPath.Append(brandName);
|
||||
winPath.Append(NS_LITERAL_STRING(" Wallpaper.bmp").get());
|
||||
|
||||
// write the bitmap to a file in the windows dir
|
||||
rv = WriteBitmap(winPath, gfxFrame);
|
||||
|
||||
// if the file was written successfully, set it as the system wallpaper
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
char subKey[] = "Control Panel\\Desktop";
|
||||
PRBool result = PR_FALSE;
|
||||
DWORD dwDisp = 0;
|
||||
HKEY key;
|
||||
// Try to create/open a subkey under HKLM.
|
||||
DWORD rc = ::RegCreateKeyEx( HKEY_CURRENT_USER,
|
||||
subKey,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&key,
|
||||
&dwDisp );
|
||||
if (REG_SUCCEEDED(rc)) {
|
||||
unsigned char tile[2];
|
||||
unsigned char style[2];
|
||||
if (aPosition == BACKGROUND_TILE) {
|
||||
tile[0] = '1';
|
||||
style[0] = '1';
|
||||
}
|
||||
else if (aPosition == BACKGROUND_CENTER) {
|
||||
tile[0] = '0';
|
||||
style[0] = '0';
|
||||
}
|
||||
else if (aPosition == BACKGROUND_STRETCH) {
|
||||
tile[0] = '0';
|
||||
style[0] = '2';
|
||||
}
|
||||
tile[1] = '\0';
|
||||
style[1] = '\0';
|
||||
::RegSetValueEx(key, "TileWallpaper", 0, REG_SZ, tile, sizeof(tile));
|
||||
::RegSetValueEx(key, "WallpaperStyle", 0, REG_SZ, style, sizeof(style));
|
||||
::SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, ToNewCString(winPath), SPIF_UPDATEINIFILE | SPIF_SENDWININICHANGE);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::OpenPreferredApplication(PRInt32 aApplication)
|
||||
{
|
||||
nsCAutoString application;
|
||||
switch (aApplication) {
|
||||
case nsIShellService::APPLICATION_MAIL:
|
||||
application = NS_LITERAL_CSTRING("Mail");
|
||||
break;
|
||||
case nsIShellService::APPLICATION_NEWS:
|
||||
application = NS_LITERAL_CSTRING("News");
|
||||
break;
|
||||
}
|
||||
|
||||
// The Default Client section of the Windows Registry looks like this:
|
||||
//
|
||||
// Clients\aClient\
|
||||
// e.g. aClient = "Mail"...
|
||||
// \Mail\(default) = Client Subkey Name
|
||||
// \Client Subkey Name
|
||||
// \Client Subkey Name\shell\open\command\
|
||||
// \Client Subkey Name\shell\open\command\(default) = path to exe
|
||||
//
|
||||
nsCAutoString clientKey(NS_LITERAL_CSTRING("SOFTWARE\\Clients\\"));
|
||||
clientKey += application;
|
||||
|
||||
// Find the default application for this class.
|
||||
HKEY theKey;
|
||||
DWORD result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, clientKey.get(),
|
||||
0, KEY_READ, &theKey);
|
||||
if (REG_FAILED(result))
|
||||
return NS_OK;
|
||||
|
||||
char buf[MAX_BUF];
|
||||
DWORD type, len = sizeof buf;
|
||||
result = ::RegQueryValueEx(theKey, "", 0, &type, (LPBYTE)&buf, &len);
|
||||
if (REG_FAILED(result) || nsDependentCString(buf).IsEmpty())
|
||||
return NS_OK;
|
||||
|
||||
// Find the "open" command
|
||||
clientKey.Append("\\");
|
||||
clientKey.Append(buf);
|
||||
clientKey.Append("\\shell\\open\\command");
|
||||
|
||||
result = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, clientKey.get(),
|
||||
0, KEY_READ, &theKey);
|
||||
if (REG_FAILED(result))
|
||||
return NS_OK;
|
||||
|
||||
::ZeroMemory(buf, sizeof(buf));
|
||||
len = sizeof buf;
|
||||
result = ::RegQueryValueEx(theKey, "", 0, &type, (LPBYTE)&buf, &len);
|
||||
if (REG_FAILED(result) || nsDependentCString(buf).IsEmpty())
|
||||
return NS_OK;
|
||||
|
||||
nsCAutoString path; path.Assign(buf);
|
||||
|
||||
// Look for any embedded environment variables and substitute their
|
||||
// values, as |::CreateProcess| is unable to do this.
|
||||
PRInt32 end = path.Length();
|
||||
PRInt32 cursor = 0, temp = 0;
|
||||
::ZeroMemory(buf, sizeof(buf));
|
||||
do {
|
||||
cursor = path.FindChar('%', cursor);
|
||||
if (cursor < 0)
|
||||
break;
|
||||
|
||||
temp = path.FindChar('%', cursor + 1);
|
||||
|
||||
++cursor;
|
||||
|
||||
::ZeroMemory(&buf, sizeof(buf));
|
||||
::GetEnvironmentVariable(nsCAutoString(Substring(path, cursor, temp - cursor)).get(),
|
||||
buf, sizeof(buf));
|
||||
|
||||
// "+ 2" is to subtract the extra characters used to delimit the environment
|
||||
// variable ('%').
|
||||
path.Replace((cursor - 1), temp - cursor + 2, nsDependentCString(buf));
|
||||
|
||||
++cursor;
|
||||
}
|
||||
while (cursor < end);
|
||||
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
|
||||
::ZeroMemory(&si, sizeof(STARTUPINFO));
|
||||
::ZeroMemory(&pi, sizeof(PROCESS_INFORMATION));
|
||||
|
||||
char* pathCStr = ToNewCString(path);
|
||||
BOOL success = ::CreateProcess(NULL, pathCStr, NULL, NULL, FALSE, 0, NULL,
|
||||
NULL, &si, &pi);
|
||||
nsCRT::free(pathCStr);
|
||||
if (!success)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::GetDesktopBackgroundColor(PRUint32* aColor)
|
||||
{
|
||||
PRUint32 color = ::GetSysColor(COLOR_DESKTOP);
|
||||
*aColor = (GetRValue(color) << 16) | (GetGValue(color) << 8) | GetBValue(color);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::SetDesktopBackgroundColor(PRUint32 aColor)
|
||||
{
|
||||
int aParameters[2] = { COLOR_BACKGROUND, COLOR_DESKTOP };
|
||||
BYTE r = (aColor >> 16);
|
||||
BYTE g = (aColor << 16) >> 24;
|
||||
BYTE b = (aColor << 24) >> 24;
|
||||
COLORREF colors[2] = { RGB(r,g,b), RGB(r,g,b) };
|
||||
|
||||
::SetSysColors(sizeof(aParameters) / sizeof(int), aParameters, colors);
|
||||
|
||||
char subKey[] = "Control Panel\\Colors";
|
||||
PRBool result = PR_FALSE;
|
||||
DWORD dwDisp = 0;
|
||||
HKEY key;
|
||||
// Try to create/open a subkey under HKLM.
|
||||
DWORD rc = ::RegCreateKeyEx(HKEY_CURRENT_USER, subKey, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &key,
|
||||
&dwDisp);
|
||||
if (REG_SUCCEEDED(rc)) {
|
||||
unsigned char rgb[12];
|
||||
sprintf((char*)rgb, "%u %u %u\0", r, g, b);
|
||||
::RegSetValueEx(key, "Background", 0, REG_SZ, (const unsigned char*)rgb, strlen((char*)rgb));
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowsShellService::GetUnreadMailCount(PRUint32* aCount)
|
||||
{
|
||||
*aCount = 0;
|
||||
|
||||
HKEY accountKey;
|
||||
if (GetMailAccountKey(&accountKey)) {
|
||||
DWORD type, unreadCount;
|
||||
DWORD len = sizeof unreadCount;
|
||||
DWORD result = ::RegQueryValueEx(accountKey, "MessageCount", 0, &type,
|
||||
(LPBYTE)&unreadCount, &len);
|
||||
if (REG_SUCCEEDED(result)) {
|
||||
*aCount = unreadCount;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsWindowsShellService::GetMailAccountKey(HKEY* aResult)
|
||||
{
|
||||
HKEY mailKey;
|
||||
DWORD result = ::RegOpenKeyEx(HKEY_CURRENT_USER,
|
||||
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\",
|
||||
0, KEY_ENUMERATE_SUB_KEYS, &mailKey);
|
||||
|
||||
PRInt32 i = 0;
|
||||
do {
|
||||
char subkeyName[MAX_BUF];
|
||||
DWORD len = sizeof subkeyName;
|
||||
result = ::RegEnumKeyEx(mailKey, i++, subkeyName, &len, 0, 0, 0, 0);
|
||||
if (REG_SUCCEEDED(result)) {
|
||||
HKEY accountKey;
|
||||
result = ::RegOpenKeyEx(mailKey, subkeyName, 0, KEY_READ, &accountKey);
|
||||
if (REG_SUCCEEDED(result)) {
|
||||
*aResult = accountKey;
|
||||
return PR_TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Shell Service.
|
||||
*
|
||||
* The Initial Developer of the Original Code is mozilla.org.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2004
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Ben Goodger <ben@mozilla.org>
|
||||
* Aaron Kaluszka <ask@swva.net>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nswindowsshellservice_h____
|
||||
#define nswindowsshellservice_h____
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsIWindowsShellService.h"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
class nsWindowsShellService : public nsIWindowsShellService
|
||||
{
|
||||
public:
|
||||
nsWindowsShellService() : mCheckedThisSession(PR_FALSE) {};
|
||||
virtual ~nsWindowsShellService() {};
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSISHELLSERVICE
|
||||
NS_DECL_NSIWINDOWSSHELLSERVICE
|
||||
|
||||
protected:
|
||||
PRBool GetMailAccountKey(HKEY* aResult);
|
||||
void SetRegKey(const char* aKeyName, const char* aValueName,
|
||||
const char* aValue, PRBool aBackup, HKEY aBackupKey,
|
||||
PRBool aReplaceExisting);
|
||||
|
||||
private:
|
||||
PRBool mCheckedThisSession;
|
||||
};
|
||||
|
||||
#endif // nswindowsshellservice_h____
|
Загрузка…
Ссылка в новой задаче