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

Side by Side Diff: chrome/browser/ui/login/login_prompt.cc

Issue 8590012: base::Bind migrations in chrome/browser (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 1 month 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 | « chrome/browser/ui/input_window_dialog_win.cc ('k') | chrome/browser/ui/select_file_dialog.cc » ('j') | 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) 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/bind.h"
9 #include "base/command_line.h" 10 #include "base/command_line.h"
10 #include "base/synchronization/lock.h" 11 #include "base/synchronization/lock.h"
11 #include "base/utf_string_conversions.h" 12 #include "base/utf_string_conversions.h"
12 #include "chrome/browser/password_manager/password_manager.h" 13 #include "chrome/browser/password_manager/password_manager.h"
13 #include "chrome/browser/tab_contents/tab_util.h" 14 #include "chrome/browser/tab_contents/tab_util.h"
14 #include "chrome/browser/ui/constrained_window.h" 15 #include "chrome/browser/ui/constrained_window.h"
15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
16 #include "chrome/common/chrome_notification_types.h" 17 #include "chrome/common/chrome_notification_types.h"
17 #include "content/browser/renderer_host/render_view_host.h" 18 #include "content/browser/renderer_host/render_view_host.h"
18 #include "content/browser/renderer_host/render_view_host_delegate.h" 19 #include "content/browser/renderer_host/render_view_host_delegate.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // This constructor is called on the I/O thread, so we cannot load the nib 84 // This constructor is called on the I/O thread, so we cannot load the nib
84 // here. BuildViewForPasswordManager() will be invoked on the UI thread 85 // here. BuildViewForPasswordManager() will be invoked on the UI thread
85 // later, so wait with loading the nib until then. 86 // later, so wait with loading the nib until then.
86 DCHECK(request_) << "LoginHandler constructed with NULL request"; 87 DCHECK(request_) << "LoginHandler constructed with NULL request";
87 DCHECK(auth_info_) << "LoginHandler constructed with NULL auth info"; 88 DCHECK(auth_info_) << "LoginHandler constructed with NULL auth info";
88 89
89 AddRef(); // matched by LoginHandler::ReleaseSoon(). 90 AddRef(); // matched by LoginHandler::ReleaseSoon().
90 91
91 BrowserThread::PostTask( 92 BrowserThread::PostTask(
92 BrowserThread::UI, FROM_HERE, 93 BrowserThread::UI, FROM_HERE,
93 NewRunnableMethod(this, &LoginHandler::AddObservers)); 94 base::Bind(&LoginHandler::AddObservers, this));
94 95
95 if (!ResourceDispatcherHost::RenderViewForRequest( 96 if (!ResourceDispatcherHost::RenderViewForRequest(
96 request_, &render_process_host_id_, &tab_contents_id_)) { 97 request_, &render_process_host_id_, &tab_contents_id_)) {
97 NOTREACHED(); 98 NOTREACHED();
98 } 99 }
99 } 100 }
100 101
101 LoginHandler::~LoginHandler() { 102 LoginHandler::~LoginHandler() {
102 SetModel(NULL); 103 SetModel(NULL);
103 } 104 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 // Calling NotifyAuthSupplied() directly instead of posting a task 144 // Calling NotifyAuthSupplied() directly instead of posting a task
144 // allows other LoginHandler instances to queue their 145 // allows other LoginHandler instances to queue their
145 // CloseContentsDeferred() before ours. Closing dialogs in the 146 // CloseContentsDeferred() before ours. Closing dialogs in the
146 // opposite order as they were created avoids races where remaining 147 // opposite order as they were created avoids races where remaining
147 // dialogs in the same tab may be briefly displayed to the user 148 // dialogs in the same tab may be briefly displayed to the user
148 // before they are removed. 149 // before they are removed.
149 NotifyAuthSupplied(username, password); 150 NotifyAuthSupplied(username, password);
150 151
151 BrowserThread::PostTask( 152 BrowserThread::PostTask(
152 BrowserThread::UI, FROM_HERE, 153 BrowserThread::UI, FROM_HERE,
153 NewRunnableMethod(this, &LoginHandler::CloseContentsDeferred)); 154 base::Bind(&LoginHandler::CloseContentsDeferred, this));
154 BrowserThread::PostTask( 155 BrowserThread::PostTask(
155 BrowserThread::IO, FROM_HERE, 156 BrowserThread::IO, FROM_HERE,
156 NewRunnableMethod( 157 base::Bind(&LoginHandler::SetAuthDeferred, this, username, password));
157 this, &LoginHandler::SetAuthDeferred, username, password));
158 } 158 }
159 159
160 void LoginHandler::CancelAuth() { 160 void LoginHandler::CancelAuth() {
161 if (TestAndSetAuthHandled()) 161 if (TestAndSetAuthHandled())
162 return; 162 return;
163 163
164 // Similar to how we deal with notifications above in SetAuth() 164 // Similar to how we deal with notifications above in SetAuth()
165 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) { 165 if (BrowserThread::CurrentlyOn(BrowserThread::UI)) {
166 NotifyAuthCancelled(); 166 NotifyAuthCancelled();
167 } else { 167 } else {
168 BrowserThread::PostTask( 168 BrowserThread::PostTask(
169 BrowserThread::UI, FROM_HERE, 169 BrowserThread::UI, FROM_HERE,
170 NewRunnableMethod(this, &LoginHandler::NotifyAuthCancelled)); 170 base::Bind(&LoginHandler::NotifyAuthCancelled, this));
171 } 171 }
172 172
173 BrowserThread::PostTask( 173 BrowserThread::PostTask(
174 BrowserThread::UI, FROM_HERE, 174 BrowserThread::UI, FROM_HERE,
175 NewRunnableMethod(this, &LoginHandler::CloseContentsDeferred)); 175 base::Bind(&LoginHandler::CloseContentsDeferred, this));
176 BrowserThread::PostTask( 176 BrowserThread::PostTask(
177 BrowserThread::IO, FROM_HERE, 177 BrowserThread::IO, FROM_HERE,
178 NewRunnableMethod(this, &LoginHandler::CancelAuthDeferred)); 178 base::Bind(&LoginHandler::CancelAuthDeferred, this));
179 } 179 }
180 180
181 void LoginHandler::OnRequestCancelled() { 181 void LoginHandler::OnRequestCancelled() {
182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) << 182 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)) <<
183 "Why is OnRequestCancelled called from the UI thread?"; 183 "Why is OnRequestCancelled called from the UI thread?";
184 184
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.
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 service->Notify( 318 service->Notify(
319 chrome::NOTIFICATION_AUTH_SUPPLIED, 319 chrome::NOTIFICATION_AUTH_SUPPLIED,
320 content::Source<NavigationController>(controller), 320 content::Source<NavigationController>(controller),
321 content::Details<AuthSuppliedLoginNotificationDetails>(&details)); 321 content::Details<AuthSuppliedLoginNotificationDetails>(&details));
322 } 322 }
323 323
324 void LoginHandler::ReleaseSoon() { 324 void LoginHandler::ReleaseSoon() {
325 if (!TestAndSetAuthHandled()) { 325 if (!TestAndSetAuthHandled()) {
326 BrowserThread::PostTask( 326 BrowserThread::PostTask(
327 BrowserThread::IO, FROM_HERE, 327 BrowserThread::IO, FROM_HERE,
328 NewRunnableMethod(this, &LoginHandler::CancelAuthDeferred)); 328 base::Bind(&LoginHandler::CancelAuthDeferred, this));
329 BrowserThread::PostTask( 329 BrowserThread::PostTask(
330 BrowserThread::UI, FROM_HERE, 330 BrowserThread::UI, FROM_HERE,
331 NewRunnableMethod(this, &LoginHandler::NotifyAuthCancelled)); 331 base::Bind(&LoginHandler::NotifyAuthCancelled, this));
332 } 332 }
333 333
334 BrowserThread::PostTask( 334 BrowserThread::PostTask(
335 BrowserThread::UI, FROM_HERE, 335 BrowserThread::UI, FROM_HERE,
336 NewRunnableMethod(this, &LoginHandler::RemoveObservers)); 336 base::Bind(&LoginHandler::RemoveObservers, this));
337 337
338 // Delete this object once all InvokeLaters have been called. 338 // Delete this object once all InvokeLaters have been called.
339 BrowserThread::ReleaseSoon(BrowserThread::IO, FROM_HERE, this); 339 BrowserThread::ReleaseSoon(BrowserThread::IO, FROM_HERE, this);
340 } 340 }
341 341
342 // Returns whether authentication had been handled (SetAuth or CancelAuth). 342 // Returns whether authentication had been handled (SetAuth or CancelAuth).
343 bool LoginHandler::WasAuthHandled() const { 343 bool LoginHandler::WasAuthHandled() const {
344 base::AutoLock lock(handled_auth_lock_); 344 base::AutoLock lock(handled_auth_lock_);
345 bool was_handled = handled_auth_; 345 bool was_handled = handled_auth_;
346 return was_handled; 346 return was_handled;
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 // Public API 490 // Public API
491 491
492 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, 492 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
493 net::URLRequest* request) { 493 net::URLRequest* request) {
494 LoginHandler* handler = LoginHandler::Create(auth_info, request); 494 LoginHandler* handler = LoginHandler::Create(auth_info, request);
495 BrowserThread::PostTask( 495 BrowserThread::PostTask(
496 BrowserThread::UI, FROM_HERE, new LoginDialogTask( 496 BrowserThread::UI, FROM_HERE, new LoginDialogTask(
497 request->url(), auth_info, handler)); 497 request->url(), auth_info, handler));
498 return handler; 498 return handler;
499 } 499 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/input_window_dialog_win.cc ('k') | chrome/browser/ui/select_file_dialog.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698