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

Side by Side Diff: chrome/browser/login_prompt_mac.mm

Issue 194095: Fix crash when closing tab with an open http auth sheet. (Closed)
Patch Set: Created 11 years, 3 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
« 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/login_prompt.h" 5 #include "chrome/browser/login_prompt.h"
6 #import "chrome/browser/login_prompt_mac.h" 6 #import "chrome/browser/login_prompt_mac.h"
7 7
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/mac_util.h" 9 #include "base/mac_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 NOTREACHED(); 55 NOTREACHED();
56 } 56 }
57 } 57 }
58 58
59 virtual ~LoginHandlerMac() { 59 virtual ~LoginHandlerMac() {
60 if (login_model_) 60 if (login_model_)
61 login_model_->SetObserver(NULL); 61 login_model_->SetObserver(NULL);
62 } 62 }
63 63
64 void SetModel(LoginModel* model) { 64 void SetModel(LoginModel* model) {
65 if (login_model_)
66 login_model_->SetObserver(NULL);
65 login_model_ = model; 67 login_model_ = model;
66 if (login_model_) 68 if (login_model_)
67 login_model_->SetObserver(this); 69 login_model_->SetObserver(this);
68 } 70 }
69 71
70 // LoginModelObserver implementation. 72 // LoginModelObserver implementation.
71 virtual void OnAutofillDataAvailable(const std::wstring& username, 73 virtual void OnAutofillDataAvailable(const std::wstring& username,
72 const std::wstring& password) { 74 const std::wstring& password) {
73 [sheet_controller_ autofillLogin:base::SysWideToNSString(username) 75 [sheet_controller_ autofillLogin:base::SysWideToNSString(username)
74 password:base::SysWideToNSString(password)]; 76 password:base::SysWideToNSString(password)];
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 159
158 // Overridden from ConstrainedWindowMacDelegate: 160 // Overridden from ConstrainedWindowMacDelegate:
159 virtual void DeleteDelegate() { 161 virtual void DeleteDelegate() {
160 if (!WasAuthHandled(true)) { 162 if (!WasAuthHandled(true)) {
161 request_loop_->PostTask(FROM_HERE, NewRunnableMethod( 163 request_loop_->PostTask(FROM_HERE, NewRunnableMethod(
162 this, &LoginHandlerMac::CancelAuthDeferred)); 164 this, &LoginHandlerMac::CancelAuthDeferred));
163 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod( 165 ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
164 this, &LoginHandlerMac::SendNotifications)); 166 this, &LoginHandlerMac::SendNotifications));
165 } 167 }
166 168
169 // Close sheet if it's still open, as required by
170 // ConstrainedWindowMacDelegate.
171 DCHECK(MessageLoop::current() == ui_loop_);
172 if (is_sheet_open())
173 [NSApp endSheet:sheet()];
174
175 SetModel(NULL);
176
167 // Delete this object once all InvokeLaters have been called. 177 // Delete this object once all InvokeLaters have been called.
168 request_loop_->ReleaseSoon(FROM_HERE, this); 178 request_loop_->ReleaseSoon(FROM_HERE, this);
169 } 179 }
170 180
171 void OnLoginPressed(const std::wstring& username, 181 void OnLoginPressed(const std::wstring& username,
172 const std::wstring& password) { 182 const std::wstring& password) {
173 DCHECK(MessageLoop::current() == ui_loop_); 183 DCHECK(MessageLoop::current() == ui_loop_);
174 SetAuth(username, password); 184 SetAuth(username, password);
175 } 185 }
176 186
(...skipping 25 matching lines...) Expand all
202 // Verify that CancelAuth does destroy the request via our delegate. 212 // Verify that CancelAuth does destroy the request via our delegate.
203 DCHECK(request_ != NULL); 213 DCHECK(request_ != NULL);
204 ResetLoginHandlerForRequest(request_); 214 ResetLoginHandlerForRequest(request_);
205 } 215 }
206 } 216 }
207 217
208 // Closes the view_contents from the UI loop. 218 // Closes the view_contents from the UI loop.
209 void CloseContentsDeferred() { 219 void CloseContentsDeferred() {
210 DCHECK(MessageLoop::current() == ui_loop_); 220 DCHECK(MessageLoop::current() == ui_loop_);
211 221
212 // Close sheet if it's still open, as required by
213 // ConstrainedWindowMacDelegate.
214 if (is_sheet_open())
215 [NSApp endSheet:sheet()];
216
217 // The hosting ConstrainedWindow may have been freed. 222 // The hosting ConstrainedWindow may have been freed.
218 if (dialog_) 223 if (dialog_)
219 dialog_->CloseConstrainedWindow(); 224 dialog_->CloseConstrainedWindow();
220 } 225 }
221 226
222 // Returns whether authentication had been handled (SetAuth or CancelAuth). 227 // Returns whether authentication had been handled (SetAuth or CancelAuth).
223 // If |set_handled| is true, it will mark authentication as handled. 228 // If |set_handled| is true, it will mark authentication as handled.
224 bool WasAuthHandled(bool set_handled) { 229 bool WasAuthHandled(bool set_handled) {
225 AutoLock lock(handled_auth_lock_); 230 AutoLock lock(handled_auth_lock_);
226 bool was_handled = handled_auth_; 231 bool was_handled = handled_auth_;
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 340
336 - (void)autofillLogin:(NSString*)login password:(NSString*)password { 341 - (void)autofillLogin:(NSString*)login password:(NSString*)password {
337 if ([[nameField_ stringValue] length] == 0) { 342 if ([[nameField_ stringValue] length] == 0) {
338 [nameField_ setStringValue:login]; 343 [nameField_ setStringValue:login];
339 [passwordField_ setStringValue:password]; 344 [passwordField_ setStringValue:password];
340 [nameField_ selectText:self]; 345 [nameField_ selectText:self];
341 } 346 }
342 } 347 }
343 348
344 @end 349 @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