Supervised user whitelists: Cleanup
[chromium-blink-merge.git] / ios / web / web_state / web_state_observer_bridge.mm
blobc2028fe80c45220934c64826ceeb01fae0bd7e39
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 #import "ios/web/public/web_state/web_state_observer_bridge.h"
7 namespace web {
9 WebStateObserverBridge::WebStateObserverBridge(web::WebState* webState,
10                                                id<CRWWebStateObserver> observer)
11     : web::WebStateObserver(webState), observer_(observer) {
14 WebStateObserverBridge::~WebStateObserverBridge() {
17 void WebStateObserverBridge::ProvisionalNavigationStarted(const GURL& url) {
18   SEL selector = @selector(webState:didStartProvisionalNavigationForURL:);
19   if ([observer_ respondsToSelector:selector]) {
20     [observer_ webState:web_state() didStartProvisionalNavigationForURL:url];
21   }
24 void WebStateObserverBridge::NavigationItemCommitted(
25     const web::LoadCommittedDetails& load_detatils) {
26   SEL selector = @selector(webState:didCommitNavigationWithDetails:);
27   if ([observer_ respondsToSelector:selector]) {
28     [observer_ webState:web_state()
29         didCommitNavigationWithDetails:load_detatils];
30   }
33 void WebStateObserverBridge::PageLoaded(
34     web::PageLoadCompletionStatus load_completion_status) {
35   SEL selector = @selector(webStateDidLoadPage:);
36   if ([observer_ respondsToSelector:selector])
37     [observer_ webStateDidLoadPage:web_state()];
40 void WebStateObserverBridge::InsterstitialDismissed() {
41   SEL selector = @selector(webStateDidDismissInterstitial:);
42   if ([observer_ respondsToSelector:selector])
43     [observer_ webStateDidDismissInterstitial:web_state()];
46 void WebStateObserverBridge::UrlHashChanged() {
47   SEL selector = @selector(webStateDidChangeURLHash:);
48   if ([observer_ respondsToSelector:selector])
49     [observer_ webStateDidChangeURLHash:web_state()];
52 void WebStateObserverBridge::HistoryStateChanged() {
53   SEL selector = @selector(webStateDidChangeHistoryState:);
54   if ([observer_ respondsToSelector:selector])
55     [observer_ webStateDidChangeHistoryState:web_state()];
58 void WebStateObserverBridge::DocumentSubmitted(const std::string& form_name,
59                                                bool user_initiated) {
60   SEL selector =
61       @selector(webState:didSubmitDocumentWithFormNamed:userInitiated:);
62   if ([observer_ respondsToSelector:selector]) {
63     [observer_ webState:web_state()
64         didSubmitDocumentWithFormNamed:form_name
65                          userInitiated:user_initiated];
66   }
69 void WebStateObserverBridge::FormActivityRegistered(
70     const std::string& form_name,
71     const std::string& field_name,
72     const std::string& type,
73     const std::string& value,
74     int key_code,
75     bool input_missing) {
76   SEL selector = @selector(webState:
77       didRegisterFormActivityWithFormNamed:
78                                  fieldName:
79                                       type:
80                                      value:
81                                    keyCode:
82                               inputMissing:);
83   if ([observer_ respondsToSelector:selector]) {
84     [observer_ webState:web_state()
85         didRegisterFormActivityWithFormNamed:form_name
86                                    fieldName:field_name
87                                         type:type
88                                        value:value
89                                      keyCode:key_code
90                                 inputMissing:input_missing];
91   }
94 void WebStateObserverBridge::AutocompleteRequested(const GURL& source_url,
95                                                    const std::string& form_name,
96                                                    bool user_initiated) {
97   SEL selector = @selector(webState:
98       requestAutocompleteForFormNamed:
99                             sourceURL:
100                         userInitiated:);
101   if ([observer_ respondsToSelector:selector]) {
102     [observer_ webState:web_state()
103         requestAutocompleteForFormNamed:form_name
104                               sourceURL:source_url
105                           userInitiated:user_initiated];
106   }
109 void WebStateObserverBridge::FaviconUrlUpdated(
110     const std::vector<FaviconURL>& candidates) {
111   SEL selector = @selector(webState:didUpdateFaviconURLCandidates:);
112   if ([observer_ respondsToSelector:selector])
113     [observer_ webState:web_state() didUpdateFaviconURLCandidates:candidates];
116 void WebStateObserverBridge::WebStateDestroyed() {
117   SEL selector = @selector(webStateDestroyed:);
118   if ([observer_ respondsToSelector:selector]) {
119     // |webStateDestroyed:| may delete |this|, so don't expect |this| to be
120     // valid afterwards.
121     [observer_ webStateDestroyed:web_state()];
122   }
125 }  // namespace web