| 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         assert window != null; | 
 |   47         mWindow = window; | 
 |   48         mContentViewRenderView = new ContentViewRenderView(getContext(), window)
      { | 
|   41             @Override |   49             @Override | 
|   42             protected void onReadyToRender() { |   50             protected void onReadyToRender() { | 
|   43                 if (sStartup) { |   51                 if (sStartup) { | 
|   44                     mActiveShell.loadUrl(mStartupUrl); |   52                     mActiveShell.loadUrl(mStartupUrl); | 
|   45                     sStartup = false; |   53                     sStartup = false; | 
|   46                 } |   54                 } | 
|   47             } |   55             } | 
|   48         }; |   56         }; | 
|   49     } |   57     } | 
|   50  |   58  | 
|   51     /** |   59     /** | 
|   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. |   60      * @return The window used to generate all shells. | 
|   60      */ |   61      */ | 
|   61     public WindowAndroid getWindow() { |   62     public WindowAndroid getWindow() { | 
|   62         return mWindow; |   63         return mWindow; | 
|   63     } |   64     } | 
|   64  |   65  | 
|   65     /** |   66     /** | 
|   66      * Sets the startup URL for new shell windows. |   67      * Sets the startup URL for new shell windows. | 
|   67      */ |   68      */ | 
|   68     public void setStartupUrl(String url) { |   69     public void setStartupUrl(String url) { | 
| (...skipping 11 matching lines...) Expand all  Loading... | 
|   80      * Creates a new shell pointing to the specified URL. |   81      * Creates a new shell pointing to the specified URL. | 
|   81      * @param url The URL the shell should load upon creation. |   82      * @param url The URL the shell should load upon creation. | 
|   82      */ |   83      */ | 
|   83     public void launchShell(String url) { |   84     public void launchShell(String url) { | 
|   84         nativeLaunchShell(url); |   85         nativeLaunchShell(url); | 
|   85     } |   86     } | 
|   86  |   87  | 
|   87     @SuppressWarnings("unused") |   88     @SuppressWarnings("unused") | 
|   88     @CalledByNative |   89     @CalledByNative | 
|   89     private Object createShell() { |   90     private Object createShell() { | 
 |   91         assert mContentViewRenderView != null; | 
|   90         LayoutInflater inflater = |   92         LayoutInflater inflater = | 
|   91                 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN
     FLATER_SERVICE); |   93                 (LayoutInflater) getContext().getSystemService(Context.LAYOUT_IN
     FLATER_SERVICE); | 
|   92         Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); |   94         Shell shellView = (Shell) inflater.inflate(R.layout.shell_view, null); | 
|   93         shellView.setWindow(mWindow); |   95         shellView.setWindow(mWindow); | 
|   94  |   96  | 
|   95         if (mActiveShell != null) closeShell(mActiveShell); |   97         if (mActiveShell != null) closeShell(mActiveShell); | 
|   96  |   98  | 
|   97         shellView.setContentViewRenderView(mContentViewRenderView); |   99         shellView.setContentViewRenderView(mContentViewRenderView); | 
|   98         addView(shellView, new FrameLayout.LayoutParams( |  100         addView(shellView, new FrameLayout.LayoutParams( | 
|   99                 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.
     MATCH_PARENT)); |  101                 FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.
     MATCH_PARENT)); | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  114         ContentView contentView = shellView.getContentView(); |  116         ContentView contentView = shellView.getContentView(); | 
|  115         if (contentView != null) contentView.onHide(); |  117         if (contentView != null) contentView.onHide(); | 
|  116         shellView.setContentViewRenderView(null); |  118         shellView.setContentViewRenderView(null); | 
|  117         shellView.setWindow(null); |  119         shellView.setWindow(null); | 
|  118         removeView(shellView); |  120         removeView(shellView); | 
|  119     } |  121     } | 
|  120  |  122  | 
|  121     private static native void nativeInit(Object shellManagerInstance); |  123     private static native void nativeInit(Object shellManagerInstance); | 
|  122     private static native void nativeLaunchShell(String url); |  124     private static native void nativeLaunchShell(String url); | 
|  123 } |  125 } | 
| OLD | NEW |