• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.webkit;
17 
18 import android.app.Activity;
19 import android.content.Intent;
20 import android.os.Bundle;
21 import android.view.View;
22 
23 /**
24  * This activity  is invoked when a plugin elects to go into full screen mode.
25  * @hide
26  */
27 public class PluginActivity extends Activity {
28 
29     /* package */ static final String INTENT_EXTRA_PACKAGE_NAME =
30             "android.webkit.plugin.PACKAGE_NAME";
31     /* package */ static final String INTENT_EXTRA_CLASS_NAME =
32             "android.webkit.plugin.CLASS_NAME";
33     /* package */ static final String INTENT_EXTRA_NPP_INSTANCE =
34             "android.webkit.plugin.NPP_INSTANCE";
35 
36     /** Called when the activity is first created. */
37     @Override
onCreate(Bundle savedInstanceState)38     public void onCreate(Bundle savedInstanceState) {
39         super.onCreate(savedInstanceState);
40 
41         final Intent intent = getIntent();
42         if (intent == null) {
43             // No intent means no class to lookup.
44             finish();
45         }
46         final String packageName =
47                 intent.getStringExtra(INTENT_EXTRA_PACKAGE_NAME);
48         final String className = intent.getStringExtra(INTENT_EXTRA_CLASS_NAME);
49         final int npp = intent.getIntExtra(INTENT_EXTRA_NPP_INSTANCE, -1);
50         // Retrieve the PluginStub implemented in packageName.className
51         PluginStub stub =
52                 PluginUtil.getPluginStub(this, packageName, className);
53 
54         if (stub != null) {
55             View pluginView = stub.getFullScreenView(npp, this);
56             if (pluginView != null) {
57                 setContentView(pluginView);
58             } else {
59                 // No custom full-sreen view returned by the plugin, odd but
60                 // just in case, finish the activity.
61                 finish();
62             }
63         } else {
64             finish();
65         }
66     }
67 }
68