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

Side by Side Diff: ios/web_view/internal/cwv_web_view.mm

Issue 2935923002: Correctly update CWVWebView properties on state restoration. (Closed)
Patch Set: Factored code to updateTitle Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 @property(nonatomic, readwrite) NSURL* lastCommittedURL; 80 @property(nonatomic, readwrite) NSURL* lastCommittedURL;
81 @property(nonatomic, readwrite) BOOL loading; 81 @property(nonatomic, readwrite) BOOL loading;
82 @property(nonatomic, readwrite, copy) NSString* title; 82 @property(nonatomic, readwrite, copy) NSString* title;
83 @property(nonatomic, readwrite) NSURL* visibleURL; 83 @property(nonatomic, readwrite) NSURL* visibleURL;
84 84
85 // Updates the availability of the back/forward navigation properties exposed 85 // Updates the availability of the back/forward navigation properties exposed
86 // through |canGoBack| and |canGoForward|. 86 // through |canGoBack| and |canGoForward|.
87 - (void)updateNavigationAvailability; 87 - (void)updateNavigationAvailability;
88 // Updates the URLs exposed through |lastCommittedURL| and |visibleURL|. 88 // Updates the URLs exposed through |lastCommittedURL| and |visibleURL|.
89 - (void)updateCurrentURLs; 89 - (void)updateCurrentURLs;
90 // Updates |title| property.
91 - (void)updateTitle;
90 92
91 @end 93 @end
92 94
93 static NSString* gUserAgentProduct = nil; 95 static NSString* gUserAgentProduct = nil;
94 96
95 @implementation CWVWebView 97 @implementation CWVWebView
96 98
97 @synthesize canGoBack = _canGoBack; 99 @synthesize canGoBack = _canGoBack;
98 @synthesize canGoForward = _canGoForward; 100 @synthesize canGoForward = _canGoForward;
99 @synthesize configuration = _configuration; 101 @synthesize configuration = _configuration;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 234
233 - (void)webStateDidStopLoading:(web::WebState*)webState { 235 - (void)webStateDidStopLoading:(web::WebState*)webState {
234 self.loading = _webState->IsLoading(); 236 self.loading = _webState->IsLoading();
235 } 237 }
236 238
237 - (void)webStateDidStartLoading:(web::WebState*)webState { 239 - (void)webStateDidStartLoading:(web::WebState*)webState {
238 self.loading = _webState->IsLoading(); 240 self.loading = _webState->IsLoading();
239 } 241 }
240 242
241 - (void)webStateDidChangeTitle:(web::WebState*)webState { 243 - (void)webStateDidChangeTitle:(web::WebState*)webState {
242 self.title = base::SysUTF16ToNSString(_webState->GetTitle()); 244 [self updateTitle];
243 } 245 }
244 246
245 - (void)renderProcessGoneForWebState:(web::WebState*)webState { 247 - (void)renderProcessGoneForWebState:(web::WebState*)webState {
246 SEL selector = @selector(webViewWebContentProcessDidTerminate:); 248 SEL selector = @selector(webViewWebContentProcessDidTerminate:);
247 if ([_navigationDelegate respondsToSelector:selector]) { 249 if ([_navigationDelegate respondsToSelector:selector]) {
248 [_navigationDelegate webViewWebContentProcessDidTerminate:self]; 250 [_navigationDelegate webViewWebContentProcessDidTerminate:self];
249 } 251 }
250 } 252 }
251 253
252 - (BOOL)webState:(web::WebState*)webState 254 - (BOOL)webState:(web::WebState*)webState
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 368
367 _javaScriptDialogPresenter = 369 _javaScriptDialogPresenter =
368 base::MakeUnique<ios_web_view::WebViewJavaScriptDialogPresenter>(self, 370 base::MakeUnique<ios_web_view::WebViewJavaScriptDialogPresenter>(self,
369 nullptr); 371 nullptr);
370 372
371 _scrollView.proxy = _webState.get()->GetWebViewProxy().scrollViewProxy; 373 _scrollView.proxy = _webState.get()->GetWebViewProxy().scrollViewProxy;
372 374
373 _translationController.webState = _webState.get(); 375 _translationController.webState = _webState.get();
374 376
375 [self addInternalWebViewAsSubview]; 377 [self addInternalWebViewAsSubview];
378
379 [self updateNavigationAvailability];
380 [self updateCurrentURLs];
381 [self updateTitle];
382 self.loading = NO;
383 self.estimatedProgress = 0.0;
376 } 384 }
377 385
378 // Adds the web view provided by |_webState| as a subview unless it has already. 386 // Adds the web view provided by |_webState| as a subview unless it has already.
379 - (void)addInternalWebViewAsSubview { 387 - (void)addInternalWebViewAsSubview {
380 UIView* subview = _webState->GetView(); 388 UIView* subview = _webState->GetView();
381 if (subview.superview == self) { 389 if (subview.superview == self) {
382 return; 390 return;
383 } 391 }
384 subview.frame = self.bounds; 392 subview.frame = self.bounds;
385 subview.autoresizingMask = 393 subview.autoresizingMask =
386 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 394 UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
387 [self addSubview:subview]; 395 [self addSubview:subview];
388 } 396 }
389 397
390 - (void)updateNavigationAvailability { 398 - (void)updateNavigationAvailability {
391 self.canGoBack = _webState && _webState->GetNavigationManager()->CanGoBack(); 399 self.canGoBack = _webState && _webState->GetNavigationManager()->CanGoBack();
392 self.canGoForward = 400 self.canGoForward =
393 _webState && _webState->GetNavigationManager()->CanGoForward(); 401 _webState && _webState->GetNavigationManager()->CanGoForward();
394 } 402 }
395 403
396 - (void)updateCurrentURLs { 404 - (void)updateCurrentURLs {
397 self.lastCommittedURL = net::NSURLWithGURL(_webState->GetLastCommittedURL()); 405 self.lastCommittedURL = net::NSURLWithGURL(_webState->GetLastCommittedURL());
398 self.visibleURL = net::NSURLWithGURL(_webState->GetVisibleURL()); 406 self.visibleURL = net::NSURLWithGURL(_webState->GetVisibleURL());
399 } 407 }
400 408
409 - (void)updateTitle {
410 self.title = base::SysUTF16ToNSString(_webState->GetTitle());
411 }
412
401 @end 413 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698