blob: 8270cfbc9d180bb3fa295b19c22f2d2f60c49dde [file] [log] [blame]
The Android Open Source Project0c908882009-03-03 19:32:16 -08001/*
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 Amirzada41242f22014-03-21 12:12:18 -070017package com.android.browser;
The Android Open Source Project0c908882009-03-03 19:32:16 -080018
Enrico Ros1c4d6b82014-10-14 16:23:17 -070019import android.Manifest;
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070020import android.app.Activity;
The Android Open Source Project0c908882009-03-03 19:32:16 -080021import android.app.Application;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080022import android.content.Context;
23import android.content.pm.PackageManager;
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070024import android.os.Bundle;
Enrico Ros1c4d6b82014-10-14 16:23:17 -070025import android.util.Log;
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070026import android.os.Process;
Tarun Nainaniea28dde2014-08-27 17:25:09 -070027
Vivek Sekhared791da2015-02-22 12:39:05 -080028import org.chromium.chrome.browser.ChromiumApplication;
29import org.chromium.chrome.browser.PKCS11AuthenticationManager;
Tarun Nainanicf41be02015-07-31 11:37:16 -070030import org.codeaurora.swe.SWEEmptyPKCS11AuthenticationManager;
Vivek Sekhared791da2015-02-22 12:39:05 -080031
Vivek Sekhar0989b452014-08-01 12:30:35 -070032import org.codeaurora.swe.Engine;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080033
Vivek Sekhared791da2015-02-22 12:39:05 -080034public class Browser extends ChromiumApplication {
The Android Open Source Project0c908882009-03-03 19:32:16 -080035
36 private final static String LOGTAG = "browser";
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080037
Dave Bort31a6d1c2009-04-13 15:56:49 -070038 // Set to true to enable verbose logging.
John Reck6c2e2f32011-08-22 13:41:23 -070039 final static boolean LOGV_ENABLED = false;
Dave Bort31a6d1c2009-04-13 15:56:49 -070040
41 // Set to true to enable extra debug logging.
42 final static boolean LOGD_ENABLED = true;
43
Panos Thomas64c77e02014-12-17 22:15:23 -080044 private static Context mContext;
45
46 public static Context getContext() {
47 return mContext;
48 }
49
John Reck6f48ba52010-12-03 16:03:14 -080050 @Override
The Android Open Source Project0c908882009-03-03 19:32:16 -080051 public void onCreate() {
Kristian Monsene800e8e2010-12-06 16:59:33 +000052 super.onCreate();
Enrico Ros1c4d6b82014-10-14 16:23:17 -070053
Panos Thomas64c77e02014-12-17 22:15:23 -080054 mContext = this;
55
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070056 if (LOGV_ENABLED) {
The Android Open Source Project0c908882009-03-03 19:32:16 -080057 Log.v(LOGTAG, "Browser.onCreate: this=" + this);
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070058 }
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 Palanichamy60aac812015-05-13 20:54:15 -070067 EngineInitializer.initializeSync((Context) Browser.this);
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070068 }
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 Monsene800e8e2010-12-06 16:59:33 +0000113
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700114 // Chromium specific initialization.
Tarun Nainani8eb00912014-07-17 12:28:32 -0700115 Engine.initializeApplicationParameters();
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700116
117 final boolean isSandboxContext = checkPermission(Manifest.permission.INTERNET,
118 Process.myPid(), Process.myUid()) != PackageManager.PERMISSION_GRANTED;
119
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -0700120 // SWE: Avoid initializing the engine for sandboxed processes.
121 if (!isSandboxContext) {
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700122 BrowserSettings.initialize((Context) this);
123 Preloader.initialize((Context) this);
124 }
Tarun Nainaniea28dde2014-08-27 17:25:09 -0700125
126 }
Vivek Sekhared791da2015-02-22 12:39:05 -0800127
128 @Override
129 protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() {
Tarun Nainanicf41be02015-07-31 11:37:16 -0700130 return new SWEEmptyPKCS11AuthenticationManager();
Vivek Sekhared791da2015-02-22 12:39:05 -0800131 }
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 Project0c908882009-03-03 19:32:16 -0800150}
151