Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java |
| index 536f4666a720e64511efbce5286b0d4527fa0cce..3c73bf65a2b14680a1b04e70cdd46ef6e0acbd8e 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java |
| @@ -41,6 +41,7 @@ import org.chromium.base.ActivityState; |
| import org.chromium.base.ApiCompatibilityUtils; |
| import org.chromium.base.ApplicationStatus; |
| import org.chromium.base.BaseSwitches; |
| +import org.chromium.base.Callback; |
| import org.chromium.base.CommandLine; |
| import org.chromium.base.SysUtils; |
| import org.chromium.base.TraceEvent; |
| @@ -84,6 +85,8 @@ import org.chromium.chrome.browser.metrics.UmaUtils; |
| import org.chromium.chrome.browser.multiwindow.MultiWindowUtils; |
| import org.chromium.chrome.browser.nfc.BeamController; |
| import org.chromium.chrome.browser.nfc.BeamProvider; |
| +import org.chromium.chrome.browser.offlinepages.OfflinePageBridge; |
| +import org.chromium.chrome.browser.offlinepages.OfflinePageItem; |
| import org.chromium.chrome.browser.offlinepages.OfflinePageUtils; |
| import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper; |
| import org.chromium.chrome.browser.pageinfo.WebsiteSettingsPopup; |
| @@ -965,17 +968,43 @@ public abstract class ChromeActivity extends AsyncInitializationActivity |
| String url = currentTab.getOfflinePageOriginalUrl(); |
| RecordHistogram.recordBooleanHistogram( |
| "OfflinePages.SharedPageWasOffline", url != null); |
| - |
| - // If there is no entry in the offline pages DB for this tab, use the tab's |
| - // URL directly. |
| - if (url == null) url = currentTab.getUrl(); |
| - |
| - ShareHelper.share( |
| - shareDirectly, mainActivity, currentTab.getTitle(), url, bitmap); |
| - if (shareDirectly) { |
| - RecordUserAction.record("MobileMenuDirectShare"); |
| + boolean offlinePageSharing = |
| + (url != null && OfflinePageBridge.isPageSharingEnabled()); |
| + |
| + if (!offlinePageSharing) { |
| + // If there is no entry in the offline pages DB for this tab, use the |
| + // tab's |
|
fgorski
2016/06/23 17:41:10
nit: please remove NL from the end.
Vivian
2016/06/27 16:56:08
Done.
|
| + // URL directly. |
| + if (url == null) url = currentTab.getUrl(); |
| + |
| + ShareHelper.share(shareDirectly, mainActivity, currentTab.getTitle(), |
| + url, bitmap); |
| + if (shareDirectly) { |
| + RecordUserAction.record("MobileMenuDirectShare"); |
| + } else { |
| + RecordUserAction.record("MobileMenuShare"); |
| + } |
| } else { |
| - RecordUserAction.record("MobileMenuShare"); |
| + // This is for experienmental feature Offline Page Sharing |
|
fgorski
2016/06/23 17:41:11
nit: End sentences with a period, please.
Vivian
2016/06/27 16:56:08
Done.
|
| + // If this page is an offline page, and the share the offline page |
| + // instead of url |
|
fgorski
2016/06/23 17:41:11
ditto Re: period.
Vivian
2016/06/27 16:56:08
Done.
|
| + String offlineUrl = currentTab.getUrl(); |
|
fgorski
2016/06/23 17:41:11
how do you know the URL is offline here?
Vivian
2016/06/27 16:56:08
It is checked in this line:
boolean offlinePageSh
|
| + OfflinePageBridge offlinePageBridge = |
| + OfflinePageBridge.getForProfile(currentTab.getProfile()); |
| + |
| + offlinePageBridge.getPageByOfflineUrl( |
|
fgorski
2016/06/23 17:41:10
Perhaps this whole code could be moved outside of
Vivian
2016/06/27 16:56:08
Done. This part is moved to OfflinePageUtils.
|
| + offlineUrl, new Callback<OfflinePageItem>() { |
| + @Override |
| + public void onResult(OfflinePageItem item) { |
| + if (item != null) { |
| + String offlineFilePath = item.getFilePath(); |
| + Context mContext = getApplicationContext(); |
| + ShareHelper.shareOfflinePage(shareDirectly, |
| + mainActivity, currentTab.getTitle(), |
| + offlineFilePath, mContext); |
| + } |
| + } |
| + }); |
| } |
| } |
| }; |