зеркало из https://github.com/mozilla/gecko-dev.git
Fix bug 248304: turn off the universal charset detector by default, but allow users to turn it back on via an item at the bottom of the Text Encodings menu. Also add a new item for GB 18030. r=pinkerton.
This commit is contained in:
Родитель
5394d6f9d7
Коммит
344e87775b
|
@ -61,26 +61,27 @@
|
|||
<integer>32</integer>
|
||||
<key>hz-gb-2312</key>
|
||||
<integer>33</integer>
|
||||
<key>gb18030</key>
|
||||
<integer>34</integer>
|
||||
|
||||
<key>iso-8859-2</key>
|
||||
<integer>34</integer>
|
||||
<integer>40</integer>
|
||||
<key>windows-1250</key>
|
||||
<integer>35</integer>
|
||||
<integer>41</integer>
|
||||
<key>iso-8859-4</key>
|
||||
<integer>36</integer>
|
||||
|
||||
<integer>42</integer>
|
||||
<key>windows-1258</key>
|
||||
<integer>37</integer>
|
||||
<integer>43</integer>
|
||||
|
||||
<key>iso-8859-9</key>
|
||||
<integer>38</integer>
|
||||
<key>windows-1254</key>
|
||||
<integer>39</integer>
|
||||
<integer>45</integer>
|
||||
|
||||
<key>windows-1254</key>
|
||||
<integer>50</integer>
|
||||
<key>windows-1257</key>
|
||||
<integer>40</integer>
|
||||
<integer>51</integer>
|
||||
|
||||
<key>utf-8</key>
|
||||
<integer>41</integer>
|
||||
<integer>60</integer>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
// This file contains Camino-specific default preferences.
|
||||
|
||||
#error unused
|
||||
|
||||
// What to load in a new tab: 0 = blank, 1 = homepage, 2 = last page
|
||||
pref("browser.tabs.startPage", 0);
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
aboutServers = id;
|
||||
aboutWindow = id;
|
||||
biggerTextSize = id;
|
||||
clearHistory = id;
|
||||
closeTab = id;
|
||||
connectToServer = id;
|
||||
displayPreferencesWindow = id;
|
||||
|
@ -68,6 +69,7 @@
|
|||
showHistory = id;
|
||||
smallerTextSize = id;
|
||||
tipsTricksLink = id;
|
||||
toggleAutoCharsetDetection = id;
|
||||
toggleBookmarksToolbar = id;
|
||||
toggleOfflineMode = id;
|
||||
viewSource = id;
|
||||
|
@ -90,6 +92,7 @@
|
|||
mGoMenu = NSMenu;
|
||||
mServersSubmenu = NSMenu;
|
||||
mShowAllBookmarksMenuItem = NSMenuItem;
|
||||
mTextEncodingsMenu = NSMenu;
|
||||
};
|
||||
SUPERCLASS = NSObject;
|
||||
},
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<key>IBEditorPositions</key>
|
||||
<dict>
|
||||
<key>29</key>
|
||||
<string>274 731 433 44 0 0 1600 1002 </string>
|
||||
<string>44 952 433 44 0 0 1600 1002 </string>
|
||||
<key>494</key>
|
||||
<string>726 607 116 61 0 0 1600 1002 </string>
|
||||
<key>670</key>
|
||||
|
|
Двоичные данные
camino/resources/localized/English.lproj/MainMenu.nib/keyedobjects.nib
сгенерированный
Двоичные данные
camino/resources/localized/English.lproj/MainMenu.nib/keyedobjects.nib
сгенерированный
Двоичный файл не отображается.
|
@ -78,6 +78,8 @@ typedef enum EBookmarkOpenBehavior
|
|||
IBOutlet NSMenu* mDockMenu;
|
||||
IBOutlet NSMenu* mServersSubmenu;
|
||||
|
||||
IBOutlet NSMenu* mTextEncodingsMenu;
|
||||
|
||||
IBOutlet NSMenu* mBookmarksHelperMenu; // not shown, used to get enable state
|
||||
|
||||
IBOutlet NSMenuItem* mBookmarksToolbarMenuItem;
|
||||
|
@ -142,6 +144,7 @@ typedef enum EBookmarkOpenBehavior
|
|||
-(IBAction) showHistory:(id)aSender;
|
||||
-(IBAction) clearHistory:(id)aSender;
|
||||
-(IBAction) reloadWithCharset:(id)aSender;
|
||||
-(IBAction) toggleAutoCharsetDetection:(id)aSender;
|
||||
|
||||
// Bookmarks menu actions.
|
||||
-(IBAction) importBookmarks:(id)aSender;
|
||||
|
|
|
@ -111,6 +111,7 @@ const int kReuseWindowOnAE = 2;
|
|||
- (BOOL)bookmarksItemsEnabled;
|
||||
- (void)adjustBookmarkMenuItems;
|
||||
- (void)doBookmarksMenuEnabling;
|
||||
- (void)adjustTextEncodingMenu;
|
||||
- (void)windowLayeringDidChange:(NSNotification*)inNotifiction;
|
||||
- (void)menuWillDisplay:(NSNotification*)inNotification;
|
||||
- (void)openPanelDidEnd:(NSOpenPanel*)inOpenPanel returnCode:(int)inReturnCode contextInfo:(void*)inContextInfo;
|
||||
|
@ -809,6 +810,16 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
|||
}
|
||||
}
|
||||
|
||||
-(IBAction) toggleAutoCharsetDetection:(id)aSender
|
||||
{
|
||||
NSString* detectorValue = [[PreferenceManager sharedInstance] getStringPref:"intl.charset.detector" withSuccess:NULL];
|
||||
BOOL universalChardetOn = [detectorValue isEqualToString:@"universal_charset_detector"];
|
||||
NSString* newValue = universalChardetOn ? @"" : @"universal_charset_detector";
|
||||
[[PreferenceManager sharedInstance] setPref:"intl.charset.detector" toString:newValue];
|
||||
// and reload
|
||||
[self doReload:nil];
|
||||
}
|
||||
|
||||
-(IBAction) doStop:(id)aSender
|
||||
{
|
||||
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||
|
@ -857,6 +868,10 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
|||
{
|
||||
[self adjustBookmarkMenuItems];
|
||||
}
|
||||
else if ([mTextEncodingsMenu isTargetOfWillDisplayNotification:[inNotification object]])
|
||||
{
|
||||
[self adjustTextEncodingMenu];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)adjustBookmarksMenuItemsEnabling
|
||||
|
@ -1208,33 +1223,38 @@ Otherwise, we return the URL we originally got. Right now this supports .url and
|
|||
}
|
||||
}
|
||||
|
||||
- (void)adjustTextEncodingMenu
|
||||
{
|
||||
BrowserWindowController* browserController = [self getMainWindowBrowserController];
|
||||
if (browserController)
|
||||
{
|
||||
// enable all items
|
||||
[mTextEncodingsMenu setAllItemsEnabled:YES startingWithItemAtIndex:0 includingSubmenus:YES];
|
||||
|
||||
NSString* charset = [browserController currentCharset];
|
||||
#if DEBUG_CHARSET
|
||||
NSLog(@"charset is %@", charset);
|
||||
#endif
|
||||
NSNumber* tag = [mCharsets objectForKey:[charset lowercaseString]];
|
||||
[mTextEncodingsMenu checkItemWithTag:[tag intValue] uncheckingOtherItems:YES];
|
||||
}
|
||||
else
|
||||
{
|
||||
[mTextEncodingsMenu setAllItemsEnabled:NO startingWithItemAtIndex:0 includingSubmenus:YES];
|
||||
// always enable the autodetect item
|
||||
[[mTextEncodingsMenu itemWithTag:kEncodingMenuAutodetectItemTag] setEnabled:YES];
|
||||
}
|
||||
|
||||
// update the state of the autodetect item
|
||||
NSString* detectorValue = [[PreferenceManager sharedInstance] getStringPref:"intl.charset.detector" withSuccess:NULL];
|
||||
BOOL universalChardetOn = [detectorValue isEqualToString:@"universal_charset_detector"];
|
||||
[[mTextEncodingsMenu itemWithTag:kEncodingMenuAutodetectItemTag] setState:universalChardetOn ? NSOnState : NSOffState];
|
||||
}
|
||||
|
||||
-(BOOL)validateMenuItem:(NSMenuItem*)aMenuItem
|
||||
{
|
||||
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
|
||||
// or the bookmark/history manager is open
|
||||
SEL action = [aMenuItem action];
|
||||
|
|
|
@ -46,6 +46,10 @@
|
|||
const int kRendezvousRelatedItemTag = 3000;
|
||||
const int kDividerTag = 4000;
|
||||
|
||||
// Tags 10-80 are reserved for text encoding items
|
||||
const int kEncodingMenuTagBase = 10;
|
||||
const int kEncodingMenuAutodetectItemTag = 200;
|
||||
|
||||
|
||||
// Bookmarks menu
|
||||
|
||||
|
|
|
@ -43,11 +43,12 @@ class nsIPref;
|
|||
|
||||
@interface PreferenceManager : NSObject
|
||||
{
|
||||
NSUserDefaults* mDefaults;
|
||||
ICInstance mInternetConfig;
|
||||
@private
|
||||
NSUserDefaults* mDefaults;
|
||||
ICInstance mInternetConfig;
|
||||
nsProfileDirServiceProvider* mProfileProvider;
|
||||
nsIPref* mPrefs;
|
||||
|
||||
long mLastRunPrefsVersion;
|
||||
// proxies notification stuff
|
||||
CFRunLoopSourceRef mRunLoopSource;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#import "UserDefaults.h"
|
||||
#import "CHBrowserService.h"
|
||||
|
||||
#include "nsBuildID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsProfileDirServiceProvider.h"
|
||||
#include "nsIPref.h"
|
||||
|
@ -62,6 +63,11 @@ nsresult PR_CALLBACK
|
|||
app_getModuleInfo(nsStaticModuleInfo **info, PRUint32 *count);
|
||||
#endif
|
||||
|
||||
// This is an arbitrary version stamp that gets written to the prefs file.
|
||||
// It can be used to detect when a new version of Camino is run that needs
|
||||
// some prefs to be upgraded.
|
||||
static const PRInt32 kCurrentPrefsVersion = 1;
|
||||
|
||||
@interface PreferenceManager(PreferenceManagerPrivate)
|
||||
|
||||
+ (PreferenceManager *) sharedInstanceDontCreate;
|
||||
|
@ -330,12 +336,16 @@ static BOOL gMadePrefManager;
|
|||
NSLog(@"Mozilla prefs not set up successfully");
|
||||
return;
|
||||
}
|
||||
|
||||
// set the universal charset detector pref. we can't set it in chimera.js
|
||||
// because it's a funky locale-specific pref.
|
||||
static const char* const kUniversalCharsetDetectorPref = "intl.charset.detector";
|
||||
mPrefs->SetCharPref(kUniversalCharsetDetectorPref, "universal_charset_detector");
|
||||
|
||||
PRInt32 lastRunPrefsVersion = 0;
|
||||
mPrefs->GetIntPref("camino.prefs_version", &lastRunPrefsVersion);
|
||||
mLastRunPrefsVersion = lastRunPrefsVersion;
|
||||
|
||||
if (mLastRunPrefsVersion < 1) // version at which we turn off the universal charset detector
|
||||
mPrefs->SetCharPref("intl.charset.detector", "");
|
||||
|
||||
mPrefs->SetIntPref("camino.prefs_version", kCurrentPrefsVersion);
|
||||
|
||||
// fix up the cookie prefs. If 'p3p' or 'accept foreign cookies' are on, remap them to
|
||||
// something that chimera can deal with.
|
||||
PRInt32 acceptCookies = 0;
|
||||
|
@ -959,4 +969,3 @@ static void SCProxiesChangedCallback(SCDynamicStoreRef store, CFArrayRef changed
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче