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

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

Issue 196109: Load the http auth dialog from the main bundle.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 11 years, 3 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
« no previous file with comments | « chrome/browser/login_prompt_mac.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
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/login_prompt.h" 5 #include "chrome/browser/login_prompt.h"
6 #import "chrome/browser/login_prompt_mac.h" 6 #import "chrome/browser/login_prompt_mac.h"
7 7
8 #include "app/l10n_util.h" 8 #include "app/l10n_util.h"
9 #include "base/mac_util.h" 9 #include "base/mac_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
12 #include "chrome/browser/cocoa/constrained_window_mac.h" 12 #include "chrome/browser/cocoa/constrained_window_mac.h"
13 #include "chrome/browser/login_model.h" 13 #include "chrome/browser/login_model.h"
14 #include "chrome/browser/password_manager/password_manager.h" 14 #include "chrome/browser/password_manager/password_manager.h"
15 #include "chrome/browser/renderer_host/resource_dispatcher_host.h" 15 #include "chrome/browser/renderer_host/resource_dispatcher_host.h"
16 #include "chrome/browser/tab_contents/navigation_controller.h" 16 #include "chrome/browser/tab_contents/navigation_controller.h"
17 #include "chrome/browser/tab_contents/tab_contents.h" 17 #include "chrome/browser/tab_contents/tab_contents.h"
18 #include "chrome/browser/tab_contents/tab_util.h" 18 #include "chrome/browser/tab_contents/tab_util.h"
19 #include "chrome/common/notification_service.h" 19 #include "chrome/common/notification_service.h"
20 #include "grit/generated_resources.h" 20 #include "grit/generated_resources.h"
21 #include "net/url_request/url_request.h" 21 #include "net/url_request/url_request.h"
22 #include "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
22 23
23 using webkit_glue::PasswordForm; 24 using webkit_glue::PasswordForm;
24 25
25 // ---------------------------------------------------------------------------- 26 // ----------------------------------------------------------------------------
26 // LoginHandlerMac 27 // LoginHandlerMac
27 28
28 // This class simply forwards the authentication from the LoginView (on 29 // This class simply forwards the authentication from the LoginView (on
29 // the UI thread) to the URLRequest (on the I/O thread). 30 // the UI thread) to the URLRequest (on the I/O thread).
30 // This class uses ref counting to ensure that it lives until all InvokeLaters 31 // This class uses ref counting to ensure that it lives until all InvokeLaters
31 // have been called. 32 // have been called.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 DCHECK(MessageLoop::current() == ui_loop_); 83 DCHECK(MessageLoop::current() == ui_loop_);
83 84
84 // Load nib here instead of in constructor. 85 // Load nib here instead of in constructor.
85 sheet_controller_ = [[[LoginHandlerSheet alloc] 86 sheet_controller_ = [[[LoginHandlerSheet alloc]
86 initWithLoginHandler:this] autorelease]; 87 initWithLoginHandler:this] autorelease];
87 init([sheet_controller_ window], sheet_controller_, 88 init([sheet_controller_ window], sheet_controller_,
88 @selector(sheetDidEnd:returnCode:contextInfo:)); 89 @selector(sheetDidEnd:returnCode:contextInfo:));
89 90
90 SetModel(manager); 91 SetModel(manager);
91 92
93 [sheet_controller_ setExplanation:base::SysWideToNSString(explanation)];
94
92 // Scary thread safety note: This can potentially be called *after* SetAuth 95 // Scary thread safety note: This can potentially be called *after* SetAuth
93 // or CancelAuth (say, if the request was cancelled before the UI thread got 96 // or CancelAuth (say, if the request was cancelled before the UI thread got
94 // control). However, that's OK since any UI interaction in those functions 97 // control). However, that's OK since any UI interaction in those functions
95 // will occur via an InvokeLater on the UI thread, which is guaranteed 98 // will occur via an InvokeLater on the UI thread, which is guaranteed
96 // to happen after this is called (since this was InvokeLater'd first). 99 // to happen after this is called (since this was InvokeLater'd first).
97 dialog_ = GetTabContentsForLogin()->CreateConstrainedDialog(this); 100 dialog_ = GetTabContentsForLogin()->CreateConstrainedDialog(this);
98 101
99 SendNotifications(); 102 SendNotifications();
100 } 103 }
101 104
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 LoginHandler* LoginHandler::Create(URLRequest* request, MessageLoop* ui_loop) { 308 LoginHandler* LoginHandler::Create(URLRequest* request, MessageLoop* ui_loop) {
306 return new LoginHandlerMac(request, ui_loop); 309 return new LoginHandlerMac(request, ui_loop);
307 } 310 }
308 311
309 // ---------------------------------------------------------------------------- 312 // ----------------------------------------------------------------------------
310 // LoginHandlerSheet 313 // LoginHandlerSheet
311 314
312 @implementation LoginHandlerSheet 315 @implementation LoginHandlerSheet
313 316
314 - (id)initWithLoginHandler:(LoginHandlerMac*)handler { 317 - (id)initWithLoginHandler:(LoginHandlerMac*)handler {
315 if ((self = [super initWithWindowNibName:@"HttpAuthLoginSheet" 318 NSString* nibPath =
316 owner:self])) { 319 [mac_util::MainAppBundle() pathForResource:@"HttpAuthLoginSheet"
320 ofType:@"nib"];
321 if ((self = [super initWithWindowNibPath:nibPath
322 owner:self])) {
317 handler_ = handler; 323 handler_ = handler;
318 } 324 }
319 return self; 325 return self;
320 } 326 }
321 327
322 - (IBAction)loginPressed:(id)sender { 328 - (IBAction)loginPressed:(id)sender {
323 using base::SysNSStringToWide; 329 using base::SysNSStringToWide;
324 [NSApp endSheet:[self window]]; 330 [NSApp endSheet:[self window]];
325 handler_->OnLoginPressed(SysNSStringToWide([nameField_ stringValue]), 331 handler_->OnLoginPressed(SysNSStringToWide([nameField_ stringValue]),
326 SysNSStringToWide([passwordField_ stringValue])); 332 SysNSStringToWide([passwordField_ stringValue]));
(...skipping 12 matching lines...) Expand all
339 } 345 }
340 346
341 - (void)autofillLogin:(NSString*)login password:(NSString*)password { 347 - (void)autofillLogin:(NSString*)login password:(NSString*)password {
342 if ([[nameField_ stringValue] length] == 0) { 348 if ([[nameField_ stringValue] length] == 0) {
343 [nameField_ setStringValue:login]; 349 [nameField_ setStringValue:login];
344 [passwordField_ setStringValue:password]; 350 [passwordField_ setStringValue:password];
345 [nameField_ selectText:self]; 351 [nameField_ selectText:self];
346 } 352 }
347 } 353 }
348 354
355 - (void)setExplanation:(NSString*)explanation {
356 // Put in the text
pink (ping after 24hrs) 2009/09/14 19:08:12 period after sentence. applies to 2 comments below
357 [explanationField_ setStringValue:explanation];
358
359 // Resize the TextField
360 CGFloat explanationShift =
361 [GTMUILocalizerAndLayoutTweaker
362 sizeToFitFixedWidthTextField:explanationField_];
363
364 // Resize the window (no shifting needed due to window layout)
365 NSWindow* window = [self window];
366 [[window contentView] setAutoresizesSubviews:NO];
367 NSRect rect = [window frame];
368 rect.size.height = rect.size.height + explanationShift;
Nico 2009/09/14 19:34:56 +=
369 [window setFrame:rect display:NO];
370 [[window contentView] setAutoresizesSubviews:YES];
371 }
372
349 @end 373 @end
OLDNEW
« no previous file with comments | « chrome/browser/login_prompt_mac.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698