mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1522694: Add a toolkit level API for determining if this is the default instance of the application. r=mconley
This also switches around a few preprocessor lines to make more sense. Differential Revision: https://phabricator.services.mozilla.com/D17557 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
88359867bd
commit
26e0f46fb1
@ -15,6 +15,7 @@
|
||||
#elif defined(MOZ_WIDGET_GTK)
|
||||
# include "nsGNOMEShellService.h"
|
||||
#endif
|
||||
#include "nsIToolkitShellService.h"
|
||||
|
||||
#if defined(MOZ_WIDGET_COCOA)
|
||||
# include "nsMacAttribution.h"
|
||||
@ -51,16 +52,12 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(nsIEHistoryEnumerator)
|
||||
#endif
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_BROWSERDIRECTORYPROVIDER_CID);
|
||||
#if defined(XP_WIN)
|
||||
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
|
||||
#elif defined(MOZ_WIDGET_GTK)
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(XP_MACOSX)
|
||||
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
|
||||
#endif
|
||||
NS_DEFINE_NAMED_CID(NS_BROWSER_ABOUT_REDIRECTOR_CID);
|
||||
#if defined(XP_WIN)
|
||||
NS_DEFINE_NAMED_CID(NS_WINIEHISTORYENUMERATOR_CID);
|
||||
#elif defined(XP_MACOSX)
|
||||
NS_DEFINE_NAMED_CID(NS_SHELLSERVICE_CID);
|
||||
#endif
|
||||
#if defined(MOZ_WIDGET_COCOA)
|
||||
NS_DEFINE_NAMED_CID(NS_MACATTRIBUTIONSERVICE_CID);
|
||||
@ -73,12 +70,12 @@ static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
|
||||
{ &kNS_SHELLSERVICE_CID, false, nullptr, nsWindowsShellServiceConstructor },
|
||||
#elif defined(MOZ_WIDGET_GTK)
|
||||
{ &kNS_SHELLSERVICE_CID, false, nullptr, nsGNOMEShellServiceConstructor },
|
||||
#elif defined(XP_MACOSX)
|
||||
{ &kNS_SHELLSERVICE_CID, false, nullptr, nsMacShellServiceConstructor },
|
||||
#endif
|
||||
{ &kNS_BROWSER_ABOUT_REDIRECTOR_CID, false, nullptr, AboutRedirector::Create },
|
||||
#if defined(XP_WIN)
|
||||
{ &kNS_WINIEHISTORYENUMERATOR_CID, false, nullptr, nsIEHistoryEnumeratorConstructor },
|
||||
#elif defined(XP_MACOSX)
|
||||
{ &kNS_SHELLSERVICE_CID, false, nullptr, nsMacShellServiceConstructor },
|
||||
#endif
|
||||
#if defined(MOZ_WIDGET_COCOA)
|
||||
{ &kNS_MACATTRIBUTIONSERVICE_CID, false, nullptr, nsMacAttributionServiceConstructor },
|
||||
@ -90,10 +87,9 @@ static const mozilla::Module::CIDEntry kBrowserCIDs[] = {
|
||||
static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
|
||||
// clang-format off
|
||||
{ NS_BROWSERDIRECTORYPROVIDER_CONTRACTID, &kNS_BROWSERDIRECTORYPROVIDER_CID },
|
||||
#if defined(XP_WIN)
|
||||
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
|
||||
#elif defined(MOZ_WIDGET_GTK)
|
||||
#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) || defined(XP_MACOSX)
|
||||
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
|
||||
{ NS_TOOLKITSHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
|
||||
#endif
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "blocked", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "certerror", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
@ -117,8 +113,6 @@ static const mozilla::Module::ContractIDEntry kBrowserContracts[] = {
|
||||
{ NS_ABOUT_MODULE_CONTRACTID_PREFIX "pocket-signup", &kNS_BROWSER_ABOUT_REDIRECTOR_CID },
|
||||
#if defined(XP_WIN)
|
||||
{ NS_IEHISTORYENUMERATOR_CONTRACTID, &kNS_WINIEHISTORYENUMERATOR_CID },
|
||||
#elif defined(XP_MACOSX)
|
||||
{ NS_SHELLSERVICE_CONTRACTID, &kNS_SHELLSERVICE_CID },
|
||||
#endif
|
||||
#if defined(MOZ_WIDGET_COCOA)
|
||||
{ NS_MACATTRIBUTIONSERVICE_CONTRACTID, &kNS_MACATTRIBUTIONSERVICE_CID },
|
||||
|
@ -23,28 +23,27 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
XPIDL_SOURCES += [
|
||||
'nsIMacShellService.idl',
|
||||
]
|
||||
|
||||
SOURCES += [
|
||||
'nsMacShellService.cpp',
|
||||
]
|
||||
elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
|
||||
XPIDL_SOURCES += [
|
||||
'nsIGNOMEShellService.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'shellservice'
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
SOURCES += [
|
||||
'nsGNOMEShellService.cpp',
|
||||
]
|
||||
elif CONFIG['OS_ARCH'] == 'WINNT':
|
||||
SOURCES += [
|
||||
'nsWindowsShellService.cpp',
|
||||
]
|
||||
LOCAL_INCLUDES += [
|
||||
'../../../other-licenses/nsis/Contrib/CityHash/cityhash',
|
||||
]
|
||||
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
|
||||
SOURCES += [
|
||||
'nsMacShellService.cpp',
|
||||
]
|
||||
elif 'gtk' in CONFIG['MOZ_WIDGET_TOOLKIT']:
|
||||
SOURCES += [
|
||||
'nsGNOMEShellService.cpp',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'shellservice'
|
||||
|
||||
if SOURCES:
|
||||
FINAL_LIBRARY = 'browsercomps'
|
||||
|
@ -121,7 +121,8 @@ nsresult nsGNOMEShellService::Init() {
|
||||
return appPath->GetNativePath(mAppPath);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsGNOMEShellService, nsIGNOMEShellService, nsIShellService)
|
||||
NS_IMPL_ISUPPORTS(nsGNOMEShellService, nsIGNOMEShellService, nsIShellService,
|
||||
nsIToolkitShellService)
|
||||
|
||||
bool nsGNOMEShellService::GetAppPathFromLauncher() {
|
||||
gchar *tmp;
|
||||
|
@ -7,10 +7,12 @@
|
||||
#define nsgnomeshellservice_h____
|
||||
|
||||
#include "nsIGNOMEShellService.h"
|
||||
#include "nsToolkitShellService.h"
|
||||
#include "nsString.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
||||
class nsGNOMEShellService final : public nsIGNOMEShellService {
|
||||
class nsGNOMEShellService final : public nsIGNOMEShellService,
|
||||
public nsToolkitShellService {
|
||||
public:
|
||||
nsGNOMEShellService() : mAppIsInPath(false) {}
|
||||
|
||||
|
@ -37,7 +37,7 @@ using mozilla::dom::Element;
|
||||
#define SAFARI_BUNDLE_IDENTIFIER "com.apple.Safari"
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsMacShellService, nsIMacShellService, nsIShellService,
|
||||
nsIWebProgressListener)
|
||||
nsIToolkitShellService, nsIWebProgressListener)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMacShellService::IsDefaultBrowser(bool aForAllTypes,
|
||||
|
@ -6,12 +6,14 @@
|
||||
#ifndef nsmacshellservice_h____
|
||||
#define nsmacshellservice_h____
|
||||
|
||||
#include "nsToolkitShellService.h"
|
||||
#include "nsIMacShellService.h"
|
||||
#include "nsIWebProgressListener.h"
|
||||
#include "nsIFile.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
class nsMacShellService : public nsIMacShellService,
|
||||
public nsToolkitShellService,
|
||||
public nsIWebProgressListener {
|
||||
public:
|
||||
nsMacShellService(){};
|
||||
|
22
browser/components/shell/nsToolkitShellService.h
Normal file
22
browser/components/shell/nsToolkitShellService.h
Normal file
@ -0,0 +1,22 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef nstoolkitshellservice_h____
|
||||
#define nstoolkitshellservice_h____
|
||||
|
||||
#include "nsIToolkitShellService.h"
|
||||
|
||||
class nsToolkitShellService : public nsIToolkitShellService {
|
||||
public:
|
||||
NS_IMETHOD IsDefaultBrowser(bool aForAllTypes,
|
||||
bool* aIsDefaultBrowser) = 0;
|
||||
|
||||
NS_IMETHODIMP IsDefaultApplication(bool* aIsDefaultBrowser) {
|
||||
// Only care about the http(s) protocol. This only matters on Windows.
|
||||
return IsDefaultBrowser(false, aIsDefaultBrowser);
|
||||
}
|
||||
};
|
||||
|
||||
#endif // nstoolkitshellservice_h____
|
@ -66,7 +66,7 @@ using mozilla::IsWin8OrLater;
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::widget;
|
||||
|
||||
NS_IMPL_ISUPPORTS(nsWindowsShellService, nsIShellService)
|
||||
NS_IMPL_ISUPPORTS(nsWindowsShellService, nsIToolkitShellService, nsIShellService)
|
||||
|
||||
static nsresult OpenKeyForReading(HKEY aKeyRoot, const nsAString& aKeyName,
|
||||
HKEY* aKey) {
|
||||
|
@ -8,12 +8,14 @@
|
||||
|
||||
#include "nscore.h"
|
||||
#include "nsString.h"
|
||||
#include "nsToolkitShellService.h"
|
||||
#include "nsIShellService.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <ole2.h>
|
||||
|
||||
class nsWindowsShellService : public nsIShellService {
|
||||
class nsWindowsShellService : public nsIShellService,
|
||||
public nsToolkitShellService {
|
||||
virtual ~nsWindowsShellService();
|
||||
|
||||
public:
|
||||
|
@ -61,6 +61,7 @@ DIRS += [
|
||||
'resistfingerprinting',
|
||||
'securityreporter',
|
||||
'sessionstore',
|
||||
'shell',
|
||||
'startup',
|
||||
'statusfilter',
|
||||
'telemetry',
|
||||
|
11
toolkit/components/shell/moz.build
Normal file
11
toolkit/components/shell/moz.build
Normal file
@ -0,0 +1,11 @@
|
||||
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# 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/.
|
||||
|
||||
XPIDL_SOURCES += [
|
||||
'nsIToolkitShellService.idl',
|
||||
]
|
||||
|
||||
XPIDL_MODULE = 'toolkit_shell'
|
22
toolkit/components/shell/nsIToolkitShellService.idl
Normal file
22
toolkit/components/shell/nsIToolkitShellService.idl
Normal file
@ -0,0 +1,22 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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 "nsISupports.idl"
|
||||
|
||||
[scriptable, uuid(9246cad6-926a-4c17-88b0-ecba8078d143)]
|
||||
interface nsIToolkitShellService : nsISupports
|
||||
{
|
||||
/**
|
||||
* Determines whether or not this application is the default for the operating
|
||||
* system. It is up to the application to determine how to answer this
|
||||
* question but it would typically involve checking if it is registered as the
|
||||
* default handler for web protocols and/or file types.
|
||||
*/
|
||||
boolean isDefaultApplication();
|
||||
};
|
||||
|
||||
%{ C++
|
||||
#define NS_TOOLKITSHELLSERVICE_CONTRACTID "@mozilla.org/toolkit/shell-service;1"
|
||||
%}
|
Loading…
Reference in New Issue
Block a user