1 // Copyright 2015 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. 4 5 package org.chromium.webview_shell; 6 7 import android.app.Activity; 8 import android.content.Intent; 9 import android.os.Bundle; 10 import android.webkit.CookieManager; 11 import android.webkit.WebView; 12 import android.webkit.WebViewClient; 13 14 /** 15 * This activity is designed for sending memory pressure signals for testing WebView. 16 */ 17 public class TelemetryMemoryPressureActivity extends Activity { 18 19 private static final String TAG = "WebViewTelemetry"; 20 21 @Override onCreate(Bundle savedInstanceState)22 public void onCreate(Bundle savedInstanceState) { 23 super.onCreate(savedInstanceState); 24 getWindow().setTitle( 25 getResources().getString(R.string.title_activity_telemetry)); 26 setContentView(R.layout.activity_webview); 27 28 WebView webview = (WebView) findViewById(R.id.webview); 29 CookieManager.setAcceptFileSchemeCookies(true); 30 webview.getSettings().setJavaScriptEnabled(true); 31 32 webview.setWebViewClient(new WebViewClient() { 33 @SuppressWarnings("deprecation") // because we support api level 19 and up. 34 @Override 35 public boolean shouldOverrideUrlLoading(WebView webView, String url) { 36 return false; 37 } 38 }); 39 40 webview.loadUrl("about:blank"); 41 } 42 43 @Override onNewIntent(Intent intent)44 protected void onNewIntent(Intent intent) { 45 moveTaskToBack(true); 46 } 47 } 48