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

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

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

Powered by Google App Engine
This is Rietveld 408576698