| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/content_settings_dialog_controller.h" | 5 #import "chrome/browser/cocoa/content_settings_dialog_controller.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 10 #include "base/mac_util.h" | 10 #include "base/mac_util.h" |
| 11 #include "chrome/browser/browser.h" | 11 #include "chrome/browser/browser.h" |
| 12 #include "chrome/browser/browser_window.h" | 12 #include "chrome/browser/browser_window.h" |
| 13 #import "chrome/browser/cocoa/content_exceptions_window_controller.h" | 13 #import "chrome/browser/cocoa/content_exceptions_window_controller.h" |
| 14 #import "chrome/browser/cocoa/cookies_window_controller.h" | 14 #import "chrome/browser/cocoa/cookies_window_controller.h" |
| 15 #import "chrome/browser/cocoa/simple_content_exceptions_window_controller.h" | 15 #import "chrome/browser/cocoa/simple_content_exceptions_window_controller.h" |
| 16 #import "chrome/browser/cocoa/l10n_util.h" | 16 #import "chrome/browser/cocoa/l10n_util.h" |
| 17 #import "chrome/browser/cocoa/tab_view_picker_table.h" |
| 17 #import "chrome/browser/geolocation/geolocation_content_settings_map.h" | 18 #import "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 18 #import "chrome/browser/geolocation/geolocation_exceptions_table_model.h" | 19 #import "chrome/browser/geolocation/geolocation_exceptions_table_model.h" |
| 19 #import "chrome/browser/host_content_settings_map.h" | 20 #import "chrome/browser/host_content_settings_map.h" |
| 20 #import "chrome/browser/notifications/desktop_notification_service.h" | 21 #import "chrome/browser/notifications/desktop_notification_service.h" |
| 21 #import "chrome/browser/notifications/notification_exceptions_table_model.h" | 22 #import "chrome/browser/notifications/notification_exceptions_table_model.h" |
| 22 #include "chrome/browser/pref_service.h" | 23 #include "chrome/browser/pref_service.h" |
| 23 #include "chrome/browser/profile.h" | 24 #include "chrome/browser/profile.h" |
| 24 #include "chrome/common/notification_service.h" | 25 #include "chrome/common/notification_service.h" |
| 25 #include "chrome/common/pref_names.h" | 26 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 27 #include "grit/locale_settings.h" | 28 #include "grit/locale_settings.h" |
| 29 #include "grit/generated_resources.h" |
| 28 | 30 |
| 29 namespace { | 31 namespace { |
| 30 | 32 |
| 31 // Stores the currently visible content settings dialog, if any. | 33 // Stores the currently visible content settings dialog, if any. |
| 32 ContentSettingsDialogController* g_instance = nil; | 34 ContentSettingsDialogController* g_instance = nil; |
| 33 | 35 |
| 34 } // namespace | 36 } // namespace |
| 35 | 37 |
| 36 | 38 |
| 37 @interface ContentSettingsDialogController(Private) | 39 @interface ContentSettingsDialogController(Private) |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 163 |
| 162 - (void)closeExceptionsSheet { | 164 - (void)closeExceptionsSheet { |
| 163 NSWindow* attachedSheet = [[self window] attachedSheet]; | 165 NSWindow* attachedSheet = [[self window] attachedSheet]; |
| 164 if (attachedSheet) { | 166 if (attachedSheet) { |
| 165 [NSApp endSheet:attachedSheet]; | 167 [NSApp endSheet:attachedSheet]; |
| 166 } | 168 } |
| 167 } | 169 } |
| 168 | 170 |
| 169 - (void)awakeFromNib { | 171 - (void)awakeFromNib { |
| 170 DCHECK([self window]); | 172 DCHECK([self window]); |
| 173 DCHECK(tabView_); |
| 174 DCHECK(tabViewPicker_); |
| 171 DCHECK_EQ(self, [[self window] delegate]); | 175 DCHECK_EQ(self, [[self window] delegate]); |
| 172 | 176 |
| 173 // Adapt views to potentially long localized strings. | 177 // Adapt views to potentially long localized strings. |
| 174 CGFloat windowDelta = 0; | 178 CGFloat windowDelta = 0; |
| 175 for (NSTabViewItem* tab in [tabView_ tabViewItems]) { | 179 for (NSTabViewItem* tab in [tabView_ tabViewItems]) { |
| 176 NSArray* subviews = [[tab view] subviews]; | 180 NSArray* subviews = [[tab view] subviews]; |
| 177 windowDelta = MAX(windowDelta, | 181 windowDelta = MAX(windowDelta, |
| 178 cocoa_l10n_util::VerticallyReflowGroup(subviews)); | 182 cocoa_l10n_util::VerticallyReflowGroup(subviews)); |
| 179 | 183 |
| 180 for (NSView* view in subviews) { | 184 for (NSView* view in subviews) { |
| 181 // Since the tab pane is in a horizontal resizer in IB, it's convenient | 185 // Since the tab pane is in a horizontal resizer in IB, it's convenient |
| 182 // to give all the subviews flexible width so that their sizes are | 186 // to give all the subviews flexible width so that their sizes are |
| 183 // autoupdated in IB. However, in chrome, the subviews shouldn't have | 187 // autoupdated in IB. However, in chrome, the subviews shouldn't have |
| 184 // flexible widths as this looks weird. | 188 // flexible widths as this looks weird. |
| 185 [view setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin]; | 189 [view setAutoresizingMask:NSViewMaxXMargin | NSViewMinYMargin]; |
| 186 } | 190 } |
| 187 } | 191 } |
| 188 | 192 |
| 193 NSString* label = |
| 194 l10n_util::GetNSStringWithFixup(IDS_CONTENT_SETTINGS_FEATURES_LABEL); |
| 195 label = [label stringByReplacingOccurrencesOfString:@":" withString:@""]; |
| 196 [tabViewPicker_ setHeading:label]; |
| 197 |
| 189 NSRect frame = [[self window] frame]; | 198 NSRect frame = [[self window] frame]; |
| 190 frame.origin.y -= windowDelta; | 199 frame.origin.y -= windowDelta; |
| 191 frame.size.height += windowDelta; | 200 frame.size.height += windowDelta; |
| 192 [[self window] setFrame:frame display:NO]; | 201 [[self window] setFrame:frame display:NO]; |
| 193 } | 202 } |
| 194 | 203 |
| 195 // NSWindowDelegate method. | 204 // NSWindowDelegate method. |
| 196 - (void)windowWillClose:(NSNotification*)notification { | 205 - (void)windowWillClose:(NSNotification*)notification { |
| 197 [self autorelease]; | 206 [self autorelease]; |
| 198 g_instance = nil; | 207 g_instance = nil; |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 [self willChangeValueForKey:@"geolocationSettingIndex"]; | 519 [self willChangeValueForKey:@"geolocationSettingIndex"]; |
| 511 [self didChangeValueForKey:@"geolocationSettingIndex"]; | 520 [self didChangeValueForKey:@"geolocationSettingIndex"]; |
| 512 } | 521 } |
| 513 if (*prefName == prefs::kDesktopNotificationDefaultContentSetting) { | 522 if (*prefName == prefs::kDesktopNotificationDefaultContentSetting) { |
| 514 [self willChangeValueForKey:@"notificationsSettingIndex"]; | 523 [self willChangeValueForKey:@"notificationsSettingIndex"]; |
| 515 [self didChangeValueForKey:@"notificationsSettingIndex"]; | 524 [self didChangeValueForKey:@"notificationsSettingIndex"]; |
| 516 } | 525 } |
| 517 } | 526 } |
| 518 | 527 |
| 519 @end | 528 @end |
| OLD | NEW |