Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
| 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 8 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 9 #import "chrome/browser/ui/cocoa/info_bubble_view.h" | 9 #import "chrome/browser/ui/cocoa/info_bubble_view.h" |
| 10 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 10 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| 11 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 11 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
| 12 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 13 #include "content/public/browser/cert_store.h" | 13 #include "content/public/browser/cert_store.h" |
| 14 #include "grit/generated_resources.h" | 14 #include "grit/generated_resources.h" |
| 15 #include "grit/theme_resources.h" | |
| 15 #include "grit/ui_resources.h" | 16 #include "grit/ui_resources.h" |
| 16 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 17 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 18 #include "ui/base/resource/resource_bundle.h" | 19 #include "ui/base/resource/resource_bundle.h" |
| 19 | 20 |
| 20 namespace { | 21 namespace { |
| 21 | 22 |
| 22 // The width of the window, in view coordinates. The height will be determined | 23 // The width of the window, in view coordinates. The height will be determined |
| 23 // by the content. | 24 // by the content. |
| 24 const CGFloat kWindowWidth = 380; | 25 const CGFloat kWindowWidth = 380; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 46 // Width of the text fields. | 47 // Width of the text fields. |
| 47 const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing + | 48 const CGFloat kTextWidth = kWindowWidth - (kImageSize + kImageSpacing + |
| 48 kFramePadding * 2); | 49 kFramePadding * 2); |
| 49 | 50 |
| 50 // The amount of padding given to tab view contents. | 51 // The amount of padding given to tab view contents. |
| 51 const CGFloat kTabViewContentsPadding = kFramePadding; | 52 const CGFloat kTabViewContentsPadding = kFramePadding; |
| 52 | 53 |
| 53 // The spacing between individual items in the Permissions tab. | 54 // The spacing between individual items in the Permissions tab. |
| 54 const CGFloat kPermissionsTabSpacing = 8; | 55 const CGFloat kPermissionsTabSpacing = 8; |
| 55 | 56 |
| 57 // The extra space to the left of the first tab in the tab strip. | |
| 58 const CGFloat kTabStripXPadding = 19; | |
| 59 | |
| 60 // The amount of space between the visual borders of adjacent tabs. | |
| 61 const CGFloat kTabSpacing = 4; | |
| 62 | |
| 63 // The extra width outside the hit rect used by the visual borders of the tab. | |
| 64 const CGFloat kTabBorderExtraWidth = 16; | |
| 65 | |
| 66 // The height of the clickable area of the tab strip. | |
| 67 const CGFloat kTabHeight = 27; | |
| 68 | |
| 69 // The height of the background image for the tab strip. | |
| 70 const CGFloat kTabStripHeight = 44; | |
| 71 | |
| 72 // The amount of space above tab labels. | |
| 73 const CGFloat kTabLabelTopPadding = 20; | |
| 74 | |
| 75 // The amount of padding to leave on either side of the tab label. | |
| 76 const CGFloat kTabLabelXPadding = 12; | |
| 77 | |
| 56 // In the permission changing menu, the order of the menu items (which | 78 // In the permission changing menu, the order of the menu items (which |
| 57 // correspond to different content settings). | 79 // correspond to different content settings). |
| 58 const ContentSetting kPermissionsMenuSettings[] = { | 80 const ContentSetting kPermissionsMenuSettings[] = { |
| 59 CONTENT_SETTING_ALLOW, | 81 CONTENT_SETTING_ALLOW, |
| 60 CONTENT_SETTING_BLOCK, | 82 CONTENT_SETTING_BLOCK, |
| 61 CONTENT_SETTING_DEFAULT | 83 CONTENT_SETTING_DEFAULT |
| 62 }; | 84 }; |
| 63 | 85 |
| 64 } // namespace | 86 } // namespace |
| 65 | 87 |
| 66 // A simple container to hold all the contents of the website settings bubble. | 88 // A simple container to hold all the contents of the website settings bubble. |
| 67 // It uses a flipped coordinate system to make text layout easier. | 89 // It uses a flipped coordinate system to make text layout easier. |
| 68 @interface WebsiteSettingsContentView : NSView | 90 @interface WebsiteSettingsContentView : NSView |
| 69 @end | 91 @end |
| 70 @implementation WebsiteSettingsContentView | 92 @implementation WebsiteSettingsContentView |
| 71 - (BOOL)isFlipped { | 93 - (BOOL)isFlipped { |
| 72 return YES; | 94 return YES; |
| 73 } | 95 } |
| 74 @end | 96 @end |
| 75 | 97 |
| 98 @interface WebsiteSettingsTabSegmentedCell : NSSegmentedCell { | |
| 99 @private | |
| 100 scoped_nsobject<NSImage> tabBackgroundImage_; | |
| 101 scoped_nsobject<NSImage> tabCenterImage_; | |
| 102 scoped_nsobject<NSImage> tabLeftImage_; | |
| 103 scoped_nsobject<NSImage> tabRightImage_; | |
| 104 } | |
| 105 @end | |
|
Robert Sesek
2012/08/09 14:44:00
nit: blank line after
Patrick Dubroy
2012/08/09 15:33:19
Done.
| |
| 106 @implementation WebsiteSettingsTabSegmentedCell | |
| 107 - (id)init { | |
| 108 if ((self = [super init])) { | |
| 109 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | |
| 110 tabBackgroundImage_.reset( | |
| 111 [rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TAB_BACKGROUND) retain]); | |
| 112 tabCenterImage_.reset( | |
| 113 [rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TAB_CENTER) retain]); | |
| 114 tabLeftImage_.reset( | |
| 115 [rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TAB_LEFT) retain]); | |
| 116 tabRightImage_.reset( | |
| 117 [rb.GetNativeImageNamed(IDR_WEBSITE_SETTINGS_TAB_RIGHT) retain]); | |
| 118 } | |
| 119 return self; | |
| 120 } | |
| 121 | |
| 122 - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView { | |
|
Robert Sesek
2012/08/09 14:44:00
nit: no space before *
Patrick Dubroy
2012/08/09 15:33:19
Done.
| |
| 123 // Draw the background for the tab strip. | |
| 124 NSDrawThreePartImage(cellFrame, | |
| 125 nil, | |
| 126 tabBackgroundImage_, | |
| 127 nil, | |
| 128 /*vertical=*/ NO, | |
| 129 NSCompositeSourceOver, | |
| 130 1, | |
| 131 /*flipped=*/ YES); | |
| 132 | |
| 133 // Draw the tab for the selected segment. The drawing area is slightly | |
| 134 // larger than the hit rect for the tab. | |
| 135 NSRect tabRect = [self hitRectForSegment:[self selectedSegment]]; | |
| 136 tabRect.origin.x -= kTabBorderExtraWidth; | |
| 137 tabRect.size.width += 2 * kTabBorderExtraWidth; | |
| 138 | |
| 139 tabRect.origin.y = 0; | |
| 140 tabRect.size.height = kTabStripHeight; | |
| 141 | |
| 142 NSDrawThreePartImage(tabRect, | |
| 143 tabLeftImage_, | |
| 144 tabCenterImage_, | |
| 145 tabRightImage_, | |
| 146 /*vertical=*/ NO, | |
| 147 NSCompositeSourceOver, | |
| 148 1, | |
| 149 /*flipped=*/ YES); | |
| 150 | |
| 151 // Call the superclass method to trigger drawing of the tab labels. | |
| 152 [self drawInteriorWithFrame:cellFrame inView:controlView]; | |
| 153 } | |
| 154 | |
| 155 // Return the hit rect (i.e., the visual bounds of the tab) for | |
| 156 // the given segment. | |
| 157 - (NSRect)hitRectForSegment:(NSInteger)segment { | |
| 158 NSRect rect = NSMakeRect(0, kTabStripHeight - kTabHeight, | |
| 159 [self widthForSegment:segment], kTabHeight); | |
| 160 for (NSInteger i = 0; i < segment; ++i) { | |
| 161 rect.origin.x += [self widthForSegment:i]; | |
| 162 } | |
| 163 int xAdjust = (segment == 0) ? kTabStripXPadding : 0; | |
|
Robert Sesek
2012/08/09 14:44:00
nit no () around ternary
Patrick Dubroy
2012/08/09 15:33:19
Done.
| |
| 164 rect.size.width = [self widthForSegment:segment] - kTabSpacing - xAdjust; | |
| 165 rect.origin.x += kTabSpacing / 2 + xAdjust; | |
| 166 | |
| 167 return rect; | |
| 168 } | |
| 169 | |
| 170 - (void)drawSegment:(NSInteger)segment | |
| 171 inFrame:(NSRect)frame | |
| 172 withView:(NSView*)controlView { | |
| 173 // Call the superclass to draw the label, adjusting the rectangle so that | |
| 174 // the label appears centered in the tab. | |
| 175 if (segment == 0) { | |
| 176 frame.origin.x += kTabStripXPadding / 2; | |
| 177 frame.size.width -= kTabStripXPadding; | |
| 178 } | |
| 179 frame.origin.y += kTabLabelTopPadding; | |
| 180 frame.size.height -= kTabLabelTopPadding; | |
| 181 [super drawSegment:segment inFrame:frame withView:controlView]; | |
| 182 } | |
| 183 | |
| 184 // Override the default tracking behavior to only respond to clicks inside the | |
| 185 // visual borders of the tab. | |
| 186 - (BOOL)startTrackingAt:(NSPoint)startPoint inView:(NSView *)controlView { | |
| 187 NSInteger segmentCount = [self segmentCount]; | |
| 188 for (NSInteger i = 0; i < segmentCount; ++i) { | |
| 189 if (NSPointInRect(startPoint, [self hitRectForSegment:i])) | |
| 190 return YES; | |
| 191 } | |
| 192 return NO; | |
| 193 } | |
| 194 | |
| 195 @end | |
| 196 | |
| 76 @implementation WebsiteSettingsBubbleController | 197 @implementation WebsiteSettingsBubbleController |
| 77 | 198 |
| 78 - (id)initWithParentWindow:(NSWindow*)parentWindow | 199 - (id)initWithParentWindow:(NSWindow*)parentWindow |
| 79 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge { | 200 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge { |
| 80 DCHECK(parentWindow); | 201 DCHECK(parentWindow); |
| 81 | 202 |
| 82 // Use an arbitrary height; it will be changed in performLayout. | 203 // Use an arbitrary height; it will be changed in performLayout. |
| 83 NSRect contentRect = NSMakeRect(0, 0, kWindowWidth, 1); | 204 NSRect contentRect = NSMakeRect(0, 0, kWindowWidth, 1); |
| 84 // Create an empty window into which content is placed. | 205 // Create an empty window into which content is placed. |
| 85 scoped_nsobject<InfoBubbleWindow> window( | 206 scoped_nsobject<InfoBubbleWindow> window( |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 126 | 247 |
| 127 // Create a text field to identity status (e.g. verified, not verified). | 248 // Create a text field to identity status (e.g. verified, not verified). |
| 128 identityStatusField_ = [self addText:string16() | 249 identityStatusField_ = [self addText:string16() |
| 129 withSize:[NSFont smallSystemFontSize] | 250 withSize:[NSFont smallSystemFontSize] |
| 130 bold:NO | 251 bold:NO |
| 131 toView:contentView_ | 252 toView:contentView_ |
| 132 atPoint:controlOrigin]; | 253 atPoint:controlOrigin]; |
| 133 | 254 |
| 134 // Create the tab view and its two tabs. | 255 // Create the tab view and its two tabs. |
| 135 | 256 |
| 257 NSRect initialFrame = NSMakeRect(0, 0, kWindowWidth, kTabStripHeight); | |
| 258 segmentedControl_.reset( | |
| 259 [[NSSegmentedControl alloc] initWithFrame:initialFrame]); | |
| 260 [segmentedControl_ setCell:[[WebsiteSettingsTabSegmentedCell alloc] init]]; | |
|
Robert Sesek
2012/08/09 14:44:00
This will leak the cell.
Patrick Dubroy
2012/08/09 15:33:19
Fixed.
| |
| 261 [segmentedControl_ setSegmentCount:2]; | |
| 262 [segmentedControl_ setTarget:self]; | |
| 263 [segmentedControl_ setAction:@selector(tabSelected:)]; | |
|
Robert Sesek
2012/08/09 14:44:01
nit: blank line after
Patrick Dubroy
2012/08/09 15:33:19
Done.
| |
| 264 NSFont* smallSystemFont = | |
| 265 [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; | |
| 266 NSDictionary* textAttributes = | |
| 267 [NSDictionary dictionaryWithObject:smallSystemFont | |
| 268 forKey:NSFontAttributeName]; | |
| 269 | |
| 270 // Create the "Permissions" tab. | |
| 271 NSString* label = l10n_util::GetNSString( | |
| 272 IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS); | |
| 273 NSSize textSize = [label sizeWithAttributes:textAttributes]; | |
| 274 CGFloat tabWidth = textSize.width + 2 * kTabLabelXPadding; | |
| 275 [segmentedControl_ setLabel:label forSegment:0]; | |
| 276 [segmentedControl_ setWidth:tabWidth + kTabStripXPadding forSegment:0]; | |
| 277 | |
| 278 // Create the "Connection" tab. | |
| 279 label = l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION); | |
| 280 textSize = [label sizeWithAttributes:textAttributes]; | |
| 281 [segmentedControl_ setLabel:label forSegment:1]; | |
| 282 | |
| 283 // Make both tabs the width of the widest. The first segment has some | |
| 284 // additional padding that is not part of the tab. | |
|
Robert Sesek
2012/08/09 14:44:01
Why?
Patrick Dubroy
2012/08/09 15:33:19
Changed the comment to explain.
| |
| 285 tabWidth = std::max(tabWidth, | |
| 286 textSize.width + 2 * kTabLabelXPadding); | |
| 287 [segmentedControl_ setWidth:tabWidth + kTabStripXPadding forSegment:0]; | |
| 288 [segmentedControl_ setWidth:tabWidth forSegment:1]; | |
| 289 | |
| 290 [segmentedControl_ setFont:smallSystemFont]; | |
| 291 [segmentedControl_ setSelectedSegment:0]; | |
| 292 [contentView_ addSubview:segmentedControl_]; | |
| 293 | |
| 136 NSRect tabFrame = NSMakeRect(0, 0, kWindowWidth, 300); | 294 NSRect tabFrame = NSMakeRect(0, 0, kWindowWidth, 300); |
| 137 tabView_.reset([[NSTabView alloc] initWithFrame:tabFrame]); | 295 tabView_.reset([[NSTabView alloc] initWithFrame:tabFrame]); |
| 138 [tabView_ setTabViewType:NSTopTabsBezelBorder]; | 296 [tabView_ setTabViewType:NSNoTabsNoBorder]; |
| 297 [tabView_ setDrawsBackground:NO]; | |
| 139 [tabView_ setControlSize:NSSmallControlSize]; | 298 [tabView_ setControlSize:NSSmallControlSize]; |
| 140 [tabView_ setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; | |
| 141 [contentView_ addSubview:tabView_.get()]; | 299 [contentView_ addSubview:tabView_.get()]; |
| 142 | 300 |
| 143 permissionsContentView_ = [self addPermissionsTabToTabView:tabView_]; | 301 permissionsContentView_ = [self addPermissionsTabToTabView:tabView_]; |
| 144 [self addConnectionTabToTabView:tabView_]; | 302 [self addConnectionTabToTabView:tabView_]; |
| 145 | 303 |
| 146 // Replace the window's content. | 304 // Replace the window's content. |
| 147 [[[self window] contentView] setSubviews: | 305 [[[self window] contentView] setSubviews: |
| 148 [NSArray arrayWithObject:contentView_.get()]]; | 306 [NSArray arrayWithObject:contentView_.get()]]; |
| 149 | 307 |
| 150 [self performLayout]; | 308 [self performLayout]; |
| 151 } | 309 } |
| 152 | 310 |
| 153 // Create the contents of the Permissions tab and add it to the given tab view. | 311 // Create the contents of the Permissions tab and add it to the given tab view. |
| 154 // Returns a weak reference to the tab view item's view. | 312 // Returns a weak reference to the tab view item's view. |
| 155 - (NSView*)addPermissionsTabToTabView:(NSTabView*)tabView { | 313 - (NSView*)addPermissionsTabToTabView:(NSTabView*)tabView { |
| 156 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]); | 314 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]); |
| 157 [item setLabel: | |
| 158 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS)]; | |
| 159 [tabView_ addTabViewItem:item.get()]; | 315 [tabView_ addTabViewItem:item.get()]; |
| 160 scoped_nsobject<NSView> contentView([[WebsiteSettingsContentView alloc] | 316 scoped_nsobject<NSView> contentView([[WebsiteSettingsContentView alloc] |
| 161 initWithFrame:[tabView_ contentRect]]); | 317 initWithFrame:[tabView_ contentRect]]); |
| 162 [item setView:contentView.get()]; | 318 [item setView:contentView.get()]; |
| 163 return contentView.get(); | 319 return contentView.get(); |
| 164 } | 320 } |
| 165 | 321 |
| 166 // Create the contents of the Connection tab and add it to the given tab view. | 322 // Create the contents of the Connection tab and add it to the given tab view. |
| 167 // Returns a weak reference to the tab view item's view. | 323 // Returns a weak reference to the tab view item's view. |
| 168 - (NSView*)addConnectionTabToTabView:(NSTabView*)tabView { | 324 - (NSView*)addConnectionTabToTabView:(NSTabView*)tabView { |
| 169 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]); | 325 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]); |
| 170 [item setLabel: | |
| 171 l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION)]; | |
| 172 | |
| 173 scoped_nsobject<NSView> contentView([[WebsiteSettingsContentView alloc] | 326 scoped_nsobject<NSView> contentView([[WebsiteSettingsContentView alloc] |
| 174 initWithFrame:[tabView_ contentRect]]); | 327 initWithFrame:[tabView_ contentRect]]); |
| 175 | 328 |
| 176 // Place all the text at the same position. It will be adjusted in | 329 // Place all the text at the same position. It will be adjusted in |
| 177 // performLayout. | 330 // performLayout. |
| 178 NSPoint textPosition = NSMakePoint( | 331 NSPoint textPosition = NSMakePoint( |
| 179 kTabViewContentsPadding + kImageSize + kImageSpacing, | 332 kTabViewContentsPadding + kImageSize + kImageSpacing, |
| 180 kTabViewContentsPadding); | 333 kTabViewContentsPadding); |
| 181 | 334 |
| 182 identityStatusIcon_ = | 335 identityStatusIcon_ = |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 260 | 413 |
| 261 // Lay out the last visit section. | 414 // Lay out the last visit section. |
| 262 [self setYPositionOfView:firstVisitIcon_ to:yPos]; | 415 [self setYPositionOfView:firstVisitIcon_ to:yPos]; |
| 263 [self sizeTextFieldHeightToFit:firstVisitHeaderField_]; | 416 [self sizeTextFieldHeightToFit:firstVisitHeaderField_]; |
| 264 yPos = [self setYPositionOfView:firstVisitHeaderField_ to:yPos]; | 417 yPos = [self setYPositionOfView:firstVisitHeaderField_ to:yPos]; |
| 265 yPos += kHeadlineSpacing; | 418 yPos += kHeadlineSpacing; |
| 266 [self sizeTextFieldHeightToFit:firstVisitDescriptionField_]; | 419 [self sizeTextFieldHeightToFit:firstVisitDescriptionField_]; |
| 267 [self setYPositionOfView:firstVisitDescriptionField_ to:yPos]; | 420 [self setYPositionOfView:firstVisitDescriptionField_ to:yPos]; |
| 268 | 421 |
| 269 // Adjust the tab view size and place it below the identity status. | 422 // Adjust the tab view size and place it below the identity status. |
| 423 | |
| 424 NSRect segmentedControlFrame = [segmentedControl_ frame]; | |
| 425 segmentedControlFrame.origin.y = | |
| 426 NSMaxY([identityStatusField_ frame]); | |
| 427 [segmentedControl_ setFrame:segmentedControlFrame]; | |
| 428 | |
| 270 NSRect tabViewFrame = [tabView_ frame]; | 429 NSRect tabViewFrame = [tabView_ frame]; |
| 271 tabViewFrame.origin.y = | 430 tabViewFrame.origin.y = NSMaxY(segmentedControlFrame); |
| 272 NSMaxY([identityStatusField_ frame]) + kVerticalSpacing; | |
| 273 | 431 |
| 274 CGFloat connectionTabHeight = std::max( | 432 CGFloat connectionTabHeight = std::max( |
| 275 NSMaxY([firstVisitDescriptionField_ frame]), | 433 NSMaxY([firstVisitDescriptionField_ frame]), |
| 276 NSMaxY([firstVisitIcon_ frame ])); | 434 NSMaxY([firstVisitIcon_ frame ])); |
| 277 connectionTabHeight += kVerticalSpacing; | 435 connectionTabHeight += kVerticalSpacing; |
| 278 | 436 |
| 279 CGFloat tabContentHeight = std::max(connectionTabHeight, | 437 CGFloat tabContentHeight = std::max(connectionTabHeight, |
| 280 permissionsTabHeight_); | 438 permissionsTabHeight_); |
| 281 tabViewFrame.size.height = tabContentHeight + | 439 tabViewFrame.size.height = tabContentHeight + |
| 282 NSHeight(tabViewFrame) - NSHeight([tabView_ contentRect]); | 440 NSHeight(tabViewFrame) - NSHeight([tabView_ contentRect]); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 462 | 620 |
| 463 [button setAction:@selector(permissionValueChanged:)]; | 621 [button setAction:@selector(permissionValueChanged:)]; |
| 464 [button setTarget:self]; | 622 [button setTarget:self]; |
| 465 | 623 |
| 466 [self setTitleOfButton:button]; | 624 [self setTitleOfButton:button]; |
| 467 | 625 |
| 468 [view addSubview:button.get()]; | 626 [view addSubview:button.get()]; |
| 469 return button.get(); | 627 return button.get(); |
| 470 } | 628 } |
| 471 | 629 |
| 630 - (void)tabSelected:(id)sender { | |
| 631 [tabView_ selectTabViewItemAtIndex:[segmentedControl_ selectedSegment]]; | |
| 632 } | |
| 633 | |
| 472 // Handler for the permission-changing menus. | 634 // Handler for the permission-changing menus. |
| 473 - (void)permissionValueChanged:(id)sender { | 635 - (void)permissionValueChanged:(id)sender { |
| 474 DCHECK([sender isKindOfClass:[NSPopUpButton class]]); | 636 DCHECK([sender isKindOfClass:[NSPopUpButton class]]); |
| 475 NSPopUpButton* button = static_cast<NSPopUpButton*>(sender); | 637 NSPopUpButton* button = static_cast<NSPopUpButton*>(sender); |
| 476 ContentSettingsType type = static_cast<ContentSettingsType>([button tag]); | 638 ContentSettingsType type = static_cast<ContentSettingsType>([button tag]); |
| 477 ContentSetting newSetting = [self contentSettingForButton:button]; | 639 ContentSetting newSetting = [self contentSettingForButton:button]; |
| 478 | 640 |
| 479 [self setTitleOfButton:button]; | 641 [self setTitleOfButton:button]; |
| 480 if (presenter_.get()) | 642 if (presenter_.get()) |
| 481 presenter_->OnSitePermissionChanged(type, newSetting); | 643 presenter_->OnSitePermissionChanged(type, newSetting); |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 611 } | 773 } |
| 612 | 774 |
| 613 void WebsiteSettingsUIBridge::SetIdentityInfo( | 775 void WebsiteSettingsUIBridge::SetIdentityInfo( |
| 614 const WebsiteSettingsUI::IdentityInfo& identity_info) { | 776 const WebsiteSettingsUI::IdentityInfo& identity_info) { |
| 615 [bubble_controller_ setIdentityInfo:identity_info]; | 777 [bubble_controller_ setIdentityInfo:identity_info]; |
| 616 } | 778 } |
| 617 | 779 |
| 618 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) { | 780 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) { |
| 619 [bubble_controller_ setFirstVisit:first_visit]; | 781 [bubble_controller_ setFirstVisit:first_visit]; |
| 620 } | 782 } |
| OLD | NEW |