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

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

Issue 2678823002: Invokes TabParentingGlobalObserver for every Tab parented. (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 | no next file » | 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_model.h" 5 #import "ios/chrome/browser/tabs/tab_model.h"
6 6
7 #include <list> 7 #include <list>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 [self insertTab:tab atIndex:index]; 574 [self insertTab:tab atIndex:index];
575 return tab; 575 return tab;
576 } 576 }
577 577
578 - (void)insertTab:(Tab*)tab atIndex:(NSUInteger)index { 578 - (void)insertTab:(Tab*)tab atIndex:(NSUInteger)index {
579 DCHECK(tab); 579 DCHECK(tab);
580 DCHECK(index <= [_tabs count]); 580 DCHECK(index <= [_tabs count]);
581 [tab fetchFavicon]; 581 [tab fetchFavicon];
582 [_tabs insertObject:tab atIndex:index]; 582 [_tabs insertObject:tab atIndex:index];
583 583
584 TabParentingGlobalObserver::GetInstance()->OnTabParented(tab.webState);
584 [_observers tabModel:self didInsertTab:tab atIndex:index inForeground:NO]; 585 [_observers tabModel:self didInsertTab:tab atIndex:index inForeground:NO];
585 [_observers tabModelDidChangeTabCount:self]; 586 [_observers tabModelDidChangeTabCount:self];
586 587
587 base::RecordAction(base::UserMetricsAction("MobileNewTabOpened")); 588 base::RecordAction(base::UserMetricsAction("MobileNewTabOpened"));
588 // Persist the session due to a new tab being inserted. If this is a 589 // Persist the session due to a new tab being inserted. If this is a
589 // background tab (will not become active), saving now will capture the 590 // background tab (will not become active), saving now will capture the
590 // state properly. If it does eventually become active, another save will 591 // state properly. If it does eventually become active, another save will
591 // be triggered to properly capture the end result. 592 // be triggered to properly capture the end result.
592 [self saveSessionImmediately:NO]; 593 [self saveSessionImmediately:NO];
593 ++_newTabCount; 594 ++_newTabCount;
(...skipping 19 matching lines...) Expand all
613 withTab:(Tab*)newTab 614 withTab:(Tab*)newTab
614 keepOldTabOpen:(BOOL)keepOldTabOpen { 615 keepOldTabOpen:(BOOL)keepOldTabOpen {
615 NSUInteger index = [self indexOfTab:oldTab]; 616 NSUInteger index = [self indexOfTab:oldTab];
616 DCHECK_NE(NSNotFound, static_cast<NSInteger>(index)); 617 DCHECK_NE(NSNotFound, static_cast<NSInteger>(index));
617 618
618 base::scoped_nsobject<Tab> tabSaver([oldTab retain]); 619 base::scoped_nsobject<Tab> tabSaver([oldTab retain]);
619 [newTab fetchFavicon]; 620 [newTab fetchFavicon];
620 [_tabs replaceObjectAtIndex:index withObject:newTab]; 621 [_tabs replaceObjectAtIndex:index withObject:newTab];
621 [newTab setParentTabModel:self]; 622 [newTab setParentTabModel:self];
622 623
624 TabParentingGlobalObserver::GetInstance()->OnTabParented(newTab.webState);
623 [_observers tabModel:self didReplaceTab:oldTab withTab:newTab atIndex:index]; 625 [_observers tabModel:self didReplaceTab:oldTab withTab:newTab atIndex:index];
624 626
625 if (self.currentTab == oldTab) 627 if (self.currentTab == oldTab)
626 [self changeSelectedTabFrom:nil to:newTab persistState:NO]; 628 [self changeSelectedTabFrom:nil to:newTab persistState:NO];
627 629
628 [oldTab setParentTabModel:nil]; 630 [oldTab setParentTabModel:nil];
629 if (!keepOldTabOpen) 631 if (!keepOldTabOpen)
630 [oldTab close]; 632 [oldTab close];
631 633
632 // Record a tab clobber, since swapping tabs bypasses the tab code that would 634 // Record a tab clobber, since swapping tabs bypasses the tab code that would
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 web::NavigationManager::WebLoadParams params(URL); 1075 web::NavigationManager::WebLoadParams params(URL);
1074 params.referrer = referrer; 1076 params.referrer = referrer;
1075 params.transition_type = ui::PAGE_TRANSITION_TYPED; 1077 params.transition_type = ui::PAGE_TRANSITION_TYPED;
1076 [[tab webController] loadWithParams:params]; 1078 [[tab webController] loadWithParams:params];
1077 [tab webController].webUsageEnabled = webUsageEnabled_; 1079 [tab webController].webUsageEnabled = webUsageEnabled_;
1078 [self insertTab:tab atIndex:index]; 1080 [self insertTab:tab atIndex:index];
1079 return tab; 1081 return tab;
1080 } 1082 }
1081 1083
1082 @end 1084 @end
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698