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

Side by Side Diff: third_party/libaddressinput/chromium/cpp/src/lookup_key_util.h

Issue 110533002: [rac] Temporarily copy libaddressinput to Chrome. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Avoid redefinition of basictypes.h Created 7 years 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (C) 2013 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 //
15 // Functions for working with lookup keys. The lookup keys are strings that
16 // identify serialized validation rules.
17
18 #ifndef I18N_ADDRESSINPUT_LOOKUP_KEY_UTIL_H_
19 #define I18N_ADDRESSINPUT_LOOKUP_KEY_UTIL_H_
20
21 #include <string>
22
23 namespace i18n {
24 namespace addressinput {
25
26 // Utility functions for lookup keys. Sample usage:
27 // LookupKeyUtil lookup_keys("https://i18napis.appspot.com/ssl-address/");
28 // Download(lookup_keys.GetUrlForKey("data/US"));
29 class LookupKeyUtil {
30 public:
31 // Builds a lookup key utility for the |validation_data_url| parameter. The
32 // parameter must end with a '/'.
33 explicit LookupKeyUtil(const std::string& validation_data_url);
34 ~LookupKeyUtil();
35
36 // Returns the URL where the |key| can be retrieved. For example, returns
37 // "https://i18napis.appspot.com/ssl-address/data/US" for input "data/US".
38 // Assumes that the input string is a valid URL segment.
39 std::string GetUrlForKey(const std::string& key) const;
40
41 // Returns the key for the |url|. For example, returns "data/US" for
42 // "https://i18napis.appspot.com/ssl-address/data/US". If the |url| does not
43 // start with |validation_data_url| that was passed to the constructor, then
44 // returns an empty string. (This can happen if the user of the library
45 // returns a bad URL in their Downloader implementation.)
46 std::string GetKeyForUrl(const std::string& url) const;
47
48 // Returns true if the |url| starts with |validation_data_url| that was passed
49 // to the constructor.
50 bool IsValidationDataUrl(const std::string& url) const;
51
52 private:
53 const std::string validation_data_url_;
54 };
55
56 } // namespace addressinput
57 } // namespace i18n
58
59 #endif // I18N_ADDRESSINPUT_LOOKUP_KEY_UTIL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698