1 // Copyright 2014 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_WEB_STATE_WEB_CONTROLLER_OBSERVER_BRIDGE_H_
6 #define IOS_WEB_WEB_STATE_WEB_CONTROLLER_OBSERVER_BRIDGE_H_
10 #include "ios/web/public/web_state/web_state_observer.h"
12 @
class CRWWebController
;
13 @protocol CRWWebControllerObserver
;
17 class DictionaryValue
;
24 // This class allows to register a CRWWebControllerObserver instance as
25 // a WebStateObserver.
26 // It listens to WebStateObserver calls and forwards them to the underlying
27 // CRWWebControllerObserver.
28 // TODO(droger): Remove this class once all CRWWebControllerObserver have been
29 // converted to WebStateObserver and WebState::ScriptCommandCallback.
30 class WebControllerObserverBridge
: public WebStateObserver
{
32 // |web_controller_observer| and |web_controller| must not be nil, and must
33 // outlive this WebControllerObserverBridge.
34 WebControllerObserverBridge(
35 id
<CRWWebControllerObserver
> web_controller_observer
,
37 CRWWebController
* web_controller
);
39 ~WebControllerObserverBridge() override
;
41 // Gets the underlying CRWWebControllerObserver.
42 id
<CRWWebControllerObserver
> web_controller_observer() const {
43 return web_controller_observer_
;
47 // WebStateObserver implementation.
48 void PageLoaded(PageLoadCompletionStatus load_completion_status
) override
;
50 // Callback for script commands.
51 bool ScriptCommandReceived(const base::DictionaryValue
& value
,
53 bool user_is_interacting
);
55 id
<CRWWebControllerObserver
> web_controller_observer_
; // Weak.
56 CRWWebController
* web_controller_
; // Weak.
57 std::string script_command_callback_prefix_
;
59 DISALLOW_COPY_AND_ASSIGN(WebControllerObserverBridge
);
64 #endif // IOS_WEB_WEB_STATE_WEB_CONTROLLER_OBSERVER_BRIDGE_H_