| 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 | 6 |
| 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
| 8 | 8 |
| 9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 [self setBordered:NO]; | 612 [self setBordered:NO]; |
| 613 [self setFont:[NSFont labelFontOfSize:kTitleFontSize]]; | 613 [self setFont:[NSFont labelFontOfSize:kTitleFontSize]]; |
| 614 [self setAlignment:NSCenterTextAlignment]; | 614 [self setAlignment:NSCenterTextAlignment]; |
| 615 [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail]; | 615 [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail]; |
| 616 [self setTitle:profileName]; | 616 [self setTitle:profileName]; |
| 617 } | 617 } |
| 618 return self; | 618 return self; |
| 619 } | 619 } |
| 620 | 620 |
| 621 - (void)saveProfileName:(id)sender { | 621 - (void)saveProfileName:(id)sender { |
| 622 NSString* text = [profileNameTextField_ stringValue]; | 622 base::string16 newProfileName = |
| 623 base::SysNSStringToUTF16([profileNameTextField_ stringValue]); |
| 624 |
| 623 // Empty profile names are not allowed, and are treated as a cancel. | 625 // Empty profile names are not allowed, and are treated as a cancel. |
| 624 if ([text length] > 0) { | 626 base::TrimWhitespace(newProfileName, base::TRIM_ALL, &newProfileName); |
| 625 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text)); | 627 if (!newProfileName.empty()) { |
| 628 profiles::UpdateProfileName(profile_, newProfileName); |
| 626 [controller_ | 629 [controller_ |
| 627 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME]; | 630 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME]; |
| 628 [self setTitle:text]; | 631 [self setTitle:base::SysUTF16ToNSString(newProfileName)]; |
| 632 } else { |
| 633 // Since the text is empty and not allowed, revert it from the textbox. |
| 634 [profileNameTextField_ setStringValue:[self title]]; |
| 629 } | 635 } |
| 630 [profileNameTextField_ setHidden:YES]; | 636 [profileNameTextField_ setHidden:YES]; |
| 631 } | 637 } |
| 632 | 638 |
| 633 - (void)showEditableView:(id)sender { | 639 - (void)showEditableView:(id)sender { |
| 634 [profileNameTextField_ setHidden:NO]; | 640 [profileNameTextField_ setHidden:NO]; |
| 635 [[self window] makeFirstResponder:profileNameTextField_]; | 641 [[self window] makeFirstResponder:profileNameTextField_]; |
| 636 } | 642 } |
| 637 | 643 |
| 638 @end | 644 @end |
| (...skipping 1311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1950 } | 1956 } |
| 1951 | 1957 |
| 1952 - (bool)shouldShowGoIncognito { | 1958 - (bool)shouldShowGoIncognito { |
| 1953 bool incognitoAvailable = | 1959 bool incognitoAvailable = |
| 1954 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1960 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 1955 IncognitoModePrefs::DISABLED; | 1961 IncognitoModePrefs::DISABLED; |
| 1956 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 1962 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 1957 } | 1963 } |
| 1958 | 1964 |
| 1959 @end | 1965 @end |
| OLD | NEW |