| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/privacy_blacklist/blacklist_interceptor.h" | 5 #include "chrome/browser/privacy_blacklist/blacklist_interceptor.h" |
| 6 | 6 |
| 7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 IDR_BLACKLIST_HTML); | 74 IDR_BLACKLIST_HTML); |
| 75 return jstemplate_builder::GetI18nTemplateHtml(html, &strings); | 75 return jstemplate_builder::GetI18nTemplateHtml(html, &strings); |
| 76 } | 76 } |
| 77 | 77 |
| 78 const Blacklist::Provider* GetBestMatchingEntryProvider() const { | 78 const Blacklist::Provider* GetBestMatchingEntryProvider() const { |
| 79 // If kBlockAll is specified, assign blame to such an entry. | 79 // If kBlockAll is specified, assign blame to such an entry. |
| 80 // Otherwise pick the first one. | 80 // Otherwise pick the first one. |
| 81 const BlacklistManager* blacklist_manager = | 81 const BlacklistManager* blacklist_manager = |
| 82 request_info_.GetBlacklistManager(); | 82 request_info_.GetBlacklistManager(); |
| 83 const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist(); | 83 const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist(); |
| 84 scoped_ptr<Blacklist::Match> match(blacklist->findMatch(request_->url())); | 84 scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request_->url())); |
| 85 const Blacklist::Entry* entry = NULL; | 85 const Blacklist::Entry* entry = NULL; |
| 86 if (match->attributes() & Blacklist::kBlockAll) { | 86 if (match->attributes() & Blacklist::kBlockAll) { |
| 87 for (std::vector<const Blacklist::Entry*>::const_iterator i = | 87 for (std::vector<const Blacklist::Entry*>::const_iterator i = |
| 88 match->entries().begin(); i != match->entries().end(); ++i) { | 88 match->entries().begin(); i != match->entries().end(); ++i) { |
| 89 if ((*i)->attributes() == Blacklist::kBlockAll) { | 89 if ((*i)->attributes() == Blacklist::kBlockAll) { |
| 90 entry = *i; | 90 entry = *i; |
| 91 break; | 91 break; |
| 92 } | 92 } |
| 93 } | 93 } |
| 94 } else { | 94 } else { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 116 BlacklistRequestInfo* request_info = | 116 BlacklistRequestInfo* request_info = |
| 117 BlacklistRequestInfo::FromURLRequest(request); | 117 BlacklistRequestInfo::FromURLRequest(request); |
| 118 if (!request_info) { | 118 if (!request_info) { |
| 119 // Not all requests have privacy blacklist data, for example downloads. | 119 // Not all requests have privacy blacklist data, for example downloads. |
| 120 return NULL; | 120 return NULL; |
| 121 } | 121 } |
| 122 | 122 |
| 123 const BlacklistManager* blacklist_manager = | 123 const BlacklistManager* blacklist_manager = |
| 124 request_info->GetBlacklistManager(); | 124 request_info->GetBlacklistManager(); |
| 125 const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist(); | 125 const Blacklist* blacklist = blacklist_manager->GetCompiledBlacklist(); |
| 126 scoped_ptr<Blacklist::Match> match(blacklist->findMatch(request->url())); | 126 scoped_ptr<Blacklist::Match> match(blacklist->FindMatch(request->url())); |
| 127 | 127 |
| 128 if (!match.get()) { | 128 if (!match.get()) { |
| 129 // Nothing is blacklisted for this request. Do not intercept. | 129 // Nothing is blacklisted for this request. Do not intercept. |
| 130 return NULL; | 130 return NULL; |
| 131 } | 131 } |
| 132 | 132 |
| 133 // TODO(phajdan.jr): Should we have some UI to notify about blocked referrer? | 133 // TODO(phajdan.jr): Should we have some UI to notify about blocked referrer? |
| 134 if (match->attributes() & Blacklist::kDontSendReferrer) | 134 if (match->attributes() & Blacklist::kDontSendReferrer) |
| 135 request->set_referrer(std::string()); | 135 request->set_referrer(std::string()); |
| 136 | 136 |
| 137 if (match->IsBlocked(request->url())) | 137 if (match->IsBlocked(request->url())) |
| 138 return new URLRequestBlacklistJob(request, *request_info); | 138 return new URLRequestBlacklistJob(request, *request_info); |
| 139 | 139 |
| 140 return NULL; | 140 return NULL; |
| 141 } | 141 } |
| OLD | NEW |