| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser.physicalweb; | 5 package org.chromium.chrome.browser.physicalweb; |
| 6 | 6 |
| 7 import android.content.Intent; |
| 7 import android.os.Build; | 8 import android.os.Build; |
| 8 | 9 |
| 9 import org.chromium.chrome.browser.ChromeActivity; | 10 import org.chromium.chrome.browser.ChromeActivity; |
| 10 import org.chromium.chrome.browser.share.ShareActivity; | 11 import org.chromium.chrome.browser.share.ShareActivity; |
| 11 | 12 |
| 12 /** | 13 /** |
| 13 * A simple activity that allows Chrome to start the physical web sharing servic
e. | 14 * A simple activity that allows Chrome to start the physical web sharing servic
e. |
| 14 */ | 15 */ |
| 15 public class PhysicalWebShareActivity extends ShareActivity { | 16 public class PhysicalWebShareActivity extends ShareActivity { |
| 16 @Override | 17 @Override |
| 17 protected void handleShareAction(ChromeActivity triggeringActivity) { | 18 protected void handleShareAction(ChromeActivity triggeringActivity) { |
| 18 // TODO(iankc): implement this. | 19 String url = triggeringActivity.getActivityTab().getUrl(); |
| 20 |
| 21 Intent intent = new Intent(this, PhysicalWebBroadcastService.class); |
| 22 intent.putExtra(PhysicalWebBroadcastService.DISPLAY_URL_KEY, url); |
| 23 startService(intent); |
| 19 } | 24 } |
| 20 | 25 |
| 26 /** |
| 27 * Returns whether we should show this sharing option in the share sheet. |
| 28 * Pre-conditions for Physical Web Sharing to be enabled: |
| 29 * Device is Marshmallow or above. |
| 30 * Device has sharing feature enabled. |
| 31 * @return {@code true} if the feature should be enabled. |
| 32 */ |
| 21 public static boolean featureIsAvailable() { | 33 public static boolean featureIsAvailable() { |
| 22 return PhysicalWeb.sharingIsEnabled() && Build.VERSION.SDK_INT >= Build.
VERSION_CODES.M; | 34 return PhysicalWeb.sharingIsEnabled() && Build.VERSION.SDK_INT >= Build.
VERSION_CODES.M; |
| 23 } | 35 } |
| 24 } | 36 } |
| OLD | NEW |