blob: 6fb8ca2788d82a524b8caa527369732637201e9f [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;
30
Vivek Sekhar0989b452014-08-01 12:30:35 -070031import org.codeaurora.swe.Engine;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080032
Vivek Sekhared791da2015-02-22 12:39:05 -080033public class Browser extends ChromiumApplication {
The Android Open Source Project0c908882009-03-03 19:32:16 -080034
35 private final static String LOGTAG = "browser";
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080036
Dave Bort31a6d1c2009-04-13 15:56:49 -070037 // Set to true to enable verbose logging.
John Reck6c2e2f32011-08-22 13:41:23 -070038 final static boolean LOGV_ENABLED = false;
Dave Bort31a6d1c2009-04-13 15:56:49 -070039
40 // Set to true to enable extra debug logging.
41 final static boolean LOGD_ENABLED = true;
42
Panos Thomas64c77e02014-12-17 22:15:23 -080043 private static Context mContext;
44
45 public static Context getContext() {
46 return mContext;
47 }
48
John Reck6f48ba52010-12-03 16:03:14 -080049 @Override
The Android Open Source Project0c908882009-03-03 19:32:16 -080050 public void onCreate() {
Kristian Monsene800e8e2010-12-06 16:59:33 +000051 super.onCreate();
Enrico Ros1c4d6b82014-10-14 16:23:17 -070052
Panos Thomas64c77e02014-12-17 22:15:23 -080053 mContext = this;
54
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070055 if (LOGV_ENABLED) {
The Android Open Source Project0c908882009-03-03 19:32:16 -080056 Log.v(LOGTAG, "Browser.onCreate: this=" + this);
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070057 }
58
59 registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
60 @Override
61 public void onActivityCreated(final Activity activity, Bundle savedInstanceState) {
62 if (LOGV_ENABLED) {
63 Log.v(LOGTAG, "Browser.onActivityCreated: activity=" + activity);
64 }
65 if (!(activity instanceof BrowserActivity) && !(activity instanceof BrowserLauncher) ) {
Kulanthaivel Palanichamy60aac812015-05-13 20:54:15 -070066 EngineInitializer.initializeSync((Context) Browser.this);
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070067 }
68 }
69
70 @Override
71 public void onActivityDestroyed(Activity activity) {
72 if (LOGV_ENABLED) {
73 Log.v(LOGTAG, "Browser.onActivityDestroyed: activity=" + activity);
74 }
75 }
76
77 @Override
78 public void onActivityPaused(Activity activity) {
79 if (LOGV_ENABLED) {
80 Log.v(LOGTAG, "Browser.onActivityPaused: activity=" + activity);
81 }
82 }
83
84 @Override
85 public void onActivityResumed(Activity activity) {
86 if (LOGV_ENABLED) {
87 Log.v(LOGTAG, "Browser.onActivityResumed: activity=" + activity);
88 }
89 }
90
91 @Override
92 public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
93 if (LOGV_ENABLED) {
94 Log.v(LOGTAG, "Browser.onActivitySaveInstanceState: activity=" + activity);
95 }
96 }
97
98 @Override
99 public void onActivityStarted(Activity activity) {
100 if (LOGV_ENABLED) {
101 Log.v(LOGTAG, "Browser.onActivityStarted: activity=" + activity);
102 }
103 }
104
105 @Override
106 public void onActivityStopped(Activity activity) {
107 if (LOGV_ENABLED) {
108 Log.v(LOGTAG, "Browser.onActivityStopped: activity=" + activity);
109 }
110 }
111 });
Kristian Monsene800e8e2010-12-06 16:59:33 +0000112
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700113 // Chromium specific initialization.
Tarun Nainani8eb00912014-07-17 12:28:32 -0700114 Engine.initializeApplicationParameters();
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700115
116 final boolean isSandboxContext = checkPermission(Manifest.permission.INTERNET,
117 Process.myPid(), Process.myUid()) != PackageManager.PERMISSION_GRANTED;
118
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -0700119 // SWE: Avoid initializing the engine for sandboxed processes.
120 if (!isSandboxContext) {
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700121 BrowserSettings.initialize((Context) this);
122 Preloader.initialize((Context) this);
123 }
Tarun Nainaniea28dde2014-08-27 17:25:09 -0700124
125 }
Vivek Sekhared791da2015-02-22 12:39:05 -0800126
127 @Override
128 protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() {
129 return null;
130 }
131
132 @Override
133 protected void openProtectedContentSettings() {
134 }
135
136 @Override
137 protected boolean areParentalControlsEnabled() {
138 return false;
139 }
140
141 @Override
142 public String getSettingsActivityName() {
143 return null;
144 }
145
146 @Override
147 public void initCommandLine() {
148 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800149}
150