OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_sync_promo_controller.h" |
6 | 6 |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #include "chrome/browser/signin/signin_promo.h" | 8 #include "chrome/browser/signin/signin_promo.h" |
9 #include "chrome/browser/ui/chrome_pages.h" | 9 #include "chrome/browser/ui/chrome_pages.h" |
10 #include "chrome/browser/ui/chrome_style.h" | 10 #include "chrome/browser/ui/chrome_style.h" |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
74 [promoView setBorderWidth:kBorderWidth]; | 74 [promoView setBorderWidth:kBorderWidth]; |
75 [promoView setBorderColor:gfx::SkColorToDeviceNSColor(kBorderColor)]; | 75 [promoView setBorderColor:gfx::SkColorToDeviceNSColor(kBorderColor)]; |
76 | 76 |
77 // Add the sync promo text. | 77 // Add the sync promo text. |
78 size_t offset; | 78 size_t offset; |
79 const base::string16 linkText = l10n_util::GetStringUTF16( | 79 const base::string16 linkText = l10n_util::GetStringUTF16( |
80 IDS_BOOKMARK_SYNC_PROMO_LINK); | 80 IDS_BOOKMARK_SYNC_PROMO_LINK); |
81 const base::string16 promoText = l10n_util::GetStringFUTF16( | 81 const base::string16 promoText = l10n_util::GetStringFUTF16( |
82 IDS_BOOKMARK_SYNC_PROMO_MESSAGE, | 82 IDS_BOOKMARK_SYNC_PROMO_MESSAGE, |
83 linkText, &offset); | 83 linkText, &offset); |
84 const base::string16 promoTextWithoutLink = | 84 NSString* nsPromoText = SysUTF16ToNSString(promoText); |
85 promoText.substr(0, offset) + | 85 NSString* nsLinkText = SysUTF16ToNSString(linkText); |
Alexei Svitkine (slow)
2015/01/28 14:55:03
Use GetNSStringWithFixup instead of first getting
shrike
2015/01/28 17:35:04
That's a handy function, but the promoText = l10n
Alexei Svitkine (slow)
2015/01/28 17:36:58
Actually, I think the *Fixup variants aren't neede
| |
86 promoText.substr(offset + linkText.size()); | |
87 | |
88 NSFont* font = [NSFont labelFontOfSize:kFontSize]; | 86 NSFont* font = [NSFont labelFontOfSize:kFontSize]; |
89 NSColor* linkColor = gfx::SkColorToCalibratedNSColor( | 87 NSColor* linkColor = gfx::SkColorToCalibratedNSColor( |
90 chrome_style::GetLinkColor()); | 88 chrome_style::GetLinkColor()); |
91 | 89 |
92 textView_.reset([[HyperlinkTextView alloc] init]); | 90 textView_.reset([[HyperlinkTextView alloc] init]); |
93 [textView_ setMessageAndLink:base::SysUTF16ToNSString(promoTextWithoutLink) | 91 [textView_ setMessage:nsPromoText |
94 withLink:base::SysUTF16ToNSString(linkText) | 92 withFont:font |
95 atOffset:offset | 93 messageColor:gfx::SkColorToDeviceNSColor(kTextColor)]; |
96 font:font | 94 [textView_ addLinkRange:NSMakeRange(offset, [nsLinkText length]) |
97 messageColor:gfx::SkColorToDeviceNSColor(kTextColor) | 95 withName:@"" |
98 linkColor:linkColor]; | 96 linkColor:linkColor]; |
99 [textView_ setRefusesFirstResponder:YES]; | 97 [textView_ setRefusesFirstResponder:YES]; |
100 [[textView_ textContainer] setLineFragmentPadding:0.0]; | 98 [[textView_ textContainer] setLineFragmentPadding:0.0]; |
101 RemoveUnderlining(textView_, offset, linkText.size()); | 99 RemoveUnderlining(textView_, offset, linkText.size()); |
102 [textView_ setDelegate:self]; | 100 [textView_ setDelegate:self]; |
103 | 101 |
104 [promoView setContentView:textView_]; | 102 [promoView setContentView:textView_]; |
105 | 103 |
106 [self setView:promoView]; | 104 [self setView:promoView]; |
107 } | 105 } |
108 | 106 |
109 - (BOOL)textView:(NSTextView *)textView | 107 - (BOOL)textView:(NSTextView *)textView |
110 clickedOnLink:(id)link | 108 clickedOnLink:(id)link |
111 atIndex:(NSUInteger)charIndex { | 109 atIndex:(NSUInteger)charIndex { |
112 chrome::ShowBrowserSignin(browser_, signin_metrics::SOURCE_BOOKMARK_BUBBLE); | 110 chrome::ShowBrowserSignin(browser_, signin_metrics::SOURCE_BOOKMARK_BUBBLE); |
113 return YES; | 111 return YES; |
114 } | 112 } |
115 | 113 |
116 @end | 114 @end |
OLD | NEW |