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

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: add some guards so this only works for ios. 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 30 matching lines...) Expand all
53 @end 54 @end
54 55
55 @implementation CWVWebView 56 @implementation CWVWebView
56 57
57 @synthesize configuration = _configuration; 58 @synthesize configuration = _configuration;
58 @synthesize navigationDelegate = _navigationDelegate; 59 @synthesize navigationDelegate = _navigationDelegate;
59 @synthesize translationDelegate = _translationDelegate; 60 @synthesize translationDelegate = _translationDelegate;
60 @synthesize estimatedProgress = _estimatedProgress; 61 @synthesize estimatedProgress = _estimatedProgress;
61 @synthesize UIDelegate = _UIDelegate; 62 @synthesize UIDelegate = _UIDelegate;
62 63
64 + (void)setGoogleAPIKey:(NSString*)googleAPIKey
65 clientID:(NSString*)clientID
66 clientSecret:(NSString*)clientSecret {
67 google_apis::SetAPIKey(base::SysNSStringToUTF8(googleAPIKey));
68
69 std::string client_id = base::SysNSStringToUTF8(clientID);
Eugene But (OOO till 7-30) 2017/04/13 15:06:25 client_id Style is used for C++ code, Objective-C
jzw1 2017/04/14 02:10:32 Any suggestions for what I should call it since cl
Eugene But (OOO till 7-30) 2017/04/14 14:24:48 Maybe clientIDNSString? But clientIDString looks f
70 std::string client_secret = base::SysNSStringToUTF8(clientSecret);
71 for (size_t i = 0; i < google_apis::CLIENT_NUM_ITEMS; ++i) {
72 google_apis::OAuth2Client client =
73 static_cast<google_apis::OAuth2Client>(i);
74 google_apis::SetClientID(client_id, client);
75 google_apis::SetClientSecret(client_secret, client);
76 }
Roger Tawa OOO till Jul 10th 2017/04/13 17:42:43 Does this need to loop? In what cases will the io
michaeldo 2017/04/13 19:28:09 I also think this loop is odd here. (If we do need
jzw1 2017/04/14 02:10:32 Currently there's a piece of translate code: https
77 }
78
63 - (instancetype)initWithFrame:(CGRect)frame 79 - (instancetype)initWithFrame:(CGRect)frame
64 configuration:(CWVWebViewConfiguration*)configuration { 80 configuration:(CWVWebViewConfiguration*)configuration {
65 self = [super initWithFrame:frame]; 81 self = [super initWithFrame:frame];
66 if (self) { 82 if (self) {
67 _configuration = [configuration copy]; 83 _configuration = [configuration copy];
68 84
69 web::WebState::CreateParams webStateCreateParams( 85 web::WebState::CreateParams webStateCreateParams(
70 configuration.browserState); 86 configuration.browserState);
71 _webState = web::WebState::Create(webStateCreateParams); 87 _webState = web::WebState::Create(webStateCreateParams);
72 _webState->SetWebUsageEnabled(true); 88 _webState->SetWebUsageEnabled(true);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 [_UIDelegate webViewDidClose:self]; 279 [_UIDelegate webViewDidClose:self];
264 } 280 }
265 } 281 }
266 282
267 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: 283 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState:
268 (web::WebState*)webState { 284 (web::WebState*)webState {
269 return _javaScriptDialogPresenter.get(); 285 return _javaScriptDialogPresenter.get();
270 } 286 }
271 287
272 @end 288 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698