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_exceptions_window_controller.h" | 5 #import "chrome/browser/cocoa/content_exceptions_window_controller.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.h" |
8 #include "app/table_model_observer.h" | 8 #include "app/table_model_observer.h" |
9 #import "base/mac_util.h" | 9 #import "base/mac_util.h" |
10 #import "base/scoped_nsobject.h" | 10 #import "base/scoped_nsobject.h" |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 case CONTENT_SETTINGS_TYPE_POPUPS: | 116 case CONTENT_SETTINGS_TYPE_POPUPS: |
117 return l10n_util::GetNSStringWithFixup(IDS_POPUP_EXCEPTION_TITLE); | 117 return l10n_util::GetNSStringWithFixup(IDS_POPUP_EXCEPTION_TITLE); |
118 default: | 118 default: |
119 NOTREACHED(); | 119 NOTREACHED(); |
120 } | 120 } |
121 return @""; | 121 return @""; |
122 } | 122 } |
123 | 123 |
124 const CGFloat kButtonBarHeight = 35.0; | 124 const CGFloat kButtonBarHeight = 35.0; |
125 | 125 |
126 // The settings shown in the combobox if showAsk_ is false; | 126 // The settings shown in the combobox if showSession_ is false; |
127 const ContentSetting kNoAskSettings[] = { CONTENT_SETTING_ALLOW, | 127 const ContentSetting kNoSessionSettings[] = { CONTENT_SETTING_ALLOW, |
128 CONTENT_SETTING_BLOCK }; | 128 CONTENT_SETTING_BLOCK }; |
129 | 129 |
130 // The settings shown in the combobox if showAsk_ is true; | 130 // The settings shown in the combobox if showSession_ is true; |
131 const ContentSetting kAskSettings[] = { CONTENT_SETTING_ALLOW, | 131 const ContentSetting kSessionSettings[] = { CONTENT_SETTING_ALLOW, |
132 CONTENT_SETTING_ASK, | 132 CONTENT_SETTING_SESSION_ONLY, |
133 CONTENT_SETTING_SESSION_ONLY, | 133 CONTENT_SETTING_BLOCK }; |
134 CONTENT_SETTING_BLOCK }; | |
135 | 134 |
136 } // namespace | 135 } // namespace |
137 | 136 |
138 //////////////////////////////////////////////////////////////////////////////// | 137 //////////////////////////////////////////////////////////////////////////////// |
139 // ContentExceptionsWindowController implementation | 138 // ContentExceptionsWindowController implementation |
140 | 139 |
141 static ContentExceptionsWindowController* | 140 static ContentExceptionsWindowController* |
142 g_exceptionWindows[CONTENT_SETTINGS_NUM_TYPES] = { nil }; | 141 g_exceptionWindows[CONTENT_SETTINGS_NUM_TYPES] = { nil }; |
143 | 142 |
144 @implementation ContentExceptionsWindowController | 143 @implementation ContentExceptionsWindowController |
(...skipping 16 matching lines...) Expand all Loading... |
161 otrSettingsMap:(HostContentSettingsMap*)otrSettingsMap { | 160 otrSettingsMap:(HostContentSettingsMap*)otrSettingsMap { |
162 NSString* nibpath = | 161 NSString* nibpath = |
163 [mac_util::MainAppBundle() pathForResource:@"ContentExceptionsWindow" | 162 [mac_util::MainAppBundle() pathForResource:@"ContentExceptionsWindow" |
164 ofType:@"nib"]; | 163 ofType:@"nib"]; |
165 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { | 164 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { |
166 settingsType_ = settingsType; | 165 settingsType_ = settingsType; |
167 settingsMap_ = settingsMap; | 166 settingsMap_ = settingsMap; |
168 otrSettingsMap_ = otrSettingsMap; | 167 otrSettingsMap_ = otrSettingsMap; |
169 model_.reset(new ContentExceptionsTableModel( | 168 model_.reset(new ContentExceptionsTableModel( |
170 settingsMap_, otrSettingsMap_, settingsType_)); | 169 settingsMap_, otrSettingsMap_, settingsType_)); |
171 showAsk_ = settingsType_ == CONTENT_SETTINGS_TYPE_COOKIES; | 170 showSession_ = settingsType_ == CONTENT_SETTINGS_TYPE_COOKIES; |
172 otrAllowed_ = otrSettingsMap != NULL; | 171 otrAllowed_ = otrSettingsMap != NULL; |
173 tableObserver_.reset(new UpdatingContentSettingsObserver(self)); | 172 tableObserver_.reset(new UpdatingContentSettingsObserver(self)); |
174 updatesEnabled_ = YES; | 173 updatesEnabled_ = YES; |
175 | 174 |
176 // TODO(thakis): autoremember window rect. | 175 // TODO(thakis): autoremember window rect. |
177 // TODO(thakis): sorting support. | 176 // TODO(thakis): sorting support. |
178 } | 177 } |
179 return self; | 178 return self; |
180 } | 179 } |
181 | 180 |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 | 486 |
488 // The model caches its data, meaning we need to recreate it on every change. | 487 // The model caches its data, meaning we need to recreate it on every change. |
489 model_.reset(new ContentExceptionsTableModel( | 488 model_.reset(new ContentExceptionsTableModel( |
490 settingsMap_, otrSettingsMap_, settingsType_)); | 489 settingsMap_, otrSettingsMap_, settingsType_)); |
491 | 490 |
492 [tableView_ reloadData]; | 491 [tableView_ reloadData]; |
493 [self adjustEditingButtons]; | 492 [self adjustEditingButtons]; |
494 } | 493 } |
495 | 494 |
496 - (size_t)menuItemCount { | 495 - (size_t)menuItemCount { |
497 return showAsk_ ? arraysize(kAskSettings) : arraysize(kNoAskSettings); | 496 return showSession_ ? |
| 497 arraysize(kSessionSettings) : arraysize(kNoSessionSettings); |
498 } | 498 } |
499 | 499 |
500 - (NSString*)titleForIndex:(size_t)index { | 500 - (NSString*)titleForIndex:(size_t)index { |
501 switch ([self settingForIndex:index]) { | 501 switch ([self settingForIndex:index]) { |
502 case CONTENT_SETTING_ALLOW: | 502 case CONTENT_SETTING_ALLOW: |
503 return l10n_util::GetNSStringWithFixup(IDS_EXCEPTIONS_ALLOW_BUTTON); | 503 return l10n_util::GetNSStringWithFixup(IDS_EXCEPTIONS_ALLOW_BUTTON); |
504 case CONTENT_SETTING_BLOCK: | 504 case CONTENT_SETTING_BLOCK: |
505 return l10n_util::GetNSStringWithFixup(IDS_EXCEPTIONS_BLOCK_BUTTON); | 505 return l10n_util::GetNSStringWithFixup(IDS_EXCEPTIONS_BLOCK_BUTTON); |
506 case CONTENT_SETTING_ASK: | |
507 return l10n_util::GetNSStringWithFixup(IDS_EXCEPTIONS_ASK_BUTTON); | |
508 case CONTENT_SETTING_SESSION_ONLY: | 506 case CONTENT_SETTING_SESSION_ONLY: |
509 return l10n_util::GetNSStringWithFixup( | 507 return l10n_util::GetNSStringWithFixup( |
510 IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); | 508 IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); |
511 default: | 509 default: |
512 NOTREACHED(); | 510 NOTREACHED(); |
513 } | 511 } |
514 return @""; | 512 return @""; |
515 } | 513 } |
516 | 514 |
517 - (ContentSetting)settingForIndex:(size_t)index { | 515 - (ContentSetting)settingForIndex:(size_t)index { |
518 return showAsk_ ? kAskSettings[index] : kNoAskSettings[index]; | 516 return showSession_ ? kSessionSettings[index] : kNoSessionSettings[index]; |
519 } | 517 } |
520 | 518 |
521 - (size_t)indexForSetting:(ContentSetting)setting { | 519 - (size_t)indexForSetting:(ContentSetting)setting { |
522 for (size_t i = 0; i < [self menuItemCount]; ++i) { | 520 for (size_t i = 0; i < [self menuItemCount]; ++i) { |
523 if ([self settingForIndex:i] == setting) | 521 if ([self settingForIndex:i] == setting) |
524 return i; | 522 return i; |
525 } | 523 } |
526 NOTREACHED(); | 524 NOTREACHED(); |
527 return 0; | 525 return 0; |
528 } | 526 } |
529 | 527 |
530 @end | 528 @end |
OLD | NEW |