1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 package org.chromium.chrome.browser; 6 7 import android.view.View; 8 9 /** 10 * A empty stand-in for a native page. An inactive NativePage may be replaced with a 11 * FrozenNativePage to free up resources. 12 * 13 * Any method may be called on this object, except for getView(), which will trigger an assert and 14 * return null. 15 */ 16 public class FrozenNativePage implements NativePage { 17 private final String mUrl; 18 private final String mHost; 19 private final String mTitle; 20 private final int mBackgroundColor; 21 22 /** 23 * Creates a FrozenNativePage to replace the given NativePage and destroys the NativePage. 24 */ 25 public static FrozenNativePage freeze(NativePage nativePage) { 26 FrozenNativePage fnp = new FrozenNativePage(nativePage); 27 nativePage.destroy(); 28 return fnp; 29 } 30 31 private FrozenNativePage(NativePage nativePage) { 32 mHost = nativePage.getHost(); 33 mUrl = nativePage.getUrl(); 34 mTitle = nativePage.getTitle(); 35 mBackgroundColor = nativePage.getBackgroundColor(); 36 } 37 38 @Override 39 public View getView() { 40 assert false; 41 return null; 42 } 43 44 @Override 45 public String getTitle() { 46 return mTitle; 47 } 48 49 @Override 50 public String getUrl() { 51 return mUrl; 52 } 53 54 @Override 55 public String getHost() { 56 return mHost; 57 } 58 59 @Override 60 public int getBackgroundColor() { 61 return mBackgroundColor; 62 } 63 64 @Override 65 public void updateForUrl(String url) { 66 } 67 68 @Override 69 public void destroy() { 70 } 71 }