295755 Ship FlashBlock with Camino, and provide a preference in Camino's Web Features preference pane. Integration work by Bryan Atwood <bryan.h.atwood@gmail.com>. FlashBlock from http://flashblock.mozdev.org/, see camino/flashblock/README. Build trickery by me. r=smokey sr=smorgan
This commit is contained in:
Родитель
d29fabea2c
Коммит
ffaa9b7963
|
@ -1096,6 +1096,7 @@ calendar/sunbird/base/Makefile
|
|||
|
||||
MAKEFILES_macbrowser="
|
||||
camino/Makefile
|
||||
camino/flashblock/Makefile
|
||||
camino/installer/Makefile
|
||||
"
|
||||
|
||||
|
|
|
@ -6564,6 +6564,7 @@
|
|||
dstSubfolderSpec = 6;
|
||||
files = (
|
||||
3F44AD5805BDFB9F00CB4B08,
|
||||
3F44AD5805BDFB9F00CB4B18,
|
||||
3F44AD5905BDFB9F00CB4B08,
|
||||
);
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
|
@ -6575,6 +6576,12 @@
|
|||
settings = {
|
||||
};
|
||||
};
|
||||
3F44AD5805BDFB9F00CB4B18 = {
|
||||
fileRef = F6BD650001B3184301A96307;
|
||||
isa = PBXBuildFile;
|
||||
settings = {
|
||||
};
|
||||
};
|
||||
3F44AD5905BDFB9F00CB4B08 = {
|
||||
fileRef = F5DA444A027DD5AA01A80166;
|
||||
isa = PBXBuildFile;
|
||||
|
@ -10294,6 +10301,7 @@
|
|||
dstSubfolderSpec = 6;
|
||||
files = (
|
||||
3F44AF7305BDFBA000CB4B08,
|
||||
3F44AF7305BDFBA000CB4B18,
|
||||
3F44AF7405BDFBA000CB4B08,
|
||||
);
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
|
@ -10305,6 +10313,12 @@
|
|||
settings = {
|
||||
};
|
||||
};
|
||||
3F44AF7305BDFBA000CB4B18 = {
|
||||
fileRef = F6BD650001B3184301A96307;
|
||||
isa = PBXBuildFile;
|
||||
settings = {
|
||||
};
|
||||
};
|
||||
3F44AF7405BDFBA000CB4B08 = {
|
||||
fileRef = F5DA444A027DD5AA01A80166;
|
||||
isa = PBXBuildFile;
|
||||
|
@ -18744,6 +18758,7 @@
|
|||
F6BD64FF01B3184301A962F7 = {
|
||||
children = (
|
||||
F6BD650001B3184301A962F7,
|
||||
F6BD650001B3184301A96307,
|
||||
F54EF7ED022A2F9C01A80165,
|
||||
F5DA444A027DD5AA01A80166,
|
||||
);
|
||||
|
@ -18760,6 +18775,14 @@
|
|||
refType = 2;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
F6BD650001B3184301A96307 = {
|
||||
isa = PBXFileReference;
|
||||
lastKnownFileType = archive.jar;
|
||||
name = flashblock.jar;
|
||||
path = ../dist/Embed/chrome/flashblock.jar;
|
||||
refType = 2;
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
};
|
||||
rootObject = 29B97313FDCFA39411CA2CEA;
|
||||
}
|
||||
|
|
|
@ -44,6 +44,7 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
DIRS = \
|
||||
IBPalette \
|
||||
flashblock \
|
||||
$(NULL)
|
||||
|
||||
APP_NAME = Camino
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
addWhitelistSite = id;
|
||||
clickEnableAdBlocking = id;
|
||||
clickEnableAnnoyanceBlocker = id;
|
||||
clickEnableFlashBlock = id;
|
||||
clickEnableImageResizing = id;
|
||||
clickEnableJS = id;
|
||||
clickEnableJava = id;
|
||||
|
@ -37,6 +38,7 @@
|
|||
mEditWhitelist = NSButton;
|
||||
mEnableAdBlocking = NSButton;
|
||||
mEnableAnnoyanceBlocker = NSButton;
|
||||
mEnableFlashBlock = NSButton;
|
||||
mEnableJS = NSButton;
|
||||
mEnableJava = NSButton;
|
||||
mEnablePlugins = NSButton;
|
||||
|
|
|
@ -3,17 +3,13 @@
|
|||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IBDocumentLocation</key>
|
||||
<string>2 4 356 240 0 0 1024 746 </string>
|
||||
<string>5 7 356 240 0 0 1920 1178 </string>
|
||||
<key>IBFramework Version</key>
|
||||
<string>446.1</string>
|
||||
<key>IBOldestOS</key>
|
||||
<integer>2</integer>
|
||||
<key>IBOpenObjects</key>
|
||||
<array>
|
||||
<integer>5</integer>
|
||||
</array>
|
||||
<key>IBSystem Version</key>
|
||||
<string>8J135</string>
|
||||
<string>8L127</string>
|
||||
<key>IBUserGuides</key>
|
||||
<dict>
|
||||
<key>312</key>
|
||||
|
@ -25,6 +21,16 @@
|
|||
<key>guidesLocked</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>5</key>
|
||||
<dict>
|
||||
<key>guideLocations</key>
|
||||
<array>
|
||||
<string>Vertical:297.000000</string>
|
||||
<string>Vertical:297.000000</string>
|
||||
</array>
|
||||
<key>guidesLocked</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
Двоичные данные
camino/PreferencePanes/WebFeatures/English.lproj/WebFeatures.nib/keyedobjects.nib
сгенерированный
Двоичные данные
camino/PreferencePanes/WebFeatures/English.lproj/WebFeatures.nib/keyedobjects.nib
сгенерированный
Двоичный файл не отображается.
|
@ -58,6 +58,7 @@ class nsISupportsArray;
|
|||
IBOutlet NSButton *mImageResize;
|
||||
IBOutlet NSButton *mPreventAnimation;
|
||||
IBOutlet NSButton *mEditWhitelist;
|
||||
IBOutlet NSButton *mEnableFlashBlock;
|
||||
|
||||
IBOutlet id mWhitelistPanel;
|
||||
IBOutlet ExtendedTableView* mWhitelistTable;
|
||||
|
@ -82,6 +83,7 @@ class nsISupportsArray;
|
|||
-(IBAction) clickEnableImageResizing:(id)sender;
|
||||
-(IBAction) clickPreventAnimation:(id)sender;
|
||||
-(IBAction) editWhitelist:(id)sender;
|
||||
-(IBAction) clickEnableFlashBlock:(id)sender;
|
||||
|
||||
-(IBAction) clickEnableAnnoyanceBlocker:(id)sender;
|
||||
-(void) setAnnoyingWindowPrefsTo:(BOOL)inValue;
|
||||
|
|
|
@ -56,8 +56,9 @@
|
|||
// but that requires linkage and extra search paths.
|
||||
static NSString* XPCOMShutDownNotificationName = @"XPCOMShutDown";
|
||||
|
||||
// needs to match the string in PreferenceManager.mm
|
||||
// need to match the strings in PreferenceManager.mm
|
||||
static NSString* const AdBlockingChangedNotificationName = @"AdBlockingChanged";
|
||||
static NSString* const kFlashBlockChangedNotificationName = @"FlashBlockChanged";
|
||||
|
||||
// for camino.enable_plugins; needs to match string in BrowserWrapper.mm
|
||||
static NSString* const kEnablePluginsChangedNotificationName = @"EnablePluginsChanged";
|
||||
|
@ -76,6 +77,8 @@ const int kAnnoyancePrefSome = 3;
|
|||
-(NSString*)profilePath;
|
||||
- (int)annoyingWindowPrefs;
|
||||
- (int)preventAnimationCheckboxState;
|
||||
- (BOOL)isFlashBlockAllowed;
|
||||
- (void)updateFlashBlock;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -144,6 +147,15 @@ const int kAnnoyancePrefSome = 3;
|
|||
BOOL enableAdBlock = [self getBooleanPref:"camino.enable_ad_blocking" withSuccess:&gotPref];
|
||||
[mEnableAdBlocking setState:enableAdBlock];
|
||||
|
||||
// Only allow FlashBlock if dependencies are set correctly
|
||||
BOOL flashBlockAllowed = [self isFlashBlockAllowed];
|
||||
[mEnableFlashBlock setEnabled:flashBlockAllowed];
|
||||
|
||||
if (flashBlockAllowed) {
|
||||
BOOL enableFlashBlock = [self getBooleanPref:"camino.enable_flashblock" withSuccess:nil];
|
||||
[mEnableFlashBlock setState:(enableFlashBlock ? NSOnState : NSOffState)];
|
||||
}
|
||||
|
||||
// Set inital values for tabfocus pref. Internally, it's a bitwise additive pref:
|
||||
// bit 0 adds focus for text fields (not exposed in the UI, so not given a constant)
|
||||
// bit 1 adds focus for other form elements (kFocusForms)
|
||||
|
@ -167,6 +179,9 @@ const int kAnnoyancePrefSome = 3;
|
|||
-(IBAction) clickEnableJS:(id)sender
|
||||
{
|
||||
[self setPref:"javascript.enabled" toBoolean:([sender state] == NSOnState)];
|
||||
|
||||
// FlashBlock depends on Javascript so make sure to update the FlashBlock settings
|
||||
[self updateFlashBlock];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -188,6 +203,9 @@ const int kAnnoyancePrefSome = 3;
|
|||
{
|
||||
[self setPref:"camino.enable_plugins" toBoolean:([sender state] == NSOnState)];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kEnablePluginsChangedNotificationName object:nil];
|
||||
|
||||
// FlashBlock depends on plug-ins so make sure to update the FlashBlock settings
|
||||
[self updateFlashBlock];
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -235,6 +253,18 @@ const int kAnnoyancePrefSome = 3;
|
|||
[self setPref:"image.animation_mode" toString:([sender state] ? @"once" : @"normal")];
|
||||
}
|
||||
|
||||
//
|
||||
// clickEnableFlashBlock:
|
||||
//
|
||||
// Enable and disable FlashBlock. When enabled, an icon is displayed and the
|
||||
// Flash animation plays when the user clicks it. When disabled, Flash plays automatically
|
||||
//
|
||||
-(IBAction) clickEnableFlashBlock:(id)sender
|
||||
{
|
||||
[self setPref:"camino.enable_flashblock" toBoolean:([sender state] == NSOnState)];
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kFlashBlockChangedNotificationName object:nil];
|
||||
}
|
||||
|
||||
//
|
||||
// populatePermissionCache:
|
||||
//
|
||||
|
@ -501,4 +531,43 @@ const int kAnnoyancePrefSome = 3;
|
|||
return [NSString stringWithUTF8String:nativePath.get()];
|
||||
}
|
||||
|
||||
//
|
||||
// isFlashBlockAllowed
|
||||
//
|
||||
// Checks whether FlashBlock can be enabled
|
||||
// FlashBlock only allowed if javascript and plug-ins enabled
|
||||
// NOTE: This code is duplicated in PreferenceManager.mm since the FlashBlock checkbox
|
||||
// settings are done by WebFeatures and stylesheet loading is done by PreferenceManager
|
||||
//
|
||||
-(BOOL) isFlashBlockAllowed
|
||||
{
|
||||
BOOL gotPref = NO;
|
||||
BOOL jsEnabled = [self getBooleanPref:"javascript.enabled" withSuccess:&gotPref] && gotPref;
|
||||
BOOL pluginsEnabled = [self getBooleanPref:"camino.enable_plugins" withSuccess:&gotPref] || !gotPref;
|
||||
|
||||
return jsEnabled && pluginsEnabled;
|
||||
}
|
||||
|
||||
//
|
||||
// updateFlashBlock
|
||||
//
|
||||
// Update the state of the FlashBlock checkbox
|
||||
//
|
||||
-(void) updateFlashBlock
|
||||
{
|
||||
BOOL allowed = [self isFlashBlockAllowed];
|
||||
[mEnableFlashBlock setEnabled:allowed];
|
||||
|
||||
// FlashBlock state can only change if it's already enabled
|
||||
// since changing dependencies won't have affect on disabled FlashBlock
|
||||
if (![self getBooleanPref:"camino.enable_flashblock" withSuccess:nil])
|
||||
return;
|
||||
|
||||
// FlashBlock preference is enabled. Checkbox is on if FlashBlock also allowed
|
||||
[mEnableFlashBlock setState:(allowed ? NSOnState : NSOffState)];
|
||||
|
||||
// Always send a notification, dependency verification is done by receiver.
|
||||
[[NSNotificationCenter defaultCenter] postNotificationName:kFlashBlockChangedNotificationName object:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -0,0 +1,63 @@
|
|||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is just a lowly Makefile.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Google Inc.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2007
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Mark Mentovai <mark@moxienet.com> (Original Author)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
# The presence of jar.mn causes $(SOURCE_CHROME_DIR)/$(JAR_FILE).jar to be
|
||||
# built and $(SOURCE_CHROME_DIR)/installed-chrome.txt to be updated. Camino
|
||||
# uses $(TARGET_CHROME_DIR)/installed-chrome.txt instead, though, so copy
|
||||
# the jar and update the correct installed-chrome.txt file.
|
||||
|
||||
SOURCE_CHROME_DIR = $(DIST)/bin/chrome
|
||||
TARGET_CHROME_DIR = $(DIST)/Embed/chrome
|
||||
INSTALLED_CHROME = $(TARGET_CHROME_DIR)/installed-chrome.txt
|
||||
CHROME_TYPE = content
|
||||
CHROME_PKG_NAME = flashblock
|
||||
JAR_FILE = $(CHROME_PKG_NAME)
|
||||
|
||||
libs realchrome:: $(CHROME_DEPS)
|
||||
chmod a-x $(INSTALLED_CHROME)
|
||||
$(NSINSTALL) -t -m 0644 \
|
||||
$(SOURCE_CHROME_DIR)/$(JAR_FILE).jar $(TARGET_CHROME_DIR)
|
||||
$(PERL) -I$(MOZILLA_DIR)/config $(MOZILLA_DIR)/config/add-chrome.pl \
|
||||
$(INSTALLED_CHROME) 0 $(CHROME_TYPE) $(CHROME_PKG_NAME) $(JAR_FILE)
|
|
@ -0,0 +1,10 @@
|
|||
Flash blocking for Camino is implemented using the FlashBlock extension
|
||||
from http://flashblock.mozdev.org/. FlashBlock is available under the
|
||||
MPL/GPL/LGPL tri-license. The files necessary for operation in Camino
|
||||
are placed in the content directory and referenced by the jar.mn
|
||||
manifest. A contents.rdf file is included to allow Camino to identify
|
||||
the contents of flashblock.jar.
|
||||
|
||||
Camino's bundled FlashBlock extension is currently synchronized with
|
||||
FlashBlock 1.5.2 from
|
||||
http://downloads.mozdev.org/flashblock/flashblock-1.5.2.xpi.
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 2.8 KiB |
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the packages being supplied by this jar -->
|
||||
<RDF:Seq about="urn:mozilla:package:root">
|
||||
<RDF:li resource="urn:mozilla:package:flashblock"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- package information -->
|
||||
<RDF:Description about="urn:mozilla:package:flashblock"
|
||||
chrome:displayName="Flashblock"
|
||||
chrome:author="The Flashblock team"
|
||||
chrome:authorURL="http://flashblock.mozdev.org/"
|
||||
chrome:name="flashblock"
|
||||
chrome:extension="true">
|
||||
</RDF:Description>
|
||||
</RDF:RDF>
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.6 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.5 KiB |
|
@ -0,0 +1,79 @@
|
|||
/*
|
||||
* Flash Click to View by Ted Mielczarek (luser_mozilla@perilith.com)
|
||||
* Original code by Jesse Ruderman (jruderman@hmc.edu)
|
||||
* taken from http://www.squarefree.com/userstyles/xbl.html
|
||||
*
|
||||
* Change XBL binding for <object> tags, click to view flash
|
||||
*/
|
||||
|
||||
/*
|
||||
* Flash identifiers.
|
||||
*/
|
||||
object[classid*=":D27CDB6E-AE6D-11cf-96B8-444553540000"],
|
||||
object[codebase*="swflash.cab"],
|
||||
object[data*=".swf"],
|
||||
embed[type="application/x-shockwave-flash"],
|
||||
embed[src*=".swf"],
|
||||
object[type="application/x-shockwave-flash"],
|
||||
object[src*=".swf"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#flash") !important; }
|
||||
|
||||
/*
|
||||
* Director identifiers.
|
||||
*/
|
||||
object[classid*=":166B1BCA-3F9C-11CF-8075-444553540000"],
|
||||
object[codebase*="sw.cab"],
|
||||
object[data*=".dcr"],
|
||||
embed[type="application/x-director"],
|
||||
embed[src*=".dcr"],
|
||||
object[type="application/x-director"],
|
||||
object[src*=".dcr"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#director") !important; }
|
||||
|
||||
/*
|
||||
* Authorware identifiers.
|
||||
*/
|
||||
object[classid*=":15B782AF-55D8-11D1-B477-006097098764"],
|
||||
object[codebase*="awswaxf.cab"],
|
||||
object[data*=".aam"],
|
||||
embed[type="application/x-authorware-map"],
|
||||
embed[src*=".aam"],
|
||||
object[type="application/x-authorware-map"],
|
||||
object[src*=".aam"]
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#authorware") !important; }
|
||||
|
||||
/*
|
||||
* Broken Objects.
|
||||
*/
|
||||
object
|
||||
{ -moz-binding: url("chrome://flashblock/content/flashblock.xml#brokenobject") !important; }
|
||||
|
||||
/*
|
||||
* Java identifiers.
|
||||
*/
|
||||
/*
|
||||
applet,
|
||||
object[classid*=":8AD9C840-044E-11D1-B3E9-00805F499D93"],
|
||||
object[classid^="clsid:CAFEEFAC-"],
|
||||
object[classid^="java:"],
|
||||
object[type="application/x-java-applet"],
|
||||
embed[classid*=":8AD9C840-044E-11D1-B3E9-00805F499D93"],
|
||||
embed[classid^="clsid:CAFEEFAC-"],
|
||||
embed[classid^="java:"],
|
||||
embed[type="application/x-java-applet"]
|
||||
{
|
||||
-moz-binding: none !important;
|
||||
}
|
||||
*/
|
||||
|
||||
/* sIFR styles */
|
||||
.sIFR-flash, .sIFR-flash object, .sIFR-flash embed,
|
||||
.sIFR-replaced div[style*="chrome://flashblock"] {
|
||||
-moz-binding: url("chrome://flashblock/content/flashblock.xml#sifr-replaced") !important;
|
||||
}
|
||||
|
||||
span.sIFR-alternate {
|
||||
-moz-binding: url("chrome://flashblock/content/flashblock.xml#sifr-alternate") !important;
|
||||
position: static !important;
|
||||
letter-spacing: normal !important;
|
||||
}
|
|
@ -0,0 +1,267 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<bindings
|
||||
xmlns="http://www.mozilla.org/xbl"
|
||||
xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
>
|
||||
|
||||
<binding id="flash">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
|
||||
//From Jesse's XPCNativeWrapper: http://mavra.perilith.com/~luser/content/native.js
|
||||
function nativeMethod(untrustedObject, methodName)
|
||||
{
|
||||
// happier stack traces and faster multiple calls
|
||||
var fun = Components.lookupMethod(untrustedObject, methodName);
|
||||
|
||||
return function()
|
||||
{
|
||||
return fun.apply(untrustedObject, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
function flashblockCreatePlaceholder(isStandalone) {
|
||||
// Create placeholder
|
||||
var flashblockCreateElement = nativeMethod(document, "createElement");
|
||||
var placeholder = flashblockCreateElement("div");
|
||||
placeholder.isStandalone = isStandalone;
|
||||
return placeholder;
|
||||
}
|
||||
|
||||
// Substitute the animation with a placeholder
|
||||
function flashblockShowPlaceholder() {
|
||||
// Just in case the object has been moved away from under our feet during
|
||||
// the timeout, re-assign the parent node. See bug 13680
|
||||
// parent = current.parentNode;
|
||||
var newParent = current.parentNode;
|
||||
parent = newParent ? newParent : parent;
|
||||
parent.insertBefore(placeholder, current);
|
||||
if(placeholder.isStandalone) {
|
||||
placeholder.flashblock = "frame";
|
||||
current.StopPlay();
|
||||
current.LoadMovie(0, "");
|
||||
current.prevWidth = current.width;
|
||||
current.prevHeight = current.height;
|
||||
current.width = current.height = 0;
|
||||
} else {
|
||||
placeholder.flashblock = "normal";
|
||||
parent.removeChild(current);
|
||||
}
|
||||
}
|
||||
|
||||
// Show the original animation
|
||||
function flashblockShowFlash() {
|
||||
if(placeholder.flashblock == "frame") {
|
||||
current.height = current.prevHeight;
|
||||
current.width = current.prevWidth;
|
||||
current.LoadMovie(0, current.src);
|
||||
} else {
|
||||
parent.insertBefore(current, placeholder);
|
||||
}
|
||||
parent.removeChild(placeholder);
|
||||
}
|
||||
|
||||
function flashblockIsWhitelisted() {
|
||||
// Check if the page that loaded the Flash site is whitelisted
|
||||
// Thanks to Neil on #mozilla for suggesting this method, I would never have
|
||||
// thought of it on my own. :-)
|
||||
// Lor 20041215: Use "UIEvents" to make it work in post-1.0 FF
|
||||
// (thanks to Neil again)
|
||||
var flashblockEvent = document.createEvent("UIEvents");
|
||||
|
||||
if(flashblockEvent) {
|
||||
flashblockEvent.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(flashblockEvent);
|
||||
if(flashblockEvent.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function flashblockSetImage(placeholder, type) {
|
||||
var inactiveurl = "chrome://flashblock/content/" + type + ".png";
|
||||
var activeurl = "chrome://flashblock/content/flashplay.png";
|
||||
placeholder.bgInactive = "url(" + inactiveurl + ") no-repeat center";
|
||||
placeholder.bgActive = "url(" + activeurl + ") no-repeat center";
|
||||
placeholder.style.background = placeholder.bgInactive;
|
||||
}
|
||||
|
||||
function flashblockStylePlaceholder(flash, placeholder) {
|
||||
// If object's size was relative, use that.
|
||||
// Otherwise, set size to minimum 32x32 px
|
||||
placeholder.style.minWidth = "32px !important";
|
||||
placeholder.style.minHeight = "32px !important";
|
||||
// The size and positioning may come from a class
|
||||
placeholder.setAttribute("class", flash.getAttribute("class"));
|
||||
|
||||
if(flash.width.match("%$")) {
|
||||
placeholder.style.width = current.width;
|
||||
} else {
|
||||
var width = parseInt(flash.width || flash.style.width);
|
||||
if (width && width >= 32) {
|
||||
placeholder.style.width = width + "px";
|
||||
}
|
||||
}
|
||||
|
||||
if(flash.height.match("%$")) {
|
||||
placeholder.style.height = flash.height;
|
||||
} else {
|
||||
var height = parseInt(flash.height || flash.style.height);
|
||||
if (height && height >= 32) {
|
||||
placeholder.style.height = height + "px";
|
||||
}
|
||||
}
|
||||
|
||||
// Add styling rules to placeholder div.
|
||||
placeholder.style.background = placeholder.bgInactive;
|
||||
placeholder.style.border = "1px solid #dfdfdf";
|
||||
placeholder.style.cursor = "pointer";
|
||||
placeholder.style.overflow = "hidden";
|
||||
|
||||
// The size of the placeholder should include borders too,
|
||||
// otherwise scrollbars appear for blocked standalone objects
|
||||
placeholder.style.MozBoxSizing = "border-box";
|
||||
}
|
||||
|
||||
var current = this;
|
||||
var parent = current.parentNode;
|
||||
|
||||
if(flashblockIsWhitelisted())
|
||||
return;
|
||||
|
||||
// Check parent too (case of working EMBED inside broken OBJECT)
|
||||
if (current.overrideCTV || parent.overrideCTV) {
|
||||
return;
|
||||
}
|
||||
current.overrideCTV = true;
|
||||
|
||||
if (this.brokenObject) {
|
||||
var params = this.getElementsByTagName("param");
|
||||
var isFlash = false;
|
||||
for (var ii = 0; ii < params.length; ii++) {
|
||||
var pvalue = params[ii].getAttribute("value");
|
||||
if (/\.swf/i.test(pvalue)) {
|
||||
isFlash = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
var embeds = this.getElementsByTagName("embed");
|
||||
for (var jj = 0; jj < embeds.length; jj++) {
|
||||
var embed = embeds[jj];
|
||||
if (/x-shockwave-flash/i.test(embed.getAttribute("type")) ||
|
||||
/\.swf/i.test(embed.getAttribute("src"))) {
|
||||
isFlash = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isFlash) {return;}
|
||||
}
|
||||
|
||||
// Create placeholder div
|
||||
var isStandalone = ("src" in current && current.src == current.ownerDocument.location);
|
||||
var placeholder = flashblockCreatePlaceholder(isStandalone);
|
||||
|
||||
// Set placeholder image
|
||||
var type = this.flashblockType ? this.flashblockType : "flash"
|
||||
flashblockSetImage(placeholder, type);
|
||||
|
||||
flashblockStylePlaceholder(current, placeholder);
|
||||
|
||||
// Change the placeholder background when the mouse enters/exits the div.
|
||||
placeholder.onmouseover = function()
|
||||
{
|
||||
this.style.background = this.bgActive;
|
||||
}
|
||||
|
||||
placeholder.onmouseout = function()
|
||||
{
|
||||
this.style.background = this.bgInactive;
|
||||
}
|
||||
|
||||
// Replace the flash document with a placeholder.
|
||||
var flashblockSetTimeout = nativeMethod(window, "setTimeout");
|
||||
flashblockSetTimeout(flashblockShowPlaceholder, 0);
|
||||
|
||||
// Replace the placeholder with the flash document.
|
||||
placeholder.onclick = flashblockShowFlash;
|
||||
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="director" extends="#flash">
|
||||
<implementation>
|
||||
<field name="flashblockType">"director"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="authorware" extends="#flash">
|
||||
<implementation>
|
||||
<field name="flashblockType">"authorware"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="brokenobject" extends="#flash">
|
||||
<implementation>
|
||||
<field name="brokenObject">"yes"</field>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="sifr-replaced">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
event = document.createEvent("UIEvents");
|
||||
|
||||
if(event) {
|
||||
event.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(event);
|
||||
if(event.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.style.height = 0;
|
||||
this.style.width = 0;
|
||||
this.style.display = "none !important";
|
||||
this.style.position ="absolute";
|
||||
this.style.overflow ="hidden";
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
<binding id="sifr-alternate">
|
||||
<implementation>
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
var event = document.createEvent("UIEvents");
|
||||
|
||||
if(event) {
|
||||
event.initEvent("flashblockCheckLoad", true, true);
|
||||
document.dispatchEvent(event);
|
||||
if(event.getPreventDefault() == true) {
|
||||
// Whitelisted
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
this.style.visibility = "visible !important";
|
||||
this.style.display = "block !important";
|
||||
//this.style.position = "static !important";
|
||||
this.style.left = "auto !important";
|
||||
this.style.top = "auto !important";
|
||||
this.style.height = "auto !important";
|
||||
this.style.width = "auto !important";
|
||||
]]>
|
||||
</constructor>
|
||||
</implementation>
|
||||
</binding>
|
||||
|
||||
</bindings>
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 3.5 KiB |
|
@ -0,0 +1,8 @@
|
|||
flashblock.jar:
|
||||
content/flashblock/contents.rdf (content/contents.rdf)
|
||||
content/flashblock/flashblock.xml (content/flashblock.xml)
|
||||
content/flashblock/flashblock.css (content/flashblock.css)
|
||||
content/flashblock/authorware.png (content/authorware.png)
|
||||
content/flashblock/director.png (content/director.png)
|
||||
content/flashblock/flash.png (content/flash.png)
|
||||
content/flashblock/flashplay.png (content/flashplay.png)
|
|
@ -78,6 +78,7 @@ NSString* const kPrefChangedPrefNameUserInfoKey = @"pref_name";
|
|||
|
||||
|
||||
static NSString* const AdBlockingChangedNotificationName = @"AdBlockingChanged";
|
||||
static NSString* const kFlashBlockChangedNotificationName = @"FlashBlockChanged";
|
||||
|
||||
#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_4
|
||||
// These are supposedly not available before the 10.4 SDK, but some of the
|
||||
|
@ -223,6 +224,9 @@ WriteVersion(nsIFile* aProfileDir, const nsACString& aVersion,
|
|||
|
||||
- (BOOL)cleanupUserContentCSS;
|
||||
- (void)refreshAdBlockingStyleSheet:(BOOL)inLoad;
|
||||
- (void)refreshFlashBlockStyleSheet:(BOOL)inLoad;
|
||||
- (void)refreshStyleSheet:(nsIURI *)cssFileURI load:(BOOL)inLoad;
|
||||
- (BOOL)isFlashBlockAllowed;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -437,6 +441,10 @@ static BOOL gMadePrefManager;
|
|||
name:AdBlockingChangedNotificationName
|
||||
object:nil];
|
||||
|
||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||
selector:@selector(flashBlockPrefChanged:)
|
||||
name:kFlashBlockChangedNotificationName
|
||||
object:nil];
|
||||
}
|
||||
|
||||
- (void)savePrefsFile
|
||||
|
@ -827,6 +835,11 @@ static BOOL gMadePrefManager;
|
|||
|
||||
if (enableAdBlocking)
|
||||
[self refreshAdBlockingStyleSheet:YES];
|
||||
|
||||
// Load flashblock if enabled. Make sure to test dependencies to avoid conflicts
|
||||
BOOL flashBlockAllowed = [self isFlashBlockAllowed];
|
||||
if (flashBlockAllowed && [self getBooleanPref:"camino.enable_flashblock" withSuccess:nil])
|
||||
[self refreshFlashBlockStyleSheet:YES];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
|
@ -997,6 +1010,14 @@ typedef enum EProxyConfig {
|
|||
[self refreshAdBlockingStyleSheet:adBlockingEnabled];
|
||||
}
|
||||
|
||||
- (void)flashBlockPrefChanged:(NSNotification*)inNotification
|
||||
{
|
||||
BOOL allowed = [self isFlashBlockAllowed];
|
||||
|
||||
BOOL flashBlockEnabled = allowed && [self getBooleanPref:"camino.enable_flashblock" withSuccess:nil];
|
||||
[self refreshFlashBlockStyleSheet:flashBlockEnabled];
|
||||
}
|
||||
|
||||
// some versions of 0.9a copied ad_blocking.css into <profile>/chrome/userContent.css.
|
||||
// now that we load ad_blocking.css dynamically, we have to move that file aside to
|
||||
// avoid loading it.
|
||||
|
@ -1024,10 +1045,6 @@ typedef enum EProxyConfig {
|
|||
// param is NO
|
||||
- (void)refreshAdBlockingStyleSheet:(BOOL)inLoad
|
||||
{
|
||||
nsCOMPtr<nsIStyleSheetService> ssService = do_GetService("@mozilla.org/content/style-sheet-service;1");
|
||||
if (!ssService)
|
||||
return;
|
||||
|
||||
// the the uri of the sheet in our bundle
|
||||
NSString* cssFilePath = [[NSBundle mainBundle] pathForResource:@"ad_blocking" ofType:@"css"];
|
||||
if (![[NSFileManager defaultManager] isReadableFileAtPath:cssFilePath]) {
|
||||
|
@ -1046,8 +1063,30 @@ typedef enum EProxyConfig {
|
|||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
[self refreshStyleSheet:cssFileURI load:inLoad];
|
||||
}
|
||||
|
||||
// this will reload the flashblock sheet if it's already registered, or unload it if the
|
||||
// param is NO
|
||||
- (void)refreshFlashBlockStyleSheet:(BOOL)inLoad
|
||||
{
|
||||
// the the uri of the flashblock sheet in the chrome path
|
||||
nsCOMPtr<nsIURI> cssFileURI;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(cssFileURI), "chrome://flashblock/content/flashblock.css");
|
||||
if (NS_FAILED(rv))
|
||||
return;
|
||||
|
||||
[self refreshStyleSheet:cssFileURI load:inLoad];
|
||||
}
|
||||
|
||||
- (void)refreshStyleSheet:(nsIURI *)cssFileURI load:(BOOL)inLoad
|
||||
{
|
||||
nsCOMPtr<nsIStyleSheetService> ssService = do_GetService("@mozilla.org/content/style-sheet-service;1");
|
||||
if (!ssService)
|
||||
return;
|
||||
|
||||
PRBool alreadyRegistered = PR_FALSE;
|
||||
rv = ssService->SheetRegistered(cssFileURI, nsIStyleSheetService::USER_SHEET, &alreadyRegistered);
|
||||
ssService->SheetRegistered(cssFileURI, nsIStyleSheetService::USER_SHEET, &alreadyRegistered);
|
||||
if (alreadyRegistered)
|
||||
ssService->UnregisterSheet(cssFileURI, nsIStyleSheetService::USER_SHEET);
|
||||
|
||||
|
@ -1338,4 +1377,21 @@ typedef enum EProxyConfig {
|
|||
[existingObservers removeObjectIdenticalTo:prefObserverOwner]; // this should release it and unregister the observer
|
||||
}
|
||||
|
||||
//
|
||||
// isFlashBlockAllowed
|
||||
//
|
||||
// Checks whether FlashBlock can be enabled
|
||||
// FlashBlock only allowed if javascript and plug-ins enabled
|
||||
// NOTE: This code is duplicated in WebFeatures.mm since the FlashBlock checkbox
|
||||
// settings are done by WebFeatures and stylesheet loading is done by PreferenceManager
|
||||
//
|
||||
-(BOOL) isFlashBlockAllowed
|
||||
{
|
||||
BOOL gotPref = NO;
|
||||
BOOL jsEnabled = [self getBooleanPref:"javascript.enabled" withSuccess:&gotPref] && gotPref;
|
||||
BOOL pluginsEnabled = [self getBooleanPref:"camino.enable_plugins" withSuccess:&gotPref] || !gotPref;
|
||||
|
||||
return jsEnabled && pluginsEnabled;
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Загрузка…
Ссылка в новой задаче