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