| 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/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 // or CancelAuth (say, if the request was cancelled before the UI thread got | 73 // or CancelAuth (say, if the request was cancelled before the UI thread got |
| 74 // control). However, that's OK since any UI interaction in those functions | 74 // control). However, that's OK since any UI interaction in those functions |
| 75 // will occur via an InvokeLater on the UI thread, which is guaranteed | 75 // will occur via an InvokeLater on the UI thread, which is guaranteed |
| 76 // to happen after this is called (since this was InvokeLater'd first). | 76 // to happen after this is called (since this was InvokeLater'd first). |
| 77 WebContents* requesting_contents = GetWebContentsForLogin(); | 77 WebContents* requesting_contents = GetWebContentsForLogin(); |
| 78 DCHECK(requesting_contents); | 78 DCHECK(requesting_contents); |
| 79 | 79 |
| 80 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( | 80 base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
| 81 [[CustomConstrainedWindowSheet alloc] | 81 [[CustomConstrainedWindowSheet alloc] |
| 82 initWithCustomWindow:[sheet_controller_ window]]); | 82 initWithCustomWindow:[sheet_controller_ window]]); |
| 83 constrained_window_ = CreateAndShowWebModalDialogMac( | 83 constrained_window_.reset(new ConstrainedWindowMac( |
| 84 this, requesting_contents, sheet); | 84 this, requesting_contents, sheet)); |
| 85 | 85 |
| 86 NotifyAuthNeeded(); | 86 NotifyAuthNeeded(); |
| 87 } | 87 } |
| 88 | 88 |
| 89 void CloseDialog() override { | 89 void CloseDialog() override { |
| 90 // The hosting dialog may have been freed. | 90 // The hosting dialog may have been freed. |
| 91 if (constrained_window_) | 91 if (constrained_window_) |
| 92 constrained_window_->CloseWebContentsModalDialog(); | 92 constrained_window_->CloseWebContentsModalDialog(); |
| 93 } | 93 } |
| 94 | 94 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 119 ~LoginHandlerMac() override { | 119 ~LoginHandlerMac() override { |
| 120 // This class will be deleted on a non UI thread. Ensure that the UI members | 120 // This class will be deleted on a non UI thread. Ensure that the UI members |
| 121 // have already been deleted. | 121 // have already been deleted. |
| 122 CHECK(!constrained_window_.get()); | 122 CHECK(!constrained_window_.get()); |
| 123 CHECK(!sheet_controller_.get()); | 123 CHECK(!sheet_controller_.get()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // The Cocoa controller of the GUI. | 126 // The Cocoa controller of the GUI. |
| 127 base::scoped_nsobject<LoginHandlerSheet> sheet_controller_; | 127 base::scoped_nsobject<LoginHandlerSheet> sheet_controller_; |
| 128 | 128 |
| 129 std::unique_ptr<ConstrainedWindowMac> constrained_window_; | 129 scoped_ptr<ConstrainedWindowMac> constrained_window_; |
| 130 | 130 |
| 131 DISALLOW_COPY_AND_ASSIGN(LoginHandlerMac); | 131 DISALLOW_COPY_AND_ASSIGN(LoginHandlerMac); |
| 132 }; | 132 }; |
| 133 | 133 |
| 134 // static | 134 // static |
| 135 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, | 135 LoginHandler* LoginHandler::Create(net::AuthChallengeInfo* auth_info, |
| 136 net::URLRequest* request) { | 136 net::URLRequest* request) { |
| 137 if (chrome::ToolkitViewsDialogsEnabled()) | 137 if (chrome::ToolkitViewsDialogsEnabled()) |
| 138 return chrome::CreateLoginHandlerViews(auth_info, request); | 138 return chrome::CreateLoginHandlerViews(auth_info, request); |
| 139 return new LoginHandlerMac(auth_info, request); | 139 return new LoginHandlerMac(auth_info, request); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 // Resize the text field. | 201 // Resize the text field. |
| 202 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker | 202 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker |
| 203 sizeToFitFixedWidthTextField:explanationField_]; | 203 sizeToFitFixedWidthTextField:explanationField_]; |
| 204 | 204 |
| 205 NSRect newFrame = [[self window] frame]; | 205 NSRect newFrame = [[self window] frame]; |
| 206 newFrame.size.height += windowDelta; | 206 newFrame.size.height += windowDelta; |
| 207 [[self window] setFrame:newFrame display:NO]; | 207 [[self window] setFrame:newFrame display:NO]; |
| 208 } | 208 } |
| 209 | 209 |
| 210 @end | 210 @end |
| OLD | NEW |