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

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

Issue 10962002: Adding NativeWindow base class with no activity. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: deleted whitespace in OWNERS Created 8 years, 3 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.content.Intent;
9 import android.os.Bundle; 9 import android.os.Bundle;
10 import android.text.TextUtils; 10 import android.text.TextUtils;
11 import android.util.Log; 11 import android.util.Log;
12 import android.view.KeyEvent; 12 import android.view.KeyEvent;
13 13
14 import org.chromium.content.app.AppResource; 14 import org.chromium.content.app.AppResource;
15 import org.chromium.content.app.LibraryLoader; 15 import org.chromium.content.app.LibraryLoader;
16 import org.chromium.content.browser.ContentView; 16 import org.chromium.content.browser.ContentView;
17 import org.chromium.content.common.CommandLine; 17 import org.chromium.content.common.CommandLine;
18 import org.chromium.ui.gfx.NativeWindow; 18 import org.chromium.ui.gfx.ActivityNativeWindow;
19 19
20 /** 20 /**
21 * Activity for managing the Content Shell. 21 * Activity for managing the Content Shell.
22 */ 22 */
23 public class ContentShellActivity extends Activity { 23 public class ContentShellActivity extends Activity {
24 24
25 private static final String COMMAND_LINE_FILE = "/data/local/tmp/content-she ll-command-line"; 25 private static final String COMMAND_LINE_FILE = "/data/local/tmp/content-she ll-command-line";
26 private static final String TAG = ContentShellActivity.class.getName(); 26 private static final String TAG = ContentShellActivity.class.getName();
27 27
28 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl"; 28 private static final String ACTIVE_SHELL_URL_KEY = "activeUrl";
29 public static final String DEFAULT_SHELL_URL = "http://www.google.com"; 29 public static final String DEFAULT_SHELL_URL = "http://www.google.com";
30 30
31 private ShellManager mShellManager; 31 private ShellManager mShellManager;
32 private ActivityNativeWindow mActivityNativeWindow;
32 33
33 @Override 34 @Override
34 protected void onCreate(Bundle savedInstanceState) { 35 protected void onCreate(Bundle savedInstanceState) {
35 super.onCreate(savedInstanceState); 36 super.onCreate(savedInstanceState);
36 37
37 // Initializing the command line must occur before loading the library. 38 // Initializing the command line must occur before loading the library.
38 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_ FILE); 39 if (!CommandLine.isInitialized()) CommandLine.initFromFile(COMMAND_LINE_ FILE);
39 waitForDebuggerIfNeeded(); 40 waitForDebuggerIfNeeded();
40 41
41 LibraryLoader.loadAndInitSync(); 42 LibraryLoader.loadAndInitSync();
42 initializeContentViewResources(); 43 initializeContentViewResources();
43 44
44 setContentView(R.layout.content_shell_activity); 45 setContentView(R.layout.content_shell_activity);
45 mShellManager = (ShellManager) findViewById(R.id.shell_container); 46 mShellManager = (ShellManager) findViewById(R.id.shell_container);
46 mShellManager.setWindow(new NativeWindow(this)); 47 mActivityNativeWindow = new ActivityNativeWindow(this);
48 mActivityNativeWindow.restoreInstanceState(savedInstanceState);
49 mShellManager.setWindow(mActivityNativeWindow);
47 50
48 String startupUrl = getUrlFromIntent(getIntent()); 51 String startupUrl = getUrlFromIntent(getIntent());
49 if (!TextUtils.isEmpty(startupUrl)) { 52 if (!TextUtils.isEmpty(startupUrl)) {
50 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl)); 53 mShellManager.setStartupUrl(Shell.sanitizeUrl(startupUrl));
51 } 54 }
52 55
53 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTO MATIC)) { 56 if (!ContentView.enableMultiProcess(this, ContentView.MAX_RENDERERS_AUTO MATIC)) {
54 String shellUrl = DEFAULT_SHELL_URL; 57 String shellUrl = DEFAULT_SHELL_URL;
55 if (savedInstanceState != null 58 if (savedInstanceState != null
56 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) { 59 && savedInstanceState.containsKey(ACTIVE_SHELL_URL_KEY)) {
57 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY); 60 shellUrl = savedInstanceState.getString(ACTIVE_SHELL_URL_KEY);
58 } 61 }
59 mShellManager.launchShell(shellUrl); 62 mShellManager.launchShell(shellUrl);
60 } 63 }
61 } 64 }
62 65
63 @Override 66 @Override
64 protected void onSaveInstanceState(Bundle outState) { 67 protected void onSaveInstanceState(Bundle outState) {
65 super.onSaveInstanceState(outState); 68 super.onSaveInstanceState(outState);
66 Shell activeShell = getActiveShell(); 69 Shell activeShell = getActiveShell();
67 if (activeShell != null) { 70 if (activeShell != null) {
68 outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView( ).getUrl()); 71 outState.putString(ACTIVE_SHELL_URL_KEY, activeShell.getContentView( ).getUrl());
69 } 72 }
73
74 mActivityNativeWindow.saveInstanceState(outState);
70 } 75 }
71 76
72 private void waitForDebuggerIfNeeded() { 77 private void waitForDebuggerIfNeeded() {
73 if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGG ER)) { 78 if (CommandLine.getInstance().hasSwitch(CommandLine.WAIT_FOR_JAVA_DEBUGG ER)) {
74 Log.e(TAG, "Waiting for Java debugger to connect..."); 79 Log.e(TAG, "Waiting for Java debugger to connect...");
75 android.os.Debug.waitForDebugger(); 80 android.os.Debug.waitForDebugger();
76 Log.e(TAG, "Java debugger connected. Resuming execution."); 81 Log.e(TAG, "Java debugger connected. Resuming execution.");
77 } 82 }
78 } 83 }
79 84
(...skipping 30 matching lines...) Expand all
110 } 115 }
111 116
112 @Override 117 @Override
113 protected void onResume() { 118 protected void onResume() {
114 super.onResume(); 119 super.onResume();
115 120
116 ContentView view = getActiveContentView(); 121 ContentView view = getActiveContentView();
117 if (view != null) view.onActivityResume(); 122 if (view != null) view.onActivityResume();
118 } 123 }
119 124
125 @Override
126 public void onActivityResult(int requestCode, int resultCode, Intent data) {
127 super.onActivityResult(requestCode, resultCode, data);
128 mActivityNativeWindow.onActivityResult(requestCode, resultCode, data);
129 }
130
120 private static String getUrlFromIntent(Intent intent) { 131 private static String getUrlFromIntent(Intent intent) {
121 return intent != null ? intent.getDataString() : null; 132 return intent != null ? intent.getDataString() : null;
122 } 133 }
123 134
124 /** 135 /**
125 * @return The {@link ShellManager} configured for the activity or null if i t has not been 136 * @return The {@link ShellManager} configured for the activity or null if i t has not been
126 * created yet. 137 * created yet.
127 */ 138 */
128 public ShellManager getShellManager() { 139 public ShellManager getShellManager() {
129 return mShellManager; 140 return mShellManager;
(...skipping 14 matching lines...) Expand all
144 Shell shell = getActiveShell(); 155 Shell shell = getActiveShell();
145 return shell != null ? shell.getContentView() : null; 156 return shell != null ? shell.getContentView() : null;
146 } 157 }
147 158
148 private void initializeContentViewResources() { 159 private void initializeContentViewResources() {
149 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview _overlay_radius; 160 AppResource.DIMENSION_LINK_PREVIEW_OVERLAY_RADIUS = R.dimen.link_preview _overlay_radius;
150 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome r_overlay; 161 AppResource.DRAWABLE_LINK_PREVIEW_POPUP_OVERLAY = R.drawable.popup_zoome r_overlay;
151 AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibi lity_content_view; 162 AppResource.STRING_CONTENT_VIEW_CONTENT_DESCRIPTION = R.string.accessibi lity_content_view;
152 } 163 }
153 } 164 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698