| 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/mac/scoped_nsobject.h" |
| 9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 11 #include "ios/web/navigation/navigation_item_facade_delegate.h" | 12 #include "ios/web/navigation/navigation_item_facade_delegate.h" |
| 12 #include "ios/web/public/favicon_status.h" | 13 #include "ios/web/public/favicon_status.h" |
| 13 #include "ios/web/public/navigation_item.h" | 14 #include "ios/web/public/navigation_item.h" |
| 14 #include "ios/web/public/referrer.h" | 15 #include "ios/web/public/referrer.h" |
| 15 #include "ios/web/public/ssl_status.h" | 16 #include "ios/web/public/ssl_status.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 | |
| 19 namespace web { | 19 namespace web { |
| 20 | 20 |
| 21 class NavigationItemFacadeDelegate; | 21 class NavigationItemFacadeDelegate; |
| 22 | 22 |
| 23 // Implementation of NavigationItem. | 23 // Implementation of NavigationItem. |
| 24 class NavigationItemImpl : public web::NavigationItem { | 24 class NavigationItemImpl : public web::NavigationItem { |
| 25 public: | 25 public: |
| 26 // Creates a default NavigationItemImpl. | 26 // Creates a default NavigationItemImpl. |
| 27 NavigationItemImpl(); | 27 NavigationItemImpl(); |
| 28 ~NavigationItemImpl() override; | 28 ~NavigationItemImpl() override; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 57 void SetTransitionType(ui::PageTransition transition_type) override; | 57 void SetTransitionType(ui::PageTransition transition_type) override; |
| 58 ui::PageTransition GetTransitionType() const override; | 58 ui::PageTransition GetTransitionType() const override; |
| 59 const FaviconStatus& GetFavicon() const override; | 59 const FaviconStatus& GetFavicon() const override; |
| 60 FaviconStatus& GetFavicon() override; | 60 FaviconStatus& GetFavicon() override; |
| 61 const SSLStatus& GetSSL() const override; | 61 const SSLStatus& GetSSL() const override; |
| 62 SSLStatus& GetSSL() override; | 62 SSLStatus& GetSSL() override; |
| 63 void SetTimestamp(base::Time timestamp) override; | 63 void SetTimestamp(base::Time timestamp) override; |
| 64 base::Time GetTimestamp() const override; | 64 base::Time GetTimestamp() const override; |
| 65 void SetUnsafe(bool is_unsafe) override; | 65 void SetUnsafe(bool is_unsafe) override; |
| 66 bool IsUnsafe() const override; | 66 bool IsUnsafe() const override; |
| 67 void SetIsOverridingUserAgent(bool is_overriding_user_agent) override; |
| 68 bool IsOverridingUserAgent() const override; |
| 69 bool HasPostData() const override; |
| 70 NSDictionary* GetHttpRequestHeaders() const override; |
| 71 void AddHttpRequestHeaders(NSDictionary* additional_headers) override; |
| 72 |
| 73 // Serialized representation of the state object that was used in conjunction |
| 74 // with a JavaScript window.history.pushState() or |
| 75 // window.history.replaceState() call that created or modified this |
| 76 // CRWSessionEntry. Intended to be used for JavaScript history operations and |
| 77 // will be nil in most cases. |
| 78 void SetSerializedStateObject(NSString* serialized_state_object); |
| 79 NSString* GetSerializedStateObject() const; |
| 80 |
| 81 // Whether or not this item was created by calling history.pushState(). |
| 82 void SetIsCreatedFromPushState(bool push_state); |
| 83 bool IsCreatedFromPushState() const; |
| 84 |
| 85 // Whether or not to bypass showing the resubmit data confirmation when |
| 86 // loading a POST request. Set to YES for browser-generated POST requests. |
| 87 void SetShouldSkipResubmitDataConfirmation(bool skip); |
| 88 bool ShouldSkipResubmitDataConfirmation() const; |
| 89 |
| 90 // Data submitted with a POST request, persisted for resubmits. |
| 91 void SetPostData(NSData* post_data); |
| 92 NSData* GetPostData() const; |
| 93 |
| 94 // Removes the header for |key| from |http_request_headers_|. |
| 95 void RemoveHttpRequestHeaderForKey(NSString* key); |
| 96 |
| 97 // Removes all http headers from |http_request_headers_|. |
| 98 void ResetHttpRequestHeaders(); |
| 67 | 99 |
| 68 // Once a navigation item is committed, we should no longer track | 100 // Once a navigation item is committed, we should no longer track |
| 69 // non-persisted state, as documented on the members below. | 101 // non-persisted state, as documented on the members below. |
| 70 void ResetForCommit(); | 102 void ResetForCommit(); |
| 71 | 103 |
| 72 // Whether this (pending) navigation is renderer-initiated. Resets to false | 104 // Whether this (pending) navigation is renderer-initiated. Resets to false |
| 73 // for all types of navigations after commit. | 105 // for all types of navigations after commit. |
| 74 void set_is_renderer_initiated(bool is_renderer_initiated) { | 106 void set_is_renderer_initiated(bool is_renderer_initiated) { |
| 75 is_renderer_initiated_ = is_renderer_initiated; | 107 is_renderer_initiated_ = is_renderer_initiated; |
| 76 } | 108 } |
| 77 bool is_renderer_initiated() const { return is_renderer_initiated_; } | 109 bool is_renderer_initiated() const { return is_renderer_initiated_; } |
| 78 | 110 |
| 79 private: | 111 private: |
| 80 int unique_id_; | 112 int unique_id_; |
| 81 GURL url_; | 113 GURL url_; |
| 82 Referrer referrer_; | 114 Referrer referrer_; |
| 83 GURL virtual_url_; | 115 GURL virtual_url_; |
| 84 base::string16 title_; | 116 base::string16 title_; |
| 85 int32 page_id_; | 117 int32 page_id_; |
| 86 PageScrollState page_scroll_state_; | 118 PageScrollState page_scroll_state_; |
| 87 ui::PageTransition transition_type_; | 119 ui::PageTransition transition_type_; |
| 88 FaviconStatus favicon_; | 120 FaviconStatus favicon_; |
| 89 SSLStatus ssl_; | 121 SSLStatus ssl_; |
| 90 base::Time timestamp_; | 122 base::Time timestamp_; |
| 123 bool is_overriding_user_agent_; |
| 124 base::scoped_nsobject<NSMutableDictionary> http_request_headers_; |
| 125 |
| 126 base::scoped_nsobject<NSString> serialized_state_object_; |
| 127 bool is_created_from_push_state_; |
| 128 bool should_skip_resubmit_data_confirmation_; |
| 129 base::scoped_nsobject<NSData> post_data_; |
| 91 | 130 |
| 92 // Whether the item, while loading, was created for a renderer-initiated | 131 // Whether the item, while loading, was created for a renderer-initiated |
| 93 // navigation. This dictates whether the URL should be displayed before the | 132 // navigation. This dictates whether the URL should be displayed before the |
| 94 // navigation commits. It is cleared in |ResetForCommit| and not persisted. | 133 // navigation commits. It is cleared in |ResetForCommit| and not persisted. |
| 95 bool is_renderer_initiated_; | 134 bool is_renderer_initiated_; |
| 96 | 135 |
| 97 // Whether the navigation contains unsafe resources. | 136 // Whether the navigation contains unsafe resources. |
| 98 bool is_unsafe_; | 137 bool is_unsafe_; |
| 99 | 138 |
| 100 // This is a cached version of the result of GetTitleForDisplay. When the URL, | 139 // 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. | 140 // virtual URL, or title is set, this should be cleared to force a refresh. |
| 102 mutable base::string16 cached_display_title_; | 141 mutable base::string16 cached_display_title_; |
| 103 | 142 |
| 104 // Weak pointer to the facade delegate. | 143 // Weak pointer to the facade delegate. |
| 105 scoped_ptr<NavigationItemFacadeDelegate> facade_delegate_; | 144 scoped_ptr<NavigationItemFacadeDelegate> facade_delegate_; |
| 106 | 145 |
| 107 // Copy and assignment is explicitly allowed for this class. | 146 // Copy and assignment is explicitly allowed for this class. |
| 108 }; | 147 }; |
| 109 | 148 |
| 110 } // namespace web | 149 } // namespace web |
| 111 | 150 |
| 112 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ | 151 #endif // IOS_WEB_NAVIGATION_NAVIGATION_ITEM_IMPL_H_ |
| OLD | NEW |