OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/login/login_prompt.h" | 5 #include "chrome/browser/ui/login/login_prompt.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/synchronization/lock.h" | 10 #include "base/synchronization/lock.h" |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Reference is no longer valid. | 185 // Reference is no longer valid. |
186 request_ = NULL; | 186 request_ = NULL; |
187 | 187 |
188 // Give up on auth if the request was cancelled. | 188 // Give up on auth if the request was cancelled. |
189 CancelAuth(); | 189 CancelAuth(); |
190 } | 190 } |
191 | 191 |
192 void LoginHandler::AddObservers() { | 192 void LoginHandler::AddObservers() { |
193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 193 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
194 | 194 |
| 195 // This is probably OK; we need to listen to everything and we break out of |
| 196 // the Observe() if we aren't handling the same auth_info(). |
195 registrar_.Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED, | 197 registrar_.Add(this, chrome::NOTIFICATION_AUTH_SUPPLIED, |
196 NotificationService::AllSources()); | 198 NotificationService::AllBrowserContextsAndSources()); |
197 registrar_.Add(this, chrome::NOTIFICATION_AUTH_CANCELLED, | 199 registrar_.Add(this, chrome::NOTIFICATION_AUTH_CANCELLED, |
198 NotificationService::AllSources()); | 200 NotificationService::AllBrowserContextsAndSources()); |
199 } | 201 } |
200 | 202 |
201 void LoginHandler::RemoveObservers() { | 203 void LoginHandler::RemoveObservers() { |
202 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 204 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
203 | 205 |
204 registrar_.Remove(this, chrome::NOTIFICATION_AUTH_SUPPLIED, | 206 registrar_.Remove(this, chrome::NOTIFICATION_AUTH_SUPPLIED, |
205 NotificationService::AllSources()); | 207 NotificationService::AllBrowserContextsAndSources()); |
206 registrar_.Remove(this, chrome::NOTIFICATION_AUTH_CANCELLED, | 208 registrar_.Remove(this, chrome::NOTIFICATION_AUTH_CANCELLED, |
207 NotificationService::AllSources()); | 209 NotificationService::AllBrowserContextsAndSources()); |
208 | 210 |
209 DCHECK(registrar_.IsEmpty()); | 211 DCHECK(registrar_.IsEmpty()); |
210 } | 212 } |
211 | 213 |
212 void LoginHandler::Observe(int type, | 214 void LoginHandler::Observe(int type, |
213 const NotificationSource& source, | 215 const NotificationSource& source, |
214 const NotificationDetails& details) { | 216 const NotificationDetails& details) { |
215 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
216 DCHECK(type == chrome::NOTIFICATION_AUTH_SUPPLIED || | 218 DCHECK(type == chrome::NOTIFICATION_AUTH_SUPPLIED || |
217 type == chrome::NOTIFICATION_AUTH_CANCELLED); | 219 type == chrome::NOTIFICATION_AUTH_CANCELLED); |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 // Public API | 482 // Public API |
481 | 483 |
482 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 484 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
483 net::URLRequest* request) { | 485 net::URLRequest* request) { |
484 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 486 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
485 BrowserThread::PostTask( | 487 BrowserThread::PostTask( |
486 BrowserThread::UI, FROM_HERE, new LoginDialogTask( | 488 BrowserThread::UI, FROM_HERE, new LoginDialogTask( |
487 request->url(), auth_info, handler)); | 489 request->url(), auth_info, handler)); |
488 return handler; | 490 return handler; |
489 } | 491 } |
OLD | NEW |