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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 | 43 |
44 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ | 44 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ |
45 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ | 45 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ |
46 | 46 |
47 #include <iosfwd> | 47 #include <iosfwd> |
48 #include <string> | 48 #include <string> |
49 #include <vector> | 49 #include <vector> |
50 | 50 |
51 #include "base/containers/hash_tables.h" | 51 #include "base/containers/hash_tables.h" |
52 #include "base/logging.h" | 52 #include "base/logging.h" |
| 53 #include "base/strings/utf_string_conversions.h" |
53 #include "base/time/time.h" | 54 #include "base/time/time.h" |
| 55 #include "net/base/net_util.h" |
54 #include "url/url_parse.h" | 56 #include "url/url_parse.h" |
55 | 57 |
| 58 namespace autofill { |
| 59 struct PasswordForm; |
| 60 } // namespace autofill |
| 61 |
56 namespace base { | 62 namespace base { |
57 class CommandLine; | 63 class CommandLine; |
58 } // namespace base | 64 } // namespace base |
59 | 65 |
60 namespace password_manager { | 66 namespace password_manager { |
61 | 67 |
62 // Encapsulates a facet URI in canonical form. | 68 // Encapsulates a facet URI in canonical form. |
63 // | 69 // |
64 // This is a very light-weight wrapper around an std::string containing the text | 70 // This is a very light-weight wrapper around an std::string containing the text |
65 // of the URI, and can be passed around as a value. The main rationale for the | 71 // of the URI, and can be passed around as a value. The main rationale for the |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 const base::CommandLine& command_line); | 192 const base::CommandLine& command_line); |
187 | 193 |
188 // Returns whether or not affiliation requests for dummy facets should be | 194 // Returns whether or not affiliation requests for dummy facets should be |
189 // triggered as part of an experiment to exercise AffiliationService code before | 195 // triggered as part of an experiment to exercise AffiliationService code before |
190 // users would get a chance to have any real Android-based credentials. If the | 196 // users would get a chance to have any real Android-based credentials. If the |
191 // main feature is forced enabled/disabled via the command line, the experiment | 197 // main feature is forced enabled/disabled via the command line, the experiment |
192 // is force enabled/disabled correspondingly. | 198 // is force enabled/disabled correspondingly. |
193 bool IsAffiliationRequestsForDummyFacetsEnabled( | 199 bool IsAffiliationRequestsForDummyFacetsEnabled( |
194 const base::CommandLine& command_line); | 200 const base::CommandLine& command_line); |
195 | 201 |
| 202 // Returns the origin URI in a format which can be presented to a user based of |
| 203 // |password_from| field values. For web URIs |languages| is using in order to |
| 204 // determine whether a URI is 'comprehensible' to a user who understands |
| 205 // languages listed. |
| 206 std::string GetHumanReadableOrigin(const autofill::PasswordForm& password_form, |
| 207 const std::string& languages); |
| 208 |
196 // For logging use only. | 209 // For logging use only. |
197 std::ostream& operator<<(std::ostream& os, const FacetURI& facet_uri); | 210 std::ostream& operator<<(std::ostream& os, const FacetURI& facet_uri); |
198 | 211 |
199 } // namespace password_manager | 212 } // namespace password_manager |
200 | 213 |
201 // Provide a hash function so that hash_sets and maps can contain FacetURIs. | 214 // Provide a hash function so that hash_sets and maps can contain FacetURIs. |
202 namespace BASE_HASH_NAMESPACE { | 215 namespace BASE_HASH_NAMESPACE { |
203 | 216 |
204 template <> | 217 template <> |
205 struct hash<password_manager::FacetURI> { | 218 struct hash<password_manager::FacetURI> { |
206 size_t operator()(const password_manager::FacetURI& facet_uri) const { | 219 size_t operator()(const password_manager::FacetURI& facet_uri) const { |
207 return hash<std::string>()(facet_uri.potentially_invalid_spec()); | 220 return hash<std::string>()(facet_uri.potentially_invalid_spec()); |
208 } | 221 } |
209 }; | 222 }; |
210 | 223 |
211 } // namespace BASE_HASH_NAMESPACE | 224 } // namespace BASE_HASH_NAMESPACE |
212 | 225 |
213 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ | 226 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ |
OLD | NEW |