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/public/browser/notification_details.h" | 24 #include "content/public/browser/notification_details.h" |
23 #include "content/public/browser/notification_source.h" | 25 #include "content/public/browser/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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 for (NSTreeNode* treeNode in nodes) { | 239 for (NSTreeNode* treeNode in nodes) { |
238 CocoaCookieTreeNode* node = [treeNode representedObject]; | 240 CocoaCookieTreeNode* node = [treeNode representedObject]; |
239 CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]); | 241 CookieTreeNode* cookie = static_cast<CookieTreeNode*>([node treeNode]); |
240 if (cookie->GetDetailedInfo().node_type != | 242 if (cookie->GetDetailedInfo().node_type != |
241 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { | 243 CookieTreeNode::DetailedInfo::TYPE_ORIGIN) { |
242 continue; | 244 continue; |
243 } | 245 } |
244 Profile* profile = wrapper_->profile(); | 246 Profile* profile = wrapper_->profile(); |
245 CookieTreeOriginNode* origin_node = | 247 CookieTreeOriginNode* origin_node = |
246 static_cast<CookieTreeOriginNode*>(cookie); | 248 static_cast<CookieTreeOriginNode*>(cookie); |
247 origin_node->CreateContentException(profile->GetHostContentSettingsMap(), | 249 origin_node->CreateContentException(CookieSettings::GetForProfile(profile), |
248 setting); | 250 setting); |
249 if (!lastDomain.empty()) | 251 if (!lastDomain.empty()) |
250 multipleDomainsChanged = YES; | 252 multipleDomainsChanged = YES; |
251 lastDomain = origin_node->GetTitle(); | 253 lastDomain = origin_node->GetTitle(); |
252 } | 254 } |
253 if (multipleDomainsChanged) | 255 if (multipleDomainsChanged) |
254 [self showInfoBarForMultipleDomainsAndSetting:setting]; | 256 [self showInfoBarForMultipleDomainsAndSetting:setting]; |
255 else | 257 else |
256 [self showInfoBarForDomain:lastDomain setting:setting]; | 258 [self showInfoBarForDomain:lastDomain setting:setting]; |
257 contentSettingsChanged_ = YES; | 259 contentSettingsChanged_ = YES; |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 treeController = blockedTreeController_; | 508 treeController = blockedTreeController_; |
507 break; | 509 break; |
508 default: | 510 default: |
509 NOTREACHED(); | 511 NOTREACHED(); |
510 return; | 512 return; |
511 } | 513 } |
512 [detailsViewController_ configureBindingsForTreeController:treeController]; | 514 [detailsViewController_ configureBindingsForTreeController:treeController]; |
513 } | 515 } |
514 | 516 |
515 @end | 517 @end |
OLD | NEW |