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..106276d11d3180151a4ce03fa7935af503623a01 100644 |
--- a/ios/web_view/internal/cwv_web_view.mm |
+++ b/ios/web_view/internal/cwv_web_view.mm |
@@ -7,9 +7,11 @@ |
#include <memory> |
#include <utility> |
+#include "base/environment.h" |
#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 +62,28 @@ |
@synthesize estimatedProgress = _estimatedProgress; |
@synthesize UIDelegate = _UIDelegate; |
++ (void)setGoogleAPIKey:(NSString*)googleAPIKey |
+ clientID:(NSString*)clientID |
+ clientSecret:(NSString*)clientSecret { |
+ std::unique_ptr<base::Environment> environment(base::Environment::Create()); |
+ |
+ environment->SetVar("GOOGLE_API_KEY", base::SysNSStringToUTF8(googleAPIKey)); |
+ environment->SetVar("GOOGLE_DEFAULT_CLIENT_ID", |
+ base::SysNSStringToUTF8(clientID)); |
+ environment->SetVar("GOOGLE_DEFAULT_CLIENT_SECRET", |
+ base::SysNSStringToUTF8(clientSecret)); |
+ |
+ DCHECK_EQ(google_apis::GetAPIKey(), base::SysNSStringToUTF8(googleAPIKey)); |
+ DCHECK_EQ(google_apis::GetOAuth2ClientID(google_apis::CLIENT_MAIN), |
+ base::SysNSStringToUTF8(clientID)); |
+ DCHECK_EQ(google_apis::GetOAuth2ClientSecret(google_apis::CLIENT_MAIN), |
+ base::SysNSStringToUTF8(clientSecret)); |
+ |
+ environment->UnSetVar("GOOGLE_API_KEY"); |
Hiroshi Ichikawa
2017/03/31 08:15:26
I'm a bit confused how this code takes effect, by
michaeldo
2017/03/31 20:28:16
You are on the right track. By calling GetAPIKey,
Hiroshi Ichikawa
2017/04/03 05:28:16
Can you move google_apis::GetAPIKey() etc. out of
jzw1
2017/04/11 08:28:46
Yeah I'm OK with removing the DCHECKs and the UnSe
|
+ environment->UnSetVar("GOOGLE_DEFAULT_CLIENT_ID"); |
+ environment->UnSetVar("GOOGLE_DEFAULT_CLIENT_SECRET"); |
+} |
+ |
- (instancetype)initWithFrame:(CGRect)frame |
configuration:(CWVWebViewConfiguration*)configuration { |
self = [super initWithFrame:frame]; |