Chromium Code Reviews| 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/memory/scoped_nsobject.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 70 // will occur via an InvokeLater on the UI thread, which is guaranteed | 70 // will occur via an InvokeLater on the UI thread, which is guaranteed |
| 71 // to happen after this is called (since this was InvokeLater'd first). | 71 // to happen after this is called (since this was InvokeLater'd first). |
| 72 WebContents* requesting_contents = GetWebContentsForLogin(); | 72 WebContents* requesting_contents = GetWebContentsForLogin(); |
| 73 DCHECK(requesting_contents); | 73 DCHECK(requesting_contents); |
| 74 | 74 |
| 75 scoped_nsobject<CustomConstrainedWindowSheet> sheet( | 75 scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
| 76 [[CustomConstrainedWindowSheet alloc] | 76 [[CustomConstrainedWindowSheet alloc] |
| 77 initWithCustomWindow:[sheet_controller_ window]]); | 77 initWithCustomWindow:[sheet_controller_ window]]); |
| 78 constrained_window_.reset(new ConstrainedWindowMac( | 78 constrained_window_.reset(new ConstrainedWindowMac( |
| 79 this, requesting_contents, sheet)); | 79 this, requesting_contents, sheet)); |
| 80 SetDialog(constrained_window_.get()); | |
| 81 | 80 |
| 82 NotifyAuthNeeded(); | 81 NotifyAuthNeeded(); |
| 83 } | 82 } |
| 84 | 83 |
| 84 virtual void CloseDialog() OVERRIDE { | |
| 85 // The hosting WebContentsModalDialog may have been freed. | |
| 86 if (constrained_window_.get()) | |
|
sail
2013/02/16 21:45:22
don't need .get()
Mike Wittman
2013/02/19 19:08:36
Done.
| |
| 87 constrained_window_->CloseWebContentsModalDialog(); | |
| 88 } | |
| 89 | |
| 85 // Overridden from ConstrainedWindowMacDelegate: | 90 // Overridden from ConstrainedWindowMacDelegate: |
| 86 virtual void OnConstrainedWindowClosed( | 91 virtual void OnConstrainedWindowClosed( |
| 87 ConstrainedWindowMac* window) OVERRIDE { | 92 ConstrainedWindowMac* window) OVERRIDE { |
| 88 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 89 SetDialog(NULL); | |
| 90 SetModel(NULL); | 94 SetModel(NULL); |
| 91 ReleaseSoon(); | 95 ReleaseSoon(); |
| 92 | 96 |
| 93 constrained_window_.reset(); | 97 constrained_window_.reset(); |
| 94 sheet_controller_.reset(); | 98 sheet_controller_.reset(); |
| 95 } | 99 } |
| 96 | 100 |
| 97 void OnLoginPressed(const string16& username, | 101 void OnLoginPressed(const string16& username, |
| 98 const string16& password) { | 102 const string16& password) { |
| 99 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 180 // Resize the text field. | 184 // Resize the text field. |
| 181 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker | 185 CGFloat windowDelta = [GTMUILocalizerAndLayoutTweaker |
| 182 sizeToFitFixedWidthTextField:explanationField_]; | 186 sizeToFitFixedWidthTextField:explanationField_]; |
| 183 | 187 |
| 184 NSRect newFrame = [[self window] frame]; | 188 NSRect newFrame = [[self window] frame]; |
| 185 newFrame.size.height += windowDelta; | 189 newFrame.size.height += windowDelta; |
| 186 [[self window] setFrame:newFrame display:NO]; | 190 [[self window] setFrame:newFrame display:NO]; |
| 187 } | 191 } |
| 188 | 192 |
| 189 @end | 193 @end |
| OLD | NEW |