| 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 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 // Updates the window size and position. | 104 // Updates the window size and position. |
| 105 void SetWindowSize(NSWindow* window, NSSize size) { | 105 void SetWindowSize(NSWindow* window, NSSize size) { |
| 106 NSRect frame = [window frame]; | 106 NSRect frame = [window frame]; |
| 107 frame.origin.x += frame.size.width - size.width; | 107 frame.origin.x += frame.size.width - size.width; |
| 108 frame.origin.y += frame.size.height - size.height; | 108 frame.origin.y += frame.size.height - size.height; |
| 109 frame.size = size; | 109 frame.size = size; |
| 110 [window setFrame:frame display:YES]; | 110 [window setFrame:frame display:YES]; |
| 111 } | 111 } |
| 112 | 112 |
| 113 NSString* ElideEmail(const std::string& email, CGFloat width) { | 113 NSString* ElideEmail(const std::string& email, CGFloat width) { |
| 114 base::string16 elidedEmail = gfx::ElideEmail( | 114 const base::string16 elidedEmail = gfx::ElideText( |
| 115 base::UTF8ToUTF16(email), | 115 base::UTF8ToUTF16(email), gfx::FontList(), width, gfx::ELIDE_EMAIL); |
| 116 ui::ResourceBundle::GetSharedInstance().GetFontList( | |
| 117 ui::ResourceBundle::BaseFont), | |
| 118 width); | |
| 119 return base::SysUTF16ToNSString(elidedEmail); | 116 return base::SysUTF16ToNSString(elidedEmail); |
| 120 } | 117 } |
| 121 | 118 |
| 122 // Builds a label with the given |title| anchored at |frame_origin|. Sets the | 119 // Builds a label with the given |title| anchored at |frame_origin|. Sets the |
| 123 // text color and background color to the given colors if not null. | 120 // text color and background color to the given colors if not null. |
| 124 NSTextField* BuildLabel(NSString* title, | 121 NSTextField* BuildLabel(NSString* title, |
| 125 NSPoint frame_origin, | 122 NSPoint frame_origin, |
| 126 NSColor* background_color, | 123 NSColor* background_color, |
| 127 NSColor* text_color) { | 124 NSColor* text_color) { |
| 128 base::scoped_nsobject<NSTextField> label( | 125 base::scoped_nsobject<NSTextField> label( |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1345 rect.size.height = kBlueButtonHeight; | 1342 rect.size.height = kBlueButtonHeight; |
| 1346 link = [[BlueLabelButton alloc] initWithFrame:rect]; | 1343 link = [[BlueLabelButton alloc] initWithFrame:rect]; |
| 1347 | 1344 |
| 1348 // Manually elide the button text so that the contents fit inside the bubble | 1345 // Manually elide the button text so that the contents fit inside the bubble |
| 1349 // This is needed because the BlueLabelButton cell resets the style on | 1346 // This is needed because the BlueLabelButton cell resets the style on |
| 1350 // every call to -cellSize, which prevents setting a custom lineBreakMode. | 1347 // every call to -cellSize, which prevents setting a custom lineBreakMode. |
| 1351 NSString* elidedButtonText = base::SysUTF16ToNSString(gfx::ElideText( | 1348 NSString* elidedButtonText = base::SysUTF16ToNSString(gfx::ElideText( |
| 1352 l10n_util::GetStringFUTF16( | 1349 l10n_util::GetStringFUTF16( |
| 1353 IDS_SYNC_START_SYNC_BUTTON_LABEL, | 1350 IDS_SYNC_START_SYNC_BUTTON_LABEL, |
| 1354 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)), | 1351 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME)), |
| 1355 ui::ResourceBundle::GetSharedInstance().GetFontList( | 1352 gfx::FontList(), rect.size.width, gfx::ELIDE_TAIL)); |
| 1356 ui::ResourceBundle::BaseFont), | |
| 1357 rect.size.width, | |
| 1358 gfx::ELIDE_AT_END)); | |
| 1359 | 1353 |
| 1360 [link setTitle:elidedButtonText]; | 1354 [link setTitle:elidedButtonText]; |
| 1361 [link setTarget:self]; | 1355 [link setTarget:self]; |
| 1362 [link setAction:switches::IsNewProfileManagement() ? | 1356 [link setAction:switches::IsNewProfileManagement() ? |
| 1363 @selector(showInlineSigninPage:) : @selector(showTabbedSigninPage:)]; | 1357 @selector(showInlineSigninPage:) : @selector(showTabbedSigninPage:)]; |
| 1364 } | 1358 } |
| 1365 | 1359 |
| 1366 [container addSubview:link]; | 1360 [container addSubview:link]; |
| 1367 [container setFrameSize:rect.size]; | 1361 [container setFrameSize:rect.size]; |
| 1368 return container.autorelease(); | 1362 return container.autorelease(); |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 base::scoped_nsobject<NSView> container([[BackgroundColorView alloc] | 1469 base::scoped_nsobject<NSView> container([[BackgroundColorView alloc] |
| 1476 initWithFrame:rect | 1470 initWithFrame:rect |
| 1477 withColor:backgroundColor]); | 1471 withColor:backgroundColor]); |
| 1478 | 1472 |
| 1479 // Manually elide the button text so that the contents fit inside the bubble. | 1473 // Manually elide the button text so that the contents fit inside the bubble. |
| 1480 // This is needed because the BlueLabelButton cell resets the style on | 1474 // This is needed because the BlueLabelButton cell resets the style on |
| 1481 // every call to -cellSize, which prevents setting a custom lineBreakMode. | 1475 // every call to -cellSize, which prevents setting a custom lineBreakMode. |
| 1482 NSString* elidedButtonText = base::SysUTF16ToNSString(gfx::ElideText( | 1476 NSString* elidedButtonText = base::SysUTF16ToNSString(gfx::ElideText( |
| 1483 l10n_util::GetStringFUTF16( | 1477 l10n_util::GetStringFUTF16( |
| 1484 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, item.name), | 1478 IDS_PROFILES_PROFILE_ADD_ACCOUNT_BUTTON, item.name), |
| 1485 ui::ResourceBundle::GetSharedInstance().GetFontList( | 1479 gfx::FontList(), rect.size.width, gfx::ELIDE_TAIL)); |
| 1486 ui::ResourceBundle::BaseFont), | |
| 1487 rect.size.width, | |
| 1488 gfx::ELIDE_AT_END)); | |
| 1489 | 1480 |
| 1490 NSButton* addAccountsButton = | 1481 NSButton* addAccountsButton = |
| 1491 [self linkButtonWithTitle:elidedButtonText | 1482 [self linkButtonWithTitle:elidedButtonText |
| 1492 frameOrigin:NSMakePoint( | 1483 frameOrigin:NSMakePoint( |
| 1493 kHorizontalSpacing, kSmallVerticalSpacing) | 1484 kHorizontalSpacing, kSmallVerticalSpacing) |
| 1494 action:@selector(addAccount:)]; | 1485 action:@selector(addAccount:)]; |
| 1495 [container addSubview:addAccountsButton]; | 1486 [container addSubview:addAccountsButton]; |
| 1496 | 1487 |
| 1497 NSView* accountEmails = [self createAccountsListWithRect:NSMakeRect( | 1488 NSView* accountEmails = [self createAccountsListWithRect:NSMakeRect( |
| 1498 0, kAccountButtonHeight, rect.size.width, kAccountButtonHeight)]; | 1489 0, kAccountButtonHeight, rect.size.width, kAccountButtonHeight)]; |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 [button addSubview:deleteButton]; | 1782 [button addSubview:deleteButton]; |
| 1792 return button.autorelease(); | 1783 return button.autorelease(); |
| 1793 } | 1784 } |
| 1794 | 1785 |
| 1795 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { | 1786 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { |
| 1796 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); | 1787 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); |
| 1797 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; | 1788 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; |
| 1798 } | 1789 } |
| 1799 | 1790 |
| 1800 @end | 1791 @end |
| OLD | NEW |