Commit f9bf8a81 authored by shrike's avatar shrike Committed by Commit bot

Removed calls to [HyperlinkTextView setMessageAndLink:withLink:...]

Replaced occurrences of

[HyperlinkTextView setMessageAndLink:withLink:atOffset:font:
                                               messageColor:linkColor:]

with

[HyperlinkTextView setMessage:withFont:messageColor:] +
[HyperlinkTextView addLinkRange:withName:linkColor]

BUG=253755

TEST=for bookmark_sync_promo_controller.mm: Launch the Chrome browser. Click the
star icon at the right end of the omni box. In the popover window that appears,
confirm that the text at the bottom reads, “Sign in to get your bookmarks
everywhere.” and that the text “Sign in” is a clickable link that takes you to
the Chrome sign-in page.

for extension_installed_bubble_controller.mm: Launch the Chrome browser and type
chrome://extensions in the omnibox. In the page that appears click the Get more
extensions link at the bottom. Locate the Tag Assistant by Google extension and
click it. Click the “+ FREE” button in the upper-right corner of the overlay
window that appears. Click “Add” in the overlay window that appears to confirm
your action. In the bubble window that appears that says Tag Assistant has been
added to Chrome, confirm that the text at the bottom of the bubble window says,
“Sign in to Chrome to get this extension, your history, and other Chrome
settings on all your devices.”, and that “Sign in to Chrome” is a clickable link
that takes you to the Chrome sign-in page.

for exclusive_access_bubble_window_controller.mm: Launch the Chrome browser and
go to http://davidwalsh.name/demo/fullscreen.php . Click the “Launch Fullscreen”
button that appears halfway down the page. If a bubble window appears stating,
“davidwalsh.name is now full screen” click Allow. Confirm that in the next
bubble window that appears, the text at the right says, “Exit full screen (Esc)”
and that the words “Exit full screen” are a clickable link that exits full
screen mode when clicked.

Review URL: https://codereview.chromium.org/865373002

