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

Unified Diff: chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm

Issue 1835133002: Add keyboard accessibility to "Get help" link text on chooser UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address rsesek@'s comment Created 4 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm
diff --git a/chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm b/chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm
index 2c472ec62d748e557786bdb1a830d4e7ad76f771..a936f07cbc937f91a038281335a400fc0dc9df50 100644
--- a/chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm
+++ b/chrome/browser/ui/cocoa/website_settings/chooser_bubble_ui_cocoa.mm
@@ -28,7 +28,7 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "skia/ext/skia_utils_mac.h"
#include "ui/base/cocoa/cocoa_base_utils.h"
-#include "ui/base/cocoa/controls/hyperlink_text_view.h"
+#import "ui/base/cocoa/controls/hyperlink_button_cell.h"
#include "ui/base/cocoa/window_size_constants.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -69,7 +69,8 @@ scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
base::scoped_nsobject<NSTableView> tableView_;
base::scoped_nsobject<NSButton> connectButton_;
base::scoped_nsobject<NSButton> cancelButton_;
- base::scoped_nsobject<HyperlinkTextView> message_;
+ base::scoped_nsobject<NSTextField> message_;
+ base::scoped_nsobject<NSButton> getHelpButton_;
bool buttonPressed_;
Browser* browser_; // Weak.
@@ -127,8 +128,11 @@ scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
// Creates the "Cancel" button.
- (base::scoped_nsobject<NSButton>)cancelButton;
-// Creates the help link.
-- (base::scoped_nsobject<HyperlinkTextView>)message;
+// Creates the message.
+- (base::scoped_nsobject<NSTextField>)message;
+
+// Creates the "Get help" button.
+- (base::scoped_nsobject<NSButton>)getHelpButton;
// Called when the "Connect" button is pressed.
- (void)onConnect:(id)sender;
@@ -136,6 +140,9 @@ scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
// Called when the "Cancel" button is pressed.
- (void)onCancel:(id)sender;
+// Called when the "Get help" button is pressed.
+- (void)onGetHelpPressed:(id)sender;
+
@end
@implementation ChooserBubbleUiController
@@ -238,8 +245,12 @@ scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
// Message.
message_ = [self message];
+ CGFloat messageWidth = NSWidth([message_ frame]);
CGFloat messageHeight = NSHeight([message_ frame]);
+ // Get help button.
+ getHelpButton_ = [self getHelpButton];
+
// Separator.
CGFloat separatorOriginX = 0.0f;
CGFloat separatorOriginY = kMarginY + messageHeight + kVerticalPadding;
@@ -313,6 +324,15 @@ scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
[message_ setFrameOrigin:NSMakePoint(messageOriginX, messageOriginY)];
[view addSubview:message_];
+ // Get help button.
+ getHelpButton_ = [self getHelpButton];
+ CGFloat getHelpButtonOriginX =
+ kMarginX + messageWidth - kHorizontalPadding / 2;
+ CGFloat getHelpButtonOriginY = kMarginY;
+ [getHelpButton_
+ setFrameOrigin:NSMakePoint(getHelpButtonOriginX, getHelpButtonOriginY)];
+ [view addSubview:getHelpButton_];
+
bubbleFrame = [[self window] frameRectForContentRect:bubbleFrame];
if ([[self window] isVisible]) {
// Unfortunately, calling -setFrame followed by -setFrameOrigin (called
@@ -330,7 +350,7 @@ scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
[self setAnchorPoint:[self getExpectedAnchorPoint]];
[self showWindow:nil];
[[self window] makeFirstResponder:nil];
- [[self window] setInitialFirstResponder:connectButton_.get()];
+ [[self window] setInitialFirstResponder:tableView_.get()];
}
}
@@ -462,40 +482,32 @@ scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
return [self buttonWithTitle:cancelTitle action:@selector(onCancel:)];
}
-- (base::scoped_nsobject<HyperlinkTextView>)message {
- base::scoped_nsobject<HyperlinkTextView> textView(
- [[HyperlinkTextView alloc] initWithFrame:NSZeroRect]);
-
- base::string16 linkString =
- l10n_util::GetStringUTF16(IDS_CHOOSER_BUBBLE_GET_HELP_LINK_TEXT);
-
- NSString* text =
- l10n_util::GetNSStringF(IDS_CHOOSER_BUBBLE_FOOTNOTE_TEXT, linkString);
- [textView setMessage:text
- withFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]
- messageColor:[NSColor blackColor]];
-
- NSColor* linkColor =
- skia::SkColorToCalibratedNSColor(chrome_style::GetLinkColor());
- [textView
- addLinkRange:NSMakeRange([text length] - linkString.size(),
- linkString.size())
- withURL:base::SysUTF8ToNSString(
- chooserBubbleController_->GetHelpCenterUrl().spec())
- linkColor:linkColor];
-
- // Removes the underlining from the link.
- NSTextStorage* textStorage = [textView textStorage];
- [textStorage addAttribute:NSUnderlineStyleAttributeName
- value:@(NSUnderlineStyleNone)
- range:NSMakeRange(0, [text length])];
-
- [textView setVerticallyResizable:YES];
- [textView
- setFrameSize:NSMakeSize(kChooserBubbleWidth - 2 * kMarginX, MAXFLOAT)];
- [textView sizeToFit];
-
- return textView;
+- (base::scoped_nsobject<NSTextField>)message {
+ base::scoped_nsobject<NSTextField> messageView(
+ [[NSTextField alloc] initWithFrame:NSZeroRect]);
+ [messageView setDrawsBackground:NO];
+ [messageView setBezeled:NO];
+ [messageView setEditable:NO];
+ [messageView setSelectable:NO];
+ [messageView
+ setStringValue:l10n_util::GetNSStringF(IDS_CHOOSER_BUBBLE_FOOTNOTE_TEXT,
+ base::string16())];
+ [messageView setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
+ [messageView sizeToFit];
+ return messageView;
+}
+
+- (base::scoped_nsobject<NSButton>)getHelpButton {
+ base::scoped_nsobject<NSButton> button(
+ [[NSButton alloc] initWithFrame:NSZeroRect]);
+ base::scoped_nsobject<HyperlinkButtonCell> cell([[HyperlinkButtonCell alloc]
+ initTextCell:l10n_util::GetNSString(
+ IDS_CHOOSER_BUBBLE_GET_HELP_LINK_TEXT)]);
+ [button setCell:cell.get()];
+ [button sizeToFit];
+ [button setTarget:self];
+ [button setAction:@selector(onGetHelpPressed:)];
+ return button;
}
+ (CGFloat)matchWidthsOf:(NSView*)viewA andOf:(NSView*)viewB {
@@ -528,6 +540,10 @@ scoped_ptr<BubbleUi> ChooserBubbleController::BuildBubbleUi() {
[self close];
}
+- (void)onGetHelpPressed:(id)sender {
+ chooserBubbleController_->OpenHelpCenterUrl();
+}
+
@end
ChooserBubbleUiCocoa::ChooserBubbleUiCocoa(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698