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;
const base::string16 promoText = l10n_util::GetStringFUTF16(
IDS_BOOKMARK_SYNC_PROMO_MESSAGE,
linkText, &offset);
const base::string16 promoTextWithoutLink =
promoText.substr(0, offset) +
promoText.substr(offset + linkText.size());
NSString* nsPromoText = SysUTF16ToNSString(promoText);
NSString* nsLinkText = SysUTF16ToNSString(linkText);
NSFont* font = [NSFont labelFontOfSize:kFontSize];
NSColor* linkColor = gfx::SkColorToCalibratedNSColor(
chrome_style::GetLinkColor());
textView_.reset([[HyperlinkTextView alloc] init]);
[textView_ setMessageAndLink:base::SysUTF16ToNSString(promoTextWithoutLink)
withLink:base::SysUTF16ToNSString(linkText)
atOffset:offset
font:font
messageColor:gfx::SkColorToDeviceNSColor(kTextColor)
linkColor:linkColor];
[textView_ setMessage:nsPromoText
withFont:font
messageColor:gfx::SkColorToDeviceNSColor(kTextColor)];
[textView_ addLinkRange:NSMakeRange(offset, [nsLinkText length])
withName:@""
linkColor:linkColor];
[textView_ setRefusesFirstResponder:YES];
[[textView_ textContainer] setLineFragmentPadding:0.0];
RemoveUnderlining(textView_, offset, linkText.size());
......
......@@ -11,6 +11,7 @@
@class BrowserWindowController;
class Browser;
@class GTMUILocalizerAndLayoutTweaker;
@class HyperlinkTextView;
// The ExclusiveAccessBubbleWindowController manages the bubble that informs the
// user of different exclusive access state like fullscreen mode, mouse lock,
......@@ -35,7 +36,7 @@ class Browser;
// text views cannot conveniently be created in IB. The xib file contains
// a text field |exitLabelPlaceholder_| that's replaced by this text view
// |exitLabel_| in -awakeFromNib.
base::scoped_nsobject<NSTextView> exitLabel_;
base::scoped_nsobject<HyperlinkTextView> exitLabel_;
base::scoped_nsobject<NSTimer> hideTimer_;
base::scoped_nsobject<NSAnimation> hideAnimation_;
......
......@@ -214,34 +214,36 @@ const float kHideDuration = 0.7;
[exitLabel_.get() setDelegate:self];
NSString* exitLinkText;
NSString* exitUnlinkedText;
NSString* exitLinkedText;
if (bubbleType_ ==
EXCLUSIVE_ACCESS_BUBBLE_TYPE_FULLSCREEN_MOUSELOCK_EXIT_INSTRUCTION ||
bubbleType_ == EXCLUSIVE_ACCESS_BUBBLE_TYPE_MOUSELOCK_EXIT_INSTRUCTION) {
exitLinkText = @"";
exitUnlinkedText =
exitLinkedText =
[@" " stringByAppendingString:l10n_util::GetNSStringF(
IDS_FULLSCREEN_PRESS_ESC_TO_EXIT,
l10n_util::GetStringUTF16(
IDS_APP_ESC_KEY))];
} else {
exitLinkText = l10n_util::GetNSString(IDS_EXIT_FULLSCREEN_MODE);
exitUnlinkedText =
[@" " stringByAppendingString:l10n_util::GetNSStringF(
IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR,
l10n_util::GetStringUTF16(
IDS_APP_ESC_KEY))];
NSString* messageText = l10n_util::GetNSStringF(
IDS_EXIT_FULLSCREEN_MODE_ACCELERATOR,
l10n_util::GetStringUTF16(IDS_APP_ESC_KEY));
exitLinkedText =
[NSString stringWithFormat:@"%@ %@", exitLinkText, messageText];
}
NSFont* font = [NSFont
systemFontOfSize:[NSFont
systemFontSizeForControlSize:NSRegularControlSize]];
[(HyperlinkTextView*)exitLabel_.get() setMessageAndLink:exitUnlinkedText
withLink:exitLinkText
atOffset:0
font:font
messageColor:[NSColor blackColor]
linkColor:[NSColor blueColor]];
[exitLabel_.get() setMessage:exitLinkedText
withFont:font
messageColor:[NSColor blackColor]];
if ([exitLinkText length] != 0) {
[exitLabel_.get() addLinkRange:NSMakeRange(0, [exitLinkText length])
withName:@""
linkColor:[NSColor blueColor]];
}
[exitLabel_.get() setAlignment:NSRightTextAlignment];
NSRect labelFrame = [exitLabel_ frame];
......
......@@ -20,6 +20,7 @@
#include "ui/base/accelerators/platform_accelerator_cocoa.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
#import "ui/base/cocoa/controls/hyperlink_text_view.h"
using content::SiteInstance;
using content::WebContents;
......@@ -43,7 +44,7 @@ using content::WebContents;
return exitLabelPlaceholder_;
}
- (NSTextView*)exitLabel {
- (HyperlinkTextView*)exitLabel {
return exitLabel_;
}
......
......@@ -444,15 +444,14 @@ class ExtensionLoadedNotificationObserver
IDS_EXTENSION_INSTALLED_SIGNIN_PROMO_LINK));
NSString* message(l10n_util::GetNSStringWithFixup(
IDS_EXTENSION_INSTALLED_SIGNIN_PROMO));
message = [link stringByAppendingString:message];
HyperlinkTextView* view = promo_.get();
[view setMessageAndLink:message
withLink:link
atOffset:0
font:font
messageColor:[NSColor blackColor]
linkColor:gfx::SkColorToCalibratedNSColor(
chrome_style::GetLinkColor())];
[view setMessage:message withFont:font messageColor:[NSColor blackColor]];
[view addLinkRange:NSMakeRange(0, [link length])
withName:@""
linkColor:gfx::SkColorToCalibratedNSColor(
chrome_style::GetLinkColor())];
// 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
......
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