Created
January 16, 2010 18:04
-
-
Save hac/278925 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "KeywurlBrowserWindowController.h" | |
#include "KeywurlPlugin.h" | |
@implementation KeywurlBrowserWindowController | |
// We override this method to intercept addresses at an early stage without | |
// invoking Safari's fallback system. This is quicker as it avoids unnecessary | |
// DNS lookups | |
- (void) goToToolbarLocation: (id) sender { | |
KeywurlPlugin* plugin = [KeywurlPlugin sharedInstance]; | |
KeywordMapper* mapper = [plugin keywordMapper]; | |
NSString* input = [[_locationFieldEditor textStorage] string]; | |
if (input) { | |
BOOL useDefault = NO; | |
NSArray *inputComponents = [input componentsSeparatedByString:@" "]; | |
if ([mapper mappingForKeyword:[inputComponents objectAtIndex:0]]) | |
// URL begins with a search keyword and a space. | |
{ | |
useDefault = YES; | |
} | |
NSString* newUrl = [mapper mapKeywordInput: input withDefault: useDefault]; | |
if (![input isEqualToString: newUrl]) { | |
[_locationFieldEditor->field setObjectValue: newUrl]; | |
} | |
} | |
return [super goToToolbarLocation: sender]; | |
} | |
- (id) keywurl_locationFieldEditor { | |
return _locationFieldEditor; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment