Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Simplified code to track living CTF views. Changed technique to find …

…views in front tab to use same views the observations use to actually load. Removed seemingly unused InvisibleItemMenu.xib. Updated settings panel to use + and - instead of words.
commit 16b844c96b6423629d6de707ee3fe69257dbd7ce 1 parent c12886a
Otyr Ugla authored
View
4 ClickToFlash.xcodeproj/project.pbxproj
@@ -43,7 +43,6 @@
6953E43C0F3EDEB50014ECF7 /* MenubarMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6953E43A0F3EDEB50014ECF7 /* MenubarMenu.xib */; };
69A26D0C0F302C10006648BC /* NSBezierPath-RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A26D0B0F302C10006648BC /* NSBezierPath-RoundedRectangle.m */; };
79A21C4D0F30B735009424B8 /* CTFWhitelistWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 79A21C490F30B735009424B8 /* CTFWhitelistWindowController.m */; };
- A4501BC80F4439FB00D04D61 /* OSAKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4501BC70F4439FB00D04D61 /* OSAKit.framework */; };
B5028E930F413553004886D7 /* HarnessAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = B5028E910F413553004886D7 /* HarnessAppDelegate.m */; };
B5CFF17A0F40EEF1005DB9CC /* WhitelistPanel.xib in Resources */ = {isa = PBXBuildFile; fileRef = 072189BC0F30D9C3008C8944 /* WhitelistPanel.xib */; };
B5CFF1870F40F000005DB9CC /* HarnessMain.xib in Resources */ = {isa = PBXBuildFile; fileRef = B5CFF1860F40F000005DB9CC /* HarnessMain.xib */; };
@@ -86,7 +85,6 @@
69A26D0B0F302C10006648BC /* NSBezierPath-RoundedRectangle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSBezierPath-RoundedRectangle.m"; path = "Plugin/NSBezierPath-RoundedRectangle.m"; sourceTree = "<group>"; };
79A21C490F30B735009424B8 /* CTFWhitelistWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTFWhitelistWindowController.m; path = Plugin/CTFWhitelistWindowController.m; sourceTree = "<group>"; };
79A21C4A0F30B735009424B8 /* CTFWhitelistWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTFWhitelistWindowController.h; path = Plugin/CTFWhitelistWindowController.h; sourceTree = "<group>"; };
- A4501BC70F4439FB00D04D61 /* OSAKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OSAKit.framework; path = /System/Library/Frameworks/OSAKit.framework; sourceTree = "<absolute>"; };
B5028E910F413553004886D7 /* HarnessAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = HarnessAppDelegate.m; path = "TestFiles/Debugging Harness/HarnessAppDelegate.m"; sourceTree = "<group>"; };
B5028E920F413553004886D7 /* HarnessAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HarnessAppDelegate.h; path = "TestFiles/Debugging Harness/HarnessAppDelegate.h"; sourceTree = "<group>"; };
B5CFF1740F40EEDB005DB9CC /* Whitelist Panel Harness.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Whitelist Panel Harness.app"; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -105,7 +103,6 @@
files = (
55EB70580E04A8B80016593D /* Cocoa.framework in Frameworks */,
55EB70590E04A8B80016593D /* WebKit.framework in Frameworks */,
- A4501BC80F4439FB00D04D61 /* OSAKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -164,7 +161,6 @@
children = (
55EB70560E04A8B80016593D /* Cocoa.framework */,
55EB70570E04A8B80016593D /* WebKit.framework */,
- A4501BC70F4439FB00D04D61 /* OSAKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
View
12 Plugin/CTFMenubarMenuController.h
@@ -26,25 +26,22 @@ THE SOFTWARE.
#import <Cocoa/Cocoa.h>
-
@class CTFWhitelistWindowController;
+
extern NSString* kCTFLoadAllFlashViews;
extern NSString* kCTFLoadFlashViewsForWindow;
extern NSString* kCTFLoadInvisibleFlashViewsForWindow;
-extern NSString* sCTFNewViewNotification;
-extern NSString* sCTFDestroyedViewNotification;
+
extern NSUInteger maxInvisibleDimension;
@interface CTFMenubarMenuController : NSObject {
IBOutlet NSMenu* menu;
CTFWhitelistWindowController *_whitelistWindowController;
- NSMutableDictionary *_flashViews;
+ NSHashTable *_views;
}
-@property (retain) NSMutableDictionary *flashViews;
-
+ (CTFMenubarMenuController*) sharedController;
- (void) loadFlashForWindow: (NSWindow*) window;
@@ -54,4 +51,7 @@ extern NSUInteger maxInvisibleDimension;
- (IBAction) loadKeyWindowInvisibleFlash: (id) sender;
- (IBAction) showSettingsWindow: (id) sender;
+- (void) registerView: (NSView*) view;
+- (void) unregisterView: (NSView*) view;
+
@end
View
204 Plugin/CTFMenubarMenuController.m
@@ -26,18 +26,15 @@ of this software and associated documentation files (the "Software"), to deal
#import "CTFMenubarMenuController.h"
#import "CTFWhitelistWindowController.h"
-#import <OSAKit/OSAKit.h>
-#import <WebKit/WebKit.h>
+#import "Plugin.h"
NSString* kCTFLoadAllFlashViews = @"CTFLoadAllFlashViews";
NSString* kCTFLoadFlashViewsForWindow = @"CTFLoadFlashViewsForWindow";
NSString* kCTFLoadInvisibleFlashViewsForWindow = @"CTFLoadInvisibleFlashViewsForWindow";
-NSString *sCTFNewViewNotification = @"CTFNewFlashView";
-NSString *sCTFDestroyedViewNotification = @"CTFDestroyedFlashView";
+
NSUInteger maxInvisibleDimension = 50;
-static CTFMenubarMenuController* sSingleton = nil;
static NSString* kApplicationsToInstallMenuInto[] = {
@"com.apple.Safari",
@@ -116,6 +113,9 @@ - (int) applicationMenuPrefsInsertionLocation
#pragma mark Lifetime management
+static CTFMenubarMenuController* sSingleton = nil;
+
+
- (id) init
{
if( sSingleton ) {
@@ -130,19 +130,10 @@ - (id) init
if( self ) {
if( ! [ NSBundle loadNibNamed: @"MenubarMenu" owner: self ] )
NSLog( @"ClickToFlash: Could not load menubar menu nib" );
+
+ _views = NSCreateHashTable( NSNonRetainedObjectHashCallBacks, 0 );
}
- NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
- [center addObserver: self
- selector: @selector( _trackNewView: )
- name: sCTFNewViewNotification
- object: nil ];
-
- [center addObserver: self
- selector: @selector( _stopTrackingView: )
- name: sCTFDestroyedViewNotification
- object: nil ];
-
return self;
}
@@ -150,7 +141,8 @@ - (id) init
- (void) dealloc
{
[ _whitelistWindowController release ];
-
+ NSFreeHashTable( _views );
+
[ super dealloc ];
}
@@ -196,167 +188,69 @@ + (CTFMenubarMenuController*) sharedController
#pragma mark -
#pragma mark View Management
-- (void) _trackNewView: (NSNotification*) notification
-{
- NSMutableDictionary *flashViewsDict = nil;
- if ([self flashViews])
- flashViewsDict = [[self flashViews] copy];
-
- if (! flashViewsDict) flashViewsDict = [NSMutableDictionary dictionary];
-
- NSString *newViewBaseURL = [[[notification userInfo] objectForKey:@"baseURL"] absoluteString];
- NSString *newViewSrc = [[notification userInfo] objectForKey:@"src"];
- NSNumber *newViewHeight = [[notification userInfo] objectForKey:@"height"];
- NSNumber *newViewWidth = [[notification userInfo] objectForKey:@"width"];
- id newTarget = [notification object];
-
- NSDictionary *newTargetDict = [NSDictionary dictionaryWithObjectsAndKeys:newTarget,@"target",newViewSrc,@"src",newViewHeight,@"height",newViewWidth,@"width",nil];
-
- NSMutableArray *baseURLArray = [flashViewsDict objectForKey:newViewBaseURL];
-
- if (! baseURLArray) {
- baseURLArray = [NSMutableArray arrayWithObject:newTargetDict];
- [flashViewsDict setObject:baseURLArray forKey:newViewBaseURL];
- } else {
- [baseURLArray addObject:newTargetDict];
- }
-
- [self setFlashViews:flashViewsDict];
-
- // not sure why, but the following lines causes crashes and unexpected behavior
- //[flashViewsDict release];
-}
-- (void) _stopTrackingView: (NSNotification*) notification
+- (void) registerView: (NSView*) view
{
- NSMutableDictionary *flashViewsDict = nil;
- if ([self flashViews])
- flashViewsDict = [[self flashViews] copy];
-
- if (! flashViewsDict) flashViewsDict = [NSMutableDictionary dictionary];
-
- NSString *baseURL = [[notification userInfo] objectForKey:@"baseURL"];
- NSMutableArray *baseURLArray = [flashViewsDict objectForKey:baseURL];
- id flashView = [notification object];
-
- if (! baseURLArray) {
- // we're apparently not tracking this view
- return;
- }
-
- NSDictionary *currentDictionary;
- BOOL foundView = NO;
- for (currentDictionary in baseURLArray) {
- if ([currentDictionary objectForKey:@"target"] == flashView) {
- foundView = YES;
- break;
- }
- }
-
- if (foundView) {
- // only do this stuff if we actually find the view we want to stop tracking
-
- [baseURLArray removeObject:currentDictionary];
- if ([baseURLArray count] == 0) [flashViewsDict removeObjectForKey:baseURL];
- [self setFlashViews:flashViewsDict];
- }
+ NSHashInsertIfAbsent( _views, view );
}
-- (NSString *)_baseURLOfKeyWindow;
-{
- // [[NSBundle mainBundle] bundleIdentifier|executablePath|bundlePath] all return stuff for Safari
- // even if called from WebKit
-
- // the following line crashes WebKit, so we can't use the Scripting Bridge until that is fixed
- // SafariApplication *safari = [SBApplication applicationWithProcessIdentifier:getpid()];
-
- NSString *webKitFrameworkBundlePath = [[NSBundle bundleForClass:[WebView class]] bundlePath];
-
- BOOL isWebKit = NO;
- if (! [webKitFrameworkBundlePath hasPrefix:@"/System/Library/Frameworks"]) {
- // we're not using the system version of WebKit, so it's the WebKit app
- isWebKit = YES;
- };
-
- // the following line doesn't seem to work reliably
- // BOOL isWebKit = [[[NSProcessInfo processInfo] arguments] containsObject:@"-WebKitDeveloperExtras"];
- NSString *appString = @"";
- if (isWebKit) {
- appString = @"WebKit";
- } else {
- appString = @"Safari";
- }
-
- NSString *appleScriptSourceString = [NSString stringWithFormat:@"tell application \"%@\"\nURL of current tab of front window\nend tell",appString];
-
-
- // I didn't want to bring OSACrashyScript into this, but I had to; sorry guys, Scripting Bridge
- // just totally crashes WebKit and that's unacceptable
-
- NSDictionary *errorDict = nil;
- OSAScript *browserNameScript = [[OSAScript alloc] initWithSource:appleScriptSourceString];
- NSAppleEventDescriptor *aeDesc = [browserNameScript executeAndReturnError:&errorDict];
- [browserNameScript release];
-
- NSString *baseURL = nil;
-
- if (! errorDict) baseURL = [aeDesc stringValue];
-
- return baseURL;
-}
-- (BOOL) _atLeastOneFlashViewExists;
+- (void) unregisterView: (NSView*) view
{
- NSLog(@"%@",[self flashViews]);
- return ([[[self flashViews] allKeys] count] >= 1);
+ NSHashRemove( _views, view );
}
-- (BOOL) _flashViewExistsForKeyWindow;
+- (BOOL) _atLeastOneFlashViewExists
{
- NSString *baseURL = [self _baseURLOfKeyWindow];
-
- // if there's an array for the base URL, there is at least one view
- // with that base URL
- return ([[self flashViews] objectForKey:baseURL] != nil);
+ return NSCountHashTable( _views ) > 0;
}
-- (BOOL) _invisibleFlashViewExistsForKeyWindow;
+
+- (BOOL) _flashViewExistsForKeyWindowWithInvisibleOnly: (BOOL) mustBeInvisible
{
- BOOL returnValue = NO;
- NSString *baseURL = [self _baseURLOfKeyWindow];
+ BOOL rslt = NO;
- NSMutableArray *baseURLArray = [[self flashViews] objectForKey:baseURL];
+ NSWindow* keyWindow = [ NSApp keyWindow ];
- if (baseURLArray) {
- NSDictionary *currentDictionary = nil;
-
- for (currentDictionary in baseURLArray) {
- NSUInteger height = [[currentDictionary objectForKey:@"height"] intValue];
- NSUInteger width = [[currentDictionary objectForKey:@"width"] intValue];
-
- if ((height <= maxInvisibleDimension) && (width <= maxInvisibleDimension)) {
- returnValue = YES;
+ NSHashEnumerator enumerator = NSEnumerateHashTable( _views );
+ CTFClickToFlashPlugin* item;
+ while( item = NSNextHashEnumeratorItem( &enumerator ) ) {
+ if( [ item window ] == keyWindow ) {
+ if( !mustBeInvisible || [ item isConsideredInvisible ] ) {
+ rslt = YES;
break;
}
}
}
+ NSEndHashTableEnumeration( &enumerator );
- return returnValue;
+ return rslt;
}
-- (BOOL)validateMenuItem:(NSMenuItem *)item {
- BOOL returnValue = YES;
-
- if ([item action] == @selector(loadAllFlash:)) {
- returnValue = [self _atLeastOneFlashViewExists];
- } else if ([item action] == @selector(loadKeyWindowFlash:)) {
- returnValue = [self _flashViewExistsForKeyWindow];
- } else if ([item action] == @selector(loadKeyWindowInvisibleFlash:)) {
- returnValue = [self _invisibleFlashViewExistsForKeyWindow];
+- (BOOL) _flashViewExistsForKeyWindow
+{
+ return [ self _flashViewExistsForKeyWindowWithInvisibleOnly: NO ];
+}
+
+- (BOOL) _invisibleFlashViewExistsForKeyWindow;
+{
+ return [ self _flashViewExistsForKeyWindowWithInvisibleOnly: YES ];
+}
+
+- (BOOL) validateMenuItem: (NSMenuItem*) item
+{
+ if ( [ item action ] == @selector( loadAllFlash: ) ) {
+ return [ self _atLeastOneFlashViewExists ];
+ }
+ else if( [ item action ] == @selector( loadKeyWindowFlash: ) ) {
+ return [ self _flashViewExistsForKeyWindow ];
+ }
+ else if( [ item action ] == @selector(loadKeyWindowInvisibleFlash: ) ) {
+ return [ self _invisibleFlashViewExistsForKeyWindow ];
}
- return returnValue;
+ return YES;
}
#pragma mark -
@@ -408,6 +302,4 @@ - (IBAction) showSettingsWindow: (id) sender
[ _whitelistWindowController showWindow: sender ];
}
-@synthesize flashViews = _flashViews;
-
@end
View
10 Plugin/CTFWhitelistWindowController.h
@@ -2,14 +2,8 @@
@interface CTFWhitelistWindowController : NSWindowController {
- IBOutlet NSArrayController *_controller;
-// NSMutableArray *_sites;
+ IBOutlet NSArrayController *_controller;
}
-//
-//- (IBAction) addWhitelistSite: (id) sender;
-//- (IBAction) removeWhitelistSite: (id) sender;
-//
-//- (void) saveWhitelist: (id) sender;
-//- (void) whitelistChanged: (NSNotification *) note;
+
@end
View
215 Plugin/English.lproj/InvisibleItemMenu.xib
@@ -1,215 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
- <data>
- <int key="IBDocument.SystemTarget">1050</int>
- <string key="IBDocument.SystemVersion">9G55</string>
- <string key="IBDocument.InterfaceBuilderVersion">667</string>
- <string key="IBDocument.AppKitVersion">949.43</string>
- <string key="IBDocument.HIToolboxVersion">353.00</string>
- <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- <object class="NSArray" key="IBDocument.PluginDependencies">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>com.apple.InterfaceBuilderKit</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- </object>
- <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSCustomObject" id="1001">
- <string key="NSClassName">CTFInvisibleItemMenuController</string>
- </object>
- <object class="NSCustomObject" id="1003">
- <string key="NSClassName">FirstResponder</string>
- </object>
- <object class="NSCustomObject" id="1004">
- <string key="NSClassName">NSApplication</string>
- </object>
- <object class="NSMenuItem" id="866385907">
- <string key="NSTitle">ClickToFlash</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <object class="NSCustomResource" key="NSOnImage" id="125481939">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuCheckmark</string>
- </object>
- <object class="NSCustomResource" key="NSMixedImage" id="211096061">
- <string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSMenuMixedState</string>
- </object>
- <string key="NSAction">submenuAction:</string>
- <object class="NSMenu" key="NSSubmenu" id="147427458">
- <string key="NSTitle">ClickToFlash</string>
- <object class="NSMutableArray" key="NSMenuItems">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- </object>
- </object>
- <object class="NSMenuItem" id="729930334">
- <string key="NSTitle">Load Invisible Flash Content</string>
- <string key="NSKeyEquiv"/>
- <int key="NSMnemonicLoc">2147483647</int>
- <reference key="NSOnImage" ref="125481939"/>
- <reference key="NSMixedImage" ref="211096061"/>
- </object>
- </object>
- <object class="IBObjectContainer" key="IBDocument.Objects">
- <object class="NSMutableArray" key="connectionRecords">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">theMenu</string>
- <reference key="source" ref="1001"/>
- <reference key="destination" ref="866385907"/>
- </object>
- <int key="connectionID">12</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBActionConnection" key="connection">
- <string key="label">loadInvisibleFlashContent:</string>
- <reference key="source" ref="1001"/>
- <reference key="destination" ref="729930334"/>
- </object>
- <int key="connectionID">22</int>
- </object>
- <object class="IBConnectionRecord">
- <object class="IBOutletConnection" key="connection">
- <string key="label">loadInvisibleContentMenuItem</string>
- <reference key="source" ref="1001"/>
- <reference key="destination" ref="729930334"/>
- </object>
- <int key="connectionID">31</int>
- </object>
- </object>
- <object class="IBMutableOrderedSet" key="objectRecords">
- <object class="NSArray" key="orderedObjects">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="IBObjectRecord">
- <int key="objectID">0</int>
- <object class="NSArray" key="object" id="1002">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- <reference key="children" ref="1000"/>
- <nil key="parent"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-2</int>
- <reference key="object" ref="1001"/>
- <reference key="parent" ref="1002"/>
- <string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-1</int>
- <reference key="object" ref="1003"/>
- <reference key="parent" ref="1002"/>
- <string key="objectName">First Responder</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">-3</int>
- <reference key="object" ref="1004"/>
- <reference key="parent" ref="1002"/>
- <string key="objectName">Application</string>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">2</int>
- <reference key="object" ref="729930334"/>
- <reference key="parent" ref="1002"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">8</int>
- <reference key="object" ref="866385907"/>
- <object class="NSMutableArray" key="children">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <reference ref="147427458"/>
- </object>
- <reference key="parent" ref="1002"/>
- </object>
- <object class="IBObjectRecord">
- <int key="objectID">9</int>
- <reference key="object" ref="147427458"/>
- <reference key="parent" ref="866385907"/>
- </object>
- </object>
- </object>
- <object class="NSMutableDictionary" key="flattenedProperties">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>-1.IBPluginDependency</string>
- <string>-2.IBPluginDependency</string>
- <string>-3.IBPluginDependency</string>
- <string>2.IBPluginDependency</string>
- <string>8.IBPluginDependency</string>
- <string>9.IBEditorWindowLastContentRect</string>
- <string>9.IBPluginDependency</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilderKit</string>
- <string>com.apple.InterfaceBuilderKit</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{330, 521}, {64, 6}}</string>
- <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- </object>
- </object>
- <object class="NSMutableDictionary" key="unlocalizedProperties">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- </object>
- <nil key="activeLocalization"/>
- <object class="NSMutableDictionary" key="localizations">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- </object>
- </object>
- <nil key="sourceID"/>
- <int key="maxID">31</int>
- </object>
- <object class="IBClassDescriber" key="IBDocument.Classes">
- <object class="NSMutableArray" key="referencedPartialClassDescriptions">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="IBPartialClassDescription">
- <string key="className">CTFInvisibleItemMenuController</string>
- <string key="superclassName">NSObject</string>
- <object class="NSMutableDictionary" key="actions">
- <string key="NS.key.0">loadInvisibleFlashContent:</string>
- <string key="NS.object.0">id</string>
- </object>
- <object class="NSMutableDictionary" key="outlets">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <object class="NSMutableArray" key="dict.sortedKeys">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>loadInvisibleContentMenuItem</string>
- <string>plugin</string>
- <string>theMenu</string>
- </object>
- <object class="NSMutableArray" key="dict.values">
- <bool key="EncodedWithXMLCoder">YES</bool>
- <string>NSMenuItem</string>
- <string>id</string>
- <string>NSMenuItem</string>
- </object>
- </object>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">CTFInvisibleItemMenuController.h</string>
- </object>
- </object>
- </object>
- </object>
- <int key="IBDocument.localizationMode">0</int>
- <string key="IBDocument.LastKnownRelativeProjectPath">../ClickToFlash.xcodeproj</string>
- <int key="IBDocument.defaultPropertyAccessControl">3</int>
- </data>
-</archive>
View
114 Plugin/English.lproj/WhitelistPanel.xib
@@ -38,7 +38,7 @@
<object class="NSWindowTemplate" id="1005">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
- <string key="NSWindowRect">{{80, 361}, {527, 342}}</string>
+ <string key="NSWindowRect">{{80, 343}, {527, 360}}</string>
<int key="NSWTFlags">-534248448</int>
<string type="base64-UTF8" key="NSWindowTitle">Q2xpY2sgdG8gRmxhc2gg4oCUIFNldHRpbmdzA</string>
<string key="NSWindowClass">NSPanel</string>
@@ -89,7 +89,7 @@
<int key="NSCellFlags">75628032</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Whitelisted Sites</string>
- <object class="NSFont" key="NSSupport" id="26">
+ <object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">1.100000e+01</double>
<int key="NSfFlags">3100</int>
@@ -204,7 +204,7 @@
</object>
<reference ref="929019191"/>
</object>
- <string key="NSFrame">{{20, 47}, {487, 169}}</string>
+ <string key="NSFrame">{{20, 41}, {487, 169}}</string>
<reference key="NSSuperview" ref="1006"/>
<reference key="NSNextKeyView" ref="769633510"/>
<int key="NSsFlags">530</int>
@@ -218,14 +218,18 @@
<object class="NSButton" id="43744226">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{82, 19}, {63, 26}}</string>
+ <string key="NSFrame">{{48, 13}, {29, 26}}</string>
<reference key="NSSuperview" ref="1006"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="13544439">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134348800</int>
- <string key="NSContents">Remove</string>
- <reference key="NSSupport" ref="26"/>
+ <string type="base64-UTF8" key="NSContents">4oiSA</string>
+ <object class="NSFont" key="NSSupport" id="872573082">
+ <string key="NSName">Courier</string>
+ <double key="NSSize">1.400000e+01</double>
+ <int key="NSfFlags">16</int>
+ </object>
<reference key="NSControlView" ref="43744226"/>
<int key="NSButtonFlags">-2038284033</int>
<int key="NSButtonFlags2">162</int>
@@ -238,14 +242,14 @@
<object class="NSButton" id="241393621">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">292</int>
- <string key="NSFrame">{{20, 19}, {63, 26}}</string>
+ <string key="NSFrame">{{20, 13}, {29, 26}}</string>
<reference key="NSSuperview" ref="1006"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="811527510">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134348800</int>
- <string key="NSContents">Add</string>
- <reference key="NSSupport" ref="26"/>
+ <string key="NSContents">+</string>
+ <reference key="NSSupport" ref="872573082"/>
<reference key="NSControlView" ref="241393621"/>
<int key="NSButtonFlags">-2038284033</int>
<int key="NSButtonFlags2">162</int>
@@ -258,7 +262,7 @@
<object class="NSTextField" id="513114676">
<reference key="NSNextResponder" ref="1006"/>
<int key="NSvFlags">289</int>
- <string key="NSFrame">{{227, 22}, {283, 17}}</string>
+ <string key="NSFrame">{{227, 14}, {283, 17}}</string>
<reference key="NSSuperview" ref="1006"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="363160467">
@@ -284,7 +288,7 @@
<object class="NSButton" id="619486495">
<reference key="NSNextResponder" ref="235344690"/>
<int key="NSvFlags">268</int>
- <string key="NSFrame">{{93, 77}, {236, 18}}</string>
+ <string key="NSFrame">{{93, 104}, {236, 18}}</string>
<reference key="NSSuperview" ref="235344690"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="356052318">
@@ -299,11 +303,11 @@
<reference key="NSControlView" ref="619486495"/>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">130</int>
- <object class="NSCustomResource" key="NSNormalImage">
+ <object class="NSCustomResource" key="NSNormalImage" id="1064838318">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSSwitch</string>
</object>
- <object class="NSButtonImageSource" key="NSAlternateImage">
+ <object class="NSButtonImageSource" key="NSAlternateImage" id="664243181">
<string key="NSImageName">NSSwitch</string>
</object>
<string key="NSAlternateContents"/>
@@ -312,10 +316,32 @@
<int key="NSPeriodicInterval">25</int>
</object>
</object>
+ <object class="NSButton" id="90714319">
+ <reference key="NSNextResponder" ref="235344690"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{93, 84}, {271, 18}}</string>
+ <reference key="NSSuperview" ref="235344690"/>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSButtonCell" key="NSCell" id="688316371">
+ <int key="NSCellFlags">-2080244224</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSContents">Automatically load invisible Flash views</string>
+ <reference key="NSSupport" ref="906693409"/>
+ <reference key="NSControlView" ref="90714319"/>
+ <int key="NSButtonFlags">1211912703</int>
+ <int key="NSButtonFlags2">130</int>
+ <reference key="NSNormalImage" ref="1064838318"/>
+ <reference key="NSAlternateImage" ref="664243181"/>
+ <string key="NSAlternateContents"/>
+ <string key="NSKeyEquivalent"/>
+ <int key="NSPeriodicDelay">200</int>
+ <int key="NSPeriodicInterval">25</int>
+ </object>
+ </object>
<object class="NSTextField" id="972818591">
<reference key="NSNextResponder" ref="235344690"/>
<int key="NSvFlags">268</int>
- <string key="NSFrame">{{26, 78}, {58, 17}}</string>
+ <string key="NSFrame">{{26, 105}, {58, 17}}</string>
<reference key="NSSuperview" ref="235344690"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1061234246">
@@ -331,7 +357,7 @@
<object class="NSMatrix" id="211748724">
<reference key="NSNextResponder" ref="235344690"/>
<int key="NSvFlags">268</int>
- <string key="NSFrame">{{93, 2}, {285, 58}}</string>
+ <string key="NSFrame">{{93, 9}, {285, 58}}</string>
<reference key="NSSuperview" ref="235344690"/>
<bool key="NSEnabled">YES</bool>
<int key="NSNumRows">3</int>
@@ -602,7 +628,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSTextField" id="1020124743">
<reference key="NSNextResponder" ref="235344690"/>
<int key="NSvFlags">268</int>
- <string key="NSFrame">{{17, 43}, {67, 17}}</string>
+ <string key="NSFrame">{{17, 50}, {67, 17}}</string>
<reference key="NSSuperview" ref="235344690"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="393278813">
@@ -616,12 +642,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
</object>
- <string key="NSFrame">{{65, 231}, {397, 115}}</string>
+ <string key="NSFrame">{{65, 222}, {397, 142}}</string>
<reference key="NSSuperview" ref="1006"/>
<string key="NSClassName">NSView</string>
</object>
</object>
- <string key="NSFrameSize">{527, 342}</string>
+ <string key="NSFrameSize">{527, 360}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
@@ -772,6 +798,22 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">130</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBBindingConnection" key="connection">
+ <string key="label">value: values.ClickToFlash_autoLoadInvisibleViews</string>
+ <reference key="source" ref="90714319"/>
+ <reference key="destination" ref="913882380"/>
+ <object class="NSNibBindingConnector" key="connector">
+ <reference key="NSSource" ref="90714319"/>
+ <reference key="NSDestination" ref="913882380"/>
+ <string key="NSLabel">value: values.ClickToFlash_autoLoadInvisibleViews</string>
+ <string key="NSBinding">value</string>
+ <string key="NSKeyPath">values.ClickToFlash_autoLoadInvisibleViews</string>
+ <int key="NSNibBindingConnectorVersion">2</int>
+ </object>
+ </object>
+ <int key="connectionID">136</int>
+ </object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@@ -818,9 +860,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="510641939"/>
<reference ref="235344690"/>
- <reference ref="43744226"/>
<reference ref="241393621"/>
<reference ref="513114676"/>
+ <reference ref="43744226"/>
</object>
<reference key="parent" ref="1005"/>
</object>
@@ -922,6 +964,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference ref="972818591"/>
<reference ref="211748724"/>
<reference ref="1020124743"/>
+ <reference ref="90714319"/>
</object>
<reference key="parent" ref="1006"/>
</object>
@@ -1013,6 +1056,20 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="object" ref="811527510"/>
<reference key="parent" ref="241393621"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">131</int>
+ <reference key="object" ref="90714319"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="688316371"/>
+ </object>
+ <reference key="parent" ref="235344690"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">132</int>
+ <reference key="object" ref="688316371"/>
+ <reference key="parent" ref="90714319"/>
+ </object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@@ -1044,6 +1101,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>114.IBPluginDependency</string>
<string>12.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
+ <string>131.IBAttributePlaceholdersKey</string>
+ <string>131.IBPluginDependency</string>
+ <string>132.IBPluginDependency</string>
<string>14.IBPluginDependency</string>
<string>17.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
@@ -1064,9 +1124,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilderKit</string>
<string>com.apple.InterfaceBuilderKit</string>
- <string>{{38, 380}, {527, 342}}</string>
+ <string>{{46, 1154}, {527, 360}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
- <string>{{38, 380}, {527, 342}}</string>
+ <string>{{46, 1154}, {527, 360}}</string>
<integer value="1"/>
<string>{196, 240}</string>
<string>{{202, 428}, {480, 270}}</string>
@@ -1100,6 +1160,16 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <object class="NSMutableDictionary">
+ <string key="NS.key.0">ToolTip</string>
+ <object class="IBToolTipAttribute" key="NS.object.0">
+ <string key="name">ToolTip</string>
+ <reference key="object" ref="90714319"/>
+ <string key="toolTip">Loads H.264 movie version of YouTube videos by default when possible.</string>
+ </object>
+ </object>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1143,7 +1213,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</object>
<nil key="sourceID"/>
- <int key="maxID">130</int>
+ <int key="maxID">136</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
View
2  Plugin/Plugin.h
@@ -61,4 +61,6 @@ THE SOFTWARE.
- (IBAction)loadH264:(id)sender;
- (IBAction)loadAllOnPage:(id)sender;
+- (BOOL) isConsideredInvisible;
+
@end
View
49 Plugin/Plugin.m
@@ -276,28 +276,20 @@ - (id) initWithArguments:(NSDictionary *)arguments
// send a notification so that all flash objects can be tracked
- DOMElement *clonedElement = (DOMElement *)[self.container cloneNode:YES];
- int height = [[clonedElement getAttribute:@"height"] intValue];
- int width = [[clonedElement getAttribute:@"width"] intValue];
-
- if ([ [ NSUserDefaults standardUserDefaults ] boolForKey: sAutoLoadInvisibleFlashViewsKey ] &&
- ((height <= maxInvisibleDimension) && (width <= maxInvisibleDimension) ) ) {
+ if ( [ [ NSUserDefaults standardUserDefaults ] boolForKey: sAutoLoadInvisibleFlashViewsKey ]
+ && [ self isConsideredInvisible ] ) {
// auto-loading is on and this view meets the size constraints
[self _convertTypesForContainer];
} else {
// we only want to track it if we don't auto-load it
- [[NSNotificationCenter defaultCenter] postNotificationName:sCTFNewViewNotification
- object:self
- userInfo:[NSDictionary dictionaryWithObjectsAndKeys:base,@"baseURL",src,@"src",
- [NSNumber numberWithInt:height],@"height",[NSNumber numberWithInt:width],@"width",nil]
- ];
+ [[CTFMenubarMenuController sharedController] registerView: self];
}
// Observe various things:
NSNotificationCenter* center = [NSNotificationCenter defaultCenter];
- // Observe for additions to the whitelist (can't use KVO due to the dot in the pref key):
+ // Observe for additions to the whitelist:
[center addObserver: self
selector: @selector( _whitelistAdditionMade: )
name: sCTFWhitelistAdditionMade
@@ -327,11 +319,7 @@ - (void) dealloc
[self _abortAlert]; // to be on the safe side
// notify that this ClickToFlash plugin is going away
- [[NSNotificationCenter defaultCenter] postNotificationName:sCTFDestroyedViewNotification
- object:self
- userInfo:[NSDictionary dictionaryWithObject:[self baseURL]
- forKey:@"baseURL"]
- ];
+ [[CTFMenubarMenuController sharedController] unregisterView: self];
self.container = nil;
self.host = nil;
@@ -487,6 +475,16 @@ - (void) _whitelistAdditionMade: (NSNotification*) notification
[self _convertTypesForContainer];
}
+- (BOOL) isConsideredInvisible
+{
+ DOMElement* clonedElement = (DOMElement*) [ self.container cloneNode: NO ];
+
+ int height = [[clonedElement getAttribute:@"height"] intValue];
+ int width = [[clonedElement getAttribute:@"width"] intValue];
+
+ return (height <= maxInvisibleDimension) && (width <= maxInvisibleDimension);
+}
+
#pragma mark -
#pragma mark Contextual menu
@@ -585,14 +583,8 @@ - (void) _loadContentForWindow: (NSNotification*) notification
- (void) _loadInvisibleContentForWindow: (NSNotification*) notification
{
- if( [ notification object ] == [ self window ] ) {
- DOMElement* clonedElement = (DOMElement*) [ self.container cloneNode: NO ];
- int height = [[clonedElement getAttribute:@"height"] intValue];
- int width = [[clonedElement getAttribute:@"width"] intValue];
-
- if ( (height <= maxInvisibleDimension) || (width <= maxInvisibleDimension) ) {
- [ self _convertTypesForContainer ];
- }
+ if( [ notification object ] == [ self window ] && [ self isConsideredInvisible ] ) {
+ [ self _convertTypesForContainer ];
}
}
@@ -842,12 +834,7 @@ - (void) _convertTypesForElement:(DOMElement *)element
- (void) _convertTypesForContainer
{
// notify that this ClickToFlash plugin is going away
- [[NSNotificationCenter defaultCenter] postNotificationName:sCTFDestroyedViewNotification
- object:self
- userInfo:[NSDictionary dictionaryWithObject:[self baseURL]
- forKey:@"baseURL"]
- ];
-
+ [[CTFMenubarMenuController sharedController] unregisterView: self];
if ([self _useH264Version])
[self _convertToMP4Container];
Please sign in to comment.
Something went wrong with that request. Please try again.