diff options
author | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 06:54:09 +0000 |
---|---|---|
committer | danno@chromium.org <danno@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-12 06:54:09 +0000 |
commit | d0edf4e5adf877515ff49a59f63600fd88a25b36 (patch) | |
tree | ad789884b7918146fcbcddaf4f10284836ff3496 /chrome/browser/cocoa/cookie_details_view_controller.mm | |
parent | 5fed0f1c5195ded63dfadadeb93c0b1d006f1fb4 (diff) | |
download | chromium_src-d0edf4e5adf877515ff49a59f63600fd88a25b36.zip chromium_src-d0edf4e5adf877515ff49a59f63600fd88a25b36.tar.gz chromium_src-d0edf4e5adf877515ff49a59f63600fd88a25b36.tar.bz2 |
[Mac] augment modal cookie prompt on mac to include details pane
Added two new xibs. The first is a cookie info view that is shared between the tree that shows browser data and the cookie modal prompt to block accepting cookies. The second is a window to replace the NSAlert modal dialog for the cookie prompt. Modified cookie tree code and added cookie prompt code to use new xibs.
Changed "hidden" handling of cookie detail view to use bindings rather than explicit code.
TODOs for http://crbug.com/36948 not in this CL:
- changing the expiration for cookies isn't implemented
TEST=manually testing of modal cookie prompt, new unit tests
BUG=http://crbug.com/36948
Review URL: http://codereview.chromium.org/669127
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41408 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/cookie_details_view_controller.mm')
-rw-r--r-- | chrome/browser/cocoa/cookie_details_view_controller.mm | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/cookie_details_view_controller.mm b/chrome/browser/cocoa/cookie_details_view_controller.mm new file mode 100644 index 0000000..70da2a5 --- /dev/null +++ b/chrome/browser/cocoa/cookie_details_view_controller.mm @@ -0,0 +1,80 @@ +// 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 "chrome/browser/cocoa/cookie_details_view_controller.h" + +#include "app/l10n_util_mac.h" +#include "app/resource_bundle.h" +#import "base/mac_util.h" +#include "base/sys_string_conversions.h" +#import "chrome/browser/cocoa/cookie_tree_node.h" +#import "chrome/browser/cookie_modal_dialog.h" + +namespace { +static const int kMinimalLabelOffsetFromViewBottom = 20; +} + +#pragma mark View Controller + +@implementation CookieDetailsViewController + +- (id)init { + return [super initWithNibName:@"CookieDetailsView" + bundle:mac_util::MainAppBundle()]; +} + +- (void)awakeFromNib { + DCHECK(objectController_); +} + +// Finds and returns the y offset of the lowest-most non-hidden +// text field in the view. This is used to shrink the view +// appropriately so that it just fits its visible content. +- (void)getLowestLabelVerticalPosition:(NSView*)view + lowestLabelPosition:(float&)lowestLabelPosition { + if (![view isHidden]) { + if ([view isKindOfClass:[NSTextField class]]) { + NSRect frame = [view frame]; + if (frame.origin.y < lowestLabelPosition) { + lowestLabelPosition = frame.origin.y; + } + } + for (NSView* subview in [view subviews]) { + [self getLowestLabelVerticalPosition:subview + lowestLabelPosition:lowestLabelPosition]; + } + } +} + +- (void)setContentObject:(id)content { + [objectController_ setValue:content forKey:@"content"]; +} + +- (void)shrinkViewToFit { + // Adjust the information pane to be exactly the right size + // to hold the visible text information fields. + NSView* view = [self view]; + NSRect frame = [view frame]; + float lowestLabelPosition = frame.origin.y + frame.size.height; + [self getLowestLabelVerticalPosition:view + lowestLabelPosition:lowestLabelPosition]; + float verticalDelta = lowestLabelPosition - frame.origin.y - + kMinimalLabelOffsetFromViewBottom; + frame.origin.y += verticalDelta; + frame.size.height -= verticalDelta; + [[self view] setFrame:frame]; +} + +- (void)configureBindingsForTreeController:(NSTreeController*)treeController { + // There seems to be a bug in the binding logic that it's not possible + // to bind to the selection of the tree controller, the bind seems to + // require an additional path segment in the key, thus the use of + // selection.self rather than just selection below. + [objectController_ bind:@"contentObject" + toObject:treeController + withKeyPath:@"selection.self" + options:nil]; +} + +@end |