OLD | NEW |
| (Empty) |
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.mandoline; | |
6 | |
7 import android.app.Activity; | |
8 import android.content.Intent; | |
9 import android.net.Uri; | |
10 import android.os.Bundle; | |
11 | |
12 import org.chromium.base.Log; | |
13 import org.chromium.base.annotations.JNINamespace; | |
14 import org.chromium.mojo.shell.ShellMain; | |
15 | |
16 /** | |
17 * Activity hosting the Mojo View Manager for Mandoline. | |
18 */ | |
19 @JNINamespace("mandoline") | |
20 public class MandolineActivity extends Activity { | |
21 private static final String TAG = "cr.MandolineActivity"; | |
22 private static final String EXTRAS = "org.chromium.mandoline.extras"; | |
23 | |
24 @Override | |
25 protected void onCreate(final Bundle savedInstanceState) { | |
26 super.onCreate(savedInstanceState); | |
27 | |
28 String[] parameters = getIntent().getStringArrayExtra(EXTRAS); | |
29 if (parameters != null) { | |
30 for (String s : parameters) { | |
31 s = s.replace("\\,", ","); | |
32 } | |
33 } | |
34 if (Intent.ACTION_VIEW.equals(getIntent().getAction())) { | |
35 Uri uri = getIntent().getData(); | |
36 if (uri != null) { | |
37 Log.i(TAG, "MandolineActivity opening " + uri); | |
38 if (parameters == null) { | |
39 parameters = new String[] {uri.toString()}; | |
40 } else { | |
41 String[] newParameters = new String[parameters.length + 1]; | |
42 System.arraycopy(parameters, 0, newParameters, 0, parameters
.length); | |
43 newParameters[parameters.length] = uri.toString(); | |
44 parameters = newParameters; | |
45 } | |
46 } | |
47 } | |
48 | |
49 ShellMain.ensureInitialized(this, parameters); | |
50 ShellMain.start(); | |
51 } | |
52 | |
53 @Override | |
54 protected void onNewIntent(Intent intent) { | |
55 super.onNewIntent(intent); | |
56 | |
57 if (Intent.ACTION_VIEW.equals(intent.getAction())) { | |
58 Uri uri = intent.getData(); | |
59 if (uri != null) { | |
60 Log.i(TAG, "MandolineActivity launching new intent for uri: " +
uri); | |
61 nativeLaunchURL(uri.toString()); | |
62 } | |
63 } | |
64 } | |
65 | |
66 private static native void nativeLaunchURL(String url); | |
67 } | |
OLD | NEW |