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

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

Issue 2956483003: [ios] TabIdTabHelper (Closed)
Patch Set: Additional unit tests and other edits. Created 3 years, 5 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 | « ios/chrome/browser/tabs/BUILD.gn ('k') | ios/chrome/browser/tabs/tab_helper_util.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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller. h" 93 #import "ios/chrome/browser/ui/overscroll_actions/overscroll_actions_controller. h"
94 #import "ios/chrome/browser/ui/prerender_delegate.h" 94 #import "ios/chrome/browser/ui/prerender_delegate.h"
95 #import "ios/chrome/browser/ui/reader_mode/reader_mode_checker.h" 95 #import "ios/chrome/browser/ui/reader_mode/reader_mode_checker.h"
96 #import "ios/chrome/browser/ui/reader_mode/reader_mode_controller.h" 96 #import "ios/chrome/browser/ui/reader_mode/reader_mode_controller.h"
97 #include "ios/chrome/browser/ui/ui_util.h" 97 #include "ios/chrome/browser/ui/ui_util.h"
98 #import "ios/chrome/browser/web/auto_reload_bridge.h" 98 #import "ios/chrome/browser/web/auto_reload_bridge.h"
99 #import "ios/chrome/browser/web/external_app_launcher.h" 99 #import "ios/chrome/browser/web/external_app_launcher.h"
100 #import "ios/chrome/browser/web/navigation_manager_util.h" 100 #import "ios/chrome/browser/web/navigation_manager_util.h"
101 #import "ios/chrome/browser/web/passkit_dialog_provider.h" 101 #import "ios/chrome/browser/web/passkit_dialog_provider.h"
102 #include "ios/chrome/browser/web/print_observer.h" 102 #include "ios/chrome/browser/web/print_observer.h"
103 #import "ios/chrome/browser/web/tab_id_tab_helper.h"
103 #include "ios/chrome/grit/ios_strings.h" 104 #include "ios/chrome/grit/ios_strings.h"
104 #import "ios/web/navigation/navigation_item_impl.h" 105 #import "ios/web/navigation/navigation_item_impl.h"
105 #import "ios/web/navigation/navigation_manager_impl.h" 106 #import "ios/web/navigation/navigation_manager_impl.h"
106 #include "ios/web/public/favicon_status.h" 107 #include "ios/web/public/favicon_status.h"
107 #include "ios/web/public/favicon_url.h" 108 #include "ios/web/public/favicon_url.h"
108 #include "ios/web/public/interstitials/web_interstitial.h" 109 #include "ios/web/public/interstitials/web_interstitial.h"
109 #include "ios/web/public/load_committed_details.h" 110 #include "ios/web/public/load_committed_details.h"
110 #import "ios/web/public/navigation_manager.h" 111 #import "ios/web/public/navigation_manager.h"
111 #include "ios/web/public/referrer.h" 112 #include "ios/web/public/referrer.h"
112 #import "ios/web/public/serializable_user_data_manager.h" 113 #import "ios/web/public/serializable_user_data_manager.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 NSString* const kTabClosingCurrentDocumentNotificationForCrashReporting = 148 NSString* const kTabClosingCurrentDocumentNotificationForCrashReporting =
148 @"kTabClosingCurrentDocumentNotificationForCrashReporting"; 149 @"kTabClosingCurrentDocumentNotificationForCrashReporting";
149 150
150 NSString* const kTabUrlKey = @"url"; 151 NSString* const kTabUrlKey = @"url";
151 152
152 namespace { 153 namespace {
153 class TabHistoryContext; 154 class TabHistoryContext;
154 class FaviconDriverObserverBridge; 155 class FaviconDriverObserverBridge;
155 class TabInfoBarObserver; 156 class TabInfoBarObserver;
156 157
157 // The key under which the Tab ID is stored in the WebState's serializable user
158 // data.
159 NSString* const kTabIDKey = @"TabID";
160
161 // Name of histogram for recording the state of the tab when the renderer is 158 // Name of histogram for recording the state of the tab when the renderer is
162 // terminated. 159 // terminated.
163 const char kRendererTerminationStateHistogram[] = 160 const char kRendererTerminationStateHistogram[] =
164 "Tab.StateAtRendererTermination"; 161 "Tab.StateAtRendererTermination";
165 162
166 // Referrer used for clicks on article suggestions on the NTP. 163 // Referrer used for clicks on article suggestions on the NTP.
167 const char kChromeContentSuggestionsReferrer[] = 164 const char kChromeContentSuggestionsReferrer[] =
168 "https://www.googleapis.com/auth/chrome-content-suggestions"; 165 "https://www.googleapis.com/auth/chrome-content-suggestions";
169 166
170 // Enum corresponding to UMA's TabForegroundState, for 167 // Enum corresponding to UMA's TabForegroundState, for
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 infobars::InfoBar* new_infobar) { 415 infobars::InfoBar* new_infobar) {
419 // Update snapshots after the infobar has been replaced. 416 // Update snapshots after the infobar has been replaced.
420 [owner_ updateSnapshotWithOverlay:YES visibleFrameOnly:YES]; 417 [owner_ updateSnapshotWithOverlay:YES visibleFrameOnly:YES];
421 } 418 }
422 419
423 } // anonymous namespace 420 } // anonymous namespace
424 421
425 @implementation Tab 422 @implementation Tab
426 423
427 @synthesize browserState = _browserState; 424 @synthesize browserState = _browserState;
428 @synthesize tabId = tabId_;
429 @synthesize useGreyImageCache = useGreyImageCache_; 425 @synthesize useGreyImageCache = useGreyImageCache_;
430 @synthesize isPrerenderTab = _isPrerenderTab; 426 @synthesize isPrerenderTab = _isPrerenderTab;
431 @synthesize isLinkLoadingPrerenderTab = isLinkLoadingPrerenderTab_; 427 @synthesize isLinkLoadingPrerenderTab = isLinkLoadingPrerenderTab_;
432 @synthesize isVoiceSearchResultsTab = _isVoiceSearchResultsTab; 428 @synthesize isVoiceSearchResultsTab = _isVoiceSearchResultsTab;
433 @synthesize passwordController = passwordController_; 429 @synthesize passwordController = passwordController_;
434 @synthesize overscrollActionsController = _overscrollActionsController; 430 @synthesize overscrollActionsController = _overscrollActionsController;
435 @synthesize readerModeController = readerModeController_; 431 @synthesize readerModeController = readerModeController_;
436 @synthesize overscrollActionsControllerDelegate = 432 @synthesize overscrollActionsControllerDelegate =
437 overscrollActionsControllerDelegate_; 433 overscrollActionsControllerDelegate_;
438 @synthesize passKitDialogProvider = passKitDialogProvider_; 434 @synthesize passKitDialogProvider = passKitDialogProvider_;
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr); 603 net::UnescapeRule::SPACES, nullptr, nullptr, nullptr);
608 return base::SysUTF16ToNSString(urlText); 604 return base::SysUTF16ToNSString(urlText);
609 } 605 }
610 606
611 - (NSString*)tabId { 607 - (NSString*)tabId {
612 if (!self.webState) { 608 if (!self.webState) {
613 // Tab can outlive WebState, in which case Tab is not valid anymore and 609 // Tab can outlive WebState, in which case Tab is not valid anymore and
614 // tabId should be nil. 610 // tabId should be nil.
615 return nil; 611 return nil;
616 } 612 }
617 613 TabIdTabHelper* tab_id_helper = TabIdTabHelper::FromWebState(self.webState);
618 if (tabId_) 614 DCHECK(tab_id_helper);
619 return tabId_; 615 return tab_id_helper->tab_id();
620
621 web::SerializableUserDataManager* userDataManager =
622 web::SerializableUserDataManager::FromWebState(self.webState);
623 NSString* tabId = base::mac::ObjCCast<NSString>(
624 userDataManager->GetValueForSerializationKey(kTabIDKey));
625
626 if (!tabId || ![tabId length]) {
627 tabId = [[NSUUID UUID] UUIDString];
628 userDataManager->AddSerializableData(tabId, kTabIDKey);
629 }
630
631 tabId_ = [tabId copy];
632 return tabId_;
633 } 616 }
634 617
635 - (web::WebState*)webState { 618 - (web::WebState*)webState {
636 return _webStateImpl; 619 return _webStateImpl;
637 } 620 }
638 621
639 - (void)fetchFavicon { 622 - (void)fetchFavicon {
640 const GURL& url = self.visibleURL; 623 const GURL& url = self.visibleURL;
641 if (!url.is_valid()) 624 if (!url.is_valid())
642 return; 625 return;
(...skipping 1186 matching lines...) Expand 10 before | Expand all | Expand 10 after
1829 1812
1830 - (TabModel*)parentTabModel { 1813 - (TabModel*)parentTabModel {
1831 return _parentTabModel; 1814 return _parentTabModel;
1832 } 1815 }
1833 1816
1834 - (FormInputAccessoryViewController*)inputAccessoryViewController { 1817 - (FormInputAccessoryViewController*)inputAccessoryViewController {
1835 return _inputAccessoryViewController; 1818 return _inputAccessoryViewController;
1836 } 1819 }
1837 1820
1838 @end 1821 @end
OLDNEW
« no previous file with comments | « ios/chrome/browser/tabs/BUILD.gn ('k') | ios/chrome/browser/tabs/tab_helper_util.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698