diff options
author | gunsch <gunsch@chromium.org> | 2014-09-16 18:36:46 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-09-17 01:36:58 +0000 |
commit | 98dd6bf5335d87832f551e839b799421e45b3a5e (patch) | |
tree | f7630876b2a792e46d77df5e4661c48709716e7c /chromecast | |
parent | 4433bc75923b6fb4718f744e934ddf5ade2db2de (diff) | |
download | chromium_src-98dd6bf5335d87832f551e839b799421e45b3a5e.zip chromium_src-98dd6bf5335d87832f551e839b799421e45b3a5e.tar.gz chromium_src-98dd6bf5335d87832f551e839b799421e45b3a5e.tar.bz2 |
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}
Diffstat (limited to 'chromecast')
7 files changed, 15 insertions, 18 deletions
diff --git a/chromecast/android/cast_jni_registrar.cc b/chromecast/android/cast_jni_registrar.cc index db79061..e8bae63 100644 --- a/chromecast/android/cast_jni_registrar.cc +++ b/chromecast/android/cast_jni_registrar.cc @@ -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" diff --git a/chromecast/service/cast_service_android.cc b/chromecast/service/cast_service_android.cc index afaab64..07fdb5a 100644 --- a/chromecast/service/cast_service_android.cc +++ b/chromecast/service/cast_service_android.cc @@ -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() { diff --git a/chromecast/shell/app/cast_main_delegate.cc b/chromecast/shell/app/cast_main_delegate.cc index f713f5b..719cc2b 100644 --- a/chromecast/shell/app/cast_main_delegate.cc +++ b/chromecast/shell/app/cast_main_delegate.cc @@ -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 diff --git a/chromecast/shell/browser/android/cast_window_android.cc b/chromecast/shell/browser/android/cast_window_android.cc index 65380b1..4bf98c2 100644 --- a/chromecast/shell/browser/android/cast_window_android.cc +++ b/chromecast/shell/browser/android/cast_window_android.cc @@ -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 diff --git a/chromecast/shell/browser/android/cast_window_android.h b/chromecast/shell/browser/android/cast_window_android.h index 979aea9..512e5e8 100644 --- a/chromecast/shell/browser/android/cast_window_android.h +++ b/chromecast/shell/browser/android/cast_window_android.h @@ -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); diff --git a/chromecast/shell/browser/android/cast_window_manager.cc b/chromecast/shell/browser/android/cast_window_manager.cc index daa18af..8f485d5 100644 --- a/chromecast/shell/browser/android/cast_window_manager.cc +++ b/chromecast/shell/browser/android/cast_window_manager.cc @@ -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) { diff --git a/chromecast/shell/browser/android/cast_window_manager.h b/chromecast/shell/browser/android/cast_window_manager.h index 9a811a9..a7c2e0a 100644 --- a/chromecast/shell/browser/android/cast_window_manager.h +++ b/chromecast/shell/browser/android/cast_window_manager.h @@ -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); |