1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 package org.chromium.chrome.shell;
7 import android.content.Intent;
8 import android.util.Log;
10 import org.chromium.base.CommandLine;
11 import org.chromium.base.PathUtils;
12 import org.chromium.chrome.browser.ChromiumApplication;
13 import org.chromium.chrome.browser.PKCS11AuthenticationManager;
14 import org.chromium.chrome.browser.Tab;
15 import org.chromium.chrome.browser.UmaUtils;
16 import org.chromium.chrome.browser.invalidation.UniqueIdInvalidationClientNameGenerator;
17 import org.chromium.content.browser.ResourceExtractor;
19 import java.util.ArrayList;
22 * A basic test shell {@link android.app.Application}. Handles setting up the native library and
23 * loading the right resources.
25 public class ChromeShellApplication extends ChromiumApplication {
26 private static final String TAG = "ChromeShellApplication";
28 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "chromeshell";
30 * icudtl.dat provides ICU (i18n library) with all the necessary data
31 * for its operation. We used to link the data statically to our binary,
32 * but don't do that any more and need to install along with pak files.
33 * See src/third_party/icu/README.chromium.
35 private static final String[] CHROME_MANDATORY_PAKS = {
38 "chrome_100_percent.pak",
41 private static final String COMMAND_LINE_FILE = "/data/local/tmp/chrome-shell-command-line";
43 ArrayList<ChromeShellApplicationObserver> mObservers;
46 public void onCreate() {
47 // We want to do this at the earliest possible point in startup.
48 UmaUtils.recordMainEntryPointTime();
51 ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS);
52 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
54 mObservers = new ArrayList<ChromeShellApplicationObserver>();
56 // Initialize the invalidations ID, just like we would in the downstream code.
57 UniqueIdInvalidationClientNameGenerator.doInitializeAndInstallGenerator(this);
61 public void sendBroadcast(Intent intent) {
62 boolean shouldFire = true;
63 for (ChromeShellApplicationObserver observer : mObservers) {
64 shouldFire &= observer.onSendBroadcast(intent);
67 if (shouldFire) super.sendBroadcast(intent);
70 public void addObserver(ChromeShellApplicationObserver observer) {
71 mObservers.add(observer);
74 public void removeObserver(ChromeShellApplicationObserver observer) {
75 mObservers.remove(observer);
78 public static void initCommandLine() {
79 if (!CommandLine.isInitialized()) {
80 CommandLine.initFromFile(COMMAND_LINE_FILE);
85 protected void openProtectedContentSettings() {
89 protected void showSyncSettings() {
93 protected void showTermsOfServiceDialog() {
97 protected void openClearBrowsingData(Tab tab) {
98 Log.e(TAG, "Clear browsing data not currently supported in Chrome Shell");
102 protected boolean areParentalControlsEnabled() {
107 protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() {
108 return new ChromeShellPKCS11AuthenticationManager();