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

Side by Side Diff: chrome/browser/cocoa/content_settings_dialog_controller.mm

Issue 3299020: Remove vestigial cookie/web app permissions prompting UI now that the async U... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 3 months 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
OLDNEW
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/command_line.h" 10 #include "base/command_line.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 // TODO(thakis): Autosave window pos. 119 // TODO(thakis): Autosave window pos.
120 120
121 [g_instance selectTab:settingsType]; 121 [g_instance selectTab:settingsType];
122 [g_instance showWindow:nil]; 122 [g_instance showWindow:nil];
123 [g_instance closeExceptionsSheet]; 123 [g_instance closeExceptionsSheet];
124 return g_instance; 124 return g_instance;
125 } 125 }
126 126
127 - (id)initWithProfile:(Profile*)profile { 127 - (id)initWithProfile:(Profile*)profile {
128 DCHECK(profile); 128 DCHECK(profile);
129 disableCookiePrompt_ = !CommandLine::ForCurrentProcess()->HasSwitch(
130 switches::kEnableCookiePrompt);
131 NSString* nibpath = 129 NSString* nibpath =
132 [mac_util::MainAppBundle() pathForResource:@"ContentSettings" 130 [mac_util::MainAppBundle() pathForResource:@"ContentSettings"
133 ofType:@"nib"]; 131 ofType:@"nib"];
134 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { 132 if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
135 profile_ = profile; 133 profile_ = profile;
136 134
137 observer_.reset( 135 observer_.reset(
138 new ContentSettingsDialogControllerInternal::PrefObserverBridge(self)); 136 new ContentSettingsDialogControllerInternal::PrefObserverBridge(self));
139 clearSiteDataOnExit_.Init(prefs::kClearSiteDataOnExit, 137 clearSiteDataOnExit_.Init(prefs::kClearSiteDataOnExit,
140 profile_->GetPrefs(), observer_.get()); 138 profile_->GetPrefs(), observer_.get());
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 [NSApp endSheet:attachedSheet]; 173 [NSApp endSheet:attachedSheet];
176 } 174 }
177 } 175 }
178 176
179 - (void)awakeFromNib { 177 - (void)awakeFromNib {
180 DCHECK([self window]); 178 DCHECK([self window]);
181 DCHECK(tabView_); 179 DCHECK(tabView_);
182 DCHECK(tabViewPicker_); 180 DCHECK(tabViewPicker_);
183 DCHECK_EQ(self, [[self window] delegate]); 181 DCHECK_EQ(self, [[self window] delegate]);
184 182
185 [tabView_ removeTabViewItem:[tabView_
186 tabViewItemAtIndex:disableCookiePrompt_ ? 0 : 1]];
187
188 // Adapt views to potentially long localized strings. 183 // Adapt views to potentially long localized strings.
189 CGFloat windowDelta = 0; 184 CGFloat windowDelta = 0;
190 for (NSTabViewItem* tab in [tabView_ tabViewItems]) { 185 for (NSTabViewItem* tab in [tabView_ tabViewItems]) {
191 NSArray* subviews = [[tab view] subviews]; 186 NSArray* subviews = [[tab view] subviews];
192 windowDelta = MAX(windowDelta, 187 windowDelta = MAX(windowDelta,
193 cocoa_l10n_util::VerticallyReflowGroup(subviews)); 188 cocoa_l10n_util::VerticallyReflowGroup(subviews));
194 189
195 for (NSView* view in subviews) { 190 for (NSView* view in subviews) {
196 // Since the tab pane is in a horizontal resizer in IB, it's convenient 191 // Since the tab pane is in a horizontal resizer in IB, it's convenient
197 // to give all the subviews flexible width so that their sizes are 192 // to give all the subviews flexible width so that their sizes are
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 lastSelectedTab_.SetValue(index); 231 lastSelectedTab_.SetValue(index);
237 } 232 }
238 233
239 // Let esc close the window. 234 // Let esc close the window.
240 - (void)cancel:(id)sender { 235 - (void)cancel:(id)sender {
241 [self close]; 236 [self close];
242 } 237 }
243 238
244 - (void)setCookieSettingIndex:(NSInteger)value { 239 - (void)setCookieSettingIndex:(NSInteger)value {
245 ContentSetting setting = CONTENT_SETTING_DEFAULT; 240 ContentSetting setting = CONTENT_SETTING_DEFAULT;
246 // If the cookie prompt is disabled, the radio button for "block" is at the
247 // position of the "ask" radio in the old dialog.
248 if (disableCookiePrompt_ && value == kCookieAskIndex)
249 value = kCookieDisabledIndex;
250 switch (value) { 241 switch (value) {
251 case kCookieEnabledIndex: setting = CONTENT_SETTING_ALLOW; break; 242 case kCookieEnabledIndex: setting = CONTENT_SETTING_ALLOW; break;
252 case kCookieAskIndex: setting = CONTENT_SETTING_ASK; break;
253 case kCookieDisabledIndex: setting = CONTENT_SETTING_BLOCK; break; 243 case kCookieDisabledIndex: setting = CONTENT_SETTING_BLOCK; break;
254 default: 244 default:
255 NOTREACHED(); 245 NOTREACHED();
256 } 246 }
257 ContentSettingsDialogControllerInternal::PrefObserverDisabler 247 ContentSettingsDialogControllerInternal::PrefObserverDisabler
258 disabler(observer_.get()); 248 disabler(observer_.get());
259 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( 249 profile_->GetHostContentSettingsMap()->SetDefaultContentSetting(
260 CONTENT_SETTINGS_TYPE_COOKIES, 250 CONTENT_SETTINGS_TYPE_COOKIES,
261 setting); 251 setting);
262 } 252 }
263 253
264 - (NSInteger)cookieSettingIndex { 254 - (NSInteger)cookieSettingIndex {
265 switch (profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( 255 switch (profile_->GetHostContentSettingsMap()->GetDefaultContentSetting(
266 CONTENT_SETTINGS_TYPE_COOKIES)) { 256 CONTENT_SETTINGS_TYPE_COOKIES)) {
267 case CONTENT_SETTING_ALLOW: return kCookieEnabledIndex; 257 case CONTENT_SETTING_ALLOW: return kCookieEnabledIndex;
268 case CONTENT_SETTING_ASK: return kCookieAskIndex; 258 case CONTENT_SETTING_BLOCK: return kCookieDisabledIndex;
269 // If the cookie prompt is disabled, the radio button for "block" is at the
270 // position of the "ask" radio in the old dialog.
271 case CONTENT_SETTING_BLOCK: return disableCookiePrompt_ ?
272 kCookieAskIndex :
273 kCookieDisabledIndex;
274 default: 259 default:
275 NOTREACHED(); 260 NOTREACHED();
276 return kCookieEnabledIndex; 261 return kCookieEnabledIndex;
277 } 262 }
278 } 263 }
279 264
280 - (BOOL)blockThirdPartyCookies { 265 - (BOOL)blockThirdPartyCookies {
281 HostContentSettingsMap* settingsMap = profile_->GetHostContentSettingsMap(); 266 HostContentSettingsMap* settingsMap = profile_->GetHostContentSettingsMap();
282 return settingsMap->BlockThirdPartyCookies(); 267 return settingsMap->BlockThirdPartyCookies();
283 } 268 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 [self willChangeValueForKey:@"geolocationSettingIndex"]; 560 [self willChangeValueForKey:@"geolocationSettingIndex"];
576 [self didChangeValueForKey:@"geolocationSettingIndex"]; 561 [self didChangeValueForKey:@"geolocationSettingIndex"];
577 } 562 }
578 if (*prefName == prefs::kDesktopNotificationDefaultContentSetting) { 563 if (*prefName == prefs::kDesktopNotificationDefaultContentSetting) {
579 [self willChangeValueForKey:@"notificationsSettingIndex"]; 564 [self willChangeValueForKey:@"notificationsSettingIndex"];
580 [self didChangeValueForKey:@"notificationsSettingIndex"]; 565 [self didChangeValueForKey:@"notificationsSettingIndex"];
581 } 566 }
582 } 567 }
583 568
584 @end 569 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698