| 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
|
| + // 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
|
| + // If this page is an offline page, and the share the offline page
|
| + // instead of url
|
| + String offlineUrl = currentTab.getUrl();
|
| + OfflinePageBridge offlinePageBridge =
|
| + OfflinePageBridge.getForProfile(currentTab.getProfile());
|
| +
|
| + offlinePageBridge.getPageByOfflineUrl(
|
| + 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);
|
| + }
|
| + }
|
| + });
|
| }
|
| }
|
| };
|
|
|