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 | 9 |
10 #include <stddef.h> | 10 #include <stddef.h> |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
199 client_secrets_[CLIENT_REMOTING_HOST] = CalculateKeyValue( | 199 client_secrets_[CLIENT_REMOTING_HOST] = CalculateKeyValue( |
200 GOOGLE_CLIENT_SECRET_REMOTING_HOST, | 200 GOOGLE_CLIENT_SECRET_REMOTING_HOST, |
201 STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING_HOST), | 201 STRINGIZE_NO_EXPANSION(GOOGLE_CLIENT_SECRET_REMOTING_HOST), |
202 NULL, | 202 NULL, |
203 default_client_secret, | 203 default_client_secret, |
204 environment.get(), | 204 environment.get(), |
205 command_line); | 205 command_line); |
206 } | 206 } |
207 | 207 |
208 std::string api_key() const { return api_key_; } | 208 std::string api_key() const { return api_key_; } |
209 #if defined(OS_IOS) | |
210 void set_api_key(const std::string& api_key) { api_key_ = api_key; } | |
211 #endif | |
209 std::string api_key_non_stable() const { return api_key_non_stable_; } | 212 std::string api_key_non_stable() const { return api_key_non_stable_; } |
210 std::string api_key_remoting() const { return api_key_remoting_; } | 213 std::string api_key_remoting() const { return api_key_remoting_; } |
211 | 214 |
212 std::string GetClientID(OAuth2Client client) const { | 215 std::string GetClientID(OAuth2Client client) const { |
213 DCHECK_LT(client, CLIENT_NUM_ITEMS); | 216 DCHECK_LT(client, CLIENT_NUM_ITEMS); |
214 return client_ids_[client]; | 217 return client_ids_[client]; |
215 } | 218 } |
216 | 219 |
220 #if defined(OS_IOS) | |
221 void SetClientID(OAuth2Client client, const std::string& client_id) { | |
222 client_ids_[client] = client_id; | |
223 } | |
224 #endif | |
225 | |
217 std::string GetClientSecret(OAuth2Client client) const { | 226 std::string GetClientSecret(OAuth2Client client) const { |
218 DCHECK_LT(client, CLIENT_NUM_ITEMS); | 227 DCHECK_LT(client, CLIENT_NUM_ITEMS); |
219 return client_secrets_[client]; | 228 return client_secrets_[client]; |
220 } | 229 } |
221 | 230 |
231 #if defined(OS_IOS) | |
232 void SetClientSecret(OAuth2Client client, const std::string& client_secret) { | |
233 client_secrets_[client] = client_secret; | |
234 } | |
235 #endif | |
236 | |
222 std::string GetSpdyProxyAuthValue() { | 237 std::string GetSpdyProxyAuthValue() { |
223 #if defined(SPDY_PROXY_AUTH_VALUE) | 238 #if defined(SPDY_PROXY_AUTH_VALUE) |
224 return SPDY_PROXY_AUTH_VALUE; | 239 return SPDY_PROXY_AUTH_VALUE; |
225 #else | 240 #else |
226 return std::string(); | 241 return std::string(); |
227 #endif | 242 #endif |
228 } | 243 } |
229 | 244 |
230 private: | 245 private: |
231 // Gets a value for a key. In priority order, this will be the value | 246 // Gets a value for a key. In priority order, this will be the value |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 } | 327 } |
313 | 328 |
314 std::string GetNonStableAPIKey() { | 329 std::string GetNonStableAPIKey() { |
315 return g_api_key_cache.Get().api_key_non_stable(); | 330 return g_api_key_cache.Get().api_key_non_stable(); |
316 } | 331 } |
317 | 332 |
318 std::string GetRemotingAPIKey() { | 333 std::string GetRemotingAPIKey() { |
319 return g_api_key_cache.Get().api_key_remoting(); | 334 return g_api_key_cache.Get().api_key_remoting(); |
320 } | 335 } |
321 | 336 |
337 #if defined(OS_IOS) | |
338 void SetAPIKey(const std::string& api_key) { | |
339 g_api_key_cache.Get().set_api_key(api_key); | |
340 } | |
341 #endif | |
342 | |
322 std::string GetOAuth2ClientID(OAuth2Client client) { | 343 std::string GetOAuth2ClientID(OAuth2Client client) { |
323 return g_api_key_cache.Get().GetClientID(client); | 344 return g_api_key_cache.Get().GetClientID(client); |
324 } | 345 } |
325 | 346 |
326 std::string GetOAuth2ClientSecret(OAuth2Client client) { | 347 std::string GetOAuth2ClientSecret(OAuth2Client client) { |
327 return g_api_key_cache.Get().GetClientSecret(client); | 348 return g_api_key_cache.Get().GetClientSecret(client); |
328 } | 349 } |
329 | 350 |
351 #if defined(OS_IOS) | |
352 void SetOAuth2ClientID(OAuth2Client client, const std::string& client_id) { | |
353 g_api_key_cache.Get().SetClientID(client, client_id); | |
354 } | |
355 #endif | |
356 | |
357 #if defined(OS_IOS) | |
michaeldo
2017/04/14 15:25:55
nit: Put both of these methods inside a single #if
jzw1
2017/04/17 01:41:20
Done.
| |
358 void SetOAuth2ClientSecret(OAuth2Client client, | |
359 const std::string& client_secret) { | |
360 g_api_key_cache.Get().SetClientSecret(client, client_secret); | |
361 } | |
362 #endif | |
363 | |
330 std::string GetSpdyProxyAuthValue() { | 364 std::string GetSpdyProxyAuthValue() { |
331 return g_api_key_cache.Get().GetSpdyProxyAuthValue(); | 365 return g_api_key_cache.Get().GetSpdyProxyAuthValue(); |
332 } | 366 } |
333 | 367 |
334 bool IsGoogleChromeAPIKeyUsed() { | 368 bool IsGoogleChromeAPIKeyUsed() { |
335 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS) | 369 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS) |
336 return true; | 370 return true; |
337 #else | 371 #else |
338 return false; | 372 return false; |
339 #endif | 373 #endif |
340 } | 374 } |
341 | 375 |
342 } // namespace google_apis | 376 } // namespace google_apis |
OLD | NEW |