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"
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];
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];
33 void WebStateObserverBridge::DidStartLoading() {
34 SEL selector = @selector(webStateDidStartLoading:);
35 if ([observer_ respondsToSelector:selector]) {
36 [observer_ webStateDidStartLoading:web_state()];
40 void WebStateObserverBridge::DidStopLoading() {
41 SEL selector = @selector(webStateDidStopLoading:);
42 if ([observer_ respondsToSelector:selector]) {
43 [observer_ webStateDidStopLoading:web_state()];
47 void WebStateObserverBridge::PageLoaded(
48 web::PageLoadCompletionStatus load_completion_status) {
49 SEL selector = @selector(webStateDidLoadPage:);
50 if ([observer_ respondsToSelector:selector])
51 [observer_ webStateDidLoadPage:web_state()];
54 void WebStateObserverBridge::InsterstitialDismissed() {
55 SEL selector = @selector(webStateDidDismissInterstitial:);
56 if ([observer_ respondsToSelector:selector])
57 [observer_ webStateDidDismissInterstitial:web_state()];
60 void WebStateObserverBridge::UrlHashChanged() {
61 SEL selector = @selector(webStateDidChangeURLHash:);
62 if ([observer_ respondsToSelector:selector])
63 [observer_ webStateDidChangeURLHash:web_state()];
66 void WebStateObserverBridge::HistoryStateChanged() {
67 SEL selector = @selector(webStateDidChangeHistoryState:);
68 if ([observer_ respondsToSelector:selector])
69 [observer_ webStateDidChangeHistoryState:web_state()];
72 void WebStateObserverBridge::DocumentSubmitted(const std::string& form_name,
73 bool user_initiated) {
75 @selector(webState:didSubmitDocumentWithFormNamed:userInitiated:);
76 if ([observer_ respondsToSelector:selector]) {
77 [observer_ webState:web_state()
78 didSubmitDocumentWithFormNamed:form_name
79 userInitiated:user_initiated];
83 void WebStateObserverBridge::FormActivityRegistered(
84 const std::string& form_name,
85 const std::string& field_name,
86 const std::string& type,
87 const std::string& value,
90 SEL selector = @selector(webState:
91 didRegisterFormActivityWithFormNamed:
97 if ([observer_ respondsToSelector:selector]) {
98 [observer_ webState:web_state()
99 didRegisterFormActivityWithFormNamed:form_name
104 inputMissing:input_missing];
108 void WebStateObserverBridge::AutocompleteRequested(const GURL& source_url,
109 const std::string& form_name,
110 bool user_initiated) {
111 SEL selector = @selector(webState:
112 requestAutocompleteForFormNamed:
115 if ([observer_ respondsToSelector:selector]) {
116 [observer_ webState:web_state()
117 requestAutocompleteForFormNamed:form_name
119 userInitiated:user_initiated];
123 void WebStateObserverBridge::FaviconUrlUpdated(
124 const std::vector<FaviconURL>& candidates) {
125 SEL selector = @selector(webState:didUpdateFaviconURLCandidates:);
126 if ([observer_ respondsToSelector:selector])
127 [observer_ webState:web_state() didUpdateFaviconURLCandidates:candidates];
130 void WebStateObserverBridge::WebStateDestroyed() {
131 SEL selector = @selector(webStateDestroyed:);
132 if ([observer_ respondsToSelector:selector]) {
133 // |webStateDestroyed:| may delete |this|, so don't expect |this| to be
135 [observer_ webStateDestroyed:web_state()];