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

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

Issue 1665343003: Add message and Help Center link to the chooser UI for Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_text_to_webusb_chooser_ui
Patch Set: add privacy message to the chooser UI for Mac Created 4 years, 10 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 45e2349c2afd93d282a7fc2ded7e62bf0084abd6..db993c4cdaeed7594afd08ac0197e1154015e168 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
@@ -26,6 +26,7 @@
#include "chrome/browser/ui/website_settings/chooser_bubble_delegate.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/native_web_keyboard_event.h"
+#import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTweaker.h"
#include "ui/base/cocoa/window_size_constants.h"
#include "ui/base/l10n/l10n_util_mac.h"
@@ -35,7 +36,7 @@ namespace {
const CGFloat kChooserBubbleWidth = 320.0f;
// Chooser bubble height.
-const CGFloat kChooserBubbleHeight = 220.0f;
+const CGFloat kChooserBubbleHeight = 300.0f;
// Distance between the bubble border and the view that is closest to the
// border.
@@ -46,7 +47,11 @@ const CGFloat kMarginY = 20.0f;
const CGFloat kHorizontalPadding = 10.0f;
const CGFloat kVerticalPadding = 10.0f;
-const CGFloat kTitlePaddingX = 50.0f;
+// Separator alpha value.
+const CGFloat kSeparatorAlphaValue = 0.6f;
+
+// Separator height.
+const CGFloat kSeparatorHeight = 1.0f;
}
Robert Sesek 2016/02/04 23:11:59 Add a missing " // namespace" comment here.
juncai 2016/02/05 00:20:40 Done.
scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
@@ -65,6 +70,8 @@ scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
base::scoped_nsobject<NSTableView> tableView_;
base::scoped_nsobject<NSButton> connectButton_;
base::scoped_nsobject<NSButton> cancelButton_;
+ base::scoped_nsobject<NSBox> separator_;
+ base::scoped_nsobject<NSTextField> privacyMessage_;
bool buttonPressed_;
Browser* browser_; // Weak.
@@ -121,6 +128,12 @@ scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
// Creates the "Cancel" button.
- (base::scoped_nsobject<NSButton>)cancelButton;
+// Creates the separator.
+- (base::scoped_nsobject<NSBox>)separator;
+
+// Creates the privacy message.
+- (base::scoped_nsobject<NSTextField>)privacyMessage;
+
// Called when the "Connect" button is pressed.
- (void)onConnect:(id)sender;
@@ -202,6 +215,8 @@ scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
// | | | |
// | -------------------------------- |
// | [ Connect] [ Cancel ] |
+ // |----------------------------------|
+ // | Privacy message |
// ------------------------------------
// Determine the dimensions of the bubble.
@@ -213,27 +228,32 @@ scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
// Create the views.
// Title.
titleView_ = [self bubbleTitle];
- CGFloat titleOriginX = kMarginX;
CGFloat titleHeight = NSHeight([titleView_ frame]);
- CGFloat titleOriginY = kChooserBubbleHeight - kMarginY - titleHeight;
- [titleView_ setFrameOrigin:NSMakePoint(titleOriginX, titleOriginY)];
- [view addSubview:titleView_];
// Connect button.
connectButton_ = [self connectButton];
- // Cancel button.
- cancelButton_ = [self cancelButton];
CGFloat connectButtonWidth = NSWidth([connectButton_ frame]);
CGFloat connectButtonHeight = NSHeight([connectButton_ frame]);
+
+ // Cancel button.
+ cancelButton_ = [self cancelButton];
CGFloat cancelButtonWidth = NSWidth([cancelButton_ frame]);
+ // Separator.
+ separator_ = [self separator];
+
+ // Privacy message.
+ privacyMessage_ = [self privacyMessage];
+ CGFloat privacyMessageHeight = NSHeight([privacyMessage_ frame]);
+
// ScollView embedding with TableView.
CGFloat scrollViewWidth = kChooserBubbleWidth - 2 * kMarginX;
CGFloat scrollViewHeight = kChooserBubbleHeight - 2 * kMarginY -
- 2 * kVerticalPadding - titleHeight -
- connectButtonHeight;
+ 4 * kVerticalPadding - titleHeight -
+ connectButtonHeight - privacyMessageHeight;
NSRect scrollFrame =
- NSMakeRect(kMarginX, kMarginY + connectButtonHeight + kVerticalPadding,
+ NSMakeRect(kMarginX, kMarginY + privacyMessageHeight +
+ 3 * kVerticalPadding + connectButtonHeight,
scrollViewWidth, scrollViewHeight);
scrollView_.reset([[NSScrollView alloc] initWithFrame:scrollFrame]);
[scrollView_ setBorderType:NSBezelBorder];
@@ -252,26 +272,49 @@ scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
[tableView_ setHeaderView:nil];
[tableView_ setFocusRingType:NSFocusRingTypeNone];
+ // Lay out the views.
+ // Title.
+ CGFloat titleOriginX = kMarginX;
+ CGFloat titleOriginY = kChooserBubbleHeight - kMarginY - titleHeight;
+ [titleView_ setFrameOrigin:NSMakePoint(titleOriginX, titleOriginY)];
+ [view addSubview:titleView_];
+
+ // ScollView.
[scrollView_ setDocumentView:tableView_];
[view addSubview:scrollView_];
- // Set connect button and cancel button to the right place.
+ // Connect button.
CGFloat connectButtonOriginX = kChooserBubbleWidth - kMarginX -
kHorizontalPadding - connectButtonWidth -
cancelButtonWidth;
- CGFloat connectButtonOriginY = kMarginY;
+ CGFloat connectButtonOriginY =
+ kMarginY + privacyMessageHeight + 2 * kVerticalPadding;
[connectButton_
setFrameOrigin:NSMakePoint(connectButtonOriginX, connectButtonOriginY)];
[connectButton_ setEnabled:NO];
[view addSubview:connectButton_];
+ // Cancel button.
CGFloat cancelButtonOriginX =
kChooserBubbleWidth - kMarginX - cancelButtonWidth;
- CGFloat cancelButtonOriginY = kMarginY;
+ CGFloat cancelButtonOriginY = connectButtonOriginY;
[cancelButton_
setFrameOrigin:NSMakePoint(cancelButtonOriginX, cancelButtonOriginY)];
[view addSubview:cancelButton_];
+ // Separator.
+ CGFloat separatorOriginX = 0.0f;
+ CGFloat separatorOriginY = kMarginY + privacyMessageHeight + kVerticalPadding;
+ [separator_ setFrameOrigin:NSMakePoint(separatorOriginX, separatorOriginY)];
+ [view addSubview:separator_];
+
+ // Privacy message.
+ CGFloat privacyMessageOriginX = kMarginX;
+ CGFloat privacyMessageOriginY = kMarginY;
+ [privacyMessage_
+ setFrameOrigin:NSMakePoint(privacyMessageOriginX, privacyMessageOriginY)];
+ [view addSubview:privacyMessage_];
+
bubbleFrame = [[self window] frameRectForContentRect:bubbleFrame];
if ([[self window] isVisible]) {
// Unfortunately, calling -setFrame followed by -setFrameOrigin (called
@@ -392,9 +435,6 @@ scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
[titleView setStringValue:l10n_util::GetNSString(IDS_CHOOSER_BUBBLE_PROMPT)];
[titleView setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
[titleView sizeToFit];
- NSRect titleFrame = [titleView frame];
- [titleView setFrameSize:NSMakeSize(NSWidth(titleFrame) + kTitlePaddingX,
- NSHeight(titleFrame))];
return titleView;
}
@@ -422,6 +462,35 @@ scoped_ptr<BubbleUi> ChooserBubbleDelegate::BuildBubbleUi() {
return [self buttonWithTitle:cancelTitle action:@selector(onCancel:)];
}
+- (base::scoped_nsobject<NSBox>)separator {
Robert Sesek 2016/02/04 23:11:59 Can you use -[BaseBubbleController horizontalSepar
juncai 2016/02/05 00:20:40 Done.
+ base::scoped_nsobject<NSBox> spacer([[NSBox alloc] initWithFrame:NSZeroRect]);
+ [spacer setBoxType:NSBoxSeparator];
+ [spacer setBorderType:NSLineBorder];
+ [spacer setAlphaValue:kSeparatorAlphaValue];
+ [spacer setFrameSize:NSMakeSize(kChooserBubbleWidth, kSeparatorHeight)];
+ return spacer;
+}
+
+- (base::scoped_nsobject<NSTextField>)privacyMessage {
+ base::scoped_nsobject<NSTextField> privacyMessageView(
+ [[NSTextField alloc] initWithFrame:NSZeroRect]);
+ [privacyMessageView setDrawsBackground:NO];
+ [privacyMessageView setBezeled:NO];
+ [privacyMessageView setEditable:NO];
+ [privacyMessageView setSelectable:NO];
+ [privacyMessageView
+ setStringValue:l10n_util::GetNSString(
+ IDS_CHOOSER_BUBBLE_PRIVACY_MESSAGE_TEXT)];
+ [privacyMessageView
+ setFont:[NSFont systemFontOfSize:[NSFont systemFontSize]]];
+ // The height is arbitrary as it will be adjusted later.
+ [privacyMessageView
+ setFrameSize:NSMakeSize(kChooserBubbleWidth - 2 * kMarginX, 0.0f)];
+ [GTMUILocalizerAndLayoutTweaker
+ sizeToFitFixedWidthTextField:privacyMessageView];
+ return privacyMessageView;
+}
+
+ (CGFloat)matchWidthsOf:(NSView*)viewA andOf:(NSView*)viewB {
NSRect frameA = [viewA frame];
NSRect frameB = [viewB frame];
« 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