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.
5 #ifndef IOS_WEB_PUBLIC_NAVIGATION_ITEM_H_
6 #define IOS_WEB_PUBLIC_NAVIGATION_ITEM_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string16.h"
10 #include "base/time/time.h"
11 #include "ui/base/page_transition_types.h"
20 // A NavigationItem is a data structure that captures all the information
21 // required to recreate a browsing state. It represents one point in the
22 // chain of navigation managed by a NavigationManager.
23 class NavigationItem
{
25 virtual ~NavigationItem() {}
27 // Creates a new NavigationItem.
28 static scoped_ptr
<NavigationItem
> Create();
30 // Page-related stuff --------------------------------------------------------
32 // A unique ID is preserved across commits and redirects, which means that
33 // sometimes a NavigationEntry's unique ID needs to be set (e.g. when
34 // creating a committed entry to correspond to a to-be-deleted pending entry,
35 // the pending entry's ID must be copied).
36 virtual int GetUniqueID() const = 0;
38 // The actual URL of the page. For some about pages, this may be a scary
39 // data: URL or something like that. Use GetVirtualURL() below for showing to
41 virtual void SetURL(const GURL
& url
) = 0;
42 virtual const GURL
& GetURL() const = 0;
44 // The referring URL. Can be empty.
45 virtual void SetReferrer(const Referrer
& referrer
) = 0;
46 virtual const Referrer
& GetReferrer() const = 0;
48 // The virtual URL, when nonempty, will override the actual URL of the page
49 // when we display it to the user. This allows us to have nice and friendly
50 // URLs that the user sees for things like about: URLs, but actually feed
51 // the renderer a data URL that results in the content loading.
53 // GetVirtualURL() will return the URL to display to the user in all cases, so
54 // if there is no overridden display URL, it will return the actual one.
55 virtual void SetVirtualURL(const GURL
& url
) = 0;
56 virtual const GURL
& GetVirtualURL() const = 0;
58 // The title as set by the page. This will be empty if there is no title set.
59 // The caller is responsible for detecting when there is no title and
60 // displaying the appropriate "Untitled" label if this is being displayed to
62 virtual void SetTitle(const base::string16
& title
) = 0;
63 virtual const base::string16
& GetTitle() const = 0;
65 // Describes the current page that the tab represents. This is the ID that the
66 // renderer generated for the page and is how we can tell new versus
68 virtual void SetPageID(int page_id
) = 0;
69 virtual int32
GetPageID() const = 0;
71 // Page-related helpers ------------------------------------------------------
73 // Returns the title to be displayed on the tab. This could be the title of
74 // the page if it is available or the URL. |languages| is the list of
75 // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper
76 // URL formatting isn't needed (e.g., unit tests).
77 virtual const base::string16
& GetTitleForDisplay(
78 const std::string
& languages
) const = 0;
80 // Tracking stuff ------------------------------------------------------------
82 // The transition type indicates what the user did to move to this page from
84 virtual void SetTransitionType(ui::PageTransition transition_type
) = 0;
85 virtual ui::PageTransition
GetTransitionType() const = 0;
87 // The favicon data and tracking information. See web::FaviconStatus.
88 virtual const FaviconStatus
& GetFavicon() const = 0;
89 virtual FaviconStatus
& GetFavicon() = 0;
91 // All the SSL flags and state. See web::SSLStatus.
92 virtual const SSLStatus
& GetSSL() const = 0;
93 virtual SSLStatus
& GetSSL() = 0;
95 // The time at which the last known local navigation has
96 // completed. (A navigation can be completed more than once if the
99 // If GetTimestamp() returns a null time, that means that either:
101 // - this navigation hasn't completed yet;
102 // - this navigation was restored and for some reason the
103 // timestamp wasn't available;
104 // - or this navigation was copied from a foreign session.
105 virtual void SetTimestamp(base::Time timestamp
) = 0;
106 virtual base::Time
GetTimestamp() const = 0;
111 #endif // IOS_WEB_PUBLIC_NAVIGATION_ITEM_H_