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 "content/browser/background_fetch/background_fetch_cross_origin_filter.
h" | 5 #include "content/browser/background_fetch/background_fetch_cross_origin_filter.
h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "content/browser/background_fetch/background_fetch_request_info.h" | 10 #include "content/browser/background_fetch/background_fetch_request_info.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 *any_origin = true; | 30 *any_origin = true; |
31 return true; | 31 return true; |
32 } | 32 } |
33 | 33 |
34 std::set<url::Origin> candidate_origins; | 34 std::set<url::Origin> candidate_origins; |
35 std::vector<std::string> origin_vector = base::SplitString( | 35 std::vector<std::string> origin_vector = base::SplitString( |
36 value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 36 value, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
37 | 37 |
38 for (const std::string& origin_string : origin_vector) { | 38 for (const std::string& origin_string : origin_vector) { |
39 url::Origin origin = url::Origin(GURL(origin_string)); | 39 url::Origin origin = url::Origin(GURL(origin_string)); |
40 if (origin.unique()) | 40 if (origin.opaque()) |
41 return false; | 41 return false; |
42 | 42 |
43 candidate_origins.insert(origin); | 43 candidate_origins.insert(origin); |
44 } | 44 } |
45 | 45 |
46 origins->swap(candidate_origins); | 46 origins->swap(candidate_origins); |
47 return !origins->empty(); | 47 return !origins->empty(); |
48 } | 48 } |
49 | 49 |
50 } // namespace | 50 } // namespace |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 bool BackgroundFetchCrossOriginFilter::CanPopulateBody() const { | 90 bool BackgroundFetchCrossOriginFilter::CanPopulateBody() const { |
91 // The body will be populated if: | 91 // The body will be populated if: |
92 // (1) The source and the response share their origin. | 92 // (1) The source and the response share their origin. |
93 // (2) The Access-Control-Allow-Origin method allows any origin. | 93 // (2) The Access-Control-Allow-Origin method allows any origin. |
94 // (3) The Access-Control-Allow-Origin method allows the source origin. | 94 // (3) The Access-Control-Allow-Origin method allows the source origin. |
95 | 95 |
96 return is_same_origin_ || access_control_allow_origin_; | 96 return is_same_origin_ || access_control_allow_origin_; |
97 } | 97 } |
98 | 98 |
99 } // namespace content | 99 } // namespace content |
OLD | NEW |