| 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/chrome_password_manager_client.h" | 14 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 15 #include "chrome/browser/prerender/prerender_contents.h" | 15 #include "chrome/browser/prerender/prerender_contents.h" |
| 16 #include "chrome/browser/tab_contents/tab_util.h" | 16 #include "chrome/browser/tab_contents/tab_util.h" |
| 17 #include "chrome/browser/ui/login/login_interstitial_delegate.h" | 17 #include "chrome/browser/ui/login/login_interstitial_delegate.h" |
| 18 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" | 18 #include "components/password_manager/core/browser/browser_save_password_progres
s_logger.h" |
| 19 #include "components/password_manager/core/browser/password_manager.h" | 19 #include "components/password_manager/core/browser/password_manager.h" |
| 20 #include "content/public/browser/browser_thread.h" | 20 #include "content/public/browser/browser_thread.h" |
| 21 #include "content/public/browser/navigation_entry.h" |
| 21 #include "content/public/browser/notification_registrar.h" | 22 #include "content/public/browser/notification_registrar.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/render_frame_host.h" | 24 #include "content/public/browser/render_frame_host.h" |
| 24 #include "content/public/browser/resource_dispatcher_host.h" | 25 #include "content/public/browser/resource_dispatcher_host.h" |
| 25 #include "content/public/browser/resource_request_info.h" | 26 #include "content/public/browser/resource_request_info.h" |
| 26 #include "content/public/browser/web_contents.h" | 27 #include "content/public/browser/web_contents.h" |
| 28 #include "content/public/common/ssl_status.h" |
| 27 #include "grit/generated_resources.h" | 29 #include "grit/generated_resources.h" |
| 28 #include "net/base/auth.h" | 30 #include "net/base/auth.h" |
| 29 #include "net/base/load_flags.h" | 31 #include "net/base/load_flags.h" |
| 30 #include "net/base/net_util.h" | 32 #include "net/base/net_util.h" |
| 31 #include "net/http/http_transaction_factory.h" | 33 #include "net/http/http_transaction_factory.h" |
| 34 #include "net/ssl/ssl_info.h" |
| 32 #include "net/url_request/url_request.h" | 35 #include "net/url_request/url_request.h" |
| 33 #include "net/url_request/url_request_context.h" | 36 #include "net/url_request/url_request_context.h" |
| 34 #include "ui/base/l10n/l10n_util.h" | 37 #include "ui/base/l10n/l10n_util.h" |
| 35 #include "ui/gfx/text_elider.h" | 38 #include "ui/gfx/text_elider.h" |
| 36 | 39 |
| 37 using autofill::PasswordForm; | 40 using autofill::PasswordForm; |
| 38 using content::BrowserThread; | 41 using content::BrowserThread; |
| 39 using content::NavigationController; | 42 using content::NavigationController; |
| 40 using content::RenderViewHost; | 43 using content::RenderViewHost; |
| 41 using content::RenderViewHostDelegate; | 44 using content::RenderViewHostDelegate; |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 513 } |
| 511 | 514 |
| 512 if (is_main_frame && | 515 if (is_main_frame && |
| 513 parent_contents->GetVisibleURL().GetOrigin() != request_url.GetOrigin()) { | 516 parent_contents->GetVisibleURL().GetOrigin() != request_url.GetOrigin()) { |
| 514 // Show a blank interstitial for main-frame, cross origin requests | 517 // Show a blank interstitial for main-frame, cross origin requests |
| 515 // so that the correct URL is shown in the omnibox. | 518 // so that the correct URL is shown in the omnibox. |
| 516 base::Closure callback = base::Bind(&ShowLoginPrompt, | 519 base::Closure callback = base::Bind(&ShowLoginPrompt, |
| 517 request_url, | 520 request_url, |
| 518 make_scoped_refptr(auth_info), | 521 make_scoped_refptr(auth_info), |
| 519 make_scoped_refptr(handler)); | 522 make_scoped_refptr(handler)); |
| 523 const content::SSLStatus& ssl_status = |
| 524 parent_contents->GetController().GetVisibleEntry()->GetSSL(); |
| 520 // This is owned by the interstitial it creates. | 525 // This is owned by the interstitial it creates. |
| 521 new LoginInterstitialDelegate(parent_contents, | 526 new LoginInterstitialDelegate(parent_contents, |
| 522 request_url, | 527 request_url, |
| 528 ssl_status, |
| 523 callback); | 529 callback); |
| 524 } else { | 530 } else { |
| 525 ShowLoginPrompt(request_url, | 531 ShowLoginPrompt(request_url, |
| 526 auth_info, | 532 auth_info, |
| 527 handler); | 533 handler); |
| 528 } | 534 } |
| 529 } | 535 } |
| 530 | 536 |
| 531 // ---------------------------------------------------------------------------- | 537 // ---------------------------------------------------------------------------- |
| 532 // Public API | 538 // Public API |
| 533 | 539 |
| 534 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 540 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
| 535 net::URLRequest* request) { | 541 net::URLRequest* request) { |
| 536 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0; | 542 bool is_main_frame = (request->load_flags() & net::LOAD_MAIN_FRAME) != 0; |
| 537 LoginHandler* handler = LoginHandler::Create(auth_info, request); | 543 LoginHandler* handler = LoginHandler::Create(auth_info, request); |
| 538 BrowserThread::PostTask( | 544 BrowserThread::PostTask( |
| 539 BrowserThread::UI, FROM_HERE, | 545 BrowserThread::UI, FROM_HERE, |
| 540 base::Bind(&LoginDialogCallback, request->url(), | 546 base::Bind(&LoginDialogCallback, request->url(), |
| 541 make_scoped_refptr(auth_info), make_scoped_refptr(handler), | 547 make_scoped_refptr(auth_info), make_scoped_refptr(handler), |
| 542 is_main_frame)); | 548 is_main_frame)); |
| 543 return handler; | 549 return handler; |
| 544 } | 550 } |
| OLD | NEW |