Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #import <Carbon/Carbon.h> // kVK_Return. | 6 #import <Carbon/Carbon.h> // kVK_Return. |
| 7 | 7 |
| 8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
| 9 | 9 |
| 10 #include "base/mac/bundle_locations.h" | 10 #include "base/mac/bundle_locations.h" |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 729 base::string16 newProfileName = | 729 base::string16 newProfileName = |
| 730 base::SysNSStringToUTF16([profileNameTextField_ stringValue]); | 730 base::SysNSStringToUTF16([profileNameTextField_ stringValue]); |
| 731 | 731 |
| 732 // Empty profile names are not allowed, and do nothing. | 732 // Empty profile names are not allowed, and do nothing. |
| 733 base::TrimWhitespace(newProfileName, base::TRIM_ALL, &newProfileName); | 733 base::TrimWhitespace(newProfileName, base::TRIM_ALL, &newProfileName); |
| 734 if (!newProfileName.empty()) { | 734 if (!newProfileName.empty()) { |
| 735 profiles::UpdateProfileName(profile_, newProfileName); | 735 profiles::UpdateProfileName(profile_, newProfileName); |
| 736 [controller_ | 736 [controller_ |
| 737 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME]; | 737 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME]; |
| 738 [profileNameTextField_ setHidden:YES]; | 738 [profileNameTextField_ setHidden:YES]; |
| 739 // This needs to be called async as the firstResponder is reset | |
| 740 // at the same time that controlTextDidEndEditing happens. | |
| 741 dispatch_async(dispatch_get_main_queue(), ^{ | |
| 742 [[self window] makeFirstResponder:nil]; | |
| 743 }); | |
| 744 } | 739 } |
| 745 } | 740 } |
| 746 | 741 |
| 747 - (void)showEditableView:(id)sender { | 742 - (void)showEditableView:(id)sender { |
| 748 [profileNameTextField_ setHidden:NO]; | 743 [profileNameTextField_ setHidden:NO]; |
| 749 [[self window] makeFirstResponder:profileNameTextField_]; | 744 [[self window] makeFirstResponder:profileNameTextField_]; |
| 750 } | 745 } |
| 751 | 746 |
| 752 - (BOOL)canBecomeKeyView { | 747 - (BOOL)canBecomeKeyView { |
| 753 return false; | 748 return false; |
| 754 } | 749 } |
| 755 | 750 |
| 756 - (void)controlTextDidEndEditing:(NSNotification*)notification { | 751 - (BOOL)control:(NSControl*)control |
|
groby-ooo-7-16
2015/03/10 23:58:56
What if I _click_ outside of the text field?
| |
| 757 [self saveProfileName]; | 752 textView:(NSTextView*)textView |
| 753 doCommandBySelector:(SEL)commandSelector { | |
| 754 if (commandSelector == @selector(insertTab:) || | |
| 755 commandSelector == @selector(insertNewline:)) { | |
| 756 [self saveProfileName]; | |
| 757 return YES; | |
| 758 } | |
| 759 return NO; | |
| 758 } | 760 } |
| 759 | 761 |
| 760 @end | 762 @end |
| 761 | 763 |
| 762 // A custom button that allows for setting a background color when hovered over. | 764 // A custom button that allows for setting a background color when hovered over. |
| 763 @interface BackgroundColorHoverButton : HoverImageButton { | 765 @interface BackgroundColorHoverButton : HoverImageButton { |
| 764 @private | 766 @private |
| 765 base::scoped_nsobject<NSColor> backgroundColor_; | 767 base::scoped_nsobject<NSColor> backgroundColor_; |
| 766 base::scoped_nsobject<NSColor> hoverColor_; | 768 base::scoped_nsobject<NSColor> hoverColor_; |
| 767 } | 769 } |
| (...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2306 } | 2308 } |
| 2307 | 2309 |
| 2308 - (bool)shouldShowGoIncognito { | 2310 - (bool)shouldShowGoIncognito { |
| 2309 bool incognitoAvailable = | 2311 bool incognitoAvailable = |
| 2310 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2312 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2311 IncognitoModePrefs::DISABLED; | 2313 IncognitoModePrefs::DISABLED; |
| 2312 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2314 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 2313 } | 2315 } |
| 2314 | 2316 |
| 2315 @end | 2317 @end |
| OLD | NEW |