| 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/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/browser/password_manager/password_manager.h" | 13 #include "chrome/browser/password_manager/password_manager.h" |
| 14 #include "chrome/browser/tab_contents/tab_util.h" | 14 #include "chrome/browser/tab_contents/tab_util.h" |
| 15 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" | 15 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" |
| 16 #include "chrome/browser/ui/login/login_model.h" | 16 #include "chrome/browser/ui/login/login_model.h" |
| 17 #include "chrome/browser/ui/login/login_prompt.h" | 17 #include "chrome/browser/ui/login/login_prompt.h" |
| 18 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 18 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
| 20 #include "content/public/browser/web_contents.h" | 20 #include "content/public/browser/web_contents.h" |
| 21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
| 22 #include "net/url_request/url_request.h" | 22 #include "net/url_request/url_request.h" |
| 23 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 23 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
| 24 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
| 25 | 25 |
| 26 using content::BrowserThread; | 26 using content::BrowserThread; |
| 27 using content::WebContents; | 27 using content::WebContents; |
| 28 using webkit::forms::PasswordForm; | 28 using webkit::forms::PasswordForm; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)]; | 67 [sheet_controller_ setExplanation:base::SysUTF16ToNSString(explanation)]; |
| 68 | 68 |
| 69 // Scary thread safety note: This can potentially be called *after* SetAuth | 69 // Scary thread safety note: This can potentially be called *after* SetAuth |
| 70 // 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 |
| 71 // 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 |
| 72 // 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 |
| 73 // 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). |
| 74 WebContents* requesting_contents = GetWebContentsForLogin(); | 74 WebContents* requesting_contents = GetWebContentsForLogin(); |
| 75 DCHECK(requesting_contents); | 75 DCHECK(requesting_contents); |
| 76 | 76 |
| 77 TabContentsWrapper* wrapper = | 77 TabContents* tab_contents = |
| 78 TabContentsWrapper::GetCurrentWrapperForContents(requesting_contents); | 78 TabContents::FromWebContents(requesting_contents); |
| 79 SetDialog(new ConstrainedWindowMac(wrapper, this)); | 79 SetDialog(new ConstrainedWindowMac(tab_contents, this)); |
| 80 | 80 |
| 81 NotifyAuthNeeded(); | 81 NotifyAuthNeeded(); |
| 82 } | 82 } |
| 83 | 83 |
| 84 // Overridden from ConstrainedWindowMacDelegate: | 84 // Overridden from ConstrainedWindowMacDelegate: |
| 85 virtual void DeleteDelegate() { | 85 virtual void DeleteDelegate() { |
| 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 86 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 87 | 87 |
| 88 // The constrained window is going to delete itself; clear our pointer. | 88 // The constrained window is going to delete itself; clear our pointer. |
| 89 SetDialog(NULL); | 89 SetDialog(NULL); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 sizeToFitFixedWidthTextField:explanationField_]; | 189 sizeToFitFixedWidthTextField:explanationField_]; |
| 190 | 190 |
| 191 // Resize the window (no shifting needed due to window layout). | 191 // Resize the window (no shifting needed due to window layout). |
| 192 NSSize windowDelta = NSMakeSize(0, explanationShift); | 192 NSSize windowDelta = NSMakeSize(0, explanationShift); |
| 193 [GTMUILocalizerAndLayoutTweaker | 193 [GTMUILocalizerAndLayoutTweaker |
| 194 resizeWindowWithoutAutoResizingSubViews:[self window] | 194 resizeWindowWithoutAutoResizingSubViews:[self window] |
| 195 delta:windowDelta]; | 195 delta:windowDelta]; |
| 196 } | 196 } |
| 197 | 197 |
| 198 @end | 198 @end |
| OLD | NEW |