Chromium Code Reviews| Index: chrome/browser/cocoa/content_settings_dialog_controller.mm |
| diff --git a/chrome/browser/cocoa/content_settings_dialog_controller.mm b/chrome/browser/cocoa/content_settings_dialog_controller.mm |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..00862b6c8d1d52460edcf3247b3fb28afe579cc7 |
| --- /dev/null |
| +++ b/chrome/browser/cocoa/content_settings_dialog_controller.mm |
| @@ -0,0 +1,84 @@ |
| +// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#import <Cocoa/Cocoa.h> |
| + |
| +#import "chrome/browser/cocoa/content_settings_dialog_controller.h" |
|
viettrungluu
2010/02/22 00:57:40
First, I say! First!
|
| + |
| +#include "base/mac_util.h" |
| +#import "chrome/browser/cocoa/cookies_window_controller.h" |
| +#include "chrome/browser/profile.h" |
| +#include "chrome/common/pref_names.h" |
| + |
| + |
| +// Stores the currently visible content settings dialog, if any. |
| +static ContentSettingsDialogController* g_instance = nil; |
|
viettrungluu
2010/02/22 00:57:40
We're mostly now putting stuff in anonymous namesp
|
| + |
| + |
| +@interface ContentSettingsDialogController(Private) |
| +- (id)initWithProfile:(Profile*)profile; |
| +@end |
| + |
| + |
| +@implementation ContentSettingsDialogController |
| + |
| ++(id)showContentSettingsForType:(ContentSettingsType)settingsType |
| + profile:(Profile*)profile { |
| + profile = profile->GetOriginalProfile(); |
| + if (!g_instance) |
| + g_instance = [[self alloc] initWithProfile:profile]; |
| + |
| + // The code doesn't expect multiple profiles. Check that support for that |
| + // hasn't been added. |
| + DCHECK(g_instance->profile_ == profile); |
| + |
| + // Select desired tab. |
| + if (settingsType == CONTENT_SETTINGS_TYPE_DEFAULT) { |
| + // Remember the last visited page from local state. |
| + settingsType = static_cast<ContentSettingsType>( |
| + g_instance->lastSelectedTab_.GetValue()); |
|
viettrungluu
2010/02/22 00:57:40
You should validate that settingsType contains a v
|
| + if (settingsType == CONTENT_SETTINGS_TYPE_DEFAULT) |
| + settingsType = CONTENT_SETTINGS_TYPE_COOKIES; |
| + } |
| + // TODO(thakis): Actually select desired tab. |
| + |
| + [g_instance showWindow:nil]; |
| + return g_instance; |
| +} |
| + |
| +- (id)initWithProfile:(Profile*)profile { |
| + DCHECK(profile); |
| + NSString* nibpath = [mac_util::MainAppBundle() |
|
viettrungluu
2010/02/22 00:57:40
I'd prefer it if you just broke the line after the
|
| + pathForResource:@"ContentSettings" |
| + ofType:@"nib"]; |
| + if ((self = [super initWithWindowNibPath:nibpath owner:self])) { |
| + profile_ = profile; |
| + |
| + // We don't need to observe changes in this value. |
| + lastSelectedTab_.Init(prefs::kContentSettingsWindowLastTabIndex, |
| + profile->GetPrefs(), NULL); |
| + } |
| + return self; |
| +} |
| + |
| +- (void)windowWillClose:(NSNotification*)notification { |
| + [self autorelease]; |
| + g_instance = nil; |
| +} |
| + |
| +// Shows the cookies controller. |
| +- (IBAction)showCookies:(id)sender { |
| + // The controller will clean itself up. |
|
viettrungluu
2010/02/22 00:57:40
You should be a little clearer in what this means.
|
| + BrowsingDataDatabaseHelper* databaseHelper = |
| + new BrowsingDataDatabaseHelper(profile_); |
| + BrowsingDataLocalStorageHelper* storageHelper = |
| + new BrowsingDataLocalStorageHelper(profile_); |
| + CookiesWindowController* controller = |
| + [[CookiesWindowController alloc] initWithProfile:profile_ |
| + databaseHelper:databaseHelper |
| + storageHelper:storageHelper]; |
| + [controller attachSheetTo:[self window]]; |
| +} |
| + |
| +@end |