Commit b5c9bcd8 authored by cco3's avatar cco3 Committed by Commit bot

Send users to Physical WebUI instead of Activity

We have written a Physical Web WebUI that we intend to be the de facto
view for browsing Physical Web URLs.  This change makes sure the user
goes there when they try to display URLs from:
* the diagnostics page and
* the settings fragment.

BUG=663842

Review-Url: https://codereview.chromium.org/2601273003
Cr-Commit-Position: refs/heads/master@{#443393}
parent aecd7af6
...@@ -41,6 +41,7 @@ public class UrlConstants { ...@@ -41,6 +41,7 @@ public class UrlConstants {
public static final String INTERESTS_HOST = "interests"; public static final String INTERESTS_HOST = "interests";
public static final String PHYSICAL_WEB_DIAGNOSTICS_HOST = "physical-web-diagnostics"; public static final String PHYSICAL_WEB_DIAGNOSTICS_HOST = "physical-web-diagnostics";
public static final String PHYSICAL_WEB_URL = "chrome://physical-web/";
public static final String ABOUT_BLANK = "about:blank"; public static final String ABOUT_BLANK = "about:blank";
......
...@@ -4,11 +4,14 @@ ...@@ -4,11 +4,14 @@
package org.chromium.chrome.browser.physicalweb; package org.chromium.chrome.browser.physicalweb;
import android.content.Intent;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Build; import android.os.Build;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
import org.chromium.chrome.browser.ChromeFeatureList; import org.chromium.chrome.browser.ChromeFeatureList;
import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager; import org.chromium.chrome.browser.preferences.privacy.PrivacyPreferencesManager;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.search_engines.TemplateUrlService; import org.chromium.chrome.browser.search_engines.TemplateUrlService;
...@@ -146,4 +149,13 @@ public class PhysicalWeb { ...@@ -146,4 +149,13 @@ public class PhysicalWeb {
&& TemplateUrlService.getInstance().isDefaultSearchEngineGoogle() && TemplateUrlService.getInstance().isDefaultSearchEngineGoogle()
&& !Profile.getLastUsedProfile().isOffTheRecord(); && !Profile.getLastUsedProfile().isOffTheRecord();
} }
/**
* Creates an Intent that sends the user to the list of Physical Web URLs.
*/
public static Intent createListUrlsIntent() {
return new Intent(Intent.ACTION_VIEW)
.addCategory(Intent.CATEGORY_BROWSABLE)
.setData(Uri.parse(UrlConstants.PHYSICAL_WEB_URL));
}
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package org.chromium.chrome.browser.physicalweb; package org.chromium.chrome.browser.physicalweb;
import android.app.Activity; import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; import android.os.Build;
import android.text.Html; import android.text.Html;
...@@ -16,9 +15,9 @@ import android.widget.Button; ...@@ -16,9 +15,9 @@ import android.widget.Button;
import android.widget.TextView; import android.widget.TextView;
import org.chromium.base.ApiCompatibilityUtils; import org.chromium.base.ApiCompatibilityUtils;
import org.chromium.base.ContextUtils;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.BasicNativePage; import org.chromium.chrome.browser.BasicNativePage;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.UrlConstants; import org.chromium.chrome.browser.UrlConstants;
import org.chromium.chrome.browser.tab.Tab; import org.chromium.chrome.browser.tab.Tab;
import org.chromium.components.location.LocationUtils; import org.chromium.components.location.LocationUtils;
...@@ -64,7 +63,9 @@ public class PhysicalWebDiagnosticsPage extends BasicNativePage { ...@@ -64,7 +63,9 @@ public class PhysicalWebDiagnosticsPage extends BasicNativePage {
mLaunchButton.setOnClickListener(new View.OnClickListener() { mLaunchButton.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
activity.startActivity(createListUrlsIntent()); PhysicalWebUma.onActivityReferral(ListUrlsActivity.DIAGNOSTICS_REFERER);
IntentHandler.startChromeLauncherActivityForTrustedIntent(
PhysicalWeb.createListUrlsIntent());
} }
}); });
...@@ -218,11 +219,6 @@ public class PhysicalWebDiagnosticsPage extends BasicNativePage { ...@@ -218,11 +219,6 @@ public class PhysicalWebDiagnosticsPage extends BasicNativePage {
return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT); return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT);
} }
private static Intent createListUrlsIntent() {
return new Intent(ContextUtils.getApplicationContext(), ListUrlsActivity.class)
.putExtra(ListUrlsActivity.REFERER_KEY, ListUrlsActivity.DIAGNOSTICS_REFERER);
}
private static String colorToHexValue(int color) { private static String colorToHexValue(int color) {
return "#" + Integer.toHexString(color & 0x00ffffff); return "#" + Integer.toHexString(color & 0x00ffffff);
} }
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
package org.chromium.chrome.browser.preferences.privacy; package org.chromium.chrome.browser.preferences.privacy;
import android.Manifest; import android.Manifest;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
...@@ -17,6 +15,7 @@ import android.preference.PreferenceFragment; ...@@ -17,6 +15,7 @@ import android.preference.PreferenceFragment;
import org.chromium.base.Log; import org.chromium.base.Log;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.IntentHandler;
import org.chromium.chrome.browser.physicalweb.ListUrlsActivity; import org.chromium.chrome.browser.physicalweb.ListUrlsActivity;
import org.chromium.chrome.browser.physicalweb.PhysicalWeb; import org.chromium.chrome.browser.physicalweb.PhysicalWeb;
import org.chromium.chrome.browser.physicalweb.PhysicalWebUma; import org.chromium.chrome.browser.physicalweb.PhysicalWebUma;
...@@ -104,15 +103,11 @@ public class PhysicalWebPreferenceFragment extends PreferenceFragment { ...@@ -104,15 +103,11 @@ public class PhysicalWebPreferenceFragment extends PreferenceFragment {
physicalWebLaunch.setOnPreferenceClickListener(new OnPreferenceClickListener() { physicalWebLaunch.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override @Override
public boolean onPreferenceClick(Preference preference) { public boolean onPreferenceClick(Preference preference) {
startActivity(createListUrlsIntent(getActivity())); PhysicalWebUma.onActivityReferral(ListUrlsActivity.PREFERENCE_REFERER);
IntentHandler.startChromeLauncherActivityForTrustedIntent(
PhysicalWeb.createListUrlsIntent());
return true; return true;
} }
}); });
} }
private static Intent createListUrlsIntent(Context context) {
Intent intent = new Intent(context, ListUrlsActivity.class);
intent.putExtra(ListUrlsActivity.REFERER_KEY, ListUrlsActivity.PREFERENCE_REFERER);
return intent;
}
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment