blob: 5a30fad99e8d977c68bdc9115ded9e82de880b28 [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
The Android Open Source Project0c908882009-03-03 19:32:16 -080019import android.app.Application;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080020import android.content.Context;
21import android.content.pm.PackageManager;
John Reck35e9dd62011-04-25 09:01:54 -070022import android.util.Log;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080023import android.os.Process;
The Android Open Source Project0c908882009-03-03 19:32:16 -080024
Tarun Nainaniea28dde2014-08-27 17:25:09 -070025import org.chromium.content.browser.ResourceExtractor;
26import org.chromium.base.PathUtils;
27
Vivek Sekhar0989b452014-08-01 12:30:35 -070028import org.codeaurora.swe.Engine;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080029
Axesh R. Ajmera70a6ec72014-06-10 18:03:50 -070030import com.android.browser.BrowserConfig;
31
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080032public class Browser extends Application {
The Android Open Source Project0c908882009-03-03 19:32:16 -080033
34 private final static String LOGTAG = "browser";
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080035
Dave Bort31a6d1c2009-04-13 15:56:49 -070036 // Set to true to enable verbose logging.
John Reck6c2e2f32011-08-22 13:41:23 -070037 final static boolean LOGV_ENABLED = false;
Dave Bort31a6d1c2009-04-13 15:56:49 -070038
39 // Set to true to enable extra debug logging.
40 final static boolean LOGD_ENABLED = true;
41
Tarun Nainaniea28dde2014-08-27 17:25:09 -070042 private static final String[] MP_MANDATORY_PAKS = new String[] {
43 "webviewchromium.pak",
44 "icudtl.dat"
45 };
46
John Reck6f48ba52010-12-03 16:03:14 -080047 @Override
The Android Open Source Project0c908882009-03-03 19:32:16 -080048 public void onCreate() {
Kristian Monsene800e8e2010-12-06 16:59:33 +000049 super.onCreate();
Tarun Nainaniea28dde2014-08-27 17:25:09 -070050 initializeApplicationParameters();
Dave Bort31a6d1c2009-04-13 15:56:49 -070051 if (LOGV_ENABLED)
The Android Open Source Project0c908882009-03-03 19:32:16 -080052 Log.v(LOGTAG, "Browser.onCreate: this=" + this);
Kristian Monsene800e8e2010-12-06 16:59:33 +000053
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080054 // SWE: Avoid initializing databases for sandboxed processes.
55 // Must have INITIALIZE_DATABASE permission in AndroidManifest.xml only for browser process
Vivek Sekhar0989b452014-08-01 12:30:35 -070056 final String INITIALIZE_DATABASE = BrowserConfig.AUTHORITY +
Axesh R. Ajmera70a6ec72014-06-10 18:03:50 -070057 ".permission.INITIALIZE_DATABASE";
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080058 final Context context = getApplicationContext();
Vivek Sekhar0989b452014-08-01 12:30:35 -070059 boolean isActivityContext = (context.checkPermission(INITIALIZE_DATABASE,
60 Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED);
61 if (isActivityContext) {
62 // Initialize the SWE engine.
63 Engine.initialize(context);
64 BrowserSettings.initialize(context);
65 Preloader.initialize(context);
Tarun Nainaniea28dde2014-08-27 17:25:09 -070066 }
67
68 }
69
70 public static void initializeApplicationParameters() {
71 ResourceExtractor.setMandatoryPaksToExtract(MP_MANDATORY_PAKS);
72 PathUtils.setPrivateDataDirectorySuffix("android_browser");
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080073 }
The Android Open Source Project0c908882009-03-03 19:32:16 -080074}
75