OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_WEB_STATE_UI_WK_BACK_FORWARD_LIST_ITEM_HOLDER_H_ | 5 #ifndef IOS_WEB_WEB_STATE_UI_WK_BACK_FORWARD_LIST_ITEM_HOLDER_H_ |
6 #define IOS_WEB_WEB_STATE_UI_WK_BACK_FORWARD_LIST_ITEM_HOLDER_H_ | 6 #define IOS_WEB_WEB_STATE_UI_WK_BACK_FORWARD_LIST_ITEM_HOLDER_H_ |
7 | 7 |
8 #import <WebKit/WebKit.h> | 8 #import <WebKit/WebKit.h> |
9 | 9 |
10 #import "base/ios/weak_nsobject.h" | 10 #import "base/ios/weak_nsobject.h" |
11 #import "base/mac/scoped_nsobject.h" | 11 #import "base/mac/scoped_nsobject.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/supports_user_data.h" | 13 #include "base/supports_user_data.h" |
14 | 14 |
15 namespace web { | 15 namespace web { |
16 | 16 |
17 class NavigationItem; | 17 class NavigationItem; |
18 | 18 |
19 // This class is a wrapper for information needed to implement native | 19 // This class is a wrapper for information needed to implement native |
20 // WKWebView navigation. WKBackForwardListItemHolder is attached to | 20 // WKWebView navigation. WKBackForwardListItemHolder is attached to |
21 // NavigationItem via the SupportsUserData interface and holds the corresponding | 21 // NavigationItem via the SupportsUserData interface and holds the corresponding |
22 // WKBackForwardListItem, as well as any state that is inaccessible later and | 22 // WKBackForwardListItem, as well as any state that is inaccessible later and |
23 // thus needs to be preserved (e.g., WKNavigationType, MIME type). | 23 // thus needs to be preserved (e.g., WKNavigationType, MIME type). |
24 class WKBackForwardListItemHolder : public base::SupportsUserData::Data { | 24 class WKBackForwardListItemHolder : public base::SupportsUserData::Data { |
25 public: | 25 public: |
| 26 ~WKBackForwardListItemHolder() override; |
| 27 |
26 // Returns the WKBackForwardListItemHolder for the NavigationItem |item|. | 28 // Returns the WKBackForwardListItemHolder for the NavigationItem |item|. |
27 // Lazily attaches one if it does not exist. |item| cannot be null. | 29 // Lazily attaches one if it does not exist. |item| cannot be null. |
28 static web::WKBackForwardListItemHolder* FromNavigationItem( | 30 static web::WKBackForwardListItemHolder* FromNavigationItem( |
29 NavigationItem* item); | 31 NavigationItem* item); |
30 | 32 |
31 // Accessors for |item_|. Use these to get/set the association between a | 33 // Accessors for |item_|. Use these to get/set the association between a |
32 // NavigationItem and a WKBackForwardListItem. Note that | 34 // NavigationItem and a WKBackForwardListItem. Note that |
33 // |back_forward_list_item| may return nil (f.e. when the | 35 // |back_forward_list_item| may return nil (f.e. when the |
34 // parent WKBackForwardList is deallocated). | 36 // parent WKBackForwardList is deallocated). |
35 WKBackForwardListItem* back_forward_list_item() const { return item_; } | 37 WKBackForwardListItem* back_forward_list_item() const { return item_; } |
(...skipping 13 matching lines...) Expand all Loading... |
49 } | 51 } |
50 | 52 |
51 // Gets/sets the MIME type of the page corresponding to this item. | 53 // Gets/sets the MIME type of the page corresponding to this item. |
52 NSString* mime_type() const { return mime_type_.get(); } | 54 NSString* mime_type() const { return mime_type_.get(); } |
53 void set_mime_type(NSString* mime_type) { | 55 void set_mime_type(NSString* mime_type) { |
54 mime_type_.reset([mime_type copy]); | 56 mime_type_.reset([mime_type copy]); |
55 } | 57 } |
56 | 58 |
57 private: | 59 private: |
58 WKBackForwardListItemHolder(); | 60 WKBackForwardListItemHolder(); |
59 ~WKBackForwardListItemHolder() override; | |
60 | 61 |
61 // Weak pointer to a WKBackForwardListItem. Becomes nil if the parent | 62 // Weak pointer to a WKBackForwardListItem. Becomes nil if the parent |
62 // WKBackForwardList is deallocated. | 63 // WKBackForwardList is deallocated. |
63 base::WeakNSObject<WKBackForwardListItem> item_; | 64 base::WeakNSObject<WKBackForwardListItem> item_; |
64 | 65 |
65 // The navigation type for the associated NavigationItem. | 66 // The navigation type for the associated NavigationItem. |
66 WKNavigationType navigation_type_; | 67 WKNavigationType navigation_type_; |
67 | 68 |
68 // HTTP request method. | 69 // HTTP request method. |
69 base::scoped_nsobject<NSString> http_method_; | 70 base::scoped_nsobject<NSString> http_method_; |
70 | 71 |
71 // The MIME type of the page content. | 72 // The MIME type of the page content. |
72 base::scoped_nsobject<NSString> mime_type_; | 73 base::scoped_nsobject<NSString> mime_type_; |
73 | 74 |
74 DISALLOW_COPY_AND_ASSIGN(WKBackForwardListItemHolder); | 75 DISALLOW_COPY_AND_ASSIGN(WKBackForwardListItemHolder); |
75 }; | 76 }; |
76 | 77 |
77 } // namespace web | 78 } // namespace web |
78 | 79 |
79 #endif // IOS_WEB_WEB_STATE_UI_WK_BACK_FORWARD_LIST_ITEM_HOLDER_H_ | 80 #endif // IOS_WEB_WEB_STATE_UI_WK_BACK_FORWARD_LIST_ITEM_HOLDER_H_ |
OLD | NEW |