Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(64)

Side by Side Diff: chrome/browser/ui/login/login_prompt.cc

Issue 1415243004: Separate origin from explanation in HTTP Auth dialogs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/login/login_prompt.h ('k') | chrome/browser/ui/views/login_prompt_views.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 115
116 std::string languages; 116 std::string languages;
117 content::WebContents* web_contents = handler->GetWebContentsForLogin(); 117 content::WebContents* web_contents = handler->GetWebContentsForLogin();
118 if (web_contents) { 118 if (web_contents) {
119 Profile* profile = 119 Profile* profile =
120 Profile::FromBrowserContext(web_contents->GetBrowserContext()); 120 Profile::FromBrowserContext(web_contents->GetBrowserContext());
121 if (profile) 121 if (profile)
122 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages); 122 languages = profile->GetPrefs()->GetString(prefs::kAcceptLanguages);
123 } 123 }
124 124
125 base::string16 authority = 125 base::string16 authority = l10n_util::GetStringFUTF16(
126 url_formatter::FormatUrlForSecurityDisplay(request_url, languages); 126 IDS_LOGIN_DIALOG_AUTHORITY,
127 base::string16 explanation = 127 url_formatter::FormatUrlForSecurityDisplay(request_url, languages));
palmer 2015/11/19 23:01:28 Idea: Use FormatUrlForSecurityDisplayOmitScheme if
128 elided_realm.empty() 128 base::string16 explanation;
129 ? l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION_NO_REALM, 129 if (!elided_realm.empty()) {
130 authority) 130 explanation =
131 : l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION, authority, 131 l10n_util::GetStringFUTF16(IDS_LOGIN_DIALOG_DESCRIPTION, elided_realm);
palmer 2015/11/19 23:01:28 As I mentioned on the bug, I really would like to
132 elided_realm); 132 }
133
134 password_manager::PasswordManager* password_manager = 133 password_manager::PasswordManager* password_manager =
135 handler->GetPasswordManagerForLogin(); 134 handler->GetPasswordManagerForLogin();
136 135
137 if (!password_manager) { 136 if (!password_manager) {
138 #if defined(ENABLE_EXTENSIONS) 137 #if defined(ENABLE_EXTENSIONS)
139 // A WebContents in a <webview> (a GuestView type) does not have a password 138 // A WebContents in a <webview> (a GuestView type) does not have a password
140 // manager, but still needs to be able to show login prompts. 139 // manager, but still needs to be able to show login prompts.
141 if (guest_view::GuestViewBase::FromWebContents(parent_contents)) { 140 if (guest_view::GuestViewBase::FromWebContents(parent_contents)) {
142 handler->BuildViewWithoutPasswordManager(explanation); 141 handler->BuildViewWithoutPasswordManager(authority, explanation);
143 return; 142 return;
144 } 143 }
145 #endif 144 #endif
146 handler->CancelAuth(); 145 handler->CancelAuth();
147 return; 146 return;
148 } 147 }
149 148
150 if (password_manager && password_manager->client()->IsLoggingActive()) { 149 if (password_manager && password_manager->client()->IsLoggingActive()) {
151 password_manager::BrowserSavePasswordProgressLogger logger( 150 password_manager::BrowserSavePasswordProgressLogger logger(
152 password_manager->client()); 151 password_manager->client());
153 logger.LogMessage( 152 logger.LogMessage(
154 autofill::SavePasswordProgressLogger::STRING_SHOW_LOGIN_PROMPT_METHOD); 153 autofill::SavePasswordProgressLogger::STRING_SHOW_LOGIN_PROMPT_METHOD);
155 } 154 }
156 155
157 PasswordForm observed_form( 156 PasswordForm observed_form(
158 MakeInputForPasswordManager(request_url, auth_info)); 157 MakeInputForPasswordManager(request_url, auth_info));
159 handler->BuildViewWithPasswordManager(explanation, password_manager, 158 handler->BuildViewWithPasswordManager(authority, explanation,
160 observed_form); 159 password_manager, observed_form);
161 } 160 }
162 161
163 } // namespace 162 } // namespace
164 163
165 // ---------------------------------------------------------------------------- 164 // ----------------------------------------------------------------------------
166 // LoginHandler 165 // LoginHandler
167 166
168 LoginHandler::LoginModelData::LoginModelData( 167 LoginHandler::LoginModelData::LoginModelData(
169 password_manager::LoginModel* login_model, 168 password_manager::LoginModel* login_model,
170 const autofill::PasswordForm& observed_form) 169 const autofill::PasswordForm& observed_form)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 "Why is OnRequestCancelled called from the UI thread?"; 203 "Why is OnRequestCancelled called from the UI thread?";
205 204
206 // Reference is no longer valid. 205 // Reference is no longer valid.
207 request_ = NULL; 206 request_ = NULL;
208 207
209 // Give up on auth if the request was cancelled. 208 // Give up on auth if the request was cancelled.
210 CancelAuth(); 209 CancelAuth();
211 } 210 }
212 211
213 void LoginHandler::BuildViewWithPasswordManager( 212 void LoginHandler::BuildViewWithPasswordManager(
213 const base::string16& authority,
214 const base::string16& explanation, 214 const base::string16& explanation,
215 password_manager::PasswordManager* password_manager, 215 password_manager::PasswordManager* password_manager,
216 const autofill::PasswordForm& observed_form) { 216 const autofill::PasswordForm& observed_form) {
217 password_manager_ = password_manager; 217 password_manager_ = password_manager;
218 password_form_ = observed_form; 218 password_form_ = observed_form;
219 LoginHandler::LoginModelData model_data(password_manager, observed_form); 219 LoginHandler::LoginModelData model_data(password_manager, observed_form);
220 BuildViewImpl(explanation, &model_data); 220 BuildViewImpl(authority, explanation, &model_data);
221 } 221 }
222 222
223 void LoginHandler::BuildViewWithoutPasswordManager( 223 void LoginHandler::BuildViewWithoutPasswordManager(
224 const base::string16& authority,
224 const base::string16& explanation) { 225 const base::string16& explanation) {
225 BuildViewImpl(explanation, nullptr); 226 BuildViewImpl(authority, explanation, nullptr);
226 } 227 }
227 228
228 WebContents* LoginHandler::GetWebContentsForLogin() const { 229 WebContents* LoginHandler::GetWebContentsForLogin() const {
229 DCHECK_CURRENTLY_ON(BrowserThread::UI); 230 DCHECK_CURRENTLY_ON(BrowserThread::UI);
230 231
231 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID( 232 content::RenderFrameHost* rfh = content::RenderFrameHost::FromID(
232 render_process_host_id_, render_frame_id_); 233 render_process_host_id_, render_frame_id_);
233 return WebContents::FromRenderFrameHost(rfh); 234 return WebContents::FromRenderFrameHost(rfh);
234 } 235 }
235 236
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 signon_realm = auth_info.challenger.ToString(); 608 signon_realm = auth_info.challenger.ToString();
608 signon_realm.append("/"); 609 signon_realm.append("/");
609 } else { 610 } else {
610 // Take scheme, host, and port from the url. 611 // Take scheme, host, and port from the url.
611 signon_realm = url.GetOrigin().spec(); 612 signon_realm = url.GetOrigin().spec();
612 // This ends with a "/". 613 // This ends with a "/".
613 } 614 }
614 signon_realm.append(auth_info.realm); 615 signon_realm.append(auth_info.realm);
615 return signon_realm; 616 return signon_realm;
616 } 617 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/login/login_prompt.h ('k') | chrome/browser/ui/views/login_prompt_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698