OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/login_prompt.h" | 5 #include "chrome/browser/login_prompt.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/lock.h" | 9 #include "base/lock.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 std::vector<PasswordForm>* password_manager_input) { | 106 std::vector<PasswordForm>* password_manager_input) { |
107 PasswordForm dialog_form; | 107 PasswordForm dialog_form; |
108 if (LowerCaseEqualsASCII(auth_info_->scheme, "basic")) { | 108 if (LowerCaseEqualsASCII(auth_info_->scheme, "basic")) { |
109 dialog_form.scheme = PasswordForm::SCHEME_BASIC; | 109 dialog_form.scheme = PasswordForm::SCHEME_BASIC; |
110 } else if (LowerCaseEqualsASCII(auth_info_->scheme, "digest")) { | 110 } else if (LowerCaseEqualsASCII(auth_info_->scheme, "digest")) { |
111 dialog_form.scheme = PasswordForm::SCHEME_DIGEST; | 111 dialog_form.scheme = PasswordForm::SCHEME_DIGEST; |
112 } else { | 112 } else { |
113 dialog_form.scheme = PasswordForm::SCHEME_OTHER; | 113 dialog_form.scheme = PasswordForm::SCHEME_OTHER; |
114 } | 114 } |
115 if (auth_info_->is_proxy) { | 115 if (auth_info_->is_proxy) { |
116 dialog_form.origin = GURL(WideToASCII(auth_info_->host_and_port)); | 116 std::string origin = WideToASCII(auth_info_->host_and_port); |
| 117 // We don't expect this to already start with http:// or https://. |
| 118 DCHECK(origin.find("http://") != 0 && origin.find("https://") != 0); |
| 119 origin = std::string("http://") + origin; |
| 120 dialog_form.origin = GURL(origin); |
117 } else { | 121 } else { |
118 dialog_form.origin = origin_url; | 122 dialog_form.origin = origin_url; |
119 } | 123 } |
120 dialog_form.signon_realm = GetSignonRealm(dialog_form.origin, *auth_info_); | 124 dialog_form.signon_realm = GetSignonRealm(dialog_form.origin, *auth_info_); |
121 password_manager_input->push_back(dialog_form); | 125 password_manager_input->push_back(dialog_form); |
122 // Set the password form for the handler (by copy). | 126 // Set the password form for the handler (by copy). |
123 handler_->SetPasswordForm(dialog_form); | 127 handler_->SetPasswordForm(dialog_form); |
124 } | 128 } |
125 | 129 |
126 // Info about who/where/what is asking for authentication. | 130 // Info about who/where/what is asking for authentication. |
127 scoped_refptr<net::AuthChallengeInfo> auth_info_; | 131 scoped_refptr<net::AuthChallengeInfo> auth_info_; |
128 | 132 |
129 // Where to send the authentication when obtained. | 133 // Where to send the authentication when obtained. |
130 // This is owned by the ResourceDispatcherHost that invoked us. | 134 // This is owned by the ResourceDispatcherHost that invoked us. |
131 LoginHandler* handler_; | 135 LoginHandler* handler_; |
132 | 136 |
133 DISALLOW_EVIL_CONSTRUCTORS(LoginDialogTask); | 137 DISALLOW_EVIL_CONSTRUCTORS(LoginDialogTask); |
134 }; | 138 }; |
135 | 139 |
136 // ---------------------------------------------------------------------------- | 140 // ---------------------------------------------------------------------------- |
137 // Public API | 141 // Public API |
138 | 142 |
139 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, | 143 LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info, |
140 URLRequest* request, | 144 URLRequest* request, |
141 MessageLoop* ui_loop) { | 145 MessageLoop* ui_loop) { |
142 LoginHandler* handler = LoginHandler::Create(request, ui_loop); | 146 LoginHandler* handler = LoginHandler::Create(request, ui_loop); |
143 ui_loop->PostTask(FROM_HERE, new LoginDialogTask(auth_info, handler)); | 147 ui_loop->PostTask(FROM_HERE, new LoginDialogTask(auth_info, handler)); |
144 return handler; | 148 return handler; |
145 } | 149 } |
OLD | NEW |