OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_apk; | 5 package org.chromium.content_shell_apk; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Intent; | 8 import android.content.Intent; |
9 import android.os.Bundle; | 9 import android.os.Bundle; |
10 import android.text.TextUtils; | 10 import android.text.TextUtils; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // can work, so kill the whole application not just the activity | 67 // can work, so kill the whole application not just the activity |
68 System.exit(-1); | 68 System.exit(-1); |
69 return; | 69 return; |
70 } | 70 } |
71 | 71 |
72 setContentView(R.layout.content_shell_activity); | 72 setContentView(R.layout.content_shell_activity); |
73 mShellManager = (ShellManager) findViewById(R.id.shell_container); | 73 mShellManager = (ShellManager) findViewById(R.id.shell_container); |
74 mWindowAndroid = new ActivityWindowAndroid(this); | 74 mWindowAndroid = new ActivityWindowAndroid(this); |
75 mWindowAndroid.restoreInstanceState(savedInstanceState); | 75 mWindowAndroid.restoreInstanceState(savedInstanceState); |
76 mShellManager.setWindow(mWindowAndroid); | 76 mShellManager.setWindow(mWindowAndroid); |
| 77 mShellManager.setContentViewClient(new ContentViewClient() { |
| 78 @Override |
| 79 public ContentVideoViewClient getContentVideoViewClient() { |
| 80 return new ActivityContentVideoViewClient(ContentShellActivity.t
his) { |
| 81 @Override |
| 82 public void onShowCustomView(View view) { |
| 83 super.onShowCustomView(view); |
| 84 if (CommandLine.getInstance().hasSwitch( |
| 85 ContentSwitches.ENABLE_OVERLAY_FULLSCREEN_VIDEO_
SUBTITLE)) { |
| 86 mShellManager.setOverlayVideoMode(true); |
| 87 } |
| 88 } |
| 89 |
| 90 @Override |
| 91 public void onDestroyContentVideoView() { |
| 92 super.onDestroyContentVideoView(); |
| 93 if (CommandLine.getInstance().hasSwitch( |
| 94 ContentSwitches.ENABLE_OVERLAY_FULLSCREEN_VIDEO_
SUBTITLE)) { |
| 95 mShellManager.setOverlayVideoMode(false); |
| 96 } |
| 97 } |
| 98 }; |
| 99 } |
| 100 }); |
77 | 101 |
78 String startupUrl = getUrlFromIntent(getIntent()); | 102 String startupUrl = getUrlFromIntent(getIntent()); |
79 if (!TextUtils.isEmpty(startupUrl)) { | 103 if (!TextUtils.isEmpty(startupUrl)) { |
80 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); | 104 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); |
81 } | 105 } |
82 | 106 |
83 if (CommandLine.getInstance().hasSwitch(ContentSwitches.DUMP_RENDER_TREE
)) { | 107 if (CommandLine.getInstance().hasSwitch(ContentSwitches.DUMP_RENDER_TREE
)) { |
84 try { | 108 try { |
85 BrowserStartupController.get(this).startBrowserProcessesSync( | 109 BrowserStartupController.get(this).startBrowserProcessesSync( |
86 BrowserStartupController.MAX_RENDERERS_LIMIT); | 110 BrowserStartupController.MAX_RENDERERS_LIMIT); |
(...skipping 22 matching lines...) Expand all Loading... |
109 } | 133 } |
110 } | 134 } |
111 | 135 |
112 private void finishInitialization(Bundle savedInstanceState) { | 136 private void finishInitialization(Bundle savedInstanceState) { |
113 String shellUrl = ShellManager.DEFAULT_SHELL_URL; | 137 String shellUrl = ShellManager.DEFAULT_SHELL_URL; |
114 if (savedInstanceState != null | 138 if (savedInstanceState != null |
115 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { | 139 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { |
116 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY); | 140 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY); |
117 } | 141 } |
118 mShellManager.launchShell(shellUrl); | 142 mShellManager.launchShell(shellUrl); |
119 getActiveContentView().setContentViewClient(new ContentViewClient() { | |
120 @Override | |
121 public ContentVideoViewClient getContentVideoViewClient() { | |
122 return new ActivityContentVideoViewClient(ContentShellActivity.t
his) { | |
123 @Override | |
124 public void onShowCustomView(View view) { | |
125 super.onShowCustomView(view); | |
126 if (CommandLine.getInstance().hasSwitch( | |
127 ContentSwitches.ENABLE_OVERLAY_FULLSCREEN_VIDEO_
SUBTITLE)) { | |
128 mShellManager.setOverlayVideoMode(true); | |
129 } | |
130 } | |
131 | |
132 @Override | |
133 public void onDestroyContentVideoView() { | |
134 super.onDestroyContentVideoView(); | |
135 if (CommandLine.getInstance().hasSwitch( | |
136 ContentSwitches.ENABLE_OVERLAY_FULLSCREEN_VIDEO_
SUBTITLE)) { | |
137 mShellManager.setOverlayVideoMode(false); | |
138 } | |
139 } | |
140 }; | |
141 } | |
142 }); | |
143 } | 143 } |
144 | 144 |
145 private void initializationFailed() { | 145 private void initializationFailed() { |
146 Log.e(TAG, "ContentView initialization failed."); | 146 Log.e(TAG, "ContentView initialization failed."); |
147 Toast.makeText(ContentShellActivity.this, | 147 Toast.makeText(ContentShellActivity.this, |
148 R.string.browser_process_initialization_failed, | 148 R.string.browser_process_initialization_failed, |
149 Toast.LENGTH_SHORT).show(); | 149 Toast.LENGTH_SHORT).show(); |
150 finish(); | 150 finish(); |
151 } | 151 } |
152 | 152 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 | 246 |
247 /** | 247 /** |
248 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one | 248 * @return The {@link ContentView} owned by the currently visible {@link She
ll} or null if one |
249 * is not showing. | 249 * is not showing. |
250 */ | 250 */ |
251 public ContentView getActiveContentView() { | 251 public ContentView getActiveContentView() { |
252 Shell shell = getActiveShell(); | 252 Shell shell = getActiveShell(); |
253 return shell != null ? shell.getContentView() : null; | 253 return shell != null ? shell.getContentView() : null; |
254 } | 254 } |
255 } | 255 } |
OLD | NEW |