| OLD | NEW |
| 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 package org.chromium.chromecast.shell; | 5 package org.chromium.chromecast.shell; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.Intent; | 8 import android.content.Intent; |
| 9 import android.net.Uri; | 9 import android.net.Uri; |
| 10 import android.support.v4.content.LocalBroadcastManager; | 10 import android.support.v4.content.LocalBroadcastManager; |
| 11 import android.text.TextUtils; | 11 import android.text.TextUtils; |
| 12 import android.util.AttributeSet; | 12 import android.util.AttributeSet; |
| 13 import android.util.Log; | 13 import android.util.Log; |
| 14 import android.view.ViewGroup; | 14 import android.view.ViewGroup; |
| 15 import android.widget.FrameLayout; | 15 import android.widget.FrameLayout; |
| 16 import android.widget.LinearLayout; | 16 import android.widget.LinearLayout; |
| 17 | 17 |
| 18 import org.chromium.base.CalledByNative; | 18 import org.chromium.base.CalledByNative; |
| 19 import org.chromium.base.JNINamespace; | 19 import org.chromium.base.JNINamespace; |
| 20 import org.chromium.content.browser.ContentView; | 20 import org.chromium.content.browser.ContentView; |
| 21 import org.chromium.content.browser.ContentViewCore; | 21 import org.chromium.content.browser.ContentViewCore; |
| 22 import org.chromium.content.browser.ContentViewRenderView; | 22 import org.chromium.content.browser.ContentViewRenderView; |
| 23 import org.chromium.content.browser.WebContentsObserverAndroid; | 23 import org.chromium.content.browser.WebContentsObserver; |
| 24 import org.chromium.content_public.browser.LoadUrlParams; | 24 import org.chromium.content_public.browser.LoadUrlParams; |
| 25 import org.chromium.content_public.browser.NavigationController; | 25 import org.chromium.content_public.browser.NavigationController; |
| 26 import org.chromium.content_public.browser.WebContents; | 26 import org.chromium.content_public.browser.WebContents; |
| 27 import org.chromium.ui.base.WindowAndroid; | 27 import org.chromium.ui.base.WindowAndroid; |
| 28 | 28 |
| 29 /** | 29 /** |
| 30 * Container for the various UI components that make up a shell window. | 30 * Container for the various UI components that make up a shell window. |
| 31 */ | 31 */ |
| 32 @JNINamespace("chromecast::shell") | 32 @JNINamespace("chromecast::shell") |
| 33 public class CastWindowAndroid extends LinearLayout { | 33 public class CastWindowAndroid extends LinearLayout { |
| 34 public static final String TAG = "CastWindowAndroid"; | 34 public static final String TAG = "CastWindowAndroid"; |
| 35 | 35 |
| 36 public static final String ACTION_PAGE_LOADED = "castPageLoaded"; | 36 public static final String ACTION_PAGE_LOADED = "castPageLoaded"; |
| 37 public static final String ACTION_ENABLE_DEV_TOOLS = "castEnableDevTools"; | 37 public static final String ACTION_ENABLE_DEV_TOOLS = "castEnableDevTools"; |
| 38 public static final String ACTION_DISABLE_DEV_TOOLS = "castDisableDevTools"; | 38 public static final String ACTION_DISABLE_DEV_TOOLS = "castDisableDevTools"; |
| 39 | 39 |
| 40 private ContentViewCore mContentViewCore; | 40 private ContentViewCore mContentViewCore; |
| 41 private ContentViewRenderView mContentViewRenderView; | 41 private ContentViewRenderView mContentViewRenderView; |
| 42 private NavigationController mNavigationController; | 42 private NavigationController mNavigationController; |
| 43 private WebContents mWebContents; | 43 private WebContents mWebContents; |
| 44 private WebContentsObserverAndroid mWebContentsObserver; | 44 private WebContentsObserver mWebContentsObserver; |
| 45 private WindowAndroid mWindow; | 45 private WindowAndroid mWindow; |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Constructor for inflating via XML. | 48 * Constructor for inflating via XML. |
| 49 */ | 49 */ |
| 50 public CastWindowAndroid(Context context, AttributeSet attrs) { | 50 public CastWindowAndroid(Context context, AttributeSet attrs) { |
| 51 super(context, attrs); | 51 super(context, attrs); |
| 52 } | 52 } |
| 53 | 53 |
| 54 /** | 54 /** |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 mNavigationController = mWebContents.getNavigationController(); | 125 mNavigationController = mWebContents.getNavigationController(); |
| 126 | 126 |
| 127 if (getParent() != null) mContentViewCore.onShow(); | 127 if (getParent() != null) mContentViewCore.onShow(); |
| 128 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(view, | 128 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(view, |
| 129 new FrameLayout.LayoutParams( | 129 new FrameLayout.LayoutParams( |
| 130 FrameLayout.LayoutParams.MATCH_PARENT, | 130 FrameLayout.LayoutParams.MATCH_PARENT, |
| 131 FrameLayout.LayoutParams.MATCH_PARENT)); | 131 FrameLayout.LayoutParams.MATCH_PARENT)); |
| 132 view.requestFocus(); | 132 view.requestFocus(); |
| 133 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); | 133 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); |
| 134 | 134 |
| 135 mWebContentsObserver = new WebContentsObserverAndroid(mWebContents) { | 135 mWebContentsObserver = new WebContentsObserver(mWebContents) { |
| 136 @Override | 136 @Override |
| 137 public void didStopLoading(String url) { | 137 public void didStopLoading(String url) { |
| 138 Uri intentUri = Uri.parse(mNavigationController | 138 Uri intentUri = Uri.parse(mNavigationController |
| 139 .getOriginalUrlForVisibleNavigationEntry()); | 139 .getOriginalUrlForVisibleNavigationEntry()); |
| 140 Log.v(TAG, "Broadcast ACTION_PAGE_LOADED: scheme=" + intentUri.g
etScheme() | 140 Log.v(TAG, "Broadcast ACTION_PAGE_LOADED: scheme=" + intentUri.g
etScheme() |
| 141 + ", host=" + intentUri.getHost()); | 141 + ", host=" + intentUri.getHost()); |
| 142 LocalBroadcastManager.getInstance(getContext()).sendBroadcast( | 142 LocalBroadcastManager.getInstance(getContext()).sendBroadcast( |
| 143 new Intent(ACTION_PAGE_LOADED, intentUri)); | 143 new Intent(ACTION_PAGE_LOADED, intentUri)); |
| 144 } | 144 } |
| 145 }; | 145 }; |
| 146 } | 146 } |
| 147 | 147 |
| 148 /** | 148 /** |
| 149 * @return The {@link ViewGroup} currently shown by this Shell. | 149 * @return The {@link ViewGroup} currently shown by this Shell. |
| 150 */ | 150 */ |
| 151 public ViewGroup getContentView() { | 151 public ViewGroup getContentView() { |
| 152 return mContentViewCore.getContainerView(); | 152 return mContentViewCore.getContainerView(); |
| 153 } | 153 } |
| 154 | 154 |
| 155 /** | 155 /** |
| 156 * @return The {@link ContentViewCore} currently managing the view shown by
this Shell. | 156 * @return The {@link ContentViewCore} currently managing the view shown by
this Shell. |
| 157 */ | 157 */ |
| 158 public ContentViewCore getContentViewCore() { | 158 public ContentViewCore getContentViewCore() { |
| 159 return mContentViewCore; | 159 return mContentViewCore; |
| 160 } | 160 } |
| 161 } | 161 } |
| OLD | NEW |