Commit 8a503d82 authored by groby@chromium.org's avatar groby@chromium.org

Factoring out common constants

TBR=thakis@chromium.org
R=gbillock@chromium.org
BUG=none


Review URL: https://chromiumcodereview.appspot.com/10827341

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@151850 0039d316-1c4b-4281-b951-d872f2087c98
parent aba1d2ce
...@@ -35,19 +35,9 @@ using content::Referrer; ...@@ -35,19 +35,9 @@ using content::Referrer;
namespace { namespace {
// The width of the window, in view coordinates. The height will be
// determined by the content.
const CGFloat kWindowWidth = 400;
// The maximum width in view units of a suggested extension's title link.
const int kTitleLinkMaxWidth = 130;
// The width of a service button, in view coordinates. // The width of a service button, in view coordinates.
const CGFloat kServiceButtonWidth = 300; const CGFloat kServiceButtonWidth = 300;
// Padding along on the X-axis between the window frame and content.
const CGFloat kFramePadding = 10;
// Spacing in between sections. // Spacing in between sections.
const CGFloat kVerticalSpacing = 10; const CGFloat kVerticalSpacing = 10;
...@@ -58,8 +48,8 @@ const CGFloat kCloseButtonSize = 16; ...@@ -58,8 +48,8 @@ const CGFloat kCloseButtonSize = 16;
const CGFloat kHeaderFontSize = 14.5; const CGFloat kHeaderFontSize = 14.5;
// Width of the text fields. // Width of the text fields.
const CGFloat kTextWidth = kWindowWidth - const CGFloat kTextWidth = WebIntentPicker::kWindowWidth -
(kFramePadding * 2 + kCloseButtonSize); (WebIntentPicker::kContentAreaBorder * 2.0 + kCloseButtonSize);
// Sets properties on the given |field| to act as title or description labels. // Sets properties on the given |field| to act as title or description labels.
void ConfigureTextFieldAsLabel(NSTextField* field) { void ConfigureTextFieldAsLabel(NSTextField* field) {
...@@ -196,7 +186,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -196,7 +186,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
const CGFloat kAddButtonWidth = 128.0; const CGFloat kAddButtonWidth = 128.0;
// Build the main view // Build the main view
NSRect contentFrame = NSMakeRect(0, 0, kWindowWidth, kMaxHeight); NSRect contentFrame = NSMakeRect(
0, 0, WebIntentPicker::kWindowWidth, kMaxHeight);
if (self = [super initWithFrame:contentFrame]) { if (self = [super initWithFrame:contentFrame]) {
NSMutableArray* subviews = [NSMutableArray array]; NSMutableArray* subviews = [NSMutableArray array];
...@@ -220,7 +211,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -220,7 +211,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
NSRect frame = NSMakeRect(kTitleX, 0, 0, 0); NSRect frame = NSMakeRect(kTitleX, 0, 0, 0);
const string16 elidedTitle = ui::ElideText( const string16 elidedTitle = ui::ElideText(
extension->title, gfx::Font(), kTitleLinkMaxWidth, ui::ELIDE_AT_END); extension->title, gfx::Font(), WebIntentPicker::kTitleLinkMaxWidth,
ui::ELIDE_AT_END);
NSString* string = base::SysUTF16ToNSString(elidedTitle); NSString* string = base::SysUTF16ToNSString(elidedTitle);
cwsButton_.reset(CreateHyperlinkButton(string, frame)); cwsButton_.reset(CreateHyperlinkButton(string, frame));
[cwsButton_ setAlignment:NSLeftTextAlignment]; [cwsButton_ setAlignment:NSLeftTextAlignment];
...@@ -237,7 +229,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -237,7 +229,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
[subviews addObject:cwsButton_]; [subviews addObject:cwsButton_];
// Add the star rating // Add the star rating
CGFloat offsetX = frame.origin.x + NSWidth(frame) + kFramePadding; CGFloat offsetX = frame.origin.x + NSWidth(frame) +
WebIntentPicker::kContentAreaBorder;
ratingsWidget_.reset( ratingsWidget_.reset(
[SingleSuggestionView [SingleSuggestionView
createStarWidgetWithRating:extension->average_rating]); createStarWidgetWithRating:extension->average_rating]);
...@@ -384,7 +377,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -384,7 +377,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
offset += kYMargin; offset += kYMargin;
NSRect contentFrame = NSMakeRect(kFramePadding, 0, kWindowWidth, offset); NSRect contentFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0,
WebIntentPicker::kWindowWidth, offset);
if(self = [super initWithFrame:contentFrame]) if(self = [super initWithFrame:contentFrame])
[self setSubviews: subviews]; [self setSubviews: subviews];
...@@ -454,7 +448,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -454,7 +448,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
- (id)initWithPicker:(WebIntentPickerCocoa*)picker { - (id)initWithPicker:(WebIntentPickerCocoa*)picker {
// Use an arbitrary height because it will reflect the size of the content. // Use an arbitrary height because it will reflect the size of the content.
NSRect contentRect = NSMakeRect(0, 0, kWindowWidth, kVerticalSpacing); NSRect contentRect = NSMakeRect(
0, 0, WebIntentPicker::kWindowWidth, kVerticalSpacing);
// |window| is retained by the ConstrainedWindowMacDelegateCustomSheet when // |window| is retained by the ConstrainedWindowMacDelegateCustomSheet when
// the sheet is initialized. // the sheet is initialized.
...@@ -522,18 +517,21 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -522,18 +517,21 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
// Compute container size to fit all elements, including padding. // Compute container size to fit all elements, including padding.
NSSize containerSize = inlineContentSize; NSSize containerSize = inlineContentSize;
containerSize.height += [webContentView frame].origin.y + kFramePadding; containerSize.height +=
containerSize.width += 2 * kFramePadding; [webContentView frame].origin.y + WebIntentPicker::kContentAreaBorder;
containerSize.width += 2 * WebIntentPicker::kContentAreaBorder;
// Ensure minimum container width. // Ensure minimum container width.
containerSize.width = std::max(kWindowWidth, containerSize.width); containerSize.width =
std::max(CGFloat(WebIntentPicker::kWindowWidth), containerSize.width);
// Resize web contents. // Resize web contents.
[webContentView setFrameSize:inlineContentSize]; [webContentView setFrameSize:inlineContentSize];
// Position close button. // Position close button.
NSRect buttonFrame = [closeButton_ frame]; NSRect buttonFrame = [closeButton_ frame];
buttonFrame.origin.x = containerSize.width - kFramePadding - kCloseButtonSize; buttonFrame.origin.x = containerSize.width -
WebIntentPicker::kContentAreaBorder - kCloseButtonSize;
[closeButton_ setFrame:buttonFrame]; [closeButton_ setFrame:buttonFrame];
[self setContainerSize:containerSize]; [self setContainerSize:containerSize];
...@@ -617,7 +615,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -617,7 +615,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
// Returns the y position delta for the next offset. // Returns the y position delta for the next offset.
- (CGFloat)addCwsButtonToSubviews:(NSMutableArray*)subviews - (CGFloat)addCwsButtonToSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset { atOffset:(CGFloat)offset {
NSRect frame = NSMakeRect(kFramePadding, offset, 100, 10); NSRect frame =
NSMakeRect(WebIntentPicker::kContentAreaBorder, offset, 100, 10);
NSString* string = NSString* string =
l10n_util::GetNSStringWithFixup(IDS_FIND_MORE_INTENT_HANDLER_MESSAGE); l10n_util::GetNSStringWithFixup(IDS_FIND_MORE_INTENT_HANDLER_MESSAGE);
scoped_nsobject<NSButton> button(CreateHyperlinkButton(string,frame)); scoped_nsobject<NSButton> button(CreateHyperlinkButton(string,frame));
...@@ -634,7 +633,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -634,7 +633,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
- (void)addCloseButtonToSubviews:(NSMutableArray*)subviews { - (void)addCloseButtonToSubviews:(NSMutableArray*)subviews {
if (!closeButton_.get()) { if (!closeButton_.get()) {
NSRect buttonFrame = NSMakeRect( NSRect buttonFrame = NSMakeRect(
kFramePadding + kTextWidth, kFramePadding, WebIntentPicker::kContentAreaBorder + kTextWidth,
WebIntentPicker::kContentAreaBorder,
kCloseButtonSize, kCloseButtonSize); kCloseButtonSize, kCloseButtonSize);
closeButton_.reset( closeButton_.reset(
[[HoverCloseButton alloc] initWithFrame:buttonFrame]); [[HoverCloseButton alloc] initWithFrame:buttonFrame]);
...@@ -673,7 +673,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -673,7 +673,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
// Determine a good size for the inline disposition window. // Determine a good size for the inline disposition window.
gfx::Size size = WebIntentPicker::GetMinInlineDispositionSize(); gfx::Size size = WebIntentPicker::GetMinInlineDispositionSize();
NSRect frame = NSMakeRect(kFramePadding, offset, size.width(), size.height()); NSRect frame = NSMakeRect(
WebIntentPicker::kContentAreaBorder, offset, size.width(), size.height());
[contents_->web_contents()->GetNativeView() setFrame:frame]; [contents_->web_contents()->GetNativeView() setFrame:frame];
[subviews addObject:contents_->web_contents()->GetNativeView()]; [subviews addObject:contents_->web_contents()->GetNativeView()];
...@@ -684,7 +685,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -684,7 +685,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
- (CGFloat)addAnotherServiceLinkToSubviews:(NSMutableArray*)subviews - (CGFloat)addAnotherServiceLinkToSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset { atOffset:(CGFloat)offset {
NSRect textFrame = NSMakeRect(kFramePadding, offset, kTextWidth, 1); NSRect textFrame =
NSMakeRect(WebIntentPicker::kContentAreaBorder, offset, kTextWidth, 1);
[inlineDispositionTitleField_ setFrame:textFrame]; [inlineDispositionTitleField_ setFrame:textFrame];
[subviews addObject:inlineDispositionTitleField_]; [subviews addObject:inlineDispositionTitleField_];
[GTMUILocalizerAndLayoutTweaker sizeToFitView:inlineDispositionTitleField_]; [GTMUILocalizerAndLayoutTweaker sizeToFitView:inlineDispositionTitleField_];
...@@ -695,8 +697,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -695,8 +697,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
if (model_->GetInstalledServiceCount() > 1 || if (model_->GetInstalledServiceCount() > 1 ||
model_->GetSuggestedExtensionCount()) { model_->GetSuggestedExtensionCount()) {
NSRect frame = NSMakeRect( NSRect frame = NSMakeRect(
NSMaxX(textFrame) + kFramePadding, offset, NSMaxX(textFrame) + WebIntentPicker::kContentAreaBorder, offset,
kTitleLinkMaxWidth, 1); WebIntentPicker::kTitleLinkMaxWidth, 1);
NSString* string = l10n_util::GetNSStringWithFixup( NSString* string = l10n_util::GetNSStringWithFixup(
IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE); IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE);
scoped_nsobject<NSButton> button(CreateHyperlinkButton(string, frame)); scoped_nsobject<NSButton> button(CreateHyperlinkButton(string, frame));
...@@ -729,7 +731,7 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -729,7 +731,7 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
toSubviews:(NSMutableArray*)subviews toSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset { atOffset:(CGFloat)offset {
// Buttons are displayed centered. // Buttons are displayed centered.
CGFloat offsetX = (kWindowWidth - kServiceButtonWidth) / 2.0; CGFloat offsetX = (WebIntentPicker::kWindowWidth - kServiceButtonWidth) / 2.0;
NSRect frame = NSMakeRect(offsetX, offset, kServiceButtonWidth, 45); NSRect frame = NSMakeRect(offsetX, offset, kServiceButtonWidth, 45);
scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:frame]); scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:frame]);
...@@ -761,7 +763,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -761,7 +763,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
- (NSView*)createEmptyView { - (NSView*)createEmptyView {
NSMutableArray* subviews = [NSMutableArray array]; NSMutableArray* subviews = [NSMutableArray array];
NSRect titleFrame = NSMakeRect(kFramePadding, kFramePadding, NSRect titleFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder,
WebIntentPicker::kContentAreaBorder,
kTextWidth, 1); kTextWidth, 1);
scoped_nsobject<NSTextField> title( scoped_nsobject<NSTextField> title(
[[NSTextField alloc] initWithFrame:titleFrame]); [[NSTextField alloc] initWithFrame:titleFrame]);
...@@ -773,7 +776,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -773,7 +776,8 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:title]; [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:title];
NSRect bodyFrame = titleFrame; NSRect bodyFrame = titleFrame;
bodyFrame.origin.y += NSHeight(titleFrame) + kFramePadding; bodyFrame.origin.y +=
NSHeight(titleFrame) + WebIntentPicker::kContentAreaBorder;
scoped_nsobject<NSTextField> body( scoped_nsobject<NSTextField> body(
[[NSTextField alloc] initWithFrame:bodyFrame]); [[NSTextField alloc] initWithFrame:bodyFrame]);
...@@ -784,8 +788,9 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -784,8 +788,9 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:body]; [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:body];
NSRect viewFrame = NSMakeRect( NSRect viewFrame = NSMakeRect(
0, 0,
kFramePadding, WebIntentPicker::kContentAreaBorder,
std::max(NSWidth(bodyFrame), NSWidth(titleFrame)) + 2 * kFramePadding, std::max(NSWidth(bodyFrame), NSWidth(titleFrame)) +
2 * WebIntentPicker::kContentAreaBorder,
NSHeight(titleFrame) + NSHeight(bodyFrame) + kVerticalSpacing); NSHeight(titleFrame) + NSHeight(bodyFrame) + kVerticalSpacing);
titleFrame.origin.y = NSHeight(viewFrame) - NSHeight(titleFrame); titleFrame.origin.y = NSHeight(viewFrame) - NSHeight(titleFrame);
...@@ -808,7 +813,7 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -808,7 +813,7 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
model_ = model; model_ = model;
// |offset| is the Y position that should be drawn at next. // |offset| is the Y position that should be drawn at next.
CGFloat offset = kFramePadding; CGFloat offset = WebIntentPicker::kContentAreaBorder;
// Keep the new subviews in an array that gets replaced at the end. // Keep the new subviews in an array that gets replaced at the end.
NSMutableArray* subviews = [NSMutableArray array]; NSMutableArray* subviews = [NSMutableArray array];
...@@ -820,7 +825,7 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -820,7 +825,7 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
} else if (contents_) { } else if (contents_) {
offset += [self addAnotherServiceLinkToSubviews:subviews offset += [self addAnotherServiceLinkToSubviews:subviews
atOffset:offset]; atOffset:offset];
offset += kFramePadding; offset += WebIntentPicker::kContentAreaBorder;
offset += [self addInlineHtmlToSubviews:subviews atOffset:offset]; offset += [self addInlineHtmlToSubviews:subviews atOffset:offset];
} else { } else {
offset += [self addHeaderToSubviews:subviews atOffset:offset]; offset += [self addHeaderToSubviews:subviews atOffset:offset];
...@@ -860,13 +865,13 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -860,13 +865,13 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
[flipView_ setSubviews:subviews]; [flipView_ setSubviews:subviews];
// And resize to fit. // And resize to fit.
[self setContainerSize:NSMakeSize(kWindowWidth, offset)]; [self setContainerSize:NSMakeSize(WebIntentPicker::kWindowWidth, offset)];
} }
- (void)setActionString:(NSString*)actionString { - (void)setActionString:(NSString*)actionString {
NSRect textFrame; NSRect textFrame;
if (!actionTextField_.get()) { if (!actionTextField_.get()) {
textFrame = NSMakeRect(kFramePadding, 0, textFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0,
kTextWidth, 1); kTextWidth, 1);
actionTextField_.reset([[NSTextField alloc] initWithFrame:textFrame]); actionTextField_.reset([[NSTextField alloc] initWithFrame:textFrame]);
...@@ -889,7 +894,7 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { ...@@ -889,7 +894,7 @@ NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
base::SysNSStringToUTF8([nsfont fontName]), [nsfont pointSize]); base::SysNSStringToUTF8([nsfont fontName]), [nsfont pointSize]);
NSString* elidedTitle = base::SysUTF16ToNSString(ui::ElideText( NSString* elidedTitle = base::SysUTF16ToNSString(ui::ElideText(
base::SysNSStringToUTF16(title), base::SysNSStringToUTF16(title),
font, kTitleLinkMaxWidth, ui::ELIDE_AT_END)); font, WebIntentPicker::kTitleLinkMaxWidth, ui::ELIDE_AT_END));
[inlineDispositionTitleField_ setStringValue:elidedTitle]; [inlineDispositionTitleField_ setStringValue:elidedTitle];
} }
......
...@@ -48,19 +48,12 @@ using content::WebContents; ...@@ -48,19 +48,12 @@ using content::WebContents;
namespace { namespace {
// The width in pixels of the area between the icon on the left and the close
// button on the right.
const int kMainContentWidth = 400;
// The pixel size of the header label when using a non-native theme. // The pixel size of the header label when using a non-native theme.
const int kHeaderLabelPixelSize = 15; const int kHeaderLabelPixelSize = 15;
// The pixel size of the font of the main content of the dialog. // The pixel size of the font of the main content of the dialog.
const int kMainContentPixelSize = 13; const int kMainContentPixelSize = 13;
// The maximum width in pixels of a suggested extension's title link.
const int kTitleLinkMaxWidth = 130;
// Indices of the extension row widgets. // Indices of the extension row widgets.
enum { enum {
kIconIndex, kIconIndex,
...@@ -416,7 +409,7 @@ void WebIntentPickerGtk::OnPendingAsyncCompleted() { ...@@ -416,7 +409,7 @@ void WebIntentPickerGtk::OnPendingAsyncCompleted() {
// Set the label width to the size of |sub_contents|, which we don't have // Set the label width to the size of |sub_contents|, which we don't have
// access to yet, by calculating the main content width minus borders. // access to yet, by calculating the main content width minus borders.
gtk_util::SetLabelWidth(no_service_label, gtk_util::SetLabelWidth(no_service_label,
kMainContentWidth - 2 * ui::kContentAreaBorder); kWindowWidth - 2 * ui::kContentAreaBorder);
gtk_box_pack_start(GTK_BOX(hbox), no_service_label, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(hbox), no_service_label, TRUE, TRUE, 0);
gtk_widget_show_all(contents_); gtk_widget_show_all(contents_);
...@@ -537,7 +530,7 @@ void WebIntentPickerGtk::InitContents() { ...@@ -537,7 +530,7 @@ void WebIntentPickerGtk::InitContents() {
g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this); g_signal_connect(contents_, "destroy", G_CALLBACK(&OnDestroyThunk), this);
} }
gtk_widget_set_size_request(contents_, kMainContentWidth, -1); gtk_widget_set_size_request(contents_, kWindowWidth, -1);
if (model_ && model_->IsWaitingForSuggestions()) { if (model_ && model_->IsWaitingForSuggestions()) {
gtk_util::RemoveAllChildren(contents_); gtk_util::RemoveAllChildren(contents_);
...@@ -581,7 +574,7 @@ void WebIntentPickerGtk::InitMainContents() { ...@@ -581,7 +574,7 @@ void WebIntentPickerGtk::InitMainContents() {
// Set the label width to the size of |sub_contents|, which we don't have // Set the label width to the size of |sub_contents|, which we don't have
// access to yet, by calculating the main content width minus borders. // access to yet, by calculating the main content width minus borders.
gtk_util::SetLabelWidth(cws_label_, gtk_util::SetLabelWidth(cws_label_,
kMainContentWidth - 2 * ui::kContentAreaBorder); kWindowWidth - 2 * ui::kContentAreaBorder);
gtk_util::ForceFontSizePixels(cws_label_, kMainContentPixelSize); gtk_util::ForceFontSizePixels(cws_label_, kMainContentPixelSize);
// Suggested extensions vbox. // Suggested extensions vbox.
......
...@@ -23,6 +23,16 @@ class WebContents; ...@@ -23,6 +23,16 @@ class WebContents;
// Base class for the web intent picker dialog. // Base class for the web intent picker dialog.
class WebIntentPicker { class WebIntentPicker {
public: public:
// The width of the window, in view coordinates. The height will be
// determined by the content.
static const int kWindowWidth = 400;
// The maximum width in view units of a suggested extension's title link.
static const int kTitleLinkMaxWidth = 130;
// The space in pixels between the top-level groups and the dialog border.
static const int kContentAreaBorder = 10;
// Platform specific factory function. This function will automatically show // Platform specific factory function. This function will automatically show
// the picker. // the picker.
static WebIntentPicker* Create(TabContents* tab_contents, static WebIntentPicker* Create(TabContents* tab_contents,
......
...@@ -62,15 +62,6 @@ using views::GridLayout; ...@@ -62,15 +62,6 @@ using views::GridLayout;
namespace { namespace {
// The space in pixels between the top-level groups and the dialog border.
const int kContentAreaBorder = 12;
// The minimum size to display the constrained dialog.
const int kDialogMinWidth = 400;
// The maximum width in pixels of a suggested extension's title link.
const int kTitleLinkMaxWidth = 130;
// The color used to dim disabled elements. // The color used to dim disabled elements.
const SkColor kHalfOpacityWhite = SkColorSetARGB(128, 255, 255, 255); const SkColor kHalfOpacityWhite = SkColorSetARGB(128, 255, 255, 255);
...@@ -507,8 +498,9 @@ SuggestedExtensionsRowView::SuggestedExtensionsRowView( ...@@ -507,8 +498,9 @@ SuggestedExtensionsRowView::SuggestedExtensionsRowView(
icon_->SetImage(extension_->icon.ToImageSkia()); icon_->SetImage(extension_->icon.ToImageSkia());
AddChildView(icon_); AddChildView(icon_);
string16 elided_title = ui::ElideText( string16 elided_title = ui::ElideText(extension_->title, gfx::Font(),
extension_->title, gfx::Font(), kTitleLinkMaxWidth, ui::ELIDE_AT_END); WebIntentPicker::kTitleLinkMaxWidth,
ui::ELIDE_AT_END);
title_link_ = new views::Link(elided_title); title_link_ = new views::Link(elided_title);
title_link_->set_listener(this); title_link_->set_listener(this);
AddChildView(title_link_); AddChildView(title_link_);
...@@ -1107,7 +1099,7 @@ void WebIntentPickerViews::InitContents() { ...@@ -1107,7 +1099,7 @@ void WebIntentPickerViews::InitContents() {
views::GridLayout* grid_layout = new views::GridLayout(contents_); views::GridLayout* grid_layout = new views::GridLayout(contents_);
contents_->SetLayoutManager(grid_layout); contents_->SetLayoutManager(grid_layout);
grid_layout->set_minimum_size(gfx::Size(kDialogMinWidth, 0)); grid_layout->set_minimum_size(gfx::Size(kWindowWidth, 0));
grid_layout->SetInsets(kContentAreaBorder, kContentAreaBorder, grid_layout->SetInsets(kContentAreaBorder, kContentAreaBorder,
kContentAreaBorder, kContentAreaBorder); kContentAreaBorder, kContentAreaBorder);
views::ColumnSet* header_cs = grid_layout->AddColumnSet(kHeaderRowColumnSet); views::ColumnSet* header_cs = grid_layout->AddColumnSet(kHeaderRowColumnSet);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment