| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/safe_browsing/password_protection/password_protection_servi
ce.h" | 5 #include "components/safe_browsing/password_protection/password_protection_servi
ce.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION); | 328 CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION); |
| 329 stored_verdict_count_ = 0; | 329 stored_verdict_count_ = 0; |
| 330 return; | 330 return; |
| 331 } | 331 } |
| 332 | 332 |
| 333 // For now, if a URL is deleted from history, we simply remove all the | 333 // For now, if a URL is deleted from history, we simply remove all the |
| 334 // cached verdicts of the same origin. This is a pretty aggressive deletion. | 334 // cached verdicts of the same origin. This is a pretty aggressive deletion. |
| 335 // We might revisit this logic later to decide if we want to only delete the | 335 // We might revisit this logic later to decide if we want to only delete the |
| 336 // cached verdict whose cache expression matches this URL. | 336 // cached verdict whose cache expression matches this URL. |
| 337 for (const history::URLRow& row : deleted_rows) { | 337 for (const history::URLRow& row : deleted_rows) { |
| 338 if (!row.url().SchemeIsHTTPOrHTTPS()) |
| 339 continue; |
| 338 GURL url_key = GetHostNameWithHTTPScheme(row.url()); | 340 GURL url_key = GetHostNameWithHTTPScheme(row.url()); |
| 339 std::unique_ptr<base::DictionaryValue> verdict_dictionary = | 341 std::unique_ptr<base::DictionaryValue> verdict_dictionary = |
| 340 base::DictionaryValue::From(content_settings_->GetWebsiteSetting( | 342 base::DictionaryValue::From(content_settings_->GetWebsiteSetting( |
| 341 url_key, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, | 343 url_key, GURL(), CONTENT_SETTINGS_TYPE_PASSWORD_PROTECTION, |
| 342 std::string(), nullptr)); | 344 std::string(), nullptr)); |
| 343 | 345 |
| 344 // Move on if we have no cached verdict for this deleted history row. | 346 // Move on if we have no cached verdict for this deleted history row. |
| 345 if (!verdict_dictionary.get() || verdict_dictionary->empty()) | 347 if (!verdict_dictionary.get() || verdict_dictionary->empty()) |
| 346 continue; | 348 continue; |
| 347 | 349 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 const std::vector<char> verdict_blob(serialized_proto.begin(), | 450 const std::vector<char> verdict_blob(serialized_proto.begin(), |
| 449 serialized_proto.end()); | 451 serialized_proto.end()); |
| 450 std::unique_ptr<base::Value> binary_value = | 452 std::unique_ptr<base::Value> binary_value = |
| 451 base::MakeUnique<base::Value>(verdict_blob); | 453 base::MakeUnique<base::Value>(verdict_blob); |
| 452 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); | 454 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); |
| 453 result->Set(kVerdictProto, std::move(binary_value)); | 455 result->Set(kVerdictProto, std::move(binary_value)); |
| 454 return result; | 456 return result; |
| 455 } | 457 } |
| 456 | 458 |
| 457 } // namespace safe_browsing | 459 } // namespace safe_browsing |
| OLD | NEW |