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

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

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

Powered by Google App Engine
This is Rietveld 408576698