OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.offlinepages; | 5 package org.chromium.chrome.browser.offlinepages; |
6 | 6 |
7 import android.app.Activity; | 7 import android.app.Activity; |
8 import android.content.Context; | 8 import android.content.Context; |
9 import android.content.Intent; | 9 import android.content.Intent; |
10 import android.content.IntentFilter; | 10 import android.content.IntentFilter; |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 * @return a callback of OfflinePageItem | 353 * @return a callback of OfflinePageItem |
354 */ | 354 */ |
355 private static Callback<OfflinePageItem> selectPageForOnlineUrlCallback( | 355 private static Callback<OfflinePageItem> selectPageForOnlineUrlCallback( |
356 final WebContents webContents, final OfflinePageBridge offlinePageBr
idge, | 356 final WebContents webContents, final OfflinePageBridge offlinePageBr
idge, |
357 final Callback<OfflinePageItem> prepareForSharing) { | 357 final Callback<OfflinePageItem> prepareForSharing) { |
358 return new Callback<OfflinePageItem>() { | 358 return new Callback<OfflinePageItem>() { |
359 @Override | 359 @Override |
360 public void onResult(OfflinePageItem item) { | 360 public void onResult(OfflinePageItem item) { |
361 if (item == null) { | 361 if (item == null) { |
362 // If the page has no offline copy, save the page offline. | 362 // If the page has no offline copy, save the page offline. |
363 ClientId clientId = ClientId.createClientIdForTabSharing(); | 363 ClientId clientId = ClientId.createGuidClientIdForNamespace( |
| 364 OfflinePageBridge.SHARE_NAMESPACE); |
364 offlinePageBridge.savePage(webContents, clientId, | 365 offlinePageBridge.savePage(webContents, clientId, |
365 savePageCallback(prepareForSharing, offlinePageBridg
e)); | 366 savePageCallback(prepareForSharing, offlinePageBridg
e)); |
366 return; | 367 return; |
367 } | 368 } |
368 // If the online page has offline copy associated with it, use t
he file directly. | 369 // If the online page has offline copy associated with it, use t
he file directly. |
369 prepareForSharing.onResult(item); | 370 prepareForSharing.onResult(item); |
370 } | 371 } |
371 }; | 372 }; |
372 } | 373 } |
373 | 374 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
579 @VisibleForTesting | 580 @VisibleForTesting |
580 static void setInstanceForTesting(OfflinePageUtils instance) { | 581 static void setInstanceForTesting(OfflinePageUtils instance) { |
581 sInstance = instance; | 582 sInstance = instance; |
582 } | 583 } |
583 | 584 |
584 @VisibleForTesting | 585 @VisibleForTesting |
585 public static void setSnackbarDurationForTesting(int durationMs) { | 586 public static void setSnackbarDurationForTesting(int durationMs) { |
586 sSnackbarDurationMs = durationMs; | 587 sSnackbarDurationMs = durationMs; |
587 } | 588 } |
588 } | 589 } |
OLD | NEW |