| Index: ios/chrome/browser/tabs/tab.mm
|
| diff --git a/ios/chrome/browser/tabs/tab.mm b/ios/chrome/browser/tabs/tab.mm
|
| index de02267567d80d4f495596526d3fe7c93f3273ce..cd84b0fce7d043e1daa43e47cafd2d575580e404 100644
|
| --- a/ios/chrome/browser/tabs/tab.mm
|
| +++ b/ios/chrome/browser/tabs/tab.mm
|
| @@ -338,6 +338,10 @@
|
| // Sets the favicon on the current NavigationItem.
|
| - (void)setFavicon:(const gfx::Image*)image;
|
|
|
| +// Updates the title field of the current session entry. Also updates the
|
| +// history database.
|
| +- (void)updateTitle:(NSString*)title;
|
| +
|
| // Saves the current title to the history database.
|
| - (void)saveTitleToHistoryDB;
|
|
|
| @@ -974,6 +978,20 @@
|
| setDelegate:overscrollActionsControllerDelegate];
|
| overscrollActionsControllerDelegate_.reset(
|
| overscrollActionsControllerDelegate);
|
| +}
|
| +
|
| +- (void)updateTitle:(NSString*)title {
|
| + web::NavigationItem* item = [self navigationManager]->GetVisibleItem();
|
| + if (!item)
|
| + return;
|
| + item->SetTitle(base::SysNSStringToUTF16(title));
|
| + // TODO(crbug.com/546218): See if this can be removed; it's not clear that
|
| + // other platforms send this (tab sync triggers need to be compared against
|
| + // upstream).
|
| + if (webStateImpl_)
|
| + webStateImpl_->GetNavigationManagerImpl().OnNavigationItemChanged();
|
| +
|
| + [self saveTitleToHistoryDB];
|
| }
|
|
|
| - (void)saveTitleToHistoryDB {
|
| @@ -1811,8 +1829,13 @@
|
|
|
| - (void)webController:(CRWWebController*)webController
|
| titleDidChange:(NSString*)title {
|
| - [self saveTitleToHistoryDB];
|
| - [parentTabModel_ notifyTabChanged:self];
|
| + NSString* oldTitle = [self title];
|
| + BOOL isTitleChanged = (!oldTitle && title) || (oldTitle && !title) ||
|
| + (![oldTitle isEqualToString:title]);
|
| + if (isTitleChanged) {
|
| + [self updateTitle:title];
|
| + [parentTabModel_ notifyTabChanged:self];
|
| + }
|
| }
|
|
|
| - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url
|
|
|