| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "base/mac/mac_util.h" | 9 #import "base/mac/mac_util.h" |
| 10 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| 11 #include "chrome/browser/content_settings/host_content_settings_map.h" | 11 #include "chrome/browser/content_settings/cookie_settings.h" |
| 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" | 12 #include "chrome/browser/content_settings/tab_specific_content_settings.h" |
| 13 #include "chrome/browser/infobars/infobar_tab_helper.h" | 13 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 14 #include "chrome/browser/prefs/pref_service.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" | 16 #include "chrome/browser/ui/cocoa/constrained_window_mac.h" |
| 16 #import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller
.h" | 17 #import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller
.h" |
| 17 #import "chrome/browser/ui/cocoa/vertical_gradient_view.h" | 18 #import "chrome/browser/ui/cocoa/vertical_gradient_view.h" |
| 18 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" | 19 #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" |
| 19 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 20 #include "chrome/common/chrome_notification_types.h" | 21 #include "chrome/common/chrome_notification_types.h" |
| 22 #include "chrome/common/pref_names.h" |
| 21 #include "content/browser/tab_contents/tab_contents.h" | 23 #include "content/browser/tab_contents/tab_contents.h" |
| 22 #include "content/common/notification_details.h" | 24 #include "content/common/notification_details.h" |
| 23 #include "content/common/notification_source.h" | 25 #include "content/common/notification_source.h" |
| 24 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 25 #include "grit/theme_resources.h" | 27 #include "grit/theme_resources.h" |
| 26 #include "skia/ext/skia_utils_mac.h" | 28 #include "skia/ext/skia_utils_mac.h" |
| 27 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" | 29 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" |
| 28 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" | 30 #import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h" |
| 29 #include "third_party/apple/ImageAndTextCell.h" | 31 #include "third_party/apple/ImageAndTextCell.h" |
| 30 #include "third_party/skia/include/core/SkBitmap.h" | 32 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 endingColor:bannerEndingColor]); | 179 endingColor:bannerEndingColor]); |
| 178 [infoBar_ setGradient:bannerGradient]; | 180 [infoBar_ setGradient:bannerGradient]; |
| 179 | 181 |
| 180 NSColor* bannerStrokeColor = | 182 NSColor* bannerStrokeColor = |
| 181 [NSColor colorWithCalibratedWhite:kBannerStrokeColor | 183 [NSColor colorWithCalibratedWhite:kBannerStrokeColor |
| 182 alpha:1.0]; | 184 alpha:1.0]; |
| 183 [infoBar_ setStrokeColor:bannerStrokeColor]; | 185 [infoBar_ setStrokeColor:bannerStrokeColor]; |
| 184 | 186 |
| 185 // Change the label of the blocked cookies part if necessary. | 187 // Change the label of the blocked cookies part if necessary. |
| 186 Profile* profile = wrapper_->profile(); | 188 Profile* profile = wrapper_->profile(); |
| 187 if (profile->GetHostContentSettingsMap()->BlockThirdPartyCookies()) { | 189 if (profile->GetPrefs()->GetBoolean(prefs::kBlockThirdPartyCookies)) { |
| 188 [blockedCookiesText_ setStringValue:l10n_util::GetNSString( | 190 [blockedCookiesText_ setStringValue:l10n_util::GetNSString( |
| 189 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED)]; | 191 IDS_COLLECTED_COOKIES_BLOCKED_THIRD_PARTY_BLOCKING_ENABLED)]; |
| 190 CGFloat textDeltaY = [GTMUILocalizerAndLayoutTweaker | 192 CGFloat textDeltaY = [GTMUILocalizerAndLayoutTweaker |
| 191 sizeToFitFixedWidthTextField:blockedCookiesText_]; | 193 sizeToFitFixedWidthTextField:blockedCookiesText_]; |
| 192 | 194 |
| 193 // Shrink the blocked cookies outline view. | 195 // Shrink the blocked cookies outline view. |
| 194 NSRect frame = [blockedScrollView_ frame]; | 196 NSRect frame = [blockedScrollView_ frame]; |
| 195 frame.size.height -= textDeltaY; | 197 frame.size.height -= textDeltaY; |
| 196 [blockedScrollView_ setFrame:frame]; | 198 [blockedScrollView_ setFrame:frame]; |
| 197 | 199 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 for (NSTreeNode* treeNode in nodes) { | 238 for (NSTreeNode* treeNode in nodes) { |
| 237 CocoaCookieTreeNode* node = [treeNode representedObject]; | 239 CocoaCookieTreeNode* node = [treeNode representedObject]; |
| 238 CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]); | 240 CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]); |
| 239 if (cookie->GetDetailedInfo().node_type != | 241 if (cookie->GetDetailedInfo().node_type != |
| 240 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { | 242 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { |
| 241 continue; | 243 continue; |
| 242 } | 244 } |
| 243 Profile* profile = wrapper_->profile(); | 245 Profile* profile = wrapper_->profile(); |
| 244 CookieTreeOriginNode* origin_node = | 246 CookieTreeOriginNode* origin_node = |
| 245 static_cast<CookieTreeOriginNode*>(cookie); | 247 static_cast<CookieTreeOriginNode*>(cookie); |
| 246 origin_node->CreateContentException(profile->GetHostContentSettingsMap(), | 248 origin_node->CreateContentException(CookieSettings::GetForProfile(profile), |
| 247 setting); | 249 setting); |
| 248 if (!lastDomain.empty()) | 250 if (!lastDomain.empty()) |
| 249 multipleDomainsChanged = YES; | 251 multipleDomainsChanged = YES; |
| 250 lastDomain = origin_node->GetTitle(); | 252 lastDomain = origin_node->GetTitle(); |
| 251 } | 253 } |
| 252 if (multipleDomainsChanged) | 254 if (multipleDomainsChanged) |
| 253 [self showInfoBarForMultipleDomainsAndSetting:setting]; | 255 [self showInfoBarForMultipleDomainsAndSetting:setting]; |
| 254 else | 256 else |
| 255 [self showInfoBarForDomain:lastDomain setting:setting]; | 257 [self showInfoBarForDomain:lastDomain setting:setting]; |
| 256 contentSettingsChanged_ = YES; | 258 contentSettingsChanged_ = YES; |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 treeController = blockedTreeController_; | 507 treeController = blockedTreeController_; |
| 506 break; | 508 break; |
| 507 default: | 509 default: |
| 508 NOTREACHED(); | 510 NOTREACHED(); |
| 509 return; | 511 return; |
| 510 } | 512 } |
| 511 [detailsViewController_ configureBindingsForTreeController:treeController]; | 513 [detailsViewController_ configureBindingsForTreeController:treeController]; |
| 512 } | 514 } |
| 513 | 515 |
| 514 @end | 516 @end |
| OLD | NEW |