OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "google_apis/google_api_keys.h" | 5 #include "google_apis/google_api_keys.h" |
6 | 6 |
7 // If you add more includes to this list, you also need to add them to | 7 // If you add more includes to this list, you also need to add them to |
8 // google_api_keys_unittest.cc. | 8 // google_api_keys_unittest.cc. |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/environment.h" | 10 #include "base/environment.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #endif | 42 #endif |
43 | 43 |
44 #if !defined(GOOGLE_CLIENT_ID_REMOTING) | 44 #if !defined(GOOGLE_CLIENT_ID_REMOTING) |
45 #define GOOGLE_CLIENT_ID_REMOTING DUMMY_API_TOKEN | 45 #define GOOGLE_CLIENT_ID_REMOTING DUMMY_API_TOKEN |
46 #endif | 46 #endif |
47 | 47 |
48 #if !defined(GOOGLE_CLIENT_SECRET_REMOTING) | 48 #if !defined(GOOGLE_CLIENT_SECRET_REMOTING) |
49 #define GOOGLE_CLIENT_SECRET_REMOTING DUMMY_API_TOKEN | 49 #define GOOGLE_CLIENT_SECRET_REMOTING DUMMY_API_TOKEN |
50 #endif | 50 #endif |
51 | 51 |
| 52 #if !defined(GOOGLE_CLIENT_ID_REMOTING_HOST) |
| 53 #define GOOGLE_CLIENT_ID_REMOTING_HOST DUMMY_API_TOKEN |
| 54 #endif |
| 55 |
| 56 #if !defined(GOOGLE_CLIENT_SECRET_REMOTING_HOST) |
| 57 #define GOOGLE_CLIENT_SECRET_REMOTING_HOST DUMMY_API_TOKEN |
| 58 #endif |
| 59 |
52 // These are used as shortcuts for developers and users providing | 60 // These are used as shortcuts for developers and users providing |
53 // OAuth credentials via preprocessor defines or environment | 61 // OAuth credentials via preprocessor defines or environment |
54 // variables. If set, they will be used to replace any of the client | 62 // variables. If set, they will be used to replace any of the client |
55 // IDs and secrets above that have not been set (and only those; they | 63 // IDs and secrets above that have not been set (and only those; they |
56 // will not override already-set values). | 64 // will not override already-set values). |
57 #if !defined(GOOGLE_DEFAULT_CLIENT_ID) | 65 #if !defined(GOOGLE_DEFAULT_CLIENT_ID) |
58 #define GOOGLE_DEFAULT_CLIENT_ID "" | 66 #define GOOGLE_DEFAULT_CLIENT_ID "" |
59 #endif | 67 #endif |
60 #if !defined(GOOGLE_DEFAULT_CLIENT_SECRET) | 68 #if !defined(GOOGLE_DEFAULT_CLIENT_SECRET) |
61 #define GOOGLE_DEFAULT_CLIENT_SECRET "" | 69 #define GOOGLE_DEFAULT_CLIENT_SECRET "" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 default_client_id, | 153 default_client_id, |
146 environment.get(), | 154 environment.get(), |
147 command_line); | 155 command_line); |
148 client_secrets_[CLIENT_REMOTING] = CalculateKeyValue( | 156 client_secrets_[CLIENT_REMOTING] = CalculateKeyValue( |
149 GOOGLE_CLIENT_SECRET_REMOTING, | 157 GOOGLE_CLIENT_SECRET_REMOTING, |
150 STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING), | 158 STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING), |
151 NULL, | 159 NULL, |
152 default_client_secret, | 160 default_client_secret, |
153 environment.get(), | 161 environment.get(), |
154 command_line); | 162 command_line); |
| 163 |
| 164 client_ids_[CLIENT_REMOTING_HOST] = CalculateKeyValue( |
| 165 GOOGLE_CLIENT_ID_REMOTING_HOST, |
| 166 STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_ID_REMOTING_HOST), |
| 167 NULL, |
| 168 default_client_id, |
| 169 environment.get(), |
| 170 command_line); |
| 171 client_secrets_[CLIENT_REMOTING_HOST] = CalculateKeyValue( |
| 172 GOOGLE_CLIENT_SECRET_REMOTING_HOST, |
| 173 STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING_HOST), |
| 174 NULL, |
| 175 default_client_secret, |
| 176 environment.get(), |
| 177 command_line); |
155 } | 178 } |
156 | 179 |
157 std::string api_key() const { return api_key_; } | 180 std::string api_key() const { return api_key_; } |
158 | 181 |
159 std::string GetClientID(OAuth2Client client) const { | 182 std::string GetClientID(OAuth2Client client) const { |
160 DCHECK_LT(client, CLIENT_NUM_ITEMS); | 183 DCHECK_LT(client, CLIENT_NUM_ITEMS); |
161 return client_ids_[client]; | 184 return client_ids_[client]; |
162 } | 185 } |
163 | 186 |
164 std::string GetClientSecret(OAuth2Client client) const { | 187 std::string GetClientSecret(OAuth2Client client) const { |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 | 263 |
241 std::string GetOAuth2ClientID(OAuth2Client client) { | 264 std::string GetOAuth2ClientID(OAuth2Client client) { |
242 return g_api_key_cache.Get().GetClientID(client); | 265 return g_api_key_cache.Get().GetClientID(client); |
243 } | 266 } |
244 | 267 |
245 std::string GetOAuth2ClientSecret(OAuth2Client client) { | 268 std::string GetOAuth2ClientSecret(OAuth2Client client) { |
246 return g_api_key_cache.Get().GetClientSecret(client); | 269 return g_api_key_cache.Get().GetClientSecret(client); |
247 } | 270 } |
248 | 271 |
249 } // namespace google_apis | 272 } // namespace google_apis |
OLD | NEW |