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

Unified Diff: ios/web_view/internal/cwv_web_view.mm

Issue 2786033002: Expose way to set google api key through CWVWebView class method. (Closed)
Patch Set: Few lints 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 side-by-side diff with in-line comments
Download patch
Index: ios/web_view/internal/cwv_web_view.mm
diff --git a/ios/web_view/internal/cwv_web_view.mm b/ios/web_view/internal/cwv_web_view.mm
index 08fb4d8dc30b2994005f51fbd5799b2b1efbc42c..0da46bd48a7c6b8c517da960386e2403ce02aa41 100644
--- a/ios/web_view/internal/cwv_web_view.mm
+++ b/ios/web_view/internal/cwv_web_view.mm
@@ -10,6 +10,7 @@
#import "base/ios/weak_nsobject.h"
#include "base/memory/ptr_util.h"
#include "base/strings/sys_string_conversions.h"
+#include "google_apis/google_api_keys.h"
#import "ios/web/public/navigation_manager.h"
#include "ios/web/public/referrer.h"
#include "ios/web/public/reload_type.h"
@@ -60,6 +61,21 @@
@synthesize estimatedProgress = _estimatedProgress;
@synthesize UIDelegate = _UIDelegate;
++ (void)setGoogleAPIKey:(NSString*)googleAPIKey
+ clientID:(NSString*)clientID
+ clientSecret:(NSString*)clientSecret {
+ google_apis::SetAPIKey(base::SysNSStringToUTF8(googleAPIKey));
+
+ std::string clientIDString = base::SysNSStringToUTF8(clientID);
+ std::string clientSecretString = base::SysNSStringToUTF8(clientSecret);
+ for (size_t i = 0; i < google_apis::CLIENT_NUM_ITEMS; ++i) {
+ google_apis::OAuth2Client client =
+ static_cast<google_apis::OAuth2Client>(i);
michaeldo 2017/04/14 15:25:55 Can we prevent the cast if we do this loop inside
jzw1 2017/04/17 01:41:20 I followed the loop example in google_api_keys.cc:
+ google_apis::SetOAuth2ClientID(client, clientIDString);
+ google_apis::SetOAuth2ClientSecret(client, clientSecretString);
+ }
+}
+
- (instancetype)initWithFrame:(CGRect)frame
configuration:(CWVWebViewConfiguration*)configuration {
self = [super initWithFrame:frame];

Powered by Google App Engine
This is Rietveld 408576698