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

Unified Diff: ui/shell_dialogs/select_file_dialog_mac.mm

Issue 1880313003: Mac File Dialogs: Remove SaveAccessoryView.xib (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « ui/shell_dialogs/select_file_dialog_mac.h ('k') | ui/shell_dialogs/shell_dialogs.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « ui/shell_dialogs/select_file_dialog_mac.h ('k') | ui/shell_dialogs/shell_dialogs.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698