Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(726)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java

Issue 2081153005: [Offline Page] Offline page sharing implementation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix typo Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..87978640355a337712a2fb8037ff66a53f1625c1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java
@@ -84,6 +84,7 @@ 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.OfflinePageUtils;
import org.chromium.chrome.browser.omaha.UpdateMenuItemHelper;
import org.chromium.chrome.browser.pageinfo.WebsiteSettingsPopup;
@@ -959,26 +960,37 @@ public abstract class ChromeActivity extends AsyncInitializationActivity
final Activity mainActivity = this;
ContentBitmapCallback callback = new ContentBitmapCallback() {
- @Override
- public void onFinishGetBitmap(Bitmap bitmap, int response) {
- // Check whether this page is an offline page, and use its online URL if so.
- 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");
- } else {
- RecordUserAction.record("MobileMenuShare");
- }
+ @Override
+ public void onFinishGetBitmap(Bitmap bitmap, int response) {
+ // Check whether this page is an offline page, and use its online URL if so.
+ String url = currentTab.getOfflinePageOriginalUrl();
+ RecordHistogram.recordBooleanHistogram(
+ "OfflinePages.SharedPageWasOffline", url != null);
+ boolean offlinePageSharing =
fgorski 2016/06/28 20:03:22 rename to isOfflinePageSharingEnabled, please
Vivian 2016/07/27 23:44:10 Done.
+ (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, null, bitmap);
+ if (shareDirectly) {
+ RecordUserAction.record("MobileMenuDirectShare");
+ } else {
+ RecordUserAction.record("MobileMenuShare");
}
- };
+ } else {
+ // This is for experienmental feature Offline Page Sharing.
dewittj 2016/06/28 16:45:25 This feature is embedded enough in sharing and has
Vivian 2016/07/27 23:44:10 Acknowledged.
+ // If this page is an offline page, and the share the offline page
+ // instead of url.
+ Context mContext = getApplicationContext();
+ OfflinePageUtils.shareOfflinePage(
+ shareDirectly, mainActivity, url, bitmap, mContext, currentTab);
+ }
+ }
+ };
if (isIncognito || currentTab.getWebContents() == null) {
callback.onFinishGetBitmap(null, ReadbackResponse.SURFACE_UNAVAILABLE);
} else {

Powered by Google App Engine
This is Rietveld 408576698