OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/password_manager/password_manager.h" | 14 #include "chrome/browser/password_manager/password_manager.h" |
15 #include "chrome/browser/tab_contents/tab_util.h" | 15 #include "chrome/browser/tab_contents/tab_util.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
20 #include "content/public/browser/resource_dispatcher_host.h" | 20 #include "content/public/browser/resource_dispatcher_host.h" |
21 #include "content/public/browser/resource_request_info.h" | 21 #include "content/public/browser/resource_request_info.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
24 #include "net/base/auth.h" | 24 #include "net/base/auth.h" |
25 #include "net/base/net_util.h" | 25 #include "net/base/net_util.h" |
26 #include "net/http/http_transaction_factory.h" | 26 #include "net/http/http_transaction_factory.h" |
27 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
28 #include "net/url_request/url_request_context.h" | 28 #include "net/url_request/url_request_context.h" |
29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
30 #include "ui/base/text/text_elider.h" | 30 #include "ui/gfx/text_elider.h" |
31 | 31 |
32 using autofill::PasswordForm; | 32 using autofill::PasswordForm; |
33 using content::BrowserThread; | 33 using content::BrowserThread; |
34 using content::NavigationController; | 34 using content::NavigationController; |
35 using content::RenderViewHost; | 35 using content::RenderViewHost; |
36 using content::RenderViewHostDelegate; | 36 using content::RenderViewHostDelegate; |
37 using content::ResourceDispatcherHost; | 37 using content::ResourceDispatcherHost; |
38 using content::ResourceRequestInfo; | 38 using content::ResourceRequestInfo; |
39 using content::WebContents; | 39 using content::WebContents; |
40 | 40 |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
434 | 434 |
435 // Tell the password manager to look for saved passwords. | 435 // Tell the password manager to look for saved passwords. |
436 std::vector<PasswordForm> v; | 436 std::vector<PasswordForm> v; |
437 MakeInputForPasswordManager(request_url, auth_info, handler, &v); | 437 MakeInputForPasswordManager(request_url, auth_info, handler, &v); |
438 password_manager->OnPasswordFormsParsed(v); | 438 password_manager->OnPasswordFormsParsed(v); |
439 handler->SetPasswordManager(password_manager); | 439 handler->SetPasswordManager(password_manager); |
440 | 440 |
441 // The realm is controlled by the remote server, so there is no reason | 441 // The realm is controlled by the remote server, so there is no reason |
442 // to believe it is of a reasonable length. | 442 // to believe it is of a reasonable length. |
443 string16 elided_realm; | 443 string16 elided_realm; |
444 ui::ElideString(UTF8ToUTF16(auth_info->realm), 120, &elided_realm); | 444 gfx::ElideString(UTF8ToUTF16(auth_info->realm), 120, &elided_realm); |
445 | 445 |
446 string16 host_and_port = ASCIIToUTF16(request_url.scheme() + "://" + | 446 string16 host_and_port = ASCIIToUTF16(request_url.scheme() + "://" + |
447 auth_info->challenger.ToString()); | 447 auth_info->challenger.ToString()); |
448 string16 explanation = elided_realm.empty() ? | 448 string16 explanation = elided_realm.empty() ? |
449 l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, | 449 l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, |
450 host_and_port) : | 450 host_and_port) : |
451 l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION, | 451 l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION, |
452 host_and_port, | 452 host_and_port, |
453 elided_realm); | 453 elided_realm); |
454 handler->BuildViewForPasswordManager(password_manager, explanation); | 454 handler->BuildViewForPasswordManager(password_manager, explanation); |
455 } | 455 } |
456 | 456 |
457 // ---------------------------------------------------------------------------- | 457 // ---------------------------------------------------------------------------- |
458 // Public API | 458 // Public API |
459 | 459 |
460 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 460 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
461 net::URLRequest* request) { | 461 net::URLRequest* request) { |
462 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 462 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
463 BrowserThread::PostTask( | 463 BrowserThread::PostTask( |
464 BrowserThread::UI, FROM_HERE, | 464 BrowserThread::UI, FROM_HERE, |
465 base::Bind(&LoginDialogCallback, request->url(), | 465 base::Bind(&LoginDialogCallback, request->url(), |
466 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); | 466 make_scoped_refptr(auth_info), make_scoped_refptr(handler))); |
467 return handler; | 467 return handler; |
468 } | 468 } |
OLD | NEW |