Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ios / web / public / navigation_item.h
blobe067a82ee32b2feae65a2f0e469e4f6af5efb8c2
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 "ios/web/public/web_state/page_scroll_state.h"
12 #include "ui/base/page_transition_types.h"
14 class GURL;
16 namespace web {
17 struct FaviconStatus;
18 struct Referrer;
19 struct SSLStatus;
21 // A NavigationItem is a data structure that captures all the information
22 // required to recreate a browsing state. It represents one point in the
23 // chain of navigation managed by a NavigationManager.
24 class NavigationItem {
25 public:
26 virtual ~NavigationItem() {}
28 // Creates a new NavigationItem.
29 static scoped_ptr<NavigationItem> Create();
31 // Page-related stuff --------------------------------------------------------
33 // A unique ID is preserved across commits and redirects, which means that
34 // sometimes a NavigationEntry's unique ID needs to be set (e.g. when
35 // creating a committed entry to correspond to a to-be-deleted pending entry,
36 // the pending entry's ID must be copied).
37 virtual int GetUniqueID() const = 0;
39 // The actual URL of the page. For some about pages, this may be a scary
40 // data: URL or something like that. Use GetVirtualURL() below for showing to
41 // the user.
42 virtual void SetURL(const GURL& url) = 0;
43 virtual const GURL& GetURL() const = 0;
45 // The referring URL. Can be empty.
46 virtual void SetReferrer(const Referrer& referrer) = 0;
47 virtual const Referrer& GetReferrer() const = 0;
49 // The virtual URL, when nonempty, will override the actual URL of the page
50 // when we display it to the user. This allows us to have nice and friendly
51 // URLs that the user sees for things like about: URLs, but actually feed
52 // the renderer a data URL that results in the content loading.
54 // GetVirtualURL() will return the URL to display to the user in all cases, so
55 // if there is no overridden display URL, it will return the actual one.
56 virtual void SetVirtualURL(const GURL& url) = 0;
57 virtual const GURL& GetVirtualURL() const = 0;
59 // The title as set by the page. This will be empty if there is no title set.
60 // The caller is responsible for detecting when there is no title and
61 // displaying the appropriate "Untitled" label if this is being displayed to
62 // the user.
63 virtual void SetTitle(const base::string16& title) = 0;
64 virtual const base::string16& GetTitle() const = 0;
66 // Describes the current page that the tab represents. This is the ID that the
67 // renderer generated for the page and is how we can tell new versus
68 // renavigations.
69 virtual void SetPageID(int page_id) = 0;
70 virtual int32 GetPageID() const = 0;
72 // Stores the NavigationItem's last recorded scroll offset and zoom scale.
73 virtual void SetPageScrollState(const PageScrollState& scroll_state) = 0;
74 virtual const PageScrollState& GetPageScrollState() const = 0;
76 // Page-related helpers ------------------------------------------------------
78 // Returns the title to be displayed on the tab. This could be the title of
79 // the page if it is available or the URL. |languages| is the list of
80 // accpeted languages (e.g., prefs::kAcceptLanguages) or empty if proper
81 // URL formatting isn't needed (e.g., unit tests).
82 virtual const base::string16& GetTitleForDisplay(
83 const std::string& languages) const = 0;
85 // Tracking stuff ------------------------------------------------------------
87 // The transition type indicates what the user did to move to this page from
88 // the previous page.
89 virtual void SetTransitionType(ui::PageTransition transition_type) = 0;
90 virtual ui::PageTransition GetTransitionType() const = 0;
92 // The favicon data and tracking information. See web::FaviconStatus.
93 virtual const FaviconStatus& GetFavicon() const = 0;
94 virtual FaviconStatus& GetFavicon() = 0;
96 // All the SSL flags and state. See web::SSLStatus.
97 virtual const SSLStatus& GetSSL() const = 0;
98 virtual SSLStatus& GetSSL() = 0;
100 // The time at which the last known local navigation has
101 // completed. (A navigation can be completed more than once if the
102 // page is reloaded.)
104 // If GetTimestamp() returns a null time, that means that either:
106 // - this navigation hasn't completed yet;
107 // - this navigation was restored and for some reason the
108 // timestamp wasn't available;
109 // - or this navigation was copied from a foreign session.
110 virtual void SetTimestamp(base::Time timestamp) = 0;
111 virtual base::Time GetTimestamp() const = 0;
113 // |true| if this item contains unsafe resources and will be removed. This
114 // property doesn't get serialized.
115 virtual void SetUnsafe(bool is_unsafe) = 0;
116 virtual bool IsUnsafe() const = 0;
119 } // namespace web
121 #endif // IOS_WEB_PUBLIC_NAVIGATION_ITEM_H_