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/auto_login_prompter.h" | 5 #include "chrome/browser/ui/auto_login_prompter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
299 // In an incognito window, there may not be a profile sync service and/or | 299 // In an incognito window, there may not be a profile sync service and/or |
300 // signin manager. | 300 // signin manager. |
301 if (!profile->HasProfileSyncService()) | 301 if (!profile->HasProfileSyncService()) |
302 return; | 302 return; |
303 SigninManager* signin_manager = profile->GetProfileSyncService()->signin(); | 303 SigninManager* signin_manager = profile->GetProfileSyncService()->signin(); |
304 if (!signin_manager) | 304 if (!signin_manager) |
305 return; | 305 return; |
306 | 306 |
307 // Make sure that |account|, if specified, matches the logged in user. | 307 // Make sure that |account|, if specified, matches the logged in user. |
308 // However, |account| is usually empty. | 308 // However, |account| is usually empty. |
309 const std::string& username = signin_manager->GetUsername(); | 309 const std::string& username = signin_manager->GetAuthenticatedUsername(); |
310 if (!account.empty() && (username != account)) | 310 if (!account.empty() && (username != account)) |
311 return; | 311 return; |
312 | 312 |
313 // Make sure there are credentials in the token manager, otherwise there is | 313 // Make sure there are credentials in the token manager, otherwise there is |
314 // no way to craft the TokenAuth URL. | 314 // no way to craft the TokenAuth URL. |
315 if (!profile->GetTokenService()->AreCredentialsValid()) | 315 if (!profile->GetTokenService()->AreCredentialsValid()) |
316 return; | 316 return; |
317 | 317 |
318 // We can't add the infobar just yet, since we need to wait for the tab to | 318 // We can't add the infobar just yet, since we need to wait for the tab to |
319 // finish loading. If we don't, the info bar appears and then disappears | 319 // finish loading. If we don't, the info bar appears and then disappears |
(...skipping 16 matching lines...) Expand all Loading... |
336 infobar_helper, &tab_contents_->controller(), | 336 infobar_helper, &tab_contents_->controller(), |
337 profile->GetTokenService(), profile->GetPrefs(), | 337 profile->GetTokenService(), profile->GetPrefs(), |
338 username_, args_)); | 338 username_, args_)); |
339 } | 339 } |
340 } | 340 } |
341 // Either we couldn't add the infobar, we added the infobar, or the tab | 341 // Either we couldn't add the infobar, we added the infobar, or the tab |
342 // contents was destroyed before the navigation completed. In any case | 342 // contents was destroyed before the navigation completed. In any case |
343 // there's no reason to live further. | 343 // there's no reason to live further. |
344 delete this; | 344 delete this; |
345 } | 345 } |
OLD | NEW |