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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 width - (2 * chrome_style::kHorizontalPadding) - (2 * kBorderWidth); | 61 width - (2 * chrome_style::kHorizontalPadding) - (2 * kBorderWidth); |
62 NSRect frame = [[textView_ textStorage] | 62 NSRect frame = [[textView_ textStorage] |
63 boundingRectWithSize:NSMakeSize(availableWidth, 0.0) | 63 boundingRectWithSize:NSMakeSize(availableWidth, 0.0) |
64 options:NSStringDrawingUsesLineFragmentOrigin]; | 64 options:NSStringDrawingUsesLineFragmentOrigin]; |
65 return frame.size.height + (2 * kVerticalPadding) + (2 * kBorderWidth); | 65 return frame.size.height + (2 * kVerticalPadding) + (2 * kBorderWidth); |
66 } | 66 } |
67 | 67 |
68 - (void)loadView { | 68 - (void)loadView { |
69 NSBox* promoView = [[[NSBox alloc] init] autorelease]; | 69 NSBox* promoView = [[[NSBox alloc] init] autorelease]; |
70 [promoView setBoxType:NSBoxCustom]; | 70 [promoView setBoxType:NSBoxCustom]; |
71 [promoView setFillColor:gfx::SkColorToDeviceNSColor(kBackgroundColor)]; | 71 [promoView setFillColor:skia::SkColorToDeviceNSColor(kBackgroundColor)]; |
72 [promoView setContentViewMargins:NSMakeSize(chrome_style::kHorizontalPadding, | 72 [promoView setContentViewMargins:NSMakeSize(chrome_style::kHorizontalPadding, |
73 kVerticalPadding)]; | 73 kVerticalPadding)]; |
74 [promoView setBorderType:NSLineBorder]; | 74 [promoView setBorderType:NSLineBorder]; |
75 [promoView setBorderWidth:kBorderWidth]; | 75 [promoView setBorderWidth:kBorderWidth]; |
76 [promoView setBorderColor:gfx::SkColorToDeviceNSColor(kBorderColor)]; | 76 [promoView setBorderColor:skia::SkColorToDeviceNSColor(kBorderColor)]; |
77 | 77 |
78 // Add the sync promo text. | 78 // Add the sync promo text. |
79 size_t offset; | 79 size_t offset; |
80 const base::string16 linkText = l10n_util::GetStringUTF16( | 80 const base::string16 linkText = l10n_util::GetStringUTF16( |
81 IDS_BOOKMARK_SYNC_PROMO_LINK); | 81 IDS_BOOKMARK_SYNC_PROMO_LINK); |
82 const base::string16 promoText = l10n_util::GetStringFUTF16( | 82 const base::string16 promoText = l10n_util::GetStringFUTF16( |
83 IDS_BOOKMARK_SYNC_PROMO_MESSAGE, | 83 IDS_BOOKMARK_SYNC_PROMO_MESSAGE, |
84 linkText, &offset); | 84 linkText, &offset); |
85 NSString* nsPromoText = SysUTF16ToNSString(promoText); | 85 NSString* nsPromoText = SysUTF16ToNSString(promoText); |
86 NSString* nsLinkText = SysUTF16ToNSString(linkText); | 86 NSString* nsLinkText = SysUTF16ToNSString(linkText); |
87 NSFont* font = [NSFont labelFontOfSize:kFontSize]; | 87 NSFont* font = [NSFont labelFontOfSize:kFontSize]; |
88 NSColor* linkColor = gfx::SkColorToCalibratedNSColor( | 88 NSColor* linkColor = skia::SkColorToCalibratedNSColor( |
89 chrome_style::GetLinkColor()); | 89 chrome_style::GetLinkColor()); |
90 | 90 |
91 textView_.reset([[HyperlinkTextView alloc] init]); | 91 textView_.reset([[HyperlinkTextView alloc] init]); |
92 [textView_ setMessage:nsPromoText | 92 [textView_ setMessage:nsPromoText |
93 withFont:font | 93 withFont:font |
94 messageColor:gfx::SkColorToDeviceNSColor(kTextColor)]; | 94 messageColor:skia::SkColorToDeviceNSColor(kTextColor)]; |
95 [textView_ addLinkRange:NSMakeRange(offset, [nsLinkText length]) | 95 [textView_ addLinkRange:NSMakeRange(offset, [nsLinkText length]) |
96 withURL:@"about:blank" // using a link here is bad ui | 96 withURL:@"about:blank" // using a link here is bad ui |
97 linkColor:linkColor]; | 97 linkColor:linkColor]; |
98 [textView_ setRefusesFirstResponder:YES]; | 98 [textView_ setRefusesFirstResponder:YES]; |
99 [[textView_ textContainer] setLineFragmentPadding:0.0]; | 99 [[textView_ textContainer] setLineFragmentPadding:0.0]; |
100 RemoveUnderlining(textView_, offset, linkText.size()); | 100 RemoveUnderlining(textView_, offset, linkText.size()); |
101 [textView_ setDelegate:self]; | 101 [textView_ setDelegate:self]; |
102 | 102 |
103 [promoView setContentView:textView_]; | 103 [promoView setContentView:textView_]; |
104 | 104 |
105 [self setView:promoView]; | 105 [self setView:promoView]; |
106 } | 106 } |
107 | 107 |
108 - (BOOL)textView:(NSTextView *)textView | 108 - (BOOL)textView:(NSTextView *)textView |
109 clickedOnLink:(id)link | 109 clickedOnLink:(id)link |
110 atIndex:(NSUInteger)charIndex { | 110 atIndex:(NSUInteger)charIndex { |
111 chrome::ShowBrowserSignin( | 111 chrome::ShowBrowserSignin( |
112 browser_, signin_metrics::AccessPoint::ACCESS_POINT_BOOKMARK_BUBBLE); | 112 browser_, signin_metrics::AccessPoint::ACCESS_POINT_BOOKMARK_BUBBLE); |
113 return YES; | 113 return YES; |
114 } | 114 } |
115 | 115 |
116 @end | 116 @end |
OLD | NEW |