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 | ed791da | 2015-02-22 12:39:05 -0800 | [diff] [blame] | 28 | import org.chromium.chrome.browser.ChromiumApplication; |
| 29 | import org.chromium.chrome.browser.PKCS11AuthenticationManager; |
Tarun Nainani | cf41be0 | 2015-07-31 11:37:16 -0700 | [diff] [blame^] | 30 | import org.codeaurora.swe.SWEEmptyPKCS11AuthenticationManager; |
Vivek Sekhar | ed791da | 2015-02-22 12:39:05 -0800 | [diff] [blame] | 31 | |
Vivek Sekhar | 0989b45 | 2014-08-01 12:30:35 -0700 | [diff] [blame] | 32 | import org.codeaurora.swe.Engine; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 33 | |
Vivek Sekhar | ed791da | 2015-02-22 12:39:05 -0800 | [diff] [blame] | 34 | public class Browser extends ChromiumApplication { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 35 | |
| 36 | private final static String LOGTAG = "browser"; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 37 | |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 38 | // Set to true to enable verbose logging. |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 39 | final static boolean LOGV_ENABLED = false; |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 40 | |
| 41 | // Set to true to enable extra debug logging. |
| 42 | final static boolean LOGD_ENABLED = true; |
| 43 | |
Panos Thomas | 64c77e0 | 2014-12-17 22:15:23 -0800 | [diff] [blame] | 44 | private static Context mContext; |
| 45 | |
| 46 | public static Context getContext() { |
| 47 | return mContext; |
| 48 | } |
| 49 | |
John Reck | 6f48ba5 | 2010-12-03 16:03:14 -0800 | [diff] [blame] | 50 | @Override |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 51 | public void onCreate() { |
Kristian Monsen | e800e8e | 2010-12-06 16:59:33 +0000 | [diff] [blame] | 52 | super.onCreate(); |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 53 | |
Panos Thomas | 64c77e0 | 2014-12-17 22:15:23 -0800 | [diff] [blame] | 54 | mContext = this; |
| 55 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 56 | if (LOGV_ENABLED) { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 57 | Log.v(LOGTAG, "Browser.onCreate: this=" + this); |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() { |
| 61 | @Override |
| 62 | public void onActivityCreated(final Activity activity, Bundle savedInstanceState) { |
| 63 | if (LOGV_ENABLED) { |
| 64 | Log.v(LOGTAG, "Browser.onActivityCreated: activity=" + activity); |
| 65 | } |
| 66 | if (!(activity instanceof BrowserActivity) && !(activity instanceof BrowserLauncher) ) { |
Kulanthaivel Palanichamy | 60aac81 | 2015-05-13 20:54:15 -0700 | [diff] [blame] | 67 | EngineInitializer.initializeSync((Context) Browser.this); |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public void onActivityDestroyed(Activity activity) { |
| 73 | if (LOGV_ENABLED) { |
| 74 | Log.v(LOGTAG, "Browser.onActivityDestroyed: activity=" + activity); |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | @Override |
| 79 | public void onActivityPaused(Activity activity) { |
| 80 | if (LOGV_ENABLED) { |
| 81 | Log.v(LOGTAG, "Browser.onActivityPaused: activity=" + activity); |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | @Override |
| 86 | public void onActivityResumed(Activity activity) { |
| 87 | if (LOGV_ENABLED) { |
| 88 | Log.v(LOGTAG, "Browser.onActivityResumed: activity=" + activity); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | @Override |
| 93 | public void onActivitySaveInstanceState(Activity activity, Bundle outState) { |
| 94 | if (LOGV_ENABLED) { |
| 95 | Log.v(LOGTAG, "Browser.onActivitySaveInstanceState: activity=" + activity); |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public void onActivityStarted(Activity activity) { |
| 101 | if (LOGV_ENABLED) { |
| 102 | Log.v(LOGTAG, "Browser.onActivityStarted: activity=" + activity); |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | @Override |
| 107 | public void onActivityStopped(Activity activity) { |
| 108 | if (LOGV_ENABLED) { |
| 109 | Log.v(LOGTAG, "Browser.onActivityStopped: activity=" + activity); |
| 110 | } |
| 111 | } |
| 112 | }); |
Kristian Monsen | e800e8e | 2010-12-06 16:59:33 +0000 | [diff] [blame] | 113 | |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 114 | // Chromium specific initialization. |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 115 | Engine.initializeApplicationParameters(); |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 116 | |
| 117 | final boolean isSandboxContext = checkPermission(Manifest.permission.INTERNET, |
| 118 | Process.myPid(), Process.myUid()) != PackageManager.PERMISSION_GRANTED; |
| 119 | |
Kulanthaivel Palanichamy | 7794268 | 2014-10-28 11:52:06 -0700 | [diff] [blame] | 120 | // SWE: Avoid initializing the engine for sandboxed processes. |
| 121 | if (!isSandboxContext) { |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame] | 122 | BrowserSettings.initialize((Context) this); |
| 123 | Preloader.initialize((Context) this); |
| 124 | } |
Tarun Nainani | ea28dde | 2014-08-27 17:25:09 -0700 | [diff] [blame] | 125 | |
| 126 | } |
Vivek Sekhar | ed791da | 2015-02-22 12:39:05 -0800 | [diff] [blame] | 127 | |
| 128 | @Override |
| 129 | protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() { |
Tarun Nainani | cf41be0 | 2015-07-31 11:37:16 -0700 | [diff] [blame^] | 130 | return new SWEEmptyPKCS11AuthenticationManager(); |
Vivek Sekhar | ed791da | 2015-02-22 12:39:05 -0800 | [diff] [blame] | 131 | } |
| 132 | |
| 133 | @Override |
| 134 | protected void openProtectedContentSettings() { |
| 135 | } |
| 136 | |
| 137 | @Override |
| 138 | protected boolean areParentalControlsEnabled() { |
| 139 | return false; |
| 140 | } |
| 141 | |
| 142 | @Override |
| 143 | public String getSettingsActivityName() { |
| 144 | return null; |
| 145 | } |
| 146 | |
| 147 | @Override |
| 148 | public void initCommandLine() { |
| 149 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 150 | } |
| 151 | |