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

Side by Side Diff: chrome/browser/ui/cocoa/shell_dialogs_mac.mm

Issue 6031008: Mac: Try to fix a crash related to save panels. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 12 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "chrome/browser/shell_dialogs.h" 5 #include "chrome/browser/shell_dialogs.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 #include <CoreServices/CoreServices.h> 8 #include <CoreServices/CoreServices.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 18 matching lines...) Expand all
29 // A bridge class to act as the modal delegate to the save/open sheet and send 29 // A bridge class to act as the modal delegate to the save/open sheet and send
30 // the results to the C++ class. 30 // the results to the C++ class.
31 @interface SelectFileDialogBridge : NSObject<NSOpenSavePanelDelegate> { 31 @interface SelectFileDialogBridge : NSObject<NSOpenSavePanelDelegate> {
32 @private 32 @private
33 SelectFileDialogImpl* selectFileDialogImpl_; // WEAK; owns us 33 SelectFileDialogImpl* selectFileDialogImpl_; // WEAK; owns us
34 } 34 }
35 35
36 - (id)initWithSelectFileDialogImpl:(SelectFileDialogImpl*)s; 36 - (id)initWithSelectFileDialogImpl:(SelectFileDialogImpl*)s;
37 - (void)endedPanel:(NSSavePanel*)panel 37 - (void)endedPanel:(NSSavePanel*)panel
38 withReturn:(int)returnCode 38 withReturn:(int)returnCode
39 context:(void *)context; 39 context:(void*)context;
40 40
41 // NSSavePanel delegate method 41 // NSSavePanel delegate method
42 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename; 42 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename;
43 43
44 @end 44 @end
45 45
46 // Implementation of SelectFileDialog that shows Cocoa dialogs for choosing a 46 // Implementation of SelectFileDialog that shows Cocoa dialogs for choosing a
47 // file or folder. 47 // file or folder.
48 class SelectFileDialogImpl : public SelectFileDialog { 48 class SelectFileDialogImpl : public SelectFileDialog {
49 public: 49 public:
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // to hold the pointers, since we can't delete from the map as we're iterating 119 // to hold the pointers, since we can't delete from the map as we're iterating
120 // through it. 120 // through it.
121 std::vector<NSSavePanel*> panels; 121 std::vector<NSSavePanel*> panels;
122 for (std::map<NSSavePanel*, void*>::iterator it = params_map_.begin(); 122 for (std::map<NSSavePanel*, void*>::iterator it = params_map_.begin();
123 it != params_map_.end(); ++it) { 123 it != params_map_.end(); ++it) {
124 panels.push_back(it->first); 124 panels.push_back(it->first);
125 } 125 }
126 126
127 for (std::vector<NSSavePanel*>::iterator it = panels.begin(); 127 for (std::vector<NSSavePanel*>::iterator it = panels.begin();
128 it != panels.end(); ++it) { 128 it != panels.end(); ++it) {
129 [(*it) cancel:nil]; 129 [*it cancel:*it];
130 } 130 }
131 } 131 }
132 132
133 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const { 133 bool SelectFileDialogImpl::IsRunning(gfx::NativeWindow parent_window) const {
134 return parents_.find(parent_window) != parents_.end(); 134 return parents_.find(parent_window) != parents_.end();
135 } 135 }
136 136
137 void SelectFileDialogImpl::ListenerDestroyed() { 137 void SelectFileDialogImpl::ListenerDestroyed() {
138 listener_ = NULL; 138 listener_ = NULL;
139 } 139 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 if (!default_extension.empty()) 210 if (!default_extension.empty())
211 [dialog setRequiredFileType:base::SysUTF8ToNSString(default_extension)]; 211 [dialog setRequiredFileType:base::SysUTF8ToNSString(default_extension)];
212 212
213 params_map_[dialog] = params; 213 params_map_[dialog] = params;
214 type_map_[dialog] = type; 214 type_map_[dialog] = type;
215 215
216 SheetContext* context = new SheetContext; 216 SheetContext* context = new SheetContext;
217 217
218 // |context| should never be NULL, but we are seeing indications otherwise. 218 // |context| should never be NULL, but we are seeing indications otherwise.
219 // |This CHECK is here to confirm if we are actually getting NULL 219 // This CHECK is here to confirm if we are actually getting NULL
220 // ||context|s. http://crbug.com/58959 220 // |context|s. http://crbug.com/58959
221 CHECK(context); 221 CHECK(context);
222 context->type = type; 222 context->type = type;
223 context->owning_window = owning_window; 223 context->owning_window = owning_window;
224 224
225 if (type == SELECT_SAVEAS_FILE) { 225 if (type == SELECT_SAVEAS_FILE) {
226 [dialog beginSheetForDirectory:default_dir 226 [dialog beginSheetForDirectory:default_dir
227 file:default_filename 227 file:default_filename
228 modalForWindow:owning_window 228 modalForWindow:owning_window
229 modalDelegate:bridge_.get() 229 modalDelegate:bridge_.get()
230 didEndSelector:@selector(endedPanel:withReturn:context:) 230 didEndSelector:@selector(endedPanel:withReturn:context:)
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
354 - (id)initWithSelectFileDialogImpl:(SelectFileDialogImpl*)s { 354 - (id)initWithSelectFileDialogImpl:(SelectFileDialogImpl*)s {
355 self = [super init]; 355 self = [super init];
356 if (self != nil) { 356 if (self != nil) {
357 selectFileDialogImpl_ = s; 357 selectFileDialogImpl_ = s;
358 } 358 }
359 return self; 359 return self;
360 } 360 }
361 361
362 - (void)endedPanel:(NSSavePanel*)panel 362 - (void)endedPanel:(NSSavePanel*)panel
363 withReturn:(int)returnCode 363 withReturn:(int)returnCode
364 context:(void *)context { 364 context:(void*)context {
365 // |context| should never be NULL, but we are seeing indications otherwise. 365 // |context| should never be NULL, but we are seeing indications otherwise.
366 // |This CHECK is here to confirm if we are actually getting NULL 366 // |This CHECK is here to confirm if we are actually getting NULL
367 // ||context|s. http://crbug.com/58959 367 // ||context|s. http://crbug.com/58959
368 CHECK(context); 368 CHECK(context);
369 369
370 int index = 0; 370 int index = 0;
371 SelectFileDialogImpl::SheetContext* context_struct = 371 SelectFileDialogImpl::SheetContext* context_struct =
372 (SelectFileDialogImpl::SheetContext*)context; 372 (SelectFileDialogImpl::SheetContext*)context;
373 373
374 SelectFileDialog::Type type = context_struct->type; 374 SelectFileDialog::Type type = context_struct->type;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 paths, 408 paths,
409 index); 409 index);
410 [panel release]; 410 [panel release];
411 } 411 }
412 412
413 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { 413 - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename {
414 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename); 414 return selectFileDialogImpl_->ShouldEnableFilename(sender, filename);
415 } 415 }
416 416
417 @end 417 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698