Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: chrome/browser/cocoa/applescript/window_applescript.mm

Issue 3163008: Removed a command which resulted in a crash.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/cocoa/applescript/window_applescript.h" 5 #import "chrome/browser/cocoa/applescript/window_applescript.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "base/scoped_nsobject.h" 8 #import "base/scoped_nsobject.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 return nil; 64 return nil;
65 } 65 }
66 66
67 if ((self = [super init])) { 67 if ((self = [super init])) {
68 browser_ = Browser::Create(aProfile); 68 browser_ = Browser::Create(aProfile);
69 browser_->NewTab(); 69 browser_->NewTab();
70 browser_->window()->Show(); 70 browser_->window()->Show();
71 scoped_nsobject<NSNumber> numID( 71 scoped_nsobject<NSNumber> numID(
72 [[NSNumber alloc] initWithInt:browser_->session_id().id()]); 72 [[NSNumber alloc] initWithInt:browser_->session_id().id()]);
73 [self setUniqueID:numID]; 73 [self setUniqueID:numID];
74 [self setContainer:
75 (BrowserCrApplication*)[BrowserCrApplication sharedApplication]
76 property:AppleScript::kWindowsProperty];
77 } 74 }
78 return self; 75 return self;
79 } 76 }
80 77
81 - (id)initWithBrowser:(Browser*)aBrowser { 78 - (id)initWithBrowser:(Browser*)aBrowser {
82 if (!aBrowser) { 79 if (!aBrowser) {
83 [self release]; 80 [self release];
84 return nil; 81 return nil;
85 } 82 }
86 83
87 if ((self = [super init])) { 84 if ((self = [super init])) {
88 // It is safe to be weak, if a window goes away (eg user closing a window) 85 // It is safe to be weak, if a window goes away (eg user closing a window)
89 // the applescript runtime calls appleScriptWindows in 86 // the applescript runtime calls appleScriptWindows in
90 // BrowserCrApplication and this particular window is never returned. 87 // BrowserCrApplication and this particular window is never returned.
91 browser_ = aBrowser; 88 browser_ = aBrowser;
92 scoped_nsobject<NSNumber> numID( 89 scoped_nsobject<NSNumber> numID(
93 [[NSNumber alloc] initWithInt:browser_->session_id().id()]); 90 [[NSNumber alloc] initWithInt:browser_->session_id().id()]);
94 [self setUniqueID:numID]; 91 [self setUniqueID:numID];
95 [self setContainer:NSApp
96 property:AppleScript::kWindowsProperty];
97 } 92 }
98 return self; 93 return self;
99 } 94 }
100 95
101 - (NSWindow*)nativeHandle { 96 - (NSWindow*)nativeHandle {
102 // window() can be NULL during startup. 97 // window() can be NULL during startup.
103 if (browser_->window()) 98 if (browser_->window())
104 return browser_->window()->GetNativeHandle(); 99 return browser_->window()->GetNativeHandle();
105 return nil; 100 return nil;
106 } 101 }
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 [[self nativeHandle] setValue:(id)value forKey:key]; 240 [[self nativeHandle] setValue:(id)value forKey:key];
246 } 241 }
247 242
248 - (void)handlesCloseScriptCommand:(NSCloseCommand*)command { 243 - (void)handlesCloseScriptCommand:(NSCloseCommand*)command {
249 // window() can be NULL during startup. 244 // window() can be NULL during startup.
250 if (browser_->window()) 245 if (browser_->window())
251 browser_->window()->Close(); 246 browser_->window()->Close();
252 } 247 }
253 248
254 @end 249 @end
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/applescript/scripting.sdef ('k') | chrome/browser/cocoa/applescript/window_applescript_test.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698