Landing changes from CHIMERA_M1_0_1_BRANCH. (I know I'm breaking the static build, I'll fix it later). Code depending on other Mozilla changes is #ifdef'd BRANCH_CHANGES_NEED_MERGED.

This commit is contained in:
bryner%netscape.com 2003-02-13 10:26:09 +00:00
Родитель dcb73f7dcd
Коммит 513721f882
88 изменённых файлов: 3976 добавлений и 1732 удалений

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -9,7 +9,7 @@
#include "nsIPermission.h"
#include "nsISupportsArray.h"
#include "nsXPIDLString.h"
#include "nsString.h"
// prefs for keychain password autofill
static const char* const gUseKeychainPref = "chimera.store_passwords_with_keychain";
@ -199,7 +199,7 @@ const int kDisableAllCookies = 2;
if ( perm ) {
nsXPIDLCString host;
perm->GetHost(getter_Copies(host));
mManager->Remove(nsDependentCString(host), 0); // could this api _be_ any worse? Come on!
mManager->Remove(host, 0); // could this api _be_ any worse? Come on!
mCachedPermissions->RemoveElementAt(row);
}

Просмотреть файл

@ -2,7 +2,7 @@
\readonlydoc1{\fonttbl\f0\fswiss\fcharset77 Optima-Bold;\f1\fswiss\fcharset77 Optima-Regular;\f2\fswiss\fcharset77 Helvetica;
\f3\fnil\fcharset77 Monaco;}
{\colortbl;\red255\green255\blue255;\red4\green16\blue255;}
\margl1440\margr1440\vieww13740\viewh16200\viewkind0
\margl1440\margr1440\vieww13940\viewh15220\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f0\b\fs48 \cf0 Chimera Read Me\
@ -71,4 +71,7 @@ To find out more about Chimera, see the project page at:\
\
\cf2 http://www.mozilla.org/projects/chimera/\cf0 \
\
This page contains information about how to give feedback on Chimera, has links that allow you to query for known bugs, see what\'d5s going on with current development, and about how to build it yourself from source.}
This page contains information about how to give feedback on Chimera, has links that allow you to query for known bugs, see what\'d5s going on with current development, and about how to build it yourself from source.\
\
There is also a Unix browser project called Chimera, which is unrelated to Chimera for OS X. More information about the Unix/X11 Chimera browser can be found at \cf2 http://www.chimera.org/\cf0 \
}

Просмотреть файл

@ -0,0 +1,139 @@
{\rtf1\mac\ansicpg10000\cocoartf102
{\fonttbl\f0\fswiss\fcharset77 Optima-Bold;\f1\fswiss\fcharset77 Optima-Regular;\f2\fswiss\fcharset77 Optima-Italic;
\f3\fnil\fcharset77 Monaco;}
{\colortbl;\red255\green255\blue255;\red4\green16\blue255;}
\margl1440\margr1440\vieww13340\viewh16360\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f0\b\fs48 \cf0 Chimera 0.7 Release Notes\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f1\b0\fs24 \cf2 http://www.mozilla.org/projects/chimera/\cf0 \
\
\pard\tx720\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640
\cf0 The following changes and improvements have been made since the Chimera 0.6 release. \
\pard\tx360\tx720\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\ql\qnatural
\cf0 \
\f0\b Highlights
\f1\b0 \
\
\'a5 New Download Manager, with auto-download and auto-dispatch.\
\'a5 Compatible with URL Manager Pro\
\'a5 Page Text Encodings menu\
\'a5 Global History in the sidebar\
\'a5 Send Link menu item, and other new toolbar buttons\
\'a5 Dragging of images and links to the desktop, and other applications\
\'a5 Support for Shockwave Directory content\
\'a5 Uses Rendezvous to show local FTP and web servers\
\'a5 Supports Proxy Auto-config\
\
\f0\b Details\
\f1\b0 \
\f2\i User Interface
\f1\i0 \
\
\'a5 Chimera now has a Text Encoding submenu, allowing you to override the character set of a page when it doesn't display correctly.\
\'a5 Chimera now supports the Menu Sharing protocol, allowing applications like URL Manager Pro to work.\
\'a5 Popup windows no longer do an ugly resize-flash when they appear.\
\'a5 If you type something in the URL bar before Chimera finishes loading the first page, it will no longer get replaced by the page URL.\
\'a5 Global history is now visible in the sidebar (and is much faster than before).\
\'a5 Redesigned content-generated dialogs (like cookie and JavaScript dialogs) to autosize. JS dialogs are identified by a \'d4[JavaScript Application]\'d5 label to avoid spoofing attacks now.\
\
\f2\i Menus and Toolbars
\f1\i0 \
\
\'a5 New, brighter toolbar icons.\
\'a5 Added a \'d2Send Link\'d3 command to the File menu (with an optional toolbar button), which opens a mail message with the URL of the current page in your favorite mail application.\
\'a5 Added additional optional toolbar buttons for New Tab, Close Tab, Search etc.\
\'a5 Added some new items to the context menus, relating to frames, and copying images.\
\'a5 Added support for copying images to the clipboard, and dragging images and links to the desktop, and to other applications.\
\'a5 Fixed an issue that would cause the wrong window to be used for loading a bookmark, or URL sometimes.\
\'a5 The \'d2small icons\'d3 toolbar mode is shorter now to save screen space.\
\
\f2\i Downloading
\f1\i0 \
\
\'a5 Downloads are now shown in a Download manager, reducing the number of open windows.\
\'a5 If you quit while downloads are in progress, Chimera will warn you now.\
\'a5 Downloads now start automatically, saving into your Downloads folder, without asking you where to save the file. Option-click a link if you want to specify a different location at which save the file.\
\'a5 Added a preference (in the Downloads tab of the Navigation pane) to automatically dispatch downloaded files to helper applications. For security reasons, this defaults to being off.\
\
\f2\i Plugins
\f1\i0 \
\
\'a5 Shockwave Director content now loads in Chimera.\
\'a5 The Default plugin (which displays when you're missing the plugin for some content) correctly remembers which MIME type you've seen before now.\
\'a5 Context menus for plugins now display correctly, RealPlayer video displays more reliably, and plugins are less likely to draw incorrectly when being scrolled.\
\'a5 The QuickTime plugin now correctly handles more MIME types now.\
\'a5 Fixed various MRJ (Java) plugin issues (but not, as yet, the problem of typing and dragging in applets).\
\
\f2\i Web Page display
\f1\i0 \
\
\'a5 The default resolution was set to 96dpi, to better match other Mac browsers. You may have to adjust your preferred font sizes to compensate.\
\'a5 The User-Agent string now contains \'d3Mach-O\'d3 and \'d2Chimera\'d3 to allow web authors to more accurately identify the browser.\
\'a5 Framesets loaded in background tabs show correctly now\
\'a5 Typing performance in textareas was somewhat improved.\
\'a5 Tabbing to a text field now selects its content.\
\'a5 If JavaScript on a page calls
\f3\fs18 window.close()
\f1\fs24 , we now close just the tab for that page, if there are multiple tabs.\
\'a5 Form controls no longer draw in \'d3bold\'d3\
\'a5 Pages loading in background tabs now show errors if the load fails, as they should.\
\'a5 Chimera now respects the \'d2autocomplete=off\'d3 attribute on web forms, for sites that don't want username/password filling for security reasons.\
\'a5 Fixed an issue with the sizing of form controls when zooming.\
\'a5 Fixed some "smearing" display problems with absolutely-positioned elements.\
\'a5 If you need to see JavaScript errors, you can set a hidden pref ("chimera.log_js_to_console") to have Chimera dump them to the console.\
\
\f2\i Bookmarks
\f1\i0 \
\
\'a5 Command-clicking a toolbar link, or a bookmark in the sidebar will load it in a new tab now.\
\'a5 You can put a bookmark folder in the Dock menu now (do a Get Info on a bookmark folder in Chimera). Mac OS X 10.2 only.\
\'a5 It's now possible to convert a bookmarks tab group to a normal folder, and vice versa (via a checkbox in the bookmark Get Info panel).\
\'a5 You can import Chimera-format bookmarks.xml files.\
\'a5 It's now possible to export bookmarks to an HTML file now (via an item on the application menu)\
\'a5 Site icons (\'d2favicons\'d3) are shown on the bookmarks toolbar now.\
\
\f2\i Networking
\f1\i0 \
\
\'a5 Chimera will now pick up changes made to the system proxy settings (e.g. when you change Locations in the Network System Preferences) without having to be restarted.\
\'a5 Chimera will only show \'d2Connection Refused\'d3 and \'d2Unknown host\'d3 errors for the main page now, rather than images and iframe contents. This helps those using proxy techniques for image blocking.\
\
\f2\i Other Changes
\f1\i0 \
\
\'a5 The Print dialog now has a \'d2Web Browser\'d3 panel that allows you to control the printing of background colors and images, among other options.\
\'a5 Chimera now supports the Services menu in web content.\
\'a5 You can get the URL of the front window via AppleEvents now.\
\'a5 Holding down the Shift key while using the scrollwheel scrolls sideways now.\
\'a5 Fixed an issue with QuickDraw that caused a number of random crashes.\
\'a5 Chimera will now run if your home directory is on a network volume.\
\'a5 Some memory leaks were fixed.\
\'a5 Added the ability to set the preferred minimum font size, in the Advanced panel of the Appearance font prefs.\
\'a5 Fixed an issue where Chimera could use a lot of CPU when waking from sleep.\
\'a5 Chimera is more compatible with the \'d2Metallizer\'d3 haxie now.\
\
\f2\i Known issues
\f1\i0 \
\
\'a5 Shockwave Director content displays at the wrong location in the window, if hardware rendering is enabled.\
\'a5 Typing and dragging in Java applets does not work correctly.\
\'a5 The Windows Media Player plugin is not compatible with Chimera.\
\'a5 If you try to open Chimera's AppleScript dictionary, say from Script Editor, you\'d5ll get an error. To work around this, open the application package, and remove the \'d2Localized.rsrc\'d3 file in Contents/Resources/English.lproj. This will, however, prevent Shockwave Director content from loading so we recommend you do this on a copy of the application.\
\'a5 Issues remain when typing in non-Roman languages; sometimes hitting the Delete key can cause Chimera to go Back, rather than deleting text.\
\
}

Просмотреть файл

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Contains mappings of character encodings (lowercase) to menu item tags in the Text Encoding menu. -->
<plist version="1.0">
<dict>
<key>iso-8859-1</key>
<integer>10</integer>
<key>x-mac-roman</key>
<integer>11</integer>
<key>iso-2022-jp</key>
<integer>12</integer>
<key>shift_jis</key>
<integer>13</integer>
<key>euc-jp</key>
<integer>14</integer>
<key>big5</key>
<integer>15</integer>
<key>big5-hkscs</key>
<integer>16</integer>
<key>iso-2022-kr</key>
<integer>17</integer>
<key>x-johab</key>
<integer>18</integer>
<key>x-windows-949</key>
<integer>19</integer>
<key>iso-8859-6</key>
<integer>20</integer>
<key>windows-1256</key>
<integer>21</integer>
<key>iso-8859-8</key>
<integer>22</integer>
<key>windows-1255</key>
<integer>23</integer>
<key>iso-8859-7</key>
<integer>24</integer>
<key>windows-1253</key>
<integer>25</integer>
<key>iso-8859-5</key>
<integer>26</integer>
<key>x-mac-cyrillic</key>
<integer>27</integer>
<key>koi8-r</key>
<integer>28</integer>
<key>windows-1251</key>
<integer>29</integer>
<key>tis-620</key>
<integer>30</integer>
<key>gb2312</key>
<integer>31</integer>
<key>x-gbk</key>
<integer>32</integer>
<key>hz-gb-2312</key>
<integer>33</integer>
<key>iso-8859-2</key>
<integer>34</integer>
<key>windows-1250</key>
<integer>35</integer>
<key>iso-8859-4</key>
<integer>36</integer>
<key>windows-1258</key>
<integer>37</integer>
<key>iso-8859-9</key>
<integer>38</integer>
<key>windows-1254</key>
<integer>39</integer>
<key>windows-1257</key>
<integer>40</integer>
<key>utf-8</key>
<integer>41</integer>
</dict>
</plist>

Просмотреть файл

@ -28,7 +28,7 @@
<string>140 644 198 144 0 0 1152 848 </string>
</dict>
<key>IBFramework Version</key>
<string>286.0</string>
<string>291.0</string>
<key>IBGroupedObjects</key>
<dict>
<key>7</key>

Двоичные данные
camino/resources/localized/English.lproj/BrowserWindow.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -41,6 +41,7 @@
pageSetup = id;
previousTab = id;
printPage = id;
reloadWithCharset = id;
savePage = id;
sendURL = id;
showAboutBox = id;

Просмотреть файл

@ -3,18 +3,18 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>105 33 482 372 0 0 1600 1002 </string>
<string>37 174 482 240 0 0 1152 848 </string>
<key>IBEditorPositions</key>
<dict>
<key>266</key>
<string>644 623 277 90 0 0 1600 1002 </string>
<key>29</key>
<string>11 957 446 44 0 0 1600 1002 </string>
<string>103 790 446 44 0 0 1152 848 </string>
<key>494</key>
<string>117 597 185 48 0 0 1280 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>286.0</string>
<string>291.0</string>
<key>IBGroupedObjects</key>
<dict>
<key>0</key>

Двоичные данные
camino/resources/localized/English.lproj/MainMenu.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

