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

Unified Diff: ios/web/web_state/ui/crw_web_controller.mm

Issue 2711123004: Cherry-picked remaining parts of 'Fixed title updating for back forward navigation.' (Closed)
Patch Set: Created 3 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_web_controller.mm
diff --git a/ios/web/web_state/ui/crw_web_controller.mm b/ios/web/web_state/ui/crw_web_controller.mm
index 1f20df56c0032658f45927fa4d62cfa0d7e43a85..3e85b266568658499e98974d12770f8dc29bd0be 100644
--- a/ios/web/web_state/ui/crw_web_controller.mm
+++ b/ios/web/web_state/ui/crw_web_controller.mm
@@ -739,8 +739,9 @@ typedef void (^ViewportStateCompletion)(const web::PageViewportState*);
stateObject:(NSString*)stateObject;
// Sets _documentURL to newURL, and updates any relevant state information.
- (void)setDocumentURL:(const GURL&)newURL;
-// Sets WKWebView's title to the last committed navigation item.
-- (void)updateNavigationItemTitle;
+// Sets last committed NavigationItem's title to the given |title|, which can
+// not be nil.
+- (void)setNavigationItemTitle:(NSString*)title;
// Returns YES if the current navigation item corresponds to a web page
// loaded by a POST request.
- (BOOL)isCurrentNavigationItemPOST;
@@ -1423,15 +1424,14 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
}
}
-- (void)updateNavigationItemTitle {
- NSString* webViewTitle = [_webView title];
- DCHECK(webViewTitle);
+- (void)setNavigationItemTitle:(NSString*)title {
+ DCHECK(title);
auto& navigationManager = _webStateImpl->GetNavigationManagerImpl();
web::NavigationItem* item = navigationManager.GetLastCommittedItem();
if (!item)
return;
- base::string16 newTitle = base::SysNSStringToUTF16(webViewTitle);
+ base::string16 newTitle = base::SysNSStringToUTF16(title);
if (item->GetTitle() == newTitle)
return;
@@ -1442,7 +1442,7 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
navigationManager.OnNavigationItemChanged();
if ([_delegate respondsToSelector:@selector(webController:titleDidChange:)]) {
- [_delegate webController:self titleDidChange:webViewTitle];
+ [_delegate webController:self titleDidChange:title];
}
}
@@ -1870,14 +1870,13 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
// Perform post-load-finished updates.
[self didFinishWithURL:currentURL loadSuccess:loadSuccess];
- // Inform the embedder the title changed.
+ NSString* title = [self.nativeController title];
+ if (title)
+ [self setNavigationItemTitle:title];
+
+ // If the controller handles title change notification, route those to the
+ // delegate.
if ([_delegate respondsToSelector:@selector(webController:titleDidChange:)]) {
- NSString* title = [self.nativeController title];
- // If a title is present, notify the delegate.
- if (title)
- [_delegate webController:self titleDidChange:title];
- // If the controller handles title change notification, route those to the
- // delegate.
if ([self.nativeController respondsToSelector:@selector(setDelegate:)]) {
[self.nativeController setDelegate:self];
}
@@ -4982,7 +4981,6 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
// This is the point where the document's URL and title have actually changed,
// and pending navigation information should be applied to state information.
[self setDocumentURL:net::GURLWithNSURL([_webView URL])];
- [self updateNavigationItemTitle];
if (!_lastRegisteredRequestURL.is_valid() &&
_documentURL != _lastRegisteredRequestURL) {
@@ -5025,6 +5023,10 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
// Attempt to update the HTML5 history state.
[self updateHTML5HistoryState];
+ // This is the point where pending entry has been committed, and navigation
+ // item title should be updated.
+ [self setNavigationItemTitle:[_webView title]];
+
// Report cases where SSL cert is missing for a secure connection.
if (_documentURL.SchemeIsCryptographic()) {
scoped_refptr<net::X509Certificate> cert =
@@ -5225,7 +5227,7 @@ const NSTimeInterval kSnapshotOverlayTransition = 0.5;
if (hasPendingNavigation) {
// Do not update the title if there is a navigation in progress because
// there is no way to tell if KVO change fired for new or previous page.
- [self updateNavigationItemTitle];
+ [self setNavigationItemTitle:[_webView title]];
}
}
« 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