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 class WKNavigationState : int { |
| 15 // Navigation does not exist. |
| 16 NONE = 0, |
| 17 // WKNavigation returned from |loadRequest:|, |goToBackForwardListItem:|, |
| 18 // |loadFileURL:allowingReadAccessToURL:|, |loadHTMLString:baseURL:|, |
| 19 // |loadData:MIMEType:characterEncodingName:baseURL:|, |goBack|, |goForward|, |
| 20 // |reload| or |reloadFromOrigin|. |
| 21 REQUESTED, |
| 22 // WKNavigation passed to |webView:didStartProvisionalNavigation:|. |
| 23 STARTED, |
| 24 // WKNavigation passed to |
| 25 // |webView:didReceiveServerRedirectForProvisionalNavigation:|. |
| 26 REDIRECTED, |
| 27 // WKNavigation passed to |webView:didFailProvisionalNavigation:|. |
| 28 PROVISIONALY_FAILED, |
| 29 // WKNavigation passed to |webView:didCommitNavigation:|. |
| 30 COMMITTED, |
| 31 // WKNavigation passed to |webView:didFinishNavigation:|. |
| 32 FINISHED, |
| 33 // WKNavigation passed to |webView:didFailNavigation:withError:|. |
| 34 FAILED, |
| 35 }; |
| 36 |
| 37 } // namespace web |
| 38 |
| 39 // Stores states for WKNavigation objects. Allows lookign up for last added |
| 40 // navigation object. |
| 41 @interface CRWWKNavigationStates : NSObject |
| 42 |
| 43 // Adds a new navigation if it was not added yet. If navigation was already |
| 44 // added then updates state for existing navigation. Updating state does not |
| 45 // affect the result of |lastAddedNavigation| method. New added navigations |
| 46 // should have WKNavigationState::REQUESTED, WKNavigationState::STARTED or |
| 47 // WKNavigationState::COMMITTED state. Passed |navigation| will be help as weak |
| 48 // reference and will not be retained. No-op if |navigation| is null. |
| 49 - (void)setState:(web::WKNavigationState)state |
| 50 forNavigation:(WKNavigation*)navigation; |
| 51 |
| 52 // WKNavigation which was added the most recently via |setState:forNavigation:|. |
| 53 // Updating navigation state via |setState:forNavigation:| does not change the |
| 54 // last added navigation. Returns nil if there are no stored navigations. |
| 55 - (WKNavigation*)lastAddedNavigation; |
| 56 |
| 57 // Returns state of the given navigation or WKNavigationState::NONE if |
| 58 // navigation does not exist. |
| 59 - (web::WKNavigationState)stateForNavigation:(WKNavigation*)navigation; |
| 60 |
| 61 @end |
| 62 |
| 63 #endif // IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ |
OLD | NEW |