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::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) {
61 @selector(webState:didSubmitDocumentWithFormNamed:userInitiated:);
62 if ([observer_ respondsToSelector:selector]) {
63 [observer_ webState:web_state()
64 didSubmitDocumentWithFormNamed:form_name
65 userInitiated:user_initiated];
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,
76 SEL selector = @selector(webState:
77 didRegisterFormActivityWithFormNamed:
83 if ([observer_ respondsToSelector:selector]) {
84 [observer_ webState:web_state()
85 didRegisterFormActivityWithFormNamed:form_name
90 inputMissing:input_missing];
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:
101 if ([observer_ respondsToSelector:selector]) {
102 [observer_ webState:web_state()
103 requestAutocompleteForFormNamed:form_name
105 userInitiated:user_initiated];
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
121 [observer_ webStateDestroyed:web_state()];