The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2006 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 | |
| 17 | package com.android.browser; |
| 18 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 19 | import android.app.Activity; |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 20 | import android.app.KeyguardManager; |
John Reck | 9d27ff5 | 2011-02-11 17:47:54 -0800 | [diff] [blame] | 21 | import android.content.Context; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 22 | import android.content.Intent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 23 | import android.content.res.Configuration; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 24 | import android.os.Bundle; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 25 | import android.os.Handler; |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 26 | import android.os.PowerManager; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 27 | import android.util.Log; |
Leon Scroggins III | 8e4fbf1 | 2010-08-17 16:58:15 -0400 | [diff] [blame] | 28 | import android.view.ActionMode; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 29 | import android.view.ContextMenu; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 30 | import android.view.ContextMenu.ContextMenuInfo; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 31 | import android.view.KeyEvent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 32 | import android.view.Menu; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 33 | import android.view.MenuItem; |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 34 | import android.view.MotionEvent; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 35 | import android.view.View; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 36 | import android.view.Window; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 37 | import android.webkit.JavascriptInterface; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 38 | |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 39 | import com.android.browser.UI.ComboViews; |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 40 | import com.android.browser.stub.NullController; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 41 | |
John Reck | d3e4d5b | 2011-07-13 15:48:43 -0700 | [diff] [blame] | 42 | import com.google.common.annotations.VisibleForTesting; |
| 43 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 44 | public class BrowserActivity extends Activity { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 45 | |
John Reck | 439c9a5 | 2010-12-14 10:04:39 -0800 | [diff] [blame] | 46 | public static final String ACTION_SHOW_BOOKMARKS = "show_bookmarks"; |
| 47 | public static final String ACTION_SHOW_BROWSER = "show_browser"; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 48 | public static final String ACTION_RESTART = "--restart--"; |
| 49 | private static final String EXTRA_STATE = "state"; |
John Reck | 38b3965 | 2012-06-05 09:22:59 -0700 | [diff] [blame] | 50 | public static final String EXTRA_DISABLE_URL_OVERRIDE = "disable_url_override"; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 51 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 52 | private final static String LOGTAG = "browser"; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 53 | |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 54 | private final static boolean LOGV_ENABLED = Browser.LOGV_ENABLED; |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 55 | |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 56 | private ActivityController mController = NullController.INSTANCE; |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 57 | private Handler mHandler = new Handler(); |
Jeff Davidson | 4361029 | 2010-07-16 16:03:58 -0700 | [diff] [blame] | 58 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 59 | @Override |
| 60 | public void onCreate(Bundle icicle) { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 61 | if (LOGV_ENABLED) { |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 62 | Log.v(LOGTAG, this + " onStart, has state: " |
| 63 | + (icicle == null ? "false" : "true")); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 64 | } |
| 65 | super.onCreate(icicle); |
Derek Sollenberger | ffa561e | 2010-11-16 14:19:01 -0500 | [diff] [blame] | 66 | |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 67 | if (shouldIgnoreIntents()) { |
| 68 | finish(); |
| 69 | return; |
| 70 | } |
| 71 | |
John Reck | f57c029 | 2011-07-21 18:15:39 -0700 | [diff] [blame] | 72 | // If this was a web search request, pass it on to the default web |
| 73 | // search provider and finish this activity. |
| 74 | if (IntentHandler.handleWebSearchIntent(this, null, getIntent())) { |
| 75 | finish(); |
| 76 | return; |
| 77 | } |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 78 | mController = createController(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 79 | |
George Mount | 3636d0a | 2011-11-21 09:08:21 -0800 | [diff] [blame] | 80 | Intent intent = (icicle == null) ? getIntent() : null; |
| 81 | mController.start(intent); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 82 | } |
| 83 | |
John Reck | a5176f3 | 2011-05-17 12:35:37 -0700 | [diff] [blame] | 84 | public static boolean isTablet(Context context) { |
| 85 | return context.getResources().getBoolean(R.bool.isTablet); |
John Reck | 9d27ff5 | 2011-02-11 17:47:54 -0800 | [diff] [blame] | 86 | } |
| 87 | |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 88 | private Controller createController() { |
| 89 | Controller controller = new Controller(this); |
| 90 | boolean xlarge = isTablet(this); |
| 91 | UI ui = null; |
| 92 | if (xlarge) { |
| 93 | ui = new XLargeUi(this, controller); |
| 94 | } else { |
| 95 | ui = new PhoneUi(this, controller); |
| 96 | } |
| 97 | controller.setUi(ui); |
| 98 | return controller; |
| 99 | } |
| 100 | |
John Reck | 4155485 | 2010-12-01 12:53:37 -0800 | [diff] [blame] | 101 | @VisibleForTesting |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 102 | Controller getController() { |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 103 | return (Controller) mController; |
Michael Kolb | a2b2ba8 | 2010-08-04 17:54:03 -0700 | [diff] [blame] | 104 | } |
| 105 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 106 | @Override |
| 107 | protected void onNewIntent(Intent intent) { |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 108 | if (shouldIgnoreIntents()) return; |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 109 | if (ACTION_RESTART.equals(intent.getAction())) { |
| 110 | Bundle outState = new Bundle(); |
John Reck | 1cf4b79 | 2011-07-26 10:22:22 -0700 | [diff] [blame] | 111 | mController.onSaveInstanceState(outState); |
John Reck | 63bb687 | 2010-12-01 19:29:32 -0800 | [diff] [blame] | 112 | finish(); |
| 113 | getApplicationContext().startActivity( |
| 114 | new Intent(getApplicationContext(), BrowserActivity.class) |
| 115 | .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
| 116 | .putExtra(EXTRA_STATE, outState)); |
| 117 | return; |
| 118 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 119 | mController.handleNewIntent(intent); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 120 | } |
| 121 | |
John Reck | 7878f22 | 2012-04-18 16:23:14 -0700 | [diff] [blame] | 122 | private KeyguardManager mKeyguardManager; |
| 123 | private PowerManager mPowerManager; |
| 124 | private boolean shouldIgnoreIntents() { |
| 125 | // Only process intents if the screen is on and the device is unlocked |
| 126 | // aka, if we will be user-visible |
| 127 | if (mKeyguardManager == null) { |
| 128 | mKeyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE); |
| 129 | } |
| 130 | if (mPowerManager == null) { |
| 131 | mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); |
| 132 | } |
| 133 | boolean ignore = !mPowerManager.isScreenOn(); |
| 134 | ignore |= mKeyguardManager.inKeyguardRestrictedInputMode(); |
| 135 | if (LOGV_ENABLED) { |
| 136 | Log.v(LOGTAG, "ignore intents: " + ignore); |
| 137 | } |
| 138 | return ignore; |
| 139 | } |
| 140 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 141 | @Override |
| 142 | protected void onResume() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 143 | super.onResume(); |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 144 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 145 | Log.v(LOGTAG, "BrowserActivity.onResume: this=" + this); |
| 146 | } |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 147 | mController.onResume(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 148 | } |
| 149 | |
Leon Scroggins | a81a764 | 2009-08-31 17:05:41 -0400 | [diff] [blame] | 150 | @Override |
| 151 | public boolean onMenuOpened(int featureId, Menu menu) { |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 152 | if (Window.FEATURE_OPTIONS_PANEL == featureId) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 153 | mController.onMenuOpened(featureId, menu); |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 154 | } |
Leon Scroggins | a81a764 | 2009-08-31 17:05:41 -0400 | [diff] [blame] | 155 | return true; |
| 156 | } |
| 157 | |
Leon Scroggins | 3bbb6ca | 2009-09-09 12:51:10 -0400 | [diff] [blame] | 158 | @Override |
| 159 | public void onOptionsMenuClosed(Menu menu) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 160 | mController.onOptionsMenuClosed(menu); |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 161 | } |
| 162 | |
Leon Scroggins | b2b19f5 | 2009-10-09 16:10:00 -0400 | [diff] [blame] | 163 | @Override |
| 164 | public void onContextMenuClosed(Menu menu) { |
| 165 | super.onContextMenuClosed(menu); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 166 | mController.onContextMenuClosed(menu); |
Leon Scroggins | b2b19f5 | 2009-10-09 16:10:00 -0400 | [diff] [blame] | 167 | } |
| 168 | |
Leon Scroggins | c6fa110 | 2009-09-21 10:40:01 -0400 | [diff] [blame] | 169 | /** |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 170 | * onSaveInstanceState(Bundle map) |
| 171 | * onSaveInstanceState is called right before onStop(). The map contains |
| 172 | * the saved state. |
| 173 | */ |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 174 | @Override |
| 175 | protected void onSaveInstanceState(Bundle outState) { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 176 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 177 | Log.v(LOGTAG, "BrowserActivity.onSaveInstanceState: this=" + this); |
| 178 | } |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 179 | mController.onSaveInstanceState(outState); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 180 | } |
| 181 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 182 | @Override |
| 183 | protected void onPause() { |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 184 | mController.onPause(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 185 | super.onPause(); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 186 | } |
| 187 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 188 | @Override |
| 189 | protected void onDestroy() { |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 190 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 191 | Log.v(LOGTAG, "BrowserActivity.onDestroy: this=" + this); |
| 192 | } |
| 193 | super.onDestroy(); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 194 | mController.onDestroy(); |
| 195 | mController = NullController.INSTANCE; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | @Override |
| 199 | public void onConfigurationChanged(Configuration newConfig) { |
| 200 | super.onConfigurationChanged(newConfig); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 201 | mController.onConfgurationChanged(newConfig); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 202 | } |
| 203 | |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 204 | @Override |
| 205 | public void onLowMemory() { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 206 | super.onLowMemory(); |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 207 | mController.onLowMemory(); |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 208 | } |
| 209 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 210 | @Override |
| 211 | public boolean onCreateOptionsMenu(Menu menu) { |
| 212 | super.onCreateOptionsMenu(menu); |
John Reck | 9c35b9c | 2012-05-30 10:08:50 -0700 | [diff] [blame] | 213 | return mController.onCreateOptionsMenu(menu); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 217 | public boolean onPrepareOptionsMenu(Menu menu) { |
| 218 | super.onPrepareOptionsMenu(menu); |
John Reck | b3417f0 | 2011-01-14 11:01:05 -0800 | [diff] [blame] | 219 | return mController.onPrepareOptionsMenu(menu); |
Cary Clark | 01cfcdd | 2010-06-04 16:36:45 -0400 | [diff] [blame] | 220 | } |
| 221 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 222 | @Override |
| 223 | public boolean onOptionsItemSelected(MenuItem item) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 224 | if (!mController.onOptionsItemSelected(item)) { |
kaiyiz | a8b6dbb | 2013-07-29 18:11:22 +0800 | [diff] [blame] | 225 | if (item.getItemId() == R.id.exit_menu_id) { |
| 226 | finish(); |
| 227 | new Handler().postDelayed(new Runnable() { |
| 228 | @Override |
| 229 | public void run() { |
| 230 | // Make sure all tabs are closed. |
| 231 | if (mController != NullController.INSTANCE) { |
| 232 | mController.onPause(); |
| 233 | mController.onDestroy(); |
| 234 | // Clear the state before kill the browser process. |
| 235 | CrashRecoveryHandler.getInstance().clearState(true); |
| 236 | mController = NullController.INSTANCE; |
| 237 | } |
| 238 | android.os.Process.killProcess(android.os.Process.myPid()); |
| 239 | } |
| 240 | }, 300); |
| 241 | } |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 242 | return super.onOptionsItemSelected(item); |
Michael Kolb | 370a4f3 | 2010-10-06 10:45:32 -0700 | [diff] [blame] | 243 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 244 | return true; |
| 245 | } |
| 246 | |
| 247 | @Override |
| 248 | public void onCreateContextMenu(ContextMenu menu, View v, |
| 249 | ContextMenuInfo menuInfo) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 250 | mController.onCreateContextMenu(menu, v, menuInfo); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 251 | } |
| 252 | |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 253 | @Override |
| 254 | public boolean onContextItemSelected(MenuItem item) { |
| 255 | return mController.onContextItemSelected(item); |
Grace Kloba | 22ac16e | 2009-10-07 18:00:23 -0700 | [diff] [blame] | 256 | } |
| 257 | |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 258 | @Override |
| 259 | public boolean onKeyDown(int keyCode, KeyEvent event) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 260 | return mController.onKeyDown(keyCode, event) || |
| 261 | super.onKeyDown(keyCode, event); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 262 | } |
| 263 | |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 264 | @Override |
John Reck | e6bf4ab | 2011-02-24 15:48:05 -0800 | [diff] [blame] | 265 | public boolean onKeyLongPress(int keyCode, KeyEvent event) { |
| 266 | return mController.onKeyLongPress(keyCode, event) || |
| 267 | super.onKeyLongPress(keyCode, event); |
| 268 | } |
| 269 | |
| 270 | @Override |
Grace Kloba | 5942df0 | 2009-09-18 11:48:29 -0700 | [diff] [blame] | 271 | public boolean onKeyUp(int keyCode, KeyEvent event) { |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 272 | return mController.onKeyUp(keyCode, event) || |
| 273 | super.onKeyUp(keyCode, event); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 274 | } |
| 275 | |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 276 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 277 | public void onActionModeStarted(ActionMode mode) { |
| 278 | super.onActionModeStarted(mode); |
| 279 | mController.onActionModeStarted(mode); |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 280 | } |
| 281 | |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 282 | @Override |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 283 | public void onActionModeFinished(ActionMode mode) { |
| 284 | super.onActionModeFinished(mode); |
| 285 | mController.onActionModeFinished(mode); |
Michael Kolb | e421c24 | 2010-10-04 19:29:01 -0700 | [diff] [blame] | 286 | } |
| 287 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 288 | @Override |
| 289 | protected void onActivityResult(int requestCode, int resultCode, |
Michael Kolb | 8233fac | 2010-10-26 16:08:53 -0700 | [diff] [blame] | 290 | Intent intent) { |
| 291 | mController.onActivityResult(requestCode, resultCode, intent); |
Andrei Popescu | 163ab74 | 2009-10-20 17:58:23 +0100 | [diff] [blame] | 292 | } |
| 293 | |
Michael Kolb | fbc579a | 2011-07-07 15:59:33 -0700 | [diff] [blame] | 294 | @Override |
| 295 | public boolean onSearchRequested() { |
| 296 | return mController.onSearchRequested(); |
| 297 | } |
| 298 | |
Michael Kolb | c3af067 | 2011-08-09 10:24:41 -0700 | [diff] [blame] | 299 | @Override |
| 300 | public boolean dispatchKeyEvent(KeyEvent event) { |
| 301 | return mController.dispatchKeyEvent(event) |
| 302 | || super.dispatchKeyEvent(event); |
| 303 | } |
| 304 | |
| 305 | @Override |
| 306 | public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 307 | return mController.dispatchKeyShortcutEvent(event) |
| 308 | || super.dispatchKeyShortcutEvent(event); |
| 309 | } |
| 310 | |
| 311 | @Override |
| 312 | public boolean dispatchTouchEvent(MotionEvent ev) { |
| 313 | return mController.dispatchTouchEvent(ev) |
| 314 | || super.dispatchTouchEvent(ev); |
| 315 | } |
| 316 | |
| 317 | @Override |
| 318 | public boolean dispatchTrackballEvent(MotionEvent ev) { |
| 319 | return mController.dispatchTrackballEvent(ev) |
| 320 | || super.dispatchTrackballEvent(ev); |
| 321 | } |
| 322 | |
| 323 | @Override |
| 324 | public boolean dispatchGenericMotionEvent(MotionEvent ev) { |
| 325 | return mController.dispatchGenericMotionEvent(ev) || |
| 326 | super.dispatchGenericMotionEvent(ev); |
| 327 | } |
| 328 | |
qqzhou | 8c5b0a3 | 2013-07-22 15:31:03 +0800 | [diff] [blame] | 329 | // add for carrier homepage feature |
| 330 | @JavascriptInterface |
| 331 | public void loadBookmarks() { |
| 332 | mHandler.post(new Runnable() { |
| 333 | @Override |
| 334 | public void run() { |
| 335 | if (mController instanceof Controller) { |
| 336 | ((Controller)mController).bookmarksOrHistoryPicker(ComboViews.Bookmarks); |
| 337 | } |
| 338 | } |
| 339 | }); |
| 340 | } |
| 341 | |
| 342 | // add for carrier homepage feature |
| 343 | @JavascriptInterface |
| 344 | public void loadHistory() { |
| 345 | mHandler.post(new Runnable() { |
| 346 | @Override |
| 347 | public void run() { |
| 348 | if (mController instanceof Controller) { |
| 349 | ((Controller)mController).bookmarksOrHistoryPicker(ComboViews.History); |
| 350 | } |
| 351 | } |
| 352 | }); |
| 353 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 354 | } |