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

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: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web_view/internal/DEPS ('k') | ios/web_view/public/cwv_web_view.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 157ed90a02db5844d0c3e00e02864434d63738ae..da06b5577e33646e9c5e58261fb480d58fea16b3 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"
@@ -93,6 +94,21 @@ static NSString* gUserAgentProduct = nil;
gUserAgentProduct = [product copy];
}
++ (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);
+ google_apis::SetOAuth2ClientID(client, clientIDString);
+ google_apis::SetOAuth2ClientSecret(client, clientSecretString);
+ }
+}
+
- (instancetype)initWithFrame:(CGRect)frame
configuration:(CWVWebViewConfiguration*)configuration {
self = [super initWithFrame:frame];
« no previous file with comments | « ios/web_view/internal/DEPS ('k') | ios/web_view/public/cwv_web_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698