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

Side by Side 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: last patch 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ios/web_view/public/cwv_web_view.h" 5 #import "ios/web_view/public/cwv_web_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #import "base/ios/weak_nsobject.h" 10 #import "base/ios/weak_nsobject.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "google_apis/google_api_keys.h"
13 #import "ios/web/public/navigation_manager.h" 14 #import "ios/web/public/navigation_manager.h"
14 #include "ios/web/public/referrer.h" 15 #include "ios/web/public/referrer.h"
15 #include "ios/web/public/reload_type.h" 16 #include "ios/web/public/reload_type.h"
16 #import "ios/web/public/web_state/context_menu_params.h" 17 #import "ios/web/public/web_state/context_menu_params.h"
17 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" 18 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h"
18 #import "ios/web/public/web_state/ui/crw_web_delegate.h" 19 #import "ios/web/public/web_state/ui/crw_web_delegate.h"
19 #import "ios/web/public/web_state/web_state.h" 20 #import "ios/web/public/web_state/web_state.h"
20 #import "ios/web/public/web_state/web_state_delegate_bridge.h" 21 #import "ios/web/public/web_state/web_state_delegate_bridge.h"
21 #import "ios/web/public/web_state/web_state_observer_bridge.h" 22 #import "ios/web/public/web_state/web_state_observer_bridge.h"
22 #import "ios/web_view/internal/cwv_html_element_internal.h" 23 #import "ios/web_view/internal/cwv_html_element_internal.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 @synthesize UIDelegate = _UIDelegate; 87 @synthesize UIDelegate = _UIDelegate;
87 88
88 + (NSString*)userAgentProduct { 89 + (NSString*)userAgentProduct {
89 return gUserAgentProduct; 90 return gUserAgentProduct;
90 } 91 }
91 92
92 + (void)setUserAgentProduct:(NSString*)product { 93 + (void)setUserAgentProduct:(NSString*)product {
93 gUserAgentProduct = [product copy]; 94 gUserAgentProduct = [product copy];
94 } 95 }
95 96
97 + (void)setGoogleAPIKey:(NSString*)googleAPIKey
98 clientID:(NSString*)clientID
99 clientSecret:(NSString*)clientSecret {
100 google_apis::SetAPIKey(base::SysNSStringToUTF8(googleAPIKey));
101
102 std::string clientIDString = base::SysNSStringToUTF8(clientID);
103 std::string clientSecretString = base::SysNSStringToUTF8(clientSecret);
104 for (size_t i = 0; i < google_apis::CLIENT_NUM_ITEMS; ++i) {
105 google_apis::OAuth2Client client =
106 static_cast<google_apis::OAuth2Client>(i);
107 google_apis::SetOAuth2ClientID(client, clientIDString);
108 google_apis::SetOAuth2ClientSecret(client, clientSecretString);
109 }
110 }
111
96 - (instancetype)initWithFrame:(CGRect)frame 112 - (instancetype)initWithFrame:(CGRect)frame
97 configuration:(CWVWebViewConfiguration*)configuration { 113 configuration:(CWVWebViewConfiguration*)configuration {
98 self = [super initWithFrame:frame]; 114 self = [super initWithFrame:frame];
99 if (self) { 115 if (self) {
100 _configuration = [configuration copy]; 116 _configuration = [configuration copy];
101 [self resetWebStateWithSessionStorage:nil]; 117 [self resetWebStateWithSessionStorage:nil];
102 } 118 }
103 return self; 119 return self;
104 } 120 }
105 121
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 if (subview.superview == self) { 349 if (subview.superview == self) {
334 return; 350 return;
335 } 351 }
336 subview.frame = self.bounds; 352 subview.frame = self.bounds;
337 subview.autoresizingMask = 353 subview.autoresizingMask =
338 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 354 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
339 [self addSubview:subview]; 355 [self addSubview:subview];
340 } 356 }
341 357
342 @end 358 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698