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

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

Issue 2701463002: 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 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 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 // in order of priority. 342 // in order of priority.
343 - (NSArray*)suggestionProviders; 343 - (NSArray*)suggestionProviders;
344 344
345 // Returns a list of FormInputAccessoryViewProviders to be queried for an input 345 // Returns a list of FormInputAccessoryViewProviders to be queried for an input
346 // accessory view in order of priority. 346 // accessory view in order of priority.
347 - (NSArray*)accessoryViewProviders; 347 - (NSArray*)accessoryViewProviders;
348 348
349 // Sets the favicon on the current NavigationItem. 349 // Sets the favicon on the current NavigationItem.
350 - (void)setFavicon:(const gfx::Image*)image; 350 - (void)setFavicon:(const gfx::Image*)image;
351 351
352 // Updates the title field of the current session entry. Also updates the
353 // history database.
354 - (void)updateTitle:(NSString*)title;
355
356 // Saves the current title to the history database. 352 // Saves the current title to the history database.
357 - (void)saveTitleToHistoryDB; 353 - (void)saveTitleToHistoryDB;
358 354
359 // Returns a lazily instantiated popup handler. 355 // Returns a lazily instantiated popup handler.
360 - (BlockedPopupHandler*)popupHandler; 356 - (BlockedPopupHandler*)popupHandler;
361 357
362 // Adds the current session entry to this history database. 358 // Adds the current session entry to this history database.
363 - (void)addCurrentEntryToHistoryDB; 359 - (void)addCurrentEntryToHistoryDB;
364 360
365 // Adds any cached entries from |addPageVector_| to the history DB. 361 // Adds any cached entries from |addPageVector_| to the history DB.
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
998 if (browserState_->IsOffTheRecord()) { 994 if (browserState_->IsOffTheRecord()) {
999 style = OverscrollStyle::REGULAR_PAGE_INCOGNITO; 995 style = OverscrollStyle::REGULAR_PAGE_INCOGNITO;
1000 } 996 }
1001 [overscrollActionsController_ setStyle:style]; 997 [overscrollActionsController_ setStyle:style];
1002 [overscrollActionsController_ 998 [overscrollActionsController_
1003 setDelegate:overscrollActionsControllerDelegate]; 999 setDelegate:overscrollActionsControllerDelegate];
1004 overscrollActionsControllerDelegate_.reset( 1000 overscrollActionsControllerDelegate_.reset(
1005 overscrollActionsControllerDelegate); 1001 overscrollActionsControllerDelegate);
1006 } 1002 }
1007 1003
1008 - (void)updateTitle:(NSString*)title {
1009 web::NavigationItem* item = [self navigationManager]->GetVisibleItem();
1010 if (!item)
1011 return;
1012 item->SetTitle(base::SysNSStringToUTF16(title));
1013 // TODO(crbug.com/546218): See if this can be removed; it's not clear that
1014 // other platforms send this (tab sync triggers need to be compared against
1015 // upstream).
1016 if (self.webStateImpl)
1017 self.webStateImpl->GetNavigationManagerImpl().OnNavigationItemChanged();
1018
1019 [self saveTitleToHistoryDB];
1020 }
1021
1022 - (void)saveTitleToHistoryDB { 1004 - (void)saveTitleToHistoryDB {
1023 // If incognito, don't update history. 1005 // If incognito, don't update history.
1024 if (browserState_->IsOffTheRecord()) 1006 if (browserState_->IsOffTheRecord())
1025 return; 1007 return;
1026 // Don't update the history if current entry has no title. 1008 // Don't update the history if current entry has no title.
1027 NSString* title = [self title]; 1009 NSString* title = [self title];
1028 if (![title length] || 1010 if (![title length] ||
1029 [title isEqualToString:l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE)]) 1011 [title isEqualToString:l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE)])
1030 return; 1012 return;
1031 1013
(...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after
1897 shouldOpenExternalURL:(const GURL&)URL { 1879 shouldOpenExternalURL:(const GURL&)URL {
1898 if (isPrerenderTab_ && !isLinkLoadingPrerenderTab_) { 1880 if (isPrerenderTab_ && !isLinkLoadingPrerenderTab_) {
1899 [delegate_ discardPrerender]; 1881 [delegate_ discardPrerender];
1900 return NO; 1882 return NO;
1901 } 1883 }
1902 return YES; 1884 return YES;
1903 } 1885 }
1904 1886
1905 - (void)webController:(CRWWebController*)webController 1887 - (void)webController:(CRWWebController*)webController
1906 titleDidChange:(NSString*)title { 1888 titleDidChange:(NSString*)title {
1907 NSString* oldTitle = [self title]; 1889 [self saveTitleToHistoryDB];
1908 BOOL isTitleChanged = (!oldTitle && title) || (oldTitle && !title) || 1890 [parentTabModel_ notifyTabChanged:self];
1909 (![oldTitle isEqualToString:title]);
1910 if (isTitleChanged) {
1911 [self updateTitle:title];
1912 [parentTabModel_ notifyTabChanged:self];
1913 }
1914 } 1891 }
1915 1892
1916 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url 1893 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url
1917 sourceURL:(const GURL&)sourceURL 1894 sourceURL:(const GURL&)sourceURL
1918 linkClicked:(BOOL)linkClicked { 1895 linkClicked:(BOOL)linkClicked {
1919 // Don't open any native app directly when prerendering or from Incognito. 1896 // Don't open any native app directly when prerendering or from Incognito.
1920 if (isPrerenderTab_ || self.browserState->IsOffTheRecord()) 1897 if (isPrerenderTab_ || self.browserState->IsOffTheRecord())
1921 return NO; 1898 return NO;
1922 1899
1923 base::scoped_nsprotocol<id<NativeAppMetadata>> metadata( 1900 base::scoped_nsprotocol<id<NativeAppMetadata>> metadata(
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
2334 2311
2335 - (TabModel*)parentTabModel { 2312 - (TabModel*)parentTabModel {
2336 return parentTabModel_; 2313 return parentTabModel_;
2337 } 2314 }
2338 2315
2339 - (FormInputAccessoryViewController*)inputAccessoryViewController { 2316 - (FormInputAccessoryViewController*)inputAccessoryViewController {
2340 return inputAccessoryViewController_.get(); 2317 return inputAccessoryViewController_.get();
2341 } 2318 }
2342 2319
2343 @end 2320 @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