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 #import "chrome/browser/login_prompt_mac.h" | 6 #import "chrome/browser/login_prompt_mac.h" |
7 | 7 |
8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
9 #include "base/mac_util.h" | 9 #include "base/mac_util.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 // ---------------------------------------------------------------------------- | 28 // ---------------------------------------------------------------------------- |
29 // LoginHandlerMac | 29 // LoginHandlerMac |
30 | 30 |
31 // This class simply forwards the authentication from the LoginView (on | 31 // This class simply forwards the authentication from the LoginView (on |
32 // the UI thread) to the URLRequest (on the I/O thread). | 32 // the UI thread) to the URLRequest (on the I/O thread). |
33 // This class uses ref counting to ensure that it lives until all InvokeLaters | 33 // This class uses ref counting to ensure that it lives until all InvokeLaters |
34 // have been called. | 34 // have been called. |
35 class LoginHandlerMac : public LoginHandler, | 35 class LoginHandlerMac : public LoginHandler, |
36 public ConstrainedWindowMacDelegateCustomSheet { | 36 public ConstrainedWindowMacDelegateCustomSheet { |
37 public: | 37 public: |
38 explicit LoginHandlerMac(URLRequest* request) | 38 LoginHandlerMac(net::AuthChallengeInfo* auth_info, URLRequest* request) |
39 : LoginHandler(request), | 39 : LoginHandler(auth_info, request), |
40 sheet_controller_(nil) { | 40 sheet_controller_(nil) { |
41 } | 41 } |
42 | 42 |
43 virtual ~LoginHandlerMac() { | 43 virtual ~LoginHandlerMac() { |
44 } | 44 } |
45 | 45 |
46 // LoginModelObserver implementation. | 46 // LoginModelObserver implementation. |
47 virtual void OnAutofillDataAvailable(const std::wstring& username, | 47 virtual void OnAutofillDataAvailable(const std::wstring& username, |
48 const std::wstring& password) { | 48 const std::wstring& password) { |
49 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 49 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
(...skipping 17 matching lines...) Expand all Loading... |
67 | 67 |
68 [sheet_controller_ setExplanation:base::SysWideToNSString(explanation)]; | 68 [sheet_controller_ setExplanation:base::SysWideToNSString(explanation)]; |
69 | 69 |
70 // Scary thread safety note: This can potentially be called *after* SetAuth | 70 // Scary thread safety note: This can potentially be called *after* SetAuth |
71 // or CancelAuth (say, if the request was cancelled before the UI thread got | 71 // or CancelAuth (say, if the request was cancelled before the UI thread got |
72 // control). However, that's OK since any UI interaction in those functions | 72 // control). However, that's OK since any UI interaction in those functions |
73 // will occur via an InvokeLater on the UI thread, which is guaranteed | 73 // will occur via an InvokeLater on the UI thread, which is guaranteed |
74 // to happen after this is called (since this was InvokeLater'd first). | 74 // to happen after this is called (since this was InvokeLater'd first). |
75 SetDialog(GetTabContentsForLogin()->CreateConstrainedDialog(this)); | 75 SetDialog(GetTabContentsForLogin()->CreateConstrainedDialog(this)); |
76 | 76 |
77 SendNotifications(); | 77 NotifyAuthNeeded(); |
78 } | 78 } |
79 | 79 |
80 // Overridden from ConstrainedWindowMacDelegate: | 80 // Overridden from ConstrainedWindowMacDelegate: |
81 virtual void DeleteDelegate() { | 81 virtual void DeleteDelegate() { |
82 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); | 82 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); |
83 | 83 |
84 // The constrained window is going to delete itself; clear our pointer. | 84 // The constrained window is going to delete itself; clear our pointer. |
85 SetDialog(NULL); | 85 SetDialog(NULL); |
86 SetModel(NULL); | 86 SetModel(NULL); |
87 | 87 |
(...skipping 21 matching lines...) Expand all Loading... |
109 private: | 109 private: |
110 friend class LoginPrompt; | 110 friend class LoginPrompt; |
111 | 111 |
112 // The Cocoa controller of the GUI. | 112 // The Cocoa controller of the GUI. |
113 LoginHandlerSheet* sheet_controller_; | 113 LoginHandlerSheet* sheet_controller_; |
114 | 114 |
115 DISALLOW_COPY_AND_ASSIGN(LoginHandlerMac); | 115 DISALLOW_COPY_AND_ASSIGN(LoginHandlerMac); |
116 }; | 116 }; |
117 | 117 |
118 // static | 118 // static |
119 LoginHandler* LoginHandler::Create(URLRequest* request) { | 119 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, |
120 return new LoginHandlerMac(request); | 120 URLRequest* request) { |
| 121 return new LoginHandlerMac(auth_info, request); |
121 } | 122 } |
122 | 123 |
123 // ---------------------------------------------------------------------------- | 124 // ---------------------------------------------------------------------------- |
124 // LoginHandlerSheet | 125 // LoginHandlerSheet |
125 | 126 |
126 @implementation LoginHandlerSheet | 127 @implementation LoginHandlerSheet |
127 | 128 |
128 - (id)initWithLoginHandler:(LoginHandlerMac*)handler { | 129 - (id)initWithLoginHandler:(LoginHandlerMac*)handler { |
129 NSString* nibPath = | 130 NSString* nibPath = |
130 [mac_util::MainAppBundle() pathForResource:@"HttpAuthLoginSheet" | 131 [mac_util::MainAppBundle() pathForResource:@"HttpAuthLoginSheet" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 sizeToFitFixedWidthTextField:explanationField_]; | 182 sizeToFitFixedWidthTextField:explanationField_]; |
182 | 183 |
183 // Resize the window (no shifting needed due to window layout). | 184 // Resize the window (no shifting needed due to window layout). |
184 NSSize windowDelta = NSMakeSize(0, explanationShift); | 185 NSSize windowDelta = NSMakeSize(0, explanationShift); |
185 [GTMUILocalizerAndLayoutTweaker | 186 [GTMUILocalizerAndLayoutTweaker |
186 resizeWindowWithoutAutoResizingSubViews:[self window] | 187 resizeWindowWithoutAutoResizingSubViews:[self window] |
187 delta:windowDelta]; | 188 delta:windowDelta]; |
188 } | 189 } |
189 | 190 |
190 @end | 191 @end |
OLD | NEW |