blob: bd2ac066820ac6647135ea66cb3000fafbfa94b1 [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
John Reck6f48ba52010-12-03 16:03:14 -080043 @Override
The Android Open Source Project0c908882009-03-03 19:32:16 -080044 public void onCreate() {
Kristian Monsene800e8e2010-12-06 16:59:33 +000045 super.onCreate();
Enrico Ros1c4d6b82014-10-14 16:23:17 -070046
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070047 if (LOGV_ENABLED) {
The Android Open Source Project0c908882009-03-03 19:32:16 -080048 Log.v(LOGTAG, "Browser.onCreate: this=" + this);
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -070049 }
50
51 registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacks() {
52 @Override
53 public void onActivityCreated(final Activity activity, Bundle savedInstanceState) {
54 if (LOGV_ENABLED) {
55 Log.v(LOGTAG, "Browser.onActivityCreated: activity=" + activity);
56 }
57 if (!(activity instanceof BrowserActivity) && !(activity instanceof BrowserLauncher) ) {
58 EngineInitializer.getInstance().initializeSync((Context) Browser.this);
59 }
60 }
61
62 @Override
63 public void onActivityDestroyed(Activity activity) {
64 if (LOGV_ENABLED) {
65 Log.v(LOGTAG, "Browser.onActivityDestroyed: activity=" + activity);
66 }
67 }
68
69 @Override
70 public void onActivityPaused(Activity activity) {
71 if (LOGV_ENABLED) {
72 Log.v(LOGTAG, "Browser.onActivityPaused: activity=" + activity);
73 }
74 }
75
76 @Override
77 public void onActivityResumed(Activity activity) {
78 if (LOGV_ENABLED) {
79 Log.v(LOGTAG, "Browser.onActivityResumed: activity=" + activity);
80 }
81 }
82
83 @Override
84 public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
85 if (LOGV_ENABLED) {
86 Log.v(LOGTAG, "Browser.onActivitySaveInstanceState: activity=" + activity);
87 }
88 }
89
90 @Override
91 public void onActivityStarted(Activity activity) {
92 if (LOGV_ENABLED) {
93 Log.v(LOGTAG, "Browser.onActivityStarted: activity=" + activity);
94 }
95 }
96
97 @Override
98 public void onActivityStopped(Activity activity) {
99 if (LOGV_ENABLED) {
100 Log.v(LOGTAG, "Browser.onActivityStopped: activity=" + activity);
101 }
102 }
103 });
Kristian Monsene800e8e2010-12-06 16:59:33 +0000104
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700105 // Chromium specific initialization.
Tarun Nainani8eb00912014-07-17 12:28:32 -0700106 Engine.initializeApplicationParameters();
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700107
108 final boolean isSandboxContext = checkPermission(Manifest.permission.INTERNET,
109 Process.myPid(), Process.myUid()) != PackageManager.PERMISSION_GRANTED;
110
Kulanthaivel Palanichamy77942682014-10-28 11:52:06 -0700111 // SWE: Avoid initializing the engine for sandboxed processes.
112 if (!isSandboxContext) {
Enrico Ros1c4d6b82014-10-14 16:23:17 -0700113 BrowserSettings.initialize((Context) this);
114 Preloader.initialize((Context) this);
115 }
Tarun Nainaniea28dde2014-08-27 17:25:09 -0700116
117 }
Vivek Sekhared791da2015-02-22 12:39:05 -0800118
119 @Override
120 protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() {
121 return null;
122 }
123
124 @Override
125 protected void openProtectedContentSettings() {
126 }
127
128 @Override
129 protected boolean areParentalControlsEnabled() {
130 return false;
131 }
132
133 @Override
134 public String getSettingsActivityName() {
135 return null;
136 }
137
138 @Override
139 public void initCommandLine() {
140 }
The Android Open Source Project0c908882009-03-03 19:32:16 -0800141}
142