| 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 #include "chrome/browser/cookies_tree_model.h" | 5 #include "chrome/browser/cookies_tree_model.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "base/memory/linked_ptr.h" | 13 #include "base/memory/linked_ptr.h" |
| 14 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "chrome/browser/browsing_data_cookie_helper.h" | 16 #include "chrome/browser/browsing_data_cookie_helper.h" |
| 17 #include "chrome/browser/content_settings/content_settings_pattern.h" |
| 18 #include "chrome/browser/content_settings/cookie_settings.h" |
| 17 #include "chrome/browser/content_settings/host_content_settings_map.h" | 19 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 18 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 19 #include "content/browser/in_process_webkit/webkit_context.h" | 21 #include "content/browser/in_process_webkit/webkit_context.h" |
| 20 #include "grit/generated_resources.h" | 22 #include "grit/generated_resources.h" |
| 21 #include "grit/theme_resources.h" | 23 #include "grit/theme_resources.h" |
| 22 #include "grit/ui_resources.h" | 24 #include "grit/ui_resources.h" |
| 23 #include "net/base/cookie_monster.h" | 25 #include "net/base/cookie_monster.h" |
| 24 #include "net/base/registry_controlled_domain.h" | 26 #include "net/base/registry_controlled_domain.h" |
| 25 #include "net/url_request/url_request_context.h" | 27 #include "net/url_request/url_request_context.h" |
| 26 #include "third_party/skia/include/core/SkBitmap.h" | 28 #include "third_party/skia/include/core/SkBitmap.h" |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 if (quota_child_) | 449 if (quota_child_) |
| 448 return quota_child_; | 450 return quota_child_; |
| 449 quota_child_ = new CookieTreeQuotaNode(quota_info); | 451 quota_child_ = new CookieTreeQuotaNode(quota_info); |
| 450 AddChildSortedByTitle(quota_child_); | 452 AddChildSortedByTitle(quota_child_); |
| 451 return quota_child_; | 453 return quota_child_; |
| 452 } | 454 } |
| 453 | 455 |
| 454 void CookieTreeOriginNode::CreateContentException( | 456 void CookieTreeOriginNode::CreateContentException( |
| 455 HostContentSettingsMap* content_settings, ContentSetting setting) const { | 457 HostContentSettingsMap* content_settings, ContentSetting setting) const { |
| 456 if (CanCreateContentException()) { | 458 if (CanCreateContentException()) { |
| 457 content_settings->AddExceptionForURL(url_, | 459 CookieSettings* cookie_settings = content_settings->GetCookieSettings(); |
| 458 url_, | 460 cookie_settings->ResetCookieAllowed( |
| 459 CONTENT_SETTINGS_TYPE_COOKIES, | 461 ContentSettingsPattern::FromURLNoWildcard(url_), |
| 460 "", | 462 ContentSettingsPattern::Wildcard()); |
| 461 setting); | 463 cookie_settings->ResetCookieSessionOnly( |
| 464 ContentSettingsPattern::FromURLNoWildcard(url_)); |
| 465 bool allow = (setting == CONTENT_SETTING_ALLOW || |
| 466 setting == CONTENT_SETTING_SESSION_ONLY); |
| 467 bool session_only = (setting == CONTENT_SETTING_SESSION_ONLY); |
| 468 cookie_settings->SetCookieAllowed(ContentSettingsPattern::FromURL(url_), |
| 469 ContentSettingsPattern::Wildcard(), |
| 470 allow); |
| 471 cookie_settings->SetCookieSessionOnly(ContentSettingsPattern::FromURL(url_), |
| 472 session_only); |
| 462 } | 473 } |
| 463 } | 474 } |
| 464 | 475 |
| 465 bool CookieTreeOriginNode::CanCreateContentException() const { | 476 bool CookieTreeOriginNode::CanCreateContentException() const { |
| 466 return !url_.SchemeIsFile(); | 477 return !url_.SchemeIsFile(); |
| 467 } | 478 } |
| 468 | 479 |
| 469 /////////////////////////////////////////////////////////////////////////////// | 480 /////////////////////////////////////////////////////////////////////////////// |
| 470 // CookieTreeCookiesNode, public: | 481 // CookieTreeCookiesNode, public: |
| 471 | 482 |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 | 1079 |
| 1069 void CookiesTreeModel::NotifyObserverEndBatch() { | 1080 void CookiesTreeModel::NotifyObserverEndBatch() { |
| 1070 // Only notify the observers if this is the outermost call to EndBatch() if | 1081 // Only notify the observers if this is the outermost call to EndBatch() if |
| 1071 // called in a nested manner. | 1082 // called in a nested manner. |
| 1072 if (--batch_update_ == 0) { | 1083 if (--batch_update_ == 0) { |
| 1073 FOR_EACH_OBSERVER(Observer, | 1084 FOR_EACH_OBSERVER(Observer, |
| 1074 cookies_observer_list_, | 1085 cookies_observer_list_, |
| 1075 TreeModelEndBatch(this)); | 1086 TreeModelEndBatch(this)); |
| 1076 } | 1087 } |
| 1077 } | 1088 } |
| OLD | NEW |