Cr-Commit-Position: refs/heads/master@{#313774}
parent ef8631fa
...@@ -81,21 +81,19 @@ const int kFontSize = 11; ...@@ -81,21 +81,19 @@ const int kFontSize = 11;
const base::string16 promoText = l10n_util::GetStringFUTF16( const base::string16 promoText = l10n_util::GetStringFUTF16(
IDS_BOOKMARK_SYNC_PROMO_MESSAGE, IDS_BOOKMARK_SYNC_PROMO_MESSAGE,
linkText, &offset); linkText, &offset);
const base::string16 promoTextWithoutLink = NSString* nsPromoText = SysUTF16ToNSString(promoText);
promoText.substr(0, offset) + NSString* nsLinkText = SysUTF16ToNSString(linkText);
promoText.substr(offset + linkText.size());
NSFont* font = [NSFont labelFontOfSize:kFontSize]; NSFont* font = [NSFont labelFontOfSize:kFontSize];
NSColor* linkColor = gfx::SkColorToCalibratedNSColor( NSColor* linkColor = gfx::SkColorToCalibratedNSColor(
chrome_style::GetLinkColor()); chrome_style::GetLinkColor());
textView_.reset([[HyperlinkTextView alloc] init]); textView_.reset([[HyperlinkTextView alloc] init]);
[textView_ setMessageAndLink:base::SysUTF16ToNSString(promoTextWithoutLink) [textView_ setMessage:nsPromoText
withLink:base::SysUTF16ToNSString(linkText) withFont:font
atOffset:offset messageColor:gfx::SkColorToDeviceNSColor(kTextColor)];
font:font [textView_ addLinkRange:NSMakeRange(offset, [nsLinkText length])
messageColor:gfx::SkColorToDeviceNSColor(kTextColor) withName:@""
linkColor:linkColor]; linkColor:linkColor];
[textView_ setRefusesFirstResponder:YES]; [textView_ setRefusesFirstResponder:YES];
[[textView_ textContainer] setLineFragmentPadding:0.0]; [[textView_ textContainer] setLineFragmentPadding:0.0];
RemoveUnderlining(textView_, offset, linkText.size()); RemoveUnderlining(textView_, offset, linkText.size());
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
@class BrowserWindowController; @class BrowserWindowController;
class Browser; class Browser;
@class GTMUILocalizerAndLayoutTweaker; @class GTMUILocalizerAndLayoutTweaker;
@class HyperlinkTextView;
// The ExclusiveAccessBubbleWindowController manages the bubble that informs the // The ExclusiveAccessBubbleWindowController manages the bubble that informs the
// user of different exclusive access state like fullscreen mode, mouse lock, // user of different exclusive access state like fullscreen mode, mouse lock,
...@@ -35,7 +36,7 @@ class Browser; ...@@ -35,7 +36,7 @@ class Browser;
// text views cannot conveniently be created in IB. The xib file contains // text views cannot conveniently be created in IB. The xib file contains
// a text field |exitLabelPlaceholder_| that's replaced by this text view // a text field |exitLabelPlaceholder_| that's replaced by this text view
// |exitLabel_| in -awakeFromNib. // |exitLabel_| in -awakeFromNib.
base::scoped_nsobject<NSTextView> exitLabel_; base::scoped_nsobject<HyperlinkTextView> exitLabel_;
base::scoped_nsobject<NSTimer> hideTimer_; base::scoped_nsobject<NSTimer> hideTimer_;
base::scoped_nsobject<NSAnimation> hideAnimation_; base::scoped_nsobject<NSAnimation> hideAnimation_;
......
...@@ -214,34 +214,36 @@ const float kHideDuration = 0.7; ...@@ -214,34 +214,36 @@ const float kHideDuration = 0.7;
[exitLabel_.get() setDelegate:self]; [exitLabel_.get() setDelegate:self];
NSString* exitLinkText; NSString* exitLinkText;
NSString* exitUnlinkedText; NSString* exitLinkedText;
if (bubbleType_ == if (bubbleType_ ==
EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION || EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION ||
bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION) { bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION) {
exitLinkText = @""; exitLinkText = @"";
exitUnlinkedText = exitLinkedText =
[@" " stringByAppendingString:l10n_util::GetNSStringF( [@" " stringByAppendingString:l10n_util::GetNSStringF(
IDS_FULLSCREEN_PRESS_ESC_TO_EXIT, IDS_FULLSCREEN_PRESS_ESC_TO_EXIT,
l10n_util::GetStringUTF16( l10n_util::GetStringUTF16(
IDS_APP_ESC_KEY))]; IDS_APP_ESC_KEY))];
} else { } else {
exitLinkText = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE); exitLinkText = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE);
exitUnlinkedText = NSString* messageText = l10n_util::GetNSStringF(
[@" " stringByAppendingString:l10n_util::GetNSStringF( IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR,
IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR, l10n_util::GetStringUTF16(IDS_APP_ESC_KEY));
l10n_util::GetStringUTF16( exitLinkedText =
IDS_APP_ESC_KEY))]; [NSString stringWithFormat:@"%@ %@", exitLinkText, messageText];
} }
NSFont* font = [NSFont NSFont* font = [NSFont
systemFontOfSize:[NSFont systemFontOfSize:[NSFont
systemFontSizeForControlSize:NSRegularControlSize]]; systemFontSizeForControlSize:NSRegularControlSize]];
[(HyperlinkTextView*)exitLabel_.get() setMessageAndLink:exitUnlinkedText [exitLabel_.get() setMessage:exitLinkedText
withLink:exitLinkText withFont:font
atOffset:0 messageColor:[NSColor blackColor]];
font:font if ([exitLinkText length] != 0) {
messageColor:[NSColor blackColor] [exitLabel_.get() addLinkRange:NSMakeRange(0, [exitLinkText length])
linkColor:[NSColor blueColor]]; withName:@""
linkColor:[NSColor blueColor]];
}
[exitLabel_.get() setAlignment:NSRightTextAlignment]; [exitLabel_.get() setAlignment:NSRightTextAlignment];
NSRect labelFrame = [exitLabel_ frame]; NSRect labelFrame = [exitLabel_ frame];
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "ui/base/accelerators/platform_accelerator_cocoa.h" #include "ui/base/accelerators/platform_accelerator_cocoa.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
#import "ui/base/cocoa/controls/hyperlink_text_view.h"
using content::SiteInstance; using content::SiteInstance;
using content::WebContents; using content::WebContents;
...@@ -43,7 +44,7 @@ using content::WebContents; ...@@ -43,7 +44,7 @@ using content::WebContents;
return exitLabelPlaceholder_; return exitLabelPlaceholder_;
} }
- (NSTextView*)exitLabel { - (HyperlinkTextView*)exitLabel {
return exitLabel_; return exitLabel_;
} }
......
...@@ -444,15 +444,14 @@ class ExtensionLoadedNotificationObserver ...@@ -444,15 +444,14 @@ class ExtensionLoadedNotificationObserver
IDS_EXTENSION_INSTALLED_SIGNIN_PROMO_LINK)); IDS_EXTENSION_INSTALLED_SIGNIN_PROMO_LINK));
NSString* message(l10n_util::GetNSStringWithFixup( NSString* message(l10n_util::GetNSStringWithFixup(
IDS_EXTENSION_INSTALLED_SIGNIN_PROMO)); IDS_EXTENSION_INSTALLED_SIGNIN_PROMO));
message = [link stringByAppendingString:message];
HyperlinkTextView* view = promo_.get(); HyperlinkTextView* view = promo_.get();
[view setMessageAndLink:message [view setMessage:message withFont:font messageColor:[NSColor blackColor]];
withLink:link [view addLinkRange:NSMakeRange(0, [link length])
atOffset:0 withName:@""
font:font linkColor:gfx::SkColorToCalibratedNSColor(
messageColor:[NSColor blackColor] chrome_style::GetLinkColor())];
linkColor:gfx::SkColorToCalibratedNSColor(
chrome_style::GetLinkColor())];
// HACK! The TextView does not report correct height even after you stuff // HACK! The TextView does not report correct height even after you stuff
// it with text (it tells you it is single-line even if it is multiline), so // it with text (it tells you it is single-line even if it is multiline), so
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment