зеркало из https://github.com/mozilla/pjs.git
Adding a bunch of security warnings and dialogs, overriding the
XUL impl with our own.
This commit is contained in:
Родитель
e4b3c43869
Коммит
6f39db2325
Двоичный файл не отображается.
|
@ -273,7 +273,7 @@
|
|||
buildSettings = {
|
||||
DEBUGGING_SYMBOLS = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/rdf ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/docshell ../dist/include/profile ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/xpcom";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/intl ../dist/include/pipboot ../dist/include/pipnss ../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/rdf ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/docshell ../dist/include/profile ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/xpcom";
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LIBRARY_SEARCH_PATHS = "../dist/bin ../dist/lib ../intl/unicharutil/util ../modules/zlib/src";
|
||||
OPTIMIZATION_CFLAGS = "-O2";
|
||||
|
|
Двоичный файл не отображается.
|
@ -32,6 +32,8 @@
|
|||
promptPanelCheck = id;
|
||||
promptPanelInput = id;
|
||||
promptPanelText = id;
|
||||
securityMismatchPanel = id;
|
||||
securityUnknownPanel = id;
|
||||
usernamePanel = id;
|
||||
usernamePanelCheck = id;
|
||||
usernamePanelPassword = id;
|
||||
|
|
|
@ -6,17 +6,7 @@
|
|||
<string>44 234 356 301 0 0 1024 746 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>248.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
<integer>69</integer>
|
||||
<integer>124</integer>
|
||||
<integer>53</integer>
|
||||
<integer>59</integer>
|
||||
<integer>103</integer>
|
||||
<integer>157</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q110</string>
|
||||
<string>5S60</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичный файл не отображается.
|
@ -45,7 +45,6 @@
|
|||
#include "nsIPrefBranch.h"
|
||||
#import "CHAboutBox.h"
|
||||
|
||||
|
||||
static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||
|
||||
@implementation MainController
|
||||
|
@ -94,7 +93,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"];
|
||||
|
||||
}
|
||||
|
||||
-(IBAction)newWindow:(id)aSender
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
promptPanelCheck = id;
|
||||
promptPanelInput = id;
|
||||
promptPanelText = id;
|
||||
securityMismatchPanel = id;
|
||||
securityUnknownPanel = id;
|
||||
usernamePanel = id;
|
||||
usernamePanelCheck = id;
|
||||
usernamePanelPassword = id;
|
||||
|
|
|
@ -6,17 +6,7 @@
|
|||
<string>44 234 356 301 0 0 1024 746 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>248.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
<integer>69</integer>
|
||||
<integer>124</integer>
|
||||
<integer>53</integer>
|
||||
<integer>59</integer>
|
||||
<integer>103</integer>
|
||||
<integer>157</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q110</string>
|
||||
<string>5S60</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичный файл не отображается.
|
@ -62,7 +62,9 @@
|
|||
IBOutlet id passwordPanel;
|
||||
IBOutlet id passwordPanelCheck;
|
||||
IBOutlet id passwordPanelText;
|
||||
IBOutlet id passwordPanelInput;
|
||||
IBOutlet id passwordPanelInput;
|
||||
IBOutlet id securityMismatchPanel;
|
||||
IBOutlet id securityUnknownPanel;
|
||||
IBOutlet id usernamePanel;
|
||||
IBOutlet id usernamePanelCheck;
|
||||
IBOutlet id usernamePanelText;
|
||||
|
@ -90,4 +92,8 @@
|
|||
- (BOOL)prompt:(NSWindow*)parent title:(NSString*)title text:(NSString*)text promptText:(NSMutableString*)promptText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
- (BOOL)promptUserNameAndPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text userNameText:(NSMutableString*)userNameText passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
- (BOOL)promptPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
|
||||
- (BOOL)badCert:(NSWindow*)parent;
|
||||
- (int)unknownCert:(NSWindow*)parent;
|
||||
|
||||
@end
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#import "nsAlertController.h"
|
||||
#import "nsCocoaBrowserService.h"
|
||||
|
||||
#include "nsIBadCertListener.h"
|
||||
|
||||
@implementation nsAlertController
|
||||
|
||||
- (IBAction)hitButton1:(id)sender
|
||||
|
@ -240,4 +242,22 @@
|
|||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)badCert:(NSWindow*)parent
|
||||
{
|
||||
int result = [NSApp runModalForWindow:securityMismatchPanel relativeToWindow:parent];
|
||||
[securityMismatchPanel close];
|
||||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
- (int)unknownCert:(NSWindow*)parent
|
||||
{
|
||||
int result = [NSApp runModalForWindow:securityUnknownPanel relativeToWindow:parent];
|
||||
[securityUnknownPanel close];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -40,12 +40,18 @@
|
|||
|
||||
#import "nsAlertController.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWindowCreator.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIBadCertListener.h"
|
||||
#include "nsISecurityWarningDialogs.h"
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
class nsCocoaBrowserService : public nsIWindowCreator,
|
||||
public nsIPromptService,
|
||||
public nsIFactory
|
||||
public nsIFactory,
|
||||
public nsIBadCertListener, public nsISecurityWarningDialogs, public nsINSSDialogs
|
||||
{
|
||||
public:
|
||||
nsCocoaBrowserService();
|
||||
|
@ -55,7 +61,10 @@ public:
|
|||
NS_DECL_NSIWINDOWCREATOR
|
||||
NS_DECL_NSIPROMPTSERVICE
|
||||
NS_DECL_NSIFACTORY
|
||||
|
||||
NS_DECL_NSINSSDIALOGS
|
||||
NS_DECL_NSIBADCERTLISTENER
|
||||
NS_DECL_NSISECURITYWARNINGDIALOGS
|
||||
|
||||
static nsresult InitEmbedding();
|
||||
static void TermEmbedding();
|
||||
static void BrowserClosed();
|
||||
|
@ -67,6 +76,13 @@ public:
|
|||
static PRUint32 sNumBrowsers;
|
||||
|
||||
private:
|
||||
|
||||
nsresult AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
|
||||
const PRUnichar *messageName,
|
||||
const PRUnichar *showAgainName);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> mSecurityStringBundle;
|
||||
|
||||
static nsCocoaBrowserService* sSingleton;
|
||||
static nsAlertController* sController;
|
||||
static PRBool sCanTerminate;
|
||||
|
|
|
@ -45,6 +45,17 @@
|
|||
#include "CHBrowserView.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
|
||||
// {0ffd3880-7a1a-11d6-a384-975d1d5f86fc}
|
||||
#define NS_BADCERTHANDLER_CID \
|
||||
{0x0ffd3880, 0x7a1a, 0x11d6,{0xa3, 0x84, 0x97, 0x5d, 0x1d, 0x5f, 0x86, 0xfc}}
|
||||
|
||||
nsAlertController* nsCocoaBrowserService::sController = nsnull;
|
||||
nsCocoaBrowserService* nsCocoaBrowserService::sSingleton = nsnull;
|
||||
|
@ -61,10 +72,11 @@ nsCocoaBrowserService::~nsCocoaBrowserService()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsCocoaBrowserService,
|
||||
NS_IMPL_ISUPPORTS6(nsCocoaBrowserService,
|
||||
nsIWindowCreator,
|
||||
nsIPromptService,
|
||||
nsIFactory)
|
||||
nsIFactory,
|
||||
nsIBadCertListener, nsISecurityWarningDialogs, nsINSSDialogs)
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::InitEmbedding()
|
||||
|
@ -75,34 +87,37 @@ nsCocoaBrowserService::InitEmbedding()
|
|||
return NS_OK;
|
||||
|
||||
sSingleton = new nsCocoaBrowserService();
|
||||
if (!sSingleton) {
|
||||
if (!sSingleton)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(sSingleton);
|
||||
|
||||
nsCOMPtr<nsIComponentRegistrar> cr;
|
||||
NS_GetComponentRegistrar(getter_AddRefs(cr));
|
||||
if ( !cr )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Register as the prompt service
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
|
||||
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
|
||||
|
||||
nsresult rv = nsComponentManager::RegisterFactory(kPromptServiceCID,
|
||||
"Prompt Service",
|
||||
"@mozilla.org/embedcomp/prompt-service;1",
|
||||
sSingleton,
|
||||
PR_TRUE); // replace existing
|
||||
if (NS_FAILED(rv)) {
|
||||
nsresult rv = cr->RegisterFactory(kPromptServiceCID, "Prompt Service", "@mozilla.org/embedcomp/prompt-service;1",
|
||||
sSingleton);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Register as the window creator
|
||||
nsCOMPtr<nsIWindowWatcher> watcher(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (!watcher) {
|
||||
if (!watcher)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
watcher->SetWindowCreator(sSingleton);
|
||||
|
||||
return NS_OK;
|
||||
// replace gecko's cert dialogs with our own implementation that doesn't use XUL. We rely
|
||||
// on our own dialogs in the alert nib and use the alert controller to display them.
|
||||
static NS_DEFINE_CID(kBadCertHandlerCID, NS_BADCERTHANDLER_CID);
|
||||
rv = cr->RegisterFactory(kBadCertHandlerCID, "Bad Cert Handler", NS_NSSDIALOGS_CONTRACTID,
|
||||
sSingleton);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -506,3 +521,188 @@ nsCocoaBrowserService::CreateChromeWindow(nsIWebBrowserChrome *parent,
|
|||
return browserChrome->CreateChromeWindow(parent, chromeFlags, _retval);
|
||||
}
|
||||
|
||||
|
||||
/* boolean unknownIssuer (in nsITransportSecurityInfo socketInfo,
|
||||
in nsIX509Cert cert, out addType); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
|
||||
nsIX509Cert *cert, PRInt16 *outAddType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
*outAddType = ADD_TRUSTED_FOR_SESSION;
|
||||
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*outAddType = (PRBool)[controller unknownCert:[NSApp mainWindow]];
|
||||
switch ( *outAddType ) {
|
||||
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
||||
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
default:
|
||||
*_retval = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean mismatchDomain (in nsITransportSecurityInfo socketInfo,
|
||||
in wstring targetURL,
|
||||
in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::MismatchDomain(nsITransportSecurityInfo *socketInfo,
|
||||
const PRUnichar *targetURL,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* boolean certExpired (in nsITransportSecurityInfo socketInfo,
|
||||
in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::CertExpired(nsITransportSecurityInfo *socketInfo,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::CrlNextupdate(nsITransportSecurityInfo *socketInfo,
|
||||
const PRUnichar * targetURL, nsIX509Cert *cert)
|
||||
{
|
||||
// what does this do!?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#define ENTER_SITE_PREF "security.warn_entering_secure"
|
||||
#define WEAK_SITE_PREF "security.warn_entering_weak"
|
||||
#define LEAVE_SITE_PREF "security.warn_leaving_secure"
|
||||
#define MIXEDCONTENT_PREF "security.warn_viewing_mixed"
|
||||
#define INSECURE_SUBMIT_PREF "security.warn_submit_insecure"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertEnteringSecure(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
// I don't think any user cares they're entering a secure site.
|
||||
#if 0
|
||||
rv = AlertDialog(ctx, ENTER_SITE_PREF,
|
||||
NS_LITERAL_STRING("EnterSecureMessage").get(),
|
||||
NS_LITERAL_STRING("EnterSecureShowAgain").get());
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertEnteringWeak(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, WEAK_SITE_PREF,
|
||||
NS_LITERAL_STRING("WeakSecureMessage").get(),
|
||||
NS_LITERAL_STRING("WeakSecureShowAgain").get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertLeavingSecure(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, LEAVE_SITE_PREF,
|
||||
NS_LITERAL_STRING("LeaveSecureMessage").get(),
|
||||
NS_LITERAL_STRING("LeaveSecureShowAgain").get());
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertMixedMode(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, MIXEDCONTENT_PREF,
|
||||
NS_LITERAL_STRING("MixedContentMessage").get(),
|
||||
NS_LITERAL_STRING("MixedContentShowAgain").get());
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
|
||||
const PRUnichar *dialogMessageName,
|
||||
const PRUnichar *showAgainName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get user's preference for this alert
|
||||
PRBool prefValue = PR_TRUE;
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if ( pref )
|
||||
pref->GetBoolPref(prefName, &prefValue);
|
||||
|
||||
// Stop if alert is not requested
|
||||
if (!prefValue) return NS_OK;
|
||||
|
||||
if (!mSecurityStringBundle) {
|
||||
#define STRING_BUNDLE_URL "chrome://communicator/locale/security.properties"
|
||||
nsCOMPtr<nsIStringBundleService> service = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
if ( service )
|
||||
rv = service->CreateBundle(STRING_BUNDLE_URL, getter_AddRefs(mSecurityStringBundle));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Get Prompt to use
|
||||
nsCOMPtr<nsIPrompt> prompt = do_GetInterface(ctx);
|
||||
if (!prompt) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get messages strings from localization file
|
||||
nsXPIDLString windowTitle, message, dontShowAgain;
|
||||
|
||||
mSecurityStringBundle->GetStringFromName(NS_LITERAL_STRING("Title").get(), getter_Copies(windowTitle));
|
||||
mSecurityStringBundle->GetStringFromName(dialogMessageName, getter_Copies(message));
|
||||
mSecurityStringBundle->GetStringFromName(showAgainName, getter_Copies(dontShowAgain));
|
||||
if (!windowTitle || !message || !dontShowAgain) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = prompt->AlertCheck(windowTitle, message, dontShowAgain, &prefValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!prefValue)
|
||||
pref->SetBoolPref(prefName, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::ConfirmPostToInsecure(nsIInterfaceRequestor *ctx, PRBool* _result)
|
||||
{
|
||||
// no user cares about this. the first thing they do is turn it off.
|
||||
*_result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx, PRBool* _result)
|
||||
{
|
||||
// users may care about this one, but we haven't yet implemented ConfirmEx().
|
||||
*_result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@
|
|||
buildSettings = {
|
||||
DEBUGGING_SYMBOLS = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/rdf ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/docshell ../dist/include/profile ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/xpcom";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/intl ../dist/include/pipboot ../dist/include/pipnss ../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/rdf ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/docshell ../dist/include/profile ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/xpcom";
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LIBRARY_SEARCH_PATHS = "../dist/bin ../dist/lib ../intl/unicharutil/util ../modules/zlib/src";
|
||||
OPTIMIZATION_CFLAGS = "-O2";
|
||||
|
|
Двоичные данные
camino/resources/localized/English.lproj/BrowserWindow.nib/objects.nib
сгенерированный
Двоичные данные
camino/resources/localized/English.lproj/BrowserWindow.nib/objects.nib
сгенерированный
Двоичный файл не отображается.
|
@ -32,6 +32,8 @@
|
|||
promptPanelCheck = id;
|
||||
promptPanelInput = id;
|
||||
promptPanelText = id;
|
||||
securityMismatchPanel = id;
|
||||
securityUnknownPanel = id;
|
||||
usernamePanel = id;
|
||||
usernamePanelCheck = id;
|
||||
usernamePanelPassword = id;
|
||||
|
|
|
@ -6,17 +6,7 @@
|
|||
<string>44 234 356 301 0 0 1024 746 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>248.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
<integer>69</integer>
|
||||
<integer>124</integer>
|
||||
<integer>53</integer>
|
||||
<integer>59</integer>
|
||||
<integer>103</integer>
|
||||
<integer>157</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q110</string>
|
||||
<string>5S60</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичный файл не отображается.
|
@ -45,7 +45,6 @@
|
|||
#include "nsIPrefBranch.h"
|
||||
#import "CHAboutBox.h"
|
||||
|
||||
|
||||
static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||
|
||||
@implementation MainController
|
||||
|
@ -94,7 +93,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"];
|
||||
|
||||
}
|
||||
|
||||
-(IBAction)newWindow:(id)aSender
|
||||
|
|
|
@ -62,7 +62,9 @@
|
|||
IBOutlet id passwordPanel;
|
||||
IBOutlet id passwordPanelCheck;
|
||||
IBOutlet id passwordPanelText;
|
||||
IBOutlet id passwordPanelInput;
|
||||
IBOutlet id passwordPanelInput;
|
||||
IBOutlet id securityMismatchPanel;
|
||||
IBOutlet id securityUnknownPanel;
|
||||
IBOutlet id usernamePanel;
|
||||
IBOutlet id usernamePanelCheck;
|
||||
IBOutlet id usernamePanelText;
|
||||
|
@ -90,4 +92,8 @@
|
|||
- (BOOL)prompt:(NSWindow*)parent title:(NSString*)title text:(NSString*)text promptText:(NSMutableString*)promptText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
- (BOOL)promptUserNameAndPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text userNameText:(NSMutableString*)userNameText passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
- (BOOL)promptPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
|
||||
- (BOOL)badCert:(NSWindow*)parent;
|
||||
- (int)unknownCert:(NSWindow*)parent;
|
||||
|
||||
@end
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#import "nsAlertController.h"
|
||||
#import "nsCocoaBrowserService.h"
|
||||
|
||||
#include "nsIBadCertListener.h"
|
||||
|
||||
@implementation nsAlertController
|
||||
|
||||
- (IBAction)hitButton1:(id)sender
|
||||
|
@ -240,4 +242,22 @@
|
|||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)badCert:(NSWindow*)parent
|
||||
{
|
||||
int result = [NSApp runModalForWindow:securityMismatchPanel relativeToWindow:parent];
|
||||
[securityMismatchPanel close];
|
||||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
- (int)unknownCert:(NSWindow*)parent
|
||||
{
|
||||
int result = [NSApp runModalForWindow:securityUnknownPanel relativeToWindow:parent];
|
||||
[securityUnknownPanel close];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -40,12 +40,18 @@
|
|||
|
||||
#import "nsAlertController.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWindowCreator.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIBadCertListener.h"
|
||||
#include "nsISecurityWarningDialogs.h"
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
class nsCocoaBrowserService : public nsIWindowCreator,
|
||||
public nsIPromptService,
|
||||
public nsIFactory
|
||||
public nsIFactory,
|
||||
public nsIBadCertListener, public nsISecurityWarningDialogs, public nsINSSDialogs
|
||||
{
|
||||
public:
|
||||
nsCocoaBrowserService();
|
||||
|
@ -55,7 +61,10 @@ public:
|
|||
NS_DECL_NSIWINDOWCREATOR
|
||||
NS_DECL_NSIPROMPTSERVICE
|
||||
NS_DECL_NSIFACTORY
|
||||
|
||||
NS_DECL_NSINSSDIALOGS
|
||||
NS_DECL_NSIBADCERTLISTENER
|
||||
NS_DECL_NSISECURITYWARNINGDIALOGS
|
||||
|
||||
static nsresult InitEmbedding();
|
||||
static void TermEmbedding();
|
||||
static void BrowserClosed();
|
||||
|
@ -67,6 +76,13 @@ public:
|
|||
static PRUint32 sNumBrowsers;
|
||||
|
||||
private:
|
||||
|
||||
nsresult AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
|
||||
const PRUnichar *messageName,
|
||||
const PRUnichar *showAgainName);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> mSecurityStringBundle;
|
||||
|
||||
static nsCocoaBrowserService* sSingleton;
|
||||
static nsAlertController* sController;
|
||||
static PRBool sCanTerminate;
|
||||
|
|
|
@ -45,6 +45,17 @@
|
|||
#include "CHBrowserView.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
|
||||
// {0ffd3880-7a1a-11d6-a384-975d1d5f86fc}
|
||||
#define NS_BADCERTHANDLER_CID \
|
||||
{0x0ffd3880, 0x7a1a, 0x11d6,{0xa3, 0x84, 0x97, 0x5d, 0x1d, 0x5f, 0x86, 0xfc}}
|
||||
|
||||
nsAlertController* nsCocoaBrowserService::sController = nsnull;
|
||||
nsCocoaBrowserService* nsCocoaBrowserService::sSingleton = nsnull;
|
||||
|
@ -61,10 +72,11 @@ nsCocoaBrowserService::~nsCocoaBrowserService()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsCocoaBrowserService,
|
||||
NS_IMPL_ISUPPORTS6(nsCocoaBrowserService,
|
||||
nsIWindowCreator,
|
||||
nsIPromptService,
|
||||
nsIFactory)
|
||||
nsIFactory,
|
||||
nsIBadCertListener, nsISecurityWarningDialogs, nsINSSDialogs)
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::InitEmbedding()
|
||||
|
@ -75,34 +87,37 @@ nsCocoaBrowserService::InitEmbedding()
|
|||
return NS_OK;
|
||||
|
||||
sSingleton = new nsCocoaBrowserService();
|
||||
if (!sSingleton) {
|
||||
if (!sSingleton)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(sSingleton);
|
||||
|
||||
nsCOMPtr<nsIComponentRegistrar> cr;
|
||||
NS_GetComponentRegistrar(getter_AddRefs(cr));
|
||||
if ( !cr )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Register as the prompt service
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
|
||||
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
|
||||
|
||||
nsresult rv = nsComponentManager::RegisterFactory(kPromptServiceCID,
|
||||
"Prompt Service",
|
||||
"@mozilla.org/embedcomp/prompt-service;1",
|
||||
sSingleton,
|
||||
PR_TRUE); // replace existing
|
||||
if (NS_FAILED(rv)) {
|
||||
nsresult rv = cr->RegisterFactory(kPromptServiceCID, "Prompt Service", "@mozilla.org/embedcomp/prompt-service;1",
|
||||
sSingleton);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Register as the window creator
|
||||
nsCOMPtr<nsIWindowWatcher> watcher(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (!watcher) {
|
||||
if (!watcher)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
watcher->SetWindowCreator(sSingleton);
|
||||
|
||||
return NS_OK;
|
||||
// replace gecko's cert dialogs with our own implementation that doesn't use XUL. We rely
|
||||
// on our own dialogs in the alert nib and use the alert controller to display them.
|
||||
static NS_DEFINE_CID(kBadCertHandlerCID, NS_BADCERTHANDLER_CID);
|
||||
rv = cr->RegisterFactory(kBadCertHandlerCID, "Bad Cert Handler", NS_NSSDIALOGS_CONTRACTID,
|
||||
sSingleton);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -506,3 +521,188 @@ nsCocoaBrowserService::CreateChromeWindow(nsIWebBrowserChrome *parent,
|
|||
return browserChrome->CreateChromeWindow(parent, chromeFlags, _retval);
|
||||
}
|
||||
|
||||
|
||||
/* boolean unknownIssuer (in nsITransportSecurityInfo socketInfo,
|
||||
in nsIX509Cert cert, out addType); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
|
||||
nsIX509Cert *cert, PRInt16 *outAddType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
*outAddType = ADD_TRUSTED_FOR_SESSION;
|
||||
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*outAddType = (PRBool)[controller unknownCert:[NSApp mainWindow]];
|
||||
switch ( *outAddType ) {
|
||||
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
||||
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
default:
|
||||
*_retval = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean mismatchDomain (in nsITransportSecurityInfo socketInfo,
|
||||
in wstring targetURL,
|
||||
in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::MismatchDomain(nsITransportSecurityInfo *socketInfo,
|
||||
const PRUnichar *targetURL,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* boolean certExpired (in nsITransportSecurityInfo socketInfo,
|
||||
in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::CertExpired(nsITransportSecurityInfo *socketInfo,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::CrlNextupdate(nsITransportSecurityInfo *socketInfo,
|
||||
const PRUnichar * targetURL, nsIX509Cert *cert)
|
||||
{
|
||||
// what does this do!?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#define ENTER_SITE_PREF "security.warn_entering_secure"
|
||||
#define WEAK_SITE_PREF "security.warn_entering_weak"
|
||||
#define LEAVE_SITE_PREF "security.warn_leaving_secure"
|
||||
#define MIXEDCONTENT_PREF "security.warn_viewing_mixed"
|
||||
#define INSECURE_SUBMIT_PREF "security.warn_submit_insecure"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertEnteringSecure(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
// I don't think any user cares they're entering a secure site.
|
||||
#if 0
|
||||
rv = AlertDialog(ctx, ENTER_SITE_PREF,
|
||||
NS_LITERAL_STRING("EnterSecureMessage").get(),
|
||||
NS_LITERAL_STRING("EnterSecureShowAgain").get());
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertEnteringWeak(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, WEAK_SITE_PREF,
|
||||
NS_LITERAL_STRING("WeakSecureMessage").get(),
|
||||
NS_LITERAL_STRING("WeakSecureShowAgain").get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertLeavingSecure(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, LEAVE_SITE_PREF,
|
||||
NS_LITERAL_STRING("LeaveSecureMessage").get(),
|
||||
NS_LITERAL_STRING("LeaveSecureShowAgain").get());
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertMixedMode(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, MIXEDCONTENT_PREF,
|
||||
NS_LITERAL_STRING("MixedContentMessage").get(),
|
||||
NS_LITERAL_STRING("MixedContentShowAgain").get());
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
|
||||
const PRUnichar *dialogMessageName,
|
||||
const PRUnichar *showAgainName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get user's preference for this alert
|
||||
PRBool prefValue = PR_TRUE;
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if ( pref )
|
||||
pref->GetBoolPref(prefName, &prefValue);
|
||||
|
||||
// Stop if alert is not requested
|
||||
if (!prefValue) return NS_OK;
|
||||
|
||||
if (!mSecurityStringBundle) {
|
||||
#define STRING_BUNDLE_URL "chrome://communicator/locale/security.properties"
|
||||
nsCOMPtr<nsIStringBundleService> service = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
if ( service )
|
||||
rv = service->CreateBundle(STRING_BUNDLE_URL, getter_AddRefs(mSecurityStringBundle));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Get Prompt to use
|
||||
nsCOMPtr<nsIPrompt> prompt = do_GetInterface(ctx);
|
||||
if (!prompt) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get messages strings from localization file
|
||||
nsXPIDLString windowTitle, message, dontShowAgain;
|
||||
|
||||
mSecurityStringBundle->GetStringFromName(NS_LITERAL_STRING("Title").get(), getter_Copies(windowTitle));
|
||||
mSecurityStringBundle->GetStringFromName(dialogMessageName, getter_Copies(message));
|
||||
mSecurityStringBundle->GetStringFromName(showAgainName, getter_Copies(dontShowAgain));
|
||||
if (!windowTitle || !message || !dontShowAgain) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = prompt->AlertCheck(windowTitle, message, dontShowAgain, &prefValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!prefValue)
|
||||
pref->SetBoolPref(prefName, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::ConfirmPostToInsecure(nsIInterfaceRequestor *ctx, PRBool* _result)
|
||||
{
|
||||
// no user cares about this. the first thing they do is turn it off.
|
||||
*_result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx, PRBool* _result)
|
||||
{
|
||||
// users may care about this one, but we haven't yet implemented ConfirmEx().
|
||||
*_result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Двоичный файл не отображается.
|
@ -273,7 +273,7 @@
|
|||
buildSettings = {
|
||||
DEBUGGING_SYMBOLS = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/rdf ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/docshell ../dist/include/profile ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/xpcom";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/intl ../dist/include/pipboot ../dist/include/pipnss ../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/rdf ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/docshell ../dist/include/profile ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/xpcom";
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LIBRARY_SEARCH_PATHS = "../dist/bin ../dist/lib ../intl/unicharutil/util ../modules/zlib/src";
|
||||
OPTIMIZATION_CFLAGS = "-O2";
|
||||
|
|
Двоичный файл не отображается.
|
@ -32,6 +32,8 @@
|
|||
promptPanelCheck = id;
|
||||
promptPanelInput = id;
|
||||
promptPanelText = id;
|
||||
securityMismatchPanel = id;
|
||||
securityUnknownPanel = id;
|
||||
usernamePanel = id;
|
||||
usernamePanelCheck = id;
|
||||
usernamePanelPassword = id;
|
||||
|
|
|
@ -6,17 +6,7 @@
|
|||
<string>44 234 356 301 0 0 1024 746 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>248.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
<integer>69</integer>
|
||||
<integer>124</integer>
|
||||
<integer>53</integer>
|
||||
<integer>59</integer>
|
||||
<integer>103</integer>
|
||||
<integer>157</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q110</string>
|
||||
<string>5S60</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичный файл не отображается.
|
@ -45,7 +45,6 @@
|
|||
#include "nsIPrefBranch.h"
|
||||
#import "CHAboutBox.h"
|
||||
|
||||
|
||||
static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||
|
||||
@implementation MainController
|
||||
|
@ -94,7 +93,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"];
|
||||
|
||||
}
|
||||
|
||||
-(IBAction)newWindow:(id)aSender
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
promptPanelCheck = id;
|
||||
promptPanelInput = id;
|
||||
promptPanelText = id;
|
||||
securityMismatchPanel = id;
|
||||
securityUnknownPanel = id;
|
||||
usernamePanel = id;
|
||||
usernamePanelCheck = id;
|
||||
usernamePanelPassword = id;
|
||||
|
|
|
@ -6,17 +6,7 @@
|
|||
<string>44 234 356 301 0 0 1024 746 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>248.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
<integer>69</integer>
|
||||
<integer>124</integer>
|
||||
<integer>53</integer>
|
||||
<integer>59</integer>
|
||||
<integer>103</integer>
|
||||
<integer>157</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q110</string>
|
||||
<string>5S60</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичный файл не отображается.
|
@ -62,7 +62,9 @@
|
|||
IBOutlet id passwordPanel;
|
||||
IBOutlet id passwordPanelCheck;
|
||||
IBOutlet id passwordPanelText;
|
||||
IBOutlet id passwordPanelInput;
|
||||
IBOutlet id passwordPanelInput;
|
||||
IBOutlet id securityMismatchPanel;
|
||||
IBOutlet id securityUnknownPanel;
|
||||
IBOutlet id usernamePanel;
|
||||
IBOutlet id usernamePanelCheck;
|
||||
IBOutlet id usernamePanelText;
|
||||
|
@ -90,4 +92,8 @@
|
|||
- (BOOL)prompt:(NSWindow*)parent title:(NSString*)title text:(NSString*)text promptText:(NSMutableString*)promptText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
- (BOOL)promptUserNameAndPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text userNameText:(NSMutableString*)userNameText passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
- (BOOL)promptPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
|
||||
- (BOOL)badCert:(NSWindow*)parent;
|
||||
- (int)unknownCert:(NSWindow*)parent;
|
||||
|
||||
@end
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#import "nsAlertController.h"
|
||||
#import "nsCocoaBrowserService.h"
|
||||
|
||||
#include "nsIBadCertListener.h"
|
||||
|
||||
@implementation nsAlertController
|
||||
|
||||
- (IBAction)hitButton1:(id)sender
|
||||
|
@ -240,4 +242,22 @@
|
|||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)badCert:(NSWindow*)parent
|
||||
{
|
||||
int result = [NSApp runModalForWindow:securityMismatchPanel relativeToWindow:parent];
|
||||
[securityMismatchPanel close];
|
||||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
- (int)unknownCert:(NSWindow*)parent
|
||||
{
|
||||
int result = [NSApp runModalForWindow:securityUnknownPanel relativeToWindow:parent];
|
||||
[securityUnknownPanel close];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -40,12 +40,18 @@
|
|||
|
||||
#import "nsAlertController.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWindowCreator.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIBadCertListener.h"
|
||||
#include "nsISecurityWarningDialogs.h"
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
class nsCocoaBrowserService : public nsIWindowCreator,
|
||||
public nsIPromptService,
|
||||
public nsIFactory
|
||||
public nsIFactory,
|
||||
public nsIBadCertListener, public nsISecurityWarningDialogs, public nsINSSDialogs
|
||||
{
|
||||
public:
|
||||
nsCocoaBrowserService();
|
||||
|
@ -55,7 +61,10 @@ public:
|
|||
NS_DECL_NSIWINDOWCREATOR
|
||||
NS_DECL_NSIPROMPTSERVICE
|
||||
NS_DECL_NSIFACTORY
|
||||
|
||||
NS_DECL_NSINSSDIALOGS
|
||||
NS_DECL_NSIBADCERTLISTENER
|
||||
NS_DECL_NSISECURITYWARNINGDIALOGS
|
||||
|
||||
static nsresult InitEmbedding();
|
||||
static void TermEmbedding();
|
||||
static void BrowserClosed();
|
||||
|
@ -67,6 +76,13 @@ public:
|
|||
static PRUint32 sNumBrowsers;
|
||||
|
||||
private:
|
||||
|
||||
nsresult AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
|
||||
const PRUnichar *messageName,
|
||||
const PRUnichar *showAgainName);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> mSecurityStringBundle;
|
||||
|
||||
static nsCocoaBrowserService* sSingleton;
|
||||
static nsAlertController* sController;
|
||||
static PRBool sCanTerminate;
|
||||
|
|
|
@ -45,6 +45,17 @@
|
|||
#include "CHBrowserView.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
|
||||
// {0ffd3880-7a1a-11d6-a384-975d1d5f86fc}
|
||||
#define NS_BADCERTHANDLER_CID \
|
||||
{0x0ffd3880, 0x7a1a, 0x11d6,{0xa3, 0x84, 0x97, 0x5d, 0x1d, 0x5f, 0x86, 0xfc}}
|
||||
|
||||
nsAlertController* nsCocoaBrowserService::sController = nsnull;
|
||||
nsCocoaBrowserService* nsCocoaBrowserService::sSingleton = nsnull;
|
||||
|
@ -61,10 +72,11 @@ nsCocoaBrowserService::~nsCocoaBrowserService()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsCocoaBrowserService,
|
||||
NS_IMPL_ISUPPORTS6(nsCocoaBrowserService,
|
||||
nsIWindowCreator,
|
||||
nsIPromptService,
|
||||
nsIFactory)
|
||||
nsIFactory,
|
||||
nsIBadCertListener, nsISecurityWarningDialogs, nsINSSDialogs)
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::InitEmbedding()
|
||||
|
@ -75,34 +87,37 @@ nsCocoaBrowserService::InitEmbedding()
|
|||
return NS_OK;
|
||||
|
||||
sSingleton = new nsCocoaBrowserService();
|
||||
if (!sSingleton) {
|
||||
if (!sSingleton)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(sSingleton);
|
||||
|
||||
nsCOMPtr<nsIComponentRegistrar> cr;
|
||||
NS_GetComponentRegistrar(getter_AddRefs(cr));
|
||||
if ( !cr )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Register as the prompt service
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
|
||||
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
|
||||
|
||||
nsresult rv = nsComponentManager::RegisterFactory(kPromptServiceCID,
|
||||
"Prompt Service",
|
||||
"@mozilla.org/embedcomp/prompt-service;1",
|
||||
sSingleton,
|
||||
PR_TRUE); // replace existing
|
||||
if (NS_FAILED(rv)) {
|
||||
nsresult rv = cr->RegisterFactory(kPromptServiceCID, "Prompt Service", "@mozilla.org/embedcomp/prompt-service;1",
|
||||
sSingleton);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Register as the window creator
|
||||
nsCOMPtr<nsIWindowWatcher> watcher(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (!watcher) {
|
||||
if (!watcher)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
watcher->SetWindowCreator(sSingleton);
|
||||
|
||||
return NS_OK;
|
||||
// replace gecko's cert dialogs with our own implementation that doesn't use XUL. We rely
|
||||
// on our own dialogs in the alert nib and use the alert controller to display them.
|
||||
static NS_DEFINE_CID(kBadCertHandlerCID, NS_BADCERTHANDLER_CID);
|
||||
rv = cr->RegisterFactory(kBadCertHandlerCID, "Bad Cert Handler", NS_NSSDIALOGS_CONTRACTID,
|
||||
sSingleton);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -506,3 +521,188 @@ nsCocoaBrowserService::CreateChromeWindow(nsIWebBrowserChrome *parent,
|
|||
return browserChrome->CreateChromeWindow(parent, chromeFlags, _retval);
|
||||
}
|
||||
|
||||
|
||||
/* boolean unknownIssuer (in nsITransportSecurityInfo socketInfo,
|
||||
in nsIX509Cert cert, out addType); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
|
||||
nsIX509Cert *cert, PRInt16 *outAddType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
*outAddType = ADD_TRUSTED_FOR_SESSION;
|
||||
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*outAddType = (PRBool)[controller unknownCert:[NSApp mainWindow]];
|
||||
switch ( *outAddType ) {
|
||||
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
||||
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
default:
|
||||
*_retval = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean mismatchDomain (in nsITransportSecurityInfo socketInfo,
|
||||
in wstring targetURL,
|
||||
in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::MismatchDomain(nsITransportSecurityInfo *socketInfo,
|
||||
const PRUnichar *targetURL,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* boolean certExpired (in nsITransportSecurityInfo socketInfo,
|
||||
in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::CertExpired(nsITransportSecurityInfo *socketInfo,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::CrlNextupdate(nsITransportSecurityInfo *socketInfo,
|
||||
const PRUnichar * targetURL, nsIX509Cert *cert)
|
||||
{
|
||||
// what does this do!?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#define ENTER_SITE_PREF "security.warn_entering_secure"
|
||||
#define WEAK_SITE_PREF "security.warn_entering_weak"
|
||||
#define LEAVE_SITE_PREF "security.warn_leaving_secure"
|
||||
#define MIXEDCONTENT_PREF "security.warn_viewing_mixed"
|
||||
#define INSECURE_SUBMIT_PREF "security.warn_submit_insecure"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertEnteringSecure(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
// I don't think any user cares they're entering a secure site.
|
||||
#if 0
|
||||
rv = AlertDialog(ctx, ENTER_SITE_PREF,
|
||||
NS_LITERAL_STRING("EnterSecureMessage").get(),
|
||||
NS_LITERAL_STRING("EnterSecureShowAgain").get());
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertEnteringWeak(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, WEAK_SITE_PREF,
|
||||
NS_LITERAL_STRING("WeakSecureMessage").get(),
|
||||
NS_LITERAL_STRING("WeakSecureShowAgain").get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertLeavingSecure(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, LEAVE_SITE_PREF,
|
||||
NS_LITERAL_STRING("LeaveSecureMessage").get(),
|
||||
NS_LITERAL_STRING("LeaveSecureShowAgain").get());
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertMixedMode(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, MIXEDCONTENT_PREF,
|
||||
NS_LITERAL_STRING("MixedContentMessage").get(),
|
||||
NS_LITERAL_STRING("MixedContentShowAgain").get());
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
|
||||
const PRUnichar *dialogMessageName,
|
||||
const PRUnichar *showAgainName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get user's preference for this alert
|
||||
PRBool prefValue = PR_TRUE;
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if ( pref )
|
||||
pref->GetBoolPref(prefName, &prefValue);
|
||||
|
||||
// Stop if alert is not requested
|
||||
if (!prefValue) return NS_OK;
|
||||
|
||||
if (!mSecurityStringBundle) {
|
||||
#define STRING_BUNDLE_URL "chrome://communicator/locale/security.properties"
|
||||
nsCOMPtr<nsIStringBundleService> service = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
if ( service )
|
||||
rv = service->CreateBundle(STRING_BUNDLE_URL, getter_AddRefs(mSecurityStringBundle));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Get Prompt to use
|
||||
nsCOMPtr<nsIPrompt> prompt = do_GetInterface(ctx);
|
||||
if (!prompt) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get messages strings from localization file
|
||||
nsXPIDLString windowTitle, message, dontShowAgain;
|
||||
|
||||
mSecurityStringBundle->GetStringFromName(NS_LITERAL_STRING("Title").get(), getter_Copies(windowTitle));
|
||||
mSecurityStringBundle->GetStringFromName(dialogMessageName, getter_Copies(message));
|
||||
mSecurityStringBundle->GetStringFromName(showAgainName, getter_Copies(dontShowAgain));
|
||||
if (!windowTitle || !message || !dontShowAgain) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = prompt->AlertCheck(windowTitle, message, dontShowAgain, &prefValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!prefValue)
|
||||
pref->SetBoolPref(prefName, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::ConfirmPostToInsecure(nsIInterfaceRequestor *ctx, PRBool* _result)
|
||||
{
|
||||
// no user cares about this. the first thing they do is turn it off.
|
||||
*_result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx, PRBool* _result)
|
||||
{
|
||||
// users may care about this one, but we haven't yet implemented ConfirmEx().
|
||||
*_result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@
|
|||
buildSettings = {
|
||||
DEBUGGING_SYMBOLS = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/rdf ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/docshell ../dist/include/profile ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/xpcom";
|
||||
HEADER_SEARCH_PATHS = "../dist/include/intl ../dist/include/pipboot ../dist/include/pipnss ../dist/include/webbrwsr ../dist/include/dom ../dist/include/nspr ../dist/include/string ../dist/include/rdf ../dist/include/necko ../dist/include/find ../dist/include/embed_base ../dist/include/windowwatcher ../dist/include/webshell ../dist/include/widget ../dist/include/uriloader ../dist/include/docshell ../dist/include/profile ../dist/include/layout ../dist/include/content ../dist/include/webbrowserpersist ../dist/include/pref ../dist/include/mimetype ../dist/include/shistory ../dist/include/view ../dist/include/gfx ../dist/include/xultmpl ../dist/include/xmlextras ../dist/include/htmlparser ../dist/include/locale ../dist/include/unicharutil ../dist/include/appcomps ../dist/include/xpcom";
|
||||
INSTALL_PATH = "$(HOME)/Applications";
|
||||
LIBRARY_SEARCH_PATHS = "../dist/bin ../dist/lib ../intl/unicharutil/util ../modules/zlib/src";
|
||||
OPTIMIZATION_CFLAGS = "-O2";
|
||||
|
|
Двоичные данные
chimera/resources/localized/English.lproj/BrowserWindow.nib/objects.nib
сгенерированный
Двоичные данные
chimera/resources/localized/English.lproj/BrowserWindow.nib/objects.nib
сгенерированный
Двоичный файл не отображается.
|
@ -32,6 +32,8 @@
|
|||
promptPanelCheck = id;
|
||||
promptPanelInput = id;
|
||||
promptPanelText = id;
|
||||
securityMismatchPanel = id;
|
||||
securityUnknownPanel = id;
|
||||
usernamePanel = id;
|
||||
usernamePanelCheck = id;
|
||||
usernamePanelPassword = id;
|
||||
|
|
|
@ -6,17 +6,7 @@
|
|||
<string>44 234 356 301 0 0 1024 746 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>248.0</string>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>10</integer>
|
||||
<integer>69</integer>
|
||||
<integer>124</integer>
|
||||
<integer>53</integer>
|
||||
<integer>59</integer>
|
||||
<integer>103</integer>
|
||||
<integer>157</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>5Q110</string>
|
||||
<string>5S60</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичный файл не отображается.
|
@ -45,7 +45,6 @@
|
|||
#include "nsIPrefBranch.h"
|
||||
#import "CHAboutBox.h"
|
||||
|
||||
|
||||
static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
||||
|
||||
@implementation MainController
|
||||
|
@ -94,7 +93,6 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
|
|||
// offline.
|
||||
if (mOffline)
|
||||
[mOfflineMenuItem setTitle: @"Go Online"];
|
||||
|
||||
}
|
||||
|
||||
-(IBAction)newWindow:(id)aSender
|
||||
|
|
|
@ -62,7 +62,9 @@
|
|||
IBOutlet id passwordPanel;
|
||||
IBOutlet id passwordPanelCheck;
|
||||
IBOutlet id passwordPanelText;
|
||||
IBOutlet id passwordPanelInput;
|
||||
IBOutlet id passwordPanelInput;
|
||||
IBOutlet id securityMismatchPanel;
|
||||
IBOutlet id securityUnknownPanel;
|
||||
IBOutlet id usernamePanel;
|
||||
IBOutlet id usernamePanelCheck;
|
||||
IBOutlet id usernamePanelText;
|
||||
|
@ -90,4 +92,8 @@
|
|||
- (BOOL)prompt:(NSWindow*)parent title:(NSString*)title text:(NSString*)text promptText:(NSMutableString*)promptText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
- (BOOL)promptUserNameAndPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text userNameText:(NSMutableString*)userNameText passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
- (BOOL)promptPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text passwordText:(NSMutableString*)passwordText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck;
|
||||
|
||||
- (BOOL)badCert:(NSWindow*)parent;
|
||||
- (int)unknownCert:(NSWindow*)parent;
|
||||
|
||||
@end
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
#import "nsAlertController.h"
|
||||
#import "nsCocoaBrowserService.h"
|
||||
|
||||
#include "nsIBadCertListener.h"
|
||||
|
||||
@implementation nsAlertController
|
||||
|
||||
- (IBAction)hitButton1:(id)sender
|
||||
|
@ -240,4 +242,22 @@
|
|||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)badCert:(NSWindow*)parent
|
||||
{
|
||||
int result = [NSApp runModalForWindow:securityMismatchPanel relativeToWindow:parent];
|
||||
[securityMismatchPanel close];
|
||||
|
||||
return (result == 1);
|
||||
}
|
||||
|
||||
- (int)unknownCert:(NSWindow*)parent
|
||||
{
|
||||
int result = [NSApp runModalForWindow:securityUnknownPanel relativeToWindow:parent];
|
||||
[securityUnknownPanel close];
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -40,12 +40,18 @@
|
|||
|
||||
#import "nsAlertController.h"
|
||||
#include "nsEmbedAPI.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIWindowCreator.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIBadCertListener.h"
|
||||
#include "nsISecurityWarningDialogs.h"
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
class nsCocoaBrowserService : public nsIWindowCreator,
|
||||
public nsIPromptService,
|
||||
public nsIFactory
|
||||
public nsIFactory,
|
||||
public nsIBadCertListener, public nsISecurityWarningDialogs, public nsINSSDialogs
|
||||
{
|
||||
public:
|
||||
nsCocoaBrowserService();
|
||||
|
@ -55,7 +61,10 @@ public:
|
|||
NS_DECL_NSIWINDOWCREATOR
|
||||
NS_DECL_NSIPROMPTSERVICE
|
||||
NS_DECL_NSIFACTORY
|
||||
|
||||
NS_DECL_NSINSSDIALOGS
|
||||
NS_DECL_NSIBADCERTLISTENER
|
||||
NS_DECL_NSISECURITYWARNINGDIALOGS
|
||||
|
||||
static nsresult InitEmbedding();
|
||||
static void TermEmbedding();
|
||||
static void BrowserClosed();
|
||||
|
@ -67,6 +76,13 @@ public:
|
|||
static PRUint32 sNumBrowsers;
|
||||
|
||||
private:
|
||||
|
||||
nsresult AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
|
||||
const PRUnichar *messageName,
|
||||
const PRUnichar *showAgainName);
|
||||
|
||||
nsCOMPtr<nsIStringBundle> mSecurityStringBundle;
|
||||
|
||||
static nsCocoaBrowserService* sSingleton;
|
||||
static nsAlertController* sController;
|
||||
static PRBool sCanTerminate;
|
||||
|
|
|
@ -45,6 +45,17 @@
|
|||
#include "CHBrowserView.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIPrompt.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
||||
#include "nsINSSDialogs.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIComponentRegistrar.h"
|
||||
|
||||
// {0ffd3880-7a1a-11d6-a384-975d1d5f86fc}
|
||||
#define NS_BADCERTHANDLER_CID \
|
||||
{0x0ffd3880, 0x7a1a, 0x11d6,{0xa3, 0x84, 0x97, 0x5d, 0x1d, 0x5f, 0x86, 0xfc}}
|
||||
|
||||
nsAlertController* nsCocoaBrowserService::sController = nsnull;
|
||||
nsCocoaBrowserService* nsCocoaBrowserService::sSingleton = nsnull;
|
||||
|
@ -61,10 +72,11 @@ nsCocoaBrowserService::~nsCocoaBrowserService()
|
|||
{
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS3(nsCocoaBrowserService,
|
||||
NS_IMPL_ISUPPORTS6(nsCocoaBrowserService,
|
||||
nsIWindowCreator,
|
||||
nsIPromptService,
|
||||
nsIFactory)
|
||||
nsIFactory,
|
||||
nsIBadCertListener, nsISecurityWarningDialogs, nsINSSDialogs)
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::InitEmbedding()
|
||||
|
@ -75,34 +87,37 @@ nsCocoaBrowserService::InitEmbedding()
|
|||
return NS_OK;
|
||||
|
||||
sSingleton = new nsCocoaBrowserService();
|
||||
if (!sSingleton) {
|
||||
if (!sSingleton)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ADDREF(sSingleton);
|
||||
|
||||
nsCOMPtr<nsIComponentRegistrar> cr;
|
||||
NS_GetComponentRegistrar(getter_AddRefs(cr));
|
||||
if ( !cr )
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// Register as the prompt service
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
#define NS_PROMPTSERVICE_CID \
|
||||
{0xa2112d6a, 0x0e28, 0x421f, {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}}
|
||||
static NS_DEFINE_CID(kPromptServiceCID, NS_PROMPTSERVICE_CID);
|
||||
|
||||
nsresult rv = nsComponentManager::RegisterFactory(kPromptServiceCID,
|
||||
"Prompt Service",
|
||||
"@mozilla.org/embedcomp/prompt-service;1",
|
||||
sSingleton,
|
||||
PR_TRUE); // replace existing
|
||||
if (NS_FAILED(rv)) {
|
||||
nsresult rv = cr->RegisterFactory(kPromptServiceCID, "Prompt Service", "@mozilla.org/embedcomp/prompt-service;1",
|
||||
sSingleton);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
}
|
||||
|
||||
// Register as the window creator
|
||||
nsCOMPtr<nsIWindowWatcher> watcher(do_GetService("@mozilla.org/embedcomp/window-watcher;1"));
|
||||
if (!watcher) {
|
||||
if (!watcher)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
watcher->SetWindowCreator(sSingleton);
|
||||
|
||||
return NS_OK;
|
||||
// replace gecko's cert dialogs with our own implementation that doesn't use XUL. We rely
|
||||
// on our own dialogs in the alert nib and use the alert controller to display them.
|
||||
static NS_DEFINE_CID(kBadCertHandlerCID, NS_BADCERTHANDLER_CID);
|
||||
rv = cr->RegisterFactory(kBadCertHandlerCID, "Bad Cert Handler", NS_NSSDIALOGS_CONTRACTID,
|
||||
sSingleton);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -506,3 +521,188 @@ nsCocoaBrowserService::CreateChromeWindow(nsIWebBrowserChrome *parent,
|
|||
return browserChrome->CreateChromeWindow(parent, chromeFlags, _retval);
|
||||
}
|
||||
|
||||
|
||||
/* boolean unknownIssuer (in nsITransportSecurityInfo socketInfo,
|
||||
in nsIX509Cert cert, out addType); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::UnknownIssuer(nsITransportSecurityInfo *socketInfo,
|
||||
nsIX509Cert *cert, PRInt16 *outAddType,
|
||||
PRBool *_retval)
|
||||
{
|
||||
*_retval = PR_TRUE;
|
||||
*outAddType = ADD_TRUSTED_FOR_SESSION;
|
||||
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*outAddType = (PRBool)[controller unknownCert:[NSApp mainWindow]];
|
||||
switch ( *outAddType ) {
|
||||
case nsIBadCertListener::ADD_TRUSTED_FOR_SESSION:
|
||||
case nsIBadCertListener::ADD_TRUSTED_PERMANENTLY:
|
||||
*_retval = PR_TRUE;
|
||||
break;
|
||||
default:
|
||||
*_retval = PR_FALSE;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* boolean mismatchDomain (in nsITransportSecurityInfo socketInfo,
|
||||
in wstring targetURL,
|
||||
in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::MismatchDomain(nsITransportSecurityInfo *socketInfo,
|
||||
const PRUnichar *targetURL,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
/* boolean certExpired (in nsITransportSecurityInfo socketInfo,
|
||||
in nsIX509Cert cert); */
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::CertExpired(nsITransportSecurityInfo *socketInfo,
|
||||
nsIX509Cert *cert, PRBool *_retval)
|
||||
{
|
||||
nsAlertController* controller = GetAlertController();
|
||||
if (!controller)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// HACK: there is no way to get which window this is for from the API. The
|
||||
// security team in mozilla just cheats and assumes the frontmost window so
|
||||
// that's what we'll do. Yes, it's wrong. Yes, it's skanky. Oh well.
|
||||
*_retval = (PRBool)[controller badCert:[NSApp mainWindow]];
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::CrlNextupdate(nsITransportSecurityInfo *socketInfo,
|
||||
const PRUnichar * targetURL, nsIX509Cert *cert)
|
||||
{
|
||||
// what does this do!?
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
#define ENTER_SITE_PREF "security.warn_entering_secure"
|
||||
#define WEAK_SITE_PREF "security.warn_entering_weak"
|
||||
#define LEAVE_SITE_PREF "security.warn_leaving_secure"
|
||||
#define MIXEDCONTENT_PREF "security.warn_viewing_mixed"
|
||||
#define INSECURE_SUBMIT_PREF "security.warn_submit_insecure"
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertEnteringSecure(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
// I don't think any user cares they're entering a secure site.
|
||||
#if 0
|
||||
rv = AlertDialog(ctx, ENTER_SITE_PREF,
|
||||
NS_LITERAL_STRING("EnterSecureMessage").get(),
|
||||
NS_LITERAL_STRING("EnterSecureShowAgain").get());
|
||||
#endif
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertEnteringWeak(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, WEAK_SITE_PREF,
|
||||
NS_LITERAL_STRING("WeakSecureMessage").get(),
|
||||
NS_LITERAL_STRING("WeakSecureShowAgain").get());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertLeavingSecure(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, LEAVE_SITE_PREF,
|
||||
NS_LITERAL_STRING("LeaveSecureMessage").get(),
|
||||
NS_LITERAL_STRING("LeaveSecureShowAgain").get());
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaBrowserService::AlertMixedMode(nsIInterfaceRequestor *ctx)
|
||||
{
|
||||
return AlertDialog(ctx, MIXEDCONTENT_PREF,
|
||||
NS_LITERAL_STRING("MixedContentMessage").get(),
|
||||
NS_LITERAL_STRING("MixedContentShowAgain").get());
|
||||
}
|
||||
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::AlertDialog(nsIInterfaceRequestor *ctx, const char *prefName,
|
||||
const PRUnichar *dialogMessageName,
|
||||
const PRUnichar *showAgainName)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// Get user's preference for this alert
|
||||
PRBool prefValue = PR_TRUE;
|
||||
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
|
||||
if ( pref )
|
||||
pref->GetBoolPref(prefName, &prefValue);
|
||||
|
||||
// Stop if alert is not requested
|
||||
if (!prefValue) return NS_OK;
|
||||
|
||||
if (!mSecurityStringBundle) {
|
||||
#define STRING_BUNDLE_URL "chrome://communicator/locale/security.properties"
|
||||
nsCOMPtr<nsIStringBundleService> service = do_GetService(NS_STRINGBUNDLE_CONTRACTID);
|
||||
if ( service )
|
||||
rv = service->CreateBundle(STRING_BUNDLE_URL, getter_AddRefs(mSecurityStringBundle));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
// Get Prompt to use
|
||||
nsCOMPtr<nsIPrompt> prompt = do_GetInterface(ctx);
|
||||
if (!prompt) return NS_ERROR_FAILURE;
|
||||
|
||||
// Get messages strings from localization file
|
||||
nsXPIDLString windowTitle, message, dontShowAgain;
|
||||
|
||||
mSecurityStringBundle->GetStringFromName(NS_LITERAL_STRING("Title").get(), getter_Copies(windowTitle));
|
||||
mSecurityStringBundle->GetStringFromName(dialogMessageName, getter_Copies(message));
|
||||
mSecurityStringBundle->GetStringFromName(showAgainName, getter_Copies(dontShowAgain));
|
||||
if (!windowTitle || !message || !dontShowAgain) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = prompt->AlertCheck(windowTitle, message, dontShowAgain, &prefValue);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
if (!prefValue)
|
||||
pref->SetBoolPref(prefName, PR_FALSE);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::ConfirmPostToInsecure(nsIInterfaceRequestor *ctx, PRBool* _result)
|
||||
{
|
||||
// no user cares about this. the first thing they do is turn it off.
|
||||
*_result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsCocoaBrowserService::ConfirmPostToInsecureFromSecure(nsIInterfaceRequestor *ctx, PRBool* _result)
|
||||
{
|
||||
// users may care about this one, but we haven't yet implemented ConfirmEx().
|
||||
*_result = PR_TRUE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче