OLD | NEW |
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" | 10 #import "base/mac/mac_util.h" |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 | 257 |
258 - (void)addException:(ContentSetting)setting | 258 - (void)addException:(ContentSetting)setting |
259 forTreeController:(NSTreeController*)controller { | 259 forTreeController:(NSTreeController*)controller { |
260 NSArray* nodes = [controller selectedNodes]; | 260 NSArray* nodes = [controller selectedNodes]; |
261 BOOL multipleDomainsChanged = NO; | 261 BOOL multipleDomainsChanged = NO; |
262 string16 lastDomain; | 262 string16 lastDomain; |
263 for (NSTreeNode* treeNode in nodes) { | 263 for (NSTreeNode* treeNode in nodes) { |
264 CocoaCookieTreeNode* node = [treeNode representedObject]; | 264 CocoaCookieTreeNode* node = [treeNode representedObject]; |
265 CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]); | 265 CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]); |
266 if (cookie->GetDetailedInfo().node_type != | 266 if (cookie->GetDetailedInfo().node_type != |
267 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { | 267 CookieTreeNode::DetailedInfo::TYPE_HOST) { |
268 continue; | 268 continue; |
269 } | 269 } |
270 Profile* profile = tab_contents_->profile(); | 270 Profile* profile = tab_contents_->profile(); |
271 CookieTreeOriginNode* origin_node = | 271 CookieTreeHostNode* host_node = |
272 static_cast<CookieTreeOriginNode*>(cookie); | 272 static_cast<CookieTreeHostNode*>(cookie); |
273 origin_node->CreateContentException( | 273 host_node->CreateContentException( |
274 CookieSettings::Factory::GetForProfile(profile), setting); | 274 CookieSettings::Factory::GetForProfile(profile), setting); |
275 if (!lastDomain.empty()) | 275 if (!lastDomain.empty()) |
276 multipleDomainsChanged = YES; | 276 multipleDomainsChanged = YES; |
277 lastDomain = origin_node->GetTitle(); | 277 lastDomain = host_node->GetTitle(); |
278 } | 278 } |
279 if (multipleDomainsChanged) | 279 if (multipleDomainsChanged) |
280 [self showInfoBarForMultipleDomainsAndSetting:setting]; | 280 [self showInfoBarForMultipleDomainsAndSetting:setting]; |
281 else | 281 else |
282 [self showInfoBarForDomain:lastDomain setting:setting]; | 282 [self showInfoBarForDomain:lastDomain setting:setting]; |
283 contentSettingsChanged_ = YES; | 283 contentSettingsChanged_ = YES; |
284 } | 284 } |
285 | 285 |
286 - (IBAction)allowOrigin:(id)sender { | 286 - (IBAction)allowOrigin:(id)sender { |
287 [self addException:CONTENT_SETTING_ALLOW | 287 [self addException:CONTENT_SETTING_ALLOW |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 return; | 350 return; |
351 } | 351 } |
352 NSTreeController* controller = | 352 NSTreeController* controller = |
353 isAllowedOutlineView ? allowedTreeController_ : blockedTreeController_; | 353 isAllowedOutlineView ? allowedTreeController_ : blockedTreeController_; |
354 | 354 |
355 NSArray* nodes = [controller selectedNodes]; | 355 NSArray* nodes = [controller selectedNodes]; |
356 for (NSTreeNode* treeNode in nodes) { | 356 for (NSTreeNode* treeNode in nodes) { |
357 CocoaCookieTreeNode* node = [treeNode representedObject]; | 357 CocoaCookieTreeNode* node = [treeNode representedObject]; |
358 CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]); | 358 CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]); |
359 if (cookie->GetDetailedInfo().node_type != | 359 if (cookie->GetDetailedInfo().node_type != |
360 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { | 360 CookieTreeNode::DetailedInfo::TYPE_HOST) { |
361 continue; | 361 continue; |
362 } | 362 } |
363 CookieTreeOriginNode* origin_node = | 363 CookieTreeHostNode* host_node = |
364 static_cast<CookieTreeOriginNode*>(cookie); | 364 static_cast<CookieTreeHostNode*>(cookie); |
365 if (origin_node->CanCreateContentException()) { | 365 if (host_node->CanCreateContentException()) { |
366 if (isAllowedOutlineView) { | 366 if (isAllowedOutlineView) { |
367 [self setAllowedCookiesButtonsEnabled:YES]; | 367 [self setAllowedCookiesButtonsEnabled:YES]; |
368 } else { | 368 } else { |
369 [self setBlockedCookiesButtonsEnabled:YES]; | 369 [self setBlockedCookiesButtonsEnabled:YES]; |
370 } | 370 } |
371 return; | 371 return; |
372 } | 372 } |
373 } | 373 } |
374 if (isAllowedOutlineView) { | 374 if (isAllowedOutlineView) { |
375 [self setAllowedCookiesButtonsEnabled:NO]; | 375 [self setAllowedCookiesButtonsEnabled:NO]; |
(...skipping 17 matching lines...) Expand all Loading... |
393 allowed_lsos.cookies()->Clone(), | 393 allowed_lsos.cookies()->Clone(), |
394 allowed_lsos.databases()->Clone(), | 394 allowed_lsos.databases()->Clone(), |
395 allowed_lsos.local_storages()->Clone(), | 395 allowed_lsos.local_storages()->Clone(), |
396 allowed_lsos.session_storages()->Clone(), | 396 allowed_lsos.session_storages()->Clone(), |
397 allowed_lsos.appcaches()->Clone(), | 397 allowed_lsos.appcaches()->Clone(), |
398 allowed_lsos.indexed_dbs()->Clone(), | 398 allowed_lsos.indexed_dbs()->Clone(), |
399 allowed_lsos.file_systems()->Clone(), | 399 allowed_lsos.file_systems()->Clone(), |
400 NULL, | 400 NULL, |
401 allowed_lsos.server_bound_certs()->Clone()); | 401 allowed_lsos.server_bound_certs()->Clone()); |
402 | 402 |
403 allowedTreeModel_.reset(new CookiesTreeModel(apps_map, true)); | 403 allowedTreeModel_.reset(new CookiesTreeModel(apps_map, NULL, true)); |
404 } | 404 } |
405 | 405 |
406 const LocalSharedObjectsContainer& blocked_lsos = | 406 const LocalSharedObjectsContainer& blocked_lsos = |
407 content_settings->blocked_local_shared_objects(); | 407 content_settings->blocked_local_shared_objects(); |
408 { | 408 { |
409 ContainerMap apps_map; | 409 ContainerMap apps_map; |
410 apps_map[std::string()] = new LocalDataContainer( | 410 apps_map[std::string()] = new LocalDataContainer( |
411 std::string(), std::string(), | 411 std::string(), std::string(), |
412 blocked_lsos.cookies()->Clone(), | 412 blocked_lsos.cookies()->Clone(), |
413 blocked_lsos.databases()->Clone(), | 413 blocked_lsos.databases()->Clone(), |
414 blocked_lsos.local_storages()->Clone(), | 414 blocked_lsos.local_storages()->Clone(), |
415 blocked_lsos.session_storages()->Clone(), | 415 blocked_lsos.session_storages()->Clone(), |
416 blocked_lsos.appcaches()->Clone(), | 416 blocked_lsos.appcaches()->Clone(), |
417 blocked_lsos.indexed_dbs()->Clone(), | 417 blocked_lsos.indexed_dbs()->Clone(), |
418 blocked_lsos.file_systems()->Clone(), | 418 blocked_lsos.file_systems()->Clone(), |
419 NULL, | 419 NULL, |
420 blocked_lsos.server_bound_certs()->Clone()); | 420 blocked_lsos.server_bound_certs()->Clone()); |
421 | 421 |
422 blockedTreeModel_.reset(new CookiesTreeModel(apps_map, true)); | 422 blockedTreeModel_.reset(new CookiesTreeModel(apps_map, NULL, true)); |
423 } | 423 } |
424 | 424 |
425 // Convert the model's icons from Skia to Cocoa. | 425 // Convert the model's icons from Skia to Cocoa. |
426 std::vector<gfx::ImageSkia> skiaIcons; | 426 std::vector<gfx::ImageSkia> skiaIcons; |
427 allowedTreeModel_->GetIcons(&skiaIcons); | 427 allowedTreeModel_->GetIcons(&skiaIcons); |
428 icons_.reset([[NSMutableArray alloc] init]); | 428 icons_.reset([[NSMutableArray alloc] init]); |
429 for (std::vector<gfx::ImageSkia>::iterator it = skiaIcons.begin(); | 429 for (std::vector<gfx::ImageSkia>::iterator it = skiaIcons.begin(); |
430 it != skiaIcons.end(); ++it) { | 430 it != skiaIcons.end(); ++it) { |
431 [icons_ addObject:gfx::NSImageFromImageSkia(*it)]; | 431 [icons_ addObject:gfx::NSImageFromImageSkia(*it)]; |
432 } | 432 } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 treeController = blockedTreeController_; | 569 treeController = blockedTreeController_; |
570 break; | 570 break; |
571 default: | 571 default: |
572 NOTREACHED(); | 572 NOTREACHED(); |
573 return; | 573 return; |
574 } | 574 } |
575 [detailsViewController_ configureBindingsForTreeController:treeController]; | 575 [detailsViewController_ configureBindingsForTreeController:treeController]; |
576 } | 576 } |
577 | 577 |
578 @end | 578 @end |
OLD | NEW |