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

Side by Side Diff: ios/chrome/browser/tabs/tab.mm

Issue 2685803002: Fixed title updating for back forward navigation. (Closed)
Patch Set: Stubbed title call 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 unified diff | Download patch
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/chrome/browser/tabs/tab.h" 5 #import "ios/chrome/browser/tabs/tab.h"
6 6
7 #import <CoreLocation/CoreLocation.h> 7 #import <CoreLocation/CoreLocation.h>
8 #import <UIKit/UIKit.h> 8 #import <UIKit/UIKit.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // in order of priority. 331 // in order of priority.
332 - (NSArray*)suggestionProviders; 332 - (NSArray*)suggestionProviders;
333 333
334 // Returns a list of FormInputAccessoryViewProviders to be queried for an input 334 // Returns a list of FormInputAccessoryViewProviders to be queried for an input
335 // accessory view in order of priority. 335 // accessory view in order of priority.
336 - (NSArray*)accessoryViewProviders; 336 - (NSArray*)accessoryViewProviders;
337 337
338 // Sets the favicon on the current NavigationItem. 338 // Sets the favicon on the current NavigationItem.
339 - (void)setFavicon:(const gfx::Image*)image; 339 - (void)setFavicon:(const gfx::Image*)image;
340 340
341 // Updates the title field of the current session entry. Also updates the
342 // history database.
343 - (void)updateTitle:(NSString*)title;
344
345 // Saves the current title to the history database. 341 // Saves the current title to the history database.
346 - (void)saveTitleToHistoryDB; 342 - (void)saveTitleToHistoryDB;
347 343
348 // Adds the current session entry to this history database. 344 // Adds the current session entry to this history database.
349 - (void)addCurrentEntryToHistoryDB; 345 - (void)addCurrentEntryToHistoryDB;
350 346
351 // Adds any cached entries from |addPageVector_| to the history DB. 347 // Adds any cached entries from |addPageVector_| to the history DB.
352 - (void)commitCachedEntriesToHistoryDB; 348 - (void)commitCachedEntriesToHistoryDB;
353 349
354 // Returns the OpenInController for this tab. 350 // Returns the OpenInController for this tab.
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 if (browserState_->IsOffTheRecord()) { 969 if (browserState_->IsOffTheRecord()) {
974 style = OverscrollStyle::REGULAR_PAGE_INCOGNITO; 970 style = OverscrollStyle::REGULAR_PAGE_INCOGNITO;
975 } 971 }
976 [overscrollActionsController_ setStyle:style]; 972 [overscrollActionsController_ setStyle:style];
977 [overscrollActionsController_ 973 [overscrollActionsController_
978 setDelegate:overscrollActionsControllerDelegate]; 974 setDelegate:overscrollActionsControllerDelegate];
979 overscrollActionsControllerDelegate_.reset( 975 overscrollActionsControllerDelegate_.reset(
980 overscrollActionsControllerDelegate); 976 overscrollActionsControllerDelegate);
981 } 977 }
982 978
983 - (void)updateTitle:(NSString*)title {
984 web::NavigationItem* item = [self navigationManager]->GetVisibleItem();
985 if (!item)
986 return;
987 item->SetTitle(base::SysNSStringToUTF16(title));
988 // TODO(crbug.com/546218): See if this can be removed; it's not clear that
989 // other platforms send this (tab sync triggers need to be compared against
990 // upstream).
991 if (webStateImpl_)
992 webStateImpl_->GetNavigationManagerImpl().OnNavigationItemChanged();
993
994 [self saveTitleToHistoryDB];
995 }
996
997 - (void)saveTitleToHistoryDB { 979 - (void)saveTitleToHistoryDB {
998 // If incognito, don't update history. 980 // If incognito, don't update history.
999 if (browserState_->IsOffTheRecord()) 981 if (browserState_->IsOffTheRecord())
1000 return; 982 return;
1001 // Don't update the history if current entry has no title. 983 // Don't update the history if current entry has no title.
1002 NSString* title = [self title]; 984 NSString* title = [self title];
1003 if (![title length] || 985 if (![title length] ||
1004 [title isEqualToString:l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE)]) 986 [title isEqualToString:l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE)])
1005 return; 987 return;
1006 988
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after
1822 shouldOpenExternalURL:(const GURL&)URL { 1804 shouldOpenExternalURL:(const GURL&)URL {
1823 if (isPrerenderTab_ && !isLinkLoadingPrerenderTab_) { 1805 if (isPrerenderTab_ && !isLinkLoadingPrerenderTab_) {
1824 [delegate_ discardPrerender]; 1806 [delegate_ discardPrerender];
1825 return NO; 1807 return NO;
1826 } 1808 }
1827 return YES; 1809 return YES;
1828 } 1810 }
1829 1811
1830 - (void)webController:(CRWWebController*)webController 1812 - (void)webController:(CRWWebController*)webController
1831 titleDidChange:(NSString*)title { 1813 titleDidChange:(NSString*)title {
1832 NSString* oldTitle = [self title]; 1814 [self saveTitleToHistoryDB];
1833 BOOL isTitleChanged = (!oldTitle && title) || (oldTitle && !title) || 1815 [parentTabModel_ notifyTabChanged:self];
1834 (![oldTitle isEqualToString:title]);
1835 if (isTitleChanged) {
1836 [self updateTitle:title];
1837 [parentTabModel_ notifyTabChanged:self];
1838 }
1839 } 1816 }
1840 1817
1841 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url 1818 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url
1842 sourceURL:(const GURL&)sourceURL 1819 sourceURL:(const GURL&)sourceURL
1843 linkClicked:(BOOL)linkClicked { 1820 linkClicked:(BOOL)linkClicked {
1844 // Don't open any native app directly when prerendering or from Incognito. 1821 // Don't open any native app directly when prerendering or from Incognito.
1845 if (isPrerenderTab_ || self.browserState->IsOffTheRecord()) 1822 if (isPrerenderTab_ || self.browserState->IsOffTheRecord())
1846 return NO; 1823 return NO;
1847 1824
1848 base::scoped_nsprotocol<id<NativeAppMetadata>> metadata( 1825 base::scoped_nsprotocol<id<NativeAppMetadata>> metadata(
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2256 2233
2257 - (TabModel*)parentTabModel { 2234 - (TabModel*)parentTabModel {
2258 return parentTabModel_; 2235 return parentTabModel_;
2259 } 2236 }
2260 2237
2261 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2238 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2262 return inputAccessoryViewController_.get(); 2239 return inputAccessoryViewController_.get();
2263 } 2240 }
2264 2241
2265 @end 2242 @end
OLDNEW
« no previous file with comments | « no previous file | ios/chrome/browser/tabs/tab_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698