Index: chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java |
index 5fe13a3583fad9cb49531491e2635c90823778b5..f4e45fcb7ebcd88347e76701cb119fb52a3c5ae7 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/physicalweb/PhysicalWebShareActivity.java |
@@ -6,39 +6,29 @@ package org.chromium.chrome.browser.physicalweb; |
import android.content.Intent; |
import android.os.Build; |
-import android.os.Bundle; |
-import android.support.v7.app.AppCompatActivity; |
-import org.chromium.chrome.browser.share.ShareHelper; |
-import org.chromium.chrome.browser.tab.Tab; |
-import org.chromium.chrome.browser.util.IntentUtils; |
+import org.chromium.chrome.browser.ChromeActivity; |
+import org.chromium.chrome.browser.share.ShareActivity; |
/** |
* A simple activity that allows Chrome to start the physical web sharing service. |
*/ |
-public class PhysicalWebShareActivity extends AppCompatActivity { |
- private static final String TAG = "PhysicalWebShareActivity"; |
- |
+public class PhysicalWebShareActivity extends ShareActivity { |
@Override |
- protected void onCreate(Bundle savedInstanceState) { |
- super.onCreate(savedInstanceState); |
- |
- try { |
- Intent intent = getIntent(); |
- if (intent == null) return; |
- if (!Intent.ACTION_SEND.equals(intent.getAction())) return; |
- if (!IntentUtils.safeHasExtra(getIntent(), ShareHelper.EXTRA_TASK_ID)) return; |
- handleShareAction(); |
- } finally { |
- finish(); |
- } |
- } |
+ protected void handleShareAction(ChromeActivity triggeringActivity) { |
+ String url = triggeringActivity.getActivityTab().getUrl(); |
- private void handleShareAction() { |
- // TODO(iankc): implement sharing |
+ Intent intent = new Intent(this, PhysicalWebBroadcastService.class); |
+ intent.putExtra(PhysicalWebBroadcastService.DISPLAY_URL_KEY, url); |
+ startService(intent); |
} |
- public static boolean sharingIsEnabled(Tab currentTab) { |
+ /** |
+ * Pre-conditions for Physical Web Sharing to be enabled: |
cco3
2017/03/02 23:46:07
It be good to have a summary line before this:
"Re
iankc
2017/03/02 23:51:05
Done.
|
+ * Device is Marshmallow or above. |
+ * Device has sharing feature enabled. |
+ */ |
+ public static boolean featureIsAvailable() { |
return PhysicalWeb.sharingIsEnabled() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M; |
} |
} |