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 | |
Bijan Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 17 | package com.android.browser; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 18 | |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 19 | import android.Manifest; |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame^] | 20 | import android.app.Activity; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 21 | import android.app.Application; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 22 | import android.content.Context; |
| 23 | import android.content.pm.PackageManager; |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame^] | 24 | import android.os.Bundle; |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 25 | import android.util.Log; |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame^] | 26 | import android.os.Process; |
Tarun Nainani | ea28dde | 2014-08-27 17:25:09 -0700 | [diff] [blame] | 27 | |
Vivek Sekhar | 0989b45 | 2014-08-01 12:30:35 -0700 | [diff] [blame] | 28 | import org.codeaurora.swe.Engine; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 29 | |
| 30 | public class Browser extends Application { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 31 | |
| 32 | private final static String LOGTAG = "browser"; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 33 | |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 34 | // Set to true to enable verbose logging. |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 35 | final static boolean LOGV_ENABLED = false; |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 36 | |
| 37 | // Set to true to enable extra debug logging. |
| 38 | final static boolean LOGD_ENABLED = true; |
| 39 | |
John Reck | 6f48ba5 | 2010-12-03 16:03:14 -0800 | [diff] [blame] | 40 | @Override |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 41 | public void onCreate() { |
Kristian Monsen | e800e8e | 2010-12-06 16:59:33 +0000 | [diff] [blame] | 42 | super.onCreate(); |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 43 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame^] | 44 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 45 | Log.v(LOGTAG, "Browser.onCreate: this=" + this); |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame^] | 46 | } |
| 47 | |
| 48 | registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { |
| 49 | @Override |
| 50 | public void onActivityCreated(final Activity activity, Bundle savedInstanceState) { |
| 51 | if (LOGV_ENABLED) { |
| 52 | Log.v(LOGTAG, "Browser.onActivityCreated: activity=" + activity); |
| 53 | } |
| 54 | if (!(activity instanceof BrowserActivity) && !(activity instanceof BrowserLauncher) ) { |
| 55 | EngineInitializer.getInstance().initializeSync((Context) Browser.this); |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public void onActivityDestroyed(Activity activity) { |
| 61 | if (LOGV_ENABLED) { |
| 62 | Log.v(LOGTAG, "Browser.onActivityDestroyed: activity=" + activity); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public void onActivityPaused(Activity activity) { |
| 68 | if (LOGV_ENABLED) { |
| 69 | Log.v(LOGTAG, "Browser.onActivityPaused: activity=" + activity); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | @Override |
| 74 | public void onActivityResumed(Activity activity) { |
| 75 | if (LOGV_ENABLED) { |
| 76 | Log.v(LOGTAG, "Browser.onActivityResumed: activity=" + activity); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | @Override |
| 81 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) { |
| 82 | if (LOGV_ENABLED) { |
| 83 | Log.v(LOGTAG, "Browser.onActivitySaveInstanceState: activity=" + activity); |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | @Override |
| 88 | public void onActivityStarted(Activity activity) { |
| 89 | if (LOGV_ENABLED) { |
| 90 | Log.v(LOGTAG, "Browser.onActivityStarted: activity=" + activity); |
| 91 | } |
| 92 | } |
| 93 | |
| 94 | @Override |
| 95 | public void onActivityStopped(Activity activity) { |
| 96 | if (LOGV_ENABLED) { |
| 97 | Log.v(LOGTAG, "Browser.onActivityStopped: activity=" + activity); |
| 98 | } |
| 99 | } |
| 100 | }); |
Kristian Monsen | e800e8e | 2010-12-06 16:59:33 +0000 | [diff] [blame] | 101 | |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 102 | // Chromium specific initialization. |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 103 | Engine.initializeApplicationParameters(); |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 104 | |
| 105 | final boolean isSandboxContext = checkPermission(Manifest.permission.INTERNET, |
| 106 | Process.myPid(), Process.myUid()) != PackageManager.PERMISSION_GRANTED; |
| 107 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame^] | 108 | // SWE: Avoid initializing the engine for sandboxed processes. |
| 109 | if (!isSandboxContext) { |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 110 | BrowserSettings.initialize((Context) this); |
| 111 | Preloader.initialize((Context) this); |
| 112 | } |
Tarun Nainani | ea28dde | 2014-08-27 17:25:09 -0700 | [diff] [blame] | 113 | |
| 114 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 115 | } |
| 116 | |