OLD | NEW |
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/mac_util.h" | 8 #include "base/mac/mac_util.h" |
9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "chrome/browser/password_manager/password_manager.h" | 14 #include "chrome/browser/password_manager/password_manager.h" |
15 #include "chrome/browser/tab_contents/tab_util.h" | 15 #include "chrome/browser/tab_contents/tab_util.h" |
16 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" | 16 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
17 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" | 17 #include "chrome/browser/ui/cocoa/constrained_window/constrained_window_mac.h" |
18 #include "chrome/browser/ui/login/login_model.h" | 18 #include "chrome/browser/ui/login/login_model.h" |
19 #include "chrome/browser/ui/login/login_prompt.h" | 19 #include "chrome/browser/ui/login/login_prompt.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)]; | 66 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)]; |
67 | 67 |
68 // Scary thread safety note: This can potentially be called *after* SetAuth | 68 // Scary thread safety note: This can potentially be called *after* SetAuth |
69 // or CancelAuth (say, if the request was cancelled before the UI thread got | 69 // or CancelAuth (say, if the request was cancelled before the UI thread got |
70 // control). However, that's OK since any UI interaction in those functions | 70 // control). However, that's OK since any UI interaction in those functions |
71 // will occur via an InvokeLater on the UI thread, which is guaranteed | 71 // will occur via an InvokeLater on the UI thread, which is guaranteed |
72 // to happen after this is called (since this was InvokeLater'd first). | 72 // to happen after this is called (since this was InvokeLater'd first). |
73 WebContents* requesting_contents = GetWebContentsForLogin(); | 73 WebContents* requesting_contents = GetWebContentsForLogin(); |
74 DCHECK(requesting_contents); | 74 DCHECK(requesting_contents); |
75 | 75 |
76 scoped_nsobject<CustomConstrainedWindowSheet> sheet( | 76 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
77 [[CustomConstrainedWindowSheet alloc] | 77 [[CustomConstrainedWindowSheet alloc] |
78 initWithCustomWindow:[sheet_controller_ window]]); | 78 initWithCustomWindow:[sheet_controller_ window]]); |
79 constrained_window_.reset(new ConstrainedWindowMac( | 79 constrained_window_.reset(new ConstrainedWindowMac( |
80 this, requesting_contents, sheet)); | 80 this, requesting_contents, sheet)); |
81 | 81 |
82 NotifyAuthNeeded(); | 82 NotifyAuthNeeded(); |
83 } | 83 } |
84 | 84 |
85 virtual void CloseDialog() OVERRIDE { | 85 virtual void CloseDialog() OVERRIDE { |
86 // The hosting dialog may have been freed. | 86 // The hosting dialog may have been freed. |
(...skipping 27 matching lines...) Expand all Loading... |
114 friend class LoginPrompt; | 114 friend class LoginPrompt; |
115 | 115 |
116 virtual ~LoginHandlerMac() { | 116 virtual ~LoginHandlerMac() { |
117 // This class will be deleted on a non UI thread. Ensure that the UI members | 117 // This class will be deleted on a non UI thread. Ensure that the UI members |
118 // have already been deleted. | 118 // have already been deleted. |
119 CHECK(!constrained_window_.get()); | 119 CHECK(!constrained_window_.get()); |
120 CHECK(!sheet_controller_.get()); | 120 CHECK(!sheet_controller_.get()); |
121 } | 121 } |
122 | 122 |
123 // The Cocoa controller of the GUI. | 123 // The Cocoa controller of the GUI. |
124 scoped_nsobject<LoginHandlerSheet> sheet_controller_; | 124 base::scoped_nsobject<LoginHandlerSheet> sheet_controller_; |
125 | 125 |
126 scoped_ptr<ConstrainedWindowMac> constrained_window_; | 126 scoped_ptr<ConstrainedWindowMac> constrained_window_; |
127 | 127 |
128 DISALLOW_COPY_AND_ASSIGN(LoginHandlerMac); | 128 DISALLOW_COPY_AND_ASSIGN(LoginHandlerMac); |
129 }; | 129 }; |
130 | 130 |
131 // static | 131 // static |
132 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, | 132 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, |
133 net::URLRequest* request) { | 133 net::URLRequest* request) { |
134 return new LoginHandlerMac(auth_info, request); | 134 return new LoginHandlerMac(auth_info, request); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // Resize the text field. | 185 // Resize the text field. |
186 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker | 186 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker |
187 sizeToFitFixedWidthTextField:explanationField_]; | 187 sizeToFitFixedWidthTextField:explanationField_]; |
188 | 188 |
189 NSRect newFrame = [[self window] frame]; | 189 NSRect newFrame = [[self window] frame]; |
190 newFrame.size.height += windowDelta; | 190 newFrame.size.height += windowDelta; |
191 [[self window] setFrame:newFrame display:NO]; | 191 [[self window] setFrame:newFrame display:NO]; |
192 } | 192 } |
193 | 193 |
194 @end | 194 @end |
OLD | NEW |