Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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_CRW_WK_NAVIGATION_STATES_H_ | 5 #ifndef IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ |
| 6 #define IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ | 6 #define IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ |
| 7 | 7 |
| 8 #include <memory> | |
| 9 | |
| 8 #import <Foundation/Foundation.h> | 10 #import <Foundation/Foundation.h> |
| 9 #import <WebKit/WebKit.h> | 11 #import <WebKit/WebKit.h> |
| 10 | 12 |
| 11 namespace web { | 13 namespace web { |
| 12 | 14 |
| 15 class NavigationContextImpl; | |
| 16 | |
| 13 // State of in-flight WKNavigation objects. | 17 // State of in-flight WKNavigation objects. |
| 14 enum class WKNavigationState : int { | 18 enum class WKNavigationState : int { |
| 15 // Navigation does not exist. | 19 // Navigation does not exist. |
| 16 NONE = 0, | 20 NONE = 0, |
| 17 // WKNavigation returned from |loadRequest:|, |goToBackForwardListItem:|, | 21 // WKNavigation returned from |loadRequest:|, |goToBackForwardListItem:|, |
| 18 // |loadFileURL:allowingReadAccessToURL:|, |loadHTMLString:baseURL:|, | 22 // |loadFileURL:allowingReadAccessToURL:|, |loadHTMLString:baseURL:|, |
| 19 // |loadData:MIMEType:characterEncodingName:baseURL:|, |goBack|, |goForward|, | 23 // |loadData:MIMEType:characterEncodingName:baseURL:|, |goBack|, |goForward|, |
| 20 // |reload| or |reloadFromOrigin|. | 24 // |reload| or |reloadFromOrigin|. |
| 21 REQUESTED, | 25 REQUESTED, |
| 22 // WKNavigation passed to |webView:didStartProvisionalNavigation:|. | 26 // WKNavigation passed to |webView:didStartProvisionalNavigation:|. |
| 23 STARTED, | 27 STARTED, |
| 24 // WKNavigation passed to | 28 // WKNavigation passed to |
| 25 // |webView:didReceiveServerRedirectForProvisionalNavigation:|. | 29 // |webView:didReceiveServerRedirectForProvisionalNavigation:|. |
| 26 REDIRECTED, | 30 REDIRECTED, |
| 27 // WKNavigation passed to |webView:didFailProvisionalNavigation:|. | 31 // WKNavigation passed to |webView:didFailProvisionalNavigation:|. |
| 28 PROVISIONALY_FAILED, | 32 PROVISIONALY_FAILED, |
| 29 // WKNavigation passed to |webView:didCommitNavigation:|. | 33 // WKNavigation passed to |webView:didCommitNavigation:|. |
| 30 COMMITTED, | 34 COMMITTED, |
| 31 // WKNavigation passed to |webView:didFinishNavigation:|. | 35 // WKNavigation passed to |webView:didFinishNavigation:|. |
| 32 FINISHED, | 36 FINISHED, |
| 33 // WKNavigation passed to |webView:didFailNavigation:withError:|. | 37 // WKNavigation passed to |webView:didFailNavigation:withError:|. |
| 34 FAILED, | 38 FAILED, |
| 35 }; | 39 }; |
| 36 | 40 |
| 37 } // namespace web | 41 } // namespace web |
| 38 | 42 |
| 39 // Stores states for WKNavigation objects. Allows lookign up for last added | 43 // Stores states and navigation contexts for WKNavigation objects. |
| 40 // navigation object. | 44 // Allows looking up for last added navigation object. |
| 41 @interface CRWWKNavigationStates : NSObject | 45 @interface CRWWKNavigationStates : NSObject |
| 42 | 46 |
| 43 // Adds a new navigation if it was not added yet. If navigation was already | 47 // 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 | 48 // added then updates state for existing navigation. Updating state does not |
| 45 // affect the result of |lastAddedNavigation| method. New added navigations | 49 // affect the result of |lastAddedNavigation| method. New added navigations |
| 46 // should have WKNavigationState::REQUESTED, WKNavigationState::STARTED or | 50 // should have WKNavigationState::REQUESTED, WKNavigationState::STARTED or |
| 47 // WKNavigationState::COMMITTED state. Passed |navigation| will be help as weak | 51 // WKNavigationState::COMMITTED state. Passed |navigation| will be help as weak |
| 48 // reference and will not be retained. No-op if |navigation| is null. | 52 // reference and will not be retained. No-op if |navigation| is null. |
| 49 - (void)setState:(web::WKNavigationState)state | 53 - (void)setState:(web::WKNavigationState)state |
| 50 forNavigation:(WKNavigation*)navigation; | 54 forNavigation:(WKNavigation*)navigation; |
| 51 | 55 |
| 52 // Removes given |navigation|. Fails if |navigation| does not exist. No-op if | 56 // Removes given |navigation|. Fails if |navigation| does not exist. No-op if |
| 53 // |navigation| is null. | 57 // |navigation| is null. |
| 54 - (void)removeNavigation:(WKNavigation*)navigation; | 58 - (void)removeNavigation:(WKNavigation*)navigation; |
| 55 | 59 |
| 60 // Adds a new navigation if it was not added yet. If navigation was already | |
| 61 // added then updates context for existing navigation. Updating context does not | |
| 62 // affect the result of |lastAddedNavigation| method. Passed |navigation| will | |
|
kkhorimoto
2017/04/25 13:29:55
Optional: I don't think "Passed" is really necessa
Eugene But (OOO till 7-30)
2017/04/25 21:02:58
Done.
| |
| 63 // be held as weak reference and will not be retained. No-op if |navigation| is | |
| 64 // null. | |
| 65 - (void)setContext:(std::unique_ptr<web::NavigationContextImpl>)context | |
| 66 forNavigation:(WKNavigation*)navigation; | |
| 67 | |
| 68 // Returns context if one was previously associated with given |navigation|. | |
| 69 // Returns null if |navigation| is null. | |
| 70 - (web::NavigationContextImpl*)contextForNavigation:(WKNavigation*)navigation; | |
| 71 | |
| 56 // WKNavigation which was added the most recently via |setState:forNavigation:|. | 72 // WKNavigation which was added the most recently via |setState:forNavigation:|. |
| 57 // Updating navigation state via |setState:forNavigation:| does not change the | 73 // Updating navigation state via |setState:forNavigation:| does not change the |
| 58 // last added navigation. Returns nil if there are no stored navigations. | 74 // last added navigation. Returns nil if there are no stored navigations. |
| 59 - (WKNavigation*)lastAddedNavigation; | 75 - (WKNavigation*)lastAddedNavigation; |
| 60 | 76 |
| 61 // State of WKNavigation which was added the most recently via | 77 // State of WKNavigation which was added the most recently via |
| 62 // |setState:forNavigation:|. WKNavigationState::NONE if CRWWKNavigationStates | 78 // |setState:forNavigation:|. WKNavigationState::NONE if CRWWKNavigationStates |
| 63 // is empty. | 79 // is empty. |
| 64 - (web::WKNavigationState)lastAddedNavigationState; | 80 - (web::WKNavigationState)lastAddedNavigationState; |
| 65 | 81 |
| 66 @end | 82 @end |
| 67 | 83 |
| 68 #endif // IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ | 84 #endif // IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ |
| OLD | NEW |