Chromium Code Reviews| Index: chromecast/browser/android/cast_window_android.cc |
| diff --git a/chromecast/browser/android/cast_window_android.cc b/chromecast/browser/android/cast_window_android.cc |
| index 8503fd6671306195b4aa96fc49a404504dc773eb..c304fe863035c7132d00b12c43025408d4f1ad90 100644 |
| --- a/chromecast/browser/android/cast_window_android.cc |
| +++ b/chromecast/browser/android/cast_window_android.cc |
| @@ -6,6 +6,7 @@ |
| #include "base/message_loop/message_loop_proxy.h" |
| #include "chromecast/browser/android/cast_window_manager.h" |
| +#include "chromecast/browser/cast_content_window.h" |
| #include "content/public/browser/devtools_agent_host.h" |
| #include "content/public/browser/navigation_controller.h" |
| #include "content/public/browser/navigation_entry.h" |
| @@ -30,54 +31,45 @@ bool CastWindowAndroid::RegisterJni(JNIEnv* env) { |
| return RegisterNativesImpl(env); |
| } |
| -CastWindowAndroid::CastWindowAndroid(content::WebContents* web_contents) |
| - : content::WebContentsObserver(web_contents), |
| - weak_factory_(this) { |
| -} |
| - |
| -CastWindowAndroid::~CastWindowAndroid() { |
| -} |
| - |
| // static |
| CastWindowAndroid* CastWindowAndroid::CreateNewWindow( |
| content::BrowserContext* browser_context, |
| const GURL& url) { |
| - content::WebContents::CreateParams create_params(browser_context); |
| - create_params.routing_id = MSG_ROUTING_NONE; |
| - content::WebContents* web_contents = |
| - content::WebContents::Create(create_params); |
| - CastWindowAndroid* shell = CreateCastWindowAndroid( |
| - web_contents, |
| - create_params.initial_size); |
| + CastWindowAndroid* window = new CastWindowAndroid(browser_context); |
| + window->Initialize(); |
| + |
| if (!url.is_empty()) |
| - shell->LoadURL(url); |
| - return shell; |
| + window->LoadURL(url); |
| + return window; |
| } |
| -// static |
| -CastWindowAndroid* CastWindowAndroid::CreateCastWindowAndroid( |
| - content::WebContents* web_contents, |
| - const gfx::Size& initial_size) { |
| - CastWindowAndroid* shell = new CastWindowAndroid(web_contents); |
| +CastWindowAndroid::CastWindowAndroid(content::BrowserContext* browser_context) |
| + : browser_context_(browser_context), |
| + window_(new CastContentWindow), |
|
lcwu1
2015/02/04 00:28:31
Given that you renamed 'shell' to 'window' for Cas
gunsch
2015/02/04 00:38:36
Oof, the naming did get rough. Renamed a couple th
|
| + weak_factory_(this) { |
| +} |
| - JNIEnv* env = base::android::AttachCurrentThread(); |
| - base::android::ScopedJavaLocalRef<jobject> shell_android( |
| - CreateCastWindowView(shell)); |
| +void CastWindowAndroid::Initialize() { |
| + web_contents_ = window_->CreateWebContents(gfx::Size(), browser_context_); |
| + web_contents_->SetDelegate(this); |
| + content::WebContentsObserver::Observe(web_contents_.get()); |
| - shell->java_object_.Reset(env, shell_android.Release()); |
| - shell->web_contents_.reset(web_contents); |
| - web_contents->SetDelegate(shell); |
| + JNIEnv* env = base::android::AttachCurrentThread(); |
| + base::android::ScopedJavaLocalRef<jobject> window_android( |
| + CreateCastWindowView(this)); |
| + java_object_.Reset(env, window_android.Release()); |
| Java_CastWindowAndroid_initFromNativeWebContents( |
| - env, shell->java_object_.obj(), web_contents->GetJavaWebContents().obj(), |
| - web_contents->GetRenderProcessHost()->GetID()); |
| + env, java_object_.obj(), web_contents_->GetJavaWebContents().obj(), |
| + web_contents_->GetRenderProcessHost()->GetID()); |
| // Enabling hole-punching also requires runtime renderer preference |
| - web_contents->GetMutableRendererPrefs()-> |
| + web_contents_->GetMutableRendererPrefs()-> |
| use_video_overlay_for_embedded_encrypted_video = true; |
| - web_contents->GetRenderViewHost()->SyncRendererPrefs(); |
| + web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| +} |
| - return shell; |
| +CastWindowAndroid::~CastWindowAndroid() { |
| } |
| void CastWindowAndroid::Close() { |