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.base.ResourceExtractor;
13 import org.chromium.chrome.browser.ChromiumApplication;
14 import org.chromium.chrome.browser.PKCS11AuthenticationManager;
15 import org.chromium.chrome.browser.Tab;
16 import org.chromium.chrome.browser.UmaUtils;
17 import org.chromium.chrome.browser.invalidation.UniqueIdInvalidationClientNameGenerator;
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 * V8's initial snapshot used to be statically linked to the binary, but
36 * now it's loaded from external files. Therefore we need to install such
37 * snapshots (natives_blob.bin and snapshot.bin) along with pak files.
39 private static final String[] CHROME_MANDATORY_PAKS = {
42 "chrome_100_percent.pak",
47 private static final String COMMAND_LINE_FILE = "/data/local/tmp/chrome-shell-command-line";
49 ArrayList<ChromeShellApplicationObserver> mObservers;
52 public void onCreate() {
53 // We want to do this at the earliest possible point in startup.
54 UmaUtils.recordMainEntryPointTime();
57 ResourceExtractor.setMandatoryPaksToExtract(CHROME_MANDATORY_PAKS);
58 PathUtils.setPrivateDataDirectorySuffix(PRIVATE_DATA_DIRECTORY_SUFFIX);
60 mObservers = new ArrayList<ChromeShellApplicationObserver>();
62 // Initialize the invalidations ID, just like we would in the downstream code.
63 UniqueIdInvalidationClientNameGenerator.doInitializeAndInstallGenerator(this);
67 public void sendBroadcast(Intent intent) {
68 boolean shouldFire = true;
69 for (ChromeShellApplicationObserver observer : mObservers) {
70 shouldFire &= observer.onSendBroadcast(intent);
73 if (shouldFire) super.sendBroadcast(intent);
76 public void addObserver(ChromeShellApplicationObserver observer) {
77 mObservers.add(observer);
80 public void removeObserver(ChromeShellApplicationObserver observer) {
81 mObservers.remove(observer);
85 public void initCommandLine() {
86 if (!CommandLine.isInitialized()) {
87 CommandLine.initFromFile(COMMAND_LINE_FILE);
92 protected void openProtectedContentSettings() {
96 protected void showSyncSettings() {
100 protected void showAutofillSettings() {
104 protected void showPasswordSettings() {
108 protected void showTermsOfServiceDialog() {
112 protected void openClearBrowsingData(Tab tab) {
113 Log.e(TAG, "Clear browsing data not currently supported in Chrome Shell");
117 protected boolean areParentalControlsEnabled() {
122 protected PKCS11AuthenticationManager getPKCS11AuthenticationManager() {
123 return new ChromeShellPKCS11AuthenticationManager();