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

Side by Side Diff: google_apis/google_api_keys.cc

Issue 2786033002: Expose way to set google api key through CWVWebView class method. (Closed)
Patch Set: fix dependency Created 3 years, 8 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
« no previous file with comments | « google_apis/google_api_keys.h ('k') | google_apis/google_api_keys_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
356 void SetOAuth2ClientSecret(OAuth2Client client,
357 const std::string& client_secret) {
358 g_api_key_cache.Get().SetClientSecret(client, client_secret);
359 }
360 #endif
361
330 std::string GetSpdyProxyAuthValue() { 362 std::string GetSpdyProxyAuthValue() {
331 return g_api_key_cache.Get().GetSpdyProxyAuthValue(); 363 return g_api_key_cache.Get().GetSpdyProxyAuthValue();
332 } 364 }
333 365
334 bool IsGoogleChromeAPIKeyUsed() { 366 bool IsGoogleChromeAPIKeyUsed() {
335 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS) 367 #if defined(GOOGLE_CHROME_BUILD) || defined(USE_OFFICIAL_GOOGLE_API_KEYS)
336 return true; 368 return true;
337 #else 369 #else
338 return false; 370 return false;
339 #endif 371 #endif
340 } 372 }
341 373
342 } // namespace google_apis 374 } // namespace google_apis
OLDNEW
« no previous file with comments | « google_apis/google_api_keys.h ('k') | google_apis/google_api_keys_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698