| Index: ui/shell_dialogs/select_file_dialog_mac.mm
|
| diff --git a/ui/shell_dialogs/select_file_dialog_mac.mm b/ui/shell_dialogs/select_file_dialog_mac.mm
|
| index 1ac812236305e9eb72ef14efe0f4069354f70c1e..4c2d34526bfcf0b49e53b03199476a2c64169b56 100644
|
| --- a/ui/shell_dialogs/select_file_dialog_mac.mm
|
| +++ b/ui/shell_dialogs/select_file_dialog_mac.mm
|
| @@ -15,6 +15,7 @@
|
| #include "base/mac/bundle_locations.h"
|
| #include "base/mac/foundation_util.h"
|
| #include "base/mac/scoped_cftyperef.h"
|
| +#import "base/mac/sdk_forward_declarations.h"
|
| #include "base/strings/sys_string_conversions.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "base/threading/thread_restrictions.h"
|
| @@ -24,6 +25,8 @@
|
|
|
| namespace {
|
|
|
| +const int kAccessoryViewHorizontalMargin = 20;
|
| +const int kAccessoryViewVerticalMargin = 20;
|
| const int kFileTypePopupTag = 1234;
|
|
|
| CFStringRef CreateUTIFromExtension(const base::FilePath::StringType& ext) {
|
| @@ -265,6 +268,33 @@ SelectFileDialogImpl::~SelectFileDialogImpl() {
|
| }
|
|
|
| // static
|
| +NSView* SelectFileDialogImpl::CreateAccessoryView() {
|
| + base::scoped_nsobject<NSTextField> textfield([[NSTextField alloc] init]);
|
| + [textfield
|
| + setStringValue:l10n_util::GetNSString(IDS_SAVE_PAGE_FILE_FORMAT_PROMPT)];
|
| + [textfield setDrawsBackground:NO];
|
| + [textfield setEditable:NO];
|
| + [textfield setSelectable:NO];
|
| + [textfield setBezeled:NO];
|
| + [textfield setFont:[NSFont systemFontOfSize:0]];
|
| + [textfield setTranslatesAutoresizingMaskIntoConstraints:NO];
|
| +
|
| + base::scoped_nsobject<NSPopUpButton> popup([[NSPopUpButton alloc] init]);
|
| + [popup setTag:kFileTypePopupTag];
|
| + [popup setAlignment:NSNaturalTextAlignment];
|
| + [popup setTranslatesAutoresizingMaskIntoConstraints:NO];
|
| +
|
| + NSStackView* accessory_view =
|
| + [NSStackView stackViewWithViews:@[ textfield, popup ]];
|
| + [accessory_view
|
| + setEdgeInsets:NSEdgeInsetsMake(kAccessoryViewVerticalMargin,
|
| + kAccessoryViewHorizontalMargin,
|
| + kAccessoryViewVerticalMargin,
|
| + kAccessoryViewHorizontalMargin)];
|
| + return accessory_view;
|
| +}
|
| +
|
| +// static
|
| base::scoped_nsobject<ExtensionDropdownHandler>
|
| SelectFileDialogImpl::SetAccessoryView(
|
| NSSavePanel* dialog,
|
| @@ -272,11 +302,8 @@ SelectFileDialogImpl::SetAccessoryView(
|
| int file_type_index,
|
| const base::FilePath::StringType& default_extension) {
|
| DCHECK(file_types);
|
| - NSView* accessory_view = ui::GetViewFromNib(@"SaveAccessoryView");
|
| - if (!accessory_view)
|
| - return base::scoped_nsobject<ExtensionDropdownHandler>();
|
| - [dialog setAccessoryView:accessory_view];
|
|
|
| + NSView* accessory_view = CreateAccessoryView();
|
| NSPopUpButton* popup = [accessory_view viewWithTag:kFileTypePopupTag];
|
| DCHECK(popup);
|
|
|
| @@ -355,6 +382,10 @@ SelectFileDialogImpl::SetAccessoryView(
|
| [handler popupAction:popup];
|
| }
|
|
|
| + // This should not have been needed but is required for correct layout on OSX
|
| + // 10.9.
|
| + [accessory_view layoutSubtreeIfNeeded];
|
| + [dialog setAccessoryView:accessory_view];
|
| return handler;
|
| }
|
|
|
|
|