OLD | NEW |
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 Loading... |
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 |
341 // Saves the current title to the history database. | 345 // Saves the current title to the history database. |
342 - (void)saveTitleToHistoryDB; | 346 - (void)saveTitleToHistoryDB; |
343 | 347 |
344 // Adds the current session entry to this history database. | 348 // Adds the current session entry to this history database. |
345 - (void)addCurrentEntryToHistoryDB; | 349 - (void)addCurrentEntryToHistoryDB; |
346 | 350 |
347 // Adds any cached entries from |addPageVector_| to the history DB. | 351 // Adds any cached entries from |addPageVector_| to the history DB. |
348 - (void)commitCachedEntriesToHistoryDB; | 352 - (void)commitCachedEntriesToHistoryDB; |
349 | 353 |
350 // Returns the OpenInController for this tab. | 354 // Returns the OpenInController for this tab. |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 if (browserState_->IsOffTheRecord()) { | 973 if (browserState_->IsOffTheRecord()) { |
970 style = OverscrollStyle::REGULAR_PAGE_INCOGNITO; | 974 style = OverscrollStyle::REGULAR_PAGE_INCOGNITO; |
971 } | 975 } |
972 [overscrollActionsController_ setStyle:style]; | 976 [overscrollActionsController_ setStyle:style]; |
973 [overscrollActionsController_ | 977 [overscrollActionsController_ |
974 setDelegate:overscrollActionsControllerDelegate]; | 978 setDelegate:overscrollActionsControllerDelegate]; |
975 overscrollActionsControllerDelegate_.reset( | 979 overscrollActionsControllerDelegate_.reset( |
976 overscrollActionsControllerDelegate); | 980 overscrollActionsControllerDelegate); |
977 } | 981 } |
978 | 982 |
| 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 |
979 - (void)saveTitleToHistoryDB { | 997 - (void)saveTitleToHistoryDB { |
980 // If incognito, don't update history. | 998 // If incognito, don't update history. |
981 if (browserState_->IsOffTheRecord()) | 999 if (browserState_->IsOffTheRecord()) |
982 return; | 1000 return; |
983 // Don't update the history if current entry has no title. | 1001 // Don't update the history if current entry has no title. |
984 NSString* title = [self title]; | 1002 NSString* title = [self title]; |
985 if (![title length] || | 1003 if (![title length] || |
986 [title isEqualToString:l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE)]) | 1004 [title isEqualToString:l10n_util::GetNSString(IDS_DEFAULT_TAB_TITLE)]) |
987 return; | 1005 return; |
988 | 1006 |
(...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 shouldOpenExternalURL:(const GURL&)URL { | 1822 shouldOpenExternalURL:(const GURL&)URL { |
1805 if (isPrerenderTab_ && !isLinkLoadingPrerenderTab_) { | 1823 if (isPrerenderTab_ && !isLinkLoadingPrerenderTab_) { |
1806 [delegate_ discardPrerender]; | 1824 [delegate_ discardPrerender]; |
1807 return NO; | 1825 return NO; |
1808 } | 1826 } |
1809 return YES; | 1827 return YES; |
1810 } | 1828 } |
1811 | 1829 |
1812 - (void)webController:(CRWWebController*)webController | 1830 - (void)webController:(CRWWebController*)webController |
1813 titleDidChange:(NSString*)title { | 1831 titleDidChange:(NSString*)title { |
1814 [self saveTitleToHistoryDB]; | 1832 NSString* oldTitle = [self title]; |
1815 [parentTabModel_ notifyTabChanged:self]; | 1833 BOOL isTitleChanged = (!oldTitle && title) || (oldTitle && !title) || |
| 1834 (![oldTitle isEqualToString:title]); |
| 1835 if (isTitleChanged) { |
| 1836 [self updateTitle:title]; |
| 1837 [parentTabModel_ notifyTabChanged:self]; |
| 1838 } |
1816 } | 1839 } |
1817 | 1840 |
1818 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url | 1841 - (BOOL)urlTriggersNativeAppLaunch:(const GURL&)url |
1819 sourceURL:(const GURL&)sourceURL | 1842 sourceURL:(const GURL&)sourceURL |
1820 linkClicked:(BOOL)linkClicked { | 1843 linkClicked:(BOOL)linkClicked { |
1821 // Don't open any native app directly when prerendering or from Incognito. | 1844 // Don't open any native app directly when prerendering or from Incognito. |
1822 if (isPrerenderTab_ || self.browserState->IsOffTheRecord()) | 1845 if (isPrerenderTab_ || self.browserState->IsOffTheRecord()) |
1823 return NO; | 1846 return NO; |
1824 | 1847 |
1825 base::scoped_nsprotocol<id<NativeAppMetadata>> metadata( | 1848 base::scoped_nsprotocol<id<NativeAppMetadata>> metadata( |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 | 2256 |
2234 - (TabModel*)parentTabModel { | 2257 - (TabModel*)parentTabModel { |
2235 return parentTabModel_; | 2258 return parentTabModel_; |
2236 } | 2259 } |
2237 | 2260 |
2238 - (FormInputAccessoryViewController*)inputAccessoryViewController { | 2261 - (FormInputAccessoryViewController*)inputAccessoryViewController { |
2239 return inputAccessoryViewController_.get(); | 2262 return inputAccessoryViewController_.get(); |
2240 } | 2263 } |
2241 | 2264 |
2242 @end | 2265 @end |
OLD | NEW |