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

Side by Side Diff: chrome/browser/ui/cocoa/login_prompt_cocoa.mm

Issue 1466473003: Do not show untrustworthy strings in the basic auth dialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix XIB. Created 5 years 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/cocoa/login_prompt_cocoa.h ('k') | chrome/browser/ui/login/login_prompt.h » ('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 #import "chrome/browser/ui/cocoa/login_prompt_cocoa.h" 5 #import "chrome/browser/ui/cocoa/login_prompt_cocoa.h"
6 6
7 #include "base/mac/bundle_locations.h" 7 #include "base/mac/bundle_locations.h"
8 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
9 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 const base::string16& username, 45 const base::string16& username,
46 const base::string16& password) override { 46 const base::string16& password) override {
47 DCHECK_CURRENTLY_ON(BrowserThread::UI); 47 DCHECK_CURRENTLY_ON(BrowserThread::UI);
48 48
49 [sheet_controller_ autofillLogin:base::SysUTF16ToNSString(username) 49 [sheet_controller_ autofillLogin:base::SysUTF16ToNSString(username)
50 password:base::SysUTF16ToNSString(password)]; 50 password:base::SysUTF16ToNSString(password)];
51 } 51 }
52 void OnLoginModelDestroying() override {} 52 void OnLoginModelDestroying() override {}
53 53
54 // LoginHandler: 54 // LoginHandler:
55 void BuildViewImpl(const base::string16& explanation, 55 void BuildViewImpl(const base::string16& authority,
56 const base::string16& explanation,
56 LoginModelData* login_model_data) override { 57 LoginModelData* login_model_data) override {
57 DCHECK_CURRENTLY_ON(BrowserThread::UI); 58 DCHECK_CURRENTLY_ON(BrowserThread::UI);
58 59
59 sheet_controller_.reset( 60 sheet_controller_.reset(
60 [[LoginHandlerSheet alloc] initWithLoginHandler:this]); 61 [[LoginHandlerSheet alloc] initWithLoginHandler:this]);
61 62
62 if (login_model_data) 63 if (login_model_data)
63 SetModel(*login_model_data); 64 SetModel(*login_model_data);
64 else 65 else
65 ResetModel(); 66 ResetModel();
66 67
68 [sheet_controller_ setAuthority:base::SysUTF16ToNSString(authority)];
67 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)]; 69 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)];
68 70
69 // Scary thread safety note: This can potentially be called *after* SetAuth 71 // Scary thread safety note: This can potentially be called *after* SetAuth
70 // or CancelAuth (say, if the request was cancelled before the UI thread got 72 // or CancelAuth (say, if the request was cancelled before the UI thread got
71 // control). However, that's OK since any UI interaction in those functions 73 // control). However, that's OK since any UI interaction in those functions
72 // will occur via an InvokeLater on the UI thread, which is guaranteed 74 // will occur via an InvokeLater on the UI thread, which is guaranteed
73 // to happen after this is called (since this was InvokeLater'd first). 75 // to happen after this is called (since this was InvokeLater'd first).
74 WebContents* requesting_contents = GetWebContentsForLogin(); 76 WebContents* requesting_contents = GetWebContentsForLogin();
75 DCHECK(requesting_contents); 77 DCHECK(requesting_contents);
76 78
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 } 175 }
174 176
175 - (void)autofillLogin:(NSString*)login password:(NSString*)password { 177 - (void)autofillLogin:(NSString*)login password:(NSString*)password {
176 if ([[nameField_ stringValue] length] == 0) { 178 if ([[nameField_ stringValue] length] == 0) {
177 [nameField_ setStringValue:login]; 179 [nameField_ setStringValue:login];
178 [passwordField_ setStringValue:password]; 180 [passwordField_ setStringValue:password];
179 [nameField_ selectText:self]; 181 [nameField_ selectText:self];
180 } 182 }
181 } 183 }
182 184
185 - (void)setAuthority:(NSString*)authority {
186 [authorityField_ setStringValue:authority];
187
188 // Resize the text field.
189 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker
190 sizeToFitFixedWidthTextField:authorityField_];
191
192 NSRect newFrame = [[self window] frame];
193 newFrame.size.height += windowDelta;
194 [[self window] setFrame:newFrame display:NO];
195 }
196
183 - (void)setExplanation:(NSString*)explanation { 197 - (void)setExplanation:(NSString*)explanation {
184 // Put in the text.
185 [explanationField_ setStringValue:explanation]; 198 [explanationField_ setStringValue:explanation];
186 199
187 // Resize the text field. 200 // Resize the text field.
188 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker 201 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker
189 sizeToFitFixedWidthTextField:explanationField_]; 202 sizeToFitFixedWidthTextField:explanationField_];
190 203
191 NSRect newFrame = [[self window] frame]; 204 NSRect newFrame = [[self window] frame];
192 newFrame.size.height += windowDelta; 205 newFrame.size.height += windowDelta;
193 [[self window] setFrame:newFrame display:NO]; 206 [[self window] setFrame:newFrame display:NO];
194 } 207 }
195 208
196 @end 209 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/login_prompt_cocoa.h ('k') | chrome/browser/ui/login/login_prompt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698