/*
* $Id: STSafariPluginHandler.m 207 2010-01-31 00:08:34Z stuart $
*
* SafariTabs
* http://stuconnolly.com/projects/safaritabs/
*
* Copyright (c) 2010 Stuart Connolly. All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import <WebKit/WebKit.h>
#import "STSafariPluginHandler.h"
#import "STSessionHandler.h"
#import "STSessionRestoreController.h"
#import "BrowserDocument.h"
#import "STBrowserWindowController.h"
#import "STUpdater.h"
#import "STUpdaterDialogs.h"
#import "STConstants.h"
@implementation STSafariPluginHandler
/*!
* Returns the application's shared instance of the SafariTabs plugin.
*
* @return The application's shared instance of the SafariTabs plugin.
*/
+ (STSafariPluginHandler *)sharedInstance
{
// Singleton instance
static STSafariPluginHandler *_sharedPluginHandler = nil;
// Returns a single static instance of the plugin handler
if (_sharedPluginHandler == nil) {
_sharedPluginHandler = [[STSafariPluginHandler alloc] init];
}
return _sharedPluginHandler;
}
/*!
* Returns SafariTabs' main instance of its updater.
*
* @return SafariTabs' updater
*/
- (STUpdater *)safariTabsUpdater
{
if (!_updater) {
_updater = [[STUpdater alloc] init];
}
return _updater;
}
/*!
* Returns SafariTabs' main instance of its session handler.
*
* @return SafariTabs' session handler
*/
- (STSessionHandler *)sessionHandler
{
if (!_sessionHandler) {
_sessionHandler = [[STSessionHandler alloc] init];
}
return _sessionHandler;
}
/*!
* Returns SafariTabs' main instance of its session restore controller.
*
* @return SafariTabs' session restore controller
*/
- (STSessionRestoreController *)sessionRestoreController
{
if (!_sessionRestoreController) {
_sessionRestoreController = [[STSessionRestoreController alloc] initWithDelegate:self];
}
return _sessionRestoreController;
}
#pragma mark -
#pragma mark Updater Delegate Methods
- (void)updater
:(STUpdater
*)updater newVersionAvailable
:(NSString *)version
{
NSAlert *alert
= STGetNewVersionAvailableDialog
(version,
YES);
if ([alert runModal] == NSAlertDefaultReturn) {
[_updater downloadUpdate];
}
if ([[alert suppressionButton] state] == NSOnState) {
[[NSUserDefaults standardUserDefaults
] setBool
:NO forKey
:STCheckForUpdates
];
}
}
- (void)updaterDownloadUpdateError:(STUpdater *)updater
{
// Do nothing becuase we are checking in the background
}
- (void)updaterDownloadComplete:(STUpdater *)updater
{
STDisplayDownloadCompleteDialog();
}
- (void)updaterNoNewVersionAvailable:(STUpdater *)updater
{
// Do nothing becuase we are checking in the background
}
- (void)updaterCheckForUpdateError:(STUpdater *)updater
{
// Do nothing becuase we are checking in the background
}
#pragma mark -
/*!
* @brief Dealloc
*/
- (void)dealloc
{
[_updater release], _updater = nil;
[_sessionRestoreController release], _sessionRestoreController = nil;
[super dealloc];
}
@end