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;
9 import org.chromium.base.CommandLine;
10 import org.chromium.base.PathUtils;
11 import org.chromium.chrome.browser.ChromiumApplication;
12 import org.chromium.chrome.browser.PKCS11AuthenticationManager;
13 import org.chromium.chrome.browser.UmaUtils;
14 import org.chromium.chrome.browser.invalidation.UniqueIdInvalidationClientNameGenerator;
15 import org.chromium.content.browser.ResourceExtractor;
17 import java.util.ArrayList;
20 * A basic test shell {@link android.app.Application}. Handles setting up the native library and
21 * loading the right resources.
23 public class ChromeShellApplication extends ChromiumApplication {
24 private static final String PRIVATE_DATA_DIRECTORY_SUFFIX = "chromeshell";
26 * icudtl.dat provides ICU (i18n library) with all the necessary data
27 * for its operation. We used to link the data statically to our binary,
28 * but don't do that any more and need to install along with pak files.
29 * See src/third_party/icu/README.chromium.
31 private static final String[] CHROME_MANDATORY_PAKS = {
34 "chrome_100_percent.pak",
37 private static final String COMMAND_LINE_FILE = "/data/local/tmp/chrome-shell-command-line";
39 ArrayList<ChromeShellApplicationObserver> mObservers;
42 public void onCreate() {
43 // We want to do this at the earliest possible point in startup.
44 UmaUtils.recordMainEntryPointTime();
47 ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS);
48 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
50 mObservers = new ArrayList<ChromeShellApplicationObserver>();
52 // Initialize the invalidations ID, just like we would in the downstream code.
53 UniqueIdInvalidationClientNameGenerator.doInitializeAndInstallGenerator(this);
57 public void sendBroadcast(Intent intent) {
58 boolean shouldFire = true;
59 for (ChromeShellApplicationObserver observer : mObservers) {
60 shouldFire &= observer.onSendBroadcast(intent);
63 if (shouldFire) super.sendBroadcast(intent);
66 public void addObserver(ChromeShellApplicationObserver observer) {
67 mObservers.add(observer);
70 public void removeObserver(ChromeShellApplicationObserver observer) {
71 mObservers.remove(observer);
74 public static void initCommandLine() {
75 if (!CommandLine.isInitialized()) {
76 CommandLine.initFromFile(COMMAND_LINE_FILE);
81 protected void openProtectedContentSettings() {
85 protected void showSyncSettings() {
89 protected void showTermsOfServiceDialog() {
93 protected boolean areParentalControlsEnabled() {
98 protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() {
99 return new ChromeShellPKCS11AuthenticationManager();