Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: chrome/browser/ui/cocoa/passwords/pending_password_view_controller.mm

Issue 1610653002: Integrate the account chooser dialog on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include <algorithm> 5 #include <algorithm>
6 6
7 #import "chrome/browser/ui/cocoa/passwords/pending_password_view_controller.h" 7 #import "chrome/browser/ui/cocoa/passwords/pending_password_view_controller.h"
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // password row, and the buttons row on one line each, but not smaller than 83 // password row, and the buttons row on one line each, but not smaller than
84 // kDesiredBubbleWidth. 84 // kDesiredBubbleWidth.
85 85
86 // Create the elements and add them to the view. 86 // Create the elements and add them to the view.
87 87
88 // Close button. 88 // Close button.
89 closeButton_ = [self newCloseButton]; 89 closeButton_ = [self newCloseButton];
90 [view addSubview:closeButton_]; 90 [view addSubview:closeButton_];
91 91
92 // Title. 92 // Title.
93 base::scoped_nsobject<HyperlinkTextView> titleView( 93 HyperlinkTextView* titleView = TitleLabelWithLink(
94 [[HyperlinkTextView alloc] initWithFrame:NSZeroRect]); 94 model_->title(), model_->title_brand_link_range(), self);
95 NSColor* textColor = [NSColor blackColor];
96 NSFont* font = ResourceBundle::GetSharedInstance()
97 .GetFontList(ResourceBundle::SmallFont)
98 .GetPrimaryFont()
99 .GetNativeFont();
100 [titleView setMessage:base::SysUTF16ToNSString(model_->title())
101 withFont:font
102 messageColor:textColor];
103 NSRange titleBrandLinkRange = model_->title_brand_link_range().ToNSRange();
104 if (titleBrandLinkRange.length) {
105 NSColor* linkColor =
106 skia::SkColorToCalibratedNSColor(chrome_style::GetLinkColor());
107 [titleView addLinkRange:titleBrandLinkRange
108 withURL:nil
109 linkColor:linkColor];
110 [titleView.get() setDelegate:self];
111
112 // Create the link with no underlining.
113 [titleView setLinkTextAttributes:nil];
114 NSTextStorage* text = [titleView textStorage];
115 [text addAttribute:NSUnderlineStyleAttributeName
116 value:@(NSUnderlineStyleNone)
117 range:titleBrandLinkRange];
118 } else {
119 // TODO(vasilii): remove if crbug.com/515189 is fixed.
120 [titleView setRefusesFirstResponder:YES];
121 }
122 95
123 // Force the text to wrap to fit in the bubble size. 96 // Force the text to wrap to fit in the bubble size.
124 int titleRightPadding = 97 int titleRightPadding =
125 2 * chrome_style::kCloseButtonPadding + NSWidth([closeButton_ frame]); 98 2 * chrome_style::kCloseButtonPadding + NSWidth([closeButton_ frame]);
126 int titleWidth = kDesiredBubbleWidth - kFramePadding - titleRightPadding; 99 int titleWidth = kDesiredBubbleWidth - kFramePadding - titleRightPadding;
127 [titleView setVerticallyResizable:YES]; 100 [titleView setVerticallyResizable:YES];
128 [titleView setFrameSize:NSMakeSize(titleWidth, MAXFLOAT)]; 101 [titleView setFrameSize:NSMakeSize(titleWidth, MAXFLOAT)];
129 // Set the same text inset as in |passwordRow|. 102 // Set the same text inset as in |passwordRow|.
130 [[titleView textContainer] setLineFragmentPadding:kTitleTextInset]; 103 [[titleView textContainer] setLineFragmentPadding:kTitleTextInset];
131 [titleView sizeToFit]; 104 [titleView sizeToFit];
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 182
210 @end 183 @end
211 184
212 @implementation PendingPasswordViewController (Testing) 185 @implementation PendingPasswordViewController (Testing)
213 186
214 - (NSButton*)closeButton { 187 - (NSButton*)closeButton {
215 return closeButton_.get(); 188 return closeButton_.get();
216 } 189 }
217 190
218 @end 191 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698