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

Side by Side Diff: chromecast/browser/cast_content_window.cc

Issue 823763002: Seperate creation of WebContents and window tree in CastContentWindow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 12 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "chromecast/browser/cast_content_window.h" 5 #include "chromecast/browser/cast_content_window.h"
6 6
7 #include "base/threading/thread_restrictions.h" 7 #include "base/threading/thread_restrictions.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "ipc/ipc_message.h" 9 #include "ipc/ipc_message.h"
10 10
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 CastContentWindow::CastContentWindow() {} 52 CastContentWindow::CastContentWindow() {}
53 53
54 CastContentWindow::~CastContentWindow() { 54 CastContentWindow::~CastContentWindow() {
55 #if defined(USE_AURA) 55 #if defined(USE_AURA)
56 window_tree_host_.reset(); 56 window_tree_host_.reset();
57 // We don't delete the screen here to avoid a CHECK failure when 57 // We don't delete the screen here to avoid a CHECK failure when
58 // the screen size is queried periodically for metric gathering. b/18101124 58 // the screen size is queried periodically for metric gathering. b/18101124
59 #endif 59 #endif
60 } 60 }
61 61
62 scoped_ptr<content::WebContents> CastContentWindow::Create( 62 void CastContentWindow::CreateWindowTree(
63 const gfx::Size& initial_size, 63 const gfx::Size& initial_size,
64 content::BrowserContext* browser_context) { 64 content::WebContents* web_contents) {
65 #if defined(USE_AURA) 65 #if defined(USE_AURA)
66 // Aura initialization 66 // Aura initialization
67 // TODO(lcwu): We only need a minimal implementation of gfx::Screen 67 // TODO(lcwu): We only need a minimal implementation of gfx::Screen
68 // and aura's TestScreen will do for us now. We should change to use 68 // and aura's TestScreen will do for us now. We should change to use
69 // ozone's screen implementation when it is ready. 69 // ozone's screen implementation when it is ready.
70 gfx::Screen* old_screen = 70 gfx::Screen* old_screen =
71 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE); 71 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_NATIVE);
72 if (!old_screen || old_screen->GetPrimaryDisplay().size() != initial_size) { 72 if (!old_screen || old_screen->GetPrimaryDisplay().size() != initial_size) {
73 gfx::Screen* new_screen = aura::TestScreen::Create(initial_size); 73 gfx::Screen* new_screen = aura::TestScreen::Create(initial_size);
74 DCHECK(new_screen) << "New screen not created."; 74 DCHECK(new_screen) << "New screen not created.";
75 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, new_screen); 75 gfx::Screen::SetScreenInstance(gfx::SCREEN_TYPE_NATIVE, new_screen);
76 if (old_screen) { 76 if (old_screen) {
77 delete old_screen; 77 delete old_screen;
78 } 78 }
79 } 79 }
80 CHECK(aura::Env::GetInstance()); 80 CHECK(aura::Env::GetInstance());
81 window_tree_host_.reset( 81 window_tree_host_.reset(
82 aura::WindowTreeHost::Create(gfx::Rect(initial_size))); 82 aura::WindowTreeHost::Create(gfx::Rect(initial_size)));
83 window_tree_host_->InitHost(); 83 window_tree_host_->InitHost();
84 window_tree_host_->window()->SetLayoutManager( 84 window_tree_host_->window()->SetLayoutManager(
85 new CastFillLayout(window_tree_host_->window())); 85 new CastFillLayout(window_tree_host_->window()));
86 window_tree_host_->Show(); 86 window_tree_host_->Show();
87 #endif 87 #endif
88 88
89 content::WebContents::CreateParams create_params(browser_context, NULL);
90 create_params.routing_id = MSG_ROUTING_NONE;
91 create_params.initial_size = initial_size;
92 content::WebContents* web_contents = content::WebContents::Create(
93 create_params);
94
95 #if defined(USE_AURA) 89 #if defined(USE_AURA)
gunsch 2014/12/23 18:25:41 merge the #ifdef blocks, this is the same conditio
96 // Add and show content's view/window 90 // Add and show content's view/window
97 aura::Window* content_window = web_contents->GetNativeView(); 91 aura::Window* content_window = web_contents->GetNativeView();
98 aura::Window* parent = window_tree_host_->window(); 92 aura::Window* parent = window_tree_host_->window();
99 if (!parent->Contains(content_window)) { 93 if (!parent->Contains(content_window)) {
100 parent->AddChild(content_window); 94 parent->AddChild(content_window);
101 } 95 }
102 content_window->Show(); 96 content_window->Show();
103 #endif 97 #endif
98 }
99
100 scoped_ptr<content::WebContents> CastContentWindow::CreateWebContents(
101 const gfx::Size& initial_size,
102 content::BrowserContext* browser_context) {
103 content::WebContents::CreateParams create_params(browser_context, NULL);
104 create_params.routing_id = MSG_ROUTING_NONE;
105 create_params.initial_size = initial_size;
106 content::WebContents* web_contents = content::WebContents::Create(
107 create_params);
104 108
105 return make_scoped_ptr(web_contents); 109 return make_scoped_ptr(web_contents);
106 } 110 }
107 111
108 } // namespace chromecast 112 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/browser/cast_content_window.h ('k') | chromecast/browser/service/cast_service_simple.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698