hunspell: Cleanup to fix the header include guards under google/ directory.
[chromium-blink-merge.git] / ios / web / web_state / web_state_observer_bridge.mm
blob292470c79e8cdbd45869f02bea65a2f51cb57d04
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::DidStartLoading() {
34   SEL selector = @selector(webStateDidStartLoading:);
35   if ([observer_ respondsToSelector:selector]) {
36     [observer_ webStateDidStartLoading:web_state()];
37   }
40 void WebStateObserverBridge::DidStopLoading() {
41   SEL selector = @selector(webStateDidStopLoading:);
42   if ([observer_ respondsToSelector:selector]) {
43     [observer_ webStateDidStopLoading:web_state()];
44   }
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) {
74   SEL selector =
75       @selector(webState:didSubmitDocumentWithFormNamed:userInitiated:);
76   if ([observer_ respondsToSelector:selector]) {
77     [observer_ webState:web_state()
78         didSubmitDocumentWithFormNamed:form_name
79                          userInitiated:user_initiated];
80   }
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,
88     int key_code,
89     bool input_missing) {
90   SEL selector = @selector(webState:
91       didRegisterFormActivityWithFormNamed:
92                                  fieldName:
93                                       type:
94                                      value:
95                                    keyCode:
96                               inputMissing:);
97   if ([observer_ respondsToSelector:selector]) {
98     [observer_ webState:web_state()
99         didRegisterFormActivityWithFormNamed:form_name
100                                    fieldName:field_name
101                                         type:type
102                                        value:value
103                                      keyCode:key_code
104                                 inputMissing:input_missing];
105   }
108 void WebStateObserverBridge::FaviconUrlUpdated(
109     const std::vector<FaviconURL>& candidates) {
110   SEL selector = @selector(webState:didUpdateFaviconURLCandidates:);
111   if ([observer_ respondsToSelector:selector])
112     [observer_ webState:web_state() didUpdateFaviconURLCandidates:candidates];
115 void WebStateObserverBridge::WebStateDestroyed() {
116   SEL selector = @selector(webStateDestroyed:);
117   if ([observer_ respondsToSelector:selector]) {
118     // |webStateDestroyed:| may delete |this|, so don't expect |this| to be
119     // valid afterwards.
120     [observer_ webStateDestroyed:web_state()];
121   }
124 }  // namespace web