blob: c9b8e7b39ba8d9b37103daa37c0cf540830fadd2 [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
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080025import org.codeaurora.swe.CookieSyncManager;
26
27public class Browser extends Application {
The Android Open Source Project0c908882009-03-03 19:32:16 -080028
29 private final static String LOGTAG = "browser";
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080030
Dave Bort31a6d1c2009-04-13 15:56:49 -070031 // Set to true to enable verbose logging.
John Reck6c2e2f32011-08-22 13:41:23 -070032 final static boolean LOGV_ENABLED = false;
Dave Bort31a6d1c2009-04-13 15:56:49 -070033
34 // Set to true to enable extra debug logging.
35 final static boolean LOGD_ENABLED = true;
36
John Reck6f48ba52010-12-03 16:03:14 -080037 @Override
The Android Open Source Project0c908882009-03-03 19:32:16 -080038 public void onCreate() {
Kristian Monsene800e8e2010-12-06 16:59:33 +000039 super.onCreate();
40
Dave Bort31a6d1c2009-04-13 15:56:49 -070041 if (LOGV_ENABLED)
The Android Open Source Project0c908882009-03-03 19:32:16 -080042 Log.v(LOGTAG, "Browser.onCreate: this=" + this);
Kristian Monsene800e8e2010-12-06 16:59:33 +000043
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080044 // SWE: Avoid initializing databases for sandboxed processes.
45 // Must have INITIALIZE_DATABASE permission in AndroidManifest.xml only for browser process
Bijan Amirzada41242f22014-03-21 12:12:18 -070046 final String INITIALIZE_DATABASE="com.android.browser.permission.INITIALIZE_DATABASE";
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080047 final Context context = getApplicationContext();
48 if (context.checkPermission(INITIALIZE_DATABASE,
49 Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED) {
The Android Open Source Project0c908882009-03-03 19:32:16 -080050
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080051 // create CookieSyncManager with current Context
Bijan Amirzada41242f22014-03-21 12:12:18 -070052 CookieSyncManager.createInstance(this);
Bijan Amirzada9b1e9882014-02-26 17:15:46 -080053 BrowserSettings.initialize(getApplicationContext());
54 Preloader.initialize(getApplicationContext());
55 }
56 }
The Android Open Source Project0c908882009-03-03 19:32:16 -080057}
58