diff options
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/back_forward_menu_model_unittest.cc | 2 | ||||
-rw-r--r-- | chrome/browser/browser.cc | 15 | ||||
-rw-r--r-- | chrome/browser/debugger/debugger_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/external_tab_container.cc | 3 | ||||
-rw-r--r-- | chrome/browser/navigation_controller.cc | 22 | ||||
-rw-r--r-- | chrome/browser/navigation_controller.h | 12 | ||||
-rw-r--r-- | chrome/browser/navigation_controller_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/tab_contents.h | 3 | ||||
-rw-r--r-- | chrome/browser/tab_contents_factory.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/dom_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/web_contents.cc | 5 | ||||
-rw-r--r-- | chrome/browser/web_contents.h | 2 | ||||
-rw-r--r-- | chrome/browser/web_contents_view.h | 3 | ||||
-rw-r--r-- | chrome/browser/web_contents_view_win.cc | 13 | ||||
-rw-r--r-- | chrome/browser/web_contents_view_win.h | 3 |
15 files changed, 63 insertions, 35 deletions
diff --git a/chrome/browser/back_forward_menu_model_unittest.cc b/chrome/browser/back_forward_menu_model_unittest.cc index e194480..a1d9e47 100644 --- a/chrome/browser/back_forward_menu_model_unittest.cc +++ b/chrome/browser/back_forward_menu_model_unittest.cc @@ -95,7 +95,7 @@ class BackFwdMenuModelTest : public testing::Test { protected: TabContents* CreateTabContents() { TabContents* contents = new BackFwdMenuModelTestTabContents; - contents->CreateView(); + contents->CreateView(::GetDesktopWindow(), gfx::Rect()); contents->SetupController(profile_); return contents; } diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 7c8542c..142ef6f 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1235,7 +1235,9 @@ TabContents* Browser::CreateTabContentsForURL( TabContentsType type = TabContents::TypeForURL(&real_url); DCHECK(type != TAB_CONTENTS_UNKNOWN_TYPE); - TabContents* contents = TabContents::CreateWithType(type, profile, instance); + HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle()); + TabContents* contents = TabContents::CreateWithType(type, parent_hwnd, + profile, instance); contents->SetupController(profile); if (!defer_load) { @@ -1263,7 +1265,9 @@ void Browser::DuplicateContentsAt(int index) { if (type_ == BrowserType::TABBED_BROWSER) { // If this is a tabbed browser, just create a duplicate tab inside the same // window next to the tab being duplicated. - new_contents = contents->controller()->Clone()->active_contents(); + HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle()); + new_contents = contents->controller()->Clone( + parent_hwnd)->active_contents(); // If you duplicate a tab that is not selected, we need to make sure to // select the tab being duplicated so that DetermineInsertionIndex returns // the right index (if tab 5 is selected and we right-click tab 1 we want @@ -1285,8 +1289,9 @@ void Browser::DuplicateContentsAt(int index) { browser->window()->Show(); // The page transition below is only for the purpose of inserting the tab. + HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle()); new_contents = browser->AddTabWithNavigationController( - contents->controller()->Clone(), + contents->controller()->Clone(parent_hwnd), PageTransition::LINK); } @@ -2188,7 +2193,9 @@ NavigationController* Browser::BuildRestoredNavigationController( // Create a NavigationController. This constructor creates the appropriate // set of TabContents. - return new NavigationController(profile_, navigations, selected_navigation); + HWND parent_hwnd = reinterpret_cast<HWND>(window_->GetNativeHandle()); + return new NavigationController( + profile_, navigations, selected_navigation, parent_hwnd); } else { // No navigations. Create a tab with about:blank. TabContents* contents = diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc index 169be19..127c987 100644 --- a/chrome/browser/debugger/debugger_view.cc +++ b/chrome/browser/debugger/debugger_view.cc @@ -92,8 +92,8 @@ void DebuggerView::OnInit() { // We can't create the WebContents until we've actually been put into a real // view hierarchy somewhere. Profile* profile = BrowserList::GetLastActive()->profile(); - TabContents* tc = TabContents::CreateWithType(TAB_CONTENTS_DEBUGGER, profile, - NULL); + TabContents* tc = TabContents::CreateWithType(TAB_CONTENTS_DEBUGGER, + ::GetDesktopWindow(), profile, NULL); web_contents_ = tc->AsWebContents(); web_contents_->SetupController(profile); web_contents_->set_delegate(this); diff --git a/chrome/browser/external_tab_container.cc b/chrome/browser/external_tab_container.cc index 62aec65..ea1f7e3 100644 --- a/chrome/browser/external_tab_container.cc +++ b/chrome/browser/external_tab_container.cc @@ -57,7 +57,8 @@ bool ExternalTabContainer::Init(Profile* profile) { views::FocusManager::CreateFocusManager(m_hWnd, GetRootView()); DCHECK(focus_manager); focus_manager->AddKeystrokeListener(this); - tab_contents_ = TabContents::CreateWithType(TAB_CONTENTS_WEB, profile, NULL); + tab_contents_ = TabContents::CreateWithType(TAB_CONTENTS_WEB, + m_hWnd, profile, NULL); if (!tab_contents_) { NOTREACHED(); DestroyWindow(); diff --git a/chrome/browser/navigation_controller.cc b/chrome/browser/navigation_controller.cc index 123530f..9f9cf68 100644 --- a/chrome/browser/navigation_controller.cc +++ b/chrome/browser/navigation_controller.cc @@ -183,7 +183,8 @@ NavigationController::NavigationController(TabContents* contents, NavigationController::NavigationController( Profile* profile, const std::vector<TabNavigation>& navigations, - int selected_navigation) + int selected_navigation, + HWND parent) : profile_(profile), pending_entry_(NULL), last_committed_entry_index_(-1), @@ -202,7 +203,7 @@ NavigationController::NavigationController( CreateNavigationEntriesFromTabNavigations(navigations, &entries_); // And finish the restore. - FinishRestore(selected_navigation); + FinishRestore(parent, selected_navigation); } NavigationController::~NavigationController() { @@ -1022,7 +1023,10 @@ void NavigationController::NavigateToPendingEntry(bool reload) { if (from_contents && from_contents->type() != pending_entry_->tab_type()) from_contents->set_is_active(false); - TabContents* contents = GetTabContentsCreateIfNecessary(*pending_entry_); + HWND parent = + from_contents ? GetParent(from_contents->GetContainerHWND()) : 0; + TabContents* contents = + GetTabContentsCreateIfNecessary(parent, *pending_entry_); contents->set_is_active(true); active_contents_ = contents; @@ -1054,10 +1058,11 @@ void NavigationController::NotifyNavigationEntryCommitted( } TabContents* NavigationController::GetTabContentsCreateIfNecessary( + HWND parent, const NavigationEntry& entry) { TabContents* contents = GetTabContents(entry.tab_type()); if (!contents) { - contents = TabContents::CreateWithType(entry.tab_type(), profile_, + contents = TabContents::CreateWithType(entry.tab_type(), parent, profile_, entry.site_instance()); if (!contents->AsWebContents()) { // Update the max page id, otherwise the newly created TabContents may @@ -1137,7 +1142,7 @@ void NavigationController::NotifyEntryChanged(const NavigationEntry* entry, Details<EntryChangedDetails>(&det)); } -NavigationController* NavigationController::Clone() { +NavigationController* NavigationController::Clone(HWND parent_hwnd) { NavigationController* nc = new NavigationController(NULL, profile_); if (GetEntryCount() == 0) @@ -1151,7 +1156,7 @@ NavigationController* NavigationController::Clone() { new NavigationEntry(*GetEntryAtIndex(i)))); } - nc->FinishRestore(last_committed_entry_index_); + nc->FinishRestore(parent_hwnd, last_committed_entry_index_); return nc; } @@ -1197,7 +1202,7 @@ void NavigationController::CancelTabContentsCollection(TabContentsType t) { } } -void NavigationController::FinishRestore(int selected_index) { +void NavigationController::FinishRestore(HWND parent_hwnd, int selected_index) { DCHECK(selected_index >= 0 && selected_index < GetEntryCount()); ConfigureEntriesForRestore(&entries_); @@ -1206,7 +1211,8 @@ void NavigationController::FinishRestore(int selected_index) { last_committed_entry_index_ = selected_index; // Callers assume we have an active_contents after restoring, so set it now. - active_contents_ = GetTabContentsCreateIfNecessary(*entries_[selected_index]); + active_contents_ = + GetTabContentsCreateIfNecessary(parent_hwnd, *entries_[selected_index]); } void NavigationController::DiscardNonCommittedEntriesInternal() { diff --git a/chrome/browser/navigation_controller.h b/chrome/browser/navigation_controller.h index ba805bd..5b5408f 100644 --- a/chrome/browser/navigation_controller.h +++ b/chrome/browser/navigation_controller.h @@ -128,7 +128,8 @@ class NavigationController { NavigationController( Profile* profile, const std::vector<TabNavigation>& navigations, - int selected_navigation); + int selected_navigation, + HWND parent); ~NavigationController(); // Begin the destruction sequence for this NavigationController and all its @@ -140,8 +141,8 @@ class NavigationController { void Destroy(); // Clone the receiving navigation controller. Only the active tab contents is - // duplicated. - NavigationController* Clone(); + // duplicated. It is created as a child of the provided HWND. + NavigationController* Clone(HWND hwnd); // Returns the profile for this controller. It can never be NULL. Profile* profile() const { @@ -433,7 +434,8 @@ class NavigationController { // Returns the TabContents for the |entry|'s type. If the TabContents // doesn't yet exist, it is created. If a new TabContents is created, its // parent is |parent|. Becomes part of |entry|'s SiteInstance. - TabContents* GetTabContentsCreateIfNecessary(const NavigationEntry& entry); + TabContents* GetTabContentsCreateIfNecessary(HWND parent, + const NavigationEntry& entry); // Register the provided tab contents. This tab contents will be owned // and deleted by this navigation controller @@ -461,7 +463,7 @@ class NavigationController { // Invoked after session/tab restore or cloning a tab. Resets the transition // type of the entries, updates the max page id and creates the active // contents. - void FinishRestore(int selected_index); + void FinishRestore(HWND parent_hwnd, int selected_index); // Inserts an entry after the current position, removing all entries after it. // The new entry will become the active one. diff --git a/chrome/browser/navigation_controller_unittest.cc b/chrome/browser/navigation_controller_unittest.cc index f7baada..64dae5e 100644 --- a/chrome/browser/navigation_controller_unittest.cc +++ b/chrome/browser/navigation_controller_unittest.cc @@ -52,7 +52,7 @@ class NavigationControllerTest : public testing::Test, contents = new TestTabContents(type1()); contents->set_delegate(this); - contents->CreateView(); + contents->CreateView(::GetDesktopWindow(), gfx::Rect()); contents->SetupController(profile); } @@ -1233,7 +1233,7 @@ TEST_F(NavigationControllerTest, RestoreNavigate) { navigations.push_back(TabNavigation(0, url, GURL(), L"Title", "state", PageTransition::LINK)); NavigationController* controller = - new NavigationController(profile, navigations, 0); + new NavigationController(profile, navigations, 0, NULL); controller->GoToIndex(0); // We should now have one entry, and it should be "pending". diff --git a/chrome/browser/tab_contents.h b/chrome/browser/tab_contents.h index ebbc47b..6f7f592 100644 --- a/chrome/browser/tab_contents.h +++ b/chrome/browser/tab_contents.h @@ -75,6 +75,7 @@ class TabContents : public PageNavigator { // Creates a new TabContents of the given type. Will reuse the given // instance's renderer, if it is not null. static TabContents* CreateWithType(TabContentsType type, + HWND parent, Profile* profile, SiteInstance* instance); @@ -339,7 +340,7 @@ class TabContents : public PageNavigator { // Tell the subclass to set up the view (e.g. create the container HWND if // applicable) and any other create-time setup. - virtual void CreateView() {} + virtual void CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds) {} // Returns the HWND associated with this TabContents. Outside of automation // in the context of the UI, this is required to be implemented. diff --git a/chrome/browser/tab_contents_factory.cc b/chrome/browser/tab_contents_factory.cc index 2488222..19b40569 100644 --- a/chrome/browser/tab_contents_factory.cc +++ b/chrome/browser/tab_contents_factory.cc @@ -38,6 +38,7 @@ TabContentsType TabContentsFactory::NextUnusedType() { /*static*/ TabContents* TabContents::CreateWithType(TabContentsType type, + HWND parent, Profile* profile, SiteInstance* instance) { TabContents* contents; @@ -88,7 +89,7 @@ TabContents* TabContents::CreateWithType(TabContentsType type, } if (contents) - contents->CreateView(); + contents->CreateView(parent, gfx::Rect()); return contents; } diff --git a/chrome/browser/views/dom_view.cc b/chrome/browser/views/dom_view.cc index ba74fac..ebb63e3 100644 --- a/chrome/browser/views/dom_view.cc +++ b/chrome/browser/views/dom_view.cc @@ -28,8 +28,8 @@ bool DOMView::Init(Profile* profile, SiteInstance* instance) { // a DOMUIHostFactory rather than TabContentsFactory, because DOMView's // should only be associated with instances of DOMUIHost. TabContentsType type = TabContents::TypeForURL(&contents_); - TabContents* tab_contents = TabContents::CreateWithType(type, profile, - instance); + TabContents* tab_contents = TabContents::CreateWithType(type, + GetContainer()->GetHWND(), profile, instance); host_ = tab_contents->AsDOMUIHost(); DCHECK(host_); diff --git a/chrome/browser/web_contents.cc b/chrome/browser/web_contents.cc index a8fe7db..dda65e1 100644 --- a/chrome/browser/web_contents.cc +++ b/chrome/browser/web_contents.cc @@ -481,8 +481,9 @@ void WebContents::SetDownloadShelfVisible(bool visible) { } // Stupid view pass-throughs -void WebContents::CreateView() { - view_->CreateView(); +void WebContents::CreateView(HWND parent_hwnd, + const gfx::Rect& initial_bounds) { + view_->CreateView(parent_hwnd, initial_bounds); } HWND WebContents::GetContainerHWND() const { return view_->GetContainerHWND(); diff --git a/chrome/browser/web_contents.h b/chrome/browser/web_contents.h index 71894de..8b59d6b 100644 --- a/chrome/browser/web_contents.h +++ b/chrome/browser/web_contents.h @@ -103,7 +103,7 @@ class WebContents : public TabContents, // Retarded pass-throughs to the view. // TODO(brettw) fix this, tab contents shouldn't have these methods, probably // it should be killed altogether. - virtual void CreateView(); + virtual void CreateView(HWND parent_hwnd, const gfx::Rect& initial_bounds); virtual HWND GetContainerHWND() const; virtual HWND GetContentHWND(); virtual void GetContainerBounds(gfx::Rect *out) const; diff --git a/chrome/browser/web_contents_view.h b/chrome/browser/web_contents_view.h index c253a7d..e6b24c2 100644 --- a/chrome/browser/web_contents_view.h +++ b/chrome/browser/web_contents_view.h @@ -38,7 +38,8 @@ class WebContentsView : public RenderViewHostDelegate::View { virtual WebContents* GetWebContents() = 0; - virtual void CreateView() = 0; + virtual void CreateView(HWND parent_hwnd, + const gfx::Rect& initial_bounds) = 0; // Sets up the View that holds the rendered web page, receives messages for // it and contains page plugins. diff --git a/chrome/browser/web_contents_view_win.cc b/chrome/browser/web_contents_view_win.cc index 7c369f7..dcf8136 100644 --- a/chrome/browser/web_contents_view_win.cc +++ b/chrome/browser/web_contents_view_win.cc @@ -52,9 +52,10 @@ WebContents* WebContentsViewWin::GetWebContents() { return web_contents_; } -void WebContentsViewWin::CreateView() { +void WebContentsViewWin::CreateView(HWND parent_hwnd, + const gfx::Rect& initial_bounds) { set_delete_on_destroy(false); - ContainerWin::Init(GetDesktopWindow(), gfx::Rect(), false); + ContainerWin::Init(parent_hwnd, initial_bounds, false); // Remove the root view drop target so we can register our own. RevokeDragDrop(GetHWND()); @@ -364,7 +365,13 @@ WebContents* WebContentsViewWin::CreateNewWindowInternal( new_contents->SetupController(web_contents_->profile()); WebContentsView* new_view = new_contents->view(); - new_view->CreateView(); + // TODO(beng) + // The intention here is to create background tabs, which should ideally + // be parented to NULL. However doing that causes the corresponding view + // container windows to show up as overlapped windows, which causes + // other issues. We should fix this. + HWND new_view_parent_window = ::GetAncestor(GetContainerHWND(), GA_ROOT); + new_view->CreateView(new_view_parent_window, gfx::Rect()); // TODO(brettw) it seems bogus that we have to call this function on the // newly created object and give it one of its own member variables. diff --git a/chrome/browser/web_contents_view_win.h b/chrome/browser/web_contents_view_win.h index ee28e87..ca03829 100644 --- a/chrome/browser/web_contents_view_win.h +++ b/chrome/browser/web_contents_view_win.h @@ -31,7 +31,8 @@ class WebContentsViewWin : public WebContentsView, // WebContentsView implementation -------------------------------------------- virtual WebContents* GetWebContents(); - virtual void CreateView(); + virtual void CreateView(HWND parent_hwnd, + const gfx::Rect& initial_bounds); virtual RenderWidgetHostViewWin* CreateViewForWidget( RenderWidgetHost* render_widget_host); virtual HWND GetContainerHWND() const; |