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_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ | 5 #ifndef IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ |
6 #define IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ | 6 #define IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "ios/web/navigation/navigation_item_facade_delegate.h" |
11 #include "ios/web/public/favicon_status.h" | 12 #include "ios/web/public/favicon_status.h" |
12 #include "ios/web/public/navigation_item.h" | 13 #include "ios/web/public/navigation_item.h" |
13 #include "ios/web/public/referrer.h" | 14 #include "ios/web/public/referrer.h" |
14 #include "ios/web/public/ssl_status.h" | 15 #include "ios/web/public/ssl_status.h" |
15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
16 | 17 |
| 18 |
17 namespace web { | 19 namespace web { |
18 | 20 |
| 21 class NavigationItemFacadeDelegate; |
| 22 |
19 // Implementation of NavigationItem. | 23 // Implementation of NavigationItem. |
20 class NavigationItemImpl : public web::NavigationItem { | 24 class NavigationItemImpl : public web::NavigationItem { |
21 public: | 25 public: |
22 // Creates a default NavigationItemImpl. | 26 // Creates a default NavigationItemImpl. |
23 NavigationItemImpl(); | 27 NavigationItemImpl(); |
24 ~NavigationItemImpl() override; | 28 ~NavigationItemImpl() override; |
25 | 29 |
| 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); |
| 33 |
| 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; |
| 40 |
26 // NavigationItem implementation: | 41 // NavigationItem implementation: |
27 int GetUniqueID() const override; | 42 int GetUniqueID() const override; |
28 void SetURL(const GURL& url) override; | 43 void SetURL(const GURL& url) override; |
29 const GURL& GetURL() const override; | 44 const GURL& GetURL() const override; |
30 void SetReferrer(const web::Referrer& referrer) override; | 45 void SetReferrer(const web::Referrer& referrer) override; |
31 const web::Referrer& GetReferrer() const override; | 46 const web::Referrer& GetReferrer() const override; |
32 void SetVirtualURL(const GURL& url) override; | 47 void SetVirtualURL(const GURL& url) override; |
33 const GURL& GetVirtualURL() const override; | 48 const GURL& GetVirtualURL() const override; |
34 void SetTitle(const base::string16& title) override; | 49 void SetTitle(const base::string16& title) override; |
35 const base::string16& GetTitle() const override; | 50 const base::string16& GetTitle() const override; |
36 void SetPageID(int page_id) override; | 51 void SetPageID(int page_id) override; |
37 int32 GetPageID() const override; | 52 int32 GetPageID() const override; |
| 53 void SetPageScrollState(const PageScrollState& scroll_state) override; |
| 54 const PageScrollState& GetPageScrollState() const override; |
38 const base::string16& GetTitleForDisplay( | 55 const base::string16& GetTitleForDisplay( |
39 const std::string& languages) const override; | 56 const std::string& languages) const override; |
40 void SetTransitionType(ui::PageTransition transition_type) override; | 57 void SetTransitionType(ui::PageTransition transition_type) override; |
41 ui::PageTransition GetTransitionType() const override; | 58 ui::PageTransition GetTransitionType() const override; |
42 const FaviconStatus& GetFavicon() const override; | 59 const FaviconStatus& GetFavicon() const override; |
43 FaviconStatus& GetFavicon() override; | 60 FaviconStatus& GetFavicon() override; |
44 const SSLStatus& GetSSL() const override; | 61 const SSLStatus& GetSSL() const override; |
45 SSLStatus& GetSSL() override; | 62 SSLStatus& GetSSL() override; |
46 void SetTimestamp(base::Time timestamp) override; | 63 void SetTimestamp(base::Time timestamp) override; |
47 base::Time GetTimestamp() const override; | 64 base::Time GetTimestamp() const override; |
| 65 void SetUnsafe(bool is_unsafe) override; |
| 66 bool IsUnsafe() const override; |
| 67 |
| 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(); |
| 71 |
| 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; |
| 76 } |
| 77 bool is_renderer_initiated() const { return is_renderer_initiated_; } |
48 | 78 |
49 private: | 79 private: |
50 int unique_id_; | 80 int unique_id_; |
51 GURL url_; | 81 GURL url_; |
52 Referrer referrer_; | 82 Referrer referrer_; |
53 GURL virtual_url_; | 83 GURL virtual_url_; |
54 base::string16 title_; | 84 base::string16 title_; |
55 int32 page_id_; | 85 int32 page_id_; |
| 86 PageScrollState page_scroll_state_; |
56 ui::PageTransition transition_type_; | 87 ui::PageTransition transition_type_; |
57 FaviconStatus favicon_; | 88 FaviconStatus favicon_; |
58 SSLStatus ssl_; | 89 SSLStatus ssl_; |
59 base::Time timestamp_; | 90 base::Time timestamp_; |
60 | 91 |
| 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_; |
| 96 |
| 97 // Whether the navigation contains unsafe resources. |
| 98 bool is_unsafe_; |
| 99 |
61 // This is a cached version of the result of GetTitleForDisplay. When the URL, | 100 // This is a cached version of the result of GetTitleForDisplay. When the URL, |
62 // virtual URL, or title is set, this should be cleared to force a refresh. | 101 // virtual URL, or title is set, this should be cleared to force a refresh. |
63 mutable base::string16 cached_display_title_; | 102 mutable base::string16 cached_display_title_; |
64 | 103 |
| 104 // Weak pointer to the facade delegate. |
| 105 scoped_ptr<NavigationItemFacadeDelegate> facade_delegate_; |
| 106 |
65 // Copy and assignment is explicitly allowed for this class. | 107 // Copy and assignment is explicitly allowed for this class. |
66 }; | 108 }; |
67 | 109 |
68 } // namespace web | 110 } // namespace web |
69 | 111 |
70 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ | 112 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ |
OLD | NEW |