Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ios / web / navigation / navigation_item_impl.h
blob9abd992f2b81dec2a74ca45f8002033f8922491f
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_NAVIGATION_NAVIGATION_ITEM_IMPL_H_
6 #define IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_
8 #include "base/basictypes.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string16.h"
11 #include "ios/web/navigation/navigation_item_facade_delegate.h"
12 #include "ios/web/public/favicon_status.h"
13 #include "ios/web/public/navigation_item.h"
14 #include "ios/web/public/referrer.h"
15 #include "ios/web/public/ssl_status.h"
16 #include "url/gurl.h"
19 namespace web {
21 class NavigationItemFacadeDelegate;
23 // Implementation of NavigationItem.
24 class NavigationItemImpl : public web::NavigationItem {
25 public:
26 // Creates a default NavigationItemImpl.
27 NavigationItemImpl();
28 ~NavigationItemImpl() override;
30 // Since NavigationItemImpls own their facade delegates, there is no implicit
31 // copy constructor (scoped_ptrs can't be copied), so one is defined here.
32 NavigationItemImpl(const NavigationItemImpl& item);
34 // Accessors for the delegate used to drive the navigation entry facade.
35 // NOTE: to minimize facade synchronization code, NavigationItems take
36 // ownership of their facade delegates.
37 void SetFacadeDelegate(
38 scoped_ptr<NavigationItemFacadeDelegate> facade_delegate);
39 NavigationItemFacadeDelegate* GetFacadeDelegate() const;
41 // NavigationItem implementation:
42 int GetUniqueID() const override;
43 void SetURL(const GURL& url) override;
44 const GURL& GetURL() const override;
45 void SetReferrer(const web::Referrer& referrer) override;
46 const web::Referrer& GetReferrer() const override;
47 void SetVirtualURL(const GURL& url) override;
48 const GURL& GetVirtualURL() const override;
49 void SetTitle(const base::string16& title) override;
50 const base::string16& GetTitle() const override;
51 void SetPageID(int page_id) override;
52 int32 GetPageID() const override;
53 void SetPageScrollState(const PageScrollState& scroll_state) override;
54 const PageScrollState& GetPageScrollState() const override;
55 const base::string16& GetTitleForDisplay(
56 const std::string& languages) const override;
57 void SetTransitionType(ui::PageTransition transition_type) override;
58 ui::PageTransition GetTransitionType() const override;
59 const FaviconStatus& GetFavicon() const override;
60 FaviconStatus& GetFavicon() override;
61 const SSLStatus& GetSSL() const override;
62 SSLStatus& GetSSL() override;
63 void SetTimestamp(base::Time timestamp) override;
64 base::Time GetTimestamp() const override;
65 void SetUnsafe(bool is_unsafe) override;
66 bool IsUnsafe() const override;
68 // Once a navigation item is committed, we should no longer track
69 // non-persisted state, as documented on the members below.
70 void ResetForCommit();
72 // Whether this (pending) navigation is renderer-initiated. Resets to false
73 // for all types of navigations after commit.
74 void set_is_renderer_initiated(bool is_renderer_initiated) {
75 is_renderer_initiated_ = is_renderer_initiated;
77 bool is_renderer_initiated() const { return is_renderer_initiated_; }
79 private:
80 int unique_id_;
81 GURL url_;
82 Referrer referrer_;
83 GURL virtual_url_;
84 base::string16 title_;
85 int32 page_id_;
86 PageScrollState page_scroll_state_;
87 ui::PageTransition transition_type_;
88 FaviconStatus favicon_;
89 SSLStatus ssl_;
90 base::Time timestamp_;
92 // Whether the item, while loading, was created for a renderer-initiated
93 // navigation. This dictates whether the URL should be displayed before the
94 // navigation commits. It is cleared in |ResetForCommit| and not persisted.
95 bool is_renderer_initiated_;
97 // Whether the navigation contains unsafe resources.
98 bool is_unsafe_;
100 // This is a cached version of the result of GetTitleForDisplay. When the URL,
101 // virtual URL, or title is set, this should be cleared to force a refresh.
102 mutable base::string16 cached_display_title_;
104 // Weak pointer to the facade delegate.
105 scoped_ptr<NavigationItemFacadeDelegate> facade_delegate_;
107 // Copy and assignment is explicitly allowed for this class.
110 } // namespace web
112 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_