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