Index: chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm |
diff --git a/chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm b/chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm |
index 0c9e0f44e77fa4b7c913f092879c5b96e76c5ae9..35bc3de936bed940e9a8ba8d084431f81879ff4c 100644 |
--- a/chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm |
+++ b/chrome/browser/ui/cocoa/browser/profile_chooser_controller.mm |
@@ -27,7 +27,9 @@ |
#include "chrome/browser/ui/browser.h" |
#include "chrome/browser/ui/browser_dialogs.h" |
#include "chrome/browser/ui/browser_window.h" |
+#include "chrome/browser/ui/chrome_pages.h" |
#include "chrome/browser/ui/chrome_style.h" |
+#import "chrome/browser/ui/cocoa/hyperlink_text_view.h" |
#import "chrome/browser/ui/cocoa/info_bubble_view.h" |
#import "chrome/browser/ui/cocoa/info_bubble_window.h" |
#import "chrome/browser/ui/cocoa/user_manager_mac.h" |
@@ -140,6 +142,41 @@ NSTextField* BuildLabel(NSString* title, |
return label.autorelease(); |
} |
+// Builds a fixed-width NSTextView. |
Alexei Svitkine (slow)
2014/04/08 20:37:51
Document params please.
guohui
2014/04/09 13:22:53
Done.
|
+NSTextView* BuildTextView(id<NSTextViewDelegate> delegate, |
Alexei Svitkine (slow)
2014/04/08 20:37:51
This seems to be a much more specific method than
guohui
2014/04/09 13:22:53
Done.
|
+ NSString* message, |
+ NSString* link, |
+ int link_offset, |
+ NSPoint frame_origin, |
+ CGFloat frame_width) { |
+ base::scoped_nsobject<HyperlinkTextView> text_view( |
+ [[HyperlinkTextView alloc] initWithFrame:NSZeroRect]); |
+ NSColor* link_color = gfx::SkColorToCalibratedNSColor( |
+ chrome_style::GetLinkColor()); |
+ [text_view setMessageAndLink:message |
+ withLink:link |
+ atOffset:link_offset |
+ font:[NSFont labelFontOfSize:kTextFontSize] |
+ messageColor:[NSColor blackColor] |
+ linkColor:link_color]; |
+ |
+ // Removes the underlyining from the link. |
Alexei Svitkine (slow)
2014/04/08 20:37:51
Nit: underline
guohui
2014/04/09 13:22:53
Done.
|
+ [text_view setLinkTextAttributes:nil]; |
+ NSTextStorage* text_storage = [text_view textStorage]; |
+ NSRange link_range = NSMakeRange(link_offset, [link length]); |
+ [text_storage addAttribute:NSUnderlineStyleAttributeName |
+ value:[NSNumber numberWithInt:NSUnderlineStyleNone] |
+ range:link_range]; |
+ |
+ NSRect frame = [[text_view attributedString] |
+ boundingRectWithSize:NSMakeSize(frame_width, 0) |
+ options:NSStringDrawingUsesLineFragmentOrigin]; |
+ frame.origin = frame_origin; |
+ [text_view setFrame:frame]; |
+ [text_view setDelegate:delegate]; |
+ return text_view.autorelease(); |
+} |
+ |
// Builds a title card with one back button right aligned and one label center |
// aligned. |
NSView* BuildTitleCard(NSRect frame_rect, |
@@ -1289,18 +1326,29 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
yOffset = NSMaxY([removeAndRelaunchButton frame]) + kVerticalSpacing; |
} |
- // Adds the main text. |
- NSString* contentStr = isPrimaryAccount ? |
- l10n_util::GetNSStringF(IDS_PROFILES_PRIMARY_ACCOUNT_REMOVAL_TEXT, |
- base::UTF8ToUTF16(accountIdToRemove_)) : |
- l10n_util::GetNSString(IDS_PROFILES_ACCOUNT_REMOVAL_TEXT); |
- NSTextField* contentLabel = |
- BuildLabel(contentStr, NSMakePoint(kHorizontalSpacing, yOffset), |
- nil /* background_color */, nil /* text_color */); |
- [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
- [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
- [container addSubview:contentLabel]; |
- yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; |
+ NSView* contentView; |
+ NSPoint contentFrameOrigin = NSMakePoint(kHorizontalSpacing, yOffset); |
+ if (isPrimaryAccount) { |
+ std::vector<size_t> offsets; |
+ NSString* contentStr = l10n_util::GetNSStringF( |
+ IDS_PROFILES_PRIMARY_ACCOUNT_REMOVAL_TEXT, |
+ base::UTF8ToUTF16(accountIdToRemove_), base::string16(), &offsets); |
+ NSString* linkStr = l10n_util::GetNSString(IDS_PROFILES_SETTINGS_LINK); |
+ contentView = BuildTextView(self, contentStr, linkStr, offsets[1], |
+ contentFrameOrigin, availableWidth); |
Alexei Svitkine (slow)
2014/04/08 20:37:51
Nit: Align.
|
+ } else { |
+ NSString* contentStr = isPrimaryAccount ? |
+ l10n_util::GetNSStringF(IDS_PROFILES_PRIMARY_ACCOUNT_REMOVAL_TEXT, |
+ base::UTF8ToUTF16(accountIdToRemove_)) : |
+ l10n_util::GetNSString(IDS_PROFILES_ACCOUNT_REMOVAL_TEXT); |
+ NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, |
+ nil /* background_color */, nil /* text_color */); |
+ [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
+ [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
+ contentView = contentLabel; |
+ } |
+ [container addSubview:contentView]; |
+ yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; |
// Adds the title card. |
NSBox* separator = [self separatorWithFrame: |
@@ -1320,6 +1368,14 @@ class ActiveProfileObserverBridge : public AvatarMenuObserver, |
return container.autorelease(); |
} |
+// Called when clicked on the settings link. |
+- (BOOL)textView:(NSTextView*)textView |
+ clickedOnLink:(id)link |
+ atIndex:(NSUInteger)charIndex { |
+ chrome::ShowSettings(browser_); |
+ return YES; |
+} |
+ |
- (NSButton*)hoverButtonWithRect:(NSRect)rect |
text:(NSString*)text |
imageResourceId:(int)imageResourceId |