This source file includes following definitions.
- OnAutofillDataAvailable
- OnLoginModelDestroying
- BuildViewForPasswordManager
- CloseDialog
- Create
#include "chrome/browser/ui/login/login_prompt.h"
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/android/tab_android.h"
#include "chrome/browser/ui/android/chrome_http_auth_handler.h"
#include "chrome/browser/ui/login/login_prompt.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
#include "net/base/auth.h"
using content::BrowserThread;
using net::URLRequest;
using net::AuthChallengeInfo;
class LoginHandlerAndroid : public LoginHandler {
public:
LoginHandlerAndroid(AuthChallengeInfo* auth_info, URLRequest* request)
: LoginHandler(auth_info, request) {
}
virtual void OnAutofillDataAvailable(
const base::string16& username,
const base::string16& password) OVERRIDE {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
DCHECK(chrome_http_auth_handler_.get() != NULL);
chrome_http_auth_handler_->OnAutofillDataAvailable(
username, password);
}
virtual void OnLoginModelDestroying() OVERRIDE {}
virtual void BuildViewForPasswordManager(
PasswordManager* manager,
const base::string16& explanation) OVERRIDE {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
content::WebContents* web_contents = GetWebContentsForLogin();
CHECK(web_contents);
TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents);
if (tab_android) {
chrome_http_auth_handler_.reset(new ChromeHttpAuthHandler(explanation));
chrome_http_auth_handler_->Init();
chrome_http_auth_handler_->SetObserver(this);
tab_android->OnReceivedHttpAuthRequest(
chrome_http_auth_handler_.get()->GetJavaObject(),
base::ASCIIToUTF16(auth_info()->challenger.ToString()),
base::UTF8ToUTF16(auth_info()->realm));
SetModel(manager);
NotifyAuthNeeded();
} else {
CancelAuth();
LOG(WARNING) << "HTTP Authentication failed because TabAndroid is "
"missing";
}
}
protected:
virtual ~LoginHandlerAndroid() {}
virtual void CloseDialog() OVERRIDE {}
private:
scoped_ptr<ChromeHttpAuthHandler> chrome_http_auth_handler_;
};
LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info,
net::URLRequest* request) {
return new LoginHandlerAndroid(auth_info, request);
}