This commit is contained in:
Corey Johnson & Nathan Sobo
2012-02-28 13:20:55 -08:00
parent b37b45b4b1
commit d9697d6ad1
4 changed files with 21 additions and 21 deletions

View File

@@ -8,7 +8,7 @@ class ClientHandler;
@interface Atom : NSApplication<CefAppProtocol> {
NSView *_hiddenGlobalView;
BOOL handlingSendEvent_;
CefRefPtr<ClientHandler> _globalHandler;
CefRefPtr<ClientHandler> _clientHandler;
}
- (void)open:(NSString *)path;

View File

@@ -40,8 +40,8 @@
[super sendEvent:event];
}
- (void)createSharedContext {
_globalHandler = new ClientHandler(self);
- (void)createAtomContext {
_clientHandler = new ClientHandler(self);
CefWindowInfo window_info;
_hiddenGlobalView = [[NSView alloc] init];
@@ -50,7 +50,7 @@
CefBrowserSettings settings;
NSURL *resourceDirURL = [[NSBundle mainBundle] resourceURL];
NSString *indexURLString = [[resourceDirURL URLByAppendingPathComponent:@"index.html"] absoluteString];
CefBrowser::CreateBrowser(window_info, _globalHandler.get(), [indexURLString UTF8String], settings);
CefBrowser::CreateBrowser(window_info, _clientHandler.get(), [indexURLString UTF8String], settings);
}
- (void)open:(NSString *)path {
@@ -58,12 +58,12 @@
}
- (IBAction)runSpecs:(id)sender {
CefRefPtr<CefV8Context> appContext = _globalHandler->GetBrowser()->GetMainFrame()->GetV8Context();
[[AtomController alloc] initSpecsWithAppContext:appContext];
CefRefPtr<CefV8Context> atomContext = _clientHandler->GetBrowser()->GetMainFrame()->GetV8Context();
[[AtomController alloc] initSpecsWithAtomContext:atomContext];
}
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
[self createSharedContext];
[self createAtomContext];
}
- (void)applicationWillTerminate:(NSNotification *)aNotification {

View File

@@ -7,12 +7,12 @@ class ClientHandler;
NSView *_webView;
NSString *_bootstrapScript;
CefRefPtr<CefV8Context> _appContext;
CefRefPtr<ClientHandler> _handler;
CefRefPtr<CefV8Context> _atomContext;
CefRefPtr<ClientHandler> _clientHandler;
}
- (id)initWithBootstrapScript:(NSString *)bootstrapScript appContext:(CefRefPtr<CefV8Context>) context;
- (id)initSpecsWithAppContext:(CefRefPtr<CefV8Context>)appContext;
- (id)initWithBootstrapScript:(NSString *)bootstrapScript atomContext:(CefRefPtr<CefV8Context>) context;
- (id)initSpecsWithAtomContext:(CefRefPtr<CefV8Context>)atomContext;
- (void)createBrowser;

View File

@@ -13,10 +13,10 @@
[super dealloc];
}
- (id)initWithBootstrapScript:(NSString *)bootstrapScript appContext:(CefRefPtr<CefV8Context>)appContext {
- (id)initWithBootstrapScript:(NSString *)bootstrapScript atomContext:(CefRefPtr<CefV8Context>)atomContext {
self = [super initWithWindowNibName:@"ClientWindow"];
_bootstrapScript = [bootstrapScript retain];
_appContext = appContext;
_atomContext = atomContext;
[self createBrowser];
[self.window makeKeyAndOrderFront:nil];
@@ -24,15 +24,15 @@
return self;
}
- (id)initSpecsWithAppContext:(CefRefPtr<CefV8Context>)appContext {
return [self initWithBootstrapScript:@"spec-bootstrap" appContext:appContext];
- (id)initSpecsWithAtomContext:(CefRefPtr<CefV8Context>)atomContext {
return [self initWithBootstrapScript:@"spec-bootstrap" atomContext:atomContext];
}
- (void)createBrowser {
[self.window setDelegate:self];
[self.window setReleasedWhenClosed:NO];
_handler = new ClientHandler(self);
_clientHandler = new ClientHandler(self);
CefWindowInfo window_info;
CefBrowserSettings settings;
@@ -43,7 +43,7 @@
NSURL *resourceDirURL = [[NSBundle mainBundle] resourceURL];
NSString *indexURLString = [[resourceDirURL URLByAppendingPathComponent:@"index.html"] absoluteString];
CefBrowser::CreateBrowser(window_info, _handler.get(), [indexURLString UTF8String], settings);
CefBrowser::CreateBrowser(window_info, _clientHandler.get(), [indexURLString UTF8String], settings);
}
- (void)afterCreated:(CefRefPtr<CefBrowser>) browser {
@@ -63,7 +63,7 @@
CefRefPtr<CefV8Value> pathToOpen = CefV8Value::CreateString("~/");
global->SetValue("$pathToOpen", pathToOpen, V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue("atom", _appContext->GetGlobal()->GetValue("atom"), V8_PROPERTY_ATTRIBUTE_NONE);
global->SetValue("atom", _atomContext->GetGlobal()->GetValue("atom"), V8_PROPERTY_ATTRIBUTE_NONE);
context->Exit();
}
@@ -74,10 +74,10 @@
// sequence by getting rid of the window. By returning YES, we allow the window
// to be removed from the screen.
- (BOOL)windowShouldClose:(id)window {
_handler->GetBrowser()->CloseDevTools();
_clientHandler->GetBrowser()->CloseDevTools();
_appContext = NULL;
_handler = NULL;
_atomContext = NULL;
_clientHandler = NULL;
// Clean ourselves up after clearing the stack of anything that might have the window on it.
[self autorelease];