Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Side by Side Diff: chrome/browser/ui/login/login_prompt_mac.mm

Issue 6312154: Remove wstring from RVH's run Javascript command.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #include "chrome/browser/ui/login/login_prompt.h" 5 #include "chrome/browser/ui/login/login_prompt.h"
6 #import "chrome/browser/ui/login/login_prompt_mac.h" 6 #import "chrome/browser/ui/login/login_prompt_mac.h"
7 7
8 #include "base/mac/mac_util.h" 8 #include "base/mac/mac_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 10 #include "base/sys_string_conversions.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 virtual void OnAutofillDataAvailable(const std::wstring& username, 46 virtual void OnAutofillDataAvailable(const std::wstring& username,
47 const std::wstring& password) { 47 const std::wstring& password) {
48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 48 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
49 49
50 [sheet_controller_ autofillLogin:base::SysWideToNSString(username) 50 [sheet_controller_ autofillLogin:base::SysWideToNSString(username)
51 password:base::SysWideToNSString(password)]; 51 password:base::SysWideToNSString(password)];
52 } 52 }
53 53
54 // LoginHandler: 54 // LoginHandler:
55 virtual void BuildViewForPasswordManager(PasswordManager* manager, 55 virtual void BuildViewForPasswordManager(PasswordManager* manager,
56 std::wstring explanation) { 56 const string16& explanation) {
57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 57 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
58 58
59 // Load nib here instead of in constructor. 59 // Load nib here instead of in constructor.
60 sheet_controller_ = [[[LoginHandlerSheet alloc] 60 sheet_controller_ = [[[LoginHandlerSheet alloc]
61 initWithLoginHandler:this] autorelease]; 61 initWithLoginHandler:this] autorelease];
62 init([sheet_controller_ window], sheet_controller_, 62 init([sheet_controller_ window], sheet_controller_,
63 @selector(sheetDidEnd:returnCode:contextInfo:)); 63 @selector(sheetDidEnd:returnCode:contextInfo:));
64 64
65 SetModel(manager); 65 SetModel(manager);
66 66
67 [sheet_controller_ setExplanation:base::SysWideToNSString(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 SetDialog(GetTabContentsForLogin()->CreateConstrainedDialog(this)); 74 SetDialog(GetTabContentsForLogin()->CreateConstrainedDialog(this));
75 75
76 NotifyAuthNeeded(); 76 NotifyAuthNeeded();
77 } 77 }
78 78
79 // Overridden from ConstrainedWindowMacDelegate: 79 // Overridden from ConstrainedWindowMacDelegate:
80 virtual void DeleteDelegate() { 80 virtual void DeleteDelegate() {
81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 81 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
82 82
83 // The constrained window is going to delete itself; clear our pointer. 83 // The constrained window is going to delete itself; clear our pointer.
84 SetDialog(NULL); 84 SetDialog(NULL);
85 SetModel(NULL); 85 SetModel(NULL);
86 86
87 // Close sheet if it's still open, as required by 87 // Close sheet if it's still open, as required by
88 // ConstrainedWindowMacDelegate. 88 // ConstrainedWindowMacDelegate.
89 if (is_sheet_open()) 89 if (is_sheet_open())
90 [NSApp endSheet:sheet()]; 90 [NSApp endSheet:sheet()];
91 91
92 ReleaseSoon(); 92 ReleaseSoon();
93 } 93 }
94 94
95 void OnLoginPressed(const std::wstring& username, 95 void OnLoginPressed(const string16& username,
96 const std::wstring& password) { 96 const string16& password) {
97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 97 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
98 98
99 SetAuth(username, password); 99 SetAuth(username, password);
100 } 100 }
101 101
102 void OnCancelPressed() { 102 void OnCancelPressed() {
103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 103 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
104 104
105 CancelAuth(); 105 CancelAuth();
106 } 106 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 // The buttons could be in a modal loop, so disconnect them so they cannot 140 // The buttons could be in a modal loop, so disconnect them so they cannot
141 // call back to us after we're dead. 141 // call back to us after we're dead.
142 [loginButton_ setTarget:nil]; 142 [loginButton_ setTarget:nil];
143 [cancelButton_ setTarget:nil]; 143 [cancelButton_ setTarget:nil];
144 [super dealloc]; 144 [super dealloc];
145 } 145 }
146 146
147 - (IBAction)loginPressed:(id)sender { 147 - (IBAction)loginPressed:(id)sender {
148 using base::SysNSStringToWide; 148 using base::SysNSStringToWide;
149 [NSApp endSheet:[self window]]; 149 [NSApp endSheet:[self window]];
150 handler_->OnLoginPressed(SysNSStringToWide([nameField_ stringValue]), 150 handler_->OnLoginPressed(
151 SysNSStringToWide([passwordField_ stringValue])); 151 base::SysNSStringToUTF16([nameField_ stringValue]),
152 base::SysNSStringToUTF16([passwordField_ stringValue]));
152 } 153 }
153 154
154 - (IBAction)cancelPressed:(id)sender { 155 - (IBAction)cancelPressed:(id)sender {
155 [NSApp endSheet:[self window]]; 156 [NSApp endSheet:[self window]];
156 handler_->OnCancelPressed(); 157 handler_->OnCancelPressed();
157 } 158 }
158 159
159 - (void)sheetDidEnd:(NSWindow*)sheet 160 - (void)sheetDidEnd:(NSWindow*)sheet
160 returnCode:(int)returnCode 161 returnCode:(int)returnCode
161 contextInfo:(void *)contextInfo { 162 contextInfo:(void *)contextInfo {
(...skipping 19 matching lines...) Expand all
181 sizeToFitFixedWidthTextField:explanationField_]; 182 sizeToFitFixedWidthTextField:explanationField_];
182 183
183 // Resize the window (no shifting needed due to window layout). 184 // Resize the window (no shifting needed due to window layout).
184 NSSize windowDelta = NSMakeSize(0, explanationShift); 185 NSSize windowDelta = NSMakeSize(0, explanationShift);
185 [GTMUILocalizerAndLayoutTweaker 186 [GTMUILocalizerAndLayoutTweaker
186 resizeWindowWithoutAutoResizingSubViews:[self window] 187 resizeWindowWithoutAutoResizingSubViews:[self window]
187 delta:windowDelta]; 188 delta:windowDelta];
188 } 189 }
189 190
190 @end 191 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698