@ -86,15 +86,15 @@ nsDownloadListenerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult
static const nsModuleComponentInfo gAppComponents[] = {
{
"Security Dialogs",
"PSM Security Warnings",
NS_SECURITYDIALOGS_CID,
NS_BADCERTLISTENER_CONTRACTID,
NS_SECURITYWARNINGDIALOGS_CONTRACTID,
SecurityDialogsConstructor
},
{
"Security Dialogs",
"Bad Cert Handler",
NS_SECURITYDIALOGS_CID,
NS_SECURITYWARNINGDIALOGS_CONTRACTID,
NS_BADCERTLISTENER_CONTRACTID,
SecurityDialogsConstructor
},
{

Просмотреть файл

@ -89,6 +89,8 @@
SharedMenusObj* mSharedMenusObj;
NetworkServices* mNetworkServices;
NSMutableDictionary* mCharsets;
}
// File menu actions.
@ -127,6 +129,7 @@
-(IBAction) smallerTextSize:(id)aSender;
-(IBAction) viewSource:(id)aSender;
-(IBAction) manageSidebar: (id)aSender;
-(IBAction) reloadWithCharset:(id)aSender;
// Bookmarks menu actions.
-(IBAction) importBookmarks:(id)aSender;

Просмотреть файл

@ -150,6 +150,8 @@ const int kReuseWindowOnAE = 2;
-(void)dealloc
{
[mCharsets release];
// Terminate shared menus
[mSharedMenusObj release];
@ -256,6 +258,10 @@ const int kReuseWindowOnAE = 2;
while ((itemIndex = [mGoMenu indexOfItemWithTag:kRendezvousRelatedItemTag]) != -1)
[mGoMenu removeItemAtIndex:itemIndex];
}
// load up the charset dictionary with keys and menu titles.
NSString* charsetPath = [NSBundle pathForResource:@"Charset" ofType:@"dict" inDirectory:[[NSBundle mainBundle] bundlePath]];
mCharsets = [[NSDictionary dictionaryWithContentsOfFile:charsetPath] retain];
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
@ -305,6 +311,9 @@ const int kReuseWindowOnAE = 2;
- (void)setupStartpage
{
// only do this if no url was specified in the command-line
if (mStartURL) return;
// for non-nightly builds, show a special start page
PreferenceManager* prefManager = [PreferenceManager sharedInstance];
@ -535,6 +544,18 @@ const int kReuseWindowOnAE = 2;
[browserController reload: aSender];
}
-(IBAction) reloadWithCharset:(id)aSender
{
// Figure out which charset to tell gecko to load based on the sender's tag. There
// is guaranteed to only be 1 key that matches this tag, so we just take the first one.
BrowserWindowController* browserController = [self getMainWindowBrowserController];
if (browserController) {
NSArray* charsetList = [mCharsets allKeysForObject:[NSNumber numberWithInt:[aSender tag]]];
NS_ASSERTION([charsetList count] == 1, "OOPS, multiply defined charsets in plist");
[browserController reloadWithNewCharset:[charsetList objectAtIndex:0]];
}
}
-(IBAction) doStop:(id)aSender
{
BrowserWindowController* browserController = [self getMainWindowBrowserController];
@ -918,11 +939,34 @@ const int kReuseWindowOnAE = 2;
{
BrowserWindowController* browserController = [self getMainWindowBrowserController];
// Handle the encoding menu first, since there are many of those items. They're
// identifyable because they have a specific tag.
const int kEncodingMenuTag = 10;
if ( [aMenuItem tag] >= kEncodingMenuTag ) {
if ( browserController ) {
NSString* charset = [browserController currentCharset];
#if DEBUG_CHARSET
NSLog(@"charset is %@", charset);
#endif
// given the document's charset, check if it maps to the same int as the
// current item's key. If yes, we select this item because it's our charset.
// Note that this relies on the key in the nib mapping to the right integer
// in the plist.
NSNumber* tag = [mCharsets objectForKey:[charset lowercaseString]];
if ( tag && [[NSNumber numberWithInt:[aMenuItem tag]] isEqualToNumber:tag] )
[aMenuItem setState:NSOnState];
else
[aMenuItem setState:NSOffState];
return YES;
}
return NO;
}
// disable items that aren't relevant if there's no main browser window open
SEL action = [aMenuItem action];
//NSLog(@"MainController validateMenuItem for %@ (%s)", [aMenuItem title], action);
if (action == @selector(printPage:) ||
/* ... many more items go here ... */
/* action == @selector(goHome:) || */ // always enabled
@ -1103,17 +1147,16 @@ const int kReuseWindowOnAE = 2;
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApp hasVisibleWindows:(BOOL)flag
{
// If AppKit knows what to do, let it.
if (flag)
return YES;
// If window available, wake it up. |mainWindow| should always be null.
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow)
// ignore |hasVisibleWindows| because we always want to show a browser window when
// the user clicks on the app icon, even if, say, prefs or the d/l window are open.
// If there is no browser, create one. If there is one, bring it to the front and
// unminimize it if it's down in the dock.
NSWindow* frontBrowser = [self getFrontmostBrowserWindow];
if ( !frontBrowser )
[self newWindow:self];
else { // Don't think this will ever happen, but just in case
if ([[mainWindow windowController]respondsToSelector:@selector(showWindow:)])
[[mainWindow windowController] showWindow:self];
else {
if ([[frontBrowser windowController] respondsToSelector:@selector(showWindow:)])
[[frontBrowser windowController] showWindow:self];
else
[self newWindow:self];
}

Просмотреть файл

@ -47,9 +47,20 @@ NSGETMODULE(_name) (nsIComponentManager* aCompMgr, \
}
// NSGetModule entry points
DECL_NSGETMODULE(UcharUtil)
DECL_NSGETMODULE(nsUConvModule)
DECL_NSGETMODULE(nsI18nModule)
DECL_NSGETMODULE(nsUCvJAModule)
DECL_NSGETMODULE(nsUCvCnModule)
DECL_NSGETMODULE(nsUCvLatinModule)
DECL_NSGETMODULE(nsUCvTWModule)
DECL_NSGETMODULE(nsUCvTW2Module)
DECL_NSGETMODULE(nsUCvKoModule)
DECL_NSGETMODULE(nsLocaleModule)
DECL_NSGETMODULE(nsStringBundleModule)
DECL_NSGETMODULE(nsLWBrkModule)
DECL_NSGETMODULE(nsCharDetModule)
DECL_NSGETMODULE(xpconnect)
DECL_NSGETMODULE(cacheservice)
DECL_NSGETMODULE(necko_core_and_primary_protocols)
DECL_NSGETMODULE(necko_secondary_protocols)
DECL_NSGETMODULE(nsURILoaderModule)
@ -60,9 +71,14 @@ DECL_NSGETMODULE(nsChromeModule)
DECL_NSGETMODULE(nsRDFModule)
DECL_NSGETMODULE(nsParserModule)
DECL_NSGETMODULE(nsGfxMacModule)
DECL_NSGETMODULE(nsGfx2Module)
DECL_NSGETMODULE(nsImageLib2Module)
DECL_NSGETMODULE(nsPNGDecoderModule)
DECL_NSGETMODULE(nsGIFModule2)
DECL_NSGETMODULE(nsJPEGDecoderModule)
DECL_NSGETMODULE(nsPluginModule)
DECL_NSGETMODULE(javascript__protocol)
DECL_NSGETMODULE(JS_component_loader)
DECL_NSGETMODULE(DOM_components)
DECL_NSGETMODULE(nsViewModule)
DECL_NSGETMODULE(nsWidgetMacModule)
@ -74,6 +90,7 @@ DECL_NSGETMODULE(embedcomponents)
DECL_NSGETMODULE(Browser_Embedding_Module)
DECL_NSGETMODULE(nsEditorModule)
DECL_NSGETMODULE(nsTransactionManagerModule)
DECL_NSGETMODULE(nsTextServicesModule)
DECL_NSGETMODULE(nsProfileModule)
DECL_NSGETMODULE(Session_History_Module)
DECL_NSGETMODULE(application)
@ -89,9 +106,20 @@ DECL_NSGETMODULE(NSS)
*/
static nsStaticModuleInfo gStaticModuleInfo[] = {
#define MODULE(_name) { (#_name), NSGETMODULE(_name) }
MODULE(UcharUtil),
MODULE(nsUConvModule),
MODULE(nsI18nModule),
MODULE(nsUCvJAModule),
MODULE(nsUCvCnModule),
MODULE(nsUCvLatinModule),
MODULE(nsUCvTWModule),
MODULE(nsUCvTW2Module),
MODULE(nsUCvKoModule),
MODULE(nsLocaleModule),
MODULE(nsStringBundleModule),
MODULE(nsLWBrkModule),
MODULE(nsCharDetModule),
MODULE(xpconnect),
MODULE(cacheservice),
MODULE(necko_core_and_primary_protocols),
MODULE(necko_secondary_protocols),
MODULE(nsURILoaderModule),
@ -102,9 +130,14 @@ MODULE(nsChromeModule),
MODULE(nsRDFModule),
MODULE(nsParserModule),
MODULE(nsGfxMacModule),
MODULE(nsGfx2Module),
MODULE(nsImageLib2Module),
MODULE(nsPNGDecoderModule),
MODULE(nsGIFModule2),
MODULE(nsJPEGDecoderModule),
MODULE(nsPluginModule),
MODULE(javascript__protocol),
MODULE(JS_component_loader),
MODULE(DOM_components),
MODULE(nsViewModule),
MODULE(nsWidgetMacModule),
@ -116,6 +149,7 @@ MODULE(embedcomponents),
MODULE(Browser_Embedding_Module),
MODULE(nsEditorModule),
MODULE(nsTransactionManagerModule),
MODULE(nsTextServicesModule),
MODULE(nsProfileModule),
MODULE(Session_History_Module),
MODULE(application),

Просмотреть файл

@ -41,6 +41,7 @@
#define BookmarksExport_h__
#include "nsString.h"
#include "nsIDOMDocument.h"
#include "nsIOutputStream.h"
#include "nsCOMPtr.h"

Просмотреть файл

@ -47,11 +47,12 @@
#include "nsILocalFile.h"
#include "nsILocalFileMac.h"
#include "nsIOutputStream.h"
#include "nsIAtom.h"
#include "nsNetUtil.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIContent.h"
#include "nsIAtom.h"
/*
Netscape HTML bookmarks format is:

Просмотреть файл

@ -658,11 +658,10 @@ BookmarksService::SaveBookmarksToFile(const nsAString& inFileName)
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), bookmarksTempFile);
if (NS_FAILED(rv)) return rv;
PRUint32 bytesWritten = 0;
if (writeDocType)
{
const char* const kDocTypeString = "<!DOCTYPE bookmarks SYSTEM \"http://www.mozilla.org/DTDs/ChimeraBookmarks.dtd\">\n";
PRUint32 bytesWritten = 0;
rv = outputStream->Write(kDocTypeString, strlen(kDocTypeString), &bytesWritten);
if (NS_FAILED(rv)) return rv;
}

Просмотреть файл

@ -81,13 +81,14 @@
- (void) closePopup;
- (void) resizePopup;
- (BOOL) isOpen;
- (BOOL) userHasTyped;
- (void) onRowClicked:(NSNotification *)aNote;
- (void) onBlur:(NSNotification *)aNote;
- (void) onResize:(NSNotification *)aNote;
- (void) onUndoOrRedo:(NSNotification *)aNote;
- (void) setStringUndoably:(NSString*)aString fromLocation:(unsigned int)aLocation;
- (void) setURI:(NSString*)aURI;
- (id) fieldEditor;
@end

Просмотреть файл

@ -54,7 +54,6 @@ class AutoCompleteListener : public nsIAutoCompleteListener
public:
AutoCompleteListener(AutoCompleteTextField* aTextField)
{
NS_INIT_ISUPPORTS();
mTextField = aTextField;
}
@ -79,6 +78,7 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
////////////////////////////////////////////////////////////////////////
@interface AutoCompleteTextField(Private)
- (void)cleanup;
- (void) setStringUndoably:(NSString*)aString fromLocation:(unsigned int)aLocation;
@end
@implementation AutoCompleteTextField
@ -372,6 +372,18 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
return [mPopupWin isVisible];
}
//
// -userHasTyped
//
// Returns whether the user has typed anything into the url bar since the last
// time the url was set (by loading a page). We know this is the case by looking
// at if there is a search string.
//
- (BOOL) userHasTyped
{
return ( mSearchString != nil );
}
// url completion ////////////////////////////
- (void) completeDefaultResult
@ -447,6 +459,25 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
}
}
//
// -setURI
//
// the public way to change the url string so that it does the right thing for handling
// autocomplete and completions in progress
//
- (void) setURI:(NSString*)aURI
{
// if the urlbar has focus (actually if its field editor has focus), we
// need to use one of its routines to update the autocomplete status or
// we could find ourselves with stale results and the popup still open. If
// it doesn't have focus, we can bypass all that and just use normal routines.
if ( [[self window] firstResponder] == [self fieldEditor] )
[self setStringUndoably:aURI fromLocation:0]; // updates autocomplete correctly
else
[self setStringValue:aURI];
}
- (void) setStringUndoably:(NSString *)aString fromLocation:(unsigned int)aLocation
{
NSTextView *fieldEditor = [self fieldEditor];
@ -554,16 +585,23 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
- (void)controlTextDidChange:(NSNotification *)aNote
{
NSTextView *fieldEditor = [[aNote userInfo] objectForKey:@"NSFieldEditor"];
// we are here either because the user is typing or they are selecting
// an item in the autocomplete popup. When they are typing, the location of
// the selection will be non-zero (wherever the insertion point is). When
// they autocomplete, the length and the location will both be zero.
// We use this info in the following way: if they are typing or backspacing,
// restart the search and no longer use the selection in the popup.
NSRange range = [fieldEditor selectedRange];
// make sure we're typing at the end of the string
if (range.location == [[fieldEditor string] length]) {
NSString* currentText = [fieldEditor string];
if ([currentText length] && range.location) {
// when we ask for a NSTextView string, Cocoa returns
// a pointer to the view's backing store. So, the value
// of the string continually changes as we edit the text view.
// Since we'll edit the text view as we add in autocomplete results,
// we've got to make a copy of the string as it currently stands
// to know what we were searching for in the first place.
NSString *searchString = [[fieldEditor string] copyWithZone:nil];
NSString *searchString = [currentText copyWithZone:nil];
[self startSearch:searchString complete:!mBackspaced];
[searchString release];
}
@ -575,7 +613,7 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
- (void)controlTextDidEndEditing:(NSNotification *)aNote
{
[self closePopup];
[self clearResults];
[[[[aNote userInfo] objectForKey:@"NSFieldEditor"] undoManager] removeAllActions];
}

Просмотреть файл

@ -130,6 +130,12 @@
- (void)removeTabViewItem:(NSTabViewItem *)tabViewItem
{
// the normal behavior of the tab widget is to select the tab to the left
// of the tab being removed. Users, however, want the tab to the right to
// be selected. This also matches how mozilla works. Select the right tab
// first so we don't take the hit of displaying the left tab before we switch.
if ( [self selectedTabViewItem] == tabViewItem )
[self selectNextTabViewItem:self];
[super removeTabViewItem:tabViewItem];
[self showOrHideTabsAsAppropriate];
}

Просмотреть файл

@ -93,6 +93,7 @@ typedef enum
@class PageProxyIcon;
@class BrowserContentView;
@class BrowserTabViewItem;
@class AutoCompleteTextField;
@interface BrowserWindowController : NSWindowController<Find>
{
@ -101,7 +102,7 @@ typedef enum
IBOutlet NSTabView* mSidebarTabView;
IBOutlet NSTabView* mSidebarSourceTabView;
IBOutlet NSView* mLocationToolbarView;
IBOutlet NSTextField* mURLBar;
IBOutlet AutoCompleteTextField* mURLBar;
IBOutlet NSTextField* mStatus;
IBOutlet NSProgressIndicator* mProgress; // STRONG reference
IBOutlet NSImageView* mLock;
@ -258,6 +259,9 @@ typedef enum
- (IBAction)stop:(id)aSender;
- (IBAction)home:(id)aSender;
- (IBAction)reloadWithNewCharset:(NSString*)charset;
- (NSString*)currentCharset;
- (IBAction)frameToNewWindow:(id)sender;
- (IBAction)frameToNewTab:(id)sender;
- (IBAction)frameToThisWindow:(id)sender;

Просмотреть файл

@ -47,6 +47,7 @@
#import "BrowserTabView.h"
#import "UserDefaults.h"
#import "PageProxyIcon.h"
#import "AutoCompleteTextField.h"
#include "nsIWebNavigation.h"
#include "nsIDOMDocument.h"
@ -1316,16 +1317,9 @@ static NSArray* sToolbarDefaults = nil;
- (void)updateLocationFields:(NSString *)locationString
{
if ( [locationString isEqual:@"about:blank"] )
locationString = @"";
locationString = @""; // return;
// if the urlbar has focus (actually if its field editor has focus), we
// need to use one of its routines to update the autocomplete status or
// we could find ourselves with stale results and the popup still open. If
// it doesn't have focus, we can bypass all that and just use normal routines.
if ( [[self window] firstResponder] == [mURLBar fieldEditor] )
[mURLBar setStringUndoably:locationString fromLocation:0]; // updates autocomplete correctly
else
[mURLBar setStringValue:locationString];
[mURLBar setURI:locationString];
[mLocationSheetURLField setStringValue:locationString];
// don't call [window display] here, no matter how much you might want
@ -1619,10 +1613,13 @@ static NSArray* sToolbarDefaults = nil;
[newTab setLabel: NSLocalizedString(@"TabLoading", @"")];
[newView loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone activate:!aLoadInBG];
// unless we're told to load this tab in the bg, select the tab
// before we load so that it's the primary and will push the url into
// the url bar immediately rather than waiting for the server.
if (!aLoadInBG)
[mTabBrowser selectTabViewItem: newTab];
[newView loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone activate:!aLoadInBG];
}
- (void)openTabGroup:(NSArray*)urlArray replaceExistingTabs:(BOOL)replaceExisting
@ -1815,8 +1812,11 @@ static NSArray* sToolbarDefaults = nil;
{
menuPrototype = mImageMenu;
}
else if ((mContextMenuFlags & nsIContextMenuListener::CONTEXT_DOCUMENT) != 0)
else if (!mContextMenuFlags || (mContextMenuFlags & nsIContextMenuListener::CONTEXT_DOCUMENT) != 0)
{
// if there aren't any flags or we're in the background of a page,
// show the document menu. This prevents us from failing to find a case
// and not showing the context menu.
menuPrototype = mPageMenu;
[mBackItem setEnabled: [[mBrowserView getBrowserView] canGoBack]];
[mForwardItem setEnabled: [[mBrowserView getBrowserView] canGoForward]];
@ -2056,7 +2056,7 @@ static NSArray* sToolbarDefaults = nil;
BOOL oldResponderIsGecko = [self isResponderGeckoView:oldResponder];
BOOL newResponderIsGecko = [self isResponderGeckoView:newResponder];
if (oldResponderIsGecko != newResponderIsGecko)
if (oldResponderIsGecko != newResponderIsGecko && [[self window] isKeyWindow])
[[mBrowserView getBrowserView] setActive:newResponderIsGecko];
}
@ -2088,6 +2088,18 @@ static NSArray* sToolbarDefaults = nil;
return nil;
}
- (IBAction)reloadWithNewCharset:(NSString*)charset
{
[mBrowserView reloadWithNewCharset:charset];
}
- (NSString*)currentCharset
{
return [mBrowserView currentCharset];
}
@end
#pragma mark -

Просмотреть файл

@ -40,10 +40,11 @@
@class BrowserWindowController;
@class ToolTip;
@class AutoCompleteTextField;
@interface BrowserWrapper : NSView <CHBrowserListener, CHBrowserContainer>
{
NSTextField* mUrlbar;
AutoCompleteTextField* mUrlbar;
NSTextField* mStatus;
BrowserWindowController* mWindowController;
NSTabViewItem* mTabItem;
@ -98,6 +99,9 @@
- (void)setTab: (NSTabViewItem*)tab;
- (NSTabViewItem*) tab;
- (IBAction)reloadWithNewCharset:(NSString*)charset;
- (NSString*)currentCharset;
- (NSWindow*)getNativeWindow;
- (NSMenu*)getContextMenu;
- (void)setIsBookmarksImport:(BOOL)aIsImport;

Просмотреть файл

@ -46,6 +46,7 @@
#import "ToolTip.h"
#import "PageProxyIcon.h"
#import "KeychainService.h"
#import "AutoCompleteTextField.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
@ -64,8 +65,6 @@
#include "nsIPrefService.h"
#include "CHBrowserService.h"
#include "nsIWebProgressListener.h"
#include "nsIFocusController.h"
#include "nsIDOMWindowInternal.h"
#include <QuickDraw.h>
@ -241,7 +240,7 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
// update the window's title.
[self setTabTitle:mTabTitle windowTitle:mTitle];
if ([[self window] isKeyWindow])
if ([[self window] isKeyWindow] && ![mUrlbar userHasTyped])
[mBrowserView setActive: YES];
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
@ -257,9 +256,12 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
name:kOfflineNotificationName
object:nil];
// Update the URL bar.
[mWindowController updateLocationFields:[self getCurrentURLSpec]];
[mWindowController updateSiteIcons:mSiteIconImage];
// Update the URL bar, but only if the user hasn't put something of their
// own in there.
if (![mUrlbar userHasTyped]) {
[mWindowController updateLocationFields:[self getCurrentURLSpec]];
[mWindowController updateSiteIcons:mSiteIconImage];
}
if (mWindowController && !mListenersAttached)
{
@ -309,6 +311,11 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags activate:(BOOL)activate
{
// blast it into the urlbar immediately so that we know what we're
// trying to load, even if it doesn't work
if (mIsPrimary)
[mWindowController updateLocationFields:urlSpec];
mActivateOnLoad = activate;
[mBrowserView loadURI:urlSpec referrer:referrer flags:flags];
}
@ -343,25 +350,14 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
{
if (mActivateOnLoad) {
// if we're the front/key window, focus the content area. If we're not,
// tell the focus controller that the content area should be focused when
// we do finally become the key window
if ( [NSApp keyWindow] == [mBrowserView window] )
[mBrowserView setActive:YES];
else {
nsCOMPtr<nsIDOMWindow> domWindow;
nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([mBrowserView getWebBrowser]);
if ( webBrowser ) {
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
if ( domWindow ) {
nsCOMPtr<nsPIDOMWindow> piWindow ( do_QueryInterface(domWindow) );
nsCOMPtr<nsIFocusController> controller;
piWindow->GetRootFocusController(getter_AddRefs(controller));
if ( controller ) {
nsCOMPtr<nsIDOMWindowInternal> windowInt ( do_QueryInterface(domWindow) );
controller->SetFocusedWindow(windowInt);
}
}
}
// set gecko as the first responder so that it will be activated when
// the window is focused. If the user is typing in the urlBar, however,
// don't mess with the focus at all.
if ( ![mUrlbar userHasTyped] ) {
if ( [[mBrowserView window] isKeyWindow] )
[mBrowserView setActive:YES];
else
[[mBrowserView window] makeFirstResponder:mBrowserView];
}
mActivateOnLoad = NO;
}
@ -445,7 +441,8 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
if (!siteIconLoadInitiated)
[self updateSiteIconImage:nil withURI:faviconURI];
if (mIsPrimary)
// if the user has started typing something, don't destroy it
if (mIsPrimary && ![mUrlbar userHasTyped])
[mWindowController updateLocationFields:urlSpec];
}
@ -848,4 +845,16 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
return [[[self getBrowserView] getCurrentURI] isEqualToString:@"about:blank"];
}
- (IBAction)reloadWithNewCharset:(NSString*)charset
{
[[self getBrowserView] reloadWithNewCharset:charset];
}
- (NSString*)currentCharset
{
return [[self getBrowserView] currentCharset];
}
@end

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsIStringBundle.h"
#include "nsIPromptService.h"
#include "nsCOMPtr.h"
#import <Cocoa/Cocoa.h>
class CocoaPromptService : public nsIPromptService

Просмотреть файл

@ -271,7 +271,7 @@ int KeychainPrefChangedCallback(const char* inPref, void* unused)
//
attr.tag = kAccountKCItemAttr;
attr.data = (char*)[username UTF8String];
attr.length = strlen(attr.data);
attr.length = strlen(NS_REINTERPRET_CAST(const char*, attr.data));
status = KCSetAttribute(inItemRef, &attr);
if(status != noErr)
NSLog(@"Couldn't update keychain item account");
@ -522,7 +522,6 @@ NS_IMPL_ISUPPORTS2(KeychainPrompt,
KeychainPrompt::KeychainPrompt()
{
NS_INIT_ISUPPORTS();
}
KeychainPrompt::~KeychainPrompt()
@ -532,14 +531,15 @@ KeychainPrompt::~KeychainPrompt()
//
// TODO: add support for ftp username/password. The given realm for
// an ftp server has the form ftp://<username>@<server>/<path>, see
// netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp.
// TODO: add support for ftp username/password.
//
// Get server name and port from the realm ("hostname:port (realm)",
// see nsHttpChannel.cpp). we can't use CFURL routines or nsIURI
// routines because they require a protocol, and we don't have one.
//
// The given realm for an ftp server has the form ftp://<username>@<server>/<path>, see
// netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp).
//
void
KeychainPrompt::ExtractHostAndPort(const PRUnichar* inRealm, NSString** outHost, PRInt32* outPort)
{
@ -548,20 +548,40 @@ KeychainPrompt::ExtractHostAndPort(const PRUnichar* inRealm, NSString** outHost,
*outHost = @"";
*outPort = kAnyPort;
// strip off the "(realm)" part
NSString* realmStr = [NSString stringWithPRUnichars:inRealm];
NSRange firstParen = [realmStr rangeOfString:@"("];
if ( firstParen.location == NSNotFound )
firstParen.location = [realmStr length];
realmStr = [realmStr substringToIndex:firstParen.location-1];
// separate the host and the port
NSRange endOfHost = [realmStr rangeOfString:@":"];
if ( endOfHost.location == NSNotFound )
*outHost = realmStr;
// first check for an ftp url and pull out the server from the realm
if ( [realmStr rangeOfString:@"ftp://"].location != NSNotFound ) {
// cut out ftp://
realmStr = [realmStr substringFromIndex:strlen("ftp://")];
// cut out any of the path
NSRange pathDelimeter = [realmStr rangeOfString:@"/"];
if ( pathDelimeter.location != NSNotFound )
realmStr = [realmStr substringToIndex:pathDelimeter.location-1];
// now we're left with "username@server" with username being optional
NSRange usernameMarker = [realmStr rangeOfString:@"@"];
if ( usernameMarker.location != NSNotFound )
*outHost = [realmStr substringFromIndex:usernameMarker.location+1];
else
*outHost = realmStr;
}
else {
*outHost = [realmStr substringToIndex:endOfHost.location];
*outPort = [[realmStr substringFromIndex:endOfHost.location+1] intValue];
// we're an http url, strip off the "(realm)" part
NSRange firstParen = [realmStr rangeOfString:@"("];
if ( firstParen.location == NSNotFound )
firstParen.location = [realmStr length];
realmStr = [realmStr substringToIndex:firstParen.location-1];
// separate the host and the port
NSRange endOfHost = [realmStr rangeOfString:@":"];
if ( endOfHost.location == NSNotFound )
*outHost = realmStr;
else {
*outHost = [realmStr substringToIndex:endOfHost.location];
*outPort = [[realmStr substringFromIndex:endOfHost.location+1] intValue];
}
}
}
@ -712,7 +732,6 @@ NS_IMPL_ISUPPORTS2(KeychainFormSubmitObserver,
KeychainFormSubmitObserver::KeychainFormSubmitObserver()
{
NS_INIT_ISUPPORTS();
//NSLog(@"Keychain form submit observer created.");
}
@ -755,7 +774,9 @@ KeychainFormSubmitObserver::Notify(nsIContent* node, nsIDOMWindowInternal* windo
passwordElement->GetValue(pword);
NSString* username = [NSString stringWith_nsAString:uname];
NSString* password = [NSString stringWith_nsAString:pword];
if ( ![username length] || ![password length] ) // bail if either is empty
return NS_OK;
nsCOMPtr<nsIDocument> doc;
node->GetDocument(*getter_AddRefs(doc));
if (!doc)
@ -950,8 +971,16 @@ KeychainFormSubmitObserver::CheckChangeDataYN(nsIDOMWindowInternal* window)
[username assignTo_nsAString:user];
[password assignTo_nsAString:pwd];
rv = usernameElement->SetValue(user);
rv = passwordElement->SetValue(pwd);
// if the server specifies a value attribute (bug 169760), only autofill
// the password if what we have in keychain matches what the server supplies,
// otherwise don't. Don't bother checking the password field for a value; i can't
// imagine the server ever prefilling a password
nsAutoString userValue;
usernameElement->GetAttribute(NS_LITERAL_STRING("value"), userValue);
if (!userValue.Length() || userValue.Equals(user)) {
rv = usernameElement->SetValue(user);
rv = passwordElement->SetValue(pwd);
}
}
// We found the sign-in form so return now. This means we don't
@ -1015,6 +1044,13 @@ FindUsernamePasswordFields(nsIDOMHTMLFormElement* inFormElement, nsIDOMHTMLInput
return NS_ERROR_FAILURE;
*outUsername = *outPassword = nsnull;
// pages can specify that they don't want autofill by setting a
// "autocomplete=off" attribute on the form.
nsAutoString autocomplete;
inFormElement->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
if ( autocomplete.EqualsIgnoreCase("off") )
return NS_OK;
//
// Search the form the password field and the preceding text field
// We are only interested in signon forms, so we require
@ -1056,6 +1092,9 @@ FindUsernamePasswordFields(nsIDOMHTMLFormElement* inFormElement, nsIDOMHTMLInput
bool isText = (type.IsEmpty() || type.Equals(NS_LITERAL_STRING("text"), nsCaseInsensitiveStringComparator()));
bool isPassword = type.Equals(NS_LITERAL_STRING("password"), nsCaseInsensitiveStringComparator());
inputElement->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
if ( autocomplete.EqualsIgnoreCase("off") )
isPassword = false;
if(!isText && !isPassword)
continue;

Просмотреть файл

@ -195,6 +195,7 @@ nsresult RemoteURILoadManager::RequestURILoad(const nsAString& inURI, id<RemoteL
nsLoadFlags loadFlags = (allowNetworking) ? nsIRequest::LOAD_NORMAL : nsIRequest::LOAD_FROM_CACHE;
loadFlags |= nsIRequest::LOAD_BACKGROUND; // don't show progress or cookie dialogs
if (!allowNetworking)
loadFlags |= nsICachingChannel::LOAD_ONLY_FROM_CACHE;
@ -204,7 +205,7 @@ nsresult RemoteURILoadManager::RequestURILoad(const nsAString& inURI, id<RemoteL
rv = NS_NewChannel(getter_AddRefs(channel), uri, nsnull, mLoadGroup,
nsnull, loadFlags);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStreamLoader> streamLoader;
rv = NS_NewStreamLoader(getter_AddRefs(streamLoader), channel, this, loaderContext) ; // , mLoadGroup, nsnull, loadFlags);
if (NS_FAILED(rv))

Просмотреть файл

@ -52,12 +52,12 @@ public:
virtual ~SecurityDialogs();
NS_DECL_ISUPPORTS;
NS_DECL_NSIBADCERTLISTENER
NS_DECL_NSISECURITYWARNINGDIALOGS
NS_DECL_NSIBADCERTLISTENER;
NS_DECL_NSISECURITYWARNINGDIALOGS;
private:
nsresult EnsureSecurityStringBundle();
nsresult AlertDialog(nsIInterfaceRequestor* ctx, const char* prefName,
const PRUnichar* messageName,
const PRUnichar* showAgainName);

Просмотреть файл

@ -57,12 +57,11 @@ SecurityDialogs::~SecurityDialogs()
{
}
NS_IMPL_ISUPPORTS2(SecurityDialogs, nsIBadCertListener, nsISecurityWarningDialogs)
NS_IMPL_ISUPPORTS2(SecurityDialogs, nsIBadCertListener, nsISecurityWarningDialogs);
// nsIBadCertListener implementation
/* boolean confirmUnknownIssuer (in nsIInterfaceRequestor socketInfo,
in nsIX509Cert cert,
out short certAddType); */
in nsIX509Cert cert, out addType); */
NS_IMETHODIMP
SecurityDialogs::ConfirmUnknownIssuer(nsIInterfaceRequestor *socketInfo,
nsIX509Cert *cert, PRInt16 *outAddType,
@ -148,9 +147,11 @@ SecurityDialogs::NotifyCrlNextupdate(nsIInterfaceRequestor *socketInfo,
#define MIXEDCONTENT_PREF "security.warn_viewing_mixed"
#define INSECURE_SUBMIT_PREF "security.warn_submit_insecure"
// XXXbryner should we make these real confirmation dialogs?
NS_IMETHODIMP
SecurityDialogs::ConfirmEnteringSecure(nsIInterfaceRequestor *ctx,
PRBool *canceled)
PRBool *_retval)
{
// I don't think any user cares they're entering a secure site.
#if 0
@ -159,15 +160,15 @@ SecurityDialogs::ConfirmEnteringSecure(nsIInterfaceRequestor *ctx,
NS_LITERAL_STRING("EnterSecureShowAgain").get());
#endif
*canceled = PR_FALSE;
*_retval = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
SecurityDialogs::ConfirmEnteringWeak(nsIInterfaceRequestor *ctx,
PRBool *canceled)
PRBool *_retval)
{
*canceled = PR_FALSE;
*_retval = PR_TRUE;
return AlertDialog(ctx, WEAK_SITE_PREF,
NS_LITERAL_STRING("WeakSecureMessage").get(),
NS_LITERAL_STRING("WeakSecureShowAgain").get());
@ -175,9 +176,9 @@ SecurityDialogs::ConfirmEnteringWeak(nsIInterfaceRequestor *ctx,
NS_IMETHODIMP
SecurityDialogs::ConfirmLeavingSecure(nsIInterfaceRequestor *ctx,
PRBool *canceled)
PRBool *_retval)
{
*canceled = PR_FALSE;
*_retval = PR_TRUE;
return AlertDialog(ctx, LEAVE_SITE_PREF,
NS_LITERAL_STRING("LeaveSecureMessage").get(),
NS_LITERAL_STRING("LeaveSecureShowAgain").get());
@ -185,9 +186,9 @@ SecurityDialogs::ConfirmLeavingSecure(nsIInterfaceRequestor *ctx,
NS_IMETHODIMP
SecurityDialogs::ConfirmMixedMode(nsIInterfaceRequestor *ctx, PRBool *canceled)
SecurityDialogs::ConfirmMixedMode(nsIInterfaceRequestor *ctx, PRBool *_retval)
{
*canceled = PR_FALSE;
*_retval = PR_TRUE;
return AlertDialog(ctx, MIXEDCONTENT_PREF,
NS_LITERAL_STRING("MixedContentMessage").get(),
NS_LITERAL_STRING("MixedContentShowAgain").get());

Просмотреть файл

@ -39,44 +39,13 @@
@interface nsAlertController : NSObject
{
IBOutlet id alertCheckPanel;
IBOutlet id alertCheckPanelCheck;
IBOutlet id alertCheckPanelText;
IBOutlet id alertPanel;
IBOutlet id alertPanelText;
IBOutlet id confirmCheckPanel;
IBOutlet id confirmCheckPanelCheck;
IBOutlet id confirmCheckPanelText;
IBOutlet id confirmCheckPanelButton1;
IBOutlet id confirmCheckPanelButton2;
IBOutlet id confirmPanel;
IBOutlet id confirmPanelText;
IBOutlet id confirmPanelButton1;
IBOutlet id confirmPanelButton2;
IBOutlet id promptPanel;
IBOutlet id promptPanelCheck;
IBOutlet id promptPanelText;
IBOutlet id promptPanelInput;
IBOutlet id passwordPanel;
IBOutlet id passwordPanelCheck;
IBOutlet id passwordPanelText;
IBOutlet id passwordPanelInput;
IBOutlet id postToInsecureFromSecurePanel;
IBOutlet id securityMismatchPanel;
IBOutlet id expiredCertPanel;
IBOutlet id securityUnknownPanel;
IBOutlet id usernamePanel;
IBOutlet id usernamePanelCheck;
IBOutlet id usernamePanelText;
IBOutlet id usernamePanelPassword;
IBOutlet id usernamePanelUserName;
IBOutlet id owner;
// all dialogs are now created on the fly and sized to fit
}
- (IBAction)hitButton1:(id)sender;
- (IBAction)hitButton2:(id)sender;
- (IBAction)hitButton3:(id)sender;
- (void)awakeFromNib;
- (void)alert:(NSWindow*)parent title:(NSString*)title text:(NSString*)text;
- (void)alertCheck:(NSWindow*)parent title:(NSString*)title text:(NSString*)text checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue;

Просмотреть файл

@ -42,6 +42,79 @@
enum { kOKButton = 0, kCancelButton = 1, kOtherButton = 2 };
const int kMinDialogWidth = 500;
const int kMaxDialogHeight = 400;
const int kMinDialogHeight = 130;
const int kIconSize = 64;
const int kWindowBorder = 20;
const int kIconMargin = 16; // space between the icon and text content
const int kButtonMinWidth = 82;
const int kButtonMaxWidth = 200;
const int kButtonHeight = 32;
const int kButtonRightMargin = 14; // space between right edge of button and window
const int kButtonBottomMargin = 12; // space between bottom edge of button and window
const int kGeneralViewSpace = 9; // space between one view and another (vertically)
const int kViewButtonSpace = 16; // space between the bottom view and the buttons
const int kMaxFieldHeight = 100;
const int kCheckBoxWidth = 20;
const int kCheckBoxHeight = 18;
const int kTextFieldHeight = 19;
const int kStaticTextFieldHeight = 14; // height of non-editable non-bordered text fields
const int kFieldLabelSpacer = 4; // space between a static label and an editabe text field (horizontal)
const int kOtherAltButtonSpace = 25; // minimum space between the 'other' and 'alternate' buttons
const int kButtonEndCapWidth = 14;
const int kLabelCheckboxAdjustment = 2; // # pixels the label must be pushed down to line up with checkbox
//
// QDCoordsView
//
// A view that uses the QD coordinate space (top left is (0,0))
//
@interface QDCoordsView : NSView
{
}
@end
@implementation QDCoordsView
- (BOOL) isFlipped
{
return YES;
}
@end
#pragma mark -
@interface nsAlertController (nsAlertControllerPrivateMethods)
- (NSPanel*)getAlertPanelWithTitle:(NSString*)title
message:(NSString*)message
defaultButton:(NSString*)defaultLabel
altButton:(NSString*)altLabel
otherButton:(NSString*)otherLabel
extraView:(NSView*)extraView
lastResponder:(NSView*)lastResponder;
- (NSButton*)makeButtonWithTitle:(NSString*)title;
- (float)getContentWidthWithDefaultButton:(NSString*)defStr alternateButton:(NSString*)altStr otherButton:(NSString*)otherStr;
- (NSTextField*)getTitleView:(NSString*)title withWidth:(float)width;
- (NSTextField*)getLabelView:(NSString*)title withWidth:(float)width;
- (NSView*)getLoginField:(NSTextField**)field withWidth:(float)width;
- (NSView*)getPasswordField:(NSSecureTextField**)field withWidth:(float)width;
- (int)getLoginTextLabelSize;
- (NSView*)getMessageView:(NSString*)message withWidth:(float)width maxHeight:(float)maxHeight smallFont:(BOOL)useSmallFont;
- (NSView*)getCheckboxView:(NSButton**)checkBox withLabel:(NSString*)label andWidth:(float)width;
-(void)tester:(id)sender;
@end
#pragma mark -
@implementation nsAlertController
- (IBAction)hitButton1:(id)sender
@ -59,239 +132,283 @@ enum { kOKButton = 0, kCancelButton = 1, kOtherButton = 2 };
[NSApp stopModalWithCode:kOtherButton];
}
- (void)awakeFromNib
{
CHBrowserService::SetAlertController(self);
}
- (void)alert:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
{
[alertPanelText setStringValue:text];
[alertPanel setTitle:title];
[NSApp runModalForWindow:alertPanel relativeToWindow:parent];
[alertPanel close];
{
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: NSLocalizedString(@"OKButtonText", @"") altButton: nil otherButton: nil extraView: nil lastResponder:nil];
[NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
}
- (void)alertCheck:(NSWindow*)parent title:(NSString*)title text:(NSString*)text checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
{
[alertCheckPanelText setStringValue:text];
[alertCheckPanel setTitle:title];
// set up check box view
NSButton* checkBox = nil;
float width = [self getContentWidthWithDefaultButton: NSLocalizedString(@"OKButtonText", @"") alternateButton: nil otherButton: nil];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
int state = (*checkValue ? NSOnState : NSOffState);
[alertCheckPanelCheck setState:state];
[alertCheckPanelCheck setTitle:checkMsg];
[checkBox setState:state];
// get panel and display it
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: NSLocalizedString(@"OKButtonText", @"") altButton: nil otherButton: nil extraView: checkboxView lastResponder: checkBox];
[panel setInitialFirstResponder: checkBox];
[NSApp runModalForWindow:alertCheckPanel relativeToWindow:parent];
*checkValue = ([alertCheckPanelCheck state] == NSOnState);
[alertCheckPanel close];
[NSApp runModalForWindow: panel relativeToWindow:parent];
*checkValue = ([checkBox state] == NSOnState);
[panel close];
}
- (BOOL)confirm:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
{
[confirmPanelText setStringValue:text];
[confirmPanel setTitle:title];
int result = [NSApp runModalForWindow:confirmPanel relativeToWindow:parent];
[confirmPanel close];
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: NSLocalizedString(@"OKButtonText", @"") altButton: NSLocalizedString(@"CancelButtonText", @"") otherButton: nil extraView: nil lastResponder: nil];
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
return (result == kOKButton);
}
- (BOOL)confirmCheck:(NSWindow*)parent title:(NSString*)title text:(NSString*)text checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
{
[confirmCheckPanelText setStringValue:text];
[confirmCheckPanel setTitle:title];
// get button titles
NSString* okButton = NSLocalizedString(@"OKButtonText", @"");
NSString* cancelButton = NSLocalizedString(@"CancelButtonText", @"");
// set up check box view
NSButton* checkBox = nil;
float width = [self getContentWidthWithDefaultButton: okButton alternateButton: cancelButton otherButton: nil];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
int state = (*checkValue ? NSOnState : NSOffState);
[confirmCheckPanelCheck setState:state];
[confirmCheckPanelCheck setTitle:checkMsg];
[checkBox setState:state];
// get panel and display it
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: okButton altButton: cancelButton otherButton: nil extraView: checkboxView lastResponder: checkBox];
[panel setInitialFirstResponder: checkBox];
int result = [NSApp runModalForWindow:confirmCheckPanel relativeToWindow:parent];
*checkValue = ([confirmCheckPanelCheck state] == NSOnState);
[confirmCheckPanel close];
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
*checkValue = ([checkBox state] == NSOnState);
[panel close];
return (result == kOKButton);
}
- (int)confirmEx:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
button1:(NSString*)btn1 button2:(NSString*)btn2 button3:(NSString*)btn3
- (int)confirmEx:(NSWindow*)parent title:(NSString*)title text:(NSString*)text button1:(NSString*)btn1 button2:(NSString*)btn2 button3:(NSString*)btn3
{
[confirmPanelText setStringValue:text];
[confirmPanel setTitle:title];
[confirmPanelButton1 setTitle:btn1];
[confirmPanelButton2 setTitle:btn2];
int result = [NSApp runModalForWindow:confirmPanel relativeToWindow:parent];
[confirmPanel close];
return result;
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: btn1 altButton: btn2 otherButton: btn3 extraView: nil lastResponder: nil];
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
return result;
}
- (int)confirmCheckEx:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
button1:(NSString*)btn1 button2:(NSString*)btn2 button3:(NSString*)btn3
checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
- (int)confirmCheckEx:(NSWindow*)parent title:(NSString*)title text:(NSString*)text button1:(NSString*)btn1 button2:(NSString*)btn2 button3:(NSString*)btn3 checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
{
[confirmCheckPanelText setStringValue:text];
[confirmCheckPanel setTitle:title];
// set up check box view
NSButton* checkBox = nil;
float width = [self getContentWidthWithDefaultButton: btn1 alternateButton: btn2 otherButton: btn3];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
int state = (*checkValue ? NSOnState : NSOffState);
[confirmCheckPanelCheck setState:state];
[confirmCheckPanelCheck setTitle:checkMsg];
[confirmCheckPanelButton1 setTitle:btn1];
[confirmCheckPanelButton2 setTitle:btn2];
[checkBox setState:state];
int result = [NSApp runModalForWindow:confirmCheckPanel relativeToWindow:parent];
*checkValue = ([confirmCheckPanelCheck state] == NSOnState);
[confirmCheckPanel close];
// get panel and display it
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: btn1 altButton: btn2 otherButton: btn3 extraView: checkboxView lastResponder: checkBox];
[panel setInitialFirstResponder: checkBox];
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
*checkValue = ([checkBox state] == NSOnState);
[panel close];
return result;
}
- (BOOL)prompt:(NSWindow*)parent title:(NSString*)title text:(NSString*)text promptText:(NSMutableString*)promptText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck
{
[promptPanelText setStringValue:text];
[promptPanel setTitle:title];
NSString* okButton = NSLocalizedString(@"OKButtonText", @"");
NSString* cancelButton = NSLocalizedString(@"CancelButtonText", @"");
float width = [self getContentWidthWithDefaultButton: okButton alternateButton: cancelButton otherButton: nil];
NSView* extraView = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];;
// set up input field
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];
[[field cell] setControlSize: NSSmallControlSize];
[field setStringValue: promptText];
[field selectText: nil];
[field setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[field setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
[extraView addSubview: field];
[extraView setNextKeyView: field];
// set up check box view, and combine the checkbox and field into the entire extra view
NSButton* checkBox = nil;
if (doCheck) {
int state = (*checkValue ? NSOnState : NSOffState);
[promptPanelCheck setState:state];
[promptPanelCheck setTransparent:NO];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
[checkBox setState:state];
[checkboxView setFrameOrigin: NSMakePoint(0, 0)];
[extraView setFrameSize: NSMakeSize(width, kTextFieldHeight + kGeneralViewSpace + NSHeight([checkboxView frame]))];
[extraView addSubview: checkboxView];
[field setNextKeyView: checkBox];
}
else {
[promptPanelCheck setTransparent:YES];
}
[promptPanelCheck setTitle:checkMsg];
[promptPanelInput setStringValue:promptText];
// get panel and display it
NSView* lastResponder = (doCheck ? (NSView*)checkBox : (NSView*)field);
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: okButton altButton: cancelButton otherButton: nil extraView: extraView lastResponder:lastResponder];
[panel setInitialFirstResponder: field];
int result = [NSApp runModalForWindow:promptPanel relativeToWindow:parent];
*checkValue = ([promptPanelCheck state] == NSOnState);
NSString* value = [promptPanelInput stringValue];
PRUint32 length = [promptText length];
if (length) {
NSRange all;
all.location = 0;
all.length = [promptText length];
[promptText deleteCharactersInRange:all];
}
[promptText appendString:value];
[promptPanel close];
return (result == kOKButton);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
[promptText setString: [field stringValue]];
if (doCheck)
*checkValue = ([checkBox state] == NSOnState);
return (result == kOKButton);
}
- (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
{
[usernamePanelText setStringValue:text];
[usernamePanel setTitle:title];
NSString* okButton = NSLocalizedString(@"OKButtonText", @"");
NSString* cancelButton = NSLocalizedString(@"CancelButtonText", @"");
float width = [self getContentWidthWithDefaultButton: okButton alternateButton: cancelButton otherButton: nil];
NSView* extraView = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, 2*kTextFieldHeight + kGeneralViewSpace)] autorelease];
// set up username field
NSTextField* userField = nil;
NSView* userView = [self getLoginField: &userField withWidth: width];
[userView setAutoresizingMask: NSViewMinYMargin];
[userView setFrameOrigin: NSMakePoint(0, kTextFieldHeight + kGeneralViewSpace)];
[userField setStringValue: userNameText];
[extraView addSubview: userView];
[extraView setNextKeyView: userField];
// set up password field
NSSecureTextField* passField = nil;
NSView* passView = [self getPasswordField: &passField withWidth: width];
[passView setAutoresizingMask: NSViewMinYMargin];
[passView setFrameOrigin: NSMakePoint(0, 0)];
[passField setStringValue: passwordText];
[extraView addSubview: passView];
[userField setNextKeyView: passField];
// set up check box view, and combine the checkbox and field into the entire extra view
NSButton* checkBox = nil;
if (doCheck) {
int state = (*checkValue ? NSOnState : NSOffState);
[usernamePanelCheck setState:state];
[usernamePanelCheck setTransparent:NO];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
[checkBox setState:state];
[checkboxView setFrameOrigin: NSMakePoint(0, 0)];
[extraView setFrameSize: NSMakeSize(width, 2*kTextFieldHeight + 2*kGeneralViewSpace + NSHeight([checkboxView frame]))];
[extraView addSubview: checkboxView];
[passField setNextKeyView: checkBox];
}
else {
[usernamePanelCheck setTransparent:YES];
}
[usernamePanelCheck setTitle:checkMsg];
[usernamePanelPassword setStringValue:passwordText];
[usernamePanelUserName setStringValue:userNameText];
// get panel and display it
NSView* lastResponder = (doCheck ? (NSView*)checkBox : (NSView*)passField);
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: okButton altButton: cancelButton otherButton: nil extraView: extraView lastResponder:lastResponder];
[panel setInitialFirstResponder: userField];
int result = [NSApp runModalForWindow:usernamePanel relativeToWindow:parent];
*checkValue = ([usernamePanelCheck state] == NSOnState);
NSString* value = [usernamePanelUserName stringValue];
PRUint32 length = [userNameText length];
if (length) {
NSRange all;
all.location = 0;
all.length = [userNameText length];
[userNameText deleteCharactersInRange:all];
}
[userNameText appendString:value];
value = [usernamePanelPassword stringValue];
length = [passwordText length];
if (length) {
NSRange all;
all.location = 0;
all.length = [passwordText length];
[passwordText deleteCharactersInRange:all];
}
[passwordText appendString:value];
[usernamePanel close];
return (result == kOKButton);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
[userNameText setString: [userField stringValue]];
[passwordText setString: [passField stringValue]];
if (doCheck)
*checkValue = ([checkBox state] == NSOnState);
return (result == kOKButton);
}
- (BOOL)promptPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text 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
{
[passwordPanelText setStringValue:text];
[passwordPanel setTitle:title];
NSString* okButton = NSLocalizedString(@"OKButtonText", @"");
NSString* cancelButton = NSLocalizedString(@"CancelButtonText", @"");
float width = [self getContentWidthWithDefaultButton: okButton alternateButton: cancelButton otherButton: nil];
NSView* extraView = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];;
// set up input field
NSSecureTextField* passField = nil;
NSView* passView = [self getPasswordField: &passField withWidth: width];
[passView setAutoresizingMask: NSViewMinYMargin];
[passView setFrameOrigin: NSMakePoint(0, 0)];
[passField setStringValue: passwordText];
[extraView addSubview: passView];
[extraView setNextKeyView: passField];
// set up check box view, and combine the checkbox and field into the entire extra view
NSButton* checkBox = nil;
if (doCheck) {
int state = (*checkValue ? NSOnState : NSOffState);
[passwordPanelCheck setState:state];
[passwordPanelCheck setTransparent:NO];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
[checkBox setState:state];
[checkboxView setFrameOrigin: NSMakePoint(0, 0)];
[extraView setFrameSize: NSMakeSize(width, kTextFieldHeight + kGeneralViewSpace + NSHeight([checkboxView frame]))];
[extraView addSubview: checkboxView];
[passField setNextKeyView: checkBox];
}
else {
[passwordPanelCheck setTransparent:YES];
}
[passwordPanelCheck setTitle:checkMsg];
[passwordPanelInput setStringValue:passwordText];
// get panel and display it
NSView* lastResponder = (doCheck ? (NSView*)checkBox : (NSView*)passField);
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: okButton altButton: cancelButton otherButton: nil extraView: extraView lastResponder:lastResponder];
[panel setInitialFirstResponder: passField];
int result = [NSApp runModalForWindow:passwordPanel relativeToWindow:parent];
*checkValue = ([passwordPanelCheck state] == NSOnState);
NSString* value = [passwordPanelInput stringValue];
PRUint32 length = [passwordText length];
if (length) {
NSRange all;
all.location = 0;
all.length = [passwordText length];
[passwordText deleteCharactersInRange:all];
}
[passwordText appendString:value];
[passwordPanel close];
return (result == kOKButton);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
[passwordText setString: [passField stringValue]];
if (doCheck)
*checkValue = ([checkBox state] == NSOnState);
return (result == kOKButton);
}
- (BOOL)postToInsecureFromSecure:(NSWindow*)parent
{
int result = [NSApp runModalForWindow:postToInsecureFromSecurePanel relativeToWindow:parent];
[postToInsecureFromSecurePanel close];
return (result == kOKButton);
NSString* title = NSLocalizedString(@"Security Warning", @"");
NSString* message = NSLocalizedString(@"Post To Insecure", @"");
NSString* continueButton = NSLocalizedString(@"ContinueButton", @"");
NSString* stopButton = NSLocalizedString(@"StopButton", @"");
id panel = NSGetAlertPanel(title, message, continueButton, stopButton, nil);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
NSReleaseAlertPanel(panel);
return (result == NSAlertDefaultReturn);
}
- (BOOL)badCert:(NSWindow*)parent
{
int result = [NSApp runModalForWindow:securityMismatchPanel relativeToWindow:parent];
[securityMismatchPanel close];
return (result == kOKButton);
NSString* title = NSLocalizedString(@"Security Warning", @"");
NSString* message = NSLocalizedString(@"Security Mismatch", @"");
NSString* continueButton = NSLocalizedString(@"ContinueButton", @"");
NSString* stopButton = NSLocalizedString(@"StopButton", @"");
id panel = NSGetAlertPanel(title, message, continueButton, stopButton, nil);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
NSReleaseAlertPanel(panel);
return (result == NSAlertDefaultReturn);
}
- (BOOL)expiredCert:(NSWindow*)parent
{
int result = [NSApp runModalForWindow:expiredCertPanel relativeToWindow:parent];
[expiredCertPanel close];
return (result == kOKButton);
NSString* title = NSLocalizedString(@"Security Warning", @"");
NSString* message = NSLocalizedString(@"Expired Certification", @"");
NSString* continueButton = NSLocalizedString(@"ContinueButton", @"");
NSString* stopButton = NSLocalizedString(@"StopButton", @"");
id panel = NSGetAlertPanel(title, message, continueButton, stopButton, nil);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
NSReleaseAlertPanel(panel);
return (result == NSAlertDefaultReturn);
}
@ -299,10 +416,413 @@ enum { kOKButton = 0, kCancelButton = 1, kOtherButton = 2 };
{
// this dialog is a little backward, with "Stop" returning 0, and the default returning
// 1. That's just how nsIBadCertListener defines its constants. *shrug*
int result = [NSApp runModalForWindow:securityUnknownPanel relativeToWindow:parent];
[securityUnknownPanel close];
NSString* title = NSLocalizedString(@"Security Warning", @"");
NSString* message = NSLocalizedString(@"Unknown Certification", @"");
NSString* alwaysAcceptButton = NSLocalizedString(@"Accept Always", @"");
NSString* oneAcceptButton = NSLocalizedString(@"Accept Once", @"");
NSString* stopButton = NSLocalizedString(@"StopButton", @"");
id panel = NSGetAlertPanel(title, message, oneAcceptButton, stopButton, alwaysAcceptButton);
return result;
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
NSReleaseAlertPanel(panel);
int returnValue;
if (result == NSAlertDefaultReturn)
returnValue = 1;
else if (result == NSAlertOtherReturn)
returnValue = 2;
else
returnValue = 0;
return returnValue;
}
#pragma mark -
// implementation of private methods
// The content width is determined by how much space is needed to display all 3 buttons,
// since every other view in the dialog can wrap if necessary
- (float)getContentWidthWithDefaultButton:(NSString*)defStr alternateButton:(NSString*)altStr otherButton:(NSString*)otherStr
{
NSButton* defButton = [self makeButtonWithTitle: defStr];
NSButton* altButton = [self makeButtonWithTitle: altStr];
NSButton* otherButton = [self makeButtonWithTitle: otherStr];
float defWidth = NSWidth([defButton frame]);
float altWidth = (altButton) ? NSWidth([altButton frame]) : 0;
float otherWidth = (otherButton) ? NSWidth([otherButton frame]) : 0;
float minContentWidth = kMinDialogWidth - 2*kWindowBorder - kIconMargin - kIconSize;
float buttonWidth = defWidth + altWidth + otherWidth + kOtherAltButtonSpace;
// return the larger of the two
return (minContentWidth > buttonWidth) ? minContentWidth : buttonWidth;
}
- (NSPanel*)getAlertPanelWithTitle:(NSString*)title message:(NSString*)message
defaultButton:(NSString*)defaultLabel altButton:(NSString*)altLabel
otherButton:(NSString*)otherLabel extraView:(NSView*)extraView lastResponder:(NSView*)lastResponder
{
NSRect rect = NSMakeRect(0, 0, kMinDialogWidth, kMaxDialogHeight);
NSPanel* panel = [[[NSPanel alloc] initWithContentRect: rect styleMask: NSTitledWindowMask backing: NSBackingStoreBuffered defer: YES] autorelease];
NSImageView* imageView = [[[NSImageView alloc] initWithFrame: NSMakeRect(kWindowBorder, kMaxDialogHeight - kWindowBorder - kIconSize, kIconSize, kIconSize)] autorelease];
// app icon
[imageView setImage: [NSImage imageNamed: @"NSApplicationIcon"]];
[imageView setImageFrameStyle: NSImageFrameNone];
[imageView setImageScaling: NSScaleProportionally];
[imageView setAutoresizingMask: NSViewMinYMargin | NSViewMaxXMargin];
[[panel contentView] addSubview: imageView];
// create buttons
NSButton* defButton = [self makeButtonWithTitle: defaultLabel];
[defButton setAction: @selector(hitButton1:)];
[defButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
[defButton setKeyEquivalent: @"\r"]; // return
[[panel contentView] addSubview: defButton];
[panel setDefaultButtonCell: [defButton cell]];
NSView* firstKeyView = (extraView ? extraView : defButton);
NSButton* altButton = nil;
if (altLabel) {
altButton = [self makeButtonWithTitle: altLabel];
[altButton setAction: @selector(hitButton2:)];
[altButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
[altButton setKeyEquivalent: @"\e"]; // escape
[[panel contentView] addSubview: altButton];
[defButton setNextKeyView: altButton];
}
NSButton* otherButton = nil;
if (otherLabel) {
otherButton = [self makeButtonWithTitle: otherLabel];
[otherButton setAction: @selector(hitButton3:)];
[otherButton setAutoresizingMask: NSViewMaxXMargin | NSViewMaxYMargin];
[[panel contentView] addSubview: otherButton];
[otherButton setNextKeyView: firstKeyView];
if (altButton)
[altButton setNextKeyView: otherButton];
else
[defButton setNextKeyView: otherButton];
} else {
if (altButton)
[altButton setNextKeyView: firstKeyView];
else
[defButton setNextKeyView: firstKeyView];
}
// position buttons
float defWidth = NSWidth([defButton frame]);
float altWidth = (altButton) ? NSWidth([altButton frame]) : 0;
[defButton setFrameOrigin: NSMakePoint(NSWidth([panel frame]) - defWidth - kButtonRightMargin, kButtonBottomMargin)];
[altButton setFrameOrigin: NSMakePoint(NSMinX([defButton frame]) - altWidth, kButtonBottomMargin)];
[otherButton setFrameOrigin: NSMakePoint(kIconSize + kWindowBorder + kIconMargin, kButtonBottomMargin)];
// set the window width
// contentWidth is the width of the area with text, buttons, etc
// windowWidth is the total window width (contentWidth + margins + icon)
float contentWidth = [self getContentWidthWithDefaultButton: defaultLabel alternateButton: altLabel otherButton: otherLabel];
float windowWidth = kIconSize + kIconMargin + 2*kWindowBorder + contentWidth;
if (windowWidth < kMinDialogWidth)
windowWidth = kMinDialogWidth;
// get the height of all elements, and set the window height
NSTextField* titleField = [self getTitleView: title withWidth: contentWidth];
float titleHeight = [title length] ? NSHeight([titleField frame]) : 0;
float extraViewHeight = (extraView) ? NSHeight([extraView frame]) : 0;
float totalHeight = kWindowBorder + titleHeight + kGeneralViewSpace + kViewButtonSpace + kButtonHeight + kButtonBottomMargin;
if (extraViewHeight > 0)
totalHeight += extraViewHeight + kGeneralViewSpace;
float maxMessageHeight = kMaxDialogHeight - totalHeight;
NSView* messageView = [self getMessageView: message withWidth: contentWidth maxHeight: maxMessageHeight smallFont:[title length]];
float messageHeight = NSHeight([messageView frame]);
totalHeight += messageHeight;
if (totalHeight < kMinDialogHeight)
totalHeight = kMinDialogHeight;
[panel setContentSize: NSMakeSize(windowWidth, totalHeight)];
// position the title
float contentLeftEdge = kWindowBorder + kIconSize + kIconMargin;
NSRect titleRect = NSMakeRect(contentLeftEdge, totalHeight - titleHeight - kWindowBorder, contentWidth, titleHeight);
[titleField setFrame: titleRect];
if ( [title length] )
[[panel contentView] addSubview: titleField];
// position the message
NSRect messageRect = NSMakeRect(contentLeftEdge, NSMinY([titleField frame]) - kGeneralViewSpace - messageHeight, contentWidth, messageHeight);
[messageView setFrame: messageRect];
[[panel contentView] addSubview: messageView];
// position the extra view
NSRect extraRect = NSMakeRect(contentLeftEdge, NSMinY([messageView frame]) - kGeneralViewSpace - extraViewHeight, contentWidth, extraViewHeight);
[extraView setFrame: extraRect];
[[panel contentView] addSubview: extraView];
// If a lastResponder was passed in (the last item in the tab order inside
// extraView), hook it up to cycle to defButton. If not, assume there is
// nothing focusable inside extraView and hook up defButton as the first
// responder.
if (lastResponder)
[lastResponder setNextKeyView: defButton];
else
[panel setInitialFirstResponder: defButton];
return panel;
}
- (NSButton*)makeButtonWithTitle:(NSString*)title
{
if (title == nil)
return nil;
NSButton* button = [[[NSButton alloc] initWithFrame: NSMakeRect(0, 0, kButtonMinWidth, kButtonHeight)] autorelease];
[button setTitle: title];
[button setFont: [NSFont systemFontOfSize: [NSFont systemFontSize]]];
[button setBordered: YES];
[button setButtonType: NSMomentaryPushButton];
[button setBezelStyle: NSRoundedBezelStyle];
[button setTarget: self];
[button sizeToFit];
NSRect buttonFrame = [button frame];
// sizeToFit doesn't leave large enough endcaps (it goes to the bare minimum size)
buttonFrame.size.width += 2*kButtonEndCapWidth;
// make sure the button is within our allowed size range
if (NSWidth(buttonFrame) < kButtonMinWidth)
buttonFrame.size.width = kButtonMinWidth;
else if (NSWidth(buttonFrame) > kButtonMaxWidth)
buttonFrame.size.width = kButtonMaxWidth;
[button setFrame: buttonFrame];
return button;
}
- (NSTextField*)getTitleView:(NSString*)title withWidth:(float)width
{
NSTextView* textView = [[[NSTextView alloc] initWithFrame: NSMakeRect(0, 0, width, 100)] autorelease];
[textView setString: title];
[textView setMinSize: NSMakeSize(width, 0.0)];
[textView setMaxSize: NSMakeSize(width, kMaxFieldHeight)];
[textView setVerticallyResizable: YES];
[textView setHorizontallyResizable: NO];
[textView setFont: [NSFont boldSystemFontOfSize: [NSFont systemFontSize]]];
[textView sizeToFit];
NSSize textSize = NSMakeSize( ceil( NSWidth([textView frame]) ), ceil( NSHeight([textView frame]) ) );
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, textSize.width, textSize.height)] autorelease];
[field setStringValue: title];
[field setFont: [NSFont boldSystemFontOfSize: [NSFont systemFontSize]]];
[field setEditable: NO];
[field setSelectable: NO];
[field setBezeled: NO];
[field setBordered: NO];
[field setDrawsBackground: NO];
return field;
}
- (NSTextField*)getLabelView:(NSString*)title withWidth:(float)width
{
NSTextView* textView = [[[NSTextView alloc] initWithFrame: NSMakeRect(0, 0, width, 100)] autorelease];
[textView setString: title];
[textView setMinSize: NSMakeSize(width, 0.0)];
[textView setMaxSize: NSMakeSize(width, kMaxFieldHeight)];
[textView setVerticallyResizable: YES];
[textView setHorizontallyResizable: NO];
[textView setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[textView sizeToFit];
NSSize textSize = NSMakeSize(ceil(NSWidth([textView frame])), ceil(NSHeight([textView frame])) + 5);
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, textSize.width, textSize.height)] autorelease];
[field setStringValue: title];
[field setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[field setEditable: NO];
[field setSelectable: NO];
[field setBezeled: NO];
[field setBordered: NO];
[field setDrawsBackground: NO];
return field;
}
- (NSView*)getMessageView:(NSString*)message withWidth:(float)width maxHeight:(float)maxHeight smallFont:(BOOL)useSmallFont
{
NSTextView* textView = [[[NSTextView alloc] initWithFrame: NSMakeRect(0, 0, width, 100)] autorelease];
[textView setString: message];
[textView setMinSize: NSMakeSize(width, 0.0)];
[textView setVerticallyResizable: YES];
[textView setHorizontallyResizable: NO];
float displayFontSize = useSmallFont ? [NSFont smallSystemFontSize] : [NSFont systemFontSize];
[textView setFont: [NSFont systemFontOfSize:displayFontSize]];
[textView sizeToFit];
NSSize textSize = NSMakeSize(ceil(NSWidth([textView frame])), ceil(NSHeight([textView frame])) + 5);
// if the text is small enough to fit, then display it
if (textSize.height <= maxHeight) {
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, textSize.width, textSize.height)] autorelease];
[field setStringValue: message];
[field setFont: [NSFont systemFontOfSize: displayFontSize]];
[field setEditable: NO];
[field setSelectable: YES];
[field setBezeled: NO];
[field setBordered: NO];
[field setDrawsBackground: NO];
return field;
}
// if not, create scrollers
NSScrollView* scrollView = [[[NSScrollView alloc] initWithFrame: NSMakeRect(0, 0, width, maxHeight)] autorelease];
[scrollView setDocumentView: textView];
[scrollView setDrawsBackground: NO];
[scrollView setBorderType: NSBezelBorder];
[scrollView setHasHorizontalScroller: NO];
[scrollView setHasVerticalScroller: YES];
[textView setSelectable: YES];
[textView setEditable: NO];
[textView setDrawsBackground: NO];
[textView setFrameSize: [scrollView contentSize]];
return scrollView;
}
- (NSView*)getCheckboxView:(NSButton**)checkBoxPtr withLabel:(NSString*)label andWidth:(float)width
{
NSTextField* textField = [self getLabelView: label withWidth: width - kCheckBoxWidth];
float height = NSHeight([textField frame]);
// one line of text isn't as tall as the checkbox. make the view taller, or the checkbox will get clipped
if (height < kCheckBoxHeight)
height = kCheckBoxHeight;
// use a flipped view so we can more easily align everything at the top/left.
NSView* view = [[[QDCoordsView alloc] initWithFrame: NSMakeRect(0, 0, width, height)] autorelease];
[view addSubview: textField];
[view setNextKeyView: textField];
[textField setFrameOrigin: NSMakePoint(kCheckBoxWidth, kLabelCheckboxAdjustment)];
NSButton* checkBox = [[[NSButton alloc] initWithFrame: NSMakeRect(0, 0, kCheckBoxWidth, kCheckBoxHeight)] autorelease];
*checkBoxPtr = checkBox;
[checkBox setButtonType: NSSwitchButton];
[[checkBox cell] setControlSize: NSSmallControlSize];
[view addSubview: checkBox];
[textField setNextKeyView: checkBox];
// overlay the label with a transparent button that will push the checkbox
// when clicked on
NSButton* labelOverlay = [[[NSButton alloc] initWithFrame:[textField frame]] autorelease];
[labelOverlay setTransparent:YES];
[labelOverlay setTarget:[checkBox cell]];
[labelOverlay setAction:@selector(performClick:)];
[view addSubview:labelOverlay positioned:NSWindowAbove relativeTo:checkBox];
return view;
}
- (NSView*)getLoginField:(NSTextField**)fieldPtr withWidth:(float)width
{
int labelSize = [self getLoginTextLabelSize];
int fieldLeftEdge = labelSize + kFieldLabelSpacer;
NSView* view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];
NSTextField* label = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 3, labelSize, kStaticTextFieldHeight)] autorelease];
[[label cell] setControlSize: NSSmallControlSize];
[label setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[label setStringValue: NSLocalizedString(@"Username Label", @"")];
[label setEditable: NO];
[label setSelectable: NO];
[label setBordered: NO];
[label setDrawsBackground: NO];
[label setAlignment: NSRightTextAlignment];
[view addSubview: label];
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(fieldLeftEdge, 0, width - fieldLeftEdge, kTextFieldHeight)] autorelease];
[[field cell] setControlSize: NSSmallControlSize];
[field setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[view addSubview: field];
[view setNextKeyView: field];
*fieldPtr = field;
return view;
}
- (NSView*)getPasswordField:(NSSecureTextField**)fieldPtr withWidth:(float)width
{
int labelSize = [self getLoginTextLabelSize];
int fieldLeftEdge = labelSize + kFieldLabelSpacer;
NSView* view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];
NSTextField* label = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 3, labelSize, kStaticTextFieldHeight)] autorelease];
[[label cell] setControlSize: NSSmallControlSize];
[label setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[label setStringValue: NSLocalizedString(@"Password Label", @"")];
[label setEditable: NO];
[label setSelectable: NO];
[label setBordered: NO];
[label setDrawsBackground: NO];
[label setAlignment: NSRightTextAlignment];
[view addSubview: label];
NSSecureTextField* field = [[[NSSecureTextField alloc] initWithFrame: NSMakeRect(fieldLeftEdge, 0, width - fieldLeftEdge, kTextFieldHeight)] autorelease];
[[field cell] setControlSize: NSSmallControlSize];
[field setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[view addSubview: field];
[view setNextKeyView: field];
*fieldPtr = field;
return view;
}
- (int)getLoginTextLabelSize
{
NSTextField* label = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, 200, kStaticTextFieldHeight)] autorelease];
[[label cell] setControlSize: NSSmallControlSize];
[label setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[label setEditable: NO];
[label setSelectable: NO];
[label setBordered: NO];
[label setDrawsBackground: NO];
[label setAlignment: NSRightTextAlignment];
[label setStringValue: NSLocalizedString(@"Username Label", @"")];
[label sizeToFit];
float userSize = NSWidth([label frame]);
[label setStringValue: NSLocalizedString(@"Password Label", @"")];
[label sizeToFit];
float passSize = NSWidth([label frame]);
float largest = (userSize > passSize) ? userSize : passSize;
return (int)ceil(largest) + 6;
}
@end

