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

Unified Diff: ios/chrome/browser/tabs/tab_model.mm

Issue 2766413004: [ios] Change API to inform WebStateList of opener-opened relationship. (Closed)
Patch Set: Address comments. Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/tabs/tab_model.mm
diff --git a/ios/chrome/browser/tabs/tab_model.mm b/ios/chrome/browser/tabs/tab_model.mm
index 0f7a935377393285ea2013e64244b5d4740a73db..f72b5ea5c2d5843a8e5f221e910a1cc044673248 100644
--- a/ios/chrome/browser/tabs/tab_model.mm
+++ b/ios/chrome/browser/tabs/tab_model.mm
@@ -45,6 +45,7 @@
#import "ios/shared/chrome/browser/tabs/web_state_list_fast_enumeration_helper.h"
#import "ios/shared/chrome/browser/tabs/web_state_list_metrics_observer.h"
#import "ios/shared/chrome/browser/tabs/web_state_list_observer.h"
+#import "ios/shared/chrome/browser/tabs/web_state_opener.h"
#import "ios/web/navigation/crw_session_certificate_policy_manager.h"
#import "ios/web/navigation/crw_session_controller.h"
#include "ios/web/public/browser_state.h"
@@ -445,8 +446,9 @@ Tab* GetOpenerForTab(id<NSFastEnumeration> tabs, Tab* tab) {
if (index == WebStateList::kInvalidIndex)
return nil;
- web::WebState* opener = _webStateList->GetOpenerOfWebStateAt(index);
- return opener ? LegacyTabHelper::GetTabForWebState(opener) : nil;
+ WebStateOpener opener = _webStateList->GetOpenerOfWebStateAt(index);
+ return opener.opener ? LegacyTabHelper::GetTabForWebState(opener.opener)
+ : nil;
}
- (Tab*)insertTabWithURL:(const GURL&)URL
@@ -526,12 +528,18 @@ Tab* GetOpenerForTab(id<NSFastEnumeration> tabs, Tab* tab) {
[_tabRetainer addObject:tab];
if (index == TabModelConstants::kTabPositionAutomatically) {
- _webStateList->AppendWebState(transition, tab.webState, parentTab.webState);
+ _webStateList->AppendWebState(
+ transition, tab.webState,
+ WebStateOpener(parentTab.webState, tab.openerNavigationIndex));
} else {
DCHECK_LE(index, static_cast<NSUInteger>(INT_MAX));
const int insertion_index = static_cast<int>(index);
- _webStateList->InsertWebState(insertion_index, tab.webState,
- parentTab.webState);
+ _webStateList->InsertWebState(insertion_index, tab.webState);
+ if (parentTab.webState) {
+ _webStateList->SetOpenerOfWebStateAt(
+ insertion_index,
+ WebStateOpener(parentTab.webState, tab.openerNavigationIndex));
+ }
}
// Persist the session due to a new tab being inserted. If this is a
@@ -586,8 +594,14 @@ Tab* GetOpenerForTab(id<NSFastEnumeration> tabs, Tab* tab) {
// object destroyed as expected, so it will fine to ignore the result then
// too. See http://crbug.com/546222 for progress of changing the ownership
// of the WebStates.
- ignore_result(_webStateList->ReplaceWebStateAt(
- index, newTab.webState, GetOpenerForTab(self, newTab).webState));
+ ignore_result(_webStateList->ReplaceWebStateAt(index, newTab.webState));
+
+ Tab* parentTab = GetOpenerForTab(self, newTab);
+ if (parentTab) {
+ _webStateList->SetOpenerOfWebStateAt(
+ index,
+ WebStateOpener(parentTab.webState, newTab.openerNavigationIndex));
+ }
[oldTab setParentTabModel:nil];
[oldTab close];
@@ -884,7 +898,8 @@ Tab* GetOpenerForTab(id<NSFastEnumeration> tabs, Tab* tab) {
Tab* opener = GetOpenerForTab(restoredTabs.get(), tab);
if (opener) {
DCHECK(opener.webState);
- _webStateList->SetOpenerOfWebStateAt(index, opener.webState);
+ _webStateList->SetOpenerOfWebStateAt(
+ index, WebStateOpener(opener.webState, tab.openerNavigationIndex));
}
}
« no previous file with comments | « no previous file | ios/clean/chrome/browser/ui/tab_grid/tab_grid_coordinator.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698