Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Unified Diff: web_apks/minting_example/src/org/chromium/minting/MainActivity.java

Issue 1888773004: 🙅 Bind a WebAPK to its "host" browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: web_apks/minting_example/src/org/chromium/minting/MainActivity.java
diff --git a/web_apks/minting_example/src/org/chromium/minting/MainActivity.java b/web_apks/minting_example/src/org/chromium/minting/MainActivity.java
index 3786495547ae2d020765298738b94bc22e3faba9..d087fdd82da58f6aa40cedfb7cc3028a30f48dbc 100644
--- a/web_apks/minting_example/src/org/chromium/minting/MainActivity.java
+++ b/web_apks/minting_example/src/org/chromium/minting/MainActivity.java
@@ -20,13 +20,14 @@ import android.view.View;
import android.view.View.OnClickListener;
import org.chromium.minting.lib.common.WebAPKConstants;
+import org.chromium.minting.lib.common.WebAPKUtils;
import java.io.ByteArrayOutputStream;
/**
* Example client activity for a minted APK.
*/
-public class MainActivity extends Activity implements OnClickListener {
+public class MainActivity extends Activity {
private static final String EXTRA_ID = "org.chromium.chrome.browser.webapp_id";
private static final String EXTRA_ICON = "org.chromium.chrome.browser.webapp_icon";
private static final String EXTRA_NAME = "org.chromium.chrome.browser.webapp_name";
@@ -35,7 +36,6 @@ public class MainActivity extends Activity implements OnClickListener {
private static final String EXTRA_MAC = "org.chromium.chrome.browser.webapp_mac";
private static final String EXTRA_SCOPE = "org.chromium.chrome.browser.webapp_scope";
private static final String EXTRA_MINTING_PACKAGE_NAME = "EXTRA_MINTING_PACKAGE_NAME";
- private static final String EXTRA_CALLER_PACKAGE_NAME = "EXTRA_CALLER_PACKAGE_NAME";
private static final String META_DATA_HOST_URL = "hostUrl";
private static final String META_DATA_MAC = "mac";
private static final String META_DATA_SCOPE = "scope";
@@ -82,22 +82,8 @@ public class MainActivity extends Activity implements OnClickListener {
e.printStackTrace();
}
- SharedPreferences prefs =
- getSharedPreferences(MintingApplication.MINT_PREFS, MODE_PRIVATE);
- String chromePackageFromPref = prefs.getString(MintingApplication.HOST_PACKAGE_PREF,
- MintingApplication.DEFAULT_CHROME_PACKAGE_NAME);
- String callerPackageName = intent.getStringExtra(EXTRA_CALLER_PACKAGE_NAME);
- // Update value if needed
- if (callerPackageName != null && !callerPackageName.equals(chromePackageFromPref)) {
- prefs.edit().putString(MintingApplication.HOST_PACKAGE_PREF, callerPackageName)
- .apply();
- Log.d(TAG, "Chrome with package " + callerPackageName + " is new host");
- }
- String chromePackageName = callerPackageName == null ? chromePackageFromPref :
- callerPackageName;
-
Intent newIntent = new Intent();
- newIntent.setComponent(new ComponentName(chromePackageName,
+ newIntent.setComponent(new ComponentName(WebAPKUtils.getHostBrowserPackageName(this),
"org.chromium.chrome.browser.webapps.WebappLauncherActivity"));
newIntent.putExtra(EXTRA_ID, webappId);
newIntent.putExtra(EXTRA_NAME, name);
@@ -111,10 +97,6 @@ public class MainActivity extends Activity implements OnClickListener {
finish();
}
- @Override
- public void onClick(View v) {
-
- }
/**
* Compresses a bitmap into a PNG and converts into a Base64 encoded string.

Powered by Google App Engine
This is Rietveld 408576698