Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(439)

Unified Diff: ios/web/web_state/ui/crw_wk_navigation_states.h

Issue 2601083003: [ios] Correctly determine last seen WKNavigation object. (Closed)
Patch Set: Addressed review comments. Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | ios/web/web_state/ui/crw_wk_navigation_states.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/web_state/ui/crw_wk_navigation_states.h
diff --git a/ios/web/web_state/ui/crw_wk_navigation_states.h b/ios/web/web_state/ui/crw_wk_navigation_states.h
new file mode 100644
index 0000000000000000000000000000000000000000..72dd02280d8ca3c299dd6444e763c195ea7f4af1
--- /dev/null
+++ b/ios/web/web_state/ui/crw_wk_navigation_states.h
@@ -0,0 +1,60 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_
+#define IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_
+
+#import <Foundation/Foundation.h>
+#import <WebKit/WebKit.h>
+
+namespace web {
+
+// State of in-flight WKNavigation objects.
+enum class WKNavigationState : int {
+ // WKNavigation returned from |loadRequest:|, |goToBackForwardListItem:|,
+ // |loadFileURL:allowingReadAccessToURL:|, |loadHTMLString:baseURL:|,
+ // |loadData:MIMEType:characterEncodingName:baseURL:|, |goBack|, |goForward|,
+ // |reload| or |reloadFromOrigin|.
+ REQUESTED = 1,
+ // WKNavigation passed to |webView:didStartProvisionalNavigation:|.
+ STARTED,
+ // WKNavigation passed to
+ // |webView:didReceiveServerRedirectForProvisionalNavigation:|.
+ REDIRECTED,
+ // WKNavigation passed to |webView:didFailProvisionalNavigation:|.
+ PROVISIONALY_FAILED,
+ // WKNavigation passed to |webView:didCommitNavigation:|.
+ COMMITTED,
+ // WKNavigation passed to |webView:didFinishNavigation:|.
+ FINISHED,
+ // WKNavigation passed to |webView:didFailNavigation:withError:|.
+ FAILED,
+};
+
+} // namespace web
+
+// Stores states for WKNavigation objects. Allows lookign up for last added
+// navigation object.
+@interface CRWWKNavigationStates : NSObject
+
+// Adds a new navigation if it was not added yet. If navigation was already
+// added then updates state for existing navigation. Updating state does not
+// affect the result of |lastAddedNavigation| method. New added navigations
+// should have either WKNavigationState::REQUESTED or WKNavigationState::STARTED
kkhorimoto 2017/01/04 00:13:57 Just noticed now, but this should be updated to al
Eugene But (OOO till 7-30) 2017/01/04 00:20:11 Done.
+// state. Passed |navigation| will be help as weak reference and will not be
+// retained. No-op if |navigation| is null.
+- (void)setState:(web::WKNavigationState)state
+ forNavigation:(WKNavigation*)navigation;
+
+// WKNavigation which was added the most recently via |setState:forNavigation:|.
+// Updating navigation state via |setState:forNavigation:| does not change the
+// last added navigation. Returns nil if there are no stored navigations.
+- (WKNavigation*)lastAddedNavigation;
+
+// Returns state of the given navigation or 0 if navigation does not exist.
kkhorimoto 2017/01/04 00:13:57 What is returned here using enum classes? Not sur
Eugene But (OOO till 7-30) 2017/01/04 00:20:11 0 of int type. Added |NONE = 0|.
+- (web::WKNavigationState)stateForNavigation:(WKNavigation*)navigation;
+
+@end
+
+#endif // IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller.mm ('k') | ios/web/web_state/ui/crw_wk_navigation_states.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698