Commit 98dd6bf5 authored by gunsch's avatar gunsch Committed by Commit bot

Chromecast Android shell improvements:

* Handling RenderProcessGone in CastWindowAndroid
* Using CastBrowserProcess instead of passing the browser context
* A few style nits

R=byungchul@chromium.org,lcwu@chromium.org
BUG=None

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

Cr-Commit-Position: refs/heads/master@{#295210}
parent 4433bc75
......@@ -6,7 +6,6 @@
#include "base/android/jni_android.h"
#include "base/android/jni_registrar.h"
#include "chromecast/android/chromecast_config_android.h"
#include "chromecast/shell/browser/android/cast_window_android.h"
#include "chromecast/shell/browser/android/cast_window_manager.h"
......
......@@ -6,7 +6,6 @@
#include "base/callback.h"
#include "chromecast/android/chromecast_config_android.h"
#include "chromecast/shell/browser/android/cast_window_manager.h"
namespace chromecast {
......@@ -17,7 +16,6 @@ CastService* CastService::Create(content::BrowserContext* browser_context) {
CastServiceAndroid::CastServiceAndroid(content::BrowserContext* browser_context)
: CastService(browser_context) {
shell::SetBrowserContextAndroid(browser_context);
}
CastServiceAndroid::~CastServiceAndroid() {
......
......@@ -93,7 +93,7 @@ void CastMainDelegate::InitializeResourceBundle() {
base::File(pak_fd), ui::SCALE_FACTOR_100P);
return;
}
#endif
#endif // defined(OS_ANDROID)
resource_delegate_.reset(new CastResourceDelegate());
// TODO(gunsch): Use LOAD_COMMON_RESOURCES once ResourceBundle no longer
......
......@@ -126,5 +126,10 @@ void CastWindowAndroid::DeactivateContents(content::WebContents* contents) {
contents->GetRenderViewHost()->Blur();
}
void CastWindowAndroid::RenderProcessGone(base::TerminationStatus status) {
LOG(ERROR) << "Render process gone: status=" << status;
Close();
}
} // namespace shell
} // namespace chromecast
......@@ -50,7 +50,7 @@ class CastWindowAndroid : public content::WebContentsDelegate,
// Registers the JNI methods for CastWindowAndroid.
static bool RegisterJni(JNIEnv* env);
// WebContentsDelegate implementation.
// content::WebContentsDelegate implementation:
virtual void AddNewContents(content::WebContents* source,
content::WebContents* new_contents,
WindowOpenDisposition disposition,
......@@ -67,6 +67,9 @@ class CastWindowAndroid : public content::WebContentsDelegate,
virtual void ActivateContents(content::WebContents* contents) OVERRIDE;
virtual void DeactivateContents(content::WebContents* contents) OVERRIDE;
// content::WebContentsObserver implementation:
virtual void RenderProcessGone(base::TerminationStatus status) OVERRIDE;
private:
explicit CastWindowAndroid(content::WebContents* web_contents);
......
......@@ -16,6 +16,7 @@
#include "chromecast/shell/browser/android/cast_window_android.h"
#include "chromecast/shell/browser/cast_browser_context.h"
#include "chromecast/shell/browser/cast_browser_main_parts.h"
#include "chromecast/shell/browser/cast_browser_process.h"
#include "chromecast/shell/browser/cast_content_browser_client.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/web_contents.h"
......@@ -25,20 +26,14 @@
namespace {
base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject>>
base::LazyInstance<base::android::ScopedJavaGlobalRef<jobject> >
g_window_manager = LAZY_INSTANCE_INITIALIZER;
content::BrowserContext* g_browser_context = NULL;
} // namespace
namespace chromecast {
namespace shell {
void SetBrowserContextAndroid(content::BrowserContext* browser_context) {
g_browser_context = browser_context;
}
base::android::ScopedJavaLocalRef<jobject>
CreateCastWindowView(CastWindowAndroid* shell) {
JNIEnv* env = base::android::AttachCurrentThread();
......@@ -63,10 +58,11 @@ void Init(JNIEnv* env, jclass clazz, jobject obj) {
}
jlong LaunchCastWindow(JNIEnv* env, jclass clazz, jstring jurl) {
DCHECK(g_browser_context);
GURL url(base::android::ConvertJavaStringToUTF8(env, jurl));
return reinterpret_cast<jlong>(
CastWindowAndroid::CreateNewWindow(g_browser_context, url));
CastWindowAndroid::CreateNewWindow(
CastBrowserProcess::GetInstance()->browser_context(),
url));
}
void StopCastWindow(JNIEnv* env, jclass clazz, jlong nativeCastWindow) {
......
......@@ -19,10 +19,6 @@ class BrowserContext;
namespace chromecast {
namespace shell {
// Sets the browser context to use for creating windows. Must be invoked before
// a LaunchCastWindow call.
void SetBrowserContextAndroid(content::BrowserContext* browser_context);
// Given a CastWindowAndroid instance, creates and returns a Java wrapper.
base::android::ScopedJavaLocalRef<jobject>
CreateCastWindowView(CastWindowAndroid* shell);
......
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