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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings_bubble_controller.mm

Issue 11417082: [Mac] Website settings: Enlarge window when permission strings are too long. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #import <AppKit/AppKit.h> 9 #import <AppKit/AppKit.h>
10 10
(...skipping 18 matching lines...) Expand all
29 #include "grit/generated_resources.h" 29 #include "grit/generated_resources.h"
30 #include "grit/theme_resources.h" 30 #include "grit/theme_resources.h"
31 #include "grit/ui_resources.h" 31 #include "grit/ui_resources.h"
32 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" 32 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
33 #include "ui/base/l10n/l10n_util.h" 33 #include "ui/base/l10n/l10n_util.h"
34 #include "ui/base/resource/resource_bundle.h" 34 #include "ui/base/resource/resource_bundle.h"
35 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" 35 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h"
36 36
37 namespace { 37 namespace {
38 38
39 // The width of the window, in view coordinates. The height will be determined 39 // The default width of the window, in view coordinates. It may be larger to
40 // by the content. 40 // fit the content.
41 const CGFloat kWindowWidth = 310; 41 const CGFloat kDefaultWindowWidth = 310;
42 42
43 // Spacing in between sections. 43 // Spacing in between sections.
44 const CGFloat kVerticalSpacing = 10; 44 const CGFloat kVerticalSpacing = 10;
45 45
46 // Padding between the window frame and content. 46 // Padding between the window frame and content.
47 const CGFloat kFramePadding = 20; 47 const CGFloat kFramePadding = 20;
48 48
49 // Padding between the window frame and content for the internal page bubble. 49 // Padding between the window frame and content for the internal page bubble.
50 const CGFloat kInternalPageFramePadding = 10; 50 const CGFloat kInternalPageFramePadding = 10;
51 51
(...skipping 24 matching lines...) Expand all
76 76
77 // The spacing between individual items in the Permissions tab. 77 // The spacing between individual items in the Permissions tab.
78 const CGFloat kPermissionsTabSpacing = 12; 78 const CGFloat kPermissionsTabSpacing = 12;
79 79
80 // Extra spacing after a headline on the Permissions tab. 80 // Extra spacing after a headline on the Permissions tab.
81 const CGFloat kPermissionsHeadlineSpacing = 2; 81 const CGFloat kPermissionsHeadlineSpacing = 2;
82 82
83 // The amount of horizontal space between a permission label and the popup. 83 // The amount of horizontal space between a permission label and the popup.
84 const CGFloat kPermissionPopUpXSpacing = 3; 84 const CGFloat kPermissionPopUpXSpacing = 3;
85 85
86 // The amount of horizontal space between the permission popup title and the
87 // arrow icon.
88 const CGFloat kPermissionButtonTitleRightPadding = 4;
89
86 // The extra space to the left of the first tab in the tab strip. 90 // The extra space to the left of the first tab in the tab strip.
87 const CGFloat kTabStripXPadding = kFramePadding; 91 const CGFloat kTabStripXPadding = kFramePadding;
88 92
89 // The amount of space between the visual borders of adjacent tabs. 93 // The amount of space between the visual borders of adjacent tabs.
90 const CGFloat kTabSpacing = 4; 94 const CGFloat kTabSpacing = 4;
91 95
92 // The amount of space above the tab strip. 96 // The amount of space above the tab strip.
93 const CGFloat kTabStripTopSpacing = 14; 97 const CGFloat kTabStripTopSpacing = 14;
94 98
95 // The height of the clickable area of the tab. 99 // The height of the clickable area of the tab.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 nil, 196 nil,
193 tabstripCenterImage_, 197 tabstripCenterImage_,
194 tabstripLeftImage_, 198 tabstripLeftImage_,
195 /*vertical=*/ NO, 199 /*vertical=*/ NO,
196 NSCompositeSourceOver, 200 NSCompositeSourceOver,
197 1, 201 1,
198 /*flipped=*/ YES); 202 /*flipped=*/ YES);
199 203
200 // Draw the background to the right of the selected tab. 204 // Draw the background to the right of the selected tab.
201 backgroundRect.origin.x = NSMaxX(tabRect); 205 backgroundRect.origin.x = NSMaxX(tabRect);
202 backgroundRect.size.width = kWindowWidth - NSMaxX(tabRect); 206 backgroundRect.size.width = NSMaxX(cellFrame) - NSMaxX(tabRect);
203 NSDrawThreePartImage(backgroundRect, 207 NSDrawThreePartImage(backgroundRect,
204 tabstripRightImage_, 208 tabstripRightImage_,
205 tabstripCenterImage_, 209 tabstripCenterImage_,
206 nil, 210 nil,
207 /*vertical=*/ NO, 211 /*vertical=*/ NO,
208 NSCompositeSourceOver, 212 NSCompositeSourceOver,
209 1, 213 1,
210 /*flipped=*/ YES); 214 /*flipped=*/ YES);
211 215
212 // Call the superclass method to trigger drawing of the tab labels. 216 // Call the superclass method to trigger drawing of the tab labels.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 // Returns the minimum size required to display this cell. 281 // Returns the minimum size required to display this cell.
278 // It should always be exactly as tall as the tabstrip background image. 282 // It should always be exactly as tall as the tabstrip background image.
279 - (NSSize)cellSize { 283 - (NSSize)cellSize {
280 return NSMakeSize([super cellSize].width, 284 return NSMakeSize([super cellSize].width,
281 [tabstripCenterImage_ size].height); 285 [tabstripCenterImage_ size].height);
282 } 286 }
283 @end 287 @end
284 288
285 @implementation WebsiteSettingsBubbleController 289 @implementation WebsiteSettingsBubbleController
286 290
291 - (CGFloat)defaultWindowWidth {
292 return kDefaultWindowWidth;
293 }
294
287 - (id)initWithParentWindow:(NSWindow*)parentWindow 295 - (id)initWithParentWindow:(NSWindow*)parentWindow
288 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge 296 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge
289 webContents:(content::WebContents*)webContents 297 webContents:(content::WebContents*)webContents
290 isInternalPage:(BOOL)isInternalPage { 298 isInternalPage:(BOOL)isInternalPage {
291 DCHECK(parentWindow); 299 DCHECK(parentWindow);
292 300
293 webContents_ = webContents; 301 webContents_ = webContents;
294 302
295 // Use an arbitrary height; it will be changed in performLayout. 303 // Use an arbitrary height; it will be changed in performLayout.
296 NSRect contentRect = NSMakeRect(0, 0, kWindowWidth, 1); 304 NSRect contentRect = NSMakeRect(0, 0, [self defaultWindowWidth], 1);
297 // Create an empty window into which content is placed. 305 // Create an empty window into which content is placed.
298 scoped_nsobject<InfoBubbleWindow> window( 306 scoped_nsobject<InfoBubbleWindow> window(
299 [[InfoBubbleWindow alloc] initWithContentRect:contentRect 307 [[InfoBubbleWindow alloc] initWithContentRect:contentRect
300 styleMask:NSBorderlessWindowMask 308 styleMask:NSBorderlessWindowMask
301 backing:NSBackingStoreBuffered 309 backing:NSBackingStoreBuffered
302 defer:NO]); 310 defer:NO]);
303 311
304 if ((self = [super initWithWindow:window.get() 312 if ((self = [super initWithWindow:window.get()
305 parentWindow:parentWindow 313 parentWindow:parentWindow
306 anchoredAt:NSZeroPoint])) { 314 anchoredAt:NSZeroPoint])) {
307 [[self bubble] setArrowLocation:info_bubble::kTopLeft]; 315 [[self bubble] setArrowLocation:info_bubble::kTopLeft];
308 316
309 // Create the container view that uses flipped coordinates. 317 // Create the container view that uses flipped coordinates.
310 NSRect contentFrame = NSMakeRect(0, 0, kWindowWidth, 300); 318 NSRect contentFrame = NSMakeRect(0, 0, [self defaultWindowWidth], 300);
311 contentView_.reset( 319 contentView_.reset(
312 [[FlippedView alloc] initWithFrame:contentFrame]); 320 [[FlippedView alloc] initWithFrame:contentFrame]);
313 321
314 // Replace the window's content. 322 // Replace the window's content.
315 [[[self window] contentView] setSubviews: 323 [[[self window] contentView] setSubviews:
316 [NSArray arrayWithObject:contentView_.get()]]; 324 [NSArray arrayWithObject:contentView_.get()]];
317 325
318 if (isInternalPage) 326 if (isInternalPage)
319 [self initializeContentsForInternalPage]; 327 [self initializeContentsForInternalPage];
320 else 328 else
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 toView:contentView_ 366 toView:contentView_
359 atPoint:controlOrigin]; 367 atPoint:controlOrigin];
360 // Center the text vertically with the image. 368 // Center the text vertically with the image.
361 NSRect textFrame = [textField frame]; 369 NSRect textFrame = [textField frame];
362 textFrame.origin.y += (imageSize.height - NSHeight(textFrame)) / 2; 370 textFrame.origin.y += (imageSize.height - NSHeight(textFrame)) / 2;
363 [textField setFrame:textFrame]; 371 [textField setFrame:textFrame];
364 372
365 // Adjust the contentView to fit everything. 373 // Adjust the contentView to fit everything.
366 CGFloat maxY = std::max(NSMaxY([imageView frame]), NSMaxY(textFrame)); 374 CGFloat maxY = std::max(NSMaxY([imageView frame]), NSMaxY(textFrame));
367 [contentView_ setFrame:NSMakeRect( 375 [contentView_ setFrame:NSMakeRect(
368 0, 0, kWindowWidth, maxY + kInternalPageFramePadding)]; 376 0, 0, [self defaultWindowWidth], maxY + kInternalPageFramePadding)];
369 377
370 [self sizeAndPositionWindow]; 378 [self sizeAndPositionWindow];
371 } 379 }
372 380
373 // Create the subviews for the website settings bubble. 381 // Create the subviews for the website settings bubble.
374 - (void)initializeContents { 382 - (void)initializeContents {
375 // Keeps track of the position that the next control should be drawn at. 383 // Keeps track of the position that the next control should be drawn at.
376 NSPoint controlOrigin = NSMakePoint( 384 NSPoint controlOrigin = NSMakePoint(
377 kFramePadding, 385 kFramePadding,
378 kFramePadding + info_bubble::kBubbleArrowHeight); 386 kFramePadding + info_bubble::kBubbleArrowHeight);
(...skipping 12 matching lines...) Expand all
391 withSize:[NSFont smallSystemFontSize] 399 withSize:[NSFont smallSystemFontSize]
392 bold:NO 400 bold:NO
393 toView:contentView_ 401 toView:contentView_
394 atPoint:controlOrigin]; 402 atPoint:controlOrigin];
395 403
396 // Create the tab view and its two tabs. 404 // Create the tab view and its two tabs.
397 405
398 scoped_nsobject<WebsiteSettingsTabSegmentedCell> cell( 406 scoped_nsobject<WebsiteSettingsTabSegmentedCell> cell(
399 [[WebsiteSettingsTabSegmentedCell alloc] init]); 407 [[WebsiteSettingsTabSegmentedCell alloc] init]);
400 CGFloat tabstripHeight = [cell cellSize].height; 408 CGFloat tabstripHeight = [cell cellSize].height;
401 NSRect tabstripFrame = NSMakeRect(0, 0, kWindowWidth, tabstripHeight); 409 NSRect tabstripFrame = NSMakeRect(
410 0, 0, [self defaultWindowWidth], tabstripHeight);
402 segmentedControl_.reset( 411 segmentedControl_.reset(
403 [[NSSegmentedControl alloc] initWithFrame:tabstripFrame]); 412 [[NSSegmentedControl alloc] initWithFrame:tabstripFrame]);
404 [segmentedControl_ setCell:cell]; 413 [segmentedControl_ setCell:cell];
405 [segmentedControl_ setSegmentCount:WebsiteSettingsUI::NUM_TAB_IDS]; 414 [segmentedControl_ setSegmentCount:WebsiteSettingsUI::NUM_TAB_IDS];
406 [segmentedControl_ setTarget:self]; 415 [segmentedControl_ setTarget:self];
407 [segmentedControl_ setAction:@selector(tabSelected:)]; 416 [segmentedControl_ setAction:@selector(tabSelected:)];
417 [segmentedControl_ setAutoresizingMask:NSViewWidthSizable];
408 418
409 NSFont* smallSystemFont = 419 NSFont* smallSystemFont =
410 [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; 420 [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
411 NSDictionary* textAttributes = 421 NSDictionary* textAttributes =
412 [NSDictionary dictionaryWithObject:smallSystemFont 422 [NSDictionary dictionaryWithObject:smallSystemFont
413 forKey:NSFontAttributeName]; 423 forKey:NSFontAttributeName];
414 424
415 // Create the "Permissions" tab. 425 // Create the "Permissions" tab.
416 NSString* label = l10n_util::GetNSString( 426 NSString* label = l10n_util::GetNSString(
417 IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS); 427 IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS);
(...skipping 18 matching lines...) Expand all
436 tabWidth = std::max(tabWidth, 446 tabWidth = std::max(tabWidth,
437 textSize.width + 2 * kTabLabelXPadding); 447 textSize.width + 2 * kTabLabelXPadding);
438 [segmentedControl_ setWidth:tabWidth + kTabStripXPadding 448 [segmentedControl_ setWidth:tabWidth + kTabStripXPadding
439 forSegment:WebsiteSettingsUI::TAB_ID_PERMISSIONS]; 449 forSegment:WebsiteSettingsUI::TAB_ID_PERMISSIONS];
440 [segmentedControl_ setWidth:tabWidth 450 [segmentedControl_ setWidth:tabWidth
441 forSegment:WebsiteSettingsUI::TAB_ID_CONNECTION]; 451 forSegment:WebsiteSettingsUI::TAB_ID_CONNECTION];
442 452
443 [segmentedControl_ setFont:smallSystemFont]; 453 [segmentedControl_ setFont:smallSystemFont];
444 [contentView_ addSubview:segmentedControl_]; 454 [contentView_ addSubview:segmentedControl_];
445 455
446 NSRect tabFrame = NSMakeRect(0, 0, kWindowWidth, 300); 456 NSRect tabFrame = NSMakeRect(0, 0, [self defaultWindowWidth], 300);
447 tabView_.reset([[NSTabView alloc] initWithFrame:tabFrame]); 457 tabView_.reset([[NSTabView alloc] initWithFrame:tabFrame]);
448 [tabView_ setTabViewType:NSNoTabsNoBorder]; 458 [tabView_ setTabViewType:NSNoTabsNoBorder];
449 [tabView_ setDrawsBackground:NO]; 459 [tabView_ setDrawsBackground:NO];
450 [tabView_ setControlSize:NSSmallControlSize]; 460 [tabView_ setControlSize:NSSmallControlSize];
451 [contentView_ addSubview:tabView_.get()]; 461 [contentView_ addSubview:tabView_.get()];
452 462
453 permissionsTabContentView_ = [self addPermissionsTabToTabView:tabView_]; 463 permissionsTabContentView_ = [self addPermissionsTabToTabView:tabView_];
454 connectionTabContentView_ = [self addConnectionTabToTabView:tabView_]; 464 connectionTabContentView_ = [self addConnectionTabToTabView:tabView_];
455 [self setSelectedTab:WebsiteSettingsUI::TAB_ID_PERMISSIONS]; 465 [self setSelectedTab:WebsiteSettingsUI::TAB_ID_PERMISSIONS];
456 466
457 [self performLayout]; 467 [self performLayout];
458 } 468 }
459 469
460 // Create the contents of the Permissions tab and add it to the given tab view. 470 // Create the contents of the Permissions tab and add it to the given tab view.
461 // Returns a weak reference to the tab view item's view. 471 // Returns a weak reference to the tab view item's view.
462 - (NSView*)addPermissionsTabToTabView:(NSTabView*)tabView { 472 - (NSView*)addPermissionsTabToTabView:(NSTabView*)tabView {
463 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]); 473 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]);
464 [tabView_ insertTabViewItem:item.get() 474 [tabView_ insertTabViewItem:item.get()
465 atIndex:WebsiteSettingsUI::TAB_ID_PERMISSIONS]; 475 atIndex:WebsiteSettingsUI::TAB_ID_PERMISSIONS];
466 scoped_nsobject<NSView> contentView([[FlippedView alloc] 476 scoped_nsobject<NSView> contentView([[FlippedView alloc]
467 initWithFrame:[tabView_ contentRect]]); 477 initWithFrame:[tabView_ contentRect]]);
478 [contentView setAutoresizingMask:NSViewWidthSizable];
468 [item setView:contentView.get()]; 479 [item setView:contentView.get()];
469 480
470 // Initialize the two containers that hold the controls. The initial frames 481 // Initialize the two containers that hold the controls. The initial frames
471 // are arbitrary, and will be adjusted after the controls are laid out. 482 // are arbitrary, and will be adjusted after the controls are laid out.
472 cookiesView_ = [[[FlippedView alloc] 483 cookiesView_ = [[[FlippedView alloc]
473 initWithFrame:[tabView_ contentRect]] autorelease]; 484 initWithFrame:[tabView_ contentRect]] autorelease];
485 [cookiesView_ setAutoresizingMask:NSViewWidthSizable];
486
474 permissionsView_ = [[[FlippedView alloc] 487 permissionsView_ = [[[FlippedView alloc]
475 initWithFrame:[tabView_ contentRect]] autorelease]; 488 initWithFrame:[tabView_ contentRect]] autorelease];
476 489
477 [contentView addSubview:cookiesView_]; 490 [contentView addSubview:cookiesView_];
478 [contentView addSubview:permissionsView_]; 491 [contentView addSubview:permissionsView_];
479 492
480 // Create the link button to view cookies and site data. 493 // Create the link button to view cookies and site data.
481 // Its position will be set in performLayout. 494 // Its position will be set in performLayout.
482 NSString* cookieButtonText = l10n_util::GetNSString( 495 NSString* cookieButtonText = l10n_util::GetNSString(
483 IDS_WEBSITE_SETTINGS_SHOW_SITE_DATA); 496 IDS_WEBSITE_SETTINGS_SHOW_SITE_DATA);
(...skipping 30 matching lines...) Expand all
514 content::PAGE_TRANSITION_LINK, 527 content::PAGE_TRANSITION_LINK,
515 false)); 528 false));
516 } 529 }
517 530
518 // Create the contents of the Connection tab and add it to the given tab view. 531 // Create the contents of the Connection tab and add it to the given tab view.
519 // Returns a weak reference to the tab view item's view. 532 // Returns a weak reference to the tab view item's view.
520 - (NSView*)addConnectionTabToTabView:(NSTabView*)tabView { 533 - (NSView*)addConnectionTabToTabView:(NSTabView*)tabView {
521 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]); 534 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]);
522 scoped_nsobject<NSView> contentView([[FlippedView alloc] 535 scoped_nsobject<NSView> contentView([[FlippedView alloc]
523 initWithFrame:[tabView_ contentRect]]); 536 initWithFrame:[tabView_ contentRect]]);
537 [contentView setAutoresizingMask:NSViewWidthSizable];
524 538
525 // Place all the text and images at the same position. The positions will be 539 // Place all the text and images at the same position. The positions will be
526 // adjusted in performLayout. 540 // adjusted in performLayout.
527 NSPoint textPosition = NSMakePoint( 541 NSPoint textPosition = NSMakePoint(
528 kFramePadding + kConnectionImageSize + kConnectionImageSpacing, 542 kFramePadding + kConnectionImageSize + kConnectionImageSpacing,
529 kFramePadding); 543 kFramePadding);
530 NSPoint imagePosition = NSMakePoint(kFramePadding, kFramePadding); 544 NSPoint imagePosition = NSMakePoint(kFramePadding, kFramePadding);
531 NSSize imageSize = NSMakeSize(kConnectionImageSize, kConnectionImageSize); 545 NSSize imageSize = NSMakeSize(kConnectionImageSize, kConnectionImageSize);
532 546
533 identityStatusIcon_ = [self addImageWithSize:imageSize 547 identityStatusIcon_ = [self addImageWithSize:imageSize
534 toView:contentView 548 toView:contentView
535 atPoint:imagePosition]; 549 atPoint:imagePosition];
536 identityStatusDescriptionField_ = 550 identityStatusDescriptionField_ =
537 [self addText:string16() 551 [self addText:string16()
538 withSize:[NSFont smallSystemFontSize] 552 withSize:[NSFont smallSystemFontSize]
539 bold:NO 553 bold:NO
540 toView:contentView.get() 554 toView:contentView.get()
541 atPoint:textPosition]; 555 atPoint:textPosition];
556
542 separatorAfterIdentity_ = [self addSeparatorToView:contentView]; 557 separatorAfterIdentity_ = [self addSeparatorToView:contentView];
558 [separatorAfterIdentity_ setAutoresizingMask:NSViewWidthSizable];
543 559
544 connectionStatusIcon_ = [self addImageWithSize:imageSize 560 connectionStatusIcon_ = [self addImageWithSize:imageSize
545 toView:contentView 561 toView:contentView
546 atPoint:imagePosition]; 562 atPoint:imagePosition];
547 connectionStatusDescriptionField_ = 563 connectionStatusDescriptionField_ =
548 [self addText:string16() 564 [self addText:string16()
549 withSize:[NSFont smallSystemFontSize] 565 withSize:[NSFont smallSystemFontSize]
550 bold:NO 566 bold:NO
551 toView:contentView.get() 567 toView:contentView.get()
552 atPoint:textPosition]; 568 atPoint:textPosition];
553 certificateInfoButton_ = nil; // This will be created only if necessary. 569 certificateInfoButton_ = nil; // This will be created only if necessary.
554 separatorAfterConnection_ = [self addSeparatorToView:contentView]; 570 separatorAfterConnection_ = [self addSeparatorToView:contentView];
571 [separatorAfterConnection_ setAutoresizingMask:NSViewWidthSizable];
555 572
556 firstVisitIcon_ = [self addImageWithSize:imageSize 573 firstVisitIcon_ = [self addImageWithSize:imageSize
557 toView:contentView 574 toView:contentView
558 atPoint:imagePosition]; 575 atPoint:imagePosition];
559 firstVisitHeaderField_ = 576 firstVisitHeaderField_ =
560 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE) 577 [self addText:l10n_util::GetStringUTF16(IDS_PAGE_INFO_SITE_INFO_TITLE)
561 withSize:[NSFont smallSystemFontSize] 578 withSize:[NSFont smallSystemFontSize]
562 bold:YES 579 bold:YES
563 toView:contentView.get() 580 toView:contentView.get()
564 atPoint:textPosition]; 581 atPoint:textPosition];
565 firstVisitDescriptionField_ = 582 firstVisitDescriptionField_ =
566 [self addText:string16() 583 [self addText:string16()
567 withSize:[NSFont smallSystemFontSize] 584 withSize:[NSFont smallSystemFontSize]
568 bold:NO 585 bold:NO
569 toView:contentView.get() 586 toView:contentView.get()
570 atPoint:textPosition]; 587 atPoint:textPosition];
571 588
572 separatorAfterFirstVisit_ = [self addSeparatorToView:contentView]; 589 separatorAfterFirstVisit_ = [self addSeparatorToView:contentView];
590 [separatorAfterFirstVisit_ setAutoresizingMask:NSViewWidthSizable];
591
573 NSString* helpButtonText = l10n_util::GetNSString( 592 NSString* helpButtonText = l10n_util::GetNSString(
574 IDS_PAGE_INFO_HELP_CENTER_LINK); 593 IDS_PAGE_INFO_HELP_CENTER_LINK);
575 helpButton_ = [self addLinkButtonWithText:helpButtonText 594 helpButton_ = [self addLinkButtonWithText:helpButtonText
576 toView:contentView]; 595 toView:contentView];
577 [helpButton_ setTarget:self]; 596 [helpButton_ setTarget:self];
578 [helpButton_ setAction:@selector(showHelpPage:)]; 597 [helpButton_ setAction:@selector(showHelpPage:)];
579 598
580 [item setView:contentView.get()]; 599 [item setView:contentView.get()];
581 [tabView_ insertTabViewItem:item.get() 600 [tabView_ insertTabViewItem:item.get()
582 atIndex:WebsiteSettingsUI::TAB_ID_CONNECTION]; 601 atIndex:WebsiteSettingsUI::TAB_ID_CONNECTION];
583 602
584 return contentView.get(); 603 return contentView.get();
585 } 604 }
586 605
587 // Set the Y position of |view| to the given position, and return the position 606 // Set the Y position of |view| to the given position, and return the position
588 // of its bottom edge. 607 // of its bottom edge.
589 - (CGFloat)setYPositionOfView:(NSView*)view to:(CGFloat)position { 608 - (CGFloat)setYPositionOfView:(NSView*)view to:(CGFloat)position {
590 NSRect frame = [view frame]; 609 NSRect frame = [view frame];
591 frame.origin.y = position; 610 frame.origin.y = position;
592 [view setFrame:frame]; 611 [view setFrame:frame];
593 return position + NSHeight(frame); 612 return position + NSHeight(frame);
594 } 613 }
595 614
615 - (void)setWidthOfView:(NSView*)view to:(CGFloat)width {
616 [view setFrameSize:NSMakeSize(width, NSHeight([view frame]))];
617 }
618
596 // Layout all of the controls in the window. This should be called whenever 619 // Layout all of the controls in the window. This should be called whenever
597 // the content has changed. 620 // the content has changed.
598 - (void)performLayout { 621 - (void)performLayout {
622 // Make the content at least as wide as the permissions view.
623 CGFloat contentWidth = std::max([self defaultWindowWidth],
624 NSWidth([permissionsView_ frame]));
625
626 // Set the width of the content view now, so that all the text fields will
627 // be sized to fit before their heights and vertical positions are adjusted.
628 // The tab view will only resize the currently selected tab, so resize both
629 // tab content views manually.
630 [self setWidthOfView:contentView_ to:contentWidth];
631 [self setWidthOfView:permissionsTabContentView_ to:contentWidth];
632 [self setWidthOfView:connectionTabContentView_ to:contentWidth];
633
599 // Place the identity status immediately below the identity. 634 // Place the identity status immediately below the identity.
600 [self sizeTextFieldHeightToFit:identityField_]; 635 [self sizeTextFieldHeightToFit:identityField_];
601 [self sizeTextFieldHeightToFit:identityStatusField_]; 636 [self sizeTextFieldHeightToFit:identityStatusField_];
602 CGFloat yPos = NSMaxY([identityField_ frame]) + kConnectionHeadlineSpacing; 637 CGFloat yPos = NSMaxY([identityField_ frame]) + kConnectionHeadlineSpacing;
603 yPos = [self setYPositionOfView:identityStatusField_ to:yPos]; 638 yPos = [self setYPositionOfView:identityStatusField_ to:yPos];
604 639
605 // Lay out the Permissions tab. 640 // Lay out the Permissions tab.
641
606 yPos = [self setYPositionOfView:cookiesView_ to:kFramePadding]; 642 yPos = [self setYPositionOfView:cookiesView_ to:kFramePadding];
607 643
608 // Put the link button for cookies and site data just below the cookie info. 644 // Put the link button for cookies and site data just below the cookie info.
609 NSRect cookiesButtonFrame = [cookiesButton_ frame]; 645 NSRect cookiesButtonFrame = [cookiesButton_ frame];
610 cookiesButtonFrame.origin.y = yPos; 646 cookiesButtonFrame.origin.y = yPos;
611 cookiesButtonFrame.origin.x = kFramePadding; 647 cookiesButtonFrame.origin.x = kFramePadding;
612 [cookiesButton_ setFrame:cookiesButtonFrame]; 648 [cookiesButton_ setFrame:cookiesButtonFrame];
613 649
614 // Put the permission info just below the link button. 650 // Put the permission info just below the link button.
615 [self setYPositionOfView:permissionsView_ 651 [self setYPositionOfView:permissionsView_
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 yPos = [self setYPositionOfView:separatorAfterFirstVisit_ 689 yPos = [self setYPositionOfView:separatorAfterFirstVisit_
654 to:yPos + kVerticalSpacing]; 690 to:yPos + kVerticalSpacing];
655 yPos += kVerticalSpacing; 691 yPos += kVerticalSpacing;
656 [self setYPositionOfView:helpButton_ to:yPos]; 692 [self setYPositionOfView:helpButton_ to:yPos];
657 693
658 // Adjust the tab view size and place it below the identity status. 694 // Adjust the tab view size and place it below the identity status.
659 695
660 yPos = NSMaxY([identityStatusField_ frame]) + kTabStripTopSpacing; 696 yPos = NSMaxY([identityStatusField_ frame]) + kTabStripTopSpacing;
661 yPos = [self setYPositionOfView:segmentedControl_ to:yPos]; 697 yPos = [self setYPositionOfView:segmentedControl_ to:yPos];
662 698
699 CGFloat connectionTabHeight = NSMaxY([helpButton_ frame]) + kVerticalSpacing;
700
663 NSRect tabViewFrame = [tabView_ frame]; 701 NSRect tabViewFrame = [tabView_ frame];
664 tabViewFrame.origin.y = yPos; 702 tabViewFrame.origin.y = yPos;
665 703 tabViewFrame.size.height =
666 // Determine the height of the tab contents. 704 std::max(connectionTabHeight, NSMaxY([permissionsView_ frame]));
667 705 tabViewFrame.size.width = contentWidth;
668 CGFloat connectionTabHeight = std::max(
669 NSMaxY([firstVisitDescriptionField_ frame]),
670 NSMaxY([firstVisitIcon_ frame ]));
671 connectionTabHeight += kVerticalSpacing;
672
673 CGFloat permissionsTabHeight = NSMaxY([permissionsView_ frame]);
674 CGFloat tabContentHeight = std::max(connectionTabHeight,
675 permissionsTabHeight);
676 tabViewFrame.size.height = tabContentHeight +
677 NSHeight(tabViewFrame) - NSHeight([tabView_ contentRect]);
678 [tabView_ setFrame:tabViewFrame]; 706 [tabView_ setFrame:tabViewFrame];
679 707
680 // Adjust the contentView to fit everything. 708 // Adjust the contentView to fit everything.
681 [contentView_ setFrame:NSMakeRect( 709 [contentView_ setFrame:NSMakeRect(
682 0, 0, kWindowWidth, NSMaxY([tabView_ frame]))]; 710 0, 0, NSWidth(tabViewFrame), NSMaxY(tabViewFrame))];
683 711
684 [self sizeAndPositionWindow]; 712 [self sizeAndPositionWindow];
685 } 713 }
686 714
687 // Adjust the size of the window to match the size of the content, and position 715 // Adjust the size of the window to match the size of the content, and position
688 // the bubble anchor appropriately. 716 // the bubble anchor appropriately.
689 - (void)sizeAndPositionWindow { 717 - (void)sizeAndPositionWindow {
690 NSRect windowFrame = 718 NSRect windowFrame = [contentView_ frame];
691 NSMakeRect(0, 0, kWindowWidth, NSHeight([contentView_ frame]));
692 windowFrame.size = [[[self window] contentView] convertSize:windowFrame.size 719 windowFrame.size = [[[self window] contentView] convertSize:windowFrame.size
693 toView:nil]; 720 toView:nil];
694 // Adjust the origin by the difference in height. 721 // Adjust the origin by the difference in height.
695 windowFrame.origin = [[self window] frame].origin; 722 windowFrame.origin = [[self window] frame].origin;
696 windowFrame.origin.y -= NSHeight(windowFrame) - 723 windowFrame.origin.y -= NSHeight(windowFrame) -
697 NSHeight([[self window] frame]); 724 NSHeight([[self window] frame]);
698 725
699 // Resize the window. Only animate if the window is visible, otherwise it 726 // Resize the window. Only animate if the window is visible, otherwise it
700 // could be "growing" while it's opening, looking awkward. 727 // could be "growing" while it's opening, looking awkward.
701 [[self window] setFrame:windowFrame 728 [[self window] setFrame:windowFrame
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
756 CGFloat width = NSWidth([view frame]) - point.x - kFramePadding; 783 CGFloat width = NSWidth([view frame]) - point.x - kFramePadding;
757 NSRect frame = NSMakeRect(point.x, point.y, width, 100); 784 NSRect frame = NSMakeRect(point.x, point.y, width, 100);
758 scoped_nsobject<NSTextField> textField( 785 scoped_nsobject<NSTextField> textField(
759 [[NSTextField alloc] initWithFrame:frame]); 786 [[NSTextField alloc] initWithFrame:frame]);
760 [self configureTextFieldAsLabel:textField.get()]; 787 [self configureTextFieldAsLabel:textField.get()];
761 [textField setStringValue:base::SysUTF16ToNSString(text)]; 788 [textField setStringValue:base::SysUTF16ToNSString(text)];
762 NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize] 789 NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize]
763 : [NSFont systemFontOfSize:fontSize]; 790 : [NSFont systemFontOfSize:fontSize];
764 [textField setFont:font]; 791 [textField setFont:font];
765 [self sizeTextFieldHeightToFit:textField]; 792 [self sizeTextFieldHeightToFit:textField];
793 [textField setAutoresizingMask:NSViewWidthSizable];
766 [view addSubview:textField.get()]; 794 [view addSubview:textField.get()];
767 return textField.get(); 795 return textField.get();
768 } 796 }
769 797
770 // Add an image as a subview of the given view, placed at a pre-determined x 798 // Add an image as a subview of the given view, placed at a pre-determined x
771 // position and the given y position. Return the new NSImageView. 799 // position and the given y position. Return the new NSImageView.
772 - (NSImageView*)addImageWithSize:(NSSize)size 800 - (NSImageView*)addImageWithSize:(NSSize)size
773 toView:(NSView*)view 801 toView:(NSView*)view
774 atPoint:(NSPoint)point { 802 atPoint:(NSPoint)point {
775 NSRect frame = NSMakeRect(point.x, point.y, size.width, size.height); 803 NSRect frame = NSMakeRect(point.x, point.y, size.width, size.height);
(...skipping 22 matching lines...) Expand all
798 NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10); 826 NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10);
799 scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:frame]); 827 scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:frame]);
800 scoped_nsobject<HyperlinkButtonCell> cell( 828 scoped_nsobject<HyperlinkButtonCell> cell(
801 [[HyperlinkButtonCell alloc] initTextCell:text]); 829 [[HyperlinkButtonCell alloc] initTextCell:text]);
802 [cell setControlSize:NSSmallControlSize]; 830 [cell setControlSize:NSSmallControlSize];
803 [button setCell:cell.get()]; 831 [button setCell:cell.get()];
804 [button setButtonType:NSMomentaryPushInButton]; 832 [button setButtonType:NSMomentaryPushInButton];
805 [button setBezelStyle:NSRegularSquareBezelStyle]; 833 [button setBezelStyle:NSRegularSquareBezelStyle];
806 [view addSubview:button.get()]; 834 [view addSubview:button.get()];
807 835
808 // Call size-to-fit to fixup for the localized string.
809 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; 836 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()];
810 return button.get(); 837 return button.get();
811 } 838 }
812 839
840 // Determine the size of a popup button with the given title.
841 - (NSSize)sizeForPopUpButton:(NSPopUpButton*)button
842 withTitle:(NSString*)title {
843 NSDictionary* textAttributes =
844 [NSDictionary dictionaryWithObject:[button font]
845 forKey:NSFontAttributeName];
846 NSSize titleSize = [title sizeWithAttributes:textAttributes];
847
848 NSRect buttonFrame = [button frame];
849 NSRect titleRect = [[button cell] titleRectForBounds:buttonFrame];
850 CGFloat width = titleSize.width + NSWidth(buttonFrame) - NSWidth(titleRect);
851
852 return NSMakeSize(width + kPermissionButtonTitleRightPadding,
853 NSHeight(buttonFrame));
854 }
855
813 // Add a pop-up button for |permissionInfo| to the given view. 856 // Add a pop-up button for |permissionInfo| to the given view.
814 - (NSPopUpButton*)addPopUpButtonForPermission: 857 - (NSPopUpButton*)addPopUpButtonForPermission:
815 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo 858 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo
816 toView:(NSView*)view 859 toView:(NSView*)view
817 atPoint:(NSPoint)point { 860 atPoint:(NSPoint)point {
818 // Use an arbitrary width and height; it will be sized to fit. 861 // Use an arbitrary width and height; it will be sized to fit.
819 NSRect frame = NSMakeRect(point.x, point.y, 1, 1); 862 NSRect frame = NSMakeRect(point.x, point.y, 1, 1);
820 scoped_nsobject<NSPopUpButton> button( 863 scoped_nsobject<NSPopUpButton> button(
821 [[NSPopUpButton alloc] initWithFrame:frame pullsDown:NO]); 864 [[NSPopUpButton alloc] initWithFrame:frame pullsDown:NO]);
822 [button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; 865 [button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 scoped_nsobject<NSMenuItem> titleItem([[NSMenuItem alloc] init]); 899 scoped_nsobject<NSMenuItem> titleItem([[NSMenuItem alloc] init]);
857 string16 buttonTitle = WebsiteSettingsUI::PermissionActionToUIString( 900 string16 buttonTitle = WebsiteSettingsUI::PermissionActionToUIString(
858 permissionInfo.setting, 901 permissionInfo.setting,
859 permissionInfo.default_setting, 902 permissionInfo.default_setting,
860 permissionInfo.source); 903 permissionInfo.source);
861 [titleItem setTitle:base::SysUTF16ToNSString(buttonTitle)]; 904 [titleItem setTitle:base::SysUTF16ToNSString(buttonTitle)];
862 [[button cell] setUsesItemFromMenu:NO]; 905 [[button cell] setUsesItemFromMenu:NO];
863 [[button cell] setMenuItem:titleItem.get()]; 906 [[button cell] setMenuItem:titleItem.get()];
864 [button sizeToFit]; 907 [button sizeToFit];
865 908
866 // Determine the size of the title, and size the control accordingly. 909 // Determine the largest possible size for this button.
867 // Using |sizeToFit| results in way too much extra space after the text. 910 CGFloat maxTitleWidth = 0;
868 NSDictionary* textAttributes = 911 for (NSInteger i = 0; i < [button numberOfItems]; ++i) {
869 [NSDictionary dictionaryWithObject:[button font] 912 string16 title = WebsiteSettingsUI::PermissionActionToUIString(
870 forKey:NSFontAttributeName]; 913 static_cast<ContentSetting>([[button itemAtIndex:i] tag]),
871 NSSize titleSize = [[button title] sizeWithAttributes:textAttributes]; 914 permissionInfo.default_setting,
915 content_settings::SETTING_SOURCE_USER);
916 NSSize size = [self sizeForPopUpButton:button
917 withTitle:base::SysUTF16ToNSString(title)];
918 maxTitleWidth = std::max(maxTitleWidth, size.width);
919 }
920 // Ensure the containing view is large enough to contain the button with its
921 // widest possible title.
922 NSRect containerFrame = [view frame];
923 containerFrame.size.width = std::max(
924 NSWidth(containerFrame), point.x + maxTitleWidth + kFramePadding);
925 [view setFrame:containerFrame];
872 926
873 // Adjust the button frame to have a titleRect that exactly fits the title. 927 // Size the button to just fit the title.
874 NSRect buttonFrame = [button frame]; 928 [button setFrameSize:[self sizeForPopUpButton:button
875 NSRect titleRect = [[button cell] titleRectForBounds:buttonFrame]; 929 withTitle:[button title]]];
876 buttonFrame.size.width =
877 titleSize.width + NSWidth(buttonFrame) - NSWidth(titleRect);
878 [button setFrame:buttonFrame];
879 DCHECK_EQ(NSWidth([[button cell] titleRectForBounds:buttonFrame]),
880 titleSize.width);
881 930
882 [view addSubview:button.get()]; 931 [view addSubview:button.get()];
883 return button.get(); 932 return button.get();
884 } 933 }
885 934
886 // Called when the user changes the selected segment in the segmented control. 935 // Called when the user changes the selected segment in the segmented control.
887 - (void)tabSelected:(id)sender { 936 - (void)tabSelected:(id)sender {
888 [tabView_ selectTabViewItemAtIndex:[segmentedControl_ selectedSegment]]; 937 [tabView_ selectTabViewItemAtIndex:[segmentedControl_ selectedSegment]];
889 } 938 }
890 939
891 // Handler for the permission-changing menus. 940 // Handler for the permission-changing menus.
892 - (void)permissionValueChanged:(id)sender { 941 - (void)permissionValueChanged:(id)sender {
893 DCHECK([sender isKindOfClass:[NSPopUpButton class]]); 942 DCHECK([sender isKindOfClass:[NSPopUpButton class]]);
894 NSPopUpButton* button = static_cast<NSPopUpButton*>(sender); 943 NSPopUpButton* button = static_cast<NSPopUpButton*>(sender);
895 ContentSettingsType type = static_cast<ContentSettingsType>([button tag]); 944 ContentSettingsType type = static_cast<ContentSettingsType>([button tag]);
896 ContentSetting newSetting = static_cast<ContentSetting>( 945 ContentSetting newSetting = static_cast<ContentSetting>(
897 [[button selectedItem] tag]); 946 [[button selectedItem] tag]);
898 if (presenter_.get()) 947 if (presenter_.get())
899 presenter_->OnSitePermissionChanged(type, newSetting); 948 presenter_->OnSitePermissionChanged(type, newSetting);
900 } 949 }
901 950
902 // Adds a new row to the UI listing the permissions. Returns the amount of 951 // Adds a new row to the UI listing the permissions. Returns the amount of
903 // vertical space that was taken up by the row. 952 // vertical space that was taken up by the row.
904 - (CGFloat)addPermission: 953 - (NSPoint)addPermission:
905 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo 954 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo
906 toView:(NSView*)view 955 toView:(NSView*)view
907 atPoint:(NSPoint)point { 956 atPoint:(NSPoint)point {
908 // TODO(dubroy): Remove this check by refactoring GetPermissionIcon to take 957 // TODO(dubroy): Remove this check by refactoring GetPermissionIcon to take
909 // the PermissionInfo object as its argument. 958 // the PermissionInfo object as its argument.
910 ContentSetting setting = permissionInfo.setting == CONTENT_SETTING_DEFAULT ? 959 ContentSetting setting = permissionInfo.setting == CONTENT_SETTING_DEFAULT ?
911 permissionInfo.default_setting : permissionInfo.setting; 960 permissionInfo.default_setting : permissionInfo.setting;
912 NSImage* image = WebsiteSettingsUI::GetPermissionIcon( 961 NSImage* image = WebsiteSettingsUI::GetPermissionIcon(
913 permissionInfo.type, setting).ToNSImage(); 962 permissionInfo.type, setting).ToNSImage();
914 NSImageView* imageView = [self addImageWithSize:[image size] 963 NSImageView* imageView = [self addImageWithSize:[image size]
(...skipping 28 matching lines...) Expand all
943 992
944 // Align the icon with the text. 993 // Align the icon with the text.
945 [self alignPermissionIcon:imageView withTextField:label]; 994 [self alignPermissionIcon:imageView withTextField:label];
946 995
947 // Permissions specified by policy or an extension cannot be changed. 996 // Permissions specified by policy or an extension cannot be changed.
948 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION || 997 if (permissionInfo.source == content_settings::SETTING_SOURCE_EXTENSION ||
949 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) { 998 permissionInfo.source == content_settings::SETTING_SOURCE_POLICY) {
950 [button setEnabled:NO]; 999 [button setEnabled:NO];
951 } 1000 }
952 1001
953 return NSHeight([label frame]); 1002 NSRect buttonFrame = [button frame];
1003 return NSMakePoint(NSMaxX(buttonFrame), NSMaxY(buttonFrame));
954 } 1004 }
955 1005
956 // Align an image with a text field by vertically centering the image on 1006 // Align an image with a text field by vertically centering the image on
957 // the cap height of the first line of text. 1007 // the cap height of the first line of text.
958 - (void)alignPermissionIcon:(NSImageView*)imageView 1008 - (void)alignPermissionIcon:(NSImageView*)imageView
959 withTextField:(NSTextField*)textField { 1009 withTextField:(NSTextField*)textField {
960 NSFont* font = [textField font]; 1010 NSFont* font = [textField font];
961 1011
962 // Calculate the offset from the top of the text field. 1012 // Calculate the offset from the top of the text field.
963 CGFloat capHeight = [font capHeight]; 1013 CGFloat capHeight = [font capHeight];
(...skipping 22 matching lines...) Expand all
986 UTF8ToUTF16(cookieInfo.cookie_source), 1036 UTF8ToUTF16(cookieInfo.cookie_source),
987 base::IntToString16(cookieInfo.allowed), 1037 base::IntToString16(cookieInfo.allowed),
988 base::IntToString16(cookieInfo.blocked)); 1038 base::IntToString16(cookieInfo.blocked));
989 1039
990 NSTextField* label = [self addText:labelText 1040 NSTextField* label = [self addText:labelText
991 withSize:[NSFont smallSystemFontSize] 1041 withSize:[NSFont smallSystemFontSize]
992 bold:NO 1042 bold:NO
993 toView:view 1043 toView:view
994 atPoint:point]; 1044 atPoint:point];
995 1045
996 // Shrink the label to fit the text width.
997 NSSize requiredSize = [[label cell] cellSizeForBounds:[label frame]];
998 [label setFrameSize:requiredSize];
999
1000 // Align the icon with the text. 1046 // Align the icon with the text.
1001 [self alignPermissionIcon:imageView withTextField:label]; 1047 [self alignPermissionIcon:imageView withTextField:label];
1002 1048
1003 return NSHeight([label frame]); 1049 return NSHeight([label frame]);
1004 } 1050 }
1005 1051
1006 // Set the content of the identity and identity status fields. 1052 // Set the content of the identity and identity status fields.
1007 - (void)setIdentityInfo:(const WebsiteSettingsUI::IdentityInfo&)identityInfo { 1053 - (void)setIdentityInfo:(const WebsiteSettingsUI::IdentityInfo&)identityInfo {
1008 [identityField_ setStringValue: 1054 [identityField_ setStringValue:
1009 base::SysUTF8ToNSString(identityInfo.site_identity)]; 1055 base::SysUTF8ToNSString(identityInfo.site_identity)];
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 [cookiesView_ setSubviews:[NSArray array]]; 1093 [cookiesView_ setSubviews:[NSArray array]];
1048 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0); 1094 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0);
1049 1095
1050 string16 sectionTitle = l10n_util::GetStringUTF16( 1096 string16 sectionTitle = l10n_util::GetStringUTF16(
1051 IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA); 1097 IDS_WEBSITE_SETTINGS_TITLE_SITE_DATA);
1052 NSTextField* header = [self addText:sectionTitle 1098 NSTextField* header = [self addText:sectionTitle
1053 withSize:[NSFont smallSystemFontSize] 1099 withSize:[NSFont smallSystemFontSize]
1054 bold:YES 1100 bold:YES
1055 toView:cookiesView_ 1101 toView:cookiesView_
1056 atPoint:controlOrigin]; 1102 atPoint:controlOrigin];
1057 [self sizeTextFieldHeightToFit:header];
1058 controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing; 1103 controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing;
1059 1104
1060 for (CookieInfoList::const_iterator it = cookieInfoList.begin(); 1105 for (CookieInfoList::const_iterator it = cookieInfoList.begin();
1061 it != cookieInfoList.end(); 1106 it != cookieInfoList.end();
1062 ++it) { 1107 ++it) {
1063 controlOrigin.y += kPermissionsTabSpacing; 1108 controlOrigin.y += kPermissionsTabSpacing;
1064 CGFloat rowHeight = [self addCookieInfo:*it 1109 CGFloat rowHeight = [self addCookieInfo:*it
1065 toView:cookiesView_ 1110 toView:cookiesView_
1066 atPoint:controlOrigin]; 1111 atPoint:controlOrigin];
1067 controlOrigin.y += rowHeight; 1112 controlOrigin.y += rowHeight;
1068 } 1113 }
1069 1114
1070 controlOrigin.y += kPermissionsTabSpacing; 1115 controlOrigin.y += kPermissionsTabSpacing;
1071 [cookiesView_ setFrameSize:NSMakeSize(kWindowWidth, controlOrigin.y)]; 1116 [cookiesView_ setFrameSize:
1117 NSMakeSize(NSWidth([cookiesView_ frame]), controlOrigin.y)];
1118
1072 [self performLayout]; 1119 [self performLayout];
1073 } 1120 }
1074 1121
1075 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList { 1122 - (void)setPermissionInfo:(const PermissionInfoList&)permissionInfoList {
1123 // The contents of the permissions view can cause the whole window to get
1124 // bigger, but currently permissions are always set before cookie info.
1125 // Check to make sure that's still the case.
1126 DCHECK_EQ(0U, [[cookiesView_ subviews] count]);
1127
1076 [permissionsView_ setSubviews:[NSArray array]]; 1128 [permissionsView_ setSubviews:[NSArray array]];
1077 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0); 1129 NSPoint controlOrigin = NSMakePoint(kFramePadding, 0);
1078 1130
1079 string16 sectionTitle = l10n_util::GetStringUTF16( 1131 string16 sectionTitle = l10n_util::GetStringUTF16(
1080 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS); 1132 IDS_WEBSITE_SETTINGS_TITLE_SITE_PERMISSIONS);
1081 NSTextField* header = [self addText:sectionTitle 1133 NSTextField* header = [self addText:sectionTitle
1082 withSize:[NSFont smallSystemFontSize] 1134 withSize:[NSFont smallSystemFontSize]
1083 bold:YES 1135 bold:YES
1084 toView:permissionsView_ 1136 toView:permissionsView_
1085 atPoint:controlOrigin]; 1137 atPoint:controlOrigin];
1086 [self sizeTextFieldHeightToFit:header]; 1138 [self sizeTextFieldHeightToFit:header];
1087 controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing; 1139 controlOrigin.y += NSHeight([header frame]) + kPermissionsHeadlineSpacing;
1088 1140
1089 for (PermissionInfoList::const_iterator permission = 1141 for (PermissionInfoList::const_iterator permission =
1090 permissionInfoList.begin(); 1142 permissionInfoList.begin();
1091 permission != permissionInfoList.end(); 1143 permission != permissionInfoList.end();
1092 ++permission) { 1144 ++permission) {
1093 controlOrigin.y += kPermissionsTabSpacing; 1145 controlOrigin.y += kPermissionsTabSpacing;
1094 CGFloat rowHeight = [self addPermission:*permission 1146 NSPoint rowBottomRight = [self addPermission:*permission
1095 toView:permissionsView_ 1147 toView:permissionsView_
1096 atPoint:controlOrigin]; 1148 atPoint:controlOrigin];
1097 controlOrigin.y += rowHeight; 1149 controlOrigin.y = rowBottomRight.y;
1098 } 1150 }
1099 controlOrigin.y += kFramePadding; 1151 controlOrigin.y += kFramePadding;
1100 [permissionsView_ setFrameSize:NSMakeSize(kWindowWidth, controlOrigin.y)]; 1152 [permissionsView_ setFrameSize:
1153 NSMakeSize(NSWidth([permissionsView_ frame]), controlOrigin.y)];
1154 [self performLayout];
1101 } 1155 }
1102 1156
1103 - (void)setFirstVisit:(const string16&)firstVisit { 1157 - (void)setFirstVisit:(const string16&)firstVisit {
1104 [firstVisitIcon_ setImage: 1158 [firstVisitIcon_ setImage:
1105 WebsiteSettingsUI::GetFirstVisitIcon(firstVisit).ToNSImage()]; 1159 WebsiteSettingsUI::GetFirstVisitIcon(firstVisit).ToNSImage()];
1106 [firstVisitDescriptionField_ setStringValue: 1160 [firstVisitDescriptionField_ setStringValue:
1107 base::SysUTF16ToNSString(firstVisit)]; 1161 base::SysUTF16ToNSString(firstVisit)];
1108 [self performLayout]; 1162 [self performLayout];
1109 } 1163 }
1110 1164
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 [bubble_controller_ setPermissionInfo:permission_info_list]; 1232 [bubble_controller_ setPermissionInfo:permission_info_list];
1179 } 1233 }
1180 1234
1181 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) { 1235 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) {
1182 [bubble_controller_ setFirstVisit:first_visit]; 1236 [bubble_controller_ setFirstVisit:first_visit];
1183 } 1237 }
1184 1238
1185 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { 1239 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) {
1186 [bubble_controller_ setSelectedTab:tab_id]; 1240 [bubble_controller_ setSelectedTab:tab_id];
1187 } 1241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698