| 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 21 matching lines...) Expand all Loading... |
| 32 const char kVerdictProto[] = "verdict_proto"; | 32 const char kVerdictProto[] = "verdict_proto"; |
| 33 const int kRequestTimeoutMs = 10000; | 33 const int kRequestTimeoutMs = 10000; |
| 34 const char kPasswordProtectionRequestUrl[] = | 34 const char kPasswordProtectionRequestUrl[] = |
| 35 "https://sb-ssl.google.com/safebrowsing/clientreport/login"; | 35 "https://sb-ssl.google.com/safebrowsing/clientreport/login"; |
| 36 | 36 |
| 37 // Helper function to determine if the given origin matches content settings | 37 // Helper function to determine if the given origin matches content settings |
| 38 // map's patterns. | 38 // map's patterns. |
| 39 bool OriginMatchPrimaryPattern( | 39 bool OriginMatchPrimaryPattern( |
| 40 const GURL& origin, | 40 const GURL& origin, |
| 41 const ContentSettingsPattern& primary_pattern, | 41 const ContentSettingsPattern& primary_pattern, |
| 42 const ContentSettingsPattern& secondary_pattern_unused) { | 42 const ContentSettingsPattern& secondary_pattern_unused, |
| 43 base::Time last_modified_unused) { |
| 43 return ContentSettingsPattern::FromURLNoWildcard(origin) == primary_pattern; | 44 return ContentSettingsPattern::FromURLNoWildcard(origin) == primary_pattern; |
| 44 } | 45 } |
| 45 | 46 |
| 46 // Returns the number of path segments in |cache_expression_path|. | 47 // Returns the number of path segments in |cache_expression_path|. |
| 47 // For example, return 0 for "/", since there is no path after the leading | 48 // For example, return 0 for "/", since there is no path after the leading |
| 48 // slash; return 3 for "/abc/def/gh.html". | 49 // slash; return 3 for "/abc/def/gh.html". |
| 49 size_t GetPathDepth(const std::string& cache_expression_path) { | 50 size_t GetPathDepth(const std::string& cache_expression_path) { |
| 50 return base::SplitString(base::StringPiece(cache_expression_path), "/", | 51 return base::SplitString(base::StringPiece(cache_expression_path), "/", |
| 51 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY) | 52 base::KEEP_WHITESPACE, base::SPLIT_WANT_NONEMPTY) |
| 52 .size(); | 53 .size(); |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 const std::vector<char> verdict_blob(serialized_proto.begin(), | 451 const std::vector<char> verdict_blob(serialized_proto.begin(), |
| 451 serialized_proto.end()); | 452 serialized_proto.end()); |
| 452 std::unique_ptr<base::Value> binary_value = | 453 std::unique_ptr<base::Value> binary_value = |
| 453 base::MakeUnique<base::Value>(verdict_blob); | 454 base::MakeUnique<base::Value>(verdict_blob); |
| 454 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); | 455 DCHECK_EQ(base::Value::Type::BINARY, binary_value->type()); |
| 455 result->Set(kVerdictProto, std::move(binary_value)); | 456 result->Set(kVerdictProto, std::move(binary_value)); |
| 456 return result; | 457 return result; |
| 457 } | 458 } |
| 458 | 459 |
| 459 } // namespace safe_browsing | 460 } // namespace safe_browsing |
| OLD | NEW |