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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/offlinepages/OfflinePageUtils.java

Issue 1755613003: [Offline pages] Making sure http:// scheme is stripped from OIB (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.content.Context; 7 import android.content.Context;
8 import android.os.Environment; 8 import android.os.Environment;
9 9
10 import org.chromium.base.Log; 10 import org.chromium.base.Log;
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (newUrl.equals(tab.getUrl()) && isConnected()) { 132 if (newUrl.equals(tab.getUrl()) && isConnected()) {
133 Log.i(TAG, "Refreshing to the online version of an offline page, sin ce we are online"); 133 Log.i(TAG, "Refreshing to the online version of an offline page, sin ce we are online");
134 LoadUrlParams params = 134 LoadUrlParams params =
135 new LoadUrlParams(tab.getOfflinePageOriginalUrl(), PageTrans ition.RELOAD); 135 new LoadUrlParams(tab.getOfflinePageOriginalUrl(), PageTrans ition.RELOAD);
136 params.setShouldReplaceCurrentEntry(true); 136 params.setShouldReplaceCurrentEntry(true);
137 tab.loadUrl(params); 137 tab.loadUrl(params);
138 } 138 }
139 } 139 }
140 140
141 /** 141 /**
142 * Strips scheme from the original URL of the offline page. This is meant to be used by UI.
143 * @param onlineUrl an online URL to from which the scheme is removed
144 * @return onlineUrl without the scheme
145 */
146 public static String stripSchemeFromOnlineUrl(String onlineUrl) {
147 // Offline pages are only saved for https:// and http:// schemes.
148 if (onlineUrl.startsWith("https://")) {
149 return onlineUrl.substring(8);
150 } else if (onlineUrl.startsWith("http://")) {
151 return onlineUrl.substring(7);
152 } else {
153 return onlineUrl;
154 }
155 }
156
157 /**
142 * Shows the snackbar for the current tab to provide offline specific inform ation if needed. 158 * Shows the snackbar for the current tab to provide offline specific inform ation if needed.
143 * @param activity The activity owning the tab. 159 * @param activity The activity owning the tab.
144 * @param tab The current tab. 160 * @param tab The current tab.
145 */ 161 */
146 public static void showOfflineSnackbarIfNecessary(ChromeActivity activity, T ab tab) { 162 public static void showOfflineSnackbarIfNecessary(ChromeActivity activity, T ab tab) {
147 showOfflineSnackbarIfNecessary(activity, tab, null); 163 showOfflineSnackbarIfNecessary(activity, tab, null);
148 } 164 }
149 165
150 /** 166 /**
151 * Shows the snackbar for the current tab to provide offline specific inform ation if needed. 167 * Shows the snackbar for the current tab to provide offline specific inform ation if needed.
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 foundTab.loadUrl(params); 244 foundTab.loadUrl(params);
229 } 245 }
230 246
231 @Override 247 @Override
232 public void onDismissNoAction(Object actionData) { 248 public void onDismissNoAction(Object actionData) {
233 RecordUserAction.record("OfflinePages.ReloadButtonNotClicked"); 249 RecordUserAction.record("OfflinePages.ReloadButtonNotClicked");
234 } 250 }
235 }; 251 };
236 } 252 }
237 } 253 }
OLDNEW
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/pageinfo/WebsiteSettingsPopup.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698