Commit 482c153d authored by derekjchow's avatar derekjchow Committed by Commit bot

Seperate creation of WebContents and window tree in CastContentWindow

Let WebContents to be created independantly of setting up the
window tree in CastContentWindow. Allow the window tree to be
created at a later time.

R=gunsch@chromium.org
BUG=

Review URL: https://codereview.chromium.org/823763002

Cr-Commit-Position: refs/heads/master@{#309577}
parent 592b07ae
...@@ -59,9 +59,9 @@ CastContentWindow::~CastContentWindow() { ...@@ -59,9 +59,9 @@ CastContentWindow::~CastContentWindow() {
#endif #endif
} }
scoped_ptr<content::WebContents> CastContentWindow::Create( void CastContentWindow::CreateWindowTree(
const gfx::Size& initial_size, const gfx::Size& initial_size,
content::BrowserContext* browser_context) { content::WebContents* web_contents) {
#if defined(USE_AURA) #if defined(USE_AURA)
// Aura initialization // Aura initialization
// TODO(lcwu): We only need a minimal implementation of gfx::Screen // TODO(lcwu): We only need a minimal implementation of gfx::Screen
...@@ -84,15 +84,7 @@ scoped_ptr<content::WebContents> CastContentWindow::Create( ...@@ -84,15 +84,7 @@ scoped_ptr<content::WebContents> CastContentWindow::Create(
window_tree_host_->window()->SetLayoutManager( window_tree_host_->window()->SetLayoutManager(
new CastFillLayout(window_tree_host_->window())); new CastFillLayout(window_tree_host_->window()));
window_tree_host_->Show(); window_tree_host_->Show();
#endif
content::WebContents::CreateParams create_params(browser_context, NULL);
create_params.routing_id = MSG_ROUTING_NONE;
create_params.initial_size = initial_size;
content::WebContents* web_contents = content::WebContents::Create(
create_params);
#if defined(USE_AURA)
// Add and show content's view/window // Add and show content's view/window
aura::Window* content_window = web_contents->GetNativeView(); aura::Window* content_window = web_contents->GetNativeView();
aura::Window* parent = window_tree_host_->window(); aura::Window* parent = window_tree_host_->window();
...@@ -101,6 +93,16 @@ scoped_ptr<content::WebContents> CastContentWindow::Create( ...@@ -101,6 +93,16 @@ scoped_ptr<content::WebContents> CastContentWindow::Create(
} }
content_window->Show(); content_window->Show();
#endif #endif
}
scoped_ptr<content::WebContents> CastContentWindow::CreateWebContents(
const gfx::Size& initial_size,
content::BrowserContext* browser_context) {
content::WebContents::CreateParams create_params(browser_context, NULL);
create_params.routing_id = MSG_ROUTING_NONE;
create_params.initial_size = initial_size;
content::WebContents* web_contents = content::WebContents::Create(
create_params);
return make_scoped_ptr(web_contents); return make_scoped_ptr(web_contents);
} }
......
...@@ -30,8 +30,11 @@ class CastContentWindow { ...@@ -30,8 +30,11 @@ class CastContentWindow {
// Removes the window from the screen. // Removes the window from the screen.
~CastContentWindow(); ~CastContentWindow();
// Create a window with the given size. // Create a window with the given size for |web_contents|.
scoped_ptr<content::WebContents> Create( void CreateWindowTree(const gfx::Size& initial_size,
content::WebContents* web_contents);
scoped_ptr<content::WebContents> CreateWebContents(
const gfx::Size& initial_size, const gfx::Size& initial_size,
content::BrowserContext* browser_context); content::BrowserContext* browser_context);
......
...@@ -64,7 +64,8 @@ void CastServiceSimple::StartInternal() { ...@@ -64,7 +64,8 @@ void CastServiceSimple::StartInternal() {
gfx::Size initial_size(1280, 720); gfx::Size initial_size(1280, 720);
window_.reset(new CastContentWindow); window_.reset(new CastContentWindow);
web_contents_ = window_->Create(initial_size, browser_context()); web_contents_ = window_->CreateWebContents(initial_size, browser_context());
window_->CreateWindowTree(initial_size, web_contents_.get());
web_contents_->GetController().LoadURL(GetStartupURL(), web_contents_->GetController().LoadURL(GetStartupURL(),
content::Referrer(), content::Referrer(),
......
...@@ -70,8 +70,9 @@ void ChromecastBrowserTest::NavigateToURL(content::WebContents* window, ...@@ -70,8 +70,9 @@ void ChromecastBrowserTest::NavigateToURL(content::WebContents* window,
content::WebContents* ChromecastBrowserTest::CreateBrowser() { content::WebContents* ChromecastBrowserTest::CreateBrowser() {
window_.reset(new CastContentWindow); window_.reset(new CastContentWindow);
gfx::Size initial_size(1280, 720); gfx::Size initial_size(1280, 720);
web_contents_ = window_->Create(
initial_size, CastBrowserProcess::GetInstance()->browser_context()); web_contents_ = window_->CreateWebContents(initial_size, browser_context());
window_->CreateWindowTree(initial_size, web_contents_.get());
return web_contents_.get(); return web_contents_.get();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment