| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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.content_shell; | 5 package org.chromium.content_shell; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.util.AttributeSet; | 8 import android.util.AttributeSet; |
| 9 import android.view.LayoutInflater; | 9 import android.view.LayoutInflater; |
| 10 import android.widget.FrameLayout; | 10 import android.widget.FrameLayout; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 | 30 |
| 31 // The target for all content rendering. | 31 // The target for all content rendering. |
| 32 private ContentViewRenderView mContentViewRenderView; | 32 private ContentViewRenderView mContentViewRenderView; |
| 33 | 33 |
| 34 /** | 34 /** |
| 35 * Constructor for inflating via XML. | 35 * Constructor for inflating via XML. |
| 36 */ | 36 */ |
| 37 public ShellManager(Context context, AttributeSet attrs) { | 37 public ShellManager(Context context, AttributeSet attrs) { |
| 38 super(context, attrs); | 38 super(context, attrs); |
| 39 nativeInit(this); | 39 nativeInit(this); |
| 40 mContentViewRenderView = new ContentViewRenderView(context) { | 40 } |
| 41 |
| 42 /** |
| 43 * @param window The window used to generate all shells. |
| 44 */ |
| 45 public void setWindow(WindowAndroid window) { |
| 46 mWindow = window; |
| 47 mContentViewRenderView = new ContentViewRenderView(getContext(), window)
{ |
| 41 @Override | 48 @Override |
| 42 protected void onReadyToRender() { | 49 protected void onReadyToRender() { |
| 43 if (sStartup) { | 50 if (sStartup) { |
| 44 mActiveShell.loadUrl(mStartupUrl); | 51 mActiveShell.loadUrl(mStartupUrl); |
| 45 sStartup = false; | 52 sStartup = false; |
| 46 } | 53 } |
| 47 } | 54 } |
| 48 }; | 55 }; |
| 49 } | 56 } |
| 50 | 57 |
| 51 /** | 58 /** |
| 52 * @param window The window used to generate all shells. | |
| 53 */ | |
| 54 public void setWindow(WindowAndroid window) { | |
| 55 mWindow = window; | |
| 56 } | |
| 57 | |
| 58 /** | |
| 59 * @return The window used to generate all shells. | 59 * @return The window used to generate all shells. |
| 60 */ | 60 */ |
| 61 public WindowAndroid getWindow() { | 61 public WindowAndroid getWindow() { |
| 62 return mWindow; | 62 return mWindow; |
| 63 } | 63 } |
| 64 | 64 |
| 65 /** | 65 /** |
| 66 * Sets the startup URL for new shell windows. | 66 * Sets the startup URL for new shell windows. |
| 67 */ | 67 */ |
| 68 public void setStartupUrl(String url) { | 68 public void setStartupUrl(String url) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 80 * Creates a new shell pointing to the specified URL. | 80 * Creates a new shell pointing to the specified URL. |
| 81 * @param url The URL the shell should load upon creation. | 81 * @param url The URL the shell should load upon creation. |
| 82 */ | 82 */ |
| 83 public void launchShell(String url) { | 83 public void launchShell(String url) { |
| 84 nativeLaunchShell(url); | 84 nativeLaunchShell(url); |
| 85 } | 85 } |
| 86 | 86 |
| 87 @SuppressWarnings("unused") | 87 @SuppressWarnings("unused") |
| 88 @CalledByNative | 88 @CalledByNative |
| 89 private Object createShell() { | 89 private Object createShell() { |
| 90 assert mContentViewRenderView != null; |
| 90 LayoutInflater inflater = | 91 LayoutInflater inflater = |
| 91 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN
FLATER_SERVICE); | 92 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN
FLATER_SERVICE); |
| 92 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); | 93 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); |
| 93 shellView.setWindow(mWindow); | 94 shellView.setWindow(mWindow); |
| 94 | 95 |
| 95 if (mActiveShell != null) closeShell(mActiveShell); | 96 if (mActiveShell != null) closeShell(mActiveShell); |
| 96 | 97 |
| 97 shellView.setContentViewRenderView(mContentViewRenderView); | 98 shellView.setContentViewRenderView(mContentViewRenderView); |
| 98 addView(shellView, new FrameLayout.LayoutParams( | 99 addView(shellView, new FrameLayout.LayoutParams( |
| 99 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.
MATCH_PARENT)); | 100 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.
MATCH_PARENT)); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 114 ContentView contentView = shellView.getContentView(); | 115 ContentView contentView = shellView.getContentView(); |
| 115 if (contentView != null) contentView.onHide(); | 116 if (contentView != null) contentView.onHide(); |
| 116 shellView.setContentViewRenderView(null); | 117 shellView.setContentViewRenderView(null); |
| 117 shellView.setWindow(null); | 118 shellView.setWindow(null); |
| 118 removeView(shellView); | 119 removeView(shellView); |
| 119 } | 120 } |
| 120 | 121 |
| 121 private static native void nativeInit(Object shellManagerInstance); | 122 private static native void nativeInit(Object shellManagerInstance); |
| 122 private static native void nativeLaunchShell(String url); | 123 private static native void nativeLaunchShell(String url); |
| 123 } | 124 } |
| OLD | NEW |