The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 1 | /* |
| 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 Amirzada | 41242f2 | 2014-03-21 12:12:18 -0700 | [diff] [blame] | 17 | package com.android.browser; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 18 | |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame^] | 19 | import android.Manifest; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 20 | import android.app.Application; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 21 | import android.content.Context; |
| 22 | import android.content.pm.PackageManager; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 23 | import android.os.Process; |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame^] | 24 | import android.util.Log; |
Tarun Nainani | ea28dde | 2014-08-27 17:25:09 -0700 | [diff] [blame] | 25 | |
Vivek Sekhar | 0989b45 | 2014-08-01 12:30:35 -0700 | [diff] [blame] | 26 | import org.codeaurora.swe.Engine; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 27 | |
| 28 | public class Browser extends Application { |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 29 | |
| 30 | private final static String LOGTAG = "browser"; |
Bijan Amirzada | 9b1e988 | 2014-02-26 17:15:46 -0800 | [diff] [blame] | 31 | |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 32 | // Set to true to enable verbose logging. |
John Reck | 6c2e2f3 | 2011-08-22 13:41:23 -0700 | [diff] [blame] | 33 | final static boolean LOGV_ENABLED = false; |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 34 | |
| 35 | // Set to true to enable extra debug logging. |
| 36 | final static boolean LOGD_ENABLED = true; |
| 37 | |
John Reck | 6f48ba5 | 2010-12-03 16:03:14 -0800 | [diff] [blame] | 38 | @Override |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 39 | public void onCreate() { |
Kristian Monsen | e800e8e | 2010-12-06 16:59:33 +0000 | [diff] [blame] | 40 | super.onCreate(); |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame^] | 41 | |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 42 | if (LOGV_ENABLED) |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 43 | Log.v(LOGTAG, "Browser.onCreate: this=" + this); |
Kristian Monsen | e800e8e | 2010-12-06 16:59:33 +0000 | [diff] [blame] | 44 | |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame^] | 45 | // Chromium specific initialization. |
Tarun Nainani | 8eb0091 | 2014-07-17 12:28:32 -0700 | [diff] [blame] | 46 | Engine.initializeApplicationParameters(); |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame^] | 47 | |
| 48 | final boolean isSandboxContext = checkPermission(Manifest.permission.INTERNET, |
| 49 | Process.myPid(), Process.myUid()) != PackageManager.PERMISSION_GRANTED; |
| 50 | |
| 51 | if (isSandboxContext) { |
| 52 | // SWE: Avoid initializing the engine for sandboxed processes. |
| 53 | } else { |
Vivek Sekhar | 0989b45 | 2014-08-01 12:30:35 -0700 | [diff] [blame] | 54 | // Initialize the SWE engine. |
Enrico Ros | 1c4d6b8 | 2014-10-14 16:23:17 -0700 | [diff] [blame^] | 55 | Engine.initialize((Context) this); |
| 56 | BrowserSettings.initialize((Context) this); |
| 57 | Preloader.initialize((Context) this); |
| 58 | } |
Tarun Nainani | ea28dde | 2014-08-27 17:25:09 -0700 | [diff] [blame] | 59 | |
| 60 | } |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 61 | } |
| 62 | |