Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: content/shell/android/java/org/chromium/content_shell/ContentShellActivity.java

Issue 10035034: Implement the skeleton of an android content shell. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing up most of the review comments. Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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.app.Activity; 7 import android.app.Activity;
8 import android.content.Intent;
8 import android.os.Bundle; 9 import android.os.Bundle;
9 import android.util.Log; 10 import android.text.TextUtils;
11 import android.view.KeyEvent;
12
13 import org.chromium.content.browser.ContentView;
10 14
11 /** 15 /**
12 * This is the main activity for content_shell on android, gets invoked when the 16 * Activity for managing the Content Shell.
13 * app is invoked from the launcher. This activity hosts the main UI for content
14 * shell and displays the web content via its child views.
15 */ 17 */
16 public class ContentShellActivity extends Activity { 18 public class ContentShellActivity extends Activity {
17 private final String TAG = "ContentShellActivity"; 19
20 private static final String COMMAND_LINE_FILE = "/data/local/content-shell-c ommand-line";
21
22 private ShellManager mShellManager;
18 23
19 @Override 24 @Override
20 public void onCreate(Bundle savedInstanceState) { 25 protected void onCreate(Bundle savedInstanceState) {
21 super.onCreate(savedInstanceState); 26 super.onCreate(savedInstanceState);
22 Log.i(TAG, "Content shell started"); 27
28 // Initializing the command line must occur before loading the library.
29 // TODO(tedchoc): Initialize command line from file.
30 String startupUrl = getUrlFromIntent(getIntent());
31 if (!TextUtils.isEmpty(startupUrl)) {
32 // TODO(tedchoc): Append URL to command line.
33 }
34
35 // TODO(tedchoc): Load the native library.
36 initializeContentViewResources();
37
38 setContentView(R.layout.content_shell_activity);
39 mShellManager = (ShellManager) findViewById(R.id.shell_container);
40 ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTOMATIC );
41 }
42
43 @Override
44 public boolean onKeyUp(int keyCode, KeyEvent event) {
45 if (keyCode != KeyEvent.KEYCODE_BACK) return super.onKeyUp(keyCode, even t);
46
47 ShellView activeView = getActiveShellView();
48 if (activeView != null && activeView.getContentView().canGoBack()) {
49 activeView.getContentView().goBack();
50 return true;
51 }
52
53 return super.onKeyUp(keyCode, event);
54 }
55
56 @Override
57 protected void onNewIntent(Intent intent) {
58 String url = getUrlFromIntent(intent);
59 if (!TextUtils.isEmpty(url)) {
60 ShellView activeView = getActiveShellView();
61 if (activeView != null) {
62 activeView.loadUrl(url);
63 }
64 }
65 }
66
67 private static String getUrlFromIntent(Intent intent) {
68 return intent != null ? intent.getDataString() : null;
69 }
70
71 /**
72 * @return The {@link ShellManager} configured for the activity or null if i t has not been
73 * created yet.
74 */
75 public ShellManager getShellManager() {
76 return mShellManager;
77 }
78
79 /**
80 * @return The currently visible {@link ShellView} or null if one is not sho wing.
81 */
82 public ShellView getActiveShellView() {
83 return mShellManager != null ? mShellManager.getActiveShellView() : null ;
84 }
85
86 private void initializeContentViewResources() {
87 ContentView.registerPopupOverlayCornerRadius(0);
88 ContentView.registerPopupOverlayResourceId(R.drawable.popup_zoomer_overl ay);
23 } 89 }
24 } 90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698