Commit a350792a authored by jianli's avatar jianli Committed by Commit bot

Check if WebContents is null in OfflinePageUtils.isOfflinePage

WebContents might not be loaded in some case, i.e. tab switcher.
We need to check for that.

BUG=715751

Review-Url: https://codereview.chromium.org/2847863003
Cr-Commit-Position: refs/heads/master@{#467925}
parent 10751e18
...@@ -569,9 +569,11 @@ public class OfflinePageUtils { ...@@ -569,9 +569,11 @@ public class OfflinePageUtils {
* @return True if the offline page is opened. * @return True if the offline page is opened.
*/ */
public static boolean isOfflinePage(Tab tab) { public static boolean isOfflinePage(Tab tab) {
WebContents webContents = tab.getWebContents();
if (webContents == null) return false;
OfflinePageBridge offlinePageBridge = getInstance().getOfflinePageBridge(tab.getProfile()); OfflinePageBridge offlinePageBridge = getInstance().getOfflinePageBridge(tab.getProfile());
if (offlinePageBridge == null) return false; if (offlinePageBridge == null) return false;
return offlinePageBridge.isOfflinePage(tab.getWebContents()); return offlinePageBridge.isOfflinePage(webContents);
} }
/** /**
...@@ -580,9 +582,11 @@ public class OfflinePageUtils { ...@@ -580,9 +582,11 @@ public class OfflinePageUtils {
* @return The offline page if tab currently displays it, null otherwise. * @return The offline page if tab currently displays it, null otherwise.
*/ */
public static OfflinePageItem getOfflinePage(Tab tab) { public static OfflinePageItem getOfflinePage(Tab tab) {
WebContents webContents = tab.getWebContents();
if (webContents == null) return null;
OfflinePageBridge offlinePageBridge = getInstance().getOfflinePageBridge(tab.getProfile()); OfflinePageBridge offlinePageBridge = getInstance().getOfflinePageBridge(tab.getProfile());
if (offlinePageBridge == null) return null; if (offlinePageBridge == null) return null;
return offlinePageBridge.getOfflinePage(tab.getWebContents()); return offlinePageBridge.getOfflinePage(webContents);
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment