Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / ios / web / public / navigation_item.h
blobea9706eb7fd438d4022891210da32ac90af6e6d8
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_display_state.h"
12 #include "ui/base/page_transition_types.h"
14 class GURL;
16 #if defined(__OBJC__)
17 @class NSDictionary;
18 #else
19 class NSDictionary;
20 #endif // __OBJC__
22 namespace web {
23 struct FaviconStatus;
24 struct Referrer;
25 struct SSLStatus;
27 // A NavigationItem is a data structure that captures all the information
28 // required to recreate a browsing state. It represents one point in the
29 // chain of navigation managed by a NavigationManager.
30 class NavigationItem {
31 public:
32 virtual ~NavigationItem() {}
34 // Creates a new NavigationItem.
35 static scoped_ptr<NavigationItem> Create();
37 // Page-related stuff --------------------------------------------------------
39 // A unique ID is preserved across commits and redirects, which means that
40 // sometimes a NavigationEntry's unique ID needs to be set (e.g. when
41 // creating a committed entry to correspond to a to-be-deleted pending entry,
42 // the pending entry's ID must be copied).
43 virtual int GetUniqueID() const = 0;
45 // The actual URL of the page. For some about pages, this may be a scary
46 // data: URL or something like that. Use GetVirtualURL() below for showing to
47 // the user.
48 virtual void SetURL(const GURL& url) = 0;
49 virtual const GURL& GetURL() const = 0;
51 // The referring URL. Can be empty.
52 virtual void SetReferrer(const Referrer& referrer) = 0;
53 virtual const Referrer& GetReferrer() const = 0;
55 // The virtual URL, when nonempty, will override the actual URL of the page
56 // when we display it to the user. This allows us to have nice and friendly
57 // URLs that the user sees for things like about: URLs, but actually feed
58 // the renderer a data URL that results in the content loading.
60 // GetVirtualURL() will return the URL to display to the user in all cases, so
61 // if there is no overridden display URL, it will return the actual one.
62 virtual void SetVirtualURL(const GURL& url) = 0;
63 virtual const GURL& GetVirtualURL() const = 0;
65 // The title as set by the page. This will be empty if there is no title set.
66 // The caller is responsible for detecting when there is no title and
67 // displaying the appropriate "Untitled" label if this is being displayed to
68 // the user.
69 virtual void SetTitle(const base::string16& title) = 0;
70 virtual const base::string16& GetTitle() const = 0;
72 // Stores the NavigationItem's last recorded scroll offset and zoom scale.
73 virtual void SetPageDisplayState(const PageDisplayState& page_state) = 0;
74 virtual const PageDisplayState& GetPageDisplayState() 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 // accepted 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;
118 // |true| if this item uses a desktop user agent in HTTP requests and
119 // UIWebView.
120 virtual void SetIsOverridingUserAgent(bool is_overriding_user_agent) = 0;
121 virtual bool IsOverridingUserAgent() const = 0;
123 // |true| if this item is the result of a POST request with data.
124 virtual bool HasPostData() const = 0;
126 // Returns the item's current http request headers.
127 virtual NSDictionary* GetHttpRequestHeaders() const = 0;
129 // Adds headers from |additional_headers| to the item's http request headers.
130 // Existing headers with the same key will be overridden.
131 virtual void AddHttpRequestHeaders(NSDictionary* additional_headers) = 0;
134 } // namespace web
136 #endif // IOS_WEB_PUBLIC_NAVIGATION_ITEM_H_