diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 17:22:54 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-09-26 17:22:54 +0000 |
commit | e99ca5111f19b5401f0e18e52a0ebbddc8a36f78 (patch) | |
tree | 783c4faacbaf48e2bdfd40aa4bbb6ee38079bbb9 /content/browser | |
parent | 30fcaa494a7c2fd728821d603816d19f764857f6 (diff) | |
download | chromium_src-e99ca5111f19b5401f0e18e52a0ebbddc8a36f78.zip chromium_src-e99ca5111f19b5401f0e18e52a0ebbddc8a36f78.tar.gz chromium_src-e99ca5111f19b5401f0e18e52a0ebbddc8a36f78.tar.bz2 |
A few improvements to content_shell:
-support multiple windows, this allows window.open to work
-add menu to create new windows-update buttons and url bar
-ensure we destruct ResourceContext on the right thread
-ensure we destruct BrowserContext while all the threads are still alive
-add http:// to the url if the user forgot to enter it
BUG= 90445
Review URL: http://codereview.chromium.org/8043011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102749 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser')
4 files changed, 66 insertions, 6 deletions
diff --git a/content/browser/mock_content_browser_client.cc b/content/browser/mock_content_browser_client.cc index be23fd8..7544246 100644 --- a/content/browser/mock_content_browser_client.cc +++ b/content/browser/mock_content_browser_client.cc @@ -188,7 +188,7 @@ bool MockContentBrowserClient::CanCreateWindow( const GURL& source_url, WindowContainerType container_type, const content::ResourceContext& context) { - return false; + return true; } std::string MockContentBrowserClient::GetWorkerProcessTitle( diff --git a/content/browser/tab_contents/tab_contents_view_win.cc b/content/browser/tab_contents/tab_contents_view_win.cc index ffcc837..692b04f 100644 --- a/content/browser/tab_contents/tab_contents_view_win.cc +++ b/content/browser/tab_contents/tab_contents_view_win.cc @@ -4,15 +4,19 @@ #include "content/browser/tab_contents/tab_contents_view_win.h" +#include "content/browser/renderer_host/render_view_host.h" #include "content/browser/renderer_host/render_widget_host_view_win.h" #include "content/browser/tab_contents/constrained_window.h" #include "content/browser/tab_contents/interstitial_page.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/browser/tab_contents/tab_contents_delegate.h" +#include "content/browser/tab_contents/tab_contents_view_win_delegate.h" -TabContentsViewWin::TabContentsViewWin(TabContents* tab_contents) +TabContentsViewWin::TabContentsViewWin(TabContents* tab_contents, + TabContentsViewWinDelegate* delegate) : parent_(NULL), tab_contents_(tab_contents), + delegate_(delegate), view_(NULL) { } @@ -40,6 +44,7 @@ RenderWidgetHostView* TabContentsViewWin::CreateViewForWidget( view_ = new RenderWidgetHostViewWin(render_widget_host); view_->CreateWnd(GetNativeView()); view_->ShowWindow(SW_SHOW); + view_->SetSize(initial_size_); return view_; } @@ -152,9 +157,13 @@ void TabContentsViewWin::GetViewBounds(gfx::Rect* out) const { void TabContentsViewWin::CreateNewWindow( int route_id, const ViewHostMsg_CreateWindow_Params& params) { - NOTIMPLEMENTED(); -} + TabContents* tab = delegate_->CreateNewWindow(this, route_id, params); + // Copy logic from RenderViewHostDelegateViewHelper. + TabContentsView* new_view = tab->view(); + new_view->CreateViewForWidget(tab->render_view_host()); + pending_contents_[route_id] = tab->render_view_host(); +} void TabContentsViewWin::CreateNewWidget(int route_id, WebKit::WebPopupType popup_type) { @@ -169,7 +178,16 @@ void TabContentsViewWin::ShowCreatedWindow(int route_id, WindowOpenDisposition disposition, const gfx::Rect& initial_pos, bool user_gesture) { - NOTIMPLEMENTED(); + PendingContents::iterator iter = pending_contents_.find(route_id); + if (iter == pending_contents_.end()) + return; + + RenderViewHost* new_rvh = iter->second; + pending_contents_.erase(route_id); + if (!new_rvh->process()->HasConnection() || + (new_rvh->delegate()->GetAsTabContents() && !new_rvh->view())) + return; + new_rvh->Init(); } void TabContentsViewWin::ShowCreatedWidget(int route_id, diff --git a/content/browser/tab_contents/tab_contents_view_win.h b/content/browser/tab_contents/tab_contents_view_win.h index c647406..6903979 100644 --- a/content/browser/tab_contents/tab_contents_view_win.h +++ b/content/browser/tab_contents/tab_contents_view_win.h @@ -6,16 +6,20 @@ #define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_WIN_H_ #pragma once +#include <map> + #include "content/browser/tab_contents/tab_contents_view.h" #include "ui/base/win/window_impl.h" class RenderWidgetHostViewWin; +class TabContentsViewWinDelegate; // An implementation of TabContentsView for Windows. class TabContentsViewWin : public TabContentsView, public ui::WindowImpl { public: - explicit TabContentsViewWin(TabContents* tab_contents); + TabContentsViewWin(TabContents* tab_contents, + TabContentsViewWinDelegate* delegate); virtual ~TabContentsViewWin(); void SetParent(HWND parent); @@ -76,6 +80,8 @@ class TabContentsViewWin : public TabContentsView, virtual void GotFocus() OVERRIDE; virtual void TakeFocus(bool reverse) OVERRIDE; + TabContents* tab_contents() const { return tab_contents_; } + private: LRESULT OnWindowPosChanged( UINT message, WPARAM wparam, LPARAM lparam, BOOL& handled); @@ -86,9 +92,13 @@ class TabContentsViewWin : public TabContentsView, // The TabContents whose contents we display. TabContents* tab_contents_; + TabContentsViewWinDelegate* delegate_; RenderWidgetHostViewWin* view_; + typedef std::map<int, RenderViewHost*> PendingContents; + PendingContents pending_contents_; + DISALLOW_COPY_AND_ASSIGN(TabContentsViewWin); }; diff --git a/content/browser/tab_contents/tab_contents_view_win_delegate.h b/content/browser/tab_contents/tab_contents_view_win_delegate.h new file mode 100644 index 0000000..76d7fc2 --- /dev/null +++ b/content/browser/tab_contents/tab_contents_view_win_delegate.h @@ -0,0 +1,32 @@ +// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_WIN_DELEGATE_H_ +#define CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_WIN_DELEGATE_H_ +#pragma once + +#include "base/basictypes.h" + +class TabContents; +class TabContentsViewWin; +struct ViewHostMsg_CreateWindow_Params; + +// A delegate interface for TabContentsViewWin. +class TabContentsViewWinDelegate { + public: + virtual ~TabContentsViewWinDelegate() {} + + // These match the TabContentsView methods. + virtual TabContents* CreateNewWindow( + TabContentsViewWin* tab_contents_view, + int route_id, + const ViewHostMsg_CreateWindow_Params& params) = 0; + + protected: + TabContentsViewWinDelegate() {} + + DISALLOW_COPY_AND_ASSIGN(TabContentsViewWinDelegate); +}; + +#endif // CONTENT_BROWSER_TAB_CONTENTS_TAB_CONTENTS_VIEW_WIN_DELEGATE_H_ |