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) { |
nyquist
2017/03/06 22:34:14
Should this be protected by some finch flag? Or is
iankc
2017/03/07 02:10:39
This is protected in the featureIsAvailable() meth
nyquist
2017/03/07 06:58:33
Acknowledged.
| |
18 // TODO(iankc): implement this. | 19 String url = triggeringActivity.getActivityTab().getUrl(); |
nyquist
2017/03/06 22:34:14
Can the activity tab ever be null? Say the user ta
iankc
2017/03/07 02:10:40
Yes, the activity tab can be null! However, in the
nyquist
2017/03/07 06:58:33
Acknowledged.
| |
20 | |
21 Intent intent = new Intent(this, PhysicalWebBroadcastService.class); | |
22 intent.putExtra(PhysicalWebBroadcastService.DISPLAY_URL_KEY, url); | |
23 startService(intent); | |
nyquist
2017/03/06 22:34:14
Is this guaranteed to only pinky-promise be called
iankc
2017/03/07 02:10:39
This should only be called when chrome is in the f
nyquist
2017/03/07 06:58:33
Acknowledged.
| |
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 */ | |
nyquist
2017/03/06 22:34:14
Would probably be helpful with a @return here. (re
iankc
2017/03/07 02:10:39
Done.
| |
21 public static boolean featureIsAvailable() { | 32 public static boolean featureIsAvailable() { |
22 return PhysicalWeb.sharingIsEnabled() && Build.VERSION.SDK_INT >= Build. VERSION_CODES.M; | 33 return PhysicalWeb.sharingIsEnabled() && Build.VERSION.SDK_INT >= Build. VERSION_CODES.M; |
23 } | 34 } |
24 } | 35 } |
OLD | NEW |