Index: chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_pending_view_controller.mm |
diff --git a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_pending_view_controller.mm b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_pending_view_controller.mm |
index d257120eb54b105cedb5d9532fa1779bc5bb4ced..fbc1157ed349490a7965d748b40dd64db0c89cad 100644 |
--- a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_pending_view_controller.mm |
+++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_pending_view_controller.mm |
@@ -9,10 +9,13 @@ |
#include "base/strings/sys_string_conversions.h" |
#import "chrome/browser/ui/cocoa/bubble_combobox.h" |
#import "chrome/browser/ui/cocoa/passwords/manage_password_item_view_controller.h" |
+#include "chrome/browser/ui/chrome_style.h" |
#include "chrome/browser/ui/passwords/manage_passwords_bubble_model.h" |
#include "chrome/browser/ui/passwords/save_password_refusal_combobox_model.h" |
#include "chrome/grit/generated_resources.h" |
+#include "skia/ext/skia_utils_mac.h" |
#import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
+#import "ui/base/cocoa/controls/hyperlink_text_view.h" |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/base/models/combobox_model.h" |
@@ -64,6 +67,14 @@ using namespace password_manager::mac::ui; |
} |
} |
+- (BOOL)textView:(NSTextView*)textView |
+ clickedOnLink:(id)link |
+ atIndex:(NSUInteger)charIndex { |
+ model_->OnBrandLinkClicked(); |
+ [delegate_ viewShouldDismiss]; |
+ return YES; |
+} |
+ |
- (void)loadView { |
base::scoped_nsobject<NSView> view([[NSView alloc] initWithFrame:NSZeroRect]); |
@@ -75,6 +86,11 @@ using namespace password_manager::mac::ui; |
// | [Save] [Nope v] | |
// ----------------------------------- |
+ // The title text depends on whether the user is signed in and therefore syncs |
+ // their password |
+ // Do you want [Google Smart Lock]/Chrome/Chromium to save password |
+ // for this site. |
+ |
// The bubble should be wide enough to fit the title row, the username and |
// password row, and the buttons row on one line each, but not smaller than |
// kDesiredBubbleWidth. |
@@ -82,9 +98,39 @@ using namespace password_manager::mac::ui; |
// Create the elements and add them to the view. |
// Title. |
- NSTextField* titleLabel = |
- [self addTitleLabel:base::SysUTF16ToNSString(model_->title()) |
- toView:view]; |
+ titleView_.reset([[HyperlinkTextView alloc] initWithFrame:NSZeroRect]); |
+ NSColor* textColor = [NSColor blackColor]; |
+ NSFont* font = ResourceBundle::GetSharedInstance() |
+ .GetFontList(ResourceBundle::SmallFont) |
+ .GetPrimaryFont() |
+ .GetNativeFont(); |
+ [titleView_ setMessage:base::SysUTF16ToNSString(model_->title()) |
+ withFont:font |
+ messageColor:textColor]; |
+ NSRange titleBrandLinkRange = model_->title_brand_link_range().ToNSRange(); |
+ if (titleBrandLinkRange.length) { |
+ NSColor* linkColor = |
+ gfx::SkColorToCalibratedNSColor(chrome_style::GetLinkColor()); |
+ [titleView_ addLinkRange:titleBrandLinkRange |
+ withName:@"" |
+ linkColor:linkColor]; |
+ [titleView_.get() setDelegate:self]; |
+ |
+ // Create the link with no underlining. |
+ [titleView_ setLinkTextAttributes:nil]; |
+ NSTextStorage* text = [titleView_ textStorage]; |
+ [text addAttribute:NSUnderlineStyleAttributeName |
+ value:@(NSUnderlineStyleNone) |
+ range:titleBrandLinkRange]; |
+ } |
+ |
+ // Force the text to wrap to fit in the bubble size. |
+ [titleView_ setVerticallyResizable:YES]; |
+ [titleView_ setFrameSize:NSMakeSize(kDesiredBubbleWidth - 2 * kFramePadding, |
+ MAXFLOAT)]; |
+ [titleView_ sizeToFit]; |
+ |
+ [view addSubview:titleView_]; |
// Password item. |
// It should be at least as wide as the box without the padding. |
@@ -125,7 +171,7 @@ using namespace password_manager::mac::ui; |
// Compute the bubble width using the password item. |
const CGFloat contentWidth = |
- kFramePadding + NSWidth([password frame]) + kFramePadding; |
+ kFramePadding + NSWidth([titleView_ frame]) + kFramePadding; |
const CGFloat width = std::max(kDesiredBubbleWidth, contentWidth); |
// Layout the elements, starting at the bottom and moving up. |
@@ -149,10 +195,10 @@ using namespace password_manager::mac::ui; |
// Title goes at the top after some padding. |
curY = NSMaxY([password frame]) + kUnrelatedControlVerticalPadding; |
- [titleLabel setFrameOrigin:NSMakePoint(curX, curY)]; |
+ [titleView_ setFrameOrigin:NSMakePoint(curX, curY)]; |
// Update the bubble size. |
- const CGFloat height = NSMaxY([titleLabel frame]) + kFramePadding; |
+ const CGFloat height = NSMaxY([titleView_ frame]) + kFramePadding; |
[view setFrame:NSMakeRect(0, 0, width, height)]; |
[self setView:view]; |