1/*
2 * Copyright (C) 2014 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
17package com.android.webview.chromium.shell;
18
19import android.app.Activity;
20import android.content.Intent;
21import android.os.Bundle;
22import android.webkit.CookieManager;
23import android.webkit.WebView;
24import android.webkit.WebViewClient;
25
26/**
27 * This activity is designed for Android Jank testing of WebView. It takes a URL as an argument, and
28 * displays the page ready for the Jank tester to test scrolling etc.
29 */
30public class JankActivity extends Activity {
31
32    @Override
33    public void onCreate(Bundle savedInstanceState) {
34        super.onCreate(savedInstanceState);
35        getWindow().setTitle(
36                getResources().getString(R.string.title_activity_jank));
37        setContentView(R.layout.activity_telemetry);
38
39        WebView webView = (WebView) findViewById(R.id.webview);
40        CookieManager.setAcceptFileSchemeCookies(true);
41
42        webView.setWebViewClient(new WebViewClient() {
43            @Override
44            public boolean shouldOverrideUrlLoading(WebView webView, String url) {
45                return false;
46            }
47        });
48
49        String url = getUrlFromIntent(getIntent());
50        webView.loadUrl(url);
51    }
52
53    private static String getUrlFromIntent(Intent intent) {
54        return intent != null ? intent.getDataString() : null;
55    }
56
57}
58