diff options
Diffstat (limited to 'chrome/browser/cocoa')
14 files changed, 131 insertions, 114 deletions
diff --git a/chrome/browser/cocoa/applescript/window_applescript.mm b/chrome/browser/cocoa/applescript/window_applescript.mm index 7f5e6a5..631d52c 100644 --- a/chrome/browser/cocoa/applescript/window_applescript.mm +++ b/chrome/browser/cocoa/applescript/window_applescript.mm @@ -18,6 +18,7 @@ #import "chrome/browser/cocoa/applescript/tab_applescript.h" #include "chrome/browser/profile.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/ui/browser_navigator.h" #include "chrome/common/url_constants.h" @@ -170,16 +171,16 @@ // Set how long it takes a tab to be created. base::TimeTicks newTabStartTime = base::TimeTicks::Now(); - TabContents* contents = + TabContentsWrapper* contents = browser_->AddSelectedTabWithURL(GURL(chrome::kChromeUINewTabURL), PageTransition::TYPED); - contents->set_new_tab_start_time(newTabStartTime); - - [aTab setTabContent:contents]; + contents->tab_contents()->set_new_tab_start_time(newTabStartTime); + [aTab setTabContent:contents->tab_contents()]; } - (void)insertInTabs:(TabAppleScript*)aTab atIndex:(int)index { // This method gets called when a new tab is created so + // This method gets called when a new tab is created so // the container and property are set here. [aTab setContainer:self property:AppleScript::kTabsProperty]; @@ -192,9 +193,10 @@ params.disposition = NEW_FOREGROUND_TAB; params.tabstrip_index = index; browser::Navigate(¶ms); - params.target_contents->set_new_tab_start_time(newTabStartTime); + params.target_contents->tab_contents()->set_new_tab_start_time( + newTabStartTime); - [aTab setTabContent:params.target_contents]; + [aTab setTabContent:params.target_contents->tab_contents()]; } - (void)removeFromTabsAtIndex:(int)index { diff --git a/chrome/browser/cocoa/bookmarks/bookmark_all_tabs_controller.mm b/chrome/browser/cocoa/bookmarks/bookmark_all_tabs_controller.mm index 0c4be7c..125d8e1 100644 --- a/chrome/browser/cocoa/bookmarks/bookmark_all_tabs_controller.mm +++ b/chrome/browser/cocoa/bookmarks/bookmark_all_tabs_controller.mm @@ -11,6 +11,7 @@ #include "chrome/browser/browser.h" #include "chrome/browser/browser_list.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "grit/generated_resources.h" @@ -44,7 +45,7 @@ TabStripModel* tabstrip_model = browser->tabstrip_model(); const int tabCount = tabstrip_model->count(); for (int i = 0; i < tabCount; ++i) { - TabContents* tc = tabstrip_model->GetTabContentsAt(i); + TabContents* tc = tabstrip_model->GetTabContentsAt(i)->tab_contents(); const string16 tabTitle = tc->GetTitle(); const GURL& tabURL(tc->GetURL()); ActiveTabNameURLPair tabPair(tabTitle, tabURL); diff --git a/chrome/browser/cocoa/bookmarks/bookmark_bar_controller.mm b/chrome/browser/cocoa/bookmarks/bookmark_bar_controller.mm index 03e867e..79d8c23 100644 --- a/chrome/browser/cocoa/bookmarks/bookmark_bar_controller.mm +++ b/chrome/browser/cocoa/bookmarks/bookmark_bar_controller.mm @@ -1970,9 +1970,8 @@ static BOOL ValueInRangeInclusive(CGFloat low, CGFloat value, CGFloat high) { #pragma mark BookmarkBarToolbarViewController Protocol - (int)currentTabContentsHeight { - return browser_->GetSelectedTabContents() ? - browser_->GetSelectedTabContents()->view()->GetContainerSize().height() : - 0; + TabContents* tc = browser_->GetSelectedTabContents(); + return tc ? tc->view()->GetContainerSize().height() : 0; } - (ThemeProvider*)themeProvider { diff --git a/chrome/browser/cocoa/browser_window_cocoa.h b/chrome/browser/cocoa/browser_window_cocoa.h index 486ec11..1e9cf22 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.h +++ b/chrome/browser/cocoa/browser_window_cocoa.h @@ -56,7 +56,7 @@ class BrowserWindowCocoa : public BrowserWindow, virtual LocationBar* GetLocationBar() const; virtual void SetFocusToLocationBar(bool select_all); virtual void UpdateReloadStopState(bool is_loading, bool force); - virtual void UpdateToolbar(TabContents* contents, + virtual void UpdateToolbar(TabContentsWrapper* contents, bool should_restore_state); virtual void FocusToolbar(); virtual void FocusAppMenu(); diff --git a/chrome/browser/cocoa/browser_window_cocoa.mm b/chrome/browser/cocoa/browser_window_cocoa.mm index 5ce7156..8cac684 100644 --- a/chrome/browser/cocoa/browser_window_cocoa.mm +++ b/chrome/browser/cocoa/browser_window_cocoa.mm @@ -40,6 +40,7 @@ #include "chrome/browser/sidebar/sidebar_container.h" #include "chrome/browser/sidebar/sidebar_manager.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/native_web_keyboard_event.h" #include "chrome/common/notification_service.h" @@ -180,7 +181,7 @@ void BrowserWindowCocoa::ShelfVisibilityChanged() { void BrowserWindowCocoa::UpdateDevTools() { [controller_ updateDevToolsForContents: - browser_->tabstrip_model()->GetSelectedTabContents()]; + browser_->GetSelectedTabContents()]; } void BrowserWindowCocoa::UpdateLoadingAnimations(bool should_animate) { @@ -243,9 +244,9 @@ void BrowserWindowCocoa::UpdateReloadStopState(bool is_loading, bool force) { [controller_ setIsLoading:is_loading force:force]; } -void BrowserWindowCocoa::UpdateToolbar(TabContents* contents, +void BrowserWindowCocoa::UpdateToolbar(TabContentsWrapper* contents, bool should_restore_state) { - [controller_ updateToolbarWithContents:contents + [controller_ updateToolbarWithContents:contents->tab_contents() shouldRestoreState:should_restore_state ? YES : NO]; } @@ -625,7 +626,7 @@ NSWindow* BrowserWindowCocoa::window() const { } void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { - if (tab_contents == browser_->tabstrip_model()->GetSelectedTabContents()) { + if (tab_contents == browser_->GetSelectedTabContents()) { [controller_ updateSidebarForContents:tab_contents]; } } diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm index b074603..b2a83d7 100644 --- a/chrome/browser/cocoa/browser_window_controller.mm +++ b/chrome/browser/cocoa/browser_window_controller.mm @@ -54,6 +54,7 @@ #include "chrome/browser/sync/sync_ui_util_mac.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view_mac.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/themes/browser_theme_provider.h" #include "chrome/browser/window_sizer.h" @@ -616,7 +617,7 @@ std::max(kProportion * frame.size.width, std::min(kProportion * frame.size.height, frame.size.width)); - TabContents* contents = browser_->tabstrip_model()->GetSelectedTabContents(); + TabContents* contents = browser_->GetSelectedTabContents(); if (contents) { // If the intrinsic width is bigger, then make it the zoomed width. const int kScrollbarWidth = 16; // TODO(viettrungluu): ugh. @@ -1086,8 +1087,8 @@ if (!isBrowser) return; BrowserWindowController* dragBWC = (BrowserWindowController*)dragController; int index = [dragBWC->tabStripController_ modelIndexForTabView:view]; - TabContents* contents = - dragBWC->browser_->tabstrip_model()->GetTabContentsAt(index); + TabContentsWrapper* contents = + dragBWC->browser_->GetTabContentsWrapperAt(index); // The tab contents may have gone away if given a window.close() while it // is being dragged. If so, bail, we've got nothing to drop. if (!contents) @@ -1165,7 +1166,7 @@ // Fetch the tab contents for the tab being dragged. int index = [tabStripController_ modelIndexForTabView:tabView]; - TabContents* contents = browser_->tabstrip_model()->GetTabContentsAt(index); + TabContentsWrapper* contents = browser_->GetTabContentsWrapperAt(index); // Set the window size. Need to do this before we detach the tab so it's // still in the window. We have to flip the coordinates as that's what @@ -1323,7 +1324,7 @@ } - (NSString*)selectedTabTitle { - TabContents* contents = browser_->tabstrip_model()->GetSelectedTabContents(); + TabContents* contents = browser_->GetSelectedTabContents(); return base::SysUTF16ToNSString(contents->GetTitle()); } diff --git a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm index 9ff22eee..6396115 100644 --- a/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm +++ b/chrome/browser/cocoa/location_bar/location_bar_view_mac.mm @@ -314,7 +314,7 @@ void LocationBarViewMac::OnChanged() { if (update_instant_ && instant && GetTabContents()) { if (edit_view_->model()->user_input_in_progress() && edit_view_->model()->popup_model()->IsOpen()) { - instant->Update(GetTabContents(), + instant->Update(browser_->GetSelectedTabContentsWrapper(), edit_view_->model()->CurrentMatch(), WideToUTF16(edit_view_->GetText()), &suggested_text); diff --git a/chrome/browser/cocoa/tab_strip_controller.h b/chrome/browser/cocoa/tab_strip_controller.h index b063d9a..bc3210c 100644 --- a/chrome/browser/cocoa/tab_strip_controller.h +++ b/chrome/browser/cocoa/tab_strip_controller.h @@ -177,7 +177,7 @@ class ToolbarModel; // previous window, setting |pinned| to YES will propagate that state to the // new window. Mini-tabs are either app or pinned tabs; the app state is stored // by the |contents|, but the |pinned| state is the caller's responsibility. -- (void)dropTabContents:(TabContents*)contents +- (void)dropTabContents:(TabContentsWrapper*)contents withFrame:(NSRect)frame asPinnedTab:(BOOL)pinned; diff --git a/chrome/browser/cocoa/tab_strip_controller.mm b/chrome/browser/cocoa/tab_strip_controller.mm index 3ccdf3f..15b4e9c 100644 --- a/chrome/browser/cocoa/tab_strip_controller.mm +++ b/chrome/browser/cocoa/tab_strip_controller.mm @@ -37,6 +37,7 @@ #include "chrome/browser/tab_contents/navigation_entry.h" #include "chrome/browser/tab_contents/tab_contents.h" #include "chrome/browser/tab_contents/tab_contents_view.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "chrome/browser/ui/browser_navigator.h" #include "grit/app_resources.h" @@ -376,9 +377,10 @@ private: // means the tab model is already fully formed with tabs. Need to walk the // list and create the UI for each. const int existingTabCount = tabStripModel_->count(); - const TabContents* selection = tabStripModel_->GetSelectedTabContents(); + const TabContentsWrapper* selection = + tabStripModel_->GetSelectedTabContents(); for (int i = 0; i < existingTabCount; ++i) { - TabContents* currentContents = tabStripModel_->GetTabContentsAt(i); + TabContentsWrapper* currentContents = tabStripModel_->GetTabContentsAt(i); [self insertTabWithContents:currentContents atIndex:i inForeground:NO]; @@ -474,15 +476,17 @@ private: // Make sure the new tabs's sheets are visible (necessary when a background // tab opened a sheet while it was in the background and now becomes active). - TabContents* newTab = tabStripModel_->GetTabContentsAt(modelIndex); + TabContentsWrapper* newTab = tabStripModel_->GetTabContentsAt(modelIndex); DCHECK(newTab); if (newTab) { TabContents::ConstrainedWindowList::iterator it, end; - end = newTab->constrained_window_end(); + end = newTab->tab_contents()->constrained_window_end(); NSWindowController* controller = [[newView window] windowController]; DCHECK([controller isKindOfClass:[BrowserWindowController class]]); - for (it = newTab->constrained_window_begin(); it != end; ++it) { + for (it = newTab->tab_contents()->constrained_window_begin(); + it != end; + ++it) { ConstrainedWindow* constrainedWindow = *it; static_cast<ConstrainedWindowMac*>(constrainedWindow)->Realize( static_cast<BrowserWindowController*>(controller)); @@ -627,10 +631,10 @@ private: if (!tabStripModel_->ContainsIndex(index)) return; - TabContents* contents = tabStripModel_->GetTabContentsAt(index); + TabContentsWrapper* contents = tabStripModel_->GetTabContentsAt(index); if (contents) UserMetrics::RecordAction(UserMetricsAction("CloseTab_Mouse"), - contents->profile()); + contents->tab_contents()->profile()); const NSInteger numberOfOpenTabs = [self numberOfOpenTabs]; if (numberOfOpenTabs > 1) { bool isClosingLastTab = index == numberOfOpenTabs - 1; @@ -960,7 +964,7 @@ private: // Called when a notification is received from the model to insert a new tab // at |modelIndex|. -- (void)insertTabWithContents:(TabContents*)contents +- (void)insertTabWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)modelIndex inForeground:(bool)inForeground { DCHECK(contents); @@ -973,7 +977,8 @@ private: // Make a new tab. Load the contents of this tab from the nib and associate // the new controller with |contents| so it can be looked up later. scoped_nsobject<TabContentsController> contentsController( - [[TabContentsController alloc] initWithContents:contents delegate:self]); + [[TabContentsController alloc] initWithContents:contents->tab_contents() + delegate:self]); [tabContentsArray_ insertObject:contentsController atIndex:index]; // Make a new tab and add it to the strip. Keep track of its controller. @@ -990,7 +995,7 @@ private: [newView setFrame:NSOffsetRect([newView frame], 0, -[[self class] defaultTabHeight])]; - [self setTabTitle:newController withContents:contents]; + [self setTabTitle:newController withContents:contents->tab_contents()]; // If a tab is being inserted, we can again use the entire tab strip width // for layout. @@ -1008,7 +1013,7 @@ private: // dragging a tab out into a new window, we have to put the tab's favicon // into the right state up front as we won't be told to do it from anywhere // else. - [self updateFavIconForContents:contents atIndex:modelIndex]; + [self updateFavIconForContents:contents->tab_contents() atIndex:modelIndex]; // Send a broadcast that the number of tabs have changed. [[NSNotificationCenter defaultCenter] @@ -1018,8 +1023,8 @@ private: // Called when a notification is received from the model to select a particular // tab. Swaps in the toolbar and content area associated with |newContents|. -- (void)selectTabWithContents:(TabContents*)newContents - previousContents:(TabContents*)oldContents +- (void)selectTabWithContents:(TabContentsWrapper*)newContents + previousContents:(TabContentsWrapper*)oldContents atIndex:(NSInteger)modelIndex userGesture:(bool)wasUserGesture { // Take closing tabs into account. @@ -1034,7 +1039,7 @@ private: [tabContentsArray_ objectAtIndex:oldIndex]; [oldController willBecomeUnselectedTab]; oldContents->view()->StoreFocus(); - oldContents->WasHidden(); + oldContents->tab_contents()->WasHidden(); } } @@ -1060,33 +1065,34 @@ private: [self swapInTabAtIndex:modelIndex]; if (newContents) { - newContents->DidBecomeSelected(); + newContents->tab_contents()->DidBecomeSelected(); newContents->view()->RestoreFocus(); - if (newContents->find_ui_active()) + if (newContents->tab_contents()->find_ui_active()) browser_->GetFindBarController()->find_bar()->SetFocusAndSelection(); } } -- (void)tabReplacedWithContents:(TabContents*)newContents - previousContents:(TabContents*)oldContents +- (void)tabReplacedWithContents:(TabContentsWrapper*)newContents + previousContents:(TabContentsWrapper*)oldContents atIndex:(NSInteger)modelIndex { NSInteger index = [self indexFromModelIndex:modelIndex]; TabContentsController* oldController = [tabContentsArray_ objectAtIndex:index]; - DCHECK_EQ(oldContents, [oldController tabContents]); + DCHECK_EQ(oldContents->tab_contents(), [oldController tabContents]); // Simply create a new TabContentsController for |newContents| and place it // into the array, replacing |oldContents|. A TabSelectedAt notification will // follow, at which point we will install the new view. scoped_nsobject<TabContentsController> newController( - [[TabContentsController alloc] initWithContents:newContents - delegate:self]); + [[TabContentsController alloc] + initWithContents:newContents->tab_contents() + delegate:self]); // Bye bye, |oldController|. [tabContentsArray_ replaceObjectAtIndex:index withObject:newController]; - [delegate_ onReplaceTabWithContents:newContents]; + [delegate_ onReplaceTabWithContents:newContents->tab_contents()]; } // Remove all knowledge about this tab and its associated controller, and remove @@ -1171,7 +1177,7 @@ private: // Called when a notification is received from the model that the given tab // has gone away. Start an animation then force a layout to put everything // in motion. -- (void)tabDetachedWithContents:(TabContents*)contents +- (void)tabDetachedWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)modelIndex { // Take closing tabs into account. NSInteger index = [self indexFromModelIndex:modelIndex]; @@ -1189,7 +1195,7 @@ private: postNotificationName:kTabStripNumberOfTabsChanged object:self]; - [delegate_ onTabDetachedWithContents:contents]; + [delegate_ onTabDetachedWithContents:contents->tab_contents()]; } // A helper routine for creating an NSImageView to hold the fav icon or app icon @@ -1289,7 +1295,7 @@ private: // Called when a notification is received from the model that the given tab // has been updated. |loading| will be YES when we only want to update the // throbber state, not anything else about the (partially) loading tab. -- (void)tabChangedWithContents:(TabContents*)contents +- (void)tabChangedWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)modelIndex changeType:(TabStripModelObserver::TabChangeType)change { // Take closing tabs into account. @@ -1307,19 +1313,19 @@ private: TabController* tabController = [tabArray_ objectAtIndex:index]; if (change != TabStripModelObserver::LOADING_ONLY) - [self setTabTitle:tabController withContents:contents]; + [self setTabTitle:tabController withContents:contents->tab_contents()]; - [self updateFavIconForContents:contents atIndex:modelIndex]; + [self updateFavIconForContents:contents->tab_contents() atIndex:modelIndex]; TabContentsController* updatedController = [tabContentsArray_ objectAtIndex:index]; - [updatedController tabDidChange:contents]; + [updatedController tabDidChange:contents->tab_contents()]; } // Called when a tab is moved (usually by drag&drop). Keep our parallel arrays // in sync with the tab strip model. It can also be pinned/unpinned // simultaneously, so we need to take care of that. -- (void)tabMovedWithContents:(TabContents*)contents +- (void)tabMovedWithContents:(TabContentsWrapper*)contents fromIndex:(NSInteger)modelFrom toIndex:(NSInteger)modelTo { // Take closing tabs into account. @@ -1345,7 +1351,7 @@ private: } // Called when a tab is pinned or unpinned without moving. -- (void)tabMiniStateChangedWithContents:(TabContents*)contents +- (void)tabMiniStateChangedWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)modelIndex { // Take closing tabs into account. NSInteger index = [self indexFromModelIndex:modelIndex]; @@ -1360,7 +1366,7 @@ private: [tabController setMini:tabStripModel_->IsMiniTab(modelIndex)]; [tabController setPinned:tabStripModel_->IsTabPinned(modelIndex)]; [tabController setApp:tabStripModel_->IsAppTab(modelIndex)]; - [self updateFavIconForContents:contents atIndex:modelIndex]; + [self updateFavIconForContents:contents->tab_contents() atIndex:modelIndex]; // If the tab is being restored and it's pinned, the mini state is set after // the tab has already been rendered, so re-layout the tabstrip. In all other // cases, the state is set before the tab is rendered so this isn't needed. @@ -1434,7 +1440,7 @@ private: // previous window, setting |pinned| to YES will propagate that state to the // new window. Mini-tabs are either app or pinned tabs; the app state is stored // by the |contents|, but the |pinned| state is the caller's responsibility. -- (void)dropTabContents:(TabContents*)contents +- (void)dropTabContents:(TabContentsWrapper*)contents withFrame:(NSRect)frame asPinnedTab:(BOOL)pinned { int modelIndex = [self indexOfPlaceholder]; @@ -1715,8 +1721,9 @@ private: case CURRENT_TAB: UserMetrics::RecordAction(UserMetricsAction("Tab_DropURLOnTab"), browser_->profile()); - tabStripModel_->GetTabContentsAt(index)->OpenURL(url, GURL(), CURRENT_TAB, - PageTransition::TYPED); + tabStripModel_->GetTabContentsAt(index) + ->tab_contents()->OpenURL(url, GURL(), CURRENT_TAB, + PageTransition::TYPED); tabStripModel_->SelectTabContentsAt(index, true); break; default: diff --git a/chrome/browser/cocoa/tab_strip_controller_unittest.mm b/chrome/browser/cocoa/tab_strip_controller_unittest.mm index 04cf539..7cfde56 100644 --- a/chrome/browser/cocoa/tab_strip_controller_unittest.mm +++ b/chrome/browser/cocoa/tab_strip_controller_unittest.mm @@ -11,6 +11,7 @@ #import "chrome/browser/cocoa/tab_strip_controller.h" #import "chrome/browser/cocoa/tab_strip_view.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/renderer_host/site_instance.h" #include "testing/gtest/include/gtest/gtest.h" #include "testing/platform_test.h" @@ -36,26 +37,26 @@ namespace { // Stub model delegate class TestTabStripDelegate : public TabStripModelDelegate { public: - virtual TabContents* AddBlankTab(bool foreground) { + virtual TabContentsWrapper* AddBlankTab(bool foreground) { return NULL; } - virtual TabContents* AddBlankTabAt(int index, bool foreground) { + virtual TabContentsWrapper* AddBlankTabAt(int index, bool foreground) { return NULL; } - virtual Browser* CreateNewStripWithContents(TabContents* contents, + virtual Browser* CreateNewStripWithContents(TabContentsWrapper* contents, const gfx::Rect& window_bounds, const DockInfo& dock_info, bool maximize) { return NULL; } - virtual void ContinueDraggingDetachedTab(TabContents* contents, - const gfx::Rect& window_bounds, - const gfx::Rect& tab_bounds) { + virtual void ContinueDraggingDetachedTab(TabContentsWrapper* contents, + const gfx::Rect& window_bounds, + const gfx::Rect& tab_bounds) { } virtual int GetDragActions() const { return 0; } - virtual TabContents* CreateTabContentsForURL( + virtual TabContentsWrapper* CreateTabContentsForURL( const GURL& url, const GURL& referrer, Profile* profile, @@ -67,8 +68,8 @@ class TestTabStripDelegate : public TabStripModelDelegate { virtual bool CanDuplicateContentsAt(int index) { return true; } virtual void DuplicateContentsAt(int index) { } virtual void CloseFrameAfterDragSession() { } - virtual void CreateHistoricalTab(TabContents* contents) { } - virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) { + virtual void CreateHistoricalTab(TabContentsWrapper* contents) { } + virtual bool RunUnloadListenerBeforeClosing(TabContentsWrapper* contents) { return true; } virtual bool CanRestoreTab() { @@ -152,9 +153,9 @@ TEST_F(TabStripControllerTest, AddRemoveTabs) { EXPECT_TRUE(model_->empty()); SiteInstance* instance = SiteInstance::CreateSiteInstance(browser_helper_.profile()); - TabContents* tab_contents = - new TabContents(browser_helper_.profile(), instance, MSG_ROUTING_NONE, - NULL, NULL); + TabContentsWrapper* tab_contents = + Browser::TabContentsFactory(browser_helper_.profile(), instance, + MSG_ROUTING_NONE, NULL, NULL); model_->AppendTabContents(tab_contents, true); EXPECT_EQ(model_->count(), 1); } diff --git a/chrome/browser/cocoa/tab_strip_model_observer_bridge.h b/chrome/browser/cocoa/tab_strip_model_observer_bridge.h index f5b0619..fa9d1d7 100644 --- a/chrome/browser/cocoa/tab_strip_model_observer_bridge.h +++ b/chrome/browser/cocoa/tab_strip_model_observer_bridge.h @@ -10,7 +10,7 @@ #include "chrome/browser/tabs/tab_strip_model_observer.h" -class TabContents; +class TabContentsWrapper; class TabStripModel; // A C++ bridge class to handle receiving notifications from the C++ tab strip @@ -24,26 +24,26 @@ class TabStripModelObserverBridge : public TabStripModelObserver { virtual ~TabStripModelObserverBridge(); // Overridden from TabStripModelObserver - virtual void TabInsertedAt(TabContents* contents, + virtual void TabInsertedAt(TabContentsWrapper* contents, int index, bool foreground); virtual void TabClosingAt(TabStripModel* tab_strip_model, - TabContents* contents, + TabContentsWrapper* contents, int index); - virtual void TabDetachedAt(TabContents* contents, int index); - virtual void TabSelectedAt(TabContents* old_contents, - TabContents* new_contents, + virtual void TabDetachedAt(TabContentsWrapper* contents, int index); + virtual void TabSelectedAt(TabContentsWrapper* old_contents, + TabContentsWrapper* new_contents, int index, bool user_gesture); - virtual void TabMoved(TabContents* contents, + virtual void TabMoved(TabContentsWrapper* contents, int from_index, int to_index); - virtual void TabChangedAt(TabContents* contents, int index, + virtual void TabChangedAt(TabContentsWrapper* contents, int index, TabChangeType change_type); - virtual void TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, + virtual void TabReplacedAt(TabContentsWrapper* old_contents, + TabContentsWrapper* new_contents, int index); - virtual void TabMiniStateChanged(TabContents* contents, int index); + virtual void TabMiniStateChanged(TabContentsWrapper* contents, int index); virtual void TabStripEmpty(); virtual void TabStripModelDeleted(); @@ -56,27 +56,27 @@ class TabStripModelObserverBridge : public TabStripModelObserver { // Cocoa object to receive updates about changes to a tab strip model. It is // ok to not implement them, the calling code checks before calling. @interface NSObject(TabStripModelBridge) -- (void)insertTabWithContents:(TabContents*)contents +- (void)insertTabWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index inForeground:(bool)inForeground; -- (void)tabClosingWithContents:(TabContents*)contents +- (void)tabClosingWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index; -- (void)tabDetachedWithContents:(TabContents*)contents +- (void)tabDetachedWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index; -- (void)selectTabWithContents:(TabContents*)newContents - previousContents:(TabContents*)oldContents +- (void)selectTabWithContents:(TabContentsWrapper*)newContents + previousContents:(TabContentsWrapper*)oldContents atIndex:(NSInteger)index userGesture:(bool)wasUserGesture; -- (void)tabMovedWithContents:(TabContents*)contents +- (void)tabMovedWithContents:(TabContentsWrapper*)contents fromIndex:(NSInteger)from toIndex:(NSInteger)to; -- (void)tabChangedWithContents:(TabContents*)contents +- (void)tabChangedWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index changeType:(TabStripModelObserver::TabChangeType)change; -- (void)tabReplacedWithContents:(TabContents*)newContents - previousContents:(TabContents*)oldContents +- (void)tabReplacedWithContents:(TabContentsWrapper*)newContents + previousContents:(TabContentsWrapper*)oldContents atIndex:(NSInteger)index; -- (void)tabMiniStateChangedWithContents:(TabContents*)contents +- (void)tabMiniStateChangedWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index; - (void)tabStripEmpty; - (void)tabStripModelDeleted; diff --git a/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm b/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm index fbe5616..7aad635 100644 --- a/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm +++ b/chrome/browser/cocoa/tab_strip_model_observer_bridge.mm @@ -20,7 +20,7 @@ TabStripModelObserverBridge::~TabStripModelObserverBridge() { model_->RemoveObserver(this); } -void TabStripModelObserverBridge::TabInsertedAt(TabContents* contents, +void TabStripModelObserverBridge::TabInsertedAt(TabContentsWrapper* contents, int index, bool foreground) { if ([controller_ respondsToSelector: @@ -32,7 +32,7 @@ void TabStripModelObserverBridge::TabInsertedAt(TabContents* contents, } void TabStripModelObserverBridge::TabClosingAt(TabStripModel* tab_strip_model, - TabContents* contents, + TabContentsWrapper* contents, int index) { if ([controller_ respondsToSelector: @selector(tabClosingWithContents:atIndex:)]) { @@ -40,7 +40,7 @@ void TabStripModelObserverBridge::TabClosingAt(TabStripModel* tab_strip_model, } } -void TabStripModelObserverBridge::TabDetachedAt(TabContents* contents, +void TabStripModelObserverBridge::TabDetachedAt(TabContentsWrapper* contents, int index) { if ([controller_ respondsToSelector: @selector(tabDetachedWithContents:atIndex:)]) { @@ -48,10 +48,11 @@ void TabStripModelObserverBridge::TabDetachedAt(TabContents* contents, } } -void TabStripModelObserverBridge::TabSelectedAt(TabContents* old_contents, - TabContents* new_contents, - int index, - bool user_gesture) { +void TabStripModelObserverBridge::TabSelectedAt( + TabContentsWrapper* old_contents, + TabContentsWrapper* new_contents, + int index, + bool user_gesture) { if ([controller_ respondsToSelector: @selector(selectTabWithContents:previousContents:atIndex: userGesture:)]) { @@ -62,7 +63,7 @@ void TabStripModelObserverBridge::TabSelectedAt(TabContents* old_contents, } } -void TabStripModelObserverBridge::TabMoved(TabContents* contents, +void TabStripModelObserverBridge::TabMoved(TabContentsWrapper* contents, int from_index, int to_index) { if ([controller_ respondsToSelector: @@ -73,7 +74,7 @@ void TabStripModelObserverBridge::TabMoved(TabContents* contents, } } -void TabStripModelObserverBridge::TabChangedAt(TabContents* contents, +void TabStripModelObserverBridge::TabChangedAt(TabContentsWrapper* contents, int index, TabChangeType change_type) { if ([controller_ respondsToSelector: @@ -84,9 +85,10 @@ void TabStripModelObserverBridge::TabChangedAt(TabContents* contents, } } -void TabStripModelObserverBridge::TabReplacedAt(TabContents* old_contents, - TabContents* new_contents, - int index) { +void TabStripModelObserverBridge::TabReplacedAt( + TabContentsWrapper* old_contents, + TabContentsWrapper* new_contents, + int index) { if ([controller_ respondsToSelector: @selector(tabReplacedWithContents:previousContents:atIndex:)]) { [controller_ tabReplacedWithContents:new_contents @@ -97,8 +99,8 @@ void TabStripModelObserverBridge::TabReplacedAt(TabContents* old_contents, } } -void TabStripModelObserverBridge::TabMiniStateChanged(TabContents* contents, - int index) { +void TabStripModelObserverBridge::TabMiniStateChanged( + TabContentsWrapper* contents, int index) { if ([controller_ respondsToSelector: @selector(tabMiniStateChangedWithContents:atIndex:)]) { [controller_ tabMiniStateChangedWithContents:contents atIndex:index]; diff --git a/chrome/browser/cocoa/tabpose_window.mm b/chrome/browser/cocoa/tabpose_window.mm index dde7caf..eecbd65 100644 --- a/chrome/browser/cocoa/tabpose_window.mm +++ b/chrome/browser/cocoa/tabpose_window.mm @@ -23,7 +23,9 @@ #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/tab_contents/thumbnail_generator.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/common/pref_names.h" #include "grit/app_resources.h" #include "skia/ext/skia_utils_mac.h" @@ -522,7 +524,7 @@ void TileSet::Build(TabStripModel* source_model) { tiles_.resize(source_model->count()); for (size_t i = 0; i < tiles_.size(); ++i) { tiles_[i] = new Tile; - tiles_[i]->contents_ = source_model->GetTabContentsAt(i); + tiles_[i]->contents_ = source_model->GetTabContentsAt(i)->tab_contents(); } } @@ -1281,7 +1283,7 @@ void AnimateCALayerFrameFromTo( thumbLayer.frame = NSRectToCGRect(tile.thumb_rect()); } -- (void)insertTabWithContents:(TabContents*)contents +- (void)insertTabWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index inForeground:(bool)inForeground { // This happens if you cmd-click a link and then immediately open tabpose @@ -1289,7 +1291,7 @@ void AnimateCALayerFrameFromTo( ScopedCAActionSetDuration durationSetter(kObserverChangeAnimationDuration); // Insert new layer and relayout. - tileSet_->InsertTileAt(index, contents); + tileSet_->InsertTileAt(index, contents->tab_contents()); tileSet_->Layout(containingRect_); [self addLayersForTile:tileSet_->tile_at(index) showZoom:NO @@ -1317,13 +1319,13 @@ void AnimateCALayerFrameFromTo( [self selectTileAtIndex:selectedIndex]; } -- (void)tabClosingWithContents:(TabContents*)contents +- (void)tabClosingWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index { // We will also get a -tabDetachedWithContents:atIndex: notification for // closing tabs, so do nothing here. } -- (void)tabDetachedWithContents:(TabContents*)contents +- (void)tabDetachedWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index { ScopedCAActionSetDuration durationSetter(kObserverChangeAnimationDuration); @@ -1360,7 +1362,7 @@ void AnimateCALayerFrameFromTo( [self selectTileAtIndex:selectedIndex]; } -- (void)tabMovedWithContents:(TabContents*)contents +- (void)tabMovedWithContents:(TabContentsWrapper*)contents fromIndex:(NSInteger)from toIndex:(NSInteger)to { ScopedCAActionSetDuration durationSetter(kObserverChangeAnimationDuration); @@ -1397,7 +1399,7 @@ void AnimateCALayerFrameFromTo( [self selectTileAtIndex:selectedIndex]; } -- (void)tabChangedWithContents:(TabContents*)contents +- (void)tabChangedWithContents:(TabContentsWrapper*)contents atIndex:(NSInteger)index changeType:(TabStripModelObserver::TabChangeType)change { // Tell the window to update text, title, and thumb layers at |index| to get @@ -1409,16 +1411,16 @@ void AnimateCALayerFrameFromTo( // For now, just make sure that we don't hold on to an invalid TabContents // object. tabpose::Tile& tile = tileSet_->tile_at(index); - if (contents == tile.tab_contents()) { + if (contents->tab_contents() == tile.tab_contents()) { // TODO(thakis): Install a timer to send a thumb request/update title/update // favicon after 20ms or so, and reset the timer every time this is called // to make sure we get an updated thumb, without requesting them all over. return; } - tile.set_tab_contents(contents); + tile.set_tab_contents(contents->tab_contents()); ThumbnailLayer* thumbLayer = [allThumbnailLayers_ objectAtIndex:index]; - [thumbLayer setTabContents:contents]; + [thumbLayer setTabContents:contents->tab_contents()]; } - (void)tabStripModelDeleted { diff --git a/chrome/browser/cocoa/tabpose_window_unittest.mm b/chrome/browser/cocoa/tabpose_window_unittest.mm index c1c56d2..4874b30 100644 --- a/chrome/browser/cocoa/tabpose_window_unittest.mm +++ b/chrome/browser/cocoa/tabpose_window_unittest.mm @@ -9,6 +9,7 @@ #import "chrome/browser/cocoa/cocoa_test_helper.h" #include "chrome/browser/renderer_host/site_instance.h" #include "chrome/browser/tab_contents/tab_contents.h" +#include "chrome/browser/tab_contents_wrapper.h" #include "chrome/browser/tabs/tab_strip_model.h" #include "testing/gtest/include/gtest/gtest.h" @@ -20,7 +21,7 @@ class TabposeWindowTest : public CocoaTest { } void AppendTabToStrip() { - TabContents* tab_contents = new TabContents( + TabContentsWrapper* tab_contents = Browser::TabContentsFactory( browser_helper_.profile(), site_instance_, MSG_ROUTING_NONE, NULL, NULL); browser_helper_.browser()->tabstrip_model()->AppendTabContents( |
