OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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. |
| 4 |
| 5 #ifndef IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ |
| 6 #define IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ |
| 7 |
| 8 #import <Foundation/Foundation.h> |
| 9 #import <WebKit/WebKit.h> |
| 10 |
| 11 namespace web { |
| 12 |
| 13 // State of in-flight WKNavigation objects. |
| 14 enum WKNavigationState { |
| 15 // WKNavigation returned from |loadRequest:|, |goToBackForwardListItem:|, |
| 16 // |loadFileURL:allowingReadAccessToURL:|, |loadHTMLString:baseURL:|, |
| 17 // |loadData:MIMEType:characterEncodingName:baseURL:|, |goBack|, |goForward|, |
| 18 // |reload| or |reloadFromOrigin|. |
| 19 WK_NAVIGATION_STATE_REQUESTED = 1, |
| 20 // WKNavigation passed to |webView:didStartProvisionalNavigation:|. |
| 21 WK_NAVIGATION_STATE_STARTED, |
| 22 // WKNavigation passed to |
| 23 // |webView:didReceiveServerRedirectForProvisionalNavigation:|. |
| 24 WK_NAVIGATION_STATE_REDIRECTED, |
| 25 // WKNavigation passed to |webView:didFailProvisionalNavigation:|. |
| 26 WK_NAVIGATION_STATE_PROVISIONALY_FAILED, |
| 27 // WKNavigation passed to |webView:didCommitNavigation:|. |
| 28 WK_NAVIGATION_STATE_COMMITTED, |
| 29 // WKNavigation passed to |webView:didFinishNavigation:|. |
| 30 WK_NAVIGATION_STATE_FINISHED, |
| 31 // WKNavigation passed to |webView:didFailNavigation:withError:|. |
| 32 WK_NAVIGATION_STATE_FAILED, |
| 33 }; |
| 34 |
| 35 } // namespace web |
| 36 |
| 37 // Stores states for WKNavigation objects. Allows lookign up for last added |
| 38 // navigation object. |
| 39 @interface CRWWKNavigationStates : NSObject |
| 40 |
| 41 // Adds a new navigation if it was not added yet. If navigation was already |
| 42 // added then updates state for existing navigation. Updating state does not |
| 43 // affect the result of |lastAddedNavigation| method. New added navigations |
| 44 // should have either WK_NAVIGATION_STATE_REQUESTED or |
| 45 // WK_NAVIGATION_STATE_STARTED state. Passed |navigation| will be help as weak |
| 46 // reference and will not be retained. No-op if |navigation| is null. |
| 47 - (void)addNavigation:(WKNavigation*)navigation |
| 48 forState:(web::WKNavigationState)state; |
| 49 |
| 50 // WKNavigation which was added the most recently via |addNavigation:forState:|. |
| 51 // Updating navigation state via |addNavigation:forState:| does not change the |
| 52 // last added navigation. Returns nil if there are no stored navigations. |
| 53 - (WKNavigation*)lastAddedNavigation; |
| 54 |
| 55 // Returns state of the given navigation or 0 if navigation does not exist. |
| 56 - (web::WKNavigationState)stateForNavigation:(WKNavigation*)navigation; |
| 57 |
| 58 @end |
| 59 |
| 60 #endif // IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ |
OLD | NEW |