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/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #import "chrome/browser/ui/browser_dialogs.h" | 9 #import "chrome/browser/ui/browser_dialogs.h" |
| 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 10 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 toView:contentView_ | 338 toView:contentView_ |
| 339 atPoint:controlOrigin]; | 339 atPoint:controlOrigin]; |
| 340 | 340 |
| 341 // Create the tab view and its two tabs. | 341 // Create the tab view and its two tabs. |
| 342 | 342 |
| 343 NSRect initialFrame = NSMakeRect(0, 0, kWindowWidth, kTabStripHeight); | 343 NSRect initialFrame = NSMakeRect(0, 0, kWindowWidth, kTabStripHeight); |
| 344 segmentedControl_.reset( | 344 segmentedControl_.reset( |
| 345 [[NSSegmentedControl alloc] initWithFrame:initialFrame]); | 345 [[NSSegmentedControl alloc] initWithFrame:initialFrame]); |
| 346 [segmentedControl_ setCell: | 346 [segmentedControl_ setCell: |
| 347 [[[WebsiteSettingsTabSegmentedCell alloc] init] autorelease]]; | 347 [[[WebsiteSettingsTabSegmentedCell alloc] init] autorelease]]; |
| 348 [segmentedControl_ setSegmentCount:2]; | 348 [segmentedControl_ setSegmentCount:NUM_TAB_IDS]; |
| 349 [segmentedControl_ setTarget:self]; | 349 [segmentedControl_ setTarget:self]; |
| 350 [segmentedControl_ setAction:@selector(tabSelected:)]; | 350 [segmentedControl_ setAction:@selector(tabSelected:)]; |
| 351 | 351 |
| 352 NSFont* smallSystemFont = | 352 NSFont* smallSystemFont = |
| 353 [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; | 353 [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]; |
| 354 NSDictionary* textAttributes = | 354 NSDictionary* textAttributes = |
| 355 [NSDictionary dictionaryWithObject:smallSystemFont | 355 [NSDictionary dictionaryWithObject:smallSystemFont |
| 356 forKey:NSFontAttributeName]; | 356 forKey:NSFontAttributeName]; |
| 357 | 357 |
| 358 // Create the "Permissions" tab. | 358 // Create the "Permissions" tab. |
| 359 NSString* label = l10n_util::GetNSString( | 359 NSString* label = l10n_util::GetNSString( |
| 360 IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS); | 360 IDS_WEBSITE_SETTINGS_TAB_LABEL_PERMISSIONS); |
| 361 NSSize textSize = [label sizeWithAttributes:textAttributes]; | 361 NSSize textSize = [label sizeWithAttributes:textAttributes]; |
| 362 CGFloat tabWidth = textSize.width + 2 * kTabLabelXPadding; | 362 CGFloat tabWidth = textSize.width + 2 * kTabLabelXPadding; |
|
msw
2012/08/23 22:59:41
nit: the width determination code sux, but leave i
markusheintz_
2012/08/24 12:42:43
@Patrick: Is this something you want to fix in a f
Patrick Dubroy
2012/08/24 12:48:15
I don't understand what you mean. Isn't that what
msw
2012/08/24 18:56:40
Ah, don't worry about it, I'd just remove the firs
| |
| 363 [segmentedControl_ setLabel:label forSegment:0]; | 363 [segmentedControl_ setLabel:label forSegment:TAB_ID_PERMISSIONS]; |
| 364 [segmentedControl_ setWidth:tabWidth + kTabStripXPadding forSegment:0]; | 364 [segmentedControl_ setWidth:tabWidth + kTabStripXPadding |
| 365 forSegment:TAB_ID_PERMISSIONS]; | |
| 365 | 366 |
| 366 // Create the "Connection" tab. | 367 // Create the "Connection" tab. |
| 367 label = l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION); | 368 label = l10n_util::GetNSString(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION); |
| 368 textSize = [label sizeWithAttributes:textAttributes]; | 369 textSize = [label sizeWithAttributes:textAttributes]; |
| 369 [segmentedControl_ setLabel:label forSegment:1]; | 370 [segmentedControl_ setLabel:label forSegment:TAB_ID_CONNECTION]; |
| 370 | 371 |
| 371 // Make both tabs the width of the widest. The first segment has some | 372 // Make both tabs the width of the widest. The first segment has some |
| 372 // additional padding that is not part of the tab, which is used for drawing | 373 // additional padding that is not part of the tab, which is used for drawing |
| 373 // the background of the tab strip. | 374 // the background of the tab strip. |
| 374 tabWidth = std::max(tabWidth, | 375 tabWidth = std::max(tabWidth, |
| 375 textSize.width + 2 * kTabLabelXPadding); | 376 textSize.width + 2 * kTabLabelXPadding); |
| 376 [segmentedControl_ setWidth:tabWidth + kTabStripXPadding forSegment:0]; | 377 [segmentedControl_ setWidth:tabWidth + kTabStripXPadding |
| 377 [segmentedControl_ setWidth:tabWidth forSegment:1]; | 378 forSegment:TAB_ID_PERMISSIONS]; |
| 379 [segmentedControl_ setWidth:tabWidth forSegment:TAB_ID_CONNECTION]; | |
| 378 | 380 |
| 379 [segmentedControl_ setFont:smallSystemFont]; | 381 [segmentedControl_ setFont:smallSystemFont]; |
| 380 [segmentedControl_ setSelectedSegment:0]; | 382 [segmentedControl_ setSelectedSegment:0]; |
| 381 [contentView_ addSubview:segmentedControl_]; | 383 [contentView_ addSubview:segmentedControl_]; |
| 382 | 384 |
| 383 NSRect tabFrame = NSMakeRect(0, 0, kWindowWidth, 300); | 385 NSRect tabFrame = NSMakeRect(0, 0, kWindowWidth, 300); |
| 384 tabView_.reset([[NSTabView alloc] initWithFrame:tabFrame]); | 386 tabView_.reset([[NSTabView alloc] initWithFrame:tabFrame]); |
| 385 [tabView_ setTabViewType:NSNoTabsNoBorder]; | 387 [tabView_ setTabViewType:NSNoTabsNoBorder]; |
| 386 [tabView_ setDrawsBackground:NO]; | 388 [tabView_ setDrawsBackground:NO]; |
| 387 [tabView_ setControlSize:NSSmallControlSize]; | 389 [tabView_ setControlSize:NSSmallControlSize]; |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1034 } | 1036 } |
| 1035 | 1037 |
| 1036 void WebsiteSettingsUIBridge::SetPermissionInfo( | 1038 void WebsiteSettingsUIBridge::SetPermissionInfo( |
| 1037 const PermissionInfoList& permission_info_list) { | 1039 const PermissionInfoList& permission_info_list) { |
| 1038 [bubble_controller_ setPermissionInfo:permission_info_list]; | 1040 [bubble_controller_ setPermissionInfo:permission_info_list]; |
| 1039 } | 1041 } |
| 1040 | 1042 |
| 1041 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) { | 1043 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) { |
| 1042 [bubble_controller_ setFirstVisit:first_visit]; | 1044 [bubble_controller_ setFirstVisit:first_visit]; |
| 1043 } | 1045 } |
| 1046 | |
| 1047 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { | |
| 1048 // TODO(dubroy): Implement this method. | |
| 1049 } | |
| OLD | NEW |