Просмотреть файл

@ -346,7 +346,8 @@ static id gSharedProgressController = nil;
{
ProgressViewController *newController = [[ProgressViewController alloc] init];
[newController setProgressWindowController:self];
[mProgressViewControllers addObject:newController];
//[mProgressViewControllers addObject:newController];
[mProgressViewControllers insertObject:newController atIndex:0]; // new downoads at the top
return newController;
}

Просмотреть файл

@ -256,13 +256,9 @@ static NSString *ProgressViewsShouldResize = @"ProgressViewsShouldResize";
if (mDownloader) // we should always have one
mDownloader->CancelDownload();
// clean up downloaded file. - do it here or in CancelDownload?
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager isDeletableFileAtPath:mDestPath])
{
// if we delete it, fantastic. if not, oh well. better to move to trash instead?
[fileManager removeFileAtPath:mDestPath handler:nil];
}
// note that we never want to delete downloaded files here,
// because the file does not have its final path yet.
// Necko will delete the evil temp file.
}
- (IBAction)close:(id)sender

Просмотреть файл

@ -347,7 +347,7 @@ nsresult nsHeaderSniffer::InitiateDownload(nsISupports* inSourceData, nsString&
{ // Tell web persist we want no decoding on this data
flags |= nsIWebBrowserPersist::PERSIST_FLAGS_NO_CONVERSION;
webPersist->SetPersistFlags(flags);
rv = webPersist->SaveURI(sourceURI, mPostData, destFile);
rv = webPersist->SaveURI(sourceURI, nsnull, nsnull, mPostData, nsnull, destFile);
}
else
{

Просмотреть файл

@ -71,7 +71,7 @@ NS_IMPL_ISUPPORTS_INHERITED3(nsDownloadListener, CHDownloader, nsIDownload, nsIW
/* void init (in nsIURI aSource, in nsILocalFile aTarget, in wstring aDisplayName, in wstring openingWith, in long long startTime, in nsIWebBrowserPersist aPersist); */
NS_IMETHODIMP
nsDownloadListener::Init(nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisplayName,
nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist)
nsIMIMEInfo* aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist)
{
CreateDownloadDisplay(); // call the base class to make the download UI
@ -269,7 +269,12 @@ NS_IMETHODIMP nsDownloadListener::Notify(nsITimer *timer)
// changed it
nsAutoString pathStr;
mDestination->GetPath(pathStr);
[mDownloadDisplay setDestinationPath: [NSString stringWith_nsAString:pathStr]];
NSString* destPath = [NSString stringWith_nsAString:pathStr];
[mDownloadDisplay setDestinationPath:destPath];
// update the Finder immediately.
if ( NS_SUCCEEDED(mDownloadStatus) )
[[NSWorkspace sharedWorkspace] noteFileSystemChanged:destPath];
// cancelling should give us a failure status
[mDownloadDisplay onEndDownload:(NS_SUCCEEDED(mDownloadStatus) && !mUserCanceled)];
@ -364,7 +369,7 @@ nsDownloadListener::DownloadDone(nsresult aStatus)
mEndRefreshTimer = do_CreateInstance("@mozilla.org/timer;1");
if (mEndRefreshTimer)
{
nsresult rv = mEndRefreshTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT); // defaults to 1-shot, normal priority
nsresult rv = mEndRefreshTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT);
if (NS_FAILED(rv))
mEndRefreshTimer = NULL;
}

Просмотреть файл

@ -222,15 +222,6 @@ CHBrowserListener::SetChromeFlags(PRUint32 aChromeFlags)
NS_IMETHODIMP
CHBrowserListener::DestroyBrowserWindow()
{
#if 0
// XXX Could send this up to the container, but for now,
// we just destroy the enclosing window.
NSWindow* window = [mView window];
if (window) {
[window close];
}
#endif
// tell the container we want to close the window and let it do the
// right thing.
[mContainer closeBrowserWindow];
@ -261,7 +252,7 @@ CHBrowserListener::ShowAsModal()
return NS_ERROR_FAILURE;
}
NSWindow* window = [mView window];
NSWindow* window = [mView getNativeWindow];
if (!window) {
return NS_ERROR_FAILURE;
@ -309,6 +300,8 @@ CHBrowserListener::SetDimensions(PRUint32 flags, PRInt32 x, PRInt32 y, PRInt32 c
if (!mView)
return NS_ERROR_FAILURE;
// use -window here and not -getNativeWindow because we don't want to allow bg tabs
// (which aren't in the window hierarchy) to resize the window.
NSWindow* window = [mView window];
if (!window)
return NS_ERROR_FAILURE;
@ -363,7 +356,7 @@ CHBrowserListener::GetDimensions(PRUint32 flags, PRInt32 *x, PRInt32 *y, PRInt
if (!mView)
return NS_ERROR_FAILURE;
NSWindow* window = [mView window];
NSWindow* window = [mView getNativeWindow];
if (!window)
return NS_ERROR_FAILURE;
@ -403,6 +396,7 @@ CHBrowserListener::GetDimensions(PRUint32 flags, PRInt32 *x, PRInt32 *y, PRInt
NS_IMETHODIMP
CHBrowserListener::SetFocus()
{
// don't use -getNativeWindow here so tabs in the bg can't take focus
NSWindow* window = [mView window];
if (!window)
return NS_ERROR_FAILURE;
@ -433,7 +427,7 @@ CHBrowserListener::GetVisibility(PRBool *aVisibility)
return NS_ERROR_FAILURE;
}
NSWindow* window = [mView window];
NSWindow* window = [mView getNativeWindow];
if (!window) {
return NS_ERROR_FAILURE;
}
@ -446,6 +440,8 @@ CHBrowserListener::GetVisibility(PRBool *aVisibility)
NS_IMETHODIMP
CHBrowserListener::SetVisibility(PRBool aVisibility)
{
// use -window instead of -getNativeWindow to prevent bg tabs from being able to
// change the visibility
NSWindow* window = [mView window];
if (!window)
return NS_ERROR_FAILURE;
@ -512,7 +508,7 @@ CHBrowserListener::GetSiteWindow(void * *aSiteWindow)
return NS_ERROR_FAILURE;
}
NSWindow* window = [mView window];
NSWindow* window = [mView getNativeWindow];
if (!window) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -162,8 +162,7 @@ nsAlertController*
CHBrowserService::GetAlertController()
{
if (!sController) {
NSBundle* bundle = [NSBundle bundleForClass:[CHBrowserView class]];
[bundle loadNibFile:@NS_ALERT_NIB_NAME externalNameTable:nsnull withZone:[NSApp zone]];
sController = [[nsAlertController alloc] init];
}
return sController;
}

Просмотреть файл

@ -215,6 +215,9 @@ enum {
// point is over.
- (void) findEventSink:(nsIEventSink**)outSink forPoint:(NSPoint)inPoint inWindow:(NSWindow*)inWind;
- (IBAction)reloadWithNewCharset:(NSString*)charset;
- (NSString*)currentCharset;
@end
#endif // __nsCocoaBrowserView_h__

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsIWebNavigation.h"
#include "nsIWebBrowserSetup.h"
#include "nsComponentManagerUtils.h"
#include "nsIDocCharset.h"
#include "nsIURI.h"
#include "nsIDOMWindow.h"
@ -109,7 +110,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
- (nsIContentViewer*)getContentViewer; // addrefs return value
- (float)getTextZoom;
- (void)incrementTextZoom:(float)increment min:(float)min max:(float)max;
- (nsIDocShell*)getDocShell; // addrefs return value
@end
@implementation CHBrowserView
@ -480,7 +481,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
if (!sniffer)
return;
webPersist->SetProgressListener(sniffer); // owned
webPersist->SaveURI(aURI, nsnull, tmpFile);
webPersist->SaveURI(aURI, nsnull, nsnull, nsnull, nsnull, tmpFile);
}
-(void)printDocument
@ -678,8 +679,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
PRBool isEnabled = PR_FALSE;
nsCOMPtr<nsICommandManager> commandMgr(do_GetInterface(_webBrowser));
if (commandMgr) {
nsresult rv = commandMgr->IsCommandEnabled(commandName, nsnull,
&isEnabled);
nsresult rv = commandMgr->IsCommandEnabled(commandName, nsnull, &isEnabled);
#if DEBUG
if (NS_FAILED(rv))
NSLog(@"IsCommandEnabled failed");
@ -916,7 +916,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
}
- (nsIContentViewer*)getContentViewer // addrefs return value
- (nsIDocShell*)getDocShell
{
if (!_webBrowser)
return NULL;
@ -925,11 +925,14 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
nsCOMPtr<nsIScriptGlobalObject> global(do_QueryInterface(domWindow));
if (!global)
return NULL;
nsCOMPtr<nsIDocShell> docShell;
global->GetDocShell(getter_AddRefs(docShell));
if (!docShell)
return NULL;
nsIDocShell* docShell = NULL;
global->GetDocShell(&docShell); // addrefs
return docShell;
}
- (nsIContentViewer*)getContentViewer // addrefs return value
{
nsCOMPtr<nsIDocShell> docShell = dont_AddRef([self getDocShell]);
nsIContentViewer* cv = NULL;
docShell->GetContentViewer(&cv); // addrefs
return cv;
@ -1126,10 +1129,10 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
nsCOMPtr<nsICommandParams> params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID);
if (!params) return NO;
params->SetStringValue("format", NS_LITERAL_STRING("text/plain"));
params->SetStringValue("format", NS_LITERAL_STRING("text/plain"));
params->SetBooleanValue("selection_only", PR_TRUE);
nsresult rv = cmdManager->DoCommand("cmd_getContents", params, nsnull);
nsresult rv = cmdManager->DoCommand("cmd_GetContents", params, nsnull);
if (NS_FAILED(rv))
return NO;
@ -1166,4 +1169,52 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
return (BOOL)NS_SUCCEEDED(rv);
}
- (IBAction)reloadWithNewCharset:(NSString*)inCharset
{
// set charset on document then reload the page (hopefully not hitting the network)
nsCOMPtr<nsIDocShell> docShell = dont_AddRef([self getDocShell]);
nsCOMPtr<nsIDocCharset> charset ( do_QueryInterface(docShell) );
if ( charset ) {
nsAutoString charsetStr;
[inCharset assignTo_nsAString:charsetStr];
charset->SetCharset(charsetStr.get());
[self reload:nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE];
}
}
- (NSString*)currentCharset
{
#if 0
nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));
if ( wbf ) {
nsCOMPtr<nsIDOMWindow> focusedWindow;
wbf->GetFocusedWindow(getter_AddRefs(focusedWindow));
if ( focusedWindow ) {
nsCOMPtr<nsIDOMDocument> domDoc;
focusedWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc ( do_QueryInterface(domDoc) );
if ( doc ) {
nsAutoString charset;
doc->GetDocumentCharacterSet(charset);
return [NSString stringWith_nsAString:charset];
}
}
}
#endif
nsCOMPtr<nsIDOMWindow> wind;
_webBrowser->GetContentDOMWindow(getter_AddRefs(wind));
if ( wind ) {
nsCOMPtr<nsIDOMDocument> domDoc;
wind->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc ( do_QueryInterface(domDoc) );
if ( doc ) {
nsAutoString charset;
doc->GetDocumentCharacterSet(charset);
return [NSString stringWith_nsAString:charset];
}
}
return nil;
}
@end

Просмотреть файл

@ -65,15 +65,16 @@
-(void)keyDown:(NSEvent*)aEvent
{
const unichar kForwardDeleteChar = 0xf728; // couldn't find this in any cocoa header
// check each char in the event array. it should be just 1 char, but
// just in case we use a loop.
int len = [[aEvent characters] length];
for ( int i = 0; i < len; ++i ) {
unichar c = [[aEvent characters] characterAtIndex:i];
// Check for a certain set of special keys.
if (c == NSDeleteCharacter || c == NSBackspaceCharacter) {
// Check for a certain set of special keys.
if (c == NSDeleteCharacter || c == NSBackspaceCharacter || c == kForwardDeleteChar) {
// delete the bookmark
if (mDeleteAction)
[NSApp sendAction: mDeleteAction to: [self target] from: self];

Просмотреть файл

@ -55,7 +55,7 @@ class nsIRDFService;
// cached values are valid
BOOL mExpandable;
int mNumChildren;
NSArray* mChildNodes;
NSArray* mChildNodes; // array of |RDFOutlineViewItem|'s
}
- (nsIRDFResource*)resource; // addRefs the result

Просмотреть файл

@ -150,6 +150,7 @@ HistoryDataSourceObserver::OnChange(nsIRDFDataSource*, nsIRDFResource*,
@interface HistoryDataSource(Private)
- (void)cleanupHistory;
- (void)removeItemFromHistory:(id)inItem withService:(nsIBrowserHistory*)inHistService;
@end
@ -398,15 +399,27 @@ HistoryDataSourceObserver::OnChange(nsIRDFDataSource*, nsIRDFResource*,
nsCOMPtr<nsIBrowserHistory> history = do_GetService("@mozilla.org/browser/global-history;1");
if ( history ) {
// Even though it looks like relying on row numbers as we delete will get us in trouble
// and out of sync, until we actually invalidate the table, the rows keep their prior values.
// If children are selected as well as the parent, we'll just end up trying to remove the
// host string from history which will silently fail. It's extra work, but harmless.
history->StartBatchUpdate();
NSEnumerator* rowEnum = [mOutlineView selectedRowEnumerator];
for ( NSNumber* currIndex = [rowEnum nextObject]; currIndex; currIndex = [rowEnum nextObject]) {
index = [currIndex intValue];
RDFOutlineViewItem* item = [mOutlineView itemAtRow: index];
if (![mOutlineView isExpandable: item]) {
NSString* urlString = [self getPropertyString:@"http://home.netscape.com/NC-rdf#URL" forItem:item];
history->RemovePage([urlString UTF8String]);
if ([mOutlineView isExpandable: item]) {
// delete a folder by iterating over each of its children and deleting them. There
// should be a better way, but the history api's don't really support them. Expand
// the folder before we delete it otherwise we don't get any child nodes to delete.
[mOutlineView expandItem:item];
NSEnumerator* childEnum = [item->mChildNodes objectEnumerator];
RDFOutlineViewItem* currChild = nil;
while ( (currChild = [childEnum nextObject]) )
[self removeItemFromHistory:currChild withService:history];
}
else
[self removeItemFromHistory:item withService:history];
}
history->EndBatchUpdate();
if ( clearSelectionWhenDone )
@ -417,6 +430,13 @@ HistoryDataSourceObserver::OnChange(nsIRDFDataSource*, nsIRDFResource*,
}
}
-(void)removeItemFromHistory:(id)inItem withService:(nsIBrowserHistory*)inHistService;
{
NSString* urlString = [self getPropertyString:@"http://home.netscape.com/NC-rdf#URL" forItem:inItem];
inHistService->RemovePage([urlString UTF8String]);
}
//
// outlineView:tooltipForString
//

Просмотреть файл

@ -263,9 +263,11 @@ static BOOL gMadePrefManager;
}
return NO;
}
#ifdef BRANCH_CHANGES_NEED_MERGED
else if (rv == NS_ERROR_PROFILE_SETLOCK_FAILED) {
NSLog(@"SetCurrentProfile returned NS_ERROR_PROFILE_SETLOCK_FAILED");
}
#endif
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
mPrefs = prefs;

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -9,7 +9,7 @@
#include "nsIPermission.h"
#include "nsISupportsArray.h"
#include "nsXPIDLString.h"
#include "nsString.h"
// prefs for keychain password autofill
static const char* const gUseKeychainPref = "chimera.store_passwords_with_keychain";
@ -199,7 +199,7 @@ const int kDisableAllCookies = 2;
if ( perm ) {
nsXPIDLCString host;
perm->GetHost(getter_Copies(host));
mManager->Remove(nsDependentCString(host), 0); // could this api _be_ any worse? Come on!
mManager->Remove(host, 0); // could this api _be_ any worse? Come on!
mCachedPermissions->RemoveElementAt(row);
}

Просмотреть файл

@ -2,7 +2,7 @@
\readonlydoc1{\fonttbl\f0\fswiss\fcharset77 Optima-Bold;\f1\fswiss\fcharset77 Optima-Regular;\f2\fswiss\fcharset77 Helvetica;
\f3\fnil\fcharset77 Monaco;}
{\colortbl;\red255\green255\blue255;\red4\green16\blue255;}
\margl1440\margr1440\vieww13740\viewh16200\viewkind0
\margl1440\margr1440\vieww13940\viewh15220\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f0\b\fs48 \cf0 Chimera Read Me\
@ -71,4 +71,7 @@ To find out more about Chimera, see the project page at:\
\
\cf2 http://www.mozilla.org/projects/chimera/\cf0 \
\
This page contains information about how to give feedback on Chimera, has links that allow you to query for known bugs, see what\'d5s going on with current development, and about how to build it yourself from source.}
This page contains information about how to give feedback on Chimera, has links that allow you to query for known bugs, see what\'d5s going on with current development, and about how to build it yourself from source.\
\
There is also a Unix browser project called Chimera, which is unrelated to Chimera for OS X. More information about the Unix/X11 Chimera browser can be found at \cf2 http://www.chimera.org/\cf0 \
}

Просмотреть файл

@ -0,0 +1,139 @@
{\rtf1\mac\ansicpg10000\cocoartf102
{\fonttbl\f0\fswiss\fcharset77 Optima-Bold;\f1\fswiss\fcharset77 Optima-Regular;\f2\fswiss\fcharset77 Optima-Italic;
\f3\fnil\fcharset77 Monaco;}
{\colortbl;\red255\green255\blue255;\red4\green16\blue255;}
\margl1440\margr1440\vieww13340\viewh16360\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f0\b\fs48 \cf0 Chimera 0.7 Release Notes\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
\f1\b0\fs24 \cf2 http://www.mozilla.org/projects/chimera/\cf0 \
\
\pard\tx720\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640
\cf0 The following changes and improvements have been made since the Chimera 0.6 release. \
\pard\tx360\tx720\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\li720\fi-720\ql\qnatural
\cf0 \
\f0\b Highlights
\f1\b0 \
\
\'a5 New Download Manager, with auto-download and auto-dispatch.\
\'a5 Compatible with URL Manager Pro\
\'a5 Page Text Encodings menu\
\'a5 Global History in the sidebar\
\'a5 Send Link menu item, and other new toolbar buttons\
\'a5 Dragging of images and links to the desktop, and other applications\
\'a5 Support for Shockwave Directory content\
\'a5 Uses Rendezvous to show local FTP and web servers\
\'a5 Supports Proxy Auto-config\
\
\f0\b Details\
\f1\b0 \
\f2\i User Interface
\f1\i0 \
\
\'a5 Chimera now has a Text Encoding submenu, allowing you to override the character set of a page when it doesn't display correctly.\
\'a5 Chimera now supports the Menu Sharing protocol, allowing applications like URL Manager Pro to work.\
\'a5 Popup windows no longer do an ugly resize-flash when they appear.\
\'a5 If you type something in the URL bar before Chimera finishes loading the first page, it will no longer get replaced by the page URL.\
\'a5 Global history is now visible in the sidebar (and is much faster than before).\
\'a5 Redesigned content-generated dialogs (like cookie and JavaScript dialogs) to autosize. JS dialogs are identified by a \'d4[JavaScript Application]\'d5 label to avoid spoofing attacks now.\
\
\f2\i Menus and Toolbars
\f1\i0 \
\
\'a5 New, brighter toolbar icons.\
\'a5 Added a \'d2Send Link\'d3 command to the File menu (with an optional toolbar button), which opens a mail message with the URL of the current page in your favorite mail application.\
\'a5 Added additional optional toolbar buttons for New Tab, Close Tab, Search etc.\
\'a5 Added some new items to the context menus, relating to frames, and copying images.\
\'a5 Added support for copying images to the clipboard, and dragging images and links to the desktop, and to other applications.\
\'a5 Fixed an issue that would cause the wrong window to be used for loading a bookmark, or URL sometimes.\
\'a5 The \'d2small icons\'d3 toolbar mode is shorter now to save screen space.\
\
\f2\i Downloading
\f1\i0 \
\
\'a5 Downloads are now shown in a Download manager, reducing the number of open windows.\
\'a5 If you quit while downloads are in progress, Chimera will warn you now.\
\'a5 Downloads now start automatically, saving into your Downloads folder, without asking you where to save the file. Option-click a link if you want to specify a different location at which save the file.\
\'a5 Added a preference (in the Downloads tab of the Navigation pane) to automatically dispatch downloaded files to helper applications. For security reasons, this defaults to being off.\
\
\f2\i Plugins
\f1\i0 \
\
\'a5 Shockwave Director content now loads in Chimera.\
\'a5 The Default plugin (which displays when you're missing the plugin for some content) correctly remembers which MIME type you've seen before now.\
\'a5 Context menus for plugins now display correctly, RealPlayer video displays more reliably, and plugins are less likely to draw incorrectly when being scrolled.\
\'a5 The QuickTime plugin now correctly handles more MIME types now.\
\'a5 Fixed various MRJ (Java) plugin issues (but not, as yet, the problem of typing and dragging in applets).\
\
\f2\i Web Page display
\f1\i0 \
\
\'a5 The default resolution was set to 96dpi, to better match other Mac browsers. You may have to adjust your preferred font sizes to compensate.\
\'a5 The User-Agent string now contains \'d3Mach-O\'d3 and \'d2Chimera\'d3 to allow web authors to more accurately identify the browser.\
\'a5 Framesets loaded in background tabs show correctly now\
\'a5 Typing performance in textareas was somewhat improved.\
\'a5 Tabbing to a text field now selects its content.\
\'a5 If JavaScript on a page calls
\f3\fs18 window.close()
\f1\fs24 , we now close just the tab for that page, if there are multiple tabs.\
\'a5 Form controls no longer draw in \'d3bold\'d3\
\'a5 Pages loading in background tabs now show errors if the load fails, as they should.\
\'a5 Chimera now respects the \'d2autocomplete=off\'d3 attribute on web forms, for sites that don't want username/password filling for security reasons.\
\'a5 Fixed an issue with the sizing of form controls when zooming.\
\'a5 Fixed some "smearing" display problems with absolutely-positioned elements.\
\'a5 If you need to see JavaScript errors, you can set a hidden pref ("chimera.log_js_to_console") to have Chimera dump them to the console.\
\
\f2\i Bookmarks
\f1\i0 \
\
\'a5 Command-clicking a toolbar link, or a bookmark in the sidebar will load it in a new tab now.\
\'a5 You can put a bookmark folder in the Dock menu now (do a Get Info on a bookmark folder in Chimera). Mac OS X 10.2 only.\
\'a5 It's now possible to convert a bookmarks tab group to a normal folder, and vice versa (via a checkbox in the bookmark Get Info panel).\
\'a5 You can import Chimera-format bookmarks.xml files.\
\'a5 It's now possible to export bookmarks to an HTML file now (via an item on the application menu)\
\'a5 Site icons (\'d2favicons\'d3) are shown on the bookmarks toolbar now.\
\
\f2\i Networking
\f1\i0 \
\
\'a5 Chimera will now pick up changes made to the system proxy settings (e.g. when you change Locations in the Network System Preferences) without having to be restarted.\
\'a5 Chimera will only show \'d2Connection Refused\'d3 and \'d2Unknown host\'d3 errors for the main page now, rather than images and iframe contents. This helps those using proxy techniques for image blocking.\
\
\f2\i Other Changes
\f1\i0 \
\
\'a5 The Print dialog now has a \'d2Web Browser\'d3 panel that allows you to control the printing of background colors and images, among other options.\
\'a5 Chimera now supports the Services menu in web content.\
\'a5 You can get the URL of the front window via AppleEvents now.\
\'a5 Holding down the Shift key while using the scrollwheel scrolls sideways now.\
\'a5 Fixed an issue with QuickDraw that caused a number of random crashes.\
\'a5 Chimera will now run if your home directory is on a network volume.\
\'a5 Some memory leaks were fixed.\
\'a5 Added the ability to set the preferred minimum font size, in the Advanced panel of the Appearance font prefs.\
\'a5 Fixed an issue where Chimera could use a lot of CPU when waking from sleep.\
\'a5 Chimera is more compatible with the \'d2Metallizer\'d3 haxie now.\
\
\f2\i Known issues
\f1\i0 \
\
\'a5 Shockwave Director content displays at the wrong location in the window, if hardware rendering is enabled.\
\'a5 Typing and dragging in Java applets does not work correctly.\
\'a5 The Windows Media Player plugin is not compatible with Chimera.\
\'a5 If you try to open Chimera's AppleScript dictionary, say from Script Editor, you\'d5ll get an error. To work around this, open the application package, and remove the \'d2Localized.rsrc\'d3 file in Contents/Resources/English.lproj. This will, however, prevent Shockwave Director content from loading so we recommend you do this on a copy of the application.\
\'a5 Issues remain when typing in non-Roman languages; sometimes hitting the Delete key can cause Chimera to go Back, rather than deleting text.\
\
}

Просмотреть файл

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<!-- Contains mappings of character encodings (lowercase) to menu item tags in the Text Encoding menu. -->
<plist version="1.0">
<dict>
<key>iso-8859-1</key>
<integer>10</integer>
<key>x-mac-roman</key>
<integer>11</integer>
<key>iso-2022-jp</key>
<integer>12</integer>
<key>shift_jis</key>
<integer>13</integer>
<key>euc-jp</key>
<integer>14</integer>
<key>big5</key>
<integer>15</integer>
<key>big5-hkscs</key>
<integer>16</integer>
<key>iso-2022-kr</key>
<integer>17</integer>
<key>x-johab</key>
<integer>18</integer>
<key>x-windows-949</key>
<integer>19</integer>
<key>iso-8859-6</key>
<integer>20</integer>
<key>windows-1256</key>
<integer>21</integer>
<key>iso-8859-8</key>
<integer>22</integer>
<key>windows-1255</key>
<integer>23</integer>
<key>iso-8859-7</key>
<integer>24</integer>
<key>windows-1253</key>
<integer>25</integer>
<key>iso-8859-5</key>
<integer>26</integer>
<key>x-mac-cyrillic</key>
<integer>27</integer>
<key>koi8-r</key>
<integer>28</integer>
<key>windows-1251</key>
<integer>29</integer>
<key>tis-620</key>
<integer>30</integer>
<key>gb2312</key>
<integer>31</integer>
<key>x-gbk</key>
<integer>32</integer>
<key>hz-gb-2312</key>
<integer>33</integer>
<key>iso-8859-2</key>
<integer>34</integer>
<key>windows-1250</key>
<integer>35</integer>
<key>iso-8859-4</key>
<integer>36</integer>
<key>windows-1258</key>
<integer>37</integer>
<key>iso-8859-9</key>
<integer>38</integer>
<key>windows-1254</key>
<integer>39</integer>
<key>windows-1257</key>
<integer>40</integer>
<key>utf-8</key>
<integer>41</integer>
</dict>
</plist>

Просмотреть файл

@ -28,7 +28,7 @@
<string>140 644 198 144 0 0 1152 848 </string>
</dict>
<key>IBFramework Version</key>
<string>286.0</string>
<string>291.0</string>
<key>IBGroupedObjects</key>
<dict>
<key>7</key>

Двоичные данные
chimera/resources/localized/English.lproj/BrowserWindow.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Двоичный файл не отображается.

Просмотреть файл

@ -41,6 +41,7 @@
pageSetup = id;
previousTab = id;
printPage = id;
reloadWithCharset = id;
savePage = id;
sendURL = id;
showAboutBox = id;

Просмотреть файл

@ -3,18 +3,18 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>105 33 482 372 0 0 1600 1002 </string>
<string>37 174 482 240 0 0 1152 848 </string>
<key>IBEditorPositions</key>
<dict>
<key>266</key>
<string>644 623 277 90 0 0 1600 1002 </string>
<key>29</key>
<string>11 957 446 44 0 0 1600 1002 </string>
<string>103 790 446 44 0 0 1152 848 </string>
<key>494</key>
<string>117 597 185 48 0 0 1280 1002 </string>
</dict>
<key>IBFramework Version</key>
<string>286.0</string>
<string>291.0</string>
<key>IBGroupedObjects</key>
<dict>
<key>0</key>

Двоичные данные
chimera/resources/localized/English.lproj/MainMenu.nib/objects.nib сгенерированный

Двоичный файл не отображается.

Просмотреть файл

@ -86,15 +86,15 @@ nsDownloadListenerConstructor(nsISupports *aOuter, REFNSIID aIID, void **aResult
static const nsModuleComponentInfo gAppComponents[] = {
{
"Security Dialogs",
"PSM Security Warnings",
NS_SECURITYDIALOGS_CID,
NS_BADCERTLISTENER_CONTRACTID,
NS_SECURITYWARNINGDIALOGS_CONTRACTID,
SecurityDialogsConstructor
},
{
"Security Dialogs",
"Bad Cert Handler",
NS_SECURITYDIALOGS_CID,
NS_SECURITYWARNINGDIALOGS_CONTRACTID,
NS_BADCERTLISTENER_CONTRACTID,
SecurityDialogsConstructor
},
{

Просмотреть файл

@ -89,6 +89,8 @@
SharedMenusObj* mSharedMenusObj;
NetworkServices* mNetworkServices;
NSMutableDictionary* mCharsets;
}
// File menu actions.
@ -127,6 +129,7 @@
-(IBAction) smallerTextSize:(id)aSender;
-(IBAction) viewSource:(id)aSender;
-(IBAction) manageSidebar: (id)aSender;
-(IBAction) reloadWithCharset:(id)aSender;
// Bookmarks menu actions.
-(IBAction) importBookmarks:(id)aSender;

Просмотреть файл

@ -150,6 +150,8 @@ const int kReuseWindowOnAE = 2;
-(void)dealloc
{
[mCharsets release];
// Terminate shared menus
[mSharedMenusObj release];
@ -256,6 +258,10 @@ const int kReuseWindowOnAE = 2;
while ((itemIndex = [mGoMenu indexOfItemWithTag:kRendezvousRelatedItemTag]) != -1)
[mGoMenu removeItemAtIndex:itemIndex];
}
// load up the charset dictionary with keys and menu titles.
NSString* charsetPath = [NSBundle pathForResource:@"Charset" ofType:@"dict" inDirectory:[[NSBundle mainBundle] bundlePath]];
mCharsets = [[NSDictionary dictionaryWithContentsOfFile:charsetPath] retain];
}
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
@ -305,6 +311,9 @@ const int kReuseWindowOnAE = 2;
- (void)setupStartpage
{
// only do this if no url was specified in the command-line
if (mStartURL) return;
// for non-nightly builds, show a special start page
PreferenceManager* prefManager = [PreferenceManager sharedInstance];
@ -535,6 +544,18 @@ const int kReuseWindowOnAE = 2;
[browserController reload: aSender];
}
-(IBAction) reloadWithCharset:(id)aSender
{
// Figure out which charset to tell gecko to load based on the sender's tag. There
// is guaranteed to only be 1 key that matches this tag, so we just take the first one.
BrowserWindowController* browserController = [self getMainWindowBrowserController];
if (browserController) {
NSArray* charsetList = [mCharsets allKeysForObject:[NSNumber numberWithInt:[aSender tag]]];
NS_ASSERTION([charsetList count] == 1, "OOPS, multiply defined charsets in plist");
[browserController reloadWithNewCharset:[charsetList objectAtIndex:0]];
}
}
-(IBAction) doStop:(id)aSender
{
BrowserWindowController* browserController = [self getMainWindowBrowserController];
@ -918,11 +939,34 @@ const int kReuseWindowOnAE = 2;
{
BrowserWindowController* browserController = [self getMainWindowBrowserController];
// Handle the encoding menu first, since there are many of those items. They're
// identifyable because they have a specific tag.
const int kEncodingMenuTag = 10;
if ( [aMenuItem tag] >= kEncodingMenuTag ) {
if ( browserController ) {
NSString* charset = [browserController currentCharset];
#if DEBUG_CHARSET
NSLog(@"charset is %@", charset);
#endif
// given the document's charset, check if it maps to the same int as the
// current item's key. If yes, we select this item because it's our charset.
// Note that this relies on the key in the nib mapping to the right integer
// in the plist.
NSNumber* tag = [mCharsets objectForKey:[charset lowercaseString]];
if ( tag && [[NSNumber numberWithInt:[aMenuItem tag]] isEqualToNumber:tag] )
[aMenuItem setState:NSOnState];
else
[aMenuItem setState:NSOffState];
return YES;
}
return NO;
}
// disable items that aren't relevant if there's no main browser window open
SEL action = [aMenuItem action];
//NSLog(@"MainController validateMenuItem for %@ (%s)", [aMenuItem title], action);
if (action == @selector(printPage:) ||
/* ... many more items go here ... */
/* action == @selector(goHome:) || */ // always enabled
@ -1103,17 +1147,16 @@ const int kReuseWindowOnAE = 2;
- (BOOL)applicationShouldHandleReopen:(NSApplication *)theApp hasVisibleWindows:(BOOL)flag
{
// If AppKit knows what to do, let it.
if (flag)
return YES;
// If window available, wake it up. |mainWindow| should always be null.
NSWindow* mainWindow = [mApplication mainWindow];
if (!mainWindow)
// ignore |hasVisibleWindows| because we always want to show a browser window when
// the user clicks on the app icon, even if, say, prefs or the d/l window are open.
// If there is no browser, create one. If there is one, bring it to the front and
// unminimize it if it's down in the dock.
NSWindow* frontBrowser = [self getFrontmostBrowserWindow];
if ( !frontBrowser )
[self newWindow:self];
else { // Don't think this will ever happen, but just in case
if ([[mainWindow windowController]respondsToSelector:@selector(showWindow:)])
[[mainWindow windowController] showWindow:self];
else {
if ([[frontBrowser windowController] respondsToSelector:@selector(showWindow:)])
[[frontBrowser windowController] showWindow:self];
else
[self newWindow:self];
}

Просмотреть файл

@ -47,9 +47,20 @@ NSGETMODULE(_name) (nsIComponentManager* aCompMgr, \
}
// NSGetModule entry points
DECL_NSGETMODULE(UcharUtil)
DECL_NSGETMODULE(nsUConvModule)
DECL_NSGETMODULE(nsI18nModule)
DECL_NSGETMODULE(nsUCvJAModule)
DECL_NSGETMODULE(nsUCvCnModule)
DECL_NSGETMODULE(nsUCvLatinModule)
DECL_NSGETMODULE(nsUCvTWModule)
DECL_NSGETMODULE(nsUCvTW2Module)
DECL_NSGETMODULE(nsUCvKoModule)
DECL_NSGETMODULE(nsLocaleModule)
DECL_NSGETMODULE(nsStringBundleModule)
DECL_NSGETMODULE(nsLWBrkModule)
DECL_NSGETMODULE(nsCharDetModule)
DECL_NSGETMODULE(xpconnect)
DECL_NSGETMODULE(cacheservice)
DECL_NSGETMODULE(necko_core_and_primary_protocols)
DECL_NSGETMODULE(necko_secondary_protocols)
DECL_NSGETMODULE(nsURILoaderModule)
@ -60,9 +71,14 @@ DECL_NSGETMODULE(nsChromeModule)
DECL_NSGETMODULE(nsRDFModule)
DECL_NSGETMODULE(nsParserModule)
DECL_NSGETMODULE(nsGfxMacModule)
DECL_NSGETMODULE(nsGfx2Module)
DECL_NSGETMODULE(nsImageLib2Module)
DECL_NSGETMODULE(nsPNGDecoderModule)
DECL_NSGETMODULE(nsGIFModule2)
DECL_NSGETMODULE(nsJPEGDecoderModule)
DECL_NSGETMODULE(nsPluginModule)
DECL_NSGETMODULE(javascript__protocol)
DECL_NSGETMODULE(JS_component_loader)
DECL_NSGETMODULE(DOM_components)
DECL_NSGETMODULE(nsViewModule)
DECL_NSGETMODULE(nsWidgetMacModule)
@ -74,6 +90,7 @@ DECL_NSGETMODULE(embedcomponents)
DECL_NSGETMODULE(Browser_Embedding_Module)
DECL_NSGETMODULE(nsEditorModule)
DECL_NSGETMODULE(nsTransactionManagerModule)
DECL_NSGETMODULE(nsTextServicesModule)
DECL_NSGETMODULE(nsProfileModule)
DECL_NSGETMODULE(Session_History_Module)
DECL_NSGETMODULE(application)
@ -89,9 +106,20 @@ DECL_NSGETMODULE(NSS)
*/
static nsStaticModuleInfo gStaticModuleInfo[] = {
#define MODULE(_name) { (#_name), NSGETMODULE(_name) }
MODULE(UcharUtil),
MODULE(nsUConvModule),
MODULE(nsI18nModule),
MODULE(nsUCvJAModule),
MODULE(nsUCvCnModule),
MODULE(nsUCvLatinModule),
MODULE(nsUCvTWModule),
MODULE(nsUCvTW2Module),
MODULE(nsUCvKoModule),
MODULE(nsLocaleModule),
MODULE(nsStringBundleModule),
MODULE(nsLWBrkModule),
MODULE(nsCharDetModule),
MODULE(xpconnect),
MODULE(cacheservice),
MODULE(necko_core_and_primary_protocols),
MODULE(necko_secondary_protocols),
MODULE(nsURILoaderModule),
@ -102,9 +130,14 @@ MODULE(nsChromeModule),
MODULE(nsRDFModule),
MODULE(nsParserModule),
MODULE(nsGfxMacModule),
MODULE(nsGfx2Module),
MODULE(nsImageLib2Module),
MODULE(nsPNGDecoderModule),
MODULE(nsGIFModule2),
MODULE(nsJPEGDecoderModule),
MODULE(nsPluginModule),
MODULE(javascript__protocol),
MODULE(JS_component_loader),
MODULE(DOM_components),
MODULE(nsViewModule),
MODULE(nsWidgetMacModule),
@ -116,6 +149,7 @@ MODULE(embedcomponents),
MODULE(Browser_Embedding_Module),
MODULE(nsEditorModule),
MODULE(nsTransactionManagerModule),
MODULE(nsTextServicesModule),
MODULE(nsProfileModule),
MODULE(Session_History_Module),
MODULE(application),

Просмотреть файл

@ -41,6 +41,7 @@
#define BookmarksExport_h__
#include "nsString.h"
#include "nsIDOMDocument.h"
#include "nsIOutputStream.h"
#include "nsCOMPtr.h"

Просмотреть файл

@ -47,11 +47,12 @@
#include "nsILocalFile.h"
#include "nsILocalFileMac.h"
#include "nsIOutputStream.h"
#include "nsIAtom.h"
#include "nsNetUtil.h"
#include "nsIDOMElement.h"
#include "nsIDOMDocument.h"
#include "nsIContent.h"
#include "nsIAtom.h"
/*
Netscape HTML bookmarks format is:

Просмотреть файл

@ -658,11 +658,10 @@ BookmarksService::SaveBookmarksToFile(const nsAString& inFileName)
rv = NS_NewLocalFileOutputStream(getter_AddRefs(outputStream), bookmarksTempFile);
if (NS_FAILED(rv)) return rv;
PRUint32 bytesWritten = 0;
if (writeDocType)
{
const char* const kDocTypeString = "<!DOCTYPE bookmarks SYSTEM \"http://www.mozilla.org/DTDs/ChimeraBookmarks.dtd\">\n";
PRUint32 bytesWritten = 0;
rv = outputStream->Write(kDocTypeString, strlen(kDocTypeString), &bytesWritten);
if (NS_FAILED(rv)) return rv;
}

Просмотреть файл

@ -81,13 +81,14 @@
- (void) closePopup;
- (void) resizePopup;
- (BOOL) isOpen;
- (BOOL) userHasTyped;
- (void) onRowClicked:(NSNotification *)aNote;
- (void) onBlur:(NSNotification *)aNote;
- (void) onResize:(NSNotification *)aNote;
- (void) onUndoOrRedo:(NSNotification *)aNote;
- (void) setStringUndoably:(NSString*)aString fromLocation:(unsigned int)aLocation;
- (void) setURI:(NSString*)aURI;
- (id) fieldEditor;
@end

Просмотреть файл

@ -54,7 +54,6 @@ class AutoCompleteListener : public nsIAutoCompleteListener
public:
AutoCompleteListener(AutoCompleteTextField* aTextField)
{
NS_INIT_ISUPPORTS();
mTextField = aTextField;
}
@ -79,6 +78,7 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
////////////////////////////////////////////////////////////////////////
@interface AutoCompleteTextField(Private)
- (void)cleanup;
- (void) setStringUndoably:(NSString*)aString fromLocation:(unsigned int)aLocation;
@end
@implementation AutoCompleteTextField
@ -372,6 +372,18 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
return [mPopupWin isVisible];
}
//
// -userHasTyped
//
// Returns whether the user has typed anything into the url bar since the last
// time the url was set (by loading a page). We know this is the case by looking
// at if there is a search string.
//
- (BOOL) userHasTyped
{
return ( mSearchString != nil );
}
// url completion ////////////////////////////
- (void) completeDefaultResult
@ -447,6 +459,25 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
}
}
//
// -setURI
//
// the public way to change the url string so that it does the right thing for handling
// autocomplete and completions in progress
//
- (void) setURI:(NSString*)aURI
{
// if the urlbar has focus (actually if its field editor has focus), we
// need to use one of its routines to update the autocomplete status or
// we could find ourselves with stale results and the popup still open. If
// it doesn't have focus, we can bypass all that and just use normal routines.
if ( [[self window] firstResponder] == [self fieldEditor] )
[self setStringUndoably:aURI fromLocation:0]; // updates autocomplete correctly
else
[self setStringValue:aURI];
}
- (void) setStringUndoably:(NSString *)aString fromLocation:(unsigned int)aLocation
{
NSTextView *fieldEditor = [self fieldEditor];
@ -554,16 +585,23 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
- (void)controlTextDidChange:(NSNotification *)aNote
{
NSTextView *fieldEditor = [[aNote userInfo] objectForKey:@"NSFieldEditor"];
// we are here either because the user is typing or they are selecting
// an item in the autocomplete popup. When they are typing, the location of
// the selection will be non-zero (wherever the insertion point is). When
// they autocomplete, the length and the location will both be zero.
// We use this info in the following way: if they are typing or backspacing,
// restart the search and no longer use the selection in the popup.
NSRange range = [fieldEditor selectedRange];
// make sure we're typing at the end of the string
if (range.location == [[fieldEditor string] length]) {
NSString* currentText = [fieldEditor string];
if ([currentText length] && range.location) {
// when we ask for a NSTextView string, Cocoa returns
// a pointer to the view's backing store. So, the value
// of the string continually changes as we edit the text view.
// Since we'll edit the text view as we add in autocomplete results,
// we've got to make a copy of the string as it currently stands
// to know what we were searching for in the first place.
NSString *searchString = [[fieldEditor string] copyWithZone:nil];
NSString *searchString = [currentText copyWithZone:nil];
[self startSearch:searchString complete:!mBackspaced];
[searchString release];
}
@ -575,7 +613,7 @@ NS_IMPL_ISUPPORTS1(AutoCompleteListener, nsIAutoCompleteListener)
- (void)controlTextDidEndEditing:(NSNotification *)aNote
{
[self closePopup];
[self clearResults];
[[[[aNote userInfo] objectForKey:@"NSFieldEditor"] undoManager] removeAllActions];
}

Просмотреть файл

@ -130,6 +130,12 @@
- (void)removeTabViewItem:(NSTabViewItem *)tabViewItem
{
// the normal behavior of the tab widget is to select the tab to the left
// of the tab being removed. Users, however, want the tab to the right to
// be selected. This also matches how mozilla works. Select the right tab
// first so we don't take the hit of displaying the left tab before we switch.
if ( [self selectedTabViewItem] == tabViewItem )
[self selectNextTabViewItem:self];
[super removeTabViewItem:tabViewItem];
[self showOrHideTabsAsAppropriate];
}

Просмотреть файл

@ -93,6 +93,7 @@ typedef enum
@class PageProxyIcon;
@class BrowserContentView;
@class BrowserTabViewItem;
@class AutoCompleteTextField;
@interface BrowserWindowController : NSWindowController<Find>
{
@ -101,7 +102,7 @@ typedef enum
IBOutlet NSTabView* mSidebarTabView;
IBOutlet NSTabView* mSidebarSourceTabView;
IBOutlet NSView* mLocationToolbarView;
IBOutlet NSTextField* mURLBar;
IBOutlet AutoCompleteTextField* mURLBar;
IBOutlet NSTextField* mStatus;
IBOutlet NSProgressIndicator* mProgress; // STRONG reference
IBOutlet NSImageView* mLock;
@ -258,6 +259,9 @@ typedef enum
- (IBAction)stop:(id)aSender;
- (IBAction)home:(id)aSender;
- (IBAction)reloadWithNewCharset:(NSString*)charset;
- (NSString*)currentCharset;
- (IBAction)frameToNewWindow:(id)sender;
- (IBAction)frameToNewTab:(id)sender;
- (IBAction)frameToThisWindow:(id)sender;

Просмотреть файл

@ -47,6 +47,7 @@
#import "BrowserTabView.h"
#import "UserDefaults.h"
#import "PageProxyIcon.h"
#import "AutoCompleteTextField.h"
#include "nsIWebNavigation.h"
#include "nsIDOMDocument.h"
@ -1316,16 +1317,9 @@ static NSArray* sToolbarDefaults = nil;
- (void)updateLocationFields:(NSString *)locationString
{
if ( [locationString isEqual:@"about:blank"] )
locationString = @"";
locationString = @""; // return;
// if the urlbar has focus (actually if its field editor has focus), we
// need to use one of its routines to update the autocomplete status or
// we could find ourselves with stale results and the popup still open. If
// it doesn't have focus, we can bypass all that and just use normal routines.
if ( [[self window] firstResponder] == [mURLBar fieldEditor] )
[mURLBar setStringUndoably:locationString fromLocation:0]; // updates autocomplete correctly
else
[mURLBar setStringValue:locationString];
[mURLBar setURI:locationString];
[mLocationSheetURLField setStringValue:locationString];
// don't call [window display] here, no matter how much you might want
@ -1619,10 +1613,13 @@ static NSArray* sToolbarDefaults = nil;
[newTab setLabel: NSLocalizedString(@"TabLoading", @"")];
[newView loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone activate:!aLoadInBG];
// unless we're told to load this tab in the bg, select the tab
// before we load so that it's the primary and will push the url into
// the url bar immediately rather than waiting for the server.
if (!aLoadInBG)
[mTabBrowser selectTabViewItem: newTab];
[newView loadURI:aURLSpec referrer:aReferrer flags:NSLoadFlagsNone activate:!aLoadInBG];
}
- (void)openTabGroup:(NSArray*)urlArray replaceExistingTabs:(BOOL)replaceExisting
@ -1815,8 +1812,11 @@ static NSArray* sToolbarDefaults = nil;
{
menuPrototype = mImageMenu;
}
else if ((mContextMenuFlags & nsIContextMenuListener::CONTEXT_DOCUMENT) != 0)
else if (!mContextMenuFlags || (mContextMenuFlags & nsIContextMenuListener::CONTEXT_DOCUMENT) != 0)
{
// if there aren't any flags or we're in the background of a page,
// show the document menu. This prevents us from failing to find a case
// and not showing the context menu.
menuPrototype = mPageMenu;
[mBackItem setEnabled: [[mBrowserView getBrowserView] canGoBack]];
[mForwardItem setEnabled: [[mBrowserView getBrowserView] canGoForward]];
@ -2056,7 +2056,7 @@ static NSArray* sToolbarDefaults = nil;
BOOL oldResponderIsGecko = [self isResponderGeckoView:oldResponder];
BOOL newResponderIsGecko = [self isResponderGeckoView:newResponder];
if (oldResponderIsGecko != newResponderIsGecko)
if (oldResponderIsGecko != newResponderIsGecko && [[self window] isKeyWindow])
[[mBrowserView getBrowserView] setActive:newResponderIsGecko];
}
@ -2088,6 +2088,18 @@ static NSArray* sToolbarDefaults = nil;
return nil;
}
- (IBAction)reloadWithNewCharset:(NSString*)charset
{
[mBrowserView reloadWithNewCharset:charset];
}
- (NSString*)currentCharset
{
return [mBrowserView currentCharset];
}
@end
#pragma mark -

Просмотреть файл

@ -40,10 +40,11 @@
@class BrowserWindowController;
@class ToolTip;
@class AutoCompleteTextField;
@interface BrowserWrapper : NSView <CHBrowserListener, CHBrowserContainer>
{
NSTextField* mUrlbar;
AutoCompleteTextField* mUrlbar;
NSTextField* mStatus;
BrowserWindowController* mWindowController;
NSTabViewItem* mTabItem;
@ -98,6 +99,9 @@
- (void)setTab: (NSTabViewItem*)tab;
- (NSTabViewItem*) tab;
- (IBAction)reloadWithNewCharset:(NSString*)charset;
- (NSString*)currentCharset;
- (NSWindow*)getNativeWindow;
- (NSMenu*)getContextMenu;
- (void)setIsBookmarksImport:(BOOL)aIsImport;

Просмотреть файл

@ -46,6 +46,7 @@
#import "ToolTip.h"
#import "PageProxyIcon.h"
#import "KeychainService.h"
#import "AutoCompleteTextField.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
@ -64,8 +65,6 @@
#include "nsIPrefService.h"
#include "CHBrowserService.h"
#include "nsIWebProgressListener.h"
#include "nsIFocusController.h"
#include "nsIDOMWindowInternal.h"
#include <QuickDraw.h>
@ -241,7 +240,7 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
// update the window's title.
[self setTabTitle:mTabTitle windowTitle:mTitle];
if ([[self window] isKeyWindow])
if ([[self window] isKeyWindow] && ![mUrlbar userHasTyped])
[mBrowserView setActive: YES];
nsCOMPtr<nsIIOService> ioService(do_GetService(ioServiceContractID));
@ -257,9 +256,12 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
name:kOfflineNotificationName
object:nil];
// Update the URL bar.
[mWindowController updateLocationFields:[self getCurrentURLSpec]];
[mWindowController updateSiteIcons:mSiteIconImage];
// Update the URL bar, but only if the user hasn't put something of their
// own in there.
if (![mUrlbar userHasTyped]) {
[mWindowController updateLocationFields:[self getCurrentURLSpec]];
[mWindowController updateSiteIcons:mSiteIconImage];
}
if (mWindowController && !mListenersAttached)
{
@ -309,6 +311,11 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
- (void)loadURI:(NSString *)urlSpec referrer:(NSString*)referrer flags:(unsigned int)flags activate:(BOOL)activate
{
// blast it into the urlbar immediately so that we know what we're
// trying to load, even if it doesn't work
if (mIsPrimary)
[mWindowController updateLocationFields:urlSpec];
mActivateOnLoad = activate;
[mBrowserView loadURI:urlSpec referrer:referrer flags:flags];
}
@ -343,25 +350,14 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
{
if (mActivateOnLoad) {
// if we're the front/key window, focus the content area. If we're not,
// tell the focus controller that the content area should be focused when
// we do finally become the key window
if ( [NSApp keyWindow] == [mBrowserView window] )
[mBrowserView setActive:YES];
else {
nsCOMPtr<nsIDOMWindow> domWindow;
nsCOMPtr<nsIWebBrowser> webBrowser = getter_AddRefs([mBrowserView getWebBrowser]);
if ( webBrowser ) {
webBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
if ( domWindow ) {
nsCOMPtr<nsPIDOMWindow> piWindow ( do_QueryInterface(domWindow) );
nsCOMPtr<nsIFocusController> controller;
piWindow->GetRootFocusController(getter_AddRefs(controller));
if ( controller ) {
nsCOMPtr<nsIDOMWindowInternal> windowInt ( do_QueryInterface(domWindow) );
controller->SetFocusedWindow(windowInt);
}
}
}
// set gecko as the first responder so that it will be activated when
// the window is focused. If the user is typing in the urlBar, however,
// don't mess with the focus at all.
if ( ![mUrlbar userHasTyped] ) {
if ( [[mBrowserView window] isKeyWindow] )
[mBrowserView setActive:YES];
else
[[mBrowserView window] makeFirstResponder:mBrowserView];
}
mActivateOnLoad = NO;
}
@ -445,7 +441,8 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
if (!siteIconLoadInitiated)
[self updateSiteIconImage:nil withURI:faviconURI];
if (mIsPrimary)
// if the user has started typing something, don't destroy it
if (mIsPrimary && ![mUrlbar userHasTyped])
[mWindowController updateLocationFields:urlSpec];
}
@ -848,4 +845,16 @@ const NSString* kOfflineNotificationName = @"offlineModeChanged";
return [[[self getBrowserView] getCurrentURI] isEqualToString:@"about:blank"];
}
- (IBAction)reloadWithNewCharset:(NSString*)charset
{
[[self getBrowserView] reloadWithNewCharset:charset];
}
- (NSString*)currentCharset
{
return [[self getBrowserView] currentCharset];
}
@end

Просмотреть файл

@ -41,6 +41,7 @@
#include "nsIStringBundle.h"
#include "nsIPromptService.h"
#include "nsCOMPtr.h"
#import <Cocoa/Cocoa.h>
class CocoaPromptService : public nsIPromptService

Просмотреть файл

@ -271,7 +271,7 @@ int KeychainPrefChangedCallback(const char* inPref, void* unused)
//
attr.tag = kAccountKCItemAttr;
attr.data = (char*)[username UTF8String];
attr.length = strlen(attr.data);
attr.length = strlen(NS_REINTERPRET_CAST(const char*, attr.data));
status = KCSetAttribute(inItemRef, &attr);
if(status != noErr)
NSLog(@"Couldn't update keychain item account");
@ -522,7 +522,6 @@ NS_IMPL_ISUPPORTS2(KeychainPrompt,
KeychainPrompt::KeychainPrompt()
{
NS_INIT_ISUPPORTS();
}
KeychainPrompt::~KeychainPrompt()
@ -532,14 +531,15 @@ KeychainPrompt::~KeychainPrompt()
//
// TODO: add support for ftp username/password. The given realm for
// an ftp server has the form ftp://<username>@<server>/<path>, see
// netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp.
// TODO: add support for ftp username/password.
//
// Get server name and port from the realm ("hostname:port (realm)",
// see nsHttpChannel.cpp). we can't use CFURL routines or nsIURI
// routines because they require a protocol, and we don't have one.
//
// The given realm for an ftp server has the form ftp://<username>@<server>/<path>, see
// netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp).
//
void
KeychainPrompt::ExtractHostAndPort(const PRUnichar* inRealm, NSString** outHost, PRInt32* outPort)
{
@ -548,20 +548,40 @@ KeychainPrompt::ExtractHostAndPort(const PRUnichar* inRealm, NSString** outHost,
*outHost = @"";
*outPort = kAnyPort;
// strip off the "(realm)" part
NSString* realmStr = [NSString stringWithPRUnichars:inRealm];
NSRange firstParen = [realmStr rangeOfString:@"("];
if ( firstParen.location == NSNotFound )
firstParen.location = [realmStr length];
realmStr = [realmStr substringToIndex:firstParen.location-1];
// separate the host and the port
NSRange endOfHost = [realmStr rangeOfString:@":"];
if ( endOfHost.location == NSNotFound )
*outHost = realmStr;
// first check for an ftp url and pull out the server from the realm
if ( [realmStr rangeOfString:@"ftp://"].location != NSNotFound ) {
// cut out ftp://
realmStr = [realmStr substringFromIndex:strlen("ftp://")];
// cut out any of the path
NSRange pathDelimeter = [realmStr rangeOfString:@"/"];
if ( pathDelimeter.location != NSNotFound )
realmStr = [realmStr substringToIndex:pathDelimeter.location-1];
// now we're left with "username@server" with username being optional
NSRange usernameMarker = [realmStr rangeOfString:@"@"];
if ( usernameMarker.location != NSNotFound )
*outHost = [realmStr substringFromIndex:usernameMarker.location+1];
else
*outHost = realmStr;
}
else {
*outHost = [realmStr substringToIndex:endOfHost.location];
*outPort = [[realmStr substringFromIndex:endOfHost.location+1] intValue];
// we're an http url, strip off the "(realm)" part
NSRange firstParen = [realmStr rangeOfString:@"("];
if ( firstParen.location == NSNotFound )
firstParen.location = [realmStr length];
realmStr = [realmStr substringToIndex:firstParen.location-1];
// separate the host and the port
NSRange endOfHost = [realmStr rangeOfString:@":"];
if ( endOfHost.location == NSNotFound )
*outHost = realmStr;
else {
*outHost = [realmStr substringToIndex:endOfHost.location];
*outPort = [[realmStr substringFromIndex:endOfHost.location+1] intValue];
}
}
}
@ -712,7 +732,6 @@ NS_IMPL_ISUPPORTS2(KeychainFormSubmitObserver,
KeychainFormSubmitObserver::KeychainFormSubmitObserver()
{
NS_INIT_ISUPPORTS();
//NSLog(@"Keychain form submit observer created.");
}
@ -755,7 +774,9 @@ KeychainFormSubmitObserver::Notify(nsIContent* node, nsIDOMWindowInternal* windo
passwordElement->GetValue(pword);
NSString* username = [NSString stringWith_nsAString:uname];
NSString* password = [NSString stringWith_nsAString:pword];
if ( ![username length] || ![password length] ) // bail if either is empty
return NS_OK;
nsCOMPtr<nsIDocument> doc;
node->GetDocument(*getter_AddRefs(doc));
if (!doc)
@ -950,8 +971,16 @@ KeychainFormSubmitObserver::CheckChangeDataYN(nsIDOMWindowInternal* window)
[username assignTo_nsAString:user];
[password assignTo_nsAString:pwd];
rv = usernameElement->SetValue(user);
rv = passwordElement->SetValue(pwd);
// if the server specifies a value attribute (bug 169760), only autofill
// the password if what we have in keychain matches what the server supplies,
// otherwise don't. Don't bother checking the password field for a value; i can't
// imagine the server ever prefilling a password
nsAutoString userValue;
usernameElement->GetAttribute(NS_LITERAL_STRING("value"), userValue);
if (!userValue.Length() || userValue.Equals(user)) {
rv = usernameElement->SetValue(user);
rv = passwordElement->SetValue(pwd);
}
}
// We found the sign-in form so return now. This means we don't
@ -1015,6 +1044,13 @@ FindUsernamePasswordFields(nsIDOMHTMLFormElement* inFormElement, nsIDOMHTMLInput
return NS_ERROR_FAILURE;
*outUsername = *outPassword = nsnull;
// pages can specify that they don't want autofill by setting a
// "autocomplete=off" attribute on the form.
nsAutoString autocomplete;
inFormElement->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
if ( autocomplete.EqualsIgnoreCase("off") )
return NS_OK;
//
// Search the form the password field and the preceding text field
// We are only interested in signon forms, so we require
@ -1056,6 +1092,9 @@ FindUsernamePasswordFields(nsIDOMHTMLFormElement* inFormElement, nsIDOMHTMLInput
bool isText = (type.IsEmpty() || type.Equals(NS_LITERAL_STRING("text"), nsCaseInsensitiveStringComparator()));
bool isPassword = type.Equals(NS_LITERAL_STRING("password"), nsCaseInsensitiveStringComparator());
inputElement->GetAttribute(NS_LITERAL_STRING("autocomplete"), autocomplete);
if ( autocomplete.EqualsIgnoreCase("off") )
isPassword = false;
if(!isText && !isPassword)
continue;

Просмотреть файл

@ -195,6 +195,7 @@ nsresult RemoteURILoadManager::RequestURILoad(const nsAString& inURI, id<RemoteL
nsLoadFlags loadFlags = (allowNetworking) ? nsIRequest::LOAD_NORMAL : nsIRequest::LOAD_FROM_CACHE;
loadFlags |= nsIRequest::LOAD_BACKGROUND; // don't show progress or cookie dialogs
if (!allowNetworking)
loadFlags |= nsICachingChannel::LOAD_ONLY_FROM_CACHE;
@ -204,7 +205,7 @@ nsresult RemoteURILoadManager::RequestURILoad(const nsAString& inURI, id<RemoteL
rv = NS_NewChannel(getter_AddRefs(channel), uri, nsnull, mLoadGroup,
nsnull, loadFlags);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIStreamLoader> streamLoader;
rv = NS_NewStreamLoader(getter_AddRefs(streamLoader), channel, this, loaderContext) ; // , mLoadGroup, nsnull, loadFlags);
if (NS_FAILED(rv))

Просмотреть файл

@ -52,12 +52,12 @@ public:
virtual ~SecurityDialogs();
NS_DECL_ISUPPORTS;
NS_DECL_NSIBADCERTLISTENER
NS_DECL_NSISECURITYWARNINGDIALOGS
NS_DECL_NSIBADCERTLISTENER;
NS_DECL_NSISECURITYWARNINGDIALOGS;
private:
nsresult EnsureSecurityStringBundle();
nsresult AlertDialog(nsIInterfaceRequestor* ctx, const char* prefName,
const PRUnichar* messageName,
const PRUnichar* showAgainName);

Просмотреть файл

@ -57,12 +57,11 @@ SecurityDialogs::~SecurityDialogs()
{
}
NS_IMPL_ISUPPORTS2(SecurityDialogs, nsIBadCertListener, nsISecurityWarningDialogs)
NS_IMPL_ISUPPORTS2(SecurityDialogs, nsIBadCertListener, nsISecurityWarningDialogs);
// nsIBadCertListener implementation
/* boolean confirmUnknownIssuer (in nsIInterfaceRequestor socketInfo,
in nsIX509Cert cert,
out short certAddType); */
in nsIX509Cert cert, out addType); */
NS_IMETHODIMP
SecurityDialogs::ConfirmUnknownIssuer(nsIInterfaceRequestor *socketInfo,
nsIX509Cert *cert, PRInt16 *outAddType,
@ -148,9 +147,11 @@ SecurityDialogs::NotifyCrlNextupdate(nsIInterfaceRequestor *socketInfo,
#define MIXEDCONTENT_PREF "security.warn_viewing_mixed"
#define INSECURE_SUBMIT_PREF "security.warn_submit_insecure"
// XXXbryner should we make these real confirmation dialogs?
NS_IMETHODIMP
SecurityDialogs::ConfirmEnteringSecure(nsIInterfaceRequestor *ctx,
PRBool *canceled)
PRBool *_retval)
{
// I don't think any user cares they're entering a secure site.
#if 0
@ -159,15 +160,15 @@ SecurityDialogs::ConfirmEnteringSecure(nsIInterfaceRequestor *ctx,
NS_LITERAL_STRING("EnterSecureShowAgain").get());
#endif
*canceled = PR_FALSE;
*_retval = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
SecurityDialogs::ConfirmEnteringWeak(nsIInterfaceRequestor *ctx,
PRBool *canceled)
PRBool *_retval)
{
*canceled = PR_FALSE;
*_retval = PR_TRUE;
return AlertDialog(ctx, WEAK_SITE_PREF,
NS_LITERAL_STRING("WeakSecureMessage").get(),
NS_LITERAL_STRING("WeakSecureShowAgain").get());
@ -175,9 +176,9 @@ SecurityDialogs::ConfirmEnteringWeak(nsIInterfaceRequestor *ctx,
NS_IMETHODIMP
SecurityDialogs::ConfirmLeavingSecure(nsIInterfaceRequestor *ctx,
PRBool *canceled)
PRBool *_retval)
{
*canceled = PR_FALSE;
*_retval = PR_TRUE;
return AlertDialog(ctx, LEAVE_SITE_PREF,
NS_LITERAL_STRING("LeaveSecureMessage").get(),
NS_LITERAL_STRING("LeaveSecureShowAgain").get());
@ -185,9 +186,9 @@ SecurityDialogs::ConfirmLeavingSecure(nsIInterfaceRequestor *ctx,
NS_IMETHODIMP
SecurityDialogs::ConfirmMixedMode(nsIInterfaceRequestor *ctx, PRBool *canceled)
SecurityDialogs::ConfirmMixedMode(nsIInterfaceRequestor *ctx, PRBool *_retval)
{
*canceled = PR_FALSE;
*_retval = PR_TRUE;
return AlertDialog(ctx, MIXEDCONTENT_PREF,
NS_LITERAL_STRING("MixedContentMessage").get(),
NS_LITERAL_STRING("MixedContentShowAgain").get());

Просмотреть файл

@ -39,44 +39,13 @@
@interface nsAlertController : NSObject
{
IBOutlet id alertCheckPanel;
IBOutlet id alertCheckPanelCheck;
IBOutlet id alertCheckPanelText;
IBOutlet id alertPanel;
IBOutlet id alertPanelText;
IBOutlet id confirmCheckPanel;
IBOutlet id confirmCheckPanelCheck;
IBOutlet id confirmCheckPanelText;
IBOutlet id confirmCheckPanelButton1;
IBOutlet id confirmCheckPanelButton2;
IBOutlet id confirmPanel;
IBOutlet id confirmPanelText;
IBOutlet id confirmPanelButton1;
IBOutlet id confirmPanelButton2;
IBOutlet id promptPanel;
IBOutlet id promptPanelCheck;
IBOutlet id promptPanelText;
IBOutlet id promptPanelInput;
IBOutlet id passwordPanel;
IBOutlet id passwordPanelCheck;
IBOutlet id passwordPanelText;
IBOutlet id passwordPanelInput;
IBOutlet id postToInsecureFromSecurePanel;
IBOutlet id securityMismatchPanel;
IBOutlet id expiredCertPanel;
IBOutlet id securityUnknownPanel;
IBOutlet id usernamePanel;
IBOutlet id usernamePanelCheck;
IBOutlet id usernamePanelText;
IBOutlet id usernamePanelPassword;
IBOutlet id usernamePanelUserName;
IBOutlet id owner;
// all dialogs are now created on the fly and sized to fit
}
- (IBAction)hitButton1:(id)sender;
- (IBAction)hitButton2:(id)sender;
- (IBAction)hitButton3:(id)sender;
- (void)awakeFromNib;
- (void)alert:(NSWindow*)parent title:(NSString*)title text:(NSString*)text;
- (void)alertCheck:(NSWindow*)parent title:(NSString*)title text:(NSString*)text checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue;

Просмотреть файл

@ -42,6 +42,79 @@
enum { kOKButton = 0, kCancelButton = 1, kOtherButton = 2 };
const int kMinDialogWidth = 500;
const int kMaxDialogHeight = 400;
const int kMinDialogHeight = 130;
const int kIconSize = 64;
const int kWindowBorder = 20;
const int kIconMargin = 16; // space between the icon and text content
const int kButtonMinWidth = 82;
const int kButtonMaxWidth = 200;
const int kButtonHeight = 32;
const int kButtonRightMargin = 14; // space between right edge of button and window
const int kButtonBottomMargin = 12; // space between bottom edge of button and window
const int kGeneralViewSpace = 9; // space between one view and another (vertically)
const int kViewButtonSpace = 16; // space between the bottom view and the buttons
const int kMaxFieldHeight = 100;
const int kCheckBoxWidth = 20;
const int kCheckBoxHeight = 18;
const int kTextFieldHeight = 19;
const int kStaticTextFieldHeight = 14; // height of non-editable non-bordered text fields
const int kFieldLabelSpacer = 4; // space between a static label and an editabe text field (horizontal)
const int kOtherAltButtonSpace = 25; // minimum space between the 'other' and 'alternate' buttons
const int kButtonEndCapWidth = 14;
const int kLabelCheckboxAdjustment = 2; // # pixels the label must be pushed down to line up with checkbox
//
// QDCoordsView
//
// A view that uses the QD coordinate space (top left is (0,0))
//
@interface QDCoordsView : NSView
{
}
@end
@implementation QDCoordsView
- (BOOL) isFlipped
{
return YES;
}
@end
#pragma mark -
@interface nsAlertController (nsAlertControllerPrivateMethods)
- (NSPanel*)getAlertPanelWithTitle:(NSString*)title
message:(NSString*)message
defaultButton:(NSString*)defaultLabel
altButton:(NSString*)altLabel
otherButton:(NSString*)otherLabel
extraView:(NSView*)extraView
lastResponder:(NSView*)lastResponder;
- (NSButton*)makeButtonWithTitle:(NSString*)title;
- (float)getContentWidthWithDefaultButton:(NSString*)defStr alternateButton:(NSString*)altStr otherButton:(NSString*)otherStr;
- (NSTextField*)getTitleView:(NSString*)title withWidth:(float)width;
- (NSTextField*)getLabelView:(NSString*)title withWidth:(float)width;
- (NSView*)getLoginField:(NSTextField**)field withWidth:(float)width;
- (NSView*)getPasswordField:(NSSecureTextField**)field withWidth:(float)width;
- (int)getLoginTextLabelSize;
- (NSView*)getMessageView:(NSString*)message withWidth:(float)width maxHeight:(float)maxHeight smallFont:(BOOL)useSmallFont;
- (NSView*)getCheckboxView:(NSButton**)checkBox withLabel:(NSString*)label andWidth:(float)width;
-(void)tester:(id)sender;
@end
#pragma mark -
@implementation nsAlertController
- (IBAction)hitButton1:(id)sender
@ -59,239 +132,283 @@ enum { kOKButton = 0, kCancelButton = 1, kOtherButton = 2 };
[NSApp stopModalWithCode:kOtherButton];
}
- (void)awakeFromNib
{
CHBrowserService::SetAlertController(self);
}
- (void)alert:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
{
[alertPanelText setStringValue:text];
[alertPanel setTitle:title];
[NSApp runModalForWindow:alertPanel relativeToWindow:parent];
[alertPanel close];
{
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: NSLocalizedString(@"OKButtonText", @"") altButton: nil otherButton: nil extraView: nil lastResponder:nil];
[NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
}
- (void)alertCheck:(NSWindow*)parent title:(NSString*)title text:(NSString*)text checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
{
[alertCheckPanelText setStringValue:text];
[alertCheckPanel setTitle:title];
// set up check box view
NSButton* checkBox = nil;
float width = [self getContentWidthWithDefaultButton: NSLocalizedString(@"OKButtonText", @"") alternateButton: nil otherButton: nil];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
int state = (*checkValue ? NSOnState : NSOffState);
[alertCheckPanelCheck setState:state];
[alertCheckPanelCheck setTitle:checkMsg];
[checkBox setState:state];
// get panel and display it
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: NSLocalizedString(@"OKButtonText", @"") altButton: nil otherButton: nil extraView: checkboxView lastResponder: checkBox];
[panel setInitialFirstResponder: checkBox];
[NSApp runModalForWindow:alertCheckPanel relativeToWindow:parent];
*checkValue = ([alertCheckPanelCheck state] == NSOnState);
[alertCheckPanel close];
[NSApp runModalForWindow: panel relativeToWindow:parent];
*checkValue = ([checkBox state] == NSOnState);
[panel close];
}
- (BOOL)confirm:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
{
[confirmPanelText setStringValue:text];
[confirmPanel setTitle:title];
int result = [NSApp runModalForWindow:confirmPanel relativeToWindow:parent];
[confirmPanel close];
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: NSLocalizedString(@"OKButtonText", @"") altButton: NSLocalizedString(@"CancelButtonText", @"") otherButton: nil extraView: nil lastResponder: nil];
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
return (result == kOKButton);
}
- (BOOL)confirmCheck:(NSWindow*)parent title:(NSString*)title text:(NSString*)text checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
{
[confirmCheckPanelText setStringValue:text];
[confirmCheckPanel setTitle:title];
// get button titles
NSString* okButton = NSLocalizedString(@"OKButtonText", @"");
NSString* cancelButton = NSLocalizedString(@"CancelButtonText", @"");
// set up check box view
NSButton* checkBox = nil;
float width = [self getContentWidthWithDefaultButton: okButton alternateButton: cancelButton otherButton: nil];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
int state = (*checkValue ? NSOnState : NSOffState);
[confirmCheckPanelCheck setState:state];
[confirmCheckPanelCheck setTitle:checkMsg];
[checkBox setState:state];
// get panel and display it
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: okButton altButton: cancelButton otherButton: nil extraView: checkboxView lastResponder: checkBox];
[panel setInitialFirstResponder: checkBox];
int result = [NSApp runModalForWindow:confirmCheckPanel relativeToWindow:parent];
*checkValue = ([confirmCheckPanelCheck state] == NSOnState);
[confirmCheckPanel close];
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
*checkValue = ([checkBox state] == NSOnState);
[panel close];
return (result == kOKButton);
}
- (int)confirmEx:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
button1:(NSString*)btn1 button2:(NSString*)btn2 button3:(NSString*)btn3
- (int)confirmEx:(NSWindow*)parent title:(NSString*)title text:(NSString*)text button1:(NSString*)btn1 button2:(NSString*)btn2 button3:(NSString*)btn3
{
[confirmPanelText setStringValue:text];
[confirmPanel setTitle:title];
[confirmPanelButton1 setTitle:btn1];
[confirmPanelButton2 setTitle:btn2];
int result = [NSApp runModalForWindow:confirmPanel relativeToWindow:parent];
[confirmPanel close];
return result;
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: btn1 altButton: btn2 otherButton: btn3 extraView: nil lastResponder: nil];
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
return result;
}
- (int)confirmCheckEx:(NSWindow*)parent title:(NSString*)title text:(NSString*)text
button1:(NSString*)btn1 button2:(NSString*)btn2 button3:(NSString*)btn3
checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
- (int)confirmCheckEx:(NSWindow*)parent title:(NSString*)title text:(NSString*)text button1:(NSString*)btn1 button2:(NSString*)btn2 button3:(NSString*)btn3 checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue
{
[confirmCheckPanelText setStringValue:text];
[confirmCheckPanel setTitle:title];
// set up check box view
NSButton* checkBox = nil;
float width = [self getContentWidthWithDefaultButton: btn1 alternateButton: btn2 otherButton: btn3];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
int state = (*checkValue ? NSOnState : NSOffState);
[confirmCheckPanelCheck setState:state];
[confirmCheckPanelCheck setTitle:checkMsg];
[confirmCheckPanelButton1 setTitle:btn1];
[confirmCheckPanelButton2 setTitle:btn2];
[checkBox setState:state];
int result = [NSApp runModalForWindow:confirmCheckPanel relativeToWindow:parent];
*checkValue = ([confirmCheckPanelCheck state] == NSOnState);
[confirmCheckPanel close];
// get panel and display it
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: btn1 altButton: btn2 otherButton: btn3 extraView: checkboxView lastResponder: checkBox];
[panel setInitialFirstResponder: checkBox];
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
*checkValue = ([checkBox state] == NSOnState);
[panel close];
return result;
}
- (BOOL)prompt:(NSWindow*)parent title:(NSString*)title text:(NSString*)text promptText:(NSMutableString*)promptText checkMsg:(NSString*)checkMsg checkValue:(BOOL*)checkValue doCheck:(BOOL)doCheck
{
[promptPanelText setStringValue:text];
[promptPanel setTitle:title];
NSString* okButton = NSLocalizedString(@"OKButtonText", @"");
NSString* cancelButton = NSLocalizedString(@"CancelButtonText", @"");
float width = [self getContentWidthWithDefaultButton: okButton alternateButton: cancelButton otherButton: nil];
NSView* extraView = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];;
// set up input field
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];
[[field cell] setControlSize: NSSmallControlSize];
[field setStringValue: promptText];
[field selectText: nil];
[field setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[field setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin];
[extraView addSubview: field];
[extraView setNextKeyView: field];
// set up check box view, and combine the checkbox and field into the entire extra view
NSButton* checkBox = nil;
if (doCheck) {
int state = (*checkValue ? NSOnState : NSOffState);
[promptPanelCheck setState:state];
[promptPanelCheck setTransparent:NO];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
[checkBox setState:state];
[checkboxView setFrameOrigin: NSMakePoint(0, 0)];
[extraView setFrameSize: NSMakeSize(width, kTextFieldHeight + kGeneralViewSpace + NSHeight([checkboxView frame]))];
[extraView addSubview: checkboxView];
[field setNextKeyView: checkBox];
}
else {
[promptPanelCheck setTransparent:YES];
}
[promptPanelCheck setTitle:checkMsg];
[promptPanelInput setStringValue:promptText];
// get panel and display it
NSView* lastResponder = (doCheck ? (NSView*)checkBox : (NSView*)field);
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: okButton altButton: cancelButton otherButton: nil extraView: extraView lastResponder:lastResponder];
[panel setInitialFirstResponder: field];
int result = [NSApp runModalForWindow:promptPanel relativeToWindow:parent];
*checkValue = ([promptPanelCheck state] == NSOnState);
NSString* value = [promptPanelInput stringValue];
PRUint32 length = [promptText length];
if (length) {
NSRange all;
all.location = 0;
all.length = [promptText length];
[promptText deleteCharactersInRange:all];
}
[promptText appendString:value];
[promptPanel close];
return (result == kOKButton);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
[promptText setString: [field stringValue]];
if (doCheck)
*checkValue = ([checkBox state] == NSOnState);
return (result == kOKButton);
}
- (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
{
[usernamePanelText setStringValue:text];
[usernamePanel setTitle:title];
NSString* okButton = NSLocalizedString(@"OKButtonText", @"");
NSString* cancelButton = NSLocalizedString(@"CancelButtonText", @"");
float width = [self getContentWidthWithDefaultButton: okButton alternateButton: cancelButton otherButton: nil];
NSView* extraView = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, 2*kTextFieldHeight + kGeneralViewSpace)] autorelease];
// set up username field
NSTextField* userField = nil;
NSView* userView = [self getLoginField: &userField withWidth: width];
[userView setAutoresizingMask: NSViewMinYMargin];
[userView setFrameOrigin: NSMakePoint(0, kTextFieldHeight + kGeneralViewSpace)];
[userField setStringValue: userNameText];
[extraView addSubview: userView];
[extraView setNextKeyView: userField];
// set up password field
NSSecureTextField* passField = nil;
NSView* passView = [self getPasswordField: &passField withWidth: width];
[passView setAutoresizingMask: NSViewMinYMargin];
[passView setFrameOrigin: NSMakePoint(0, 0)];
[passField setStringValue: passwordText];
[extraView addSubview: passView];
[userField setNextKeyView: passField];
// set up check box view, and combine the checkbox and field into the entire extra view
NSButton* checkBox = nil;
if (doCheck) {
int state = (*checkValue ? NSOnState : NSOffState);
[usernamePanelCheck setState:state];
[usernamePanelCheck setTransparent:NO];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
[checkBox setState:state];
[checkboxView setFrameOrigin: NSMakePoint(0, 0)];
[extraView setFrameSize: NSMakeSize(width, 2*kTextFieldHeight + 2*kGeneralViewSpace + NSHeight([checkboxView frame]))];
[extraView addSubview: checkboxView];
[passField setNextKeyView: checkBox];
}
else {
[usernamePanelCheck setTransparent:YES];
}
[usernamePanelCheck setTitle:checkMsg];
[usernamePanelPassword setStringValue:passwordText];
[usernamePanelUserName setStringValue:userNameText];
// get panel and display it
NSView* lastResponder = (doCheck ? (NSView*)checkBox : (NSView*)passField);
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: okButton altButton: cancelButton otherButton: nil extraView: extraView lastResponder:lastResponder];
[panel setInitialFirstResponder: userField];
int result = [NSApp runModalForWindow:usernamePanel relativeToWindow:parent];
*checkValue = ([usernamePanelCheck state] == NSOnState);
NSString* value = [usernamePanelUserName stringValue];
PRUint32 length = [userNameText length];
if (length) {
NSRange all;
all.location = 0;
all.length = [userNameText length];
[userNameText deleteCharactersInRange:all];
}
[userNameText appendString:value];
value = [usernamePanelPassword stringValue];
length = [passwordText length];
if (length) {
NSRange all;
all.location = 0;
all.length = [passwordText length];
[passwordText deleteCharactersInRange:all];
}
[passwordText appendString:value];
[usernamePanel close];
return (result == kOKButton);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
[userNameText setString: [userField stringValue]];
[passwordText setString: [passField stringValue]];
if (doCheck)
*checkValue = ([checkBox state] == NSOnState);
return (result == kOKButton);
}
- (BOOL)promptPassword:(NSWindow*)parent title:(NSString*)title text:(NSString*)text 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
{
[passwordPanelText setStringValue:text];
[passwordPanel setTitle:title];
NSString* okButton = NSLocalizedString(@"OKButtonText", @"");
NSString* cancelButton = NSLocalizedString(@"CancelButtonText", @"");
float width = [self getContentWidthWithDefaultButton: okButton alternateButton: cancelButton otherButton: nil];
NSView* extraView = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];;
// set up input field
NSSecureTextField* passField = nil;
NSView* passView = [self getPasswordField: &passField withWidth: width];
[passView setAutoresizingMask: NSViewMinYMargin];
[passView setFrameOrigin: NSMakePoint(0, 0)];
[passField setStringValue: passwordText];
[extraView addSubview: passView];
[extraView setNextKeyView: passField];
// set up check box view, and combine the checkbox and field into the entire extra view
NSButton* checkBox = nil;
if (doCheck) {
int state = (*checkValue ? NSOnState : NSOffState);
[passwordPanelCheck setState:state];
[passwordPanelCheck setTransparent:NO];
NSView* checkboxView = [self getCheckboxView: &checkBox withLabel: checkMsg andWidth: width];
[checkBox setState:state];
[checkboxView setFrameOrigin: NSMakePoint(0, 0)];
[extraView setFrameSize: NSMakeSize(width, kTextFieldHeight + kGeneralViewSpace + NSHeight([checkboxView frame]))];
[extraView addSubview: checkboxView];
[passField setNextKeyView: checkBox];
}
else {
[passwordPanelCheck setTransparent:YES];
}
[passwordPanelCheck setTitle:checkMsg];
[passwordPanelInput setStringValue:passwordText];
// get panel and display it
NSView* lastResponder = (doCheck ? (NSView*)checkBox : (NSView*)passField);
NSPanel* panel = [self getAlertPanelWithTitle: title message: text defaultButton: okButton altButton: cancelButton otherButton: nil extraView: extraView lastResponder:lastResponder];
[panel setInitialFirstResponder: passField];
int result = [NSApp runModalForWindow:passwordPanel relativeToWindow:parent];
*checkValue = ([passwordPanelCheck state] == NSOnState);
NSString* value = [passwordPanelInput stringValue];
PRUint32 length = [passwordText length];
if (length) {
NSRange all;
all.location = 0;
all.length = [passwordText length];
[passwordText deleteCharactersInRange:all];
}
[passwordText appendString:value];
[passwordPanel close];
return (result == kOKButton);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
[passwordText setString: [passField stringValue]];
if (doCheck)
*checkValue = ([checkBox state] == NSOnState);
return (result == kOKButton);
}
- (BOOL)postToInsecureFromSecure:(NSWindow*)parent
{
int result = [NSApp runModalForWindow:postToInsecureFromSecurePanel relativeToWindow:parent];
[postToInsecureFromSecurePanel close];
return (result == kOKButton);
NSString* title = NSLocalizedString(@"Security Warning", @"");
NSString* message = NSLocalizedString(@"Post To Insecure", @"");
NSString* continueButton = NSLocalizedString(@"ContinueButton", @"");
NSString* stopButton = NSLocalizedString(@"StopButton", @"");
id panel = NSGetAlertPanel(title, message, continueButton, stopButton, nil);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
NSReleaseAlertPanel(panel);
return (result == NSAlertDefaultReturn);
}
- (BOOL)badCert:(NSWindow*)parent
{
int result = [NSApp runModalForWindow:securityMismatchPanel relativeToWindow:parent];
[securityMismatchPanel close];
return (result == kOKButton);
NSString* title = NSLocalizedString(@"Security Warning", @"");
NSString* message = NSLocalizedString(@"Security Mismatch", @"");
NSString* continueButton = NSLocalizedString(@"ContinueButton", @"");
NSString* stopButton = NSLocalizedString(@"StopButton", @"");
id panel = NSGetAlertPanel(title, message, continueButton, stopButton, nil);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
NSReleaseAlertPanel(panel);
return (result == NSAlertDefaultReturn);
}
- (BOOL)expiredCert:(NSWindow*)parent
{
int result = [NSApp runModalForWindow:expiredCertPanel relativeToWindow:parent];
[expiredCertPanel close];
return (result == kOKButton);
NSString* title = NSLocalizedString(@"Security Warning", @"");
NSString* message = NSLocalizedString(@"Expired Certification", @"");
NSString* continueButton = NSLocalizedString(@"ContinueButton", @"");
NSString* stopButton = NSLocalizedString(@"StopButton", @"");
id panel = NSGetAlertPanel(title, message, continueButton, stopButton, nil);
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
NSReleaseAlertPanel(panel);
return (result == NSAlertDefaultReturn);
}
@ -299,10 +416,413 @@ enum { kOKButton = 0, kCancelButton = 1, kOtherButton = 2 };
{
// this dialog is a little backward, with "Stop" returning 0, and the default returning
// 1. That's just how nsIBadCertListener defines its constants. *shrug*
int result = [NSApp runModalForWindow:securityUnknownPanel relativeToWindow:parent];
[securityUnknownPanel close];
NSString* title = NSLocalizedString(@"Security Warning", @"");
NSString* message = NSLocalizedString(@"Unknown Certification", @"");
NSString* alwaysAcceptButton = NSLocalizedString(@"Accept Always", @"");
NSString* oneAcceptButton = NSLocalizedString(@"Accept Once", @"");
NSString* stopButton = NSLocalizedString(@"StopButton", @"");
id panel = NSGetAlertPanel(title, message, oneAcceptButton, stopButton, alwaysAcceptButton);
return result;
int result = [NSApp runModalForWindow: panel relativeToWindow:parent];
[panel close];
NSReleaseAlertPanel(panel);
int returnValue;
if (result == NSAlertDefaultReturn)
returnValue = 1;
else if (result == NSAlertOtherReturn)
returnValue = 2;
else
returnValue = 0;
return returnValue;
}
#pragma mark -
// implementation of private methods
// The content width is determined by how much space is needed to display all 3 buttons,
// since every other view in the dialog can wrap if necessary
- (float)getContentWidthWithDefaultButton:(NSString*)defStr alternateButton:(NSString*)altStr otherButton:(NSString*)otherStr
{
NSButton* defButton = [self makeButtonWithTitle: defStr];
NSButton* altButton = [self makeButtonWithTitle: altStr];
NSButton* otherButton = [self makeButtonWithTitle: otherStr];
float defWidth = NSWidth([defButton frame]);
float altWidth = (altButton) ? NSWidth([altButton frame]) : 0;
float otherWidth = (otherButton) ? NSWidth([otherButton frame]) : 0;
float minContentWidth = kMinDialogWidth - 2*kWindowBorder - kIconMargin - kIconSize;
float buttonWidth = defWidth + altWidth + otherWidth + kOtherAltButtonSpace;
// return the larger of the two
return (minContentWidth > buttonWidth) ? minContentWidth : buttonWidth;
}
- (NSPanel*)getAlertPanelWithTitle:(NSString*)title message:(NSString*)message
defaultButton:(NSString*)defaultLabel altButton:(NSString*)altLabel
otherButton:(NSString*)otherLabel extraView:(NSView*)extraView lastResponder:(NSView*)lastResponder
{
NSRect rect = NSMakeRect(0, 0, kMinDialogWidth, kMaxDialogHeight);
NSPanel* panel = [[[NSPanel alloc] initWithContentRect: rect styleMask: NSTitledWindowMask backing: NSBackingStoreBuffered defer: YES] autorelease];
NSImageView* imageView = [[[NSImageView alloc] initWithFrame: NSMakeRect(kWindowBorder, kMaxDialogHeight - kWindowBorder - kIconSize, kIconSize, kIconSize)] autorelease];
// app icon
[imageView setImage: [NSImage imageNamed: @"NSApplicationIcon"]];
[imageView setImageFrameStyle: NSImageFrameNone];
[imageView setImageScaling: NSScaleProportionally];
[imageView setAutoresizingMask: NSViewMinYMargin | NSViewMaxXMargin];
[[panel contentView] addSubview: imageView];
// create buttons
NSButton* defButton = [self makeButtonWithTitle: defaultLabel];
[defButton setAction: @selector(hitButton1:)];
[defButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
[defButton setKeyEquivalent: @"\r"]; // return
[[panel contentView] addSubview: defButton];
[panel setDefaultButtonCell: [defButton cell]];
NSView* firstKeyView = (extraView ? extraView : defButton);
NSButton* altButton = nil;
if (altLabel) {
altButton = [self makeButtonWithTitle: altLabel];
[altButton setAction: @selector(hitButton2:)];
[altButton setAutoresizingMask: NSViewMinXMargin | NSViewMaxYMargin];
[altButton setKeyEquivalent: @"\e"]; // escape
[[panel contentView] addSubview: altButton];
[defButton setNextKeyView: altButton];
}
NSButton* otherButton = nil;
if (otherLabel) {
otherButton = [self makeButtonWithTitle: otherLabel];
[otherButton setAction: @selector(hitButton3:)];
[otherButton setAutoresizingMask: NSViewMaxXMargin | NSViewMaxYMargin];
[[panel contentView] addSubview: otherButton];
[otherButton setNextKeyView: firstKeyView];
if (altButton)
[altButton setNextKeyView: otherButton];
else
[defButton setNextKeyView: otherButton];
} else {
if (altButton)
[altButton setNextKeyView: firstKeyView];
else
[defButton setNextKeyView: firstKeyView];
}
// position buttons
float defWidth = NSWidth([defButton frame]);
float altWidth = (altButton) ? NSWidth([altButton frame]) : 0;
[defButton setFrameOrigin: NSMakePoint(NSWidth([panel frame]) - defWidth - kButtonRightMargin, kButtonBottomMargin)];
[altButton setFrameOrigin: NSMakePoint(NSMinX([defButton frame]) - altWidth, kButtonBottomMargin)];
[otherButton setFrameOrigin: NSMakePoint(kIconSize + kWindowBorder + kIconMargin, kButtonBottomMargin)];
// set the window width
// contentWidth is the width of the area with text, buttons, etc
// windowWidth is the total window width (contentWidth + margins + icon)
float contentWidth = [self getContentWidthWithDefaultButton: defaultLabel alternateButton: altLabel otherButton: otherLabel];
float windowWidth = kIconSize + kIconMargin + 2*kWindowBorder + contentWidth;
if (windowWidth < kMinDialogWidth)
windowWidth = kMinDialogWidth;
// get the height of all elements, and set the window height
NSTextField* titleField = [self getTitleView: title withWidth: contentWidth];
float titleHeight = [title length] ? NSHeight([titleField frame]) : 0;
float extraViewHeight = (extraView) ? NSHeight([extraView frame]) : 0;
float totalHeight = kWindowBorder + titleHeight + kGeneralViewSpace + kViewButtonSpace + kButtonHeight + kButtonBottomMargin;
if (extraViewHeight > 0)
totalHeight += extraViewHeight + kGeneralViewSpace;
float maxMessageHeight = kMaxDialogHeight - totalHeight;
NSView* messageView = [self getMessageView: message withWidth: contentWidth maxHeight: maxMessageHeight smallFont:[title length]];
float messageHeight = NSHeight([messageView frame]);
totalHeight += messageHeight;
if (totalHeight < kMinDialogHeight)
totalHeight = kMinDialogHeight;
[panel setContentSize: NSMakeSize(windowWidth, totalHeight)];
// position the title
float contentLeftEdge = kWindowBorder + kIconSize + kIconMargin;
NSRect titleRect = NSMakeRect(contentLeftEdge, totalHeight - titleHeight - kWindowBorder, contentWidth, titleHeight);
[titleField setFrame: titleRect];
if ( [title length] )
[[panel contentView] addSubview: titleField];
// position the message
NSRect messageRect = NSMakeRect(contentLeftEdge, NSMinY([titleField frame]) - kGeneralViewSpace - messageHeight, contentWidth, messageHeight);
[messageView setFrame: messageRect];
[[panel contentView] addSubview: messageView];
// position the extra view
NSRect extraRect = NSMakeRect(contentLeftEdge, NSMinY([messageView frame]) - kGeneralViewSpace - extraViewHeight, contentWidth, extraViewHeight);
[extraView setFrame: extraRect];
[[panel contentView] addSubview: extraView];
// If a lastResponder was passed in (the last item in the tab order inside
// extraView), hook it up to cycle to defButton. If not, assume there is
// nothing focusable inside extraView and hook up defButton as the first
// responder.
if (lastResponder)
[lastResponder setNextKeyView: defButton];
else
[panel setInitialFirstResponder: defButton];
return panel;
}
- (NSButton*)makeButtonWithTitle:(NSString*)title
{
if (title == nil)
return nil;
NSButton* button = [[[NSButton alloc] initWithFrame: NSMakeRect(0, 0, kButtonMinWidth, kButtonHeight)] autorelease];
[button setTitle: title];
[button setFont: [NSFont systemFontOfSize: [NSFont systemFontSize]]];
[button setBordered: YES];
[button setButtonType: NSMomentaryPushButton];
[button setBezelStyle: NSRoundedBezelStyle];
[button setTarget: self];
[button sizeToFit];
NSRect buttonFrame = [button frame];
// sizeToFit doesn't leave large enough endcaps (it goes to the bare minimum size)
buttonFrame.size.width += 2*kButtonEndCapWidth;
// make sure the button is within our allowed size range
if (NSWidth(buttonFrame) < kButtonMinWidth)
buttonFrame.size.width = kButtonMinWidth;
else if (NSWidth(buttonFrame) > kButtonMaxWidth)
buttonFrame.size.width = kButtonMaxWidth;
[button setFrame: buttonFrame];
return button;
}
- (NSTextField*)getTitleView:(NSString*)title withWidth:(float)width
{
NSTextView* textView = [[[NSTextView alloc] initWithFrame: NSMakeRect(0, 0, width, 100)] autorelease];
[textView setString: title];
[textView setMinSize: NSMakeSize(width, 0.0)];
[textView setMaxSize: NSMakeSize(width, kMaxFieldHeight)];
[textView setVerticallyResizable: YES];
[textView setHorizontallyResizable: NO];
[textView setFont: [NSFont boldSystemFontOfSize: [NSFont systemFontSize]]];
[textView sizeToFit];
NSSize textSize = NSMakeSize( ceil( NSWidth([textView frame]) ), ceil( NSHeight([textView frame]) ) );
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, textSize.width, textSize.height)] autorelease];
[field setStringValue: title];
[field setFont: [NSFont boldSystemFontOfSize: [NSFont systemFontSize]]];
[field setEditable: NO];
[field setSelectable: NO];
[field setBezeled: NO];
[field setBordered: NO];
[field setDrawsBackground: NO];
return field;
}
- (NSTextField*)getLabelView:(NSString*)title withWidth:(float)width
{
NSTextView* textView = [[[NSTextView alloc] initWithFrame: NSMakeRect(0, 0, width, 100)] autorelease];
[textView setString: title];
[textView setMinSize: NSMakeSize(width, 0.0)];
[textView setMaxSize: NSMakeSize(width, kMaxFieldHeight)];
[textView setVerticallyResizable: YES];
[textView setHorizontallyResizable: NO];
[textView setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[textView sizeToFit];
NSSize textSize = NSMakeSize(ceil(NSWidth([textView frame])), ceil(NSHeight([textView frame])) + 5);
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, textSize.width, textSize.height)] autorelease];
[field setStringValue: title];
[field setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[field setEditable: NO];
[field setSelectable: NO];
[field setBezeled: NO];
[field setBordered: NO];
[field setDrawsBackground: NO];
return field;
}
- (NSView*)getMessageView:(NSString*)message withWidth:(float)width maxHeight:(float)maxHeight smallFont:(BOOL)useSmallFont
{
NSTextView* textView = [[[NSTextView alloc] initWithFrame: NSMakeRect(0, 0, width, 100)] autorelease];
[textView setString: message];
[textView setMinSize: NSMakeSize(width, 0.0)];
[textView setVerticallyResizable: YES];
[textView setHorizontallyResizable: NO];
float displayFontSize = useSmallFont ? [NSFont smallSystemFontSize] : [NSFont systemFontSize];
[textView setFont: [NSFont systemFontOfSize:displayFontSize]];
[textView sizeToFit];
NSSize textSize = NSMakeSize(ceil(NSWidth([textView frame])), ceil(NSHeight([textView frame])) + 5);
// if the text is small enough to fit, then display it
if (textSize.height <= maxHeight) {
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, textSize.width, textSize.height)] autorelease];
[field setStringValue: message];
[field setFont: [NSFont systemFontOfSize: displayFontSize]];
[field setEditable: NO];
[field setSelectable: YES];
[field setBezeled: NO];
[field setBordered: NO];
[field setDrawsBackground: NO];
return field;
}
// if not, create scrollers
NSScrollView* scrollView = [[[NSScrollView alloc] initWithFrame: NSMakeRect(0, 0, width, maxHeight)] autorelease];
[scrollView setDocumentView: textView];
[scrollView setDrawsBackground: NO];
[scrollView setBorderType: NSBezelBorder];
[scrollView setHasHorizontalScroller: NO];
[scrollView setHasVerticalScroller: YES];
[textView setSelectable: YES];
[textView setEditable: NO];
[textView setDrawsBackground: NO];
[textView setFrameSize: [scrollView contentSize]];
return scrollView;
}
- (NSView*)getCheckboxView:(NSButton**)checkBoxPtr withLabel:(NSString*)label andWidth:(float)width
{
NSTextField* textField = [self getLabelView: label withWidth: width - kCheckBoxWidth];
float height = NSHeight([textField frame]);
// one line of text isn't as tall as the checkbox. make the view taller, or the checkbox will get clipped
if (height < kCheckBoxHeight)
height = kCheckBoxHeight;
// use a flipped view so we can more easily align everything at the top/left.
NSView* view = [[[QDCoordsView alloc] initWithFrame: NSMakeRect(0, 0, width, height)] autorelease];
[view addSubview: textField];
[view setNextKeyView: textField];
[textField setFrameOrigin: NSMakePoint(kCheckBoxWidth, kLabelCheckboxAdjustment)];
NSButton* checkBox = [[[NSButton alloc] initWithFrame: NSMakeRect(0, 0, kCheckBoxWidth, kCheckBoxHeight)] autorelease];
*checkBoxPtr = checkBox;
[checkBox setButtonType: NSSwitchButton];
[[checkBox cell] setControlSize: NSSmallControlSize];
[view addSubview: checkBox];
[textField setNextKeyView: checkBox];
// overlay the label with a transparent button that will push the checkbox
// when clicked on
NSButton* labelOverlay = [[[NSButton alloc] initWithFrame:[textField frame]] autorelease];
[labelOverlay setTransparent:YES];
[labelOverlay setTarget:[checkBox cell]];
[labelOverlay setAction:@selector(performClick:)];
[view addSubview:labelOverlay positioned:NSWindowAbove relativeTo:checkBox];
return view;
}
- (NSView*)getLoginField:(NSTextField**)fieldPtr withWidth:(float)width
{
int labelSize = [self getLoginTextLabelSize];
int fieldLeftEdge = labelSize + kFieldLabelSpacer;
NSView* view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];
NSTextField* label = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 3, labelSize, kStaticTextFieldHeight)] autorelease];
[[label cell] setControlSize: NSSmallControlSize];
[label setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[label setStringValue: NSLocalizedString(@"Username Label", @"")];
[label setEditable: NO];
[label setSelectable: NO];
[label setBordered: NO];
[label setDrawsBackground: NO];
[label setAlignment: NSRightTextAlignment];
[view addSubview: label];
NSTextField* field = [[[NSTextField alloc] initWithFrame: NSMakeRect(fieldLeftEdge, 0, width - fieldLeftEdge, kTextFieldHeight)] autorelease];
[[field cell] setControlSize: NSSmallControlSize];
[field setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[view addSubview: field];
[view setNextKeyView: field];
*fieldPtr = field;
return view;
}
- (NSView*)getPasswordField:(NSSecureTextField**)fieldPtr withWidth:(float)width
{
int labelSize = [self getLoginTextLabelSize];
int fieldLeftEdge = labelSize + kFieldLabelSpacer;
NSView* view = [[[NSView alloc] initWithFrame: NSMakeRect(0, 0, width, kTextFieldHeight)] autorelease];
NSTextField* label = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 3, labelSize, kStaticTextFieldHeight)] autorelease];
[[label cell] setControlSize: NSSmallControlSize];
[label setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[label setStringValue: NSLocalizedString(@"Password Label", @"")];
[label setEditable: NO];
[label setSelectable: NO];
[label setBordered: NO];
[label setDrawsBackground: NO];
[label setAlignment: NSRightTextAlignment];
[view addSubview: label];
NSSecureTextField* field = [[[NSSecureTextField alloc] initWithFrame: NSMakeRect(fieldLeftEdge, 0, width - fieldLeftEdge, kTextFieldHeight)] autorelease];
[[field cell] setControlSize: NSSmallControlSize];
[field setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[view addSubview: field];
[view setNextKeyView: field];
*fieldPtr = field;
return view;
}
- (int)getLoginTextLabelSize
{
NSTextField* label = [[[NSTextField alloc] initWithFrame: NSMakeRect(0, 0, 200, kStaticTextFieldHeight)] autorelease];
[[label cell] setControlSize: NSSmallControlSize];
[label setFont: [NSFont systemFontOfSize: [NSFont smallSystemFontSize]]];
[label setEditable: NO];
[label setSelectable: NO];
[label setBordered: NO];
[label setDrawsBackground: NO];
[label setAlignment: NSRightTextAlignment];
[label setStringValue: NSLocalizedString(@"Username Label", @"")];
[label sizeToFit];
float userSize = NSWidth([label frame]);
[label setStringValue: NSLocalizedString(@"Password Label", @"")];
[label sizeToFit];
float passSize = NSWidth([label frame]);
float largest = (userSize > passSize) ? userSize : passSize;
return (int)ceil(largest) + 6;
}
@end

Просмотреть файл

@ -346,7 +346,8 @@ static id gSharedProgressController = nil;
{
ProgressViewController *newController = [[ProgressViewController alloc] init];
[newController setProgressWindowController:self];
[mProgressViewControllers addObject:newController];
//[mProgressViewControllers addObject:newController];
[mProgressViewControllers insertObject:newController atIndex:0]; // new downoads at the top
return newController;
}

Просмотреть файл

@ -256,13 +256,9 @@ static NSString *ProgressViewsShouldResize = @"ProgressViewsShouldResize";
if (mDownloader) // we should always have one
mDownloader->CancelDownload();
// clean up downloaded file. - do it here or in CancelDownload?
NSFileManager *fileManager = [NSFileManager defaultManager];
if ([fileManager isDeletableFileAtPath:mDestPath])
{
// if we delete it, fantastic. if not, oh well. better to move to trash instead?
[fileManager removeFileAtPath:mDestPath handler:nil];
}
// note that we never want to delete downloaded files here,
// because the file does not have its final path yet.
// Necko will delete the evil temp file.
}
- (IBAction)close:(id)sender

Просмотреть файл

@ -347,7 +347,7 @@ nsresult nsHeaderSniffer::InitiateDownload(nsISupports* inSourceData, nsString&
{ // Tell web persist we want no decoding on this data
flags |= nsIWebBrowserPersist::PERSIST_FLAGS_NO_CONVERSION;
webPersist->SetPersistFlags(flags);
rv = webPersist->SaveURI(sourceURI, mPostData, destFile);
rv = webPersist->SaveURI(sourceURI, nsnull, nsnull, mPostData, nsnull, destFile);
}
else
{

Просмотреть файл

@ -71,7 +71,7 @@ NS_IMPL_ISUPPORTS_INHERITED3(nsDownloadListener, CHDownloader, nsIDownload, nsIW
/* void init (in nsIURI aSource, in nsILocalFile aTarget, in wstring aDisplayName, in wstring openingWith, in long long startTime, in nsIWebBrowserPersist aPersist); */
NS_IMETHODIMP
nsDownloadListener::Init(nsIURI *aSource, nsILocalFile *aTarget, const PRUnichar *aDisplayName,
nsIMIMEInfo *aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist)
nsIMIMEInfo* aMIMEInfo, PRInt64 startTime, nsIWebBrowserPersist *aPersist)
{
CreateDownloadDisplay(); // call the base class to make the download UI
@ -269,7 +269,12 @@ NS_IMETHODIMP nsDownloadListener::Notify(nsITimer *timer)
// changed it
nsAutoString pathStr;
mDestination->GetPath(pathStr);
[mDownloadDisplay setDestinationPath: [NSString stringWith_nsAString:pathStr]];
NSString* destPath = [NSString stringWith_nsAString:pathStr];
[mDownloadDisplay setDestinationPath:destPath];
// update the Finder immediately.
if ( NS_SUCCEEDED(mDownloadStatus) )
[[NSWorkspace sharedWorkspace] noteFileSystemChanged:destPath];
// cancelling should give us a failure status
[mDownloadDisplay onEndDownload:(NS_SUCCEEDED(mDownloadStatus) && !mUserCanceled)];
@ -364,7 +369,7 @@ nsDownloadListener::DownloadDone(nsresult aStatus)
mEndRefreshTimer = do_CreateInstance("@mozilla.org/timer;1");
if (mEndRefreshTimer)
{
nsresult rv = mEndRefreshTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT); // defaults to 1-shot, normal priority
nsresult rv = mEndRefreshTimer->InitWithCallback(this, 0, nsITimer::TYPE_ONE_SHOT);
if (NS_FAILED(rv))
mEndRefreshTimer = NULL;
}

Просмотреть файл

@ -222,15 +222,6 @@ CHBrowserListener::SetChromeFlags(PRUint32 aChromeFlags)
NS_IMETHODIMP
CHBrowserListener::DestroyBrowserWindow()
{
#if 0
// XXX Could send this up to the container, but for now,
// we just destroy the enclosing window.
NSWindow* window = [mView window];
if (window) {
[window close];
}
#endif
// tell the container we want to close the window and let it do the
// right thing.
[mContainer closeBrowserWindow];
@ -261,7 +252,7 @@ CHBrowserListener::ShowAsModal()
return NS_ERROR_FAILURE;
}
NSWindow* window = [mView window];
NSWindow* window = [mView getNativeWindow];
if (!window) {
return NS_ERROR_FAILURE;
@ -309,6 +300,8 @@ CHBrowserListener::SetDimensions(PRUint32 flags, PRInt32 x, PRInt32 y, PRInt32 c
if (!mView)
return NS_ERROR_FAILURE;
// use -window here and not -getNativeWindow because we don't want to allow bg tabs
// (which aren't in the window hierarchy) to resize the window.
NSWindow* window = [mView window];
if (!window)
return NS_ERROR_FAILURE;
@ -363,7 +356,7 @@ CHBrowserListener::GetDimensions(PRUint32 flags, PRInt32 *x, PRInt32 *y, PRInt
if (!mView)
return NS_ERROR_FAILURE;
NSWindow* window = [mView window];
NSWindow* window = [mView getNativeWindow];
if (!window)
return NS_ERROR_FAILURE;
@ -403,6 +396,7 @@ CHBrowserListener::GetDimensions(PRUint32 flags, PRInt32 *x, PRInt32 *y, PRInt
NS_IMETHODIMP
CHBrowserListener::SetFocus()
{
// don't use -getNativeWindow here so tabs in the bg can't take focus
NSWindow* window = [mView window];
if (!window)
return NS_ERROR_FAILURE;
@ -433,7 +427,7 @@ CHBrowserListener::GetVisibility(PRBool *aVisibility)
return NS_ERROR_FAILURE;
}
NSWindow* window = [mView window];
NSWindow* window = [mView getNativeWindow];
if (!window) {
return NS_ERROR_FAILURE;
}
@ -446,6 +440,8 @@ CHBrowserListener::GetVisibility(PRBool *aVisibility)
NS_IMETHODIMP
CHBrowserListener::SetVisibility(PRBool aVisibility)
{
// use -window instead of -getNativeWindow to prevent bg tabs from being able to
// change the visibility
NSWindow* window = [mView window];
if (!window)
return NS_ERROR_FAILURE;
@ -512,7 +508,7 @@ CHBrowserListener::GetSiteWindow(void * *aSiteWindow)
return NS_ERROR_FAILURE;
}
NSWindow* window = [mView window];
NSWindow* window = [mView getNativeWindow];
if (!window) {
return NS_ERROR_FAILURE;
}

Просмотреть файл

@ -162,8 +162,7 @@ nsAlertController*
CHBrowserService::GetAlertController()
{
if (!sController) {
NSBundle* bundle = [NSBundle bundleForClass:[CHBrowserView class]];
[bundle loadNibFile:@NS_ALERT_NIB_NAME externalNameTable:nsnull withZone:[NSApp zone]];
sController = [[nsAlertController alloc] init];
}
return sController;
}

Просмотреть файл

@ -215,6 +215,9 @@ enum {
// point is over.
- (void) findEventSink:(nsIEventSink**)outSink forPoint:(NSPoint)inPoint inWindow:(NSWindow*)inWind;
- (IBAction)reloadWithNewCharset:(NSString*)charset;
- (NSString*)currentCharset;
@end
#endif // __nsCocoaBrowserView_h__

Просмотреть файл

@ -43,6 +43,7 @@
#include "nsIWebNavigation.h"
#include "nsIWebBrowserSetup.h"
#include "nsComponentManagerUtils.h"
#include "nsIDocCharset.h"
#include "nsIURI.h"
#include "nsIDOMWindow.h"
@ -109,7 +110,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
- (nsIContentViewer*)getContentViewer; // addrefs return value
- (float)getTextZoom;
- (void)incrementTextZoom:(float)increment min:(float)min max:(float)max;
- (nsIDocShell*)getDocShell; // addrefs return value
@end
@implementation CHBrowserView
@ -480,7 +481,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
if (!sniffer)
return;
webPersist->SetProgressListener(sniffer); // owned
webPersist->SaveURI(aURI, nsnull, tmpFile);
webPersist->SaveURI(aURI, nsnull, nsnull, nsnull, nsnull, tmpFile);
}
-(void)printDocument
@ -678,8 +679,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
PRBool isEnabled = PR_FALSE;
nsCOMPtr<nsICommandManager> commandMgr(do_GetInterface(_webBrowser));
if (commandMgr) {
nsresult rv = commandMgr->IsCommandEnabled(commandName, nsnull,
&isEnabled);
nsresult rv = commandMgr->IsCommandEnabled(commandName, nsnull, &isEnabled);
#if DEBUG
if (NS_FAILED(rv))
NSLog(@"IsCommandEnabled failed");
@ -916,7 +916,7 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
}
- (nsIContentViewer*)getContentViewer // addrefs return value
- (nsIDocShell*)getDocShell
{
if (!_webBrowser)
return NULL;
@ -925,11 +925,14 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
nsCOMPtr<nsIScriptGlobalObject> global(do_QueryInterface(domWindow));
if (!global)
return NULL;
nsCOMPtr<nsIDocShell> docShell;
global->GetDocShell(getter_AddRefs(docShell));
if (!docShell)
return NULL;
nsIDocShell* docShell = NULL;
global->GetDocShell(&docShell); // addrefs
return docShell;
}
- (nsIContentViewer*)getContentViewer // addrefs return value
{
nsCOMPtr<nsIDocShell> docShell = dont_AddRef([self getDocShell]);
nsIContentViewer* cv = NULL;
docShell->GetContentViewer(&cv); // addrefs
return cv;
@ -1126,10 +1129,10 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
nsCOMPtr<nsICommandParams> params = do_CreateInstance(NS_COMMAND_PARAMS_CONTRACTID);
if (!params) return NO;
params->SetStringValue("format", NS_LITERAL_STRING("text/plain"));
params->SetStringValue("format", NS_LITERAL_STRING("text/plain"));
params->SetBooleanValue("selection_only", PR_TRUE);
nsresult rv = cmdManager->DoCommand("cmd_getContents", params, nsnull);
nsresult rv = cmdManager->DoCommand("cmd_GetContents", params, nsnull);
if (NS_FAILED(rv))
return NO;
@ -1166,4 +1169,52 @@ const char kDirServiceContractID[] = "@mozilla.org/file/directory_service;1";
return (BOOL)NS_SUCCEEDED(rv);
}
- (IBAction)reloadWithNewCharset:(NSString*)inCharset
{
// set charset on document then reload the page (hopefully not hitting the network)
nsCOMPtr<nsIDocShell> docShell = dont_AddRef([self getDocShell]);
nsCOMPtr<nsIDocCharset> charset ( do_QueryInterface(docShell) );
if ( charset ) {
nsAutoString charsetStr;
[inCharset assignTo_nsAString:charsetStr];
charset->SetCharset(charsetStr.get());
[self reload:nsIWebNavigation::LOAD_FLAGS_CHARSET_CHANGE];
}
}
- (NSString*)currentCharset
{
#if 0
nsCOMPtr<nsIWebBrowserFocus> wbf(do_QueryInterface(_webBrowser));
if ( wbf ) {
nsCOMPtr<nsIDOMWindow> focusedWindow;
wbf->GetFocusedWindow(getter_AddRefs(focusedWindow));
if ( focusedWindow ) {
nsCOMPtr<nsIDOMDocument> domDoc;
focusedWindow->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc ( do_QueryInterface(domDoc) );
if ( doc ) {
nsAutoString charset;
doc->GetDocumentCharacterSet(charset);
return [NSString stringWith_nsAString:charset];
}
}
}
#endif
nsCOMPtr<nsIDOMWindow> wind;
_webBrowser->GetContentDOMWindow(getter_AddRefs(wind));
if ( wind ) {
nsCOMPtr<nsIDOMDocument> domDoc;
wind->GetDocument(getter_AddRefs(domDoc));
nsCOMPtr<nsIDocument> doc ( do_QueryInterface(domDoc) );
if ( doc ) {
nsAutoString charset;
doc->GetDocumentCharacterSet(charset);
return [NSString stringWith_nsAString:charset];
}
}
return nil;
}
@end

Просмотреть файл

@ -65,15 +65,16 @@
-(void)keyDown:(NSEvent*)aEvent
{
const unichar kForwardDeleteChar = 0xf728; // couldn't find this in any cocoa header
// check each char in the event array. it should be just 1 char, but
// just in case we use a loop.
int len = [[aEvent characters] length];
for ( int i = 0; i < len; ++i ) {
unichar c = [[aEvent characters] characterAtIndex:i];
// Check for a certain set of special keys.
if (c == NSDeleteCharacter || c == NSBackspaceCharacter) {
// Check for a certain set of special keys.
if (c == NSDeleteCharacter || c == NSBackspaceCharacter || c == kForwardDeleteChar) {
// delete the bookmark
if (mDeleteAction)
[NSApp sendAction: mDeleteAction to: [self target] from: self];

Просмотреть файл

@ -55,7 +55,7 @@ class nsIRDFService;
// cached values are valid
BOOL mExpandable;
int mNumChildren;
NSArray* mChildNodes;
NSArray* mChildNodes; // array of |RDFOutlineViewItem|'s
}
- (nsIRDFResource*)resource; // addRefs the result

Просмотреть файл

@ -150,6 +150,7 @@ HistoryDataSourceObserver::OnChange(nsIRDFDataSource*, nsIRDFResource*,
@interface HistoryDataSource(Private)
- (void)cleanupHistory;
- (void)removeItemFromHistory:(id)inItem withService:(nsIBrowserHistory*)inHistService;
@end
@ -398,15 +399,27 @@ HistoryDataSourceObserver::OnChange(nsIRDFDataSource*, nsIRDFResource*,
nsCOMPtr<nsIBrowserHistory> history = do_GetService("@mozilla.org/browser/global-history;1");
if ( history ) {
// Even though it looks like relying on row numbers as we delete will get us in trouble
// and out of sync, until we actually invalidate the table, the rows keep their prior values.
// If children are selected as well as the parent, we'll just end up trying to remove the
// host string from history which will silently fail. It's extra work, but harmless.
history->StartBatchUpdate();
NSEnumerator* rowEnum = [mOutlineView selectedRowEnumerator];
for ( NSNumber* currIndex = [rowEnum nextObject]; currIndex; currIndex = [rowEnum nextObject]) {
index = [currIndex intValue];
RDFOutlineViewItem* item = [mOutlineView itemAtRow: index];
if (![mOutlineView isExpandable: item]) {
NSString* urlString = [self getPropertyString:@"http://home.netscape.com/NC-rdf#URL" forItem:item];
history->RemovePage([urlString UTF8String]);
if ([mOutlineView isExpandable: item]) {
// delete a folder by iterating over each of its children and deleting them. There
// should be a better way, but the history api's don't really support them. Expand
// the folder before we delete it otherwise we don't get any child nodes to delete.
[mOutlineView expandItem:item];
NSEnumerator* childEnum = [item->mChildNodes objectEnumerator];
RDFOutlineViewItem* currChild = nil;
while ( (currChild = [childEnum nextObject]) )
[self removeItemFromHistory:currChild withService:history];
}
else
[self removeItemFromHistory:item withService:history];
}
history->EndBatchUpdate();
if ( clearSelectionWhenDone )
@ -417,6 +430,13 @@ HistoryDataSourceObserver::OnChange(nsIRDFDataSource*, nsIRDFResource*,
}
}
-(void)removeItemFromHistory:(id)inItem withService:(nsIBrowserHistory*)inHistService;
{
NSString* urlString = [self getPropertyString:@"http://home.netscape.com/NC-rdf#URL" forItem:inItem];
inHistService->RemovePage([urlString UTF8String]);
}
//
// outlineView:tooltipForString
//

Просмотреть файл

@ -263,9 +263,11 @@ static BOOL gMadePrefManager;
}
return NO;
}
#ifdef BRANCH_CHANGES_NEED_MERGED
else if (rv == NS_ERROR_PROFILE_SETLOCK_FAILED) {
NSLog(@"SetCurrentProfile returned NS_ERROR_PROFILE_SETLOCK_FAILED");
}
#endif
nsCOMPtr<nsIPref> prefs(do_GetService(NS_PREF_CONTRACTID));
mPrefs = prefs;