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

Side by Side Diff: ios/web/web_state/ui/crw_wk_navigation_states.h

Issue 2835463002: Store NavigationIntext in CRWWKNavigationStates. (Closed)
Patch Set: Fixed compilation. Created 3 years, 7 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 unified diff | Download patch
OLDNEW
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. |navigation| will be held as a 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. |navigation| will be held
63 // as a weak reference and will not be retained. No-op if |navigation| is null.
64 - (void)setContext:(std::unique_ptr<web::NavigationContextImpl>)context
65 forNavigation:(WKNavigation*)navigation;
66
67 // Returns context if one was previously associated with given |navigation|.
68 // Returns null if |navigation| is null.
69 - (web::NavigationContextImpl*)contextForNavigation:(WKNavigation*)navigation;
70
56 // WKNavigation which was added the most recently via |setState:forNavigation:|. 71 // WKNavigation which was added the most recently via |setState:forNavigation:|.
57 // Updating navigation state via |setState:forNavigation:| does not change the 72 // Updating navigation state via |setState:forNavigation:| does not change the
58 // last added navigation. Returns nil if there are no stored navigations. 73 // last added navigation. Returns nil if there are no stored navigations.
59 - (WKNavigation*)lastAddedNavigation; 74 - (WKNavigation*)lastAddedNavigation;
60 75
61 // State of WKNavigation which was added the most recently via 76 // State of WKNavigation which was added the most recently via
62 // |setState:forNavigation:|. WKNavigationState::NONE if CRWWKNavigationStates 77 // |setState:forNavigation:|. WKNavigationState::NONE if CRWWKNavigationStates
63 // is empty. 78 // is empty.
64 - (web::WKNavigationState)lastAddedNavigationState; 79 - (web::WKNavigationState)lastAddedNavigationState;
65 80
66 @end 81 @end
67 82
68 #endif // IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_ 83 #endif // IOS_WEB_WEB_STATE_UI_CRW_WK_NAVIGATION_STATES_H_
OLDNEW
« no previous file with comments | « ios/web/web_state/navigation_context_impl.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