Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: components/password_manager/core/browser/affiliation_utils.h

Issue 868253005: AffiliationBackend: Implement the better part of on-demand fetching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Missing override. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 26 matching lines...) Expand all
37 // alphabet, with no further escaping. This is normally calculated as: 37 // alphabet, with no further escaping. This is normally calculated as:
38 // 38 //
39 // echo -n -e "$PEM_KEY" | 39 // echo -n -e "$PEM_KEY" |
40 // openssl x509 -outform DER | 40 // openssl x509 -outform DER |
41 // openssl sha -sha512 -binary | base64 | tr '+/' '-_' 41 // openssl sha -sha512 -binary | base64 | tr '+/' '-_'
42 // 42 //
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 <string> 48 #include <string>
48 #include <vector> 49 #include <vector>
49 50
51 #include "base/containers/hash_tables.h"
50 #include "base/logging.h" 52 #include "base/logging.h"
51 #include "base/time/time.h" 53 #include "base/time/time.h"
52 #include "url/url_parse.h" 54 #include "url/url_parse.h"
53 55
54 namespace password_manager { 56 namespace password_manager {
55 57
56 // Encapsulates a facet URI in canonical form. 58 // Encapsulates a facet URI in canonical form.
57 // 59 //
58 // This is a very light-weight wrapper around an std::string containing the text 60 // This is a very light-weight wrapper around an std::string containing the text
59 // of the URI, and can be passed around as a value. The main rationale for the 61 // of the URI, and can be passed around as a value. The main rationale for the
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // references, provided it is a valid Android facet URI, or the empty string 113 // references, provided it is a valid Android facet URI, or the empty string
112 // otherwise. 114 // otherwise.
113 std::string android_package_name() const; 115 std::string android_package_name() const;
114 116
115 // Returns the text of the encapsulated canonical URI, which must be valid. 117 // Returns the text of the encapsulated canonical URI, which must be valid.
116 const std::string& canonical_spec() const { 118 const std::string& canonical_spec() const {
117 DCHECK(is_valid_); 119 DCHECK(is_valid_);
118 return canonical_spec_; 120 return canonical_spec_;
119 } 121 }
120 122
123 // Returns the text of the encapsulated canonical URI, even if it is invalid.
124 const std::string& potentially_invalid_spec() const {
125 return canonical_spec_;
126 }
127
121 private: 128 private:
122 // Internal constructor to be used by the static factory methods. 129 // Internal constructor to be used by the static factory methods.
123 FacetURI(const std::string& canonical_spec, bool is_valid); 130 FacetURI(const std::string& canonical_spec, bool is_valid);
124 131
125 // Whether |canonical_spec_| contains a valid facet URI in canonical form. 132 // Whether |canonical_spec_| contains a valid facet URI in canonical form.
126 bool is_valid_; 133 bool is_valid_;
127 134
128 // The text of the encapsulated canonical URI, valid if and only if 135 // The text of the encapsulated canonical URI, valid if and only if
129 // |is_valid_| is true. 136 // |is_valid_| is true.
130 std::string canonical_spec_; 137 std::string canonical_spec_;
(...skipping 16 matching lines...) Expand all
147 base::Time last_update_time; 154 base::Time last_update_time;
148 }; 155 };
149 156
150 // Returns whether or not equivalence classes |a| and |b| are equal, that is, 157 // Returns whether or not equivalence classes |a| and |b| are equal, that is,
151 // whether or not they consist of the same set of facets. 158 // whether or not they consist of the same set of facets.
152 // 159 //
153 // Note that this will do some sorting, so it can be expensive for large inputs. 160 // Note that this will do some sorting, so it can be expensive for large inputs.
154 bool AreEquivalenceClassesEqual(const AffiliatedFacets& a, 161 bool AreEquivalenceClassesEqual(const AffiliatedFacets& a,
155 const AffiliatedFacets& b); 162 const AffiliatedFacets& b);
156 163
164 // For logging use only.
165 std::ostream& operator<<(std::ostream& os, const FacetURI& facet_uri);
166
157 } // namespace password_manager 167 } // namespace password_manager
158 168
169 // Provide a hash function so that hash_sets and maps can contain FacetURIs.
170 namespace BASE_HASH_NAMESPACE {
171
172 template <>
173 struct hash<password_manager::FacetURI> {
174 size_t operator()(const password_manager::FacetURI& facet_uri) const {
175 return hash<std::string>()(facet_uri.potentially_invalid_spec());
176 }
177 };
178
179 } // namespace BASE_HASH_NAMESPACE
180
159 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_ 181 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_AFFILIATION_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698