OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/cocoa/autofill/autofill_dialog_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 return it->second; | 190 return it->second; |
191 } | 191 } |
192 | 192 |
193 NOTREACHED(); | 193 NOTREACHED(); |
194 return string16(); | 194 return string16(); |
195 } | 195 } |
196 | 196 |
197 void AutofillDialogCocoa::SetTextContentsOfInput(const DetailInput& input, | 197 void AutofillDialogCocoa::SetTextContentsOfInput(const DetailInput& input, |
198 const string16& contents) { | 198 const string16& contents) { |
199 [sheet_delegate_ setTextContents:base::SysUTF16ToNSString(contents) | 199 [sheet_delegate_ setTextContents:base::SysUTF16ToNSString(contents) |
200 forInput:input]; | 200 forInput:input]; |
201 } | 201 } |
202 | 202 |
203 void AutofillDialogCocoa::SetTextContentsOfSuggestionInput( | 203 void AutofillDialogCocoa::SetTextContentsOfSuggestionInput( |
204 DialogSection section, | 204 DialogSection section, |
205 const base::string16& text) { | 205 const base::string16& text) { |
206 [sheet_delegate_ setTextContents:base::SysUTF16ToNSString(text) | 206 [sheet_delegate_ setTextContents:base::SysUTF16ToNSString(text) |
207 ofSuggestionForSection:section]; | 207 ofSuggestionForSection:section]; |
208 } | 208 } |
209 | 209 |
210 void AutofillDialogCocoa::ActivateInput(const DetailInput& input) { | 210 void AutofillDialogCocoa::ActivateInput(const DetailInput& input) { |
211 [sheet_delegate_ activateFieldForInput:input]; | 211 [sheet_delegate_ activateFieldForInput:input]; |
212 } | 212 } |
213 | 213 |
214 gfx::Size AutofillDialogCocoa::GetSize() const { | 214 gfx::Size AutofillDialogCocoa::GetSize() const { |
215 return gfx::Size(NSSizeToCGSize([[sheet_delegate_ window] frame].size)); | 215 return gfx::Size(NSSizeToCGSize([[sheet_delegate_ window] frame].size)); |
216 } | 216 } |
217 | 217 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 [titleTextField_ setEditable:NO]; | 334 [titleTextField_ setEditable:NO]; |
335 [titleTextField_ setBordered:NO]; | 335 [titleTextField_ setBordered:NO]; |
336 [titleTextField_ setDrawsBackground:NO]; | 336 [titleTextField_ setDrawsBackground:NO]; |
337 [titleTextField_ setFont:[NSFont systemFontOfSize:15.0]]; | 337 [titleTextField_ setFont:[NSFont systemFontOfSize:15.0]]; |
338 [titleTextField_ setStringValue: | 338 [titleTextField_ setStringValue: |
339 base::SysUTF16ToNSString(autofillDialog->delegate()->DialogTitle())]; | 339 base::SysUTF16ToNSString(autofillDialog->delegate()->DialogTitle())]; |
340 [titleTextField_ sizeToFit]; | 340 [titleTextField_ sizeToFit]; |
341 | 341 |
342 accountChooser_.reset([[AutofillAccountChooser alloc] | 342 accountChooser_.reset([[AutofillAccountChooser alloc] |
343 initWithFrame:NSZeroRect | 343 initWithFrame:NSZeroRect |
344 delegate:autofillDialog->delegate()]); | 344 delegate:autofillDialog->delegate()]); |
345 | 345 |
346 loadingShieldTextField_.reset( | 346 loadingShieldTextField_.reset( |
347 [[NSTextField alloc] initWithFrame:NSZeroRect]); | 347 [[NSTextField alloc] initWithFrame:NSZeroRect]); |
348 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 348 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
349 NSFont* loadingFont = rb.GetFont( | 349 NSFont* loadingFont = rb.GetFont( |
350 ui::ResourceBundle::BaseFont).DeriveFont(15).GetNativeFont(); | 350 ui::ResourceBundle::BaseFont).DeriveFont(15).GetNativeFont(); |
351 [loadingShieldTextField_ setFont:loadingFont]; | 351 [loadingShieldTextField_ setFont:loadingFont]; |
352 [loadingShieldTextField_ setEditable:NO]; | 352 [loadingShieldTextField_ setEditable:NO]; |
353 [loadingShieldTextField_ setBordered:NO]; | 353 [loadingShieldTextField_ setBordered:NO]; |
354 [loadingShieldTextField_ setDrawsBackground:NO]; | 354 [loadingShieldTextField_ setDrawsBackground:NO]; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 461 |
462 [titleTextField_ setStringValue: | 462 [titleTextField_ setStringValue: |
463 base::SysUTF16ToNSString(autofillDialog_->delegate()->DialogTitle())]; | 463 base::SysUTF16ToNSString(autofillDialog_->delegate()->DialogTitle())]; |
464 [titleTextField_ sizeToFit]; | 464 [titleTextField_ sizeToFit]; |
465 | 465 |
466 NSRect headerRect, mainRect, titleRect, dummyRect; | 466 NSRect headerRect, mainRect, titleRect, dummyRect; |
467 NSDivideRect(clientRect, &headerRect, &mainRect, | 467 NSDivideRect(clientRect, &headerRect, &mainRect, |
468 kAccountChooserHeight, NSMinYEdge); | 468 kAccountChooserHeight, NSMinYEdge); |
469 NSDivideRect(mainRect, &dummyRect, &mainRect, | 469 NSDivideRect(mainRect, &dummyRect, &mainRect, |
470 autofill::kDetailVerticalPadding, NSMinYEdge); | 470 autofill::kDetailVerticalPadding, NSMinYEdge); |
471 headerRect = NSInsetRect( | 471 headerRect = NSInsetRect(headerRect, chrome_style::kHorizontalPadding, 0); |
472 headerRect, chrome_style::kHorizontalPadding, 0); | |
473 NSDivideRect(headerRect, &titleRect, &headerRect, | 472 NSDivideRect(headerRect, &titleRect, &headerRect, |
474 NSWidth([titleTextField_ frame]), NSMinXEdge); | 473 NSWidth([titleTextField_ frame]), NSMinXEdge); |
475 | 474 |
476 // Align baseline of title with bottom of accountChooser. | 475 // Align baseline of title with bottom of accountChooser. |
477 base::scoped_nsobject<NSLayoutManager> layout_manager( | 476 base::scoped_nsobject<NSLayoutManager> layout_manager( |
478 [[NSLayoutManager alloc] init]); | 477 [[NSLayoutManager alloc] init]); |
479 NSFont* titleFont = [titleTextField_ font]; | 478 NSFont* titleFont = [titleTextField_ font]; |
480 titleRect.origin.y += NSHeight(titleRect) - | 479 titleRect.origin.y += NSHeight(titleRect) - |
481 [layout_manager defaultBaselineOffsetForFont:titleFont]; | 480 [layout_manager defaultBaselineOffsetForFont:titleFont]; |
482 [titleTextField_ setFrame:titleRect]; | 481 [titleTextField_ setFrame:titleRect]; |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
661 | 660 |
662 - (content::WebContents*)getSignInWebContents { | 661 - (content::WebContents*)getSignInWebContents { |
663 return [signInContainer_ webContents]; | 662 return [signInContainer_ webContents]; |
664 } | 663 } |
665 | 664 |
666 - (BOOL)IsShowingOverlay { | 665 - (BOOL)IsShowingOverlay { |
667 return ![[overlayController_ view] isHidden]; | 666 return ![[overlayController_ view] isHidden]; |
668 } | 667 } |
669 | 668 |
670 @end | 669 @end |
OLD | NEW |