OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // This file contains utilities related to working with "facets". | 5 // This file contains utilities related to working with "facets". |
6 // | 6 // |
7 // A "facet" is defined as the manifestation of a logical application on a given | 7 // A "facet" is defined as the manifestation of a logical application on a given |
8 // platform. For example, "My Bank" may have released an Android application | 8 // platform. For example, "My Bank" may have released an Android application |
9 // and a Web application accessible from a browser. These are all facets of the | 9 // and a Web application accessible from a browser. These are all facets of the |
10 // "My Bank" logical application. | 10 // "My Bank" logical application. |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // whether or not they consist of the same set of facets. | 174 // whether or not they consist of the same set of facets. |
175 // | 175 // |
176 // Note that this will do some sorting, so it can be expensive for large inputs. | 176 // Note that this will do some sorting, so it can be expensive for large inputs. |
177 bool AreEquivalenceClassesEqual(const AffiliatedFacets& a, | 177 bool AreEquivalenceClassesEqual(const AffiliatedFacets& a, |
178 const AffiliatedFacets& b); | 178 const AffiliatedFacets& b); |
179 | 179 |
180 // A shorter way to spell FacetURI::IsValidAndroidFacetURI(). | 180 // A shorter way to spell FacetURI::IsValidAndroidFacetURI(). |
181 bool IsValidAndroidFacetURI(const std::string& uri); | 181 bool IsValidAndroidFacetURI(const std::string& uri); |
182 | 182 |
183 // Returns the origin URI in a format which can be presented to a user based of | 183 // Returns the origin URI in a format which can be presented to a user based of |
184 // |password_from| field values. For web URIs |languages| is using in order to | 184 // |password_from| field values. |
185 // determine whether a URI is 'comprehensible' to a user who understands | 185 std::string GetHumanReadableOrigin(const autofill::PasswordForm& password_form); |
186 // languages listed. | |
187 std::string GetHumanReadableOrigin(const autofill::PasswordForm& password_form, | |
188 const std::string& languages); | |
189 | 186 |
190 // Returns the Android origin URI for presenting to a user. | 187 // Returns the Android origin URI for presenting to a user. |
191 std::string GetHumanReadableOriginForAndroidUri(const FacetURI facet_uri); | 188 std::string GetHumanReadableOriginForAndroidUri(const FacetURI facet_uri); |
192 | 189 |
193 // For logging use only. | 190 // For logging use only. |
194 std::ostream& operator<<(std::ostream& os, const FacetURI& facet_uri); | 191 std::ostream& operator<<(std::ostream& os, const FacetURI& facet_uri); |
195 | 192 |
196 } // namespace password_manager | 193 } // namespace password_manager |
197 | 194 |
198 // Provide a hash function so that hash_sets and maps can contain FacetURIs. | 195 // Provide a hash function so that hash_sets and maps can contain FacetURIs. |
199 namespace BASE_HASH_NAMESPACE { | 196 namespace BASE_HASH_NAMESPACE { |
200 | 197 |
201 template <> | 198 template <> |
202 struct hash<password_manager::FacetURI> { | 199 struct hash<password_manager::FacetURI> { |
203 size_t operator()(const password_manager::FacetURI& facet_uri) const { | 200 size_t operator()(const password_manager::FacetURI& facet_uri) const { |
204 return hash<std::string>()(facet_uri.potentially_invalid_spec()); | 201 return hash<std::string>()(facet_uri.potentially_invalid_spec()); |
205 } | 202 } |
206 }; | 203 }; |
207 | 204 |
208 } // namespace BASE_HASH_NAMESPACE | 205 } // namespace BASE_HASH_NAMESPACE |
209 | 206 |
210 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ | 207 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ |
OLD | NEW |