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 | |
| 17 | package com.android.browser; |
| 18 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 19 | import android.app.Application; |
| 20 | import android.content.Intent; |
John Reck | 84c2c09 | 2011-06-30 15:13:31 -0700 | [diff] [blame] | 21 | import android.os.AsyncTask; |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 22 | import android.util.Log; |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 23 | import android.webkit.CookieSyncManager; |
| 24 | |
| 25 | import dalvik.system.VMRuntime; |
| 26 | |
| 27 | public class Browser extends Application { |
| 28 | |
| 29 | private final static String LOGTAG = "browser"; |
| 30 | |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 31 | // Set to true to enable extra debugging. |
| 32 | final static boolean DEBUG = false; |
| 33 | |
| 34 | // Set to true to enable verbose logging. |
| 35 | final static boolean LOGV_ENABLED = DEBUG; |
| 36 | |
| 37 | // Set to true to enable extra debug logging. |
| 38 | final static boolean LOGD_ENABLED = true; |
| 39 | |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 40 | /** |
| 41 | * Specifies a heap utilization ratio that works better |
| 42 | * for the browser than the default ratio does. |
| 43 | */ |
| 44 | private final static float TARGET_HEAP_UTILIZATION = 0.75f; |
| 45 | |
| 46 | public Browser() { |
| 47 | } |
| 48 | |
John Reck | 6f48ba5 | 2010-12-03 16:03:14 -0800 | [diff] [blame] | 49 | @Override |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 50 | public void onCreate() { |
Kristian Monsen | e800e8e | 2010-12-06 16:59:33 +0000 | [diff] [blame] | 51 | super.onCreate(); |
| 52 | |
Dave Bort | 31a6d1c | 2009-04-13 15:56:49 -0700 | [diff] [blame] | 53 | if (LOGV_ENABLED) |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 54 | Log.v(LOGTAG, "Browser.onCreate: this=" + this); |
Kristian Monsen | e800e8e | 2010-12-06 16:59:33 +0000 | [diff] [blame] | 55 | |
John Reck | 84c2c09 | 2011-06-30 15:13:31 -0700 | [diff] [blame] | 56 | // Fix AsyncTask to use multiple threads |
| 57 | AsyncTask.setDefaultExecutor(AsyncTask.THREAD_POOL_EXECUTOR); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 58 | // Fix heap utilization for better heap size characteristics. |
| 59 | VMRuntime.getRuntime().setTargetHeapUtilization( |
| 60 | TARGET_HEAP_UTILIZATION); |
| 61 | // create CookieSyncManager with current Context |
| 62 | CookieSyncManager.createInstance(this); |
John Reck | 35e9dd6 | 2011-04-25 09:01:54 -0700 | [diff] [blame] | 63 | BrowserSettings.initialize(getApplicationContext()); |
Michael Kolb | 1461244 | 2011-06-24 13:06:29 -0700 | [diff] [blame] | 64 | Preloader.initialize(getApplicationContext()); |
The Android Open Source Project | 0c90888 | 2009-03-03 19:32:16 -0800 | [diff] [blame] | 65 | } |
| 66 | |
| 67 | static Intent createBrowserViewIntent() { |
| 68 | Intent intent = new Intent(Intent.ACTION_WEB_SEARCH); |
| 69 | return intent; |
| 70 | } |
| 71 | } |
| 72 | |