Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #import <Cocoa/Cocoa.h> | |
| 6 | |
| 7 #import "chrome/browser/cocoa/content_settings_dialog_controller.h" | |
|
viettrungluu
2010/02/22 00:57:40
First, I say! First!
| |
| 8 | |
| 9 #include "base/mac_util.h" | |
| 10 #import "chrome/browser/cocoa/cookies_window_controller.h" | |
| 11 #include "chrome/browser/profile.h" | |
| 12 #include "chrome/common/pref_names.h" | |
| 13 | |
| 14 | |
| 15 // Stores the currently visible content settings dialog, if any. | |
| 16 static ContentSettingsDialogController* g_instance = nil; | |
|
viettrungluu
2010/02/22 00:57:40
We're mostly now putting stuff in anonymous namesp
| |
| 17 | |
| 18 | |
| 19 @interface ContentSettingsDialogController(Private) | |
| 20 - (id)initWithProfile:(Profile*)profile; | |
| 21 @end | |
| 22 | |
| 23 | |
| 24 @implementation ContentSettingsDialogController | |
| 25 | |
| 26 +(id)showContentSettingsForType:(ContentSettingsType)settingsType | |
| 27 profile:(Profile*)profile { | |
| 28 profile = profile->GetOriginalProfile(); | |
| 29 if (!g_instance) | |
| 30 g_instance = [[self alloc] initWithProfile:profile]; | |
| 31 | |
| 32 // The code doesn't expect multiple profiles. Check that support for that | |
| 33 // hasn't been added. | |
| 34 DCHECK(g_instance->profile_ == profile); | |
| 35 | |
| 36 // Select desired tab. | |
| 37 if (settingsType == CONTENT_SETTINGS_TYPE_DEFAULT) { | |
| 38 // Remember the last visited page from local state. | |
| 39 settingsType = static_cast<ContentSettingsType>( | |
| 40 g_instance->lastSelectedTab_.GetValue()); | |
|
viettrungluu
2010/02/22 00:57:40
You should validate that settingsType contains a v
| |
| 41 if (settingsType == CONTENT_SETTINGS_TYPE_DEFAULT) | |
| 42 settingsType = CONTENT_SETTINGS_TYPE_COOKIES; | |
| 43 } | |
| 44 // TODO(thakis): Actually select desired tab. | |
| 45 | |
| 46 [g_instance showWindow:nil]; | |
| 47 return g_instance; | |
| 48 } | |
| 49 | |
| 50 - (id)initWithProfile:(Profile*)profile { | |
| 51 DCHECK(profile); | |
| 52 NSString* nibpath = [mac_util::MainAppBundle() | |
|
viettrungluu
2010/02/22 00:57:40
I'd prefer it if you just broke the line after the
| |
| 53 pathForResource:@"ContentSettings" | |
| 54 ofType:@"nib"]; | |
| 55 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { | |
| 56 profile_ = profile; | |
| 57 | |
| 58 // We don't need to observe changes in this value. | |
| 59 lastSelectedTab_.Init(prefs::kContentSettingsWindowLastTabIndex, | |
| 60 profile->GetPrefs(), NULL); | |
| 61 } | |
| 62 return self; | |
| 63 } | |
| 64 | |
| 65 - (void)windowWillClose:(NSNotification*)notification { | |
| 66 [self autorelease]; | |
| 67 g_instance = nil; | |
| 68 } | |
| 69 | |
| 70 // Shows the cookies controller. | |
| 71 - (IBAction)showCookies:(id)sender { | |
| 72 // The controller will clean itself up. | |
|
viettrungluu
2010/02/22 00:57:40
You should be a little clearer in what this means.
| |
| 73 BrowsingDataDatabaseHelper* databaseHelper = | |
| 74 new BrowsingDataDatabaseHelper(profile_); | |
| 75 BrowsingDataLocalStorageHelper* storageHelper = | |
| 76 new BrowsingDataLocalStorageHelper(profile_); | |
| 77 CookiesWindowController* controller = | |
| 78 [[CookiesWindowController alloc] initWithProfile:profile_ | |
| 79 databaseHelper:databaseHelper | |
| 80 storageHelper:storageHelper]; | |
| 81 [controller attachSheetTo:[self window]]; | |
| 82 } | |
| 83 | |
| 84 @end | |
| OLD | NEW |