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