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

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

Issue 1421013003: [Merge in M47] Do not involve PasswordManagerDriver in filling HTTP-auth forms; also check realm (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2526
Patch Set: Created 5 years, 2 months 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
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 23 matching lines...) Expand all
34 // This class uses ref counting to ensure that it lives until all InvokeLaters 34 // This class uses ref counting to ensure that it lives until all InvokeLaters
35 // have been called. 35 // have been called.
36 class LoginHandlerMac : public LoginHandler, 36 class LoginHandlerMac : public LoginHandler,
37 public ConstrainedWindowMacDelegate { 37 public ConstrainedWindowMacDelegate {
38 public: 38 public:
39 LoginHandlerMac(net::AuthChallengeInfo* auth_info, net::URLRequest* request) 39 LoginHandlerMac(net::AuthChallengeInfo* auth_info, net::URLRequest* request)
40 : LoginHandler(auth_info, request) { 40 : LoginHandler(auth_info, request) {
41 } 41 }
42 42
43 // LoginModelObserver implementation. 43 // LoginModelObserver implementation.
44 void OnAutofillDataAvailable(const base::string16& username, 44 void OnAutofillDataAvailableInternal(
45 const base::string16& password) override { 45 const base::string16& username,
46 const base::string16& password) override {
46 DCHECK_CURRENTLY_ON(BrowserThread::UI); 47 DCHECK_CURRENTLY_ON(BrowserThread::UI);
47 48
48 [sheet_controller_ autofillLogin:base::SysUTF16ToNSString(username) 49 [sheet_controller_ autofillLogin:base::SysUTF16ToNSString(username)
49 password:base::SysUTF16ToNSString(password)]; 50 password:base::SysUTF16ToNSString(password)];
50 } 51 }
51 void OnLoginModelDestroying() override {} 52 void OnLoginModelDestroying() override {}
52 53
53 // LoginHandler: 54 // LoginHandler:
54 void BuildViewForPasswordManager(password_manager::PasswordManager* manager, 55 void BuildView(const base::string16& explanation,
55 const base::string16& explanation) override { 56 LoginModelData* login_model_data) override {
56 DCHECK_CURRENTLY_ON(BrowserThread::UI); 57 DCHECK_CURRENTLY_ON(BrowserThread::UI);
57 58
58 sheet_controller_.reset( 59 sheet_controller_.reset(
59 [[LoginHandlerSheet alloc] initWithLoginHandler:this]); 60 [[LoginHandlerSheet alloc] initWithLoginHandler:this]);
60 61
61 SetModel(manager); 62 if (login_model_data)
63 SetModel(*login_model_data);
64 else
65 ResetModel();
62 66
63 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)]; 67 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)];
64 68
65 // Scary thread safety note: This can potentially be called *after* SetAuth 69 // Scary thread safety note: This can potentially be called *after* SetAuth
66 // or CancelAuth (say, if the request was cancelled before the UI thread got 70 // or CancelAuth (say, if the request was cancelled before the UI thread got
67 // control). However, that's OK since any UI interaction in those functions 71 // control). However, that's OK since any UI interaction in those functions
68 // will occur via an InvokeLater on the UI thread, which is guaranteed 72 // will occur via an InvokeLater on the UI thread, which is guaranteed
69 // to happen after this is called (since this was InvokeLater'd first). 73 // to happen after this is called (since this was InvokeLater'd first).
70 WebContents* requesting_contents = GetWebContentsForLogin(); 74 WebContents* requesting_contents = GetWebContentsForLogin();
71 DCHECK(requesting_contents); 75 DCHECK(requesting_contents);
72 76
73 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( 77 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet(
74 [[CustomConstrainedWindowSheet alloc] 78 [[CustomConstrainedWindowSheet alloc]
75 initWithCustomWindow:[sheet_controller_ window]]); 79 initWithCustomWindow:[sheet_controller_ window]]);
76 constrained_window_.reset(new ConstrainedWindowMac( 80 constrained_window_.reset(new ConstrainedWindowMac(
77 this, requesting_contents, sheet)); 81 this, requesting_contents, sheet));
78 82
79 NotifyAuthNeeded(); 83 NotifyAuthNeeded();
80 } 84 }
81 85
82 void CloseDialog() override { 86 void CloseDialog() override {
83 // The hosting dialog may have been freed. 87 // The hosting dialog may have been freed.
84 if (constrained_window_) 88 if (constrained_window_)
85 constrained_window_->CloseWebContentsModalDialog(); 89 constrained_window_->CloseWebContentsModalDialog();
86 } 90 }
87 91
88 // Overridden from ConstrainedWindowMacDelegate: 92 // Overridden from ConstrainedWindowMacDelegate:
89 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override { 93 void OnConstrainedWindowClosed(ConstrainedWindowMac* window) override {
90 DCHECK_CURRENTLY_ON(BrowserThread::UI); 94 DCHECK_CURRENTLY_ON(BrowserThread::UI);
91 SetModel(NULL); 95 ResetModel();
92 ReleaseSoon(); 96 ReleaseSoon();
93 97
94 constrained_window_.reset(); 98 constrained_window_.reset();
95 sheet_controller_.reset(); 99 sheet_controller_.reset();
96 } 100 }
97 101
98 void OnLoginPressed(const base::string16& username, 102 void OnLoginPressed(const base::string16& username,
99 const base::string16& password) { 103 const base::string16& password) {
100 DCHECK_CURRENTLY_ON(BrowserThread::UI); 104 DCHECK_CURRENTLY_ON(BrowserThread::UI);
101 SetAuth(username, password); 105 SetAuth(username, password);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 // Resize the text field. 187 // Resize the text field.
184 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker 188 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker
185 sizeToFitFixedWidthTextField:explanationField_]; 189 sizeToFitFixedWidthTextField:explanationField_];
186 190
187 NSRect newFrame = [[self window] frame]; 191 NSRect newFrame = [[self window] frame];
188 newFrame.size.height += windowDelta; 192 newFrame.size.height += windowDelta;
189 [[self window] setFrame:newFrame display:NO]; 193 [[self window] setFrame:newFrame display:NO];
190 } 194 }
191 195
192 @end 196 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/android/login_prompt_android.cc ('k') | chrome/browser/ui/login/login_prompt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698