Upstream version 10.38.222.0
[platform/framework/web/crosswalk.git] / src / content / public / android / java / src / org / chromium / content / browser / NavigationEntry.java
1 // Copyright 2012 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.content.browser;
6
7 import android.graphics.Bitmap;
8
9 /**
10  * Represents one entry in the navigation history of a page.
11  */
12 public class NavigationEntry {
13
14     private final int mIndex;
15     private final String mUrl;
16     private final String mOriginalUrl;
17     private final String mVirtualUrl;
18     private final String mTitle;
19     private Bitmap mFavicon;
20
21     /**
22      * Default constructor.
23      */
24     protected NavigationEntry(int index, String url, String virtualUrl, String originalUrl,
25             String title, Bitmap favicon) {
26         mIndex = index;
27         mUrl = url;
28         mVirtualUrl = virtualUrl;
29         mOriginalUrl = originalUrl;
30         mTitle = title;
31         mFavicon = favicon;
32     }
33
34     /**
35      * @return The index into the navigation history that this entry represents.
36      */
37     public int getIndex() {
38         return mIndex;
39     }
40
41     /**
42      * @return The actual URL of the page. For some about pages, this may be a
43      *         scary data: URL or something like that. Use GetVirtualURL() for
44      *         showing to the user.
45      */
46     public String getUrl() {
47         return mUrl;
48     }
49
50     /**
51      * @return The virtual URL, when nonempty, will override the actual URL of
52      *         the page when we display it to the user. This allows us to have
53      *         nice and friendly URLs that the user sees for things like about:
54      *         URLs, but actually feed the renderer a data URL that results in
55      *         the content loading.
56      *         <p/>
57      *         GetVirtualURL() will return the URL to display to the user in all
58      *         cases, so if there is no overridden display URL, it will return
59      *         the actual one.
60      */
61     public String getVirtualUrl() {
62         return mVirtualUrl;
63     }
64
65     /**
66      * @return The URL that caused this NavigationEntry to be created.
67      */
68     public String getOriginalUrl() {
69         return mOriginalUrl;
70     }
71
72     /**
73      * @return The title as set by the page. This will be empty if there is no
74      *         title set. The caller is responsible for detecting when there is
75      *         no title and displaying the appropriate "Untitled" label if this
76      *         is being displayed to the user.
77      */
78     public String getTitle() {
79         return mTitle;
80     }
81
82     /**
83      * @return The favicon of the page. This may be null.
84      */
85     public Bitmap getFavicon() {
86         return mFavicon;
87     }
88
89     /**
90      * @param favicon The updated favicon to replace the existing one with.
91      */
92     public void updateFavicon(Bitmap favicon) {
93         mFavicon = favicon;
94     }
95 }