Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / ios / web / public / web_state / web_state_observer_bridge.h
blob17b4a9f8275d253cec003adcb50481085b7d243f
1 // Copyright 2015 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.
5 #ifndef IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_OBSERVER_BRIDGE_H_
6 #define IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_OBSERVER_BRIDGE_H_
8 #import <Foundation/Foundation.h>
10 #include <string>
12 #import "base/ios/weak_nsobject.h"
13 #import "ios/web/public/web_state/web_state_observer.h"
15 class GURL;
17 // Observes page lifecyle events from Objective-C. To use as a
18 // web::WebStateObserver, wrap in a web::WebStateObserverBridge.
19 @protocol CRWWebStateObserver<NSObject>
20 @optional
22 // Invoked by WebStateObserverBridge::ProvisionalNavigationStarted.
23 - (void)webState:(web::WebState*)webState
24 didStartProvisionalNavigationForURL:(const GURL&)URL;
26 // Invoked by WebStateObserverBridge::NavigationItemCommitted.
27 - (void)webState:(web::WebState*)webState
28 didCommitNavigationWithDetails:
29 (const web::LoadCommittedDetails&)load_details;
31 // Invoked by WebStateObserverBridge::PageLoaded.
32 - (void)webStateDidLoadPage:(web::WebState*)webState;
34 // Invoked by WebStateObserverBridge::InterstitialDismissed.
35 - (void)webStateDidDismissInterstitial:(web::WebState*)webState;
37 // Invoked by WebStateObserverBridge::UrlHashChanged.
38 - (void)webStateDidChangeURLHash:(web::WebState*)webState;
40 // Invoked by WebStateObserverBridge::HistoryStateChanged.
41 - (void)webStateDidChangeHistoryState:(web::WebState*)webState;
43 // Invoked by WebStateObserverBridge::DocumentSubmitted.
44 - (void)webState:(web::WebState*)webState
45 didSubmitDocumentWithFormNamed:(const std::string&)formName
46 userInitiated:(BOOL)userInitiated;
48 // Invoked by WebStateObserverBridge::FormActivityRegistered.
49 // TODO(ios): Method should take data transfer object rather than parameters.
50 - (void)webState:(web::WebState*)webState
51 didRegisterFormActivityWithFormNamed:(const std::string&)formName
52 fieldName:(const std::string&)fieldName
53 type:(const std::string&)type
54 value:(const std::string&)value
55 keyCode:(int)keyCode
56 inputMissing:(BOOL)inputMissing;
58 // Invoked by WebStateObserverBridge::AutocompleteRequested.
59 - (void)webState:(web::WebState*)webState
60 requestAutocompleteForFormNamed:(const std::string&)formName
61 sourceURL:(const GURL&)sourceURL
62 userInitiated:(BOOL)userInitiated;
64 // Invoked by WebStateObserverBridge::FaviconUrlUpdated.
65 - (void)webState:(web::WebState*)webState
66 didUpdateFaviconURLCandidates:
67 (const std::vector<web::FaviconURL>&)candidates;
69 // Note: after |webStateDestroyed:| is invoked, the WebState being observed
70 // is no longer valid.
71 - (void)webStateDestroyed:(web::WebState*)webState;
73 // Invoked by WebStateObserverBridge::DidStopLoading.
74 - (void)webStateDidStopLoading:(web::WebState*)webState;
76 // Invoked by WebStateObserverBridge::DidStartLoading.
77 - (void)webStateDidStartLoading:(web::WebState*)webState;
79 @end
81 namespace web {
83 class WebState;
85 // Bridge to use an id<CRWWebStateObserver> as a web::WebStateObserver.
86 // Will be added/removed as an observer of the underlying WebState during
87 // construction/destruction. Instances should be owned by instances of the
88 // class they're bridging.
89 class WebStateObserverBridge : public web::WebStateObserver {
90 public:
91 WebStateObserverBridge(web::WebState* web_state,
92 id<CRWWebStateObserver> observer);
93 ~WebStateObserverBridge() override;
95 // web::WebStateObserver methods.
96 void ProvisionalNavigationStarted(const GURL& url) override;
97 void NavigationItemCommitted(
98 const LoadCommittedDetails& load_details) override;
99 void PageLoaded(
100 web::PageLoadCompletionStatus load_completion_status) override;
101 void InsterstitialDismissed() override;
102 void UrlHashChanged() override;
103 void HistoryStateChanged() override;
104 void DocumentSubmitted(const std::string& form_name,
105 bool user_initiated) override;
106 void FormActivityRegistered(const std::string& form_name,
107 const std::string& field_name,
108 const std::string& type,
109 const std::string& value,
110 int key_code,
111 bool input_missing) override;
112 void AutocompleteRequested(const GURL& source_url,
113 const std::string& form_name,
114 bool user_initiated) override;
115 void FaviconUrlUpdated(const std::vector<FaviconURL>& candidates) override;
116 void WebStateDestroyed() override;
117 void DidStartLoading() override;
118 void DidStopLoading() override;
120 private:
121 base::WeakNSProtocol<id<CRWWebStateObserver>> observer_;
122 DISALLOW_COPY_AND_ASSIGN(WebStateObserverBridge);
125 } // namespace web
127 #endif // IOS_WEB_PUBLIC_WEB_STATE_WEB_STATE_OBSERVER_BRIDGE_H_