blob: 01b9706401503fc34eb13c98e17ecaca31898dec [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
Vivek Sekhar0989b452014-08-01 12:30:35 -070025import org.codeaurora.swe.Engine;
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080026
Axesh R. Ajmera70a6ec72014-06-10 18:03:50 -070027import com.android.browser.BrowserConfig;
28
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080029public class Browser extends Application {
The Android Open Source Project0c908882009-03-03 19:32:16 -080030
31 private final static String LOGTAG = "browser";
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080032
Dave Bort31a6d1c2009-04-13 15:56:49 -070033 // Set to true to enable verbose logging.
John Reck6c2e2f32011-08-22 13:41:23 -070034 final static boolean LOGV_ENABLED = false;
Dave Bort31a6d1c2009-04-13 15:56:49 -070035
36 // Set to true to enable extra debug logging.
37 final static boolean LOGD_ENABLED = true;
38
John Reck6f48ba52010-12-03 16:03:14 -080039 @Override
The Android Open Source Project0c908882009-03-03 19:32:16 -080040 public void onCreate() {
Kristian Monsene800e8e2010-12-06 16:59:33 +000041 super.onCreate();
42
Dave Bort31a6d1c2009-04-13 15:56:49 -070043 if (LOGV_ENABLED)
The Android Open Source Project0c908882009-03-03 19:32:16 -080044 Log.v(LOGTAG, "Browser.onCreate: this=" + this);
Kristian Monsene800e8e2010-12-06 16:59:33 +000045
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080046 // SWE: Avoid initializing databases for sandboxed processes.
47 // Must have INITIALIZE_DATABASE permission in AndroidManifest.xml only for browser process
Vivek Sekhar0989b452014-08-01 12:30:35 -070048 final String INITIALIZE_DATABASE = BrowserConfig.AUTHORITY +
Axesh R. Ajmera70a6ec72014-06-10 18:03:50 -070049 ".permission.INITIALIZE_DATABASE";
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080050 final Context context = getApplicationContext();
Vivek Sekhar0989b452014-08-01 12:30:35 -070051 boolean isActivityContext = (context.checkPermission(INITIALIZE_DATABASE,
52 Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED);
53 if (isActivityContext) {
54 // Initialize the SWE engine.
55 Engine.initialize(context);
56 BrowserSettings.initialize(context);
57 Preloader.initialize(context);
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080058 }
59 }
The Android Open Source Project0c908882009-03-03 19:32:16 -080060}
61