| 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; |
| 11 | 11 |
| 12 import org.chromium.base.CalledByNative; | 12 import org.chromium.base.CalledByNative; |
| 13 import org.chromium.base.JNINamespace; | 13 import org.chromium.base.JNINamespace; |
| 14 | 14 |
| 15 /** | 15 /** |
| 16 * Container and generator of ShellViews. | 16 * Container and generator of ShellViews. |
| 17 */ | 17 */ |
| 18 @JNINamespace("content") | 18 @JNINamespace("content") |
| 19 public class ShellManager extends FrameLayout { | 19 public class ShellManager extends FrameLayout { |
| 20 | 20 |
| 21 private ShellView mActiveShellView; | 21 private Shell mActiveShell; |
| 22 | 22 |
| 23 /** | 23 /** |
| 24 * Constructor for inflating via XML. | 24 * Constructor for inflating via XML. |
| 25 */ | 25 */ |
| 26 public ShellManager(Context context, AttributeSet attrs) { | 26 public ShellManager(Context context, AttributeSet attrs) { |
| 27 super(context, attrs); | 27 super(context, attrs); |
| 28 nativeInit(this); | 28 nativeInit(this); |
| 29 } | 29 } |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @return The currently visible shell view or null if one is not showing. | 32 * @return The currently visible shell view or null if one is not showing. |
| 33 */ | 33 */ |
| 34 protected ShellView getActiveShellView() { | 34 protected Shell getActiveShell() { |
| 35 return mActiveShellView; | 35 return mActiveShell; |
| 36 } | 36 } |
| 37 | 37 |
| 38 @SuppressWarnings("unused") | 38 @SuppressWarnings("unused") |
| 39 @CalledByNative | 39 @CalledByNative |
| 40 private int createShell() { | 40 private Object createShell() { |
| 41 LayoutInflater inflater = | 41 LayoutInflater inflater = |
| 42 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN
FLATER_SERVICE); | 42 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN
FLATER_SERVICE); |
| 43 ShellView shellView = (ShellView) inflater.inflate(R.layout.shell_view,
null); | 43 Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); |
| 44 | 44 |
| 45 removeAllViews(); | 45 removeAllViews(); |
| 46 addView(shellView, new FrameLayout.LayoutParams( | 46 addView(shellView, new FrameLayout.LayoutParams( |
| 47 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.
MATCH_PARENT)); | 47 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.
MATCH_PARENT)); |
| 48 mActiveShellView = shellView; | 48 mActiveShell = shellView; |
| 49 | 49 |
| 50 return shellView.getNativeShellView(); | 50 return shellView; |
| 51 } | 51 } |
| 52 | 52 |
| 53 private static native void nativeInit(Object shellManagerInstance); | 53 private static native void nativeInit(Object shellManagerInstance); |
| 54 } | 54 } |
| OLD | NEW |