| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 using net::AuthChallengeInfo; | 21 using net::AuthChallengeInfo; |
| 22 | 22 |
| 23 class LoginHandlerAndroid : public LoginHandler { | 23 class LoginHandlerAndroid : public LoginHandler { |
| 24 public: | 24 public: |
| 25 LoginHandlerAndroid(AuthChallengeInfo* auth_info, URLRequest* request) | 25 LoginHandlerAndroid(AuthChallengeInfo* auth_info, URLRequest* request) |
| 26 : LoginHandler(auth_info, request) { | 26 : LoginHandler(auth_info, request) { |
| 27 } | 27 } |
| 28 | 28 |
| 29 // LoginHandler methods: | 29 // LoginHandler methods: |
| 30 | 30 |
| 31 virtual void OnAutofillDataAvailable( | 31 void OnAutofillDataAvailable(const base::string16& username, |
| 32 const base::string16& username, | 32 const base::string16& password) override { |
| 33 const base::string16& password) override { | |
| 34 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 33 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 35 DCHECK(chrome_http_auth_handler_.get() != NULL); | 34 DCHECK(chrome_http_auth_handler_.get() != NULL); |
| 36 chrome_http_auth_handler_->OnAutofillDataAvailable( | 35 chrome_http_auth_handler_->OnAutofillDataAvailable( |
| 37 username, password); | 36 username, password); |
| 38 } | 37 } |
| 39 virtual void OnLoginModelDestroying() override {} | 38 void OnLoginModelDestroying() override {} |
| 40 | 39 |
| 41 virtual void BuildViewForPasswordManager( | 40 void BuildViewForPasswordManager(password_manager::PasswordManager* manager, |
| 42 password_manager::PasswordManager* manager, | 41 const base::string16& explanation) override { |
| 43 const base::string16& explanation) override { | |
| 44 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 42 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 45 | 43 |
| 46 // Get pointer to TabAndroid | 44 // Get pointer to TabAndroid |
| 47 content::WebContents* web_contents = GetWebContentsForLogin(); | 45 content::WebContents* web_contents = GetWebContentsForLogin(); |
| 48 CHECK(web_contents); | 46 CHECK(web_contents); |
| 49 WindowAndroidHelper* window_helper = WindowAndroidHelper::FromWebContents( | 47 WindowAndroidHelper* window_helper = WindowAndroidHelper::FromWebContents( |
| 50 web_contents); | 48 web_contents); |
| 51 | 49 |
| 52 // Notify WindowAndroid that HTTP authentication is required. | 50 // Notify WindowAndroid that HTTP authentication is required. |
| 53 if (window_helper->GetWindowAndroid()) { | 51 if (window_helper->GetWindowAndroid()) { |
| 54 chrome_http_auth_handler_.reset(new ChromeHttpAuthHandler(explanation)); | 52 chrome_http_auth_handler_.reset(new ChromeHttpAuthHandler(explanation)); |
| 55 chrome_http_auth_handler_->Init(); | 53 chrome_http_auth_handler_->Init(); |
| 56 chrome_http_auth_handler_->SetObserver(this); | 54 chrome_http_auth_handler_->SetObserver(this); |
| 57 chrome_http_auth_handler_->ShowDialog( | 55 chrome_http_auth_handler_->ShowDialog( |
| 58 window_helper->GetWindowAndroid()->GetJavaObject().obj()); | 56 window_helper->GetWindowAndroid()->GetJavaObject().obj()); |
| 59 | 57 |
| 60 // Register to receive a callback to OnAutofillDataAvailable(). | 58 // Register to receive a callback to OnAutofillDataAvailable(). |
| 61 SetModel(manager); | 59 SetModel(manager); |
| 62 NotifyAuthNeeded(); | 60 NotifyAuthNeeded(); |
| 63 } else { | 61 } else { |
| 64 CancelAuth(); | 62 CancelAuth(); |
| 65 LOG(WARNING) << "HTTP Authentication failed because TabAndroid is " | 63 LOG(WARNING) << "HTTP Authentication failed because TabAndroid is " |
| 66 "missing"; | 64 "missing"; |
| 67 } | 65 } |
| 68 } | 66 } |
| 69 | 67 |
| 70 protected: | 68 protected: |
| 71 virtual ~LoginHandlerAndroid() {} | 69 ~LoginHandlerAndroid() override {} |
| 72 | 70 |
| 73 virtual void CloseDialog() override {} | 71 void CloseDialog() override {} |
| 74 | 72 |
| 75 private: | 73 private: |
| 76 scoped_ptr<ChromeHttpAuthHandler> chrome_http_auth_handler_; | 74 scoped_ptr<ChromeHttpAuthHandler> chrome_http_auth_handler_; |
| 77 }; | 75 }; |
| 78 | 76 |
| 79 // static | 77 // static |
| 80 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, | 78 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, |
| 81 net::URLRequest* request) { | 79 net::URLRequest* request) { |
| 82 return new LoginHandlerAndroid(auth_info, request); | 80 return new LoginHandlerAndroid(auth_info, request); |
| 83 } | 81 } |
| OLD | NEW |