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

Side by Side Diff: chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm

Issue 128673002: [Mac] Hook up the "Remove" button in the collected cookies dialog. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/ui/cocoa/content_settings/collected_cookies_mac.h" 5 #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/mac/bundle_locations.h" 9 #include "base/mac/bundle_locations.h"
10 #import "base/mac/mac_util.h"
11 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
12 #include "base/prefs/pref_service.h" 11 #include "base/prefs/pref_service.h"
13 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
14 #include "chrome/browser/browsing_data/browsing_data_appcache_helper.h"
15 #include "chrome/browser/browsing_data/browsing_data_cookie_helper.h"
16 #include "chrome/browser/browsing_data/browsing_data_database_helper.h"
17 #include "chrome/browser/browsing_data/browsing_data_file_system_helper.h"
18 #include "chrome/browser/browsing_data/browsing_data_indexed_db_helper.h"
19 #include "chrome/browser/browsing_data/browsing_data_local_storage_helper.h"
20 #include "chrome/browser/browsing_data/browsing_data_server_bound_cert_helper.h"
21 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
22 #include "chrome/browser/content_settings/cookie_settings.h" 14 #include "chrome/browser/content_settings/cookie_settings.h"
23 #include "chrome/browser/content_settings/local_shared_objects_container.h" 15 #include "chrome/browser/content_settings/local_shared_objects_container.h"
24 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 16 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
25 #include "chrome/browser/infobars/infobar_service.h" 17 #include "chrome/browser/infobars/infobar_service.h"
26 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/ui/browser_dialogs.h" 19 #include "chrome/browser/ui/browser_dialogs.h"
28 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" 20 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h"
29 #import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller .h" 21 #import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller .h"
30 #import "chrome/browser/ui/cocoa/vertical_gradient_view.h" 22 #import "chrome/browser/ui/cocoa/vertical_gradient_view.h"
31 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" 23 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h"
32 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
33 #include "content/public/browser/notification_details.h" 25 #include "content/public/browser/notification_details.h"
34 #include "content/public/browser/notification_source.h" 26 #include "content/public/browser/notification_source.h"
35 #include "content/public/browser/web_contents.h" 27 #include "content/public/browser/web_contents.h"
36 #include "content/public/browser/web_contents_view.h"
37 #include "grit/generated_resources.h" 28 #include "grit/generated_resources.h"
38 #include "grit/theme_resources.h" 29 #include "grit/theme_resources.h"
39 #include "third_party/apple_sample_code/ImageAndTextCell.h" 30 #include "third_party/apple_sample_code/ImageAndTextCell.h"
40 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h " 31 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMNSAnimation+Duration.h "
41 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h" 32 #import "third_party/google_toolbox_for_mac/src/AppKit/GTMUILocalizerAndLayoutTw eaker.h"
42 #include "ui/base/l10n/l10n_util_mac.h" 33 #include "ui/base/l10n/l10n_util_mac.h"
43 #include "ui/base/resource/resource_bundle.h" 34 #include "ui/base/resource/resource_bundle.h"
44 #include "ui/gfx/image/image.h" 35 #include "ui/gfx/image/image.h"
45 #include "ui/gfx/image/image_skia.h" 36 #include "ui/gfx/image/image_skia.h"
46 #include "ui/gfx/image/image_skia_util_mac.h" 37 #include "ui/gfx/image/image_skia_util_mac.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 window_->CloseWebContentsModalDialog(); 94 window_->CloseWebContentsModalDialog();
104 } 95 }
105 96
106 void CollectedCookiesMac::OnConstrainedWindowClosed( 97 void CollectedCookiesMac::OnConstrainedWindowClosed(
107 ConstrainedWindowMac* window) { 98 ConstrainedWindowMac* window) {
108 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); 99 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this);
109 } 100 }
110 101
111 #pragma mark Window Controller 102 #pragma mark Window Controller
112 103
113 @interface CollectedCookiesWindowController(Private) 104 @interface CollectedCookiesWindowController (Private)
114 -(void)showInfoBarForDomain:(const base::string16&)domain 105 - (void)showInfoBarForDomain:(const base::string16&)domain
115 setting:(ContentSetting)setting; 106 setting:(ContentSetting)setting;
116 -(void)showInfoBarForMultipleDomainsAndSetting:(ContentSetting)setting; 107 - (void)showInfoBarForMultipleDomainsAndSetting:(ContentSetting)setting;
117 -(void)animateInfoBar; 108 - (void)animateInfoBar;
118 @end 109 @end
119 110
120 @implementation CollectedCookiesWindowController 111 @implementation CollectedCookiesWindowController
121 112
122 @synthesize allowedCookiesButtonsEnabled =
123 allowedCookiesButtonsEnabled_;
124 @synthesize blockedCookiesButtonsEnabled =
125 blockedCookiesButtonsEnabled_;
126
127 @synthesize allowedTreeController = allowedTreeController_; 113 @synthesize allowedTreeController = allowedTreeController_;
128 @synthesize blockedTreeController = blockedTreeController_; 114 @synthesize blockedTreeController = blockedTreeController_;
129 @synthesize allowedOutlineView = allowedOutlineView_; 115 @synthesize allowedOutlineView = allowedOutlineView_;
130 @synthesize blockedOutlineView = blockedOutlineView_; 116 @synthesize blockedOutlineView = blockedOutlineView_;
131 @synthesize infoBar = infoBar_; 117 @synthesize infoBar = infoBar_;
132 @synthesize infoBarIcon = infoBarIcon_; 118 @synthesize infoBarIcon = infoBarIcon_;
133 @synthesize infoBarText = infoBarText_; 119 @synthesize infoBarText = infoBarText_;
134 @synthesize tabView = tabView_; 120 @synthesize tabView = tabView_;
135 @synthesize blockedScrollView = blockedScrollView_; 121 @synthesize blockedScrollView = blockedScrollView_;
136 @synthesize blockedCookiesText = blockedCookiesText_; 122 @synthesize blockedCookiesText = blockedCookiesText_;
137 @synthesize cookieDetailsViewPlaceholder = cookieDetailsViewPlaceholder_; 123 @synthesize cookieDetailsViewPlaceholder = cookieDetailsViewPlaceholder_;
138 124
125 @synthesize allowedCookiesButtonsEnabled =
126 allowedCookiesButtonsEnabled_;
127 @synthesize blockedCookiesButtonsEnabled =
128 blockedCookiesButtonsEnabled_;
129 @synthesize deleteCookiesButtonEnabled = deleteCookiesButtonEnabled_;
130
139 - (id)initWithWebContents:(content::WebContents*)webContents 131 - (id)initWithWebContents:(content::WebContents*)webContents
140 collectedCookiesMac:(CollectedCookiesMac*)collectedCookiesMac { 132 collectedCookiesMac:(CollectedCookiesMac*)collectedCookiesMac {
141 DCHECK(webContents); 133 DCHECK(webContents);
142 134
143 NSString* nibpath = 135 NSString* nibpath =
144 [base::mac::FrameworkBundle() pathForResource:@"CollectedCookies" 136 [base::mac::FrameworkBundle() pathForResource:@"CollectedCookies"
145 ofType:@"nib"]; 137 ofType:@"nib"];
146 if ((self = [super initWithWindowNibPath:nibpath owner:self])) { 138 if ((self = [super initWithWindowNibPath:nibpath owner:self])) {
147 webContents_ = webContents; 139 webContents_ = webContents;
148 collectedCookiesMac_ = collectedCookiesMac; 140 collectedCookiesMac_ = collectedCookiesMac;
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 lastDomain = host_node->GetTitle(); 241 lastDomain = host_node->GetTitle();
250 } 242 }
251 if (multipleDomainsChanged) 243 if (multipleDomainsChanged)
252 [self showInfoBarForMultipleDomainsAndSetting:setting]; 244 [self showInfoBarForMultipleDomainsAndSetting:setting];
253 else 245 else
254 [self showInfoBarForDomain:lastDomain setting:setting]; 246 [self showInfoBarForDomain:lastDomain setting:setting];
255 contentSettingsChanged_ = YES; 247 contentSettingsChanged_ = YES;
256 } 248 }
257 249
258 - (IBAction)allowOrigin:(id)sender { 250 - (IBAction)allowOrigin:(id)sender {
259 [self addException:CONTENT_SETTING_ALLOW 251 [self addException:CONTENT_SETTING_ALLOW
260 forTreeController:blockedTreeController_]; 252 forTreeController:blockedTreeController_];
261 } 253 }
262 254
263 - (IBAction)allowForSessionFromOrigin:(id)sender { 255 - (IBAction)allowForSessionFromOrigin:(id)sender {
264 [self addException:CONTENT_SETTING_SESSION_ONLY 256 [self addException:CONTENT_SETTING_SESSION_ONLY
265 forTreeController:blockedTreeController_]; 257 forTreeController:blockedTreeController_];
266 } 258 }
267 259
268 - (IBAction)blockOrigin:(id)sender { 260 - (IBAction)blockOrigin:(id)sender {
269 [self addException:CONTENT_SETTING_BLOCK 261 [self addException:CONTENT_SETTING_BLOCK
270 forTreeController:allowedTreeController_]; 262 forTreeController:allowedTreeController_];
271 } 263 }
272 264
265 - (IBAction)deleteSelected:(id)sender {
266 NSArray* nodes = [allowedTreeController_ selectedNodes];
267 for (NSTreeNode* cocoaTreeNode in nodes) {
268 CookieTreeNode* cookieNode = static_cast<CookieTreeNode*>(
269 [[cocoaTreeNode representedObject] treeNode]);
270 allowedTreeModel_->DeleteCookieNode(cookieNode);
271 }
272 }
273
273 - (CocoaCookieTreeNode*)cocoaAllowedTreeModel { 274 - (CocoaCookieTreeNode*)cocoaAllowedTreeModel {
274 return cocoaAllowedTreeModel_.get(); 275 return allowedControllerBridge_->cocoa_model();
275 }
276 - (void)setCocoaAllowedTreeModel:(CocoaCookieTreeNode*)model {
277 cocoaAllowedTreeModel_.reset([model retain]);
278 } 276 }
279 277
280 - (CookiesTreeModel*)allowedTreeModel { 278 - (CookiesTreeModel*)allowedTreeModel {
281 return allowedTreeModel_.get(); 279 return allowedTreeModel_.get();
282 } 280 }
283 281
284 - (CocoaCookieTreeNode*)cocoaBlockedTreeModel { 282 - (CocoaCookieTreeNode*)cocoaBlockedTreeModel {
285 return cocoaBlockedTreeModel_.get(); 283 return blockedControllerBridge_->cocoa_model();
286 }
287 - (void)setCocoaBlockedTreeModel:(CocoaCookieTreeNode*)model {
288 cocoaBlockedTreeModel_.reset([model retain]);
289 } 284 }
290 285
291 - (CookiesTreeModel*)blockedTreeModel { 286 - (CookiesTreeModel*)blockedTreeModel {
292 return blockedTreeModel_.get(); 287 return blockedTreeModel_.get();
293 } 288 }
294 289
295 - (void)outlineView:(NSOutlineView*)outlineView 290 - (void)outlineView:(NSOutlineView*)outlineView
296 willDisplayCell:(id)cell 291 willDisplayCell:(id)cell
297 forTableColumn:(NSTableColumn*)tableColumn 292 forTableColumn:(NSTableColumn*)tableColumn
298 item:(id)item { 293 item:(id)item {
299 CocoaCookieTreeNode* node = [item representedObject]; 294 CocoaCookieTreeNode* node = [item representedObject];
300 int index; 295 int index;
301 if (outlineView == allowedOutlineView_) 296 if (outlineView == allowedOutlineView_)
302 index = allowedTreeModel_->GetIconIndex([node treeNode]); 297 index = allowedTreeModel_->GetIconIndex([node treeNode]);
303 else 298 else
304 index = blockedTreeModel_->GetIconIndex([node treeNode]); 299 index = blockedTreeModel_->GetIconIndex([node treeNode]);
305 NSImage* icon = nil; 300 NSImage* icon = nil;
306 if (index >= 0) 301 if (index >= 0)
307 icon = [icons_ objectAtIndex:index]; 302 icon = [icons_ objectAtIndex:index];
308 else 303 else
309 icon = [icons_ lastObject]; 304 icon = [icons_ lastObject];
310 DCHECK([cell isKindOfClass:[ImageAndTextCell class]]); 305 DCHECK([cell isKindOfClass:[ImageAndTextCell class]]);
311 [static_cast<ImageAndTextCell*>(cell) setImage:icon]; 306 [static_cast<ImageAndTextCell*>(cell) setImage:icon];
312 } 307 }
313 308
314 - (void)outlineViewSelectionDidChange:(NSNotification*)notif { 309 - (void)outlineViewSelectionDidChange:(NSNotification*)notif {
315 BOOL isAllowedOutlineView; 310 BOOL isAllowedOutlineView;
316 if ([notif object] == allowedOutlineView_) { 311 if ([notif object] == allowedOutlineView_) {
317 isAllowedOutlineView = YES; 312 isAllowedOutlineView = YES;
313 [self setDeleteCookiesButtonEnabled:YES];
318 } else if ([notif object] == blockedOutlineView_) { 314 } else if ([notif object] == blockedOutlineView_) {
319 isAllowedOutlineView = NO; 315 isAllowedOutlineView = NO;
316 [self setDeleteCookiesButtonEnabled:NO];
320 } else { 317 } else {
321 NOTREACHED(); 318 NOTREACHED();
322 return; 319 return;
323 } 320 }
324 NSTreeController* controller = 321 NSTreeController* controller =
325 isAllowedOutlineView ? allowedTreeController_ : blockedTreeController_; 322 isAllowedOutlineView ? allowedTreeController_ : blockedTreeController_;
326 323
327 NSArray* nodes = [controller selectedNodes]; 324 NSArray* nodes = [controller selectedNodes];
328 for (NSTreeNode* treeNode in nodes) { 325 for (NSTreeNode* treeNode in nodes) {
329 CocoaCookieTreeNode* node = [treeNode representedObject]; 326 CocoaCookieTreeNode* node = [treeNode representedObject];
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 [icons_ addObject:gfx::NSImageFromImageSkia(*it)]; 370 [icons_ addObject:gfx::NSImageFromImageSkia(*it)];
374 } 371 }
375 372
376 // Default icon will be the last item in the array. 373 // Default icon will be the last item in the array.
377 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 374 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
378 // TODO(rsesek): Rename this resource now that it's in multiple places. 375 // TODO(rsesek): Rename this resource now that it's in multiple places.
379 [icons_ addObject: 376 [icons_ addObject:
380 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).ToNSImage()]; 377 rb.GetNativeImageNamed(IDR_BOOKMARK_BAR_FOLDER).ToNSImage()];
381 378
382 // Create the Cocoa model. 379 // Create the Cocoa model.
383 CookieTreeNode* root = 380 allowedControllerBridge_.reset(
384 static_cast<CookieTreeNode*>(allowedTreeModel_->GetRoot()); 381 new CookiesTreeControllerBridge(allowedTreeModel_.get()));
385 base::scoped_nsobject<CocoaCookieTreeNode> model( 382 blockedControllerBridge_.reset(
386 [[CocoaCookieTreeNode alloc] initWithNode:root]); 383 new CookiesTreeControllerBridge(blockedTreeModel_.get()));
387 [self setCocoaAllowedTreeModel:model.get()]; // Takes ownership.
388 root = static_cast<CookieTreeNode*>(blockedTreeModel_->GetRoot());
389 model.reset(
390 [[CocoaCookieTreeNode alloc] initWithNode:root]);
391 [self setCocoaBlockedTreeModel:model.get()]; // Takes ownership.
392 } 384 }
393 385
394 -(void)showInfoBarForMultipleDomainsAndSetting:(ContentSetting)setting { 386 - (void)showInfoBarForMultipleDomainsAndSetting:(ContentSetting)setting {
395 NSString* label; 387 NSString* label;
396 switch (setting) { 388 switch (setting) {
397 case CONTENT_SETTING_BLOCK: 389 case CONTENT_SETTING_BLOCK:
398 label = l10n_util::GetNSString( 390 label = l10n_util::GetNSString(
399 IDS_COLLECTED_COOKIES_MULTIPLE_BLOCK_RULES_CREATED); 391 IDS_COLLECTED_COOKIES_MULTIPLE_BLOCK_RULES_CREATED);
400 break; 392 break;
401 393
402 case CONTENT_SETTING_ALLOW: 394 case CONTENT_SETTING_ALLOW:
403 label = l10n_util::GetNSString( 395 label = l10n_util::GetNSString(
404 IDS_COLLECTED_COOKIES_MULTIPLE_ALLOW_RULES_CREATED); 396 IDS_COLLECTED_COOKIES_MULTIPLE_ALLOW_RULES_CREATED);
405 break; 397 break;
406 398
407 case CONTENT_SETTING_SESSION_ONLY: 399 case CONTENT_SETTING_SESSION_ONLY:
408 label = l10n_util::GetNSString( 400 label = l10n_util::GetNSString(
409 IDS_COLLECTED_COOKIES_MULTIPLE_SESSION_RULES_CREATED); 401 IDS_COLLECTED_COOKIES_MULTIPLE_SESSION_RULES_CREATED);
410 break; 402 break;
411 403
412 default: 404 default:
413 NOTREACHED(); 405 NOTREACHED();
414 label = [[[NSString alloc] init] autorelease]; 406 label = [[[NSString alloc] init] autorelease];
415 } 407 }
416 [infoBarText_ setStringValue:label]; 408 [infoBarText_ setStringValue:label];
417 [self animateInfoBar]; 409 [self animateInfoBar];
418 } 410 }
419 411
420 -(void)showInfoBarForDomain:(const base::string16&)domain 412 - (void)showInfoBarForDomain:(const base::string16&)domain
421 setting:(ContentSetting)setting { 413 setting:(ContentSetting)setting {
422 NSString* label; 414 NSString* label;
423 switch (setting) { 415 switch (setting) {
424 case CONTENT_SETTING_BLOCK: 416 case CONTENT_SETTING_BLOCK:
425 label = l10n_util::GetNSStringF( 417 label = l10n_util::GetNSStringF(
426 IDS_COLLECTED_COOKIES_BLOCK_RULE_CREATED, 418 IDS_COLLECTED_COOKIES_BLOCK_RULE_CREATED,
427 domain); 419 domain);
428 break; 420 break;
429 421
430 case CONTENT_SETTING_ALLOW: 422 case CONTENT_SETTING_ALLOW:
431 label = l10n_util::GetNSStringF( 423 label = l10n_util::GetNSStringF(
432 IDS_COLLECTED_COOKIES_ALLOW_RULE_CREATED, 424 IDS_COLLECTED_COOKIES_ALLOW_RULE_CREATED,
433 domain); 425 domain);
434 break; 426 break;
435 427
436 case CONTENT_SETTING_SESSION_ONLY: 428 case CONTENT_SETTING_SESSION_ONLY:
437 label = l10n_util::GetNSStringF( 429 label = l10n_util::GetNSStringF(
438 IDS_COLLECTED_COOKIES_SESSION_RULE_CREATED, 430 IDS_COLLECTED_COOKIES_SESSION_RULE_CREATED,
439 domain); 431 domain);
440 break; 432 break;
441 433
442 default: 434 default:
443 NOTREACHED(); 435 NOTREACHED();
444 label = [[[NSString alloc] init] autorelease]; 436 label = [[[NSString alloc] init] autorelease];
445 } 437 }
446 [infoBarText_ setStringValue:label]; 438 [infoBarText_ setStringValue:label];
447 [self animateInfoBar]; 439 [self animateInfoBar];
448 } 440 }
449 441
450 -(void)animateInfoBar { 442 - (void)animateInfoBar {
451 if (infoBarVisible_) 443 if (infoBarVisible_)
452 return; 444 return;
453 445
454 infoBarVisible_ = YES; 446 infoBarVisible_ = YES;
455 447
456 NSMutableArray* animations = [NSMutableArray arrayWithCapacity:3];
457
458 NSWindow* sheet = [self window]; 448 NSWindow* sheet = [self window];
459 NSRect sheetFrame = [sheet frame]; 449 NSRect sheetFrame = [sheet frame];
460 NSRect infoBarFrame = [infoBar_ frame]; 450 NSRect infoBarFrame = [infoBar_ frame];
461 NSRect tabViewFrame = [tabView_ frame]; 451 NSRect tabViewFrame = [tabView_ frame];
462 452
463 // Calculate the end position of the info bar and set it to its start 453 // Calculate the end position of the info bar and set it to its start
464 // position. 454 // position.
465 infoBarFrame.origin.y = NSHeight(sheetFrame); 455 infoBarFrame.origin.y = NSHeight(sheetFrame);
466 infoBarFrame.size.width = NSWidth(sheetFrame); 456 infoBarFrame.size.width = NSWidth(sheetFrame);
467 [infoBar_ setFrame:infoBarFrame]; 457 [infoBar_ setFrame:infoBarFrame];
468 [[[self window] contentView] addSubview:infoBar_]; 458 [[[self window] contentView] addSubview:infoBar_];
469 459
470 // Calculate the new position of the sheet. 460 // Calculate the new position of the sheet.
471 sheetFrame.origin.y -= NSHeight(infoBarFrame); 461 sheetFrame.origin.y -= NSHeight(infoBarFrame);
472 sheetFrame.size.height += NSHeight(infoBarFrame); 462 sheetFrame.size.height += NSHeight(infoBarFrame);
473 463
474 // Slide the infobar in. 464 NSArray* animations = @[
475 [animations addObject: 465 // Slide the infobar in.
476 [NSDictionary dictionaryWithObjectsAndKeys: 466 @{
477 infoBar_, NSViewAnimationTargetKey, 467 NSViewAnimationTargetKey : infoBar_,
478 [NSValue valueWithRect:infoBarFrame], 468 NSViewAnimationEndFrameKey : [NSValue valueWithRect:infoBarFrame]
479 NSViewAnimationEndFrameKey, 469 },
480 nil]]; 470 // Make sure the tab view ends up in the right position.
481 // Make sure the tab view ends up in the right position. 471 @{
482 [animations addObject: 472 NSViewAnimationTargetKey : tabView_,
483 [NSDictionary dictionaryWithObjectsAndKeys: 473 NSViewAnimationEndFrameKey : [NSValue valueWithRect:tabViewFrame]
484 tabView_, NSViewAnimationTargetKey, 474 },
485 [NSValue valueWithRect:tabViewFrame], 475 // Grow the sheet.
486 NSViewAnimationEndFrameKey, 476 @{
487 nil]]; 477 NSViewAnimationTargetKey : sheet,
478 NSViewAnimationEndFrameKey : [NSValue valueWithRect:sheetFrame]
479 }
480 ];
488 481
489 // Grow the sheet.
490 [animations addObject:
491 [NSDictionary dictionaryWithObjectsAndKeys:
492 sheet, NSViewAnimationTargetKey,
493 [NSValue valueWithRect:sheetFrame],
494 NSViewAnimationEndFrameKey,
495 nil]];
496 [animation_ setViewAnimations:animations]; 482 [animation_ setViewAnimations:animations];
497 // The default duration is 0.5s, which actually feels slow in here, so speed 483 // The default duration is 0.5s, which actually feels slow in here, so speed
498 // it up a bit. 484 // it up a bit.
499 [animation_ gtm_setDuration:0.2 485 [animation_ gtm_setDuration:0.2 eventMask:NSLeftMouseUpMask];
500 eventMask:NSLeftMouseUpMask];
501 [animation_ startAnimation]; 486 [animation_ startAnimation];
502 } 487 }
503 488
504 - (void) tabView:(NSTabView*)tabView 489 - (void)tabView:(NSTabView*)tabView
505 didSelectTabViewItem:(NSTabViewItem*)tabViewItem { 490 didSelectTabViewItem:(NSTabViewItem*)tabViewItem {
506 NSTreeController* treeController = nil; 491 NSTreeController* treeController = nil;
507 switch ([tabView indexOfTabViewItem:tabViewItem]) { 492 switch ([tabView indexOfTabViewItem:tabViewItem]) {
508 case kAllowedCookiesTabIndex: 493 case kAllowedCookiesTabIndex:
509 treeController = allowedTreeController_; 494 treeController = allowedTreeController_;
510 break; 495 break;
511 case kBlockedCookiesTabIndex: 496 case kBlockedCookiesTabIndex:
512 treeController = blockedTreeController_; 497 treeController = blockedTreeController_;
513 break; 498 break;
514 default: 499 default:
515 NOTREACHED(); 500 NOTREACHED();
516 return; 501 return;
517 } 502 }
518 [detailsViewController_ configureBindingsForTreeController:treeController]; 503 [detailsViewController_ configureBindingsForTreeController:treeController];
519 } 504 }
520 505
521 @end 506